Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*remote function hook*/
- DWORD addr_endframe = 0x00586E00; //to 0x00586EC4
- DWORD endframe_size = 0xC4;
- BYTE real_endframe_code[0xC4] = {0};
- BYTE noparray[0xC4] = {0x90};
- DWORD *moved_endframe = NULL;
- DWORD *hook_endframe = NULL;
- DWORD dwBytesWritten = NULL;
- ReadProcessMemory(mw2_proc, (LPVOID)addr_endframe, real_endframe_code, endframe_size, &dwBytesWritten);
- wprintf(L"Read real endframe function [size: %d], relocating...\n", endframe_size);
- moved_endframe = (DWORD*)VirtualAllocEx(mw2_proc, 0, endframe_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- WriteProcessMemory(mw2_proc, (LPVOID)moved_endframe, real_endframe_code, endframe_size, &dwBytesWritten);
- wprintf(L"Moved real endframe to %X. Bytes written: %d / %d\n", moved_endframe, dwBytesWritten, endframe_size);
- int codeSize = ((LPBYTE)nendframe_after - (LPBYTE)nendframe);
- hook_endframe = (DWORD*)VirtualAllocEx(mw2_proc, 0, codeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- WriteProcessMemory(mw2_proc, (LPVOID)hook_endframe, &nendframe, codeSize, &dwBytesWritten);
- wprintf(L"Wrote hook_endframe @ %X. Bytes written: %d / %d\n", hook_endframe, dwBytesWritten, codeSize);
- WriteProcessMemory(mw2_proc, (LPVOID)addr_endframe, &noparray, endframe_size, &dwBytesWritten); //Fill with NOP
- wprintf(L"Filled %X to %X with NOP. Bytes written: %d / %d\n", addr_endframe,
- addr_endframe + endframe_size, dwBytesWritten, endframe_size);
- BYTE opcode_moveax = 0xB8;
- BYTE new_endframe[] = {
- 0xB8, LOBYTE(LOWORD(hook_endframe)), HIBYTE(LOWORD(hook_endframe)),
- LOBYTE(HIWORD(hook_endframe)), HIBYTE(HIWORD(hook_endframe)), 0x90,
- 0xB8, LOBYTE(LOWORD(moved_endframe)), HIBYTE(LOWORD(moved_endframe)),
- LOBYTE(HIWORD(moved_endframe)), HIBYTE(HIWORD(moved_endframe)), 0x90
- };
- WriteProcessMemory(mw2_proc, (LPVOID)addr_endframe, new_endframe, sizeof(new_endframe), &dwBytesWritten);
- wprintf(L"Wrote new enframe @ %X. Bytes written: %d / %d\n", addr_endframe, dwBytesWritten, sizeof(new_endframe));
- /*remote function hook*/
Add Comment
Please, Sign In to add comment