mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-31 06:57:28 +05:00
First fixes for that butchered Steam re-release
This commit is contained in:
parent
92952941f3
commit
260d6a2339
2 changed files with 83 additions and 4 deletions
|
@ -1201,7 +1201,7 @@ void __declspec(naked) TrailerDoubleRWheelsFix2_Steam()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* LoadFLAC_JumpBack = AddressByVersion<void*>(0x4F3743, *(BYTE*)0x4F3A50 == 0x6A ? 0x4F3BA3 : 0x5B6B81, 0x4FFC3F);
|
static void* LoadFLAC_JumpBack = AddressByVersion<void*>(0x4F3743, *GetVer() == 1 ? (*(BYTE*)0x4F3A50 == 0x6A ? 0x4F3BA3 : 0x5B6B81) : 0, 0x4FFC3F);
|
||||||
void __declspec(naked) LoadFLAC()
|
void __declspec(naked) LoadFLAC()
|
||||||
{
|
{
|
||||||
_asm
|
_asm
|
||||||
|
@ -2938,6 +2938,47 @@ void Patch_SA_Steam()
|
||||||
InjectHook(0x5EDFD9, 0x5EE0FA, PATCH_JUMP);
|
InjectHook(0x5EDFD9, 0x5EE0FA, PATCH_JUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Patch_SA_NewSteam()
|
||||||
|
{
|
||||||
|
using namespace MemoryVP::DynBase;
|
||||||
|
|
||||||
|
// No framedelay
|
||||||
|
InjectHook(0x54ECC6, GetModule() + 0x14ED0C, PATCH_JUMP);
|
||||||
|
Patch<BYTE>(0x54ED45, 0x4);
|
||||||
|
Nop(0x54ED47, 1);
|
||||||
|
|
||||||
|
// Unlock 1.0/1.01 saves loading
|
||||||
|
Patch<WORD>(0x5ED3E9, 0xE990);
|
||||||
|
|
||||||
|
// Old .set files working again
|
||||||
|
static const DWORD dwSetVersion = 6;
|
||||||
|
Patch<const void*>(0x59058A, &dwSetVersion);
|
||||||
|
Patch<BYTE>(0x59086D, 6);
|
||||||
|
Patch<BYTE>(0x53EC4A, 6);
|
||||||
|
|
||||||
|
// Unlocked widescreen resolutions
|
||||||
|
Patch<WORD>(0x779BAD, 0x607D);
|
||||||
|
// TODO: Do the rest
|
||||||
|
|
||||||
|
// Disable re-initialization of DirectInput mouse device by the game
|
||||||
|
Patch<BYTE>(0x58A891, 0xEB);
|
||||||
|
Patch<BYTE>(0x58AA77, 0xEB);
|
||||||
|
Patch<BYTE>(0x58AB59, 0xEB);
|
||||||
|
|
||||||
|
// Make sure DirectInput mouse device is set non-exclusive (may not be needed?)
|
||||||
|
Nop(0x77AB3F, 1);
|
||||||
|
Patch<WORD>(0x77AB40, 0x01B0);
|
||||||
|
//Nop(0x77AB3B, 3);
|
||||||
|
//Nop(0x77AB3F, 3);
|
||||||
|
|
||||||
|
|
||||||
|
// 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)
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
{
|
{
|
||||||
|
@ -2947,9 +2988,12 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
{
|
{
|
||||||
hDLLModule = hinstDLL;
|
hDLLModule = hinstDLL;
|
||||||
|
|
||||||
if (*(DWORD*)0x82457C == 0x94BF || *(DWORD*)0x8245BC == 0x94BF) Patch_SA_10();
|
if ( *(DWORD*)(GetModule()+0x458D21) == 0x3539F633) Patch_SA_NewSteam();
|
||||||
|
|
||||||
|
else if (*(DWORD*)0x82457C == 0x94BF || *(DWORD*)0x8245BC == 0x94BF) Patch_SA_10();
|
||||||
else if (*(DWORD*)0x8252FC == 0x94BF || *(DWORD*)0x82533C == 0x94BF) Patch_SA_11();
|
else if (*(DWORD*)0x8252FC == 0x94BF || *(DWORD*)0x82533C == 0x94BF) Patch_SA_11();
|
||||||
else if (*(DWORD*)0x85EC4A == 0x94BF) Patch_SA_Steam();
|
else if (*(DWORD*)0x85EC4A == 0x94BF) Patch_SA_Steam();
|
||||||
|
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -35,6 +35,12 @@ inline void* GetDummy()
|
||||||
return &dwDummy;
|
return &dwDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ptrdiff_t GetModule()
|
||||||
|
{
|
||||||
|
static HMODULE hModule = GetModuleHandle(nullptr);
|
||||||
|
return (ptrdiff_t)hModule;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined SILENTPATCH_III_VER
|
#if defined SILENTPATCH_III_VER
|
||||||
|
|
||||||
// This function initially detects III version then chooses the address basing on game version
|
// This function initially detects III version then chooses the address basing on game version
|
||||||
|
@ -104,7 +110,13 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
||||||
|
|
||||||
if ( *bVer == -1 )
|
if ( *bVer == -1 )
|
||||||
{
|
{
|
||||||
if ( *(DWORD*)0x82457C == 0x94BF )
|
if ( *(DWORD*)(GetModule()+0x458D21) == 0x3539F633 )
|
||||||
|
{
|
||||||
|
*bVer = 3;
|
||||||
|
*bEuropean = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ( *(DWORD*)0x82457C == 0x94BF )
|
||||||
{
|
{
|
||||||
*bVer = 0;
|
*bVer = 0;
|
||||||
*bEuropean = false;
|
*bEuropean = false;
|
||||||
|
@ -156,6 +168,9 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
||||||
return (T)GetDummy();
|
return (T)GetDummy();
|
||||||
|
|
||||||
return (T)addressSteam;
|
return (T)addressSteam;
|
||||||
|
case 3:
|
||||||
|
// TODO: DO
|
||||||
|
return (T)GetDummy();
|
||||||
default:
|
default:
|
||||||
assert(address10);
|
assert(address10);
|
||||||
// Adjust to EU if needed
|
// Adjust to EU if needed
|
||||||
|
@ -290,7 +305,6 @@ namespace MemoryVP
|
||||||
|
|
||||||
template<typename AT>
|
template<typename AT>
|
||||||
inline void Nop(AT address, unsigned int nCount)
|
inline void Nop(AT address, unsigned int nCount)
|
||||||
// TODO: Finish multibyte nops
|
|
||||||
{
|
{
|
||||||
DWORD dwProtect[2];
|
DWORD dwProtect[2];
|
||||||
VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
|
VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
|
||||||
|
@ -329,6 +343,27 @@ namespace MemoryVP
|
||||||
else
|
else
|
||||||
VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]);
|
VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace DynBase
|
||||||
|
{
|
||||||
|
template<typename T, typename AT>
|
||||||
|
inline void Patch(AT address, T value)
|
||||||
|
{
|
||||||
|
MemoryVP::Patch(GetModule() - 0x400000 + address, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline void Nop(AT address, unsigned int nCount)
|
||||||
|
{
|
||||||
|
MemoryVP::Nop(GetModule() - 0x400000 + address, nCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename AT, typename HT>
|
||||||
|
inline void InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING)
|
||||||
|
{
|
||||||
|
MemoryVP::InjectHook(GetModule() - 0x400000 + address, hook, nType);
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue