diff --git a/Source/Windows/ARM64EC/BTInterface.h b/Source/Windows/ARM64EC/BTInterface.h index 50336c6d1..d57603079 100644 --- a/Source/Windows/ARM64EC/BTInterface.h +++ b/Source/Windows/ARM64EC/BTInterface.h @@ -11,11 +11,15 @@ void STDMETHODCALLTYPE ProcessTerm(HANDLE Handle, BOOL After, NTSTATUS Status); NTSTATUS STDMETHODCALLTYPE ThreadInit(); NTSTATUS STDMETHODCALLTYPE ThreadTerm(HANDLE Thread, LONG ExitCode); NTSTATUS STDMETHODCALLTYPE ResetToConsistentState(EXCEPTION_RECORD* Exception, CONTEXT* GuestContext, ARM64_NT_CONTEXT* NativeContext); -void STDMETHODCALLTYPE BTCpu64FlushInstructionCache(const void* Address, SIZE_T Size); void STDMETHODCALLTYPE NotifyMemoryAlloc(void* Address, SIZE_T Size, ULONG Type, ULONG Prot, BOOL After, NTSTATUS Status); void STDMETHODCALLTYPE NotifyMemoryFree(void* Address, SIZE_T Size, ULONG FreeType, BOOL After, NTSTATUS Status); void STDMETHODCALLTYPE NotifyMemoryProtect(void* Address, SIZE_T Size, ULONG NewProt, BOOL After, NTSTATUS Status); +NTSTATUS STDMETHODCALLTYPE NotifyMapViewOfSection(void* Unk1, void* Address, void* Unk2, SIZE_T Size, ULONG AllocType, ULONG Prot); void STDMETHODCALLTYPE NotifyUnmapViewOfSection(void* Address, BOOL After, NTSTATUS Status); +void STDMETHODCALLTYPE FlushInstructionCacheHeavy(const void* Address, SIZE_T Size); +void STDMETHODCALLTYPE BTCpu64FlushInstructionCache(const void* Address, SIZE_T Size); +void STDMETHODCALLTYPE BTCpu64NotifyMemoryDirty(void* Address, SIZE_T Size); +void STDMETHODCALLTYPE BTCpu64NotifyReadFile(HANDLE Handle, void* Address, SIZE_T Size, BOOL After, NTSTATUS Status); BOOLEAN STDMETHODCALLTYPE BTCpu64IsProcessorFeaturePresent(UINT Feature); void STDMETHODCALLTYPE UpdateProcessorInformation(SYSTEM_CPU_INFORMATION* Info); } diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index 349271c88..0edc3d7cd 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -588,6 +588,10 @@ void NotifyMemoryProtect(void* Address, SIZE_T Size, ULONG NewProt, BOOL After, InvalidationTracker->HandleMemoryProtectionNotification(reinterpret_cast(Address), static_cast(Size), NewProt); } +NTSTATUS NotifyMapViewOfSection(void* Unk1, void* Address, void* Unk2, SIZE_T Size, ULONG AllocType, ULONG Prot) { + return STATUS_SUCCESS; +} + void NotifyUnmapViewOfSection(void* Address, BOOL After, NTSTATUS Status) { if (!InvalidationTracker || !GetCPUArea().ThreadState()) { return; @@ -601,6 +605,15 @@ void NotifyUnmapViewOfSection(void* Address, BOOL After, NTSTATUS Status) { InvalidationTracker->InvalidateContainingSection(reinterpret_cast(Address), true); } +void FlushInstructionCacheHeavy(const void* Address, SIZE_T Size) { + if (!InvalidationTracker || !GetCPUArea().ThreadState()) { + return; + } + + std::scoped_lock Lock(ThreadCreationMutex); + InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast(Address), static_cast(Size), false); +} + void BTCpu64FlushInstructionCache(const void* Address, SIZE_T Size) { if (!InvalidationTracker || !GetCPUArea().ThreadState()) { return; @@ -610,6 +623,17 @@ void BTCpu64FlushInstructionCache(const void* Address, SIZE_T Size) { InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast(Address), static_cast(Size), false); } +void BTCpu64NotifyMemoryDirty(void* Address, SIZE_T Size) { + if (!InvalidationTracker || !GetCPUArea().ThreadState()) { + return; + } + + std::scoped_lock Lock(ThreadCreationMutex); + InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast(Address), static_cast(Size), false); +} + +void BTCpu64NotifyReadFile(HANDLE Handle, void* Address, SIZE_T Size, BOOL After, NTSTATUS Status) {} + NTSTATUS ThreadInit() { static constexpr size_t EmulatorStackSize = 0x40000; const uint64_t EmulatorStack = reinterpret_cast(::VirtualAlloc(nullptr, EmulatorStackSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)); diff --git a/Source/Windows/ARM64EC/libarm64ecfex.def b/Source/Windows/ARM64EC/libarm64ecfex.def index 035e03be0..bb51ca889 100644 --- a/Source/Windows/ARM64EC/libarm64ecfex.def +++ b/Source/Windows/ARM64EC/libarm64ecfex.def @@ -3,12 +3,14 @@ LIBRARY libarm64ecfex.dll EXPORTS BTCpu64FlushInstructionCache BTCpu64IsProcessorFeaturePresent + BTCpu64NotifyMemoryDirty + BTCpu64NotifyReadFile DispatchJump DATA RetToEntryThunk DATA ExitToX64 DATA BeginSimulation DATA -; FlushInstructionCacheHeavy -; NotifyMapViewOfSection + FlushInstructionCacheHeavy + NotifyMapViewOfSection NotifyMemoryAlloc NotifyMemoryFree NotifyMemoryProtect