Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*remote function hook*/
- LPVOID addr_endframe = (LPVOID)0x00586E00; //to 0x00586EC4
- DWORD endframe_size = 0xC4;
- BYTE real_endframe_code[0xC4] = {0};
- BYTE noparray[0xC4] = {0};
- for (int tidx = 0; tidx < 0xC4; tidx++) { noparray[tidx] = 0x90; }
- LPVOID moved_endframe = NULL;
- LPVOID hook_endframe = NULL;
- DWORD dwBytesWritten = NULL;
- /*no idea why these addresses arent in iw4mp.exe, ReadProcessMemory on both return the right values*/
- ReadProcessMemory(mw2_proc, addr_endframe, real_endframe_code, endframe_size, &dwBytesWritten);
- wprintf(L"Read real endframe function [size: %d], relocating...\n", endframe_size);
- moved_endframe = VirtualAllocEx(mw2_proc, 0, endframe_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- VirtualProtectEx(mw2_proc, moved_endframe, endframe_size, PAGE_EXECUTE_READWRITE, NULL);
- WriteProcessMemory(mw2_proc, moved_endframe, real_endframe_code, endframe_size, &dwBytesWritten);
- wprintf(L"Moved real endframe to %X. Bytes written: %d / %d\n", (DWORD)moved_endframe, dwBytesWritten, endframe_size);
- int codeSize = ((LPBYTE)nendframe_after - (LPBYTE)nendframe);
- hook_endframe = VirtualAllocEx(mw2_proc, 0, codeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- VirtualProtectEx(mw2_proc, hook_endframe, codeSize, PAGE_EXECUTE_READWRITE, NULL);
- WriteProcessMemory(mw2_proc, hook_endframe, &nendframe, codeSize, &dwBytesWritten);
- wprintf(L"Wrote hook_endframe @ %X. Bytes written: %d / %d\n", (DWORD)hook_endframe, dwBytesWritten, codeSize);
- /*no idea why these addresses aren't in iw4mp.exe, ReadProcessMemory on both return the right values*/
- WriteProcessMemory(mw2_proc, addr_endframe, &noparray, endframe_size, &dwBytesWritten); //Fill with NOP
- wprintf(L"Filled %X to %X with NOP. Bytes written: %d / %d\n", (DWORD)addr_endframe,
- (DWORD)addr_endframe + endframe_size, dwBytesWritten, endframe_size);
- *BYTE new_endframe[] = {
- //MOV EAX, <hook_endframe>
- //CALL EAX
- 0xB8, LOBYTE(LOWORD(hook_endframe)), HIBYTE(LOWORD(hook_endframe)),
- LOBYTE(HIWORD(hook_endframe)), HIBYTE(HIWORD(hook_endframe)), 0x90,
- 0xFF, 0xD0,
- //MOV EAX, <moved_endframe>
- //CALL EAX
- 0xB8, LOBYTE(LOWORD(moved_endframe)), HIBYTE(LOWORD(moved_endframe)),
- LOBYTE(HIWORD(moved_endframe)), HIBYTE(HIWORD(moved_endframe)), 0x90,
- 0xFF, 0xD0,
- //RETN
- 0xC3
- };
- WriteProcessMemory(mw2_proc, addr_endframe, new_endframe, sizeof(new_endframe), &dwBytesWritten);
- wprintf(L"Wrote new enframe @ %X. Bytes written: %d / %d\n", (DWORD)addr_endframe, dwBytesWritten, sizeof(new_endframe));
- /*remote function hook*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement