Guest User

Untitled

a guest
Jul 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. procedure Inject(ProcessHandle: longword; EntryPoint: pointer);
  2. var
  3. Module, NewModule: Pointer;
  4. Size, BytesWritten, TID: longword;
  5. begin
  6. Module := Pointer(GetModuleHandle(nil));
  7. Size := PImageOptionalHeader(Pointer(integer(Module) + PImageDosHeader(Module)._lfanew + SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage;
  8. VirtualFreeEx(ProcessHandle, Module, 0, MEM_RELEASE);
  9. NewModule := VirtualAllocEx(ProcessHandle, Module, Size, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  10. WriteProcessMemory(ProcessHandle, NewModule, Module, Size, BytesWritten);
  11. CreateRemoteThread(ProcessHandle, nil, 0, EntryPoint, Module, 0, TID);
  12. end;
Add Comment
Please, Sign In to add comment