Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure Inject(ProcessHandle: longword; EntryPoint: pointer);
- var
- Module, NewModule: Pointer;
- Size, BytesWritten, TID: longword;
- begin
- Module := Pointer(GetModuleHandle(nil));
- Size := PImageOptionalHeader(Pointer(integer(Module) + PImageDosHeader(Module)._lfanew + SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage;
- VirtualFreeEx(ProcessHandle, Module, 0, MEM_RELEASE);
- NewModule := VirtualAllocEx(ProcessHandle, Module, Size, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
- WriteProcessMemory(ProcessHandle, NewModule, Module, Size, BytesWritten);
- CreateRemoteThread(ProcessHandle, nil, 0, EntryPoint, Module, 0, TID);
- end;
Add Comment
Please, Sign In to add comment