From b4fe8f646f04bfec646b2ca6712f7ef05c4a19ec Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Thu, 25 Apr 2013 15:54:45 +0000 Subject: [PATCH] [NTOSKRNL] * Make sure that BaseAddress is at 64-k boundary in NtMapViewOfSection(). Fixes a couple NtMapViewOfSection tests. * Brought to you by Zhan Jianyu (aka larmbr) with review and improvement by Timo. CORE-7118 #resolve #comment A slightly improved fix was committed in r58851. Thanks ;) svn path=/trunk/; revision=58851 --- reactos/ntoskrnl/mm/ARM3/section.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index b3c4674aa74..3ea75c7c3bf 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -3040,6 +3040,13 @@ NtMapViewOfSection(IN HANDLE SectionHandle, return STATUS_INVALID_PAGE_PROTECTION; } + /* Check for non-allocation-granularity-aligned BaseAddress */ + if (BaseAddress && (*BaseAddress != ALIGN_DOWN_POINTER_BY(*BaseAddress, MM_VIRTMEM_GRANULARITY))) + { + DPRINT("BaseAddress is not at 64-kilobyte address boundary."); + return STATUS_MAPPED_ALIGNMENT; + } + /* Now convert the protection mask into desired section access mask */ DesiredAccess = MmMakeSectionAccess[ProtectionMask & 0x7];