=?UTF-8?Q?R=C3=A9mi=20Bernon=20?=: ntdll/tests: Add more NtMapViewOfSection tests with zero_bits.

Alexandre Julliard julliard at winehq.org
Thu Jun 20 16:04:18 CDT 2019


Module: wine
Branch: master
Commit: bec9a63f7ac7683305a3401fe005f2a6ef10db6a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=bec9a63f7ac7683305a3401fe005f2a6ef10db6a

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Jun 20 16:05:37 2019 +0200

ntdll/tests: Add more NtMapViewOfSection tests with zero_bits.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/virtual.c | 67 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
index 5a2effd..fce4049 100644
--- a/dlls/ntdll/tests/virtual.c
+++ b/dlls/ntdll/tests/virtual.c
@@ -299,25 +299,88 @@ static void test_NtMapViewOfSection(void)
     ok(result == sizeof(buffer), "ReadProcessMemory didn't read all data (%lx)\n", result);
     ok(!memcmp(buffer, data, sizeof(buffer)), "Wrong data read\n");
 
+    /* 1 zero bits should zero 63-31 upper bits */
     ptr2 = NULL;
     size = 0;
+    zero_bits = 1;
     offset.QuadPart = 0;
-    status = NtMapViewOfSection(mapping, process, &ptr2, 1, 0, &offset, &size, 1, 0, PAGE_READWRITE);
+    status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE);
     ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY,
        "NtMapViewOfSection returned %08x\n", status);
     if (status == STATUS_SUCCESS)
     {
+        todo_wine_if((UINT_PTR)ptr2 >> (32 - zero_bits))
+        ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0,
+           "NtMapViewOfSection returned address: %p\n", ptr2);
+
         status = NtUnmapViewOfSection(process, ptr2);
         ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status);
     }
 
-    /* 22 zero bits isn't acceptable */
+    for (zero_bits = 2; zero_bits <= 20; zero_bits++)
+    {
+        ptr2 = NULL;
+        size = 0;
+        offset.QuadPart = 0;
+        status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE);
+        ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY,
+           "NtMapViewOfSection with %d zero_bits returned %08x\n", zero_bits, status);
+        if (status == STATUS_SUCCESS)
+        {
+            todo_wine_if((UINT_PTR)ptr2 >> (32 - zero_bits))
+            ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0,
+               "NtMapViewOfSection with %d zero_bits returned address %p\n", zero_bits, ptr2);
+
+            status = NtUnmapViewOfSection(process, ptr2);
+            ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status);
+        }
+    }
+
+    /* 21 zero bits never succeeds */
+    ptr2 = NULL;
+    size = 0;
+    offset.QuadPart = 0;
+    status = NtMapViewOfSection(mapping, process, &ptr2, 21, 0, &offset, &size, 1, 0, PAGE_READWRITE);
+    todo_wine
+    ok(status == STATUS_NO_MEMORY || status == STATUS_INVALID_PARAMETER,
+       "NtMapViewOfSection returned %08x\n", status);
+
+    /* 22 zero bits is invalid */
     ptr2 = NULL;
     size = 0;
+    offset.QuadPart = 0;
     status = NtMapViewOfSection(mapping, process, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE);
     ok(status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER,
        "NtMapViewOfSection returned %08x\n", status);
 
+    /* zero bits > 31 should be considered as bitmask on 64bit and WoW64 */
+    ptr2 = NULL;
+    size = 0;
+    zero_bits = 0x1fffffff;
+    offset.QuadPart = 0;
+    status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE);
+
+    if (sizeof(void *) == sizeof(int) && (!pIsWow64Process ||
+        !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64))
+    {
+        ok(status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %08x\n", status);
+    }
+    else
+    {
+        todo_wine
+        ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY,
+           "NtMapViewOfSection returned %08x\n", status);
+        if (status == STATUS_SUCCESS)
+        {
+            todo_wine_if((UINT_PTR)ptr2 & ~zero_bits)
+            ok(((UINT_PTR)ptr2 & ~zero_bits) == 0,
+               "NtMapViewOfSection returned address %p\n", ptr2);
+
+            status = NtUnmapViewOfSection(process, ptr2);
+            ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status);
+        }
+    }
+
     /* mapping at the same page conflicts */
     ptr2 = ptr;
     size = 0;




More information about the wine-cvs mailing list