diff --git a/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs b/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs index a17fea5e..3022b661 100644 --- a/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs +++ b/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs @@ -73,7 +73,7 @@ namespace Ryujinx.Memory.WindowsShared lock (_protections) { - _protections.Add(new RangeNode(address, size, MemoryPermission.None)); + _protections.Add(new RangeNode(address, address + size, MemoryPermission.None)); } } @@ -132,7 +132,7 @@ namespace Ryujinx.Memory.WindowsShared try { UnmapViewInternal(sharedMemory, location, size, owner, updateProtection: false); - MapViewInternal(sharedMemory, srcOffset, location, size); + MapViewInternal(sharedMemory, srcOffset, location, size, updateProtection: true); } finally { @@ -147,8 +147,9 @@ namespace Ryujinx.Memory.WindowsShared /// Offset in the shared memory to map /// Address to map the view into /// Size of the view in bytes + /// Indicates if the memory protections should be updated after the map /// Thrown when the Windows API returns an error mapping the memory - private void MapViewInternal(IntPtr sharedMemory, ulong srcOffset, IntPtr location, IntPtr size) + private void MapViewInternal(IntPtr sharedMemory, ulong srcOffset, IntPtr location, IntPtr size, bool updateProtection) { SplitForMap((ulong)location, (ulong)size, srcOffset); @@ -168,7 +169,10 @@ namespace Ryujinx.Memory.WindowsShared throw new WindowsApiException("MapViewOfFile3"); } - UpdateProtection((ulong)location, (ulong)size, MemoryPermission.ReadAndWrite); + if (updateProtection) + { + UpdateProtection((ulong)location, (ulong)size, MemoryPermission.ReadAndWrite); + } } /// @@ -330,7 +334,7 @@ namespace Ryujinx.Memory.WindowsShared { ulong remapSize = startAddress - overlap.Start; - MapViewInternal(sharedMemory, overlap.Value, (IntPtr)overlap.Start, (IntPtr)remapSize); + MapViewInternal(sharedMemory, overlap.Value, (IntPtr)overlap.Start, (IntPtr)remapSize, updateProtection: false); RestoreRangeProtection(overlap.Start, remapSize); } @@ -341,7 +345,7 @@ namespace Ryujinx.Memory.WindowsShared ulong remapAddress = overlap.Start + overlappedSize; ulong remapSize = overlap.End - endAddress; - MapViewInternal(sharedMemory, remapBackingOffset, (IntPtr)remapAddress, (IntPtr)remapSize); + MapViewInternal(sharedMemory, remapBackingOffset, (IntPtr)remapAddress, (IntPtr)remapSize, updateProtection: false); RestoreRangeProtection(remapAddress, remapSize); } } @@ -606,7 +610,7 @@ namespace Ryujinx.Memory.WindowsShared _protections.Remove(protection); - if (protection.Value == permission) + if (protPermission == permission) { if (startAddress > protAddress) {