Author: sir_richard
Date: Wed Jul 21 17:58:09 2010
New Revision: 48163
URL:
http://svn.reactos.org/svn/reactos?rev=48163&view=rev
Log:
[NTOS]: If the memory area is owned by ARM3, and it's being freed, don't touch the
pages, just unlink it and free the memory. This is useful for MAREAs being used by ARM3 to
protect pieces of address space from the Ros Mm Allocator, but when we don't want it
to start playing with our pages. When we do free those MAREAs, keep it away!
Modified:
trunk/reactos/ntoskrnl/mm/marea.c
Modified: trunk/reactos/ntoskrnl/mm/marea.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=48…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Wed Jul 21 17:58:09 2010
@@ -732,51 +732,55 @@
PMEMORY_AREA *ParentReplace;
ULONG_PTR Address;
PVOID EndAddress;
- PEPROCESS CurrentProcess = PsGetCurrentProcess();
- PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
-
- if (Process != NULL &&
- Process != CurrentProcess)
- {
- KeAttachProcess(&Process->Pcb);
- }
-
- EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE);
- for (Address = (ULONG_PTR)MemoryArea->StartingAddress;
- Address < (ULONG_PTR)EndAddress;
- Address += PAGE_SIZE)
- {
- if (MemoryArea->Type == MEMORY_AREA_IO_MAPPING)
- {
- MmRawDeleteVirtualMapping((PVOID)Address);
- }
- else
- {
- BOOLEAN Dirty = FALSE;
- SWAPENTRY SwapEntry = 0;
- PFN_NUMBER Page = 0;
-
- if (MmIsPageSwapEntry(Process, (PVOID)Address))
- {
- MmDeletePageFileMapping(Process, (PVOID)Address, &SwapEntry);
- }
- else
- {
- MmDeleteVirtualMapping(Process, (PVOID)Address, FALSE, &Dirty,
&Page);
- }
- if (FreePage != NULL)
- {
- FreePage(FreePageContext, MemoryArea, (PVOID)Address,
- Page, SwapEntry, (BOOLEAN)Dirty);
- }
- }
- }
-
- if (Process != NULL &&
- Process != CurrentProcess)
- {
- KeDetachProcess();
- }
+
+ if (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3)
+ {
+ PEPROCESS CurrentProcess = PsGetCurrentProcess();
+ PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
+
+ if (Process != NULL &&
+ Process != CurrentProcess)
+ {
+ KeAttachProcess(&Process->Pcb);
+ }
+
+ EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE);
+ for (Address = (ULONG_PTR)MemoryArea->StartingAddress;
+ Address < (ULONG_PTR)EndAddress;
+ Address += PAGE_SIZE)
+ {
+ if (MemoryArea->Type == MEMORY_AREA_IO_MAPPING)
+ {
+ MmRawDeleteVirtualMapping((PVOID)Address);
+ }
+ else
+ {
+ BOOLEAN Dirty = FALSE;
+ SWAPENTRY SwapEntry = 0;
+ PFN_NUMBER Page = 0;
+
+ if (MmIsPageSwapEntry(Process, (PVOID)Address))
+ {
+ MmDeletePageFileMapping(Process, (PVOID)Address, &SwapEntry);
+ }
+ else
+ {
+ MmDeleteVirtualMapping(Process, (PVOID)Address, FALSE, &Dirty,
&Page);
+ }
+ if (FreePage != NULL)
+ {
+ FreePage(FreePageContext, MemoryArea, (PVOID)Address,
+ Page, SwapEntry, (BOOLEAN)Dirty);
+ }
+ }
+ }
+
+ if (Process != NULL &&
+ Process != CurrentProcess)
+ {
+ KeDetachProcess();
+ }
+ }
/* Remove the tree item. */
{