From 51b952d8a3850a890a7b8bc71dcab6762f50b9f5 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 9 Dec 2014 23:51:07 +0100 Subject: [PATCH] Newsteam r2 exe support --- SAFix/SilentPatchSA.cpp | 86 ++++++++++++++++++++++++++++++++++++++++- SilentPatch/MemoryMgr.h | 37 +++++++++++------- 2 files changed, 107 insertions(+), 16 deletions(-) diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index 42b93aa..e35bb6c 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -3043,7 +3043,7 @@ void Patch_SA_Steam() InjectHook(0x5EDFD9, 0x5EE0FA, PATCH_JUMP); } -void Patch_SA_NewSteam() +void Patch_SA_NewSteam_r1() { using namespace MemoryVP::DynBase; @@ -3124,6 +3124,87 @@ void Patch_SA_NewSteam() Patch(0x73427A, &f43); } +void Patch_SA_NewSteam_r2() +{ + using namespace MemoryVP::DynBase; + + // Nazi EXE? + if ( *(DWORD*)DynBaseAddress(0x49F810) == 0x64EC8B55 ) + { + // Regular + + // No framedelay + InjectHook(0x54ECC6, DynBaseAddress(0x54ED0C), PATCH_JUMP); + Patch(0x54ED45, 0x4); + Nop(0x54ED47, 1); + + // Unlock 1.0/1.01 saves loading + Patch(0x5ED349, 0xE990); + + // Old .set files working again + static const DWORD dwSetVersion = 6; + Patch(0x5904CA, &dwSetVersion); + Patch(0x5907AD, 6); + Patch(0x53EC4A, 6); + + // Disable re-initialization of DirectInput mouse device by the game + Patch(0x58A881, 0xEB); + Patch(0x58AA67, 0xEB); + Patch(0x58AB49, 0xEB); + } + else + { + // Nazi + + // No framedelay + InjectHook(0x54EC06, DynBaseAddress(0x54EC4C), PATCH_JUMP); + Patch(0x54EC85, 0x4); + Nop(0x54EC87, 1); + + // Unlock 1.0/1.01 saves loading + Patch(0x5ED349, 0xE990); + + // Old .set files working again + static const DWORD dwSetVersion = 6; + Patch(0x5904DA, &dwSetVersion); + Patch(0x5907BD, 6); + Patch(0x53EB9A, 6); + + // Disable re-initialization of DirectInput mouse device by the game + Patch(0x58A7D1, 0xEB); + Patch(0x58A9B7, 0xEB); + Patch(0x58AA99, 0xEB); + } + + + // Unlocked widescreen resolutions + //Patch(0x779BAD, 0x607D); + Patch(0x779BC8, 0x697D); + Patch(0x7799D8, 0x9090117D); + Nop(0x779A56, 2); + Nop(0x7799DC, 2); + + // Make sure DirectInput mouse device is set non-exclusive (may not be needed?) + Nop(0x77AB6F, 1); + Patch(0x77AB70, 0x01B0); + + // Default resolution to native resolution + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + _snprintf(aNoDesktopMode, sizeof(aNoDesktopMode), "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x77A41F, desktop.right); + Patch(0x77A424, desktop.bottom); + Patch(0x77A47B, aNoDesktopMode); + + + // Proper aspect ratios + static const float f43 = 4.0f/3.0f, f54 = 5.0f/4.0f, f169 = 16.0f/9.0f; + Patch(0x73424B, &f169); + Patch(0x734267, &f54); + Patch(0x73427A, &f43); +} + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { @@ -3137,7 +3218,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) else if (*(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF || *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF) Patch_SA_11(); else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF) Patch_SA_Steam(); - else if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633) Patch_SA_NewSteam(); + else if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633) Patch_SA_NewSteam_r1(); + else if ( *(DWORD*)DynBaseAddress(0x858D51) == 0x3539F633) Patch_SA_NewSteam_r2(); else return FALSE; } diff --git a/SilentPatch/MemoryMgr.h b/SilentPatch/MemoryMgr.h index 0459491..b66ba2f 100644 --- a/SilentPatch/MemoryMgr.h +++ b/SilentPatch/MemoryMgr.h @@ -35,16 +35,10 @@ inline void* GetDummy() return &dwDummy; } -inline ptrdiff_t GetModule() -{ - static HMODULE hModule = GetModuleHandle(nullptr); - return (ptrdiff_t)hModule; -} - template inline AT DynBaseAddress(AT address) { - return GetModule() - 0x400000 + address; + return (ptrdiff_t)GetModuleHandle(nullptr) - 0x400000 + address; } #if defined SILENTPATCH_III_VER @@ -116,37 +110,49 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam) if ( *bVer == -1 ) { - if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633 ) - { - *bVer = 3; - *bEuropean = false; - } - - else if ( *(DWORD*)DynBaseAddress(0x82457C) == 0x94BF ) + if ( *(DWORD*)DynBaseAddress(0x82457C) == 0x94BF ) { + // 1.0 US *bVer = 0; *bEuropean = false; } else if ( *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF ) { + // 1.0 EU *bVer = 0; *bEuropean = true; } else if ( *(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF ) { + // 1.01 US *bVer = 1; *bEuropean = false; } else if ( *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF ) { + // 1.01 EU *bVer = 1; *bEuropean = true; } else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF ) { + // 3.0 *bVer = 2; *bEuropean = false; } + + else if ( *(DWORD*)DynBaseAddress(0x858D21) == 0x3539F633 ) + { + // newsteam r1 + *bVer = 3; + *bEuropean = false; + } + else if ( *(DWORD*)DynBaseAddress(0x858D51) == 0x3539F633 ) + { + // newsteam r2 + *bVer = 4; + *bEuropean = false; + } } switch ( *bVer ) @@ -177,6 +183,9 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam) case 3: // TODO: DO return (T)GetDummy(); + case 4: + // TODO: DO + return (T)GetDummy(); default: assert(address10); // Adjust to EU if needed