* Sync up to trunk r55544.
[reactos.git] / ntoskrnl / mm / anonmem.c
index 88ca97b..ce73607 100644 (file)
@@ -556,6 +556,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
     KAPC_STATE ApcState;
     ULONG ProtectionMask;
     BOOLEAN Attached = FALSE;
+    ULONG_PTR EndingAddress;
     BoundaryAddressMultiple.QuadPart = 0;
     PAGED_CODE();
 
@@ -876,7 +877,9 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
 
     MemoryAreaLength = (ULONG_PTR)MemoryArea->EndingAddress -
         (ULONG_PTR)MemoryArea->StartingAddress;
-
+    EndingAddress = ((ULONG_PTR)MemoryArea->StartingAddress + RegionSize - 1) | (PAGE_SIZE - 1);
+    RegionSize = (ULONG_PTR)EndingAddress - (ULONG_PTR)MemoryArea->StartingAddress + 1; 
+    
     MmInitializeRegion(&MemoryArea->Data.VirtualMemoryData.RegionListHead,
         MemoryAreaLength, Type, Protect);
 
@@ -892,7 +895,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
     if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process);
 
     *UBaseAddress = BaseAddress;
-    *URegionSize = MemoryAreaLength;
+    *URegionSize = RegionSize;
     DPRINT("*UBaseAddress %x  *URegionSize %x\n", BaseAddress, RegionSize);
 
     return(STATUS_SUCCESS);