mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-07 02:00:16 +02:00
Windows: Handle NtReadFile calls to RX protected RWX memory
Handling this safely requires blocking all compilation for the duration of the read, as fault-based tracking doesn't work when wine's unix side itself is the one performing the write into the RWX region (we cannot catch unix faults). Fixes a startup crash in Persona 5.
This commit is contained in:
1 parent
ec13e5d503
commit
8e9f593c39
4 files changed
+93
-23
No files matched your search
@@ -881,7 +881,30 @@ void BTCpu64NotifyMemoryDirty(void* Address, SIZE_T Size) {
|
||||
InvalidationTracker->InvalidateAlignedInterval(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size), false);
|
||||
}
|
||||
|
||||
void BTCpu64NotifyReadFile(HANDLE Handle, void* Address, SIZE_T Size, BOOL After, NTSTATUS Status) {}
|
||||
void BTCpu64NotifyReadFile(HANDLE Handle, void* Address, SIZE_T Size, BOOL After, NTSTATUS Status) {
|
||||
auto* ThreadState = GetCPUArea().ThreadState();
|
||||
if (!InvalidationTracker || !ThreadState) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& InLockedRWXRead = GetFrontendThreadData(ThreadState)->InLockedRWXRead;
|
||||
if (!After) {
|
||||
ThreadCreationMutex.lock();
|
||||
CTX->GetCodeInvalidationMutex().lock();
|
||||
if (InvalidationTracker->BeginUntrackedWriteLocked(reinterpret_cast<uint64_t>(Address), static_cast<uint64_t>(Size))) {
|
||||
InLockedRWXRead = true;
|
||||
} else {
|
||||
CTX->GetCodeInvalidationMutex().unlock();
|
||||
ThreadCreationMutex.unlock();
|
||||
}
|
||||
} else {
|
||||
if (InLockedRWXRead) {
|
||||
InLockedRWXRead = false;
|
||||
CTX->GetCodeInvalidationMutex().unlock();
|
||||
ThreadCreationMutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS ThreadInit() {
|
||||
std::scoped_lock Lock(ThreadCreationMutex);
|
||||
|
||||
Reference in new issue
Block a user