Skip to content

Commit

Permalink
bf2142 patches
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 committed Dec 8, 2023
1 parent 1a48a80 commit 50dde3f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
41 changes: 41 additions & 0 deletions include/game_bf2142.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 50dde3f

Please sign in to comment.