procedure InjectDll(PID: dword;
DLL: pChar);
var
BytesWritten, hProcess, hThread, TID: Cardinal;
Parameters: pointer;
pThreadStartRoutine: Pointer;
begin
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, PID);
Parameters := VirtualAllocEx( hProcess,
nil, Length(
DLL)[u]+1[/u], MEM_COMMIT[u]
or MEM_RESERVE[/u], PAGE_READWRITE);
WriteProcessMemory(hProcess,Parameters,Pointer(
DLL),Length(
DLL)[u]+1[/u],BytesWritten);
pThreadStartRoutine := GetProcAddress(GetModuleHandle('
KERNEL32.DLL'), '
LoadLibraryA');
hThread := CreateRemoteThread([u]h[/u]Process,
nil, 0, pThreadStartRoutine, Parameters, 0, TID);
CloseHandle(hProcess);
end;