From bbbef82de905b495512f3371764f759a996c8eca Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 22 May 2014 10:08:44 +0000 Subject: [PATCH] [NTOSKRNL] - 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 | 4 ++-- reactos/ntoskrnl/mm/ARM3/virtual.c | 8 ++++---- reactos/ntoskrnl/mm/marea.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/miarm.h b/reactos/ntoskrnl/mm/ARM3/miarm.h index d1cfbb4a24d..6e803aeb7d0 100644 --- a/reactos/ntoskrnl/mm/ARM3/miarm.h +++ b/reactos/ntoskrnl/mm/ARM3/miarm.h @@ -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) || diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 3eef793fcd9..f82aedb9c9f 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -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]; } diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 5deec1abb9b..6ea4db48075 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -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) {