[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
This commit is contained in:
Timo Kreuzer 2014-05-22 10:08:44 +00:00
parent 16a52a9e08
commit bbbef82de9
3 changed files with 11 additions and 11 deletions

View 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 */ /* Check if this process is the owner, and that the thread owns the WS */
if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0) 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) 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) && return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) || ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||

View file

@ -1291,10 +1291,10 @@ MiGetPageProtection(IN PMMPTE PointerPte)
} }
/* This is software PTE */ /* This is software PTE */
DPRINT1("Prototype PTE: %lx %p\n", TempPte.u.Hard.PageFrameNumber, Pfn); DPRINT("Prototype PTE: %lx %p\n", TempPte.u.Hard.PageFrameNumber, Pfn);
DPRINT1("VA: %p\n", MiPteToAddress(&TempPte)); DPRINT("VA: %p\n", MiPteToAddress(&TempPte));
DPRINT1("Mask: %lx\n", TempPte.u.Soft.Protection); DPRINT("Mask: %lx\n", TempPte.u.Soft.Protection);
DPRINT1("Mask2: %lx\n", Pfn->OriginalPte.u.Soft.Protection); DPRINT("Mask2: %lx\n", Pfn->OriginalPte.u.Soft.Protection);
return MmProtectToValue[TempPte.u.Soft.Protection]; return MmProtectToValue[TempPte.u.Soft.Protection];
} }

View file

@ -988,6 +988,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
{ {
ULONG_PTR tmpLength; ULONG_PTR tmpLength;
PMEMORY_AREA MemoryArea; PMEMORY_AREA MemoryArea;
ULONG_PTR EndingAddress;
DPRINT("MmCreateMemoryArea(Type 0x%lx, BaseAddress %p, " DPRINT("MmCreateMemoryArea(Type 0x%lx, BaseAddress %p, "
"*BaseAddress %p, Length %p, AllocationFlags %x, " "*BaseAddress %p, Length %p, AllocationFlags %x, "
@ -997,7 +998,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
if ((*BaseAddress) == 0 && !FixedAddress) if ((*BaseAddress) == 0 && !FixedAddress)
{ {
tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, Granularity); tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, PAGE_SIZE);
*BaseAddress = MmFindGap(AddressSpace, *BaseAddress = MmFindGap(AddressSpace,
tmpLength, tmpLength,
Granularity, Granularity,
@ -1010,10 +1011,9 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
} }
else else
{ {
tmpLength = Length + ((ULONG_PTR) *BaseAddress EndingAddress = ((ULONG_PTR)*BaseAddress + Length - 1) | (PAGE_SIZE - 1);
- (ULONG_PTR) MM_ROUND_DOWN(*BaseAddress, Granularity)); *BaseAddress = ALIGN_DOWN_POINTER_BY(*BaseAddress, Granularity);
tmpLength = (ULONG_PTR)MM_ROUND_UP(tmpLength, Granularity); tmpLength = EndingAddress + 1 - (ULONG_PTR)*BaseAddress;
*BaseAddress = MM_ROUND_DOWN(*BaseAddress, Granularity);
if (!MmGetAddressSpaceOwner(AddressSpace) && *BaseAddress < MmSystemRangeStart) if (!MmGetAddressSpaceOwner(AddressSpace) && *BaseAddress < MmSystemRangeStart)
{ {