Author: cwittich
Date: Mon Jan 19 04:27:59 2009
New Revision: 38932
URL:
http://svn.reactos.org/svn/reactos?rev=38932&view=rev
Log:
don't let VirtualProtect play with not committed memory
Modified:
trunk/reactos/ntoskrnl/mm/anonmem.c
Modified: trunk/reactos/ntoskrnl/mm/anonmem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/anonmem.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] Mon Jan 19 04:27:59 2009
@@ -1028,11 +1028,20 @@
Region = MmFindRegion(MemoryArea->StartingAddress,
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
BaseAddress, NULL);
- *OldProtect = Region->Protect;
- Status = MmAlterRegion(AddressSpace, MemoryArea->StartingAddress,
- &MemoryArea->Data.VirtualMemoryData.RegionListHead,
- BaseAddress, Length, Region->Type, Protect,
- MmModifyAttributes);
+ if (Region->Type == MEM_COMMIT)
+ {
+ /* FIXME: check if the whole range is committed
+ * before altering the memory */
+ *OldProtect = Region->Protect;
+ Status = MmAlterRegion(AddressSpace, MemoryArea->StartingAddress,
+ &MemoryArea->Data.VirtualMemoryData.RegionListHead,
+ BaseAddress, Length, Region->Type, Protect,
+ MmModifyAttributes);
+ }
+ else
+ {
+ Status = STATUS_NOT_COMMITTED;
+ }
return(Status);
}