diff options
author | gdkchan <gab.dark.100@gmail.com> | 2019-12-24 22:43:47 -0300 |
---|---|---|
committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
commit | 6cf9a04d981a9e966cccb0dc90182e29aac7e270 (patch) | |
tree | f091188fde2fd7daf2924ae3455fdda4f9be6456 | |
parent | a718b60d06f5ad2219d5896c7739c29444560811 (diff) |
Stop memory modification check when a invalid address is found
-rw-r--r-- | ARMeilleure/Memory/MemoryManager.cs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/ARMeilleure/Memory/MemoryManager.cs b/ARMeilleure/Memory/MemoryManager.cs index c3f586aa..f813bd7e 100644 --- a/ARMeilleure/Memory/MemoryManager.cs +++ b/ARMeilleure/Memory/MemoryManager.cs @@ -268,33 +268,34 @@ namespace ARMeilleure.Memory while (address < endAddress) { - if (IsValidPosition((long)address)) + // If the address is invalid, we stop and consider all the remaining memory + // as not modified (since the address is invalid, we can't check, and technically + // the memory doesn't exist). + if (!IsValidPosition((long)address)) { - byte* ptr = ((byte**)_pageTable)[address >> PageBits]; + break; + } - ulong ptrUlong = (ulong)ptr; + byte* ptr = ((byte**)_pageTable)[address >> PageBits]; - if ((ptrUlong & idMask) == 0) - { - // Modified. - currSize += PageSize; + ulong ptrUlong = (ulong)ptr; - SetPtEntryFlag((long)address, (long)idMask); - } - else - { - if (currSize != 0) - { - ranges.Add((currAddr, currSize)); - } + if ((ptrUlong & idMask) == 0) + { + // Modified. + currSize += PageSize; - currAddr = address + PageSize; - currSize = 0; - } + SetPtEntryFlag((long)address, (long)idMask); } else { - currSize += PageSize; + if (currSize != 0) + { + ranges.Add((currAddr, currSize)); + } + + currAddr = address + PageSize; + currSize = 0; } address += PageSize; |