Advertisement
cgrunwald

JmpPatch

Aug 30th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. void JmpPatch(void *pDest, void *pSrc, int nNops = 0) {
  2.     DWORD OldProt;
  3.     VirtualProtect(pSrc, 5 + nNops, PAGE_EXECUTE_READWRITE, &OldProt);
  4.     *(char*)pSrc = (char)0xE9;
  5.     *(DWORD*)((DWORD)pSrc + 1) = (DWORD)pDest - (DWORD)pSrc - 5;
  6.     for (int i = 0; i < nNops; ++i) { *(BYTE*)((DWORD)pSrc + 5 + i) = 0x90; }
  7.     VirtualProtect(pSrc, 5 + nNops, OldProt, &OldProt);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement