From 46b0236d75419be9462c8114e4c6d8bbb5a0b490 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Tue, 5 Oct 2010 05:00:19 +0000 Subject: [PATCH] [NTOS]: Use the Spare flag in the VAD as a ReactOS/MemoryArea specific flag to signify that this VAD is associated with a MEMORY_AREA and should be unlinked at process exit, but not freed. This is because MemoryAreas themselves are cleaned up later, and in the future their associated VADs (not yet in Trunk) will also be parsed. In the process death scenario, those VADs will be freed, but not unlinked (since it would already have been unlinked). svn path=/trunk/; revision=48990 --- reactos/ntoskrnl/mm/ARM3/procsup.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index e0b840df203..f881922d54f 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -125,7 +125,7 @@ MiCreatePebOrTeb(IN PEPROCESS Process, /* Build the rest of the VAD now */ Vad->StartingVpn = (*Base) >> PAGE_SHIFT; - Vad->EndingVpn = ((*Base) + Size - 1) >> PAGE_SHIFT; + Vad->EndingVpn = ((*Base) + Size - 1) >> PAGE_SHIFT; Vad->u3.Secured.StartVpn = *Base; Vad->u3.Secured.EndVpn = (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1); Vad->u1.Parent = NULL; @@ -1195,6 +1195,14 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process) /* Release the working set */ MiUnlockProcessWorkingSet(Process, Thread); + /* Skip ARM3 fake VADs, they'll be freed by MmDeleteProcessAddresSpace */ + if (Vad->u.VadFlags.Spare == 1) + { + /* Set a flag so MmDeleteMemoryArea knows to free, but not to remove */ + Vad->u.VadFlags.Spare = 2; + continue; + } + /* Free the VAD memory */ ExFreePool(Vad); }