From c34fe70bfeeae25b6dab50310d216de28380f23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 10 Jul 2011 19:24:49 +0000 Subject: [PATCH] [NTOSKRNL/MM] - The initial region does not necessarily begins with the asked address, calculate remaining space acccordingly. svn path=/trunk/; revision=52616 --- reactos/ntoskrnl/mm/region.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/reactos/ntoskrnl/mm/region.c b/reactos/ntoskrnl/mm/region.c index 325457bcca6..a1077e33f65 100644 --- a/reactos/ntoskrnl/mm/region.c +++ b/reactos/ntoskrnl/mm/region.c @@ -135,16 +135,20 @@ MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress, { return(STATUS_NO_MEMORY); } + if(NewRegion->Length < Length) + RemainingLength = Length - NewRegion->Length; + else + RemainingLength = 0; } else { NewRegion = InitialRegion; + if(((ULONG_PTR)InitialBaseAddress + NewRegion->Length) < + ((ULONG_PTR)StartAddress + Length)) + RemainingLength = ((ULONG_PTR)StartAddress + Length) - ((ULONG_PTR)InitialBaseAddress + NewRegion->Length); + else + RemainingLength = 0; } - - if(NewRegion->Length < Length) - RemainingLength = Length - NewRegion->Length; - else - RemainingLength = 0; /* * Free any complete regions that are containing in the range of addresses