Advertisement
momo5502

MW2 177

Mar 23rd, 2014
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.77 KB | None | 0 0
  1. // ==========================================================
  2. // MW2 mp
  3. //
  4. // Component: IW4SP
  5. // Sub-component: clientdll
  6. // Purpose: Patches for multiplayer version 177
  7. //
  8. // Initial author: momo5502
  9. // Started: 2014-02-15
  10. // ==========================================================
  11.  
  12. #include "StdInc.h"
  13.  
  14. void PatchMW2_Steam();
  15. void* ReallocateAssetPool(int type, unsigned int newSize);
  16.  
  17. DWORD SteamUserStuff177 = 0x47BDA0;
  18. DWORD returnSuccess177 = 0x451169;
  19. DWORD otherStuff177 = 0x42B210;
  20.  
  21. void __declspec(naked) steamInitPatch177()
  22. {
  23.     __asm
  24.     {
  25.         call SteamUserStuff177
  26.         test al, al
  27.         jz returnSafe
  28.         jmp returnSuccess
  29.  
  30. returnSuccess:
  31.         call otherStuff177
  32.         test al, al
  33.         jz returnSafe
  34.         jmp returnSuccess177
  35.  
  36. returnSafe:
  37.         mov al, 1
  38.         retn
  39.     }
  40. }
  41.  
  42. cmd_function_t Cmd_OpenMenu;
  43. void Cmd_OpenMenu_f()
  44. {
  45.     if (Cmd_Argc() != 2)
  46.     {
  47.         Com_Printf(0, "USAGE: openmenu <menu name>\n");
  48.         return;
  49.     }
  50.     char* menu = Cmd_Argv(1);
  51.     __asm
  52.     {
  53.         push menu
  54.         push 62E2858h
  55.         mov eax, 4CCE60h
  56.         call eax
  57.     }
  58. }
  59.  
  60. void PatchMW2_FFHash()
  61. {
  62.     // basic checks (hash jumps, both normal and playlist)
  63.     *(WORD*)0x5B97A3 = 0x9090;
  64.     *(WORD*)0x5BA493 = 0x9090;
  65.  
  66.     *(WORD*)0x5B991C = 0x9090;
  67.     *(WORD*)0x5BA60C = 0x9090;
  68.  
  69.     *(WORD*)0x5B97B4 = 0x9090;
  70.     *(WORD*)0x5BA4A4 = 0x9090;
  71.  
  72.     // some other, unknown, check
  73.     *(BYTE*)0x5B9912 = 0xB8;
  74.     *(DWORD*)0x5B9913 = 1;
  75.  
  76.     *(BYTE*)0x5BA602 = 0xB8;
  77.     *(DWORD*)0x5BA603 = 1;
  78.  
  79.     if (IsDebuggerPresent())
  80.     {
  81.         // dirty disk breakpoint
  82.         *(BYTE*)0x4CF7F0 = 0xCC;
  83.     }
  84. }
  85.  
  86. void PatchMW2_177()
  87. {
  88.     version = 177;
  89.  
  90.     // Need to clean these up
  91.     Cmd_AddCommand = (Cmd_AddCommand_t)0x470090;
  92.     Com_Printf = (Com_Printf_t)0x402500;
  93.     R_RegisterFont = (R_RegisterFont_t)0x505670;
  94.     R_AddCmdDrawText = (R_AddCmdDrawText_t)0x509D80;
  95.     Dvar_RegisterBool = (Dvar_RegisterBool_t)0x4CE1A0;
  96.     Field_Clear = (Field_Clear_t)0x437EB0;
  97.     Com_Milliseconds = (Com_Milliseconds_t)0x42A660;
  98.     CL_IsCgameInitialized = (CL_IsCgameInitialized_t)0x43EB20;
  99.     Dvar_FindVar = (Dvar_FindVar_t)0x4D5390;
  100.     DB_LoadXAssets = (DB_LoadXAssets_t)0x4E5930;
  101.     FS_WriteFile = (FS_WriteFile_t)0x426450;
  102.     FS_ReadFile = (FS_ReadFile_t)0x4F4B90;
  103.     FS_FreeFile = (FS_FreeFile_t)0x4416B0;
  104.  
  105.     imageVersionCheckHookLoc = 0x53A456;
  106.     drawDevStuffHookLoc = 0x5ACB99;
  107.     zoneLoadHookLoc = 0x4D7378;
  108.     loadGameOverlayHookLoc = 0x60BE51;
  109.     initializeRenderer = 0x4A6A70;
  110.     SteamFriendsLoc = 0x6D75EC;
  111.  
  112.     language = (char*)0x649E748;
  113.     dvarName = (dvar_t**)0xB2C680;
  114.  
  115.     cmd_id = (DWORD*)0x1AAC5D0;
  116.     cmd_argc = (DWORD*)0x1AAC614;
  117.     cmd_argv = (DWORD**)0x1AAC634;
  118.  
  119.     PatchMW2_Steam();
  120.    
  121.     // Extdll stuff
  122.     PatchMW2_FifthInfinity();
  123.     PatchMW2_T6Clips();
  124.     PatchMW2_CryptoFiles();
  125.  
  126.     Cmd_AddCommand("openmenu", Cmd_OpenMenu_f, &Cmd_OpenMenu, 0);
  127.  
  128.     // Ignore DVAR error
  129.     nop(0x5EC371, 5);
  130.     nop(0x5EC44E, 5);
  131.     nop(0x5EC4FA, 5);
  132.     nop(0x5EC5A7, 5);
  133.  
  134.     // protocol version (workaround for hacks)
  135.     *(int*)0x4FB501 = PROTOCOL; // was 8E
  136.  
  137.     // protocol command
  138.     *(int*)0x4D36A9 = PROTOCOL; // was 8E
  139.     *(int*)0x4D36AE = PROTOCOL; // was 8E
  140.     *(int*)0x4D36B3 = PROTOCOL; // was 8E
  141.  
  142.     // Master server
  143.     strcpy((char*)0x6D9CBC, MASTER_SERVER);
  144.  
  145.     // Entirely remove steam support... we don't want you to get banned :D
  146.     *(WORD*)0x45114E = 0x01B0;
  147.     nop(0x451145, 5);
  148.     call(0x451160, steamInitPatch177, PATCH_JUMP);
  149.  
  150.     // external console
  151.     nop(0x60BB58, 11);
  152.  
  153.     // SteamNetworking stuff
  154.     *(BYTE*)0x4E6650 = 0xC3;
  155.  
  156.     // Stats stuff
  157.     *(BYTE*)0x44AAF0 = 0xC3;
  158.     *(BYTE*)0x467CC0 = 0xC3;
  159.  
  160.     // IDK what this does, could be important though...
  161.     nop(0x593A1A, 3);
  162.     nop(0x593A52, 2);
  163.     //nop(0x593A6B, 2);
  164.  
  165.     // This looks dangerous to patch
  166.     nop(0x594260, 5);
  167.  
  168.     // No improper quit popup
  169.     *(BYTE*)0x4113BB = 0xEB;
  170.  
  171.     // Ignore popup_getting_data (need to pix the playlist stuff instead of patching this)
  172.     *(BYTE*)0x473829 = 0xEB;
  173.  
  174.     // Let's assume we're online and we call ourself 'STEAM'
  175.     *(BYTE*)0x4FC2D8 = 0xEB;
  176.     *(BYTE*)0x4FC2F4 = 0xEB;
  177.     *(BYTE*)0x649D6F0 = 1;
  178.  
  179.     // m2demo stuff
  180.     *(DWORD*)0x6431D1 = (DWORD)"data";
  181.  
  182.     // Disable 'x' commands (except UPNP, that should be added lateron)
  183.     //nop(0x4059E5, 5);
  184.  
  185.     // alt-tab support
  186.     *(BYTE*)0x45ACE0 = 0xB0;
  187.     *(BYTE*)0x45ACE1 = 0x01;
  188.     *(BYTE*)0x45ACE2 = 0xC3;
  189.  
  190.     // xblive_rankedmatch
  191.     *(DWORD*)0x420A34 = DVAR_FLAG_NONE;
  192.  
  193.     // cg_fov
  194.     *(BYTE*)0x4F8E35 = DVAR_FLAG_SAVED;
  195.     *(float*)0x6E5788 = 90.0f;
  196.  
  197.     // remove fs_game check for moddable rawfiles - allows non-fs_game to modify rawfiles
  198.     *(WORD*)0x61AB76 = 0x9090;
  199.  
  200.     // remove limit on IWD file loading
  201.     //memset((void*)0x643B94, 0x90, 6);
  202.     *(BYTE*)0x642BF3 = 0xEB;
  203.  
  204.     // Force debug logging
  205.     nop(0x4AA89F, 2);
  206.     nop(0x4AA8A1, 6);
  207.  
  208.     // Configstring stuff
  209.     *(BYTE*)0x5AC2C3 = 0xEB; // CL_ParseGamestate
  210.  
  211.     // Test
  212.     ReallocateAssetPool(ASSET_TYPE_WEAPON, 2400);
  213.  
  214.     // Hide console
  215.     FreeConsole();
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement