Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


help "CreateRemoteThread Inject Dll ErrorCode C0000005&

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
riceworm
How do I cheat?
Reputation: 0

Joined: 27 Jul 2013
Posts: 5

PostPosted: Sat Aug 17, 2013 8:30 am    Post subject: help "CreateRemoteThread Inject Dll ErrorCode C0000005& Reply with quote

this is my code :
win7/64+delphi xe2

Dll:

library testdll;
uses

Windows,
Messages,
SysUtils;

procedure EntryPoint(Reason: dword); stdcall;
begin
if Reason = DLL_PROCESS_ATTACH
then begin
MessageBox(0, 'omg injection!!!', 'Very HappyVery HappyD:DVery Happy', 0);
end;
end;

begin
DLLProc := @EntryPoint;
EntryPoint(DLL_PROCESS_ATTACH);
end.

exe:
procedure TfrmMain.btnInjectClick(Sender: TObject);
var BytesWritten: SIZE_T;
PID, Process, Thread, ThreadId, hKernel: dword;
pLoadLibrary, Paramaters: pointer;
DLL: AnsiString;
NtCreateThreadEx: TNtCreateThreadEx;
begin
//DLLName=testdll.dll
DLL :=ExtractFilePath(ParamStr(0)) + DLLName;
PID := GetCurrentProcessId;

Process := OpenProcess(PROCESS_ALL_ACCESS,False,PID);
Paramaters := VirtualAllocEx(Process,nil,Length(DLL),MEM_COMMIT,PAGE_EXECUTE_READWRITE);
WriteProcessMemory(Process,Paramaters,PAnsiChar(DLL),Length(DLL),BytesWritten);

hKernel := GetModuleHandle('KERNEL32.DLL');
pLoadLibrary := GetProcAddress(hKernel,'LoadLibraryA');
Thread := CreateRemoteThread(Process,nil,0,pLoadLibrary,Paramaters,0,ThreadId);
WaitForSingleObject(Thread, INFINITE);
VirtualFreeEx(Process,Paramaters,0,MEM_RELEASE);

CloseHandle(Thread);
CloseHandle(Process);
end;


inject dll is ok ,and show MessageBox,but application get exception ,error code is $C0000005,can any body tell me why ?
Back to top
View user's profile Send private message
riceworm
How do I cheat?
Reputation: 0

Joined: 27 Jul 2013
Posts: 5

PostPosted: Sat Aug 17, 2013 6:41 pm    Post subject: Reply with quote

Sad
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Aug 18, 2013 9:27 am    Post subject: Reply with quote

Check your return values for all the API to see whats failing first. Given that you are using 'PROCESS_ALL_ACCESS' I'd assume you aren't even getting a handle.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites