From 50dde3f3e7c14cb515ffd20f0c9f909e3ee664bb Mon Sep 17 00:00:00 2001 From: anzz1 Date: Fri, 8 Dec 2023 19:02:55 +0200 Subject: [PATCH] bf2142 patches --- dllmain.c | 3 +++ include/game_bf2142.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 include/game_bf2142.h diff --git a/dllmain.c b/dllmain.c index 470ba9c..cd48181 100644 --- a/dllmain.c +++ b/dllmain.c @@ -47,6 +47,7 @@ #include "include/game_mua.h" #include "include/game_sacrifice.h" #include "include/game_nolf.h" + #include "include/game_bf2142.h" #endif // !_WIN64 #include "include/picoupnp.h" @@ -281,6 +282,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) { patch_sacrifice(); } else if (!__stricmp(p, "nolfserv.exe")) { // No One Lives Forever (Server) patch_nolf_srv(); + } else if (!__stricmp(p, "bf2142.exe")) { // Battlefield 2142 + patch_bf2142(); } else if (!__stricmp(p, "serioussam.exe") || !__stricmp(p, "sam2.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam 1 & 2 force_bind_ip = 0; patch_sam(); diff --git a/include/game_bf2142.h b/include/game_bf2142.h new file mode 100644 index 0000000..fe123c7 --- /dev/null +++ b/include/game_bf2142.h @@ -0,0 +1,41 @@ +// game_bf2142.h + +#ifndef __GAME_BF2142_H +#define __GAME_BF2142_H + +#include "include/global.h" + +__forceinline static void bf2142_disable_cert_validation(void) { + WORD search[] = {0x81,_ANY,0xEE,0x0F,0x00,0x00,0x83,_ANY,0x15,0x8B}; + BYTE patch[] = {0xB8,0x15,0x00,0x00,0x00}; + + BYTE* ptr = find_pattern_mem_wildcard(0, search, search + 9, TRUE); + if (ptr) + write_mem(ptr+6, patch, 5); +} + +__forceinline static void bf2142_patch_error_neg_206(void) { + BYTE search[] = {0xFF,0x50,0x14,0x8A,0x46,0x18,0x84,0xC0,0x74,0x29}; + BYTE patch[] = {0xEB,0x2E,0x90}; + + BYTE* ptr = find_pattern_mem(0, search, search + 9, TRUE); + if (ptr) + write_mem(ptr+3, patch, 3); +} + +__forceinline static void bf2142_fix_delete_soldier_hang(void) { + BYTE search[] = {0xFF,0x15,0xCC,0xD0,0x90,0x00,0x85,0xC0,0x0F,0x85,0x9D,0xFE,0xFF,0xFF}; + BYTE patch[] = {0xEB,0x2E,0x90}; + + BYTE* ptr = find_pattern_mem(0, search, search + 13, TRUE); + if (ptr) + nop_mem(ptr+8, 6); +} + +__noinline static void patch_bf2142() { + bf2142_disable_cert_validation(); + bf2142_patch_error_neg_206(); + bf2142_fix_delete_soldier_hang(); +} + +#endif // __GAME_BF2142_H