diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index 943a506bc..38c262c01 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -578,6 +578,10 @@ public: OvercommitTracker->UnmarkRange(Start, Length); } + FEXCore::HLE::ExecutableRangeInfo QueryGuestExecutableRange(FEXCore::Core::InternalThreadState* Thread, uint64_t Address) override { + return InvalidationTracker->QueryExecutableRange(Address); + } + void PreCompile() override { ProcessPendingCrossProcessEmulatorWork(); } diff --git a/Source/Windows/Common/InvalidationTracker.cpp b/Source/Windows/Common/InvalidationTracker.cpp index 4592151e1..b036015b3 100644 --- a/Source/Windows/Common/InvalidationTracker.cpp +++ b/Source/Windows/Common/InvalidationTracker.cpp @@ -177,4 +177,18 @@ bool InvalidationTracker::HandleRWXAccessViolation(uint64_t FaultAddress) { } return false; } + +FEXCore::HLE::ExecutableRangeInfo InvalidationTracker::QueryExecutableRange(uint64_t Address) { + std::shared_lock Lock(IntervalsLock); + const auto XResult = XIntervals.Query(Address); + if (!XResult.Enclosed) { + return {}; + } + const auto RWXResult = RWXIntervals.Query(Address); + if (RWXResult.Enclosed || (RWXResult.Size && RWXResult.Size < XResult.Size)) { + return {RWXResult.Interval.Offset, RWXResult.Interval.End - RWXResult.Interval.Offset, RWXResult.Enclosed}; + } + return {XResult.Interval.Offset, XResult.Interval.End - XResult.Interval.Offset, false}; +} + } // namespace FEX::Windows diff --git a/Source/Windows/Common/InvalidationTracker.h b/Source/Windows/Common/InvalidationTracker.h index d1654738e..96d959fad 100644 --- a/Source/Windows/Common/InvalidationTracker.h +++ b/Source/Windows/Common/InvalidationTracker.h @@ -2,6 +2,7 @@ #pragma once #include +#include #include #include @@ -30,6 +31,7 @@ public: void InvalidateAlignedInterval(uint64_t Address, uint64_t Size, bool Free); void ReprotectRWXIntervals(uint64_t Address, uint64_t Size); bool HandleRWXAccessViolation(uint64_t FaultAddress); + FEXCore::HLE::ExecutableRangeInfo QueryExecutableRange(uint64_t Address); private: FEXCore::IntervalList XIntervals; diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index 6dd89cf20..c4f093ac6 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -451,6 +451,10 @@ public: OvercommitTracker->UnmarkRange(Start, Length); } + FEXCore::HLE::ExecutableRangeInfo QueryGuestExecutableRange(FEXCore::Core::InternalThreadState* Thread, uint64_t Address) override { + return InvalidationTracker->QueryExecutableRange(Address); + } + void PreCompile() override { Wow64ProcessPendingCrossProcessItems(); }