From 1a2398d2ceacb4f8a691ab74d79ec1041b6c2b1b Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 16 Apr 2025 13:34:05 +0100 Subject: [PATCH] Windows: Call the protection callback for executable FEX mappings --- Source/Windows/ARM64EC/Module.cpp | 2 ++ Source/Windows/WOW64/Module.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index 35cac12f6..5f61c07ea 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -624,6 +624,8 @@ NTSTATUS ProcessInit() { CPUFeatures.emplace(*CTX); X64ReturnInstr = ::VirtualAlloc(nullptr, FEXCore::Utils::FEX_PAGE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + InvalidationTracker->HandleMemoryProtectionNotification(reinterpret_cast(X64ReturnInstr), FEXCore::Utils::FEX_PAGE_SIZE, + PAGE_EXECUTE_READ); *reinterpret_cast(X64ReturnInstr) = 0xc3; const uintptr_t KiUserExceptionDispatcherFFS = reinterpret_cast(GetProcAddress(NtDll, "KiUserExceptionDispatcher")); diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index c2234bc5a..6dd89cf20 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -503,6 +503,7 @@ void BTCpuProcessInit() { SIZE_T Size = 4; void* Addr = nullptr; NtAllocateVirtualMemory(NtCurrentProcess(), &Addr, (1U << 31) - 1, &Size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + InvalidationTracker->HandleMemoryProtectionNotification(reinterpret_cast(Addr), Size, PAGE_EXECUTE); *reinterpret_cast(Addr) = 0x2ecd2ecd; BridgeInstrs::Syscall = Addr; BridgeInstrs::UnixCall = reinterpret_cast(reinterpret_cast(Addr) + 2);