mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 17:00:19 +02:00
Windows: Invalidate code in freed memory after the free syscall
Windows will populate Size/Address with those of the underlying free region. This is important for cross-process free operations, where the the 'before' callback is still called after the memory is freed so querying the size of the section (which is not freed) fails.
This commit is contained in:
1 parent
a3779be9e1
commit
2faf2eb5b6
2 files changed
+5
-9
No files matched your search
@@ -793,12 +793,10 @@ void NotifyMemoryFree(void* Address, SIZE_T Size, ULONG FreeType, BOOL After, NT
|
||||
|
||||
if (!After) {
|
||||
ThreadCreationMutex.lock();
|
||||
if (FreeType & MEM_DECOMMIT) {
|
||||
InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size), true);
|
||||
} else if (FreeType & MEM_RELEASE) {
|
||||
InvalidationTracker->InvalidateContainingSection(reinterpret_cast<uint64_t>(Address), true);
|
||||
}
|
||||
} else {
|
||||
if (!Status) {
|
||||
InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size), true);
|
||||
}
|
||||
ThreadCreationMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,12 +966,10 @@ void BTCpuNotifyMemoryProtect(void* Address, SIZE_T Size, ULONG NewProt, BOOL Af
|
||||
void BTCpuNotifyMemoryFree(void* Address, SIZE_T Size, ULONG FreeType, BOOL After, ULONG Status) {
|
||||
if (!After) {
|
||||
ThreadCreationMutex.lock();
|
||||
if (!Size) {
|
||||
InvalidationTracker->InvalidateContainingSection(reinterpret_cast<uint64_t>(Address), true);
|
||||
} else if (FreeType & MEM_DECOMMIT) {
|
||||
} else {
|
||||
if (!Status) {
|
||||
InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size), true);
|
||||
}
|
||||
} else {
|
||||
ThreadCreationMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user