mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 17:00:19 +02:00
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include <FEXCore/Utils/IntervalList.h>
|
|
#include <FEXCore/HLE/SyscallHandler.h>
|
|
#include <mutex>
|
|
#include <unordered_map>
|
|
|
|
namespace FEXCore::Core {
|
|
struct InternalThreadState;
|
|
}
|
|
|
|
namespace FEXCore::Context {
|
|
class Context;
|
|
}
|
|
|
|
namespace FEX::Windows {
|
|
/**
|
|
* @brief Handles SMC and regular code invalidation
|
|
*/
|
|
class InvalidationTracker {
|
|
public:
|
|
InvalidationTracker(FEXCore::Context::Context& CTX, const std::unordered_map<DWORD, FEXCore::Core::InternalThreadState*>& Threads);
|
|
void HandleMemoryProtectionNotification(uint64_t Address, uint64_t Size, ULONG Prot);
|
|
void HandleImageMap(uint64_t Address);
|
|
struct InvalidateContainingSectionResult {
|
|
uint64_t SectionStart;
|
|
uint64_t SectionSize;
|
|
};
|
|
InvalidateContainingSectionResult InvalidateContainingSection(uint64_t Address, bool Free);
|
|
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:
|
|
void DisableSMCDetection();
|
|
|
|
FEXCore::IntervalList<uint64_t> XIntervals;
|
|
FEXCore::IntervalList<uint64_t> RWXIntervals;
|
|
std::shared_mutex IntervalsLock;
|
|
FEXCore::Context::Context& CTX;
|
|
const std::unordered_map<DWORD, FEXCore::Core::InternalThreadState*>& Threads;
|
|
bool SMCDetectionDisabled {false}; // Protected by IntervalsLock
|
|
};
|
|
} // namespace FEX::Windows
|