From dd2845401cffcc30becbfa1b2bfe7ea1ec23ac4e Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 7 Aug 2025 20:55:24 +0100 Subject: [PATCH] InvalidationTracker: Disable mono hacks when multiblock is disabled --- Source/Windows/Common/InvalidationTracker.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Windows/Common/InvalidationTracker.cpp b/Source/Windows/Common/InvalidationTracker.cpp index 4a3477aa2..e6ce26aa8 100644 --- a/Source/Windows/Common/InvalidationTracker.cpp +++ b/Source/Windows/Common/InvalidationTracker.cpp @@ -87,10 +87,17 @@ void InvalidationTracker::HandleImageMap(std::string_view Name, uint64_t Address FEX_CONFIG_OPT(MonoHacks, MONOHACKS); if (MonoHacks && (Name == "mono-2.0-bdwgc.dll" || Name == "mono.dll")) { - CTX.MarkMonoDetected(); - MonoBackpatcherDetectionPending = true; - MonoBase = Address; - MonoEnd = LastExecutableSectionEnd; + FEX_CONFIG_OPT(MaxInst, MAXINST); + FEX_CONFIG_OPT(Multiblock, MULTIBLOCK); + if (Multiblock && MaxInst() >= 500) { + // Require these settings to ensure we can safely hook all SMC sites in a single block + CTX.MarkMonoDetected(); + MonoBackpatcherDetectionPending = true; + MonoBase = Address; + MonoEnd = LastExecutableSectionEnd; + } else { + LogMan::Msg::IFmt("Not applying mono hacks, Multiblock with MaxInst >= 500 required"); + } } }