[PATCH v5 4/6] ntdll/tests: Add more NtMapViewOfSection tests with zero_bits
Rémi Bernon
rbernon at codeweavers.com
Thu Jun 20 09:05:37 CDT 2019
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
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 5ca73435541..7ea4d436e14 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;
--
2.20.1
More information about the wine-devel
mailing list