riceworm How do I cheat?
Reputation: 0
Joined: 27 Jul 2013 Posts: 5
|
Posted: Sat Aug 17, 2013 8:30 am Post subject: help "CreateRemoteThread Inject Dll ErrorCode C0000005& |
|
|
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!!!', ' D:D ', 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 ?
|
|