diff --git a/SilentPatch/TheFLAUtils.cpp b/SilentPatch/TheFLAUtils.cpp index 9fc9072..d51a0af 100644 --- a/SilentPatch/TheFLAUtils.cpp +++ b/SilentPatch/TheFLAUtils.cpp @@ -8,21 +8,32 @@ int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock; int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock; +static HMODULE flaModule = nullptr; + void FLAUtils::Init() { - const HMODULE hFLA = GetASIModuleHandle(TEXT("$fastman92limitAdjuster")); - if ( hFLA != nullptr ) + flaModule = GetASIModuleHandle(TEXT("$fastman92limitAdjuster")); + if ( flaModule != nullptr ) { - const auto function8 = reinterpret_cast(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" )); + const auto function8 = reinterpret_cast(GetProcAddress( flaModule, "GetExtendedIDfrom8bitBefore" )); if ( function8 != nullptr ) { GetExtendedID8Func = function8; } - const auto function16 = reinterpret_cast(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" )); + const auto function16 = reinterpret_cast(GetProcAddress( flaModule, "GetExtendedIDfrom16bitBefore" )); if ( function16 != nullptr ) { GetExtendedID16Func = function16; } } +} + +bool FLAUtils::UsesEnhancedIMGs() +{ + if ( flaModule == nullptr ) return false; + + const auto func = reinterpret_cast(GetProcAddress( flaModule, "IsHandlingOfEnhancedIMGarchivesEnabled" )); + if ( func == nullptr ) return false; + return func(); } \ No newline at end of file diff --git a/SilentPatch/TheFLAUtils.h b/SilentPatch/TheFLAUtils.h index fc3eaa5..8bd8d3e 100644 --- a/SilentPatch/TheFLAUtils.h +++ b/SilentPatch/TheFLAUtils.h @@ -36,6 +36,7 @@ public: }; static void Init(); + static bool UsesEnhancedIMGs(); private: static constexpr int32_t MAX_UINT8_ID = 0xFF; diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index ffbfea6..5d13dff 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -2912,9 +2912,11 @@ BOOL InjectDelayedPatches_10() InjectHook(0x713ACB, HandleMoonStuffStub, PATCH_JUMP); } + FLAUtils::Init(); + // Race condition in CdStream fixed // Not taking effect with modloader - if ( !ModCompat::ModloaderCdStreamRaceConditionAware( modloaderModule ) ) + if ( !ModCompat::ModloaderCdStreamRaceConditionAware( modloaderModule ) && !FLAUtils::UsesEnhancedIMGs() ) { ReadCall( 0x406C78, CdStreamSync::orgCdStreamInitThread ); InjectHook( 0x406C78, CdStreamSync::CdStreamInitThread ); @@ -2980,9 +2982,6 @@ BOOL InjectDelayedPatches_10() } } #endif - - - FLAUtils::Init(); return FALSE; }