mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-13 19:00:43 +02:00
As section permissions are set on the unix side we don't get a protection callback for them, workaround this by iterating over the sections of all executables after mapping and tracking the RWX ones.
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include "IntervalList.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);
|
|
void 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);
|
|
|
|
private:
|
|
IntervalList<uint64_t> RWXIntervals;
|
|
std::mutex RWXIntervalsLock;
|
|
FEXCore::Context::Context& CTX;
|
|
const std::unordered_map<DWORD, FEXCore::Core::InternalThreadState*>& Threads;
|
|
};
|
|
} // namespace FEX::Windows
|