Newsteam r2 exe support

This commit is contained in:
Silent 2014-12-09 23:51:07 +01:00
parent 4590fe17e5
commit 51b952d8a3
2 changed files with 107 additions and 16 deletions

View file

@ -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<const void*>(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<BYTE>(0x54ED45, 0x4);
Nop(0x54ED47, 1);
// Unlock 1.0/1.01 saves loading
Patch<WORD>(0x5ED349, 0xE990);
// Old .set files working again
static const DWORD dwSetVersion = 6;
Patch<const void*>(0x5904CA, &dwSetVersion);
Patch<BYTE>(0x5907AD, 6);
Patch<BYTE>(0x53EC4A, 6);
// Disable re-initialization of DirectInput mouse device by the game
Patch<BYTE>(0x58A881, 0xEB);
Patch<BYTE>(0x58AA67, 0xEB);
Patch<BYTE>(0x58AB49, 0xEB);
}
else
{
// Nazi
// No framedelay
InjectHook(0x54EC06, DynBaseAddress(0x54EC4C), PATCH_JUMP);
Patch<BYTE>(0x54EC85, 0x4);
Nop(0x54EC87, 1);
// Unlock 1.0/1.01 saves loading
Patch<WORD>(0x5ED349, 0xE990);
// Old .set files working again
static const DWORD dwSetVersion = 6;
Patch<const void*>(0x5904DA, &dwSetVersion);
Patch<BYTE>(0x5907BD, 6);
Patch<BYTE>(0x53EB9A, 6);
// Disable re-initialization of DirectInput mouse device by the game
Patch<BYTE>(0x58A7D1, 0xEB);
Patch<BYTE>(0x58A9B7, 0xEB);
Patch<BYTE>(0x58AA99, 0xEB);
}
// Unlocked widescreen resolutions
//Patch<WORD>(0x779BAD, 0x607D);
Patch<WORD>(0x779BC8, 0x697D);
Patch<DWORD>(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<WORD>(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<DWORD>(0x77A41F, desktop.right);
Patch<DWORD>(0x77A424, desktop.bottom);
Patch<const char*>(0x77A47B, aNoDesktopMode);
// Proper aspect ratios
static const float f43 = 4.0f/3.0f, f54 = 5.0f/4.0f, f169 = 16.0f/9.0f;
Patch<const void*>(0x73424B, &f169);
Patch<const void*>(0x734267, &f54);
Patch<const void*>(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;
}

View file

@ -35,16 +35,10 @@ inline void* GetDummy()
return &dwDummy;
}
inline ptrdiff_t GetModule()
{
static HMODULE hModule = GetModuleHandle(nullptr);
return (ptrdiff_t)hModule;
}
template<typename AT>
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