Sebastian Lackner : ntdll: NtMapViewOfSection should fail if both addr_ptr and zero_bits is set.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 26 07:11:54 CDT 2015


Module: wine
Branch: master
Commit: 7a8470ea945340c523af2d576b37ce168d951a27
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7a8470ea945340c523af2d576b37ce168d951a27

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Fri Jun 26 07:46:23 2015 +0200

ntdll: NtMapViewOfSection should fail if both addr_ptr and zero_bits is set.

---

 dlls/kernel32/tests/virtual.c | 24 ++++++++++++------------
 dlls/ntdll/virtual.c          |  3 +++
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 6082740..008376c 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -1093,25 +1093,25 @@ static void test_NtMapViewOfSection(void)
     size = 0;
     offset.QuadPart = 0;
     status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 12, 0, &offset, &size, 1, 0, PAGE_READWRITE );
-    todo_wine
     ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status );
-    if (status == STATUS_SUCCESS)
-    {
-        status = pNtUnmapViewOfSection( hProcess, ptr2 );
-        ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
-    }
 
     ptr2 = (char *)ptr + 0x1000;
     size = 0;
     offset.QuadPart = 0;
     status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE );
-    todo_wine
     ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status );
-    if (status == STATUS_SUCCESS)
-    {
-        status = pNtUnmapViewOfSection( hProcess, ptr2 );
-        ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
-    }
+
+    ptr2 = (char *)ptr + 0x1001;
+    size = 0;
+    offset.QuadPart = 0;
+    status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE );
+    ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status );
+
+    ptr2 = (char *)ptr + 0x1000;
+    size = 0;
+    offset.QuadPart = 1;
+    status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE );
+    ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status );
 
     if (sizeof(void *) == sizeof(int) && (!pIsWow64Process ||
         !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64))
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 72309f6..a010e3b4 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2601,6 +2601,9 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
 
     /* Check parameters */
 
+    if (*addr_ptr && zero_bits)
+        return STATUS_INVALID_PARAMETER_4;
+
     if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))
         return STATUS_MAPPED_ALIGNMENT;
 




More information about the wine-cvs mailing list