Çıktı şu şekilde :
https://ibb.co/k8XrFR
pTargetMemory: True
pLoadLibraryA: True
writtenBytes: 291
TID : 5460
Exit Code : 53608448
Last Error : 0
LastErrorMsg: The operation completed successfully.
Hiç hata yok ama dll inject olmuyor.
Kullandığım inject fonksiyonu
Kod: Tümünü seç
Function InjectDll(Process: dword; ModulePath: PChar): boolean;
var
Memory:pointer;
Code: dword;
BytesWritten: dword;
ThreadId: dword;
hThread: dword;
hKernel32: dword;
Inject: packed record
PushCommand:byte;
PushArgument:DWORD;
CallCommand:WORD;
CallAddr:DWORD;
PushExitThread:byte;
ExitThreadArg:dword;
CallExitThread:word;
CallExitThreadAddr:DWord;
AddrLoadLibrary:pointer;
AddrExitThread:pointer;
LibraryName:array[0..MAX_PATH] of char;
end;
begin
Result := false;
Memory := VirtualAllocEx(Process, nil, sizeof(Inject),
MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if Memory = nil then Exit;
Code := dword(Memory);
Inject.PushCommand := $68;
inject.PushArgument := code + $1E;
inject.CallCommand := $15FF;
inject.CallAddr := code + $16;
inject.PushExitThread := $68;
inject.ExitThreadArg := 0;
inject.CallExitThread := $15FF;
inject.CallExitThreadAddr := code + $1A;
hKernel32 := GetModuleHandle('kernel32.dll');
inject.AddrLoadLibrary := GetProcAddress(hKernel32, 'LoadLibraryA');
inject.AddrExitThread := GetProcAddress(hKernel32, 'ExitThread');
lstrcpy(@inject.LibraryName, ModulePath);
WriteProcessMemory(Process, Memory, @inject, sizeof(inject), BytesWritten);
hThread := CreateRemoteThread(Process, nil, 0, Memory, nil, 0, ThreadId);
if hThread = 0 then Exit;
CloseHandle(hThread);
Result := True;
// Debug- Bilgisi
ShowMessage('pTargetMemory: ' + BoolToStr(Memory<>nil, true) + sLineBreak +
'pLoadLibraryA: ' + BoolToStr(ModulePath<>nil, true) + sLineBreak +
'writtenBytes: ' + IntToStr(BytesWritten) + sLineBreak +
'TID: ' + IntToStr(ThreadId) + sLineBreak +
'Exit Code: ' + IntToStr(Code) + sLineBreak +
'LastError: ' + IntToStr(GetLastError) + sLineBreak +
'LastErrorMsg: ' + SysErrorMessage(GetLastError)
);
end;
Kod: Tümünü seç
procedure TForm1.Button2Click(Sender: TObject);
begin
PDosya := GetProcessId('Project1.exe');
PDosya :=OpenProcess(PROCESS_ALL_ACCESS,False,PDosya);
InjectDll(PDosya, PAnsiChar(MyPath+'kontol.dll'));
end;