diff options
Diffstat (limited to 'Ryujinx.Memory/Tracking/MemoryTracking.cs')
-rw-r--r-- | Ryujinx.Memory/Tracking/MemoryTracking.cs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/Ryujinx.Memory/Tracking/MemoryTracking.cs b/Ryujinx.Memory/Tracking/MemoryTracking.cs index c5abb576..ec75e3d0 100644 --- a/Ryujinx.Memory/Tracking/MemoryTracking.cs +++ b/Ryujinx.Memory/Tracking/MemoryTracking.cs @@ -190,30 +190,6 @@ namespace Ryujinx.Memory.Tracking /// <summary> /// Signal that a virtual memory event happened at the given location. - /// This is similar VirtualMemoryEvent, but on Windows, it might also return true after a partial unmap. - /// This should only be called from the exception handler. - /// </summary> - /// <param name="address">Virtual address accessed</param> - /// <param name="size">Size of the region affected in bytes</param> - /// <param name="write">Whether the region was written to or read</param> - /// <param name="precise">True if the access is precise, false otherwise</param> - /// <returns>True if the event triggered any tracking regions, false otherwise</returns> - public bool VirtualMemoryEventEh(ulong address, ulong size, bool write, bool precise = false) - { - // Windows has a limitation, it can't do partial unmaps. - // For this reason, we need to unmap the whole range and then remap the sub-ranges. - // When this happens, we might have caused a undesirable access violation from the time that the range was unmapped. - // In this case, try again as the memory might be mapped now. - if (OperatingSystem.IsWindows() && MemoryManagementWindows.RetryFromAccessViolation()) - { - return true; - } - - return VirtualMemoryEvent(address, size, write, precise); - } - - /// <summary> - /// Signal that a virtual memory event happened at the given location. /// This can be flagged as a precise event, which will avoid reprotection and call special handlers if possible. /// A precise event has an exact address and size, rather than triggering on page granularity. /// </summary> @@ -237,10 +213,12 @@ namespace Ryujinx.Memory.Tracking if (count == 0 && !precise) { - if (_memoryManager.IsMapped(address)) + if (_memoryManager.IsRangeMapped(address, size)) { + // TODO: There is currently the possibility that a page can be protected after its virtual region is removed. + // This code handles that case when it happens, but it would be better to find out how this happens. _memoryManager.TrackingReprotect(address & ~(ulong)(_pageSize - 1), (ulong)_pageSize, MemoryPermission.ReadAndWrite); - return false; // We can't handle this - it's probably a real invalid access. + return true; // This memory _should_ be mapped, so we need to try again. } else { |