#include #include // cod4 1.7 mp hack for geforce fx 5x00 size_t offset = 0x1f36f5; unsigned char const newBytes[] = { 0x81, 0x4b, 0x20, 0x00, 0x00, 0x02, 0x00, // or dword [ebx+0x20], 0x20000 0x5f, // pop edi 0x5e, // pop esi 0x5d, // pop ebp 0x5b, // pop ebx 0xc3 }; // ret unsigned char const oldBytes[] = { 0x7d, 0x2a, 0x6a, 0x64, 0xff, 0x15, 0xb8, //orig 0x11, 0x69, 0x00, 0x83, 0xc7 }; int main( void ) { HANDLE h = CreateFile( L"iw3mp.exe", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0 ); unsigned char buf[sizeof(newBytes)]; DWORD crap; if (INVALID_HANDLE_VALUE == h) { printf( "failed opening iw3mp.exe -- error=%x\n", GetLastError() ); return 1; } SetFilePointer( h, offset, 0, FILE_BEGIN ); ReadFile( h, buf, sizeof(buf), &crap, 0 ); if (!memcmp( buf, newBytes, sizeof(newBytes) )) { printf( "patch already applied.\n" ); return 2; } if (memcmp( buf, oldBytes, sizeof(oldBytes) )) { printf( "wrong file -- requires cod4 1.7\n" ); return 3; } SetFilePointer( h, offset, 0, FILE_BEGIN ); WriteFile( h, newBytes, sizeof(buf), &crap, 0 ); printf( "patched %u bytes at 0x%x\n", sizeof(buf), offset ); CloseHandle( h ); return 0; }