[NTOSKRNL]

When a VAD is truncated using VirtualFree, truncate the corresponding MemoryArea
so new allocations will match in both spaces.

svn path=/trunk/; revision=56727
This commit is contained in:
Art Yerkes 2012-06-12 22:31:54 +00:00
parent 343744d08b
commit cdb1c62cd1

View file

@ -4214,6 +4214,8 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
//
if ((EndingAddress >> PAGE_SHIFT) == Vad->EndingVpn)
{
PMEMORY_AREA MemoryArea;
//
// This is pretty easy and similar to case A. We compute the
// amount of pages to decommit, update the VAD's commit charge
@ -4226,7 +4228,12 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
Vad,
Process);
Vad->u.VadFlags.CommitCharge -= CommitReduction;
// For ReactOS: shrink the corresponding memory area
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)StartingAddress);
ASSERT(Vad->StartingVpn << PAGE_SHIFT == (ULONG_PTR)MemoryArea->StartingAddress);
ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT == (ULONG_PTR)MemoryArea->EndingAddress);
Vad->EndingVpn = ((ULONG_PTR)StartingAddress - 1) >> PAGE_SHIFT;
MemoryArea->EndingAddress = (PVOID)(((Vad->EndingVpn + 1) << PAGE_SHIFT) - 1);
}
else
{