[NTOSKRNL]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 22 May 2014 10:08:44 +0000 (10:08 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 22 May 2014 10:08:44 +0000 (10:08 +0000)
- Do not align the size of a memory area to the allocation granularity, but to PAGE_SIZE. Fixes OllyDbg regression from r61108. CORE-8168 #resolve
- Clarify the size calculation in MmCreateMemoryArea
- Silence a few DPRINTs

svn path=/trunk/; revision=63405

reactos/ntoskrnl/mm/ARM3/miarm.h
reactos/ntoskrnl/mm/ARM3/virtual.c
reactos/ntoskrnl/mm/marea.c

index d1cfbb4..6e803ae 100644 (file)
@@ -1100,11 +1100,11 @@ MI_WS_OWNER(IN PEPROCESS Process)
     /* Check if this process is the owner, and that the thread owns the WS */
     if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0)
     {
-        DPRINT1("Thread: %p is not an owner\n", PsGetCurrentThread());
+        DPRINT("Thread: %p is not an owner\n", PsGetCurrentThread());
     }
     if (KeGetCurrentThread()->ApcState.Process != &Process->Pcb)
     {
-        DPRINT1("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
+        DPRINT("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
     }
     return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
             ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||
index 3eef793..f82aedb 100644 (file)
@@ -1291,10 +1291,10 @@ MiGetPageProtection(IN PMMPTE PointerPte)
     }
 
     /* This is software PTE */
-    DPRINT1("Prototype PTE: %lx %p\n", TempPte.u.Hard.PageFrameNumber, Pfn);
-    DPRINT1("VA: %p\n", MiPteToAddress(&TempPte));
-    DPRINT1("Mask: %lx\n", TempPte.u.Soft.Protection);
-    DPRINT1("Mask2: %lx\n", Pfn->OriginalPte.u.Soft.Protection);
+    DPRINT("Prototype PTE: %lx %p\n", TempPte.u.Hard.PageFrameNumber, Pfn);
+    DPRINT("VA: %p\n", MiPteToAddress(&TempPte));
+    DPRINT("Mask: %lx\n", TempPte.u.Soft.Protection);
+    DPRINT("Mask2: %lx\n", Pfn->OriginalPte.u.Soft.Protection);
     return MmProtectToValue[TempPte.u.Soft.Protection];
 }
 
index 5deec1a..6ea4db4 100644 (file)
@@ -988,6 +988,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 {
    ULONG_PTR tmpLength;
    PMEMORY_AREA MemoryArea;
+   ULONG_PTR EndingAddress;
 
    DPRINT("MmCreateMemoryArea(Type 0x%lx, BaseAddress %p, "
           "*BaseAddress %p, Length %p, AllocationFlags %x, "
@@ -997,7 +998,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 
    if ((*BaseAddress) == 0 && !FixedAddress)
    {
-      tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, Granularity);
+      tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, PAGE_SIZE);
       *BaseAddress = MmFindGap(AddressSpace,
                                tmpLength,
                                Granularity,
@@ -1010,10 +1011,9 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
    }
    else
    {
-      tmpLength = Length + ((ULONG_PTR) *BaseAddress
-                         - (ULONG_PTR) MM_ROUND_DOWN(*BaseAddress, Granularity));
-      tmpLength = (ULONG_PTR)MM_ROUND_UP(tmpLength, Granularity);
-      *BaseAddress = MM_ROUND_DOWN(*BaseAddress, Granularity);
+      EndingAddress = ((ULONG_PTR)*BaseAddress + Length - 1) | (PAGE_SIZE - 1);
+      *BaseAddress = ALIGN_DOWN_POINTER_BY(*BaseAddress, Granularity);
+      tmpLength = EndingAddress + 1 - (ULONG_PTR)*BaseAddress;
 
       if (!MmGetAddressSpaceOwner(AddressSpace) && *BaseAddress < MmSystemRangeStart)
       {