captmicro

Untitled

Jun 30th, 2010
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. /*remote function hook*/
  2.     DWORD addr_endframe = 0x00586E00; //to 0x00586EC4
  3.     DWORD endframe_size = 0xC4;
  4.     BYTE real_endframe_code[0xC4] = {0};
  5.     BYTE noparray[0xC4] = {0x90};
  6.     DWORD *moved_endframe = NULL;
  7.     DWORD *hook_endframe = NULL;
  8.     DWORD dwBytesWritten = NULL;
  9.  
  10.     ReadProcessMemory(mw2_proc, (LPVOID)addr_endframe, real_endframe_code, endframe_size, &dwBytesWritten);
  11.     wprintf(L"Read real endframe function [size: %d], relocating...\n", endframe_size);
  12.     moved_endframe = (DWORD*)VirtualAllocEx(mw2_proc, 0, endframe_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  13.     WriteProcessMemory(mw2_proc, (LPVOID)moved_endframe, real_endframe_code, endframe_size, &dwBytesWritten);
  14.     wprintf(L"Moved real endframe to %X. Bytes written: %d / %d\n", moved_endframe, dwBytesWritten, endframe_size);
  15.  
  16.     int codeSize = ((LPBYTE)nendframe_after - (LPBYTE)nendframe);
  17.     hook_endframe = (DWORD*)VirtualAllocEx(mw2_proc, 0, codeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  18.     WriteProcessMemory(mw2_proc, (LPVOID)hook_endframe, &nendframe, codeSize, &dwBytesWritten);
  19.     wprintf(L"Wrote hook_endframe @ %X. Bytes written: %d / %d\n", hook_endframe, dwBytesWritten, codeSize);
  20.  
  21.     WriteProcessMemory(mw2_proc, (LPVOID)addr_endframe, &noparray, endframe_size, &dwBytesWritten); //Fill with NOP
  22.     wprintf(L"Filled %X to %X with NOP. Bytes written: %d / %d\n", addr_endframe,
  23.         addr_endframe + endframe_size, dwBytesWritten, endframe_size);
  24.  
  25.     BYTE opcode_moveax = 0xB8;
  26.     BYTE new_endframe[] = {
  27.         0xB8, LOBYTE(LOWORD(hook_endframe)), HIBYTE(LOWORD(hook_endframe)),
  28.         LOBYTE(HIWORD(hook_endframe)), HIBYTE(HIWORD(hook_endframe)), 0x90,
  29.  
  30.         0xB8, LOBYTE(LOWORD(moved_endframe)), HIBYTE(LOWORD(moved_endframe)),
  31.         LOBYTE(HIWORD(moved_endframe)), HIBYTE(HIWORD(moved_endframe)), 0x90
  32.     };
  33.  
  34.     WriteProcessMemory(mw2_proc, (LPVOID)addr_endframe, new_endframe, sizeof(new_endframe), &dwBytesWritten);
  35.     wprintf(L"Wrote new enframe @ %X. Bytes written: %d / %d\n", addr_endframe, dwBytesWritten, sizeof(new_endframe));
  36.     /*remote function hook*/
Add Comment
Please, Sign In to add comment