diff --git a/SilentPatch/ASIModuleHandle.h b/SilentPatch/ASIModuleHandle.h new file mode 100644 index 0000000..1a24e08 --- /dev/null +++ b/SilentPatch/ASIModuleHandle.h @@ -0,0 +1,43 @@ +#pragma once + +template +inline HMODULE GetASIModuleHandleA( const char(&lpModuleName)[N] ) +{ + HMODULE asi = GetModuleHandleA( lpModuleName ); + if ( asi == nullptr ) + { + char nameWithSuffix[ N + 4 ]; + memcpy( nameWithSuffix, lpModuleName, sizeof(lpModuleName) - sizeof(lpModuleName[0]) ); + nameWithSuffix[N - 1] = '.'; + nameWithSuffix[N + 0] = 'a'; + nameWithSuffix[N + 1] = 's'; + nameWithSuffix[N + 2] = 'i'; + nameWithSuffix[N + 3] = '\0'; + asi = GetModuleHandleA( nameWithSuffix ); + } + return asi; +} + +template +inline HMODULE GetASIModuleHandleW( const wchar_t(&lpModuleName)[N] ) +{ + HMODULE asi = GetModuleHandleW( lpModuleName ); + if ( asi == nullptr ) + { + wchar_t nameWithSuffix[ N + 4 ]; + memcpy( nameWithSuffix, lpModuleName, sizeof(lpModuleName) - sizeof(lpModuleName[0]) ); + nameWithSuffix[N - 1] = L'.'; + nameWithSuffix[N + 0] = L'a'; + nameWithSuffix[N + 1] = L's'; + nameWithSuffix[N + 2] = L'i'; + nameWithSuffix[N + 3] = L'\0'; + asi = GetModuleHandleW( nameWithSuffix ); + } + return asi; +} + +#ifdef _UNICODE +#define GetASIModuleHandle GetASIModuleHandleW +#else +#define GetASIModuleHandle GetASIModuleHandleA +#endif \ No newline at end of file diff --git a/SilentPatch/TheFLAUtils.cpp b/SilentPatch/TheFLAUtils.cpp index 0e1615f..9fc9072 100644 --- a/SilentPatch/TheFLAUtils.cpp +++ b/SilentPatch/TheFLAUtils.cpp @@ -3,12 +3,14 @@ #define WIN32_LEAN_AND_MEAN #include +#include "ASIModuleHandle.h" + int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock; int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock; void FLAUtils::Init() { - const HMODULE hFLA = GetModuleHandle(TEXT("$fastman92limitAdjuster.asi")); + const HMODULE hFLA = GetASIModuleHandle(TEXT("$fastman92limitAdjuster")); if ( hFLA != nullptr ) { const auto function8 = reinterpret_cast(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" )); diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 39db60e..7203789 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -19,6 +19,7 @@ #include "Patterns.h" #include "DelimStringReader.h" +#include "ASIModuleHandle.h" #pragma warning(disable:4733) @@ -2288,9 +2289,9 @@ BOOL InjectDelayedPatches_10() GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension PathRenameExtensionW(wcModulePath, L".ini"); - bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr; + bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr; bool bSAMP = GetModuleHandleW(L"samp") != nullptr; - bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr; + bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr; ReadRotorFixExceptions(wcModulePath); ReadDoubleRearWheels(wcModulePath); @@ -2467,7 +2468,7 @@ BOOL InjectDelayedPatches_10() } // SSE conflicts - if ( GetModuleHandleW(L"shadows.asi") == nullptr ) + if ( GetASIModuleHandleW(L"shadows") == nullptr ) { Patch(0x70665C, 0x52909090); InjectHook(0x706662, &CShadowCamera::Update); @@ -2487,7 +2488,7 @@ BOOL InjectDelayedPatches_10() // Adblocker #if DISABLE_FLA_DONATION_WINDOW - if ( GetModuleHandleW(L"$fastman92limitAdjuster.asi") != nullptr ) + if ( GetASIModuleHandleW(L"$fastman92limitAdjuster") != nullptr ) { if ( *(DWORD*)0x748736 != 0xE8186A53 ) { @@ -2526,9 +2527,9 @@ BOOL InjectDelayedPatches_11() GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension PathRenameExtensionW(wcModulePath, L".ini"); - bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr; + bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr; bool bSAMP = GetModuleHandleW(L"samp") != nullptr; - bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr; + bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr; ReadRotorFixExceptions(wcModulePath); @@ -2713,7 +2714,7 @@ BOOL InjectDelayedPatches_11() } // SSE conflicts - if ( GetModuleHandleW(L"shadows.asi") == nullptr ) + if ( GetASIModuleHandleW(L"shadows") == nullptr ) { Patch(0x706E8C, 0x52909090); InjectHook(0x706E92, &CShadowCamera::Update); @@ -2752,9 +2753,9 @@ BOOL InjectDelayedPatches_Steam() GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension PathRenameExtensionW(wcModulePath, L".ini"); - bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr; + bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr; bool bSAMP = GetModuleHandleW(L"samp") != nullptr; - bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr; + bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr; ReadRotorFixExceptions(wcModulePath); @@ -2927,7 +2928,7 @@ BOOL InjectDelayedPatches_Steam() } // SSE conflicts - if ( GetModuleHandleW(L"shadows.asi") == nullptr ) + if ( GetASIModuleHandleW(L"shadows") == nullptr ) { Patch(0x74A864, 0x52909090); InjectHook(0x74A86A, &CShadowCamera::Update); diff --git a/SilentPatchSA/SilentPatchSA.vcxproj b/SilentPatchSA/SilentPatchSA.vcxproj index 0fac22a..081d75f 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj +++ b/SilentPatchSA/SilentPatchSA.vcxproj @@ -235,6 +235,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio + diff --git a/SilentPatchSA/SilentPatchSA.vcxproj.filters b/SilentPatchSA/SilentPatchSA.vcxproj.filters index 343a80c..2d55077 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj.filters +++ b/SilentPatchSA/SilentPatchSA.vcxproj.filters @@ -152,6 +152,9 @@ Header Files + + Header Files +