From 365727d3e7e50f5940c2f7cb633acb67fe1102f2 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Wed, 13 May 2015 23:23:17 +0000 Subject: [PATCH] [NTVDM] Fill the part of the buffer that was supposed to receive memory data above the MAX_ADDRESS with 0xFF. svn path=/trunk/; revision=67707 --- reactos/subsystems/mvdm/ntvdm/emulator.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reactos/subsystems/mvdm/ntvdm/emulator.c b/reactos/subsystems/mvdm/ntvdm/emulator.c index 1f0a3d88cc0..71eb0056982 100644 --- a/reactos/subsystems/mvdm/ntvdm/emulator.c +++ b/reactos/subsystems/mvdm/ntvdm/emulator.c @@ -73,8 +73,16 @@ VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer /* If the A20 line is disabled, mask bit 20 */ if (!A20Line) Address &= ~(1 << 20); - if (Address >= MAX_ADDRESS) return; - Size = min(Size, MAX_ADDRESS - Address); + if ((Address + Size - 1) >= MAX_ADDRESS) + { + ULONG ExtraStart = (Address < MAX_ADDRESS) ? MAX_ADDRESS - Address : 0; + + /* Fill the memory that was above the limit with 0xFF */ + RtlFillMemory((PVOID)((ULONG_PTR)Buffer + ExtraStart), Size - ExtraStart, 0xFF); + + if (Address < MAX_ADDRESS) Size = MAX_ADDRESS - Address; + else return; + } /* Read while calling fast memory hooks */ MemRead(Address, Buffer, Size);