mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 07:13:02 +05:00
Use reinterpret_cast for function pointer casts
MSVC (wrongly) allows those casts to succeed with static_cast: https://stackoverflow.com/questions/74002657/why-cant-i-static-cast-a-void-to-a-pointer-to-function (so adjust those casts for better compiler compatibility including MinGW GCC)
This commit is contained in:
parent
4cccda9da6
commit
2bd71990de
4 changed files with 10 additions and 10 deletions
|
@ -78,19 +78,19 @@ bool RWGTA::Patches::TryLocateRwD3D8() try
|
|||
auto pfnRwD3D8SetRenderState = [] {
|
||||
try {
|
||||
// Everything except for III Steam
|
||||
return static_cast<decltype(RwD3D8SetRenderState)*>(get_pattern("39 0C C5 ? ? ? ? 74 31", -8));
|
||||
return reinterpret_cast<decltype(RwD3D8SetRenderState)*>(get_pattern("39 0C C5 ? ? ? ? 74 31", -8));
|
||||
} catch (const hook::txn_exception&) {
|
||||
// III Steam
|
||||
return static_cast<decltype(RwD3D8SetRenderState)*>(get_pattern("8B 0C C5 ? ? ? ? 3B CA", -8));
|
||||
return reinterpret_cast<decltype(RwD3D8SetRenderState)*>(get_pattern("8B 0C C5 ? ? ? ? 3B CA", -8));
|
||||
}
|
||||
}();
|
||||
auto pfnRwD3D8GetRenderState = [] {
|
||||
try {
|
||||
// Everything except for III Steam
|
||||
return static_cast<decltype(RwD3D8GetRenderState)*>(get_pattern("8B 0C C5 ? ? ? ? 89 0A C3", -8));
|
||||
return reinterpret_cast<decltype(RwD3D8GetRenderState)*>(get_pattern("8B 0C C5 ? ? ? ? 89 0A C3", -8));
|
||||
} catch (const hook::txn_exception&) {
|
||||
// III Steam
|
||||
return static_cast<decltype(RwD3D8GetRenderState)*>(get_pattern("8B 04 C5 ? ? ? ? 89 02 C3", -8));
|
||||
return reinterpret_cast<decltype(RwD3D8GetRenderState)*>(get_pattern("8B 04 C5 ? ? ? ? 89 02 C3", -8));
|
||||
}
|
||||
}();
|
||||
|
||||
|
@ -101,4 +101,4 @@ bool RWGTA::Patches::TryLocateRwD3D8() try
|
|||
catch (const hook::txn_exception&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ namespace Localization
|
|||
// ============= Call cDMAudio::IsAudioInitialised before adding one shot sounds, like in VC =============
|
||||
namespace AudioInitializedFix
|
||||
{
|
||||
auto IsAudioInitialised = static_cast<bool(*)()>(Memory::ReadCallFrom( hook::get_pattern( "E8 ? ? ? ? 84 C0 74 ? 0F B7 47 10" ) ));
|
||||
auto IsAudioInitialised = reinterpret_cast<bool(*)()>(Memory::ReadCallFrom( hook::get_pattern( "E8 ? ? ? ? 84 C0 74 ? 0F B7 47 10" ) ));
|
||||
void* (*operatorNew)(size_t size);
|
||||
|
||||
void* operatorNew_InitializedCheck( size_t size )
|
||||
|
|
|
@ -7639,7 +7639,7 @@ void Patch_SA_NewBinaries_Common(HINSTANCE hInstance)
|
|||
// Fixed escalators crash
|
||||
try
|
||||
{
|
||||
orgEscalatorsUpdate = static_cast<decltype(orgEscalatorsUpdate)>(get_pattern( "80 3D ? ? ? ? ? 74 23 56" ));
|
||||
orgEscalatorsUpdate = reinterpret_cast<decltype(orgEscalatorsUpdate)>(get_pattern( "80 3D ? ? ? ? ? 74 23 56" ));
|
||||
|
||||
auto updateEscalators = get_pattern("80 3D ? ? ? ? ? 74 22 56");
|
||||
auto removeEscalatorsForEntity = pattern( "80 7E F5 00 74 56" ).get_one();
|
||||
|
@ -8498,7 +8498,7 @@ void Patch_SA_NewBinaries_Common(HINSTANCE hInstance)
|
|||
ppRWD3D9 = *get_pattern<IDirect3D9**>("33 ED A3 ? ? ? ? 3B C5", 2 + 1);
|
||||
FrontEndMenuManager = *get_pattern<void**>("50 50 68 ? ? ? ? B9 ? ? ? ? E8", 7 + 1); // This has 2 identical matches, we just need one
|
||||
|
||||
orgGetDocumentsPath = static_cast<char*(*)()>(get_pattern( "8D 45 FC 50 68 19 00 02 00", -6 ));
|
||||
orgGetDocumentsPath = reinterpret_cast<char*(*)()>(get_pattern( "8D 45 FC 50 68 19 00 02 00", -6 ));
|
||||
|
||||
Patch(dialogBoxParam, &pDialogBoxParamA_New);
|
||||
Patch(setFocus, &pSetFocus_NOP);
|
||||
|
|
|
@ -1876,7 +1876,7 @@ void InjectDelayedPatches_VC_Common( bool bHasDebugMenu, const wchar_t* wcModule
|
|||
|
||||
|
||||
// Stuff to let us (re)initialize
|
||||
static void (*HUDReInitialise)() = static_cast<decltype(HUDReInitialise)>(get_pattern("31 C0 53 0F EF C0 C6 05"));
|
||||
static void (*HUDReInitialise)() = reinterpret_cast<decltype(HUDReInitialise)>(get_pattern("31 C0 53 0F EF C0 C6 05"));
|
||||
|
||||
// This pattern has 5 hits - first 2 are in Reinitialise, the rest is in Initialise
|
||||
auto reinitialise1 = pattern("C7 05 ? ? ? ? 05 00 00 00 66 C7 05 ? ? ? ? 00 00 C7 05 ? ? ? ? 00 00 00 00").count(5);
|
||||
|
@ -2759,7 +2759,7 @@ void Patch_VC_Common()
|
|||
using namespace IsPlayerTargettingCharFix;
|
||||
|
||||
auto isPlayerTargettingChar = pattern("83 7C 24 ? ? A3 ? ? ? ? 0F 84").get_one();
|
||||
auto using1stPersonWeaponMode = static_cast<decltype(Using1stPersonWeaponMode)>(get_pattern("66 83 F8 07 74 18", -7));
|
||||
auto using1stPersonWeaponMode = reinterpret_cast<decltype(Using1stPersonWeaponMode)>(get_pattern("66 83 F8 07 74 18", -7));
|
||||
bool* useMouse3rdPerson = *get_pattern<bool*>("80 3D ? ? ? ? ? 75 09 66 C7 05 ? ? ? ? ? ? 8B 35", 2);
|
||||
void* theCamera = *get_pattern<void*>("B9 ? ? ? ? 31 DB E8", 1);
|
||||
|
||||
|
|
Loading…
Reference in a new issue