From 6181543561fd98515d5c75fb98d0ea3f1df00f72 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 11 Jul 2009 13:40:56 +0000 Subject: [PATCH] - NtMapViewOfSection: When referencing the section object by handle, don't assume access mask of SECTION_MAP_READ. Access mask must be determined from page protection attributes passed in Protect parameter. Fixes 5 winetests for kernel32 virtual. svn path=/trunk/; revision=41885 --- reactos/ntoskrnl/mm/section.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index ddb4960a1e0..b52795d22a7 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -3729,6 +3729,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, PMMSUPPORT AddressSpace; NTSTATUS Status = STATUS_SUCCESS; ULONG tmpProtect; + ACCESS_MASK DesiredAccess; /* * Check the protection @@ -3807,8 +3808,27 @@ NtMapViewOfSection(IN HANDLE SectionHandle, AddressSpace = &Process->Vm; + /* Convert NT Protection Attr to Access Mask */ + if (Protect == PAGE_READONLY) + { + DesiredAccess = SECTION_MAP_READ; + } + else if (Protect == PAGE_READWRITE) + { + DesiredAccess = SECTION_MAP_WRITE; + } + else if (Protect == PAGE_WRITECOPY) + { + DesiredAccess = SECTION_QUERY; + } + /* FIXME: Handle other Protection Attributes. For now keep previous behavior */ + else + { + DesiredAccess = SECTION_MAP_READ; + } + Status = ObReferenceObjectByHandle(SectionHandle, - SECTION_MAP_READ, + DesiredAccess, MmSectionObjectType, PreviousMode, (PVOID*)(PVOID)&Section,