From 23ef53ceff9c180ddf8d0098d55929a599ea6cb5 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 19 Jan 2009 10:27:59 +0000 Subject: [PATCH] don't let VirtualProtect play with not committed memory svn path=/trunk/; revision=38932 --- reactos/ntoskrnl/mm/anonmem.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/reactos/ntoskrnl/mm/anonmem.c b/reactos/ntoskrnl/mm/anonmem.c index c1003717943..b75c6b7e874 100644 --- a/reactos/ntoskrnl/mm/anonmem.c +++ b/reactos/ntoskrnl/mm/anonmem.c @@ -1028,11 +1028,20 @@ MmProtectAnonMem(PMM_AVL_TABLE AddressSpace, 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); }