[PATCH v2 7/8] ntdll/tests: Factor WoW64 checks and add is_win64 constant

Rémi Bernon rbernon at codeweavers.com
Fri Jun 14 08:11:16 CDT 2019


This is in order to use todo_wine_if(is_win64) in next patch.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/ntdll/tests/virtual.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
index 8693194ae84..a338bf1db09 100644
--- a/dlls/ntdll/tests/virtual.c
+++ b/dlls/ntdll/tests/virtual.c
@@ -27,6 +27,7 @@
 #include "wine/test.h"
 
 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
+const BOOL is_win64 = sizeof(void*) > sizeof(int);
 
 static void test_AllocateVirtualMemory(void)
 {
@@ -36,6 +37,8 @@ static void test_AllocateVirtualMemory(void)
     ULONG zero_bits;
     BOOL is_wow64;
 
+    if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE;
+
     /* simple allocation should success */
     size = 0x1000;
     addr1 = NULL;
@@ -138,8 +141,7 @@ static void test_AllocateVirtualMemory(void)
     status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size,
                                       MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
 
-    if (sizeof(void *) == sizeof(int) && (!pIsWow64Process ||
-        !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64))
+    if (!is_win64 && !is_wow64)
     {
         ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status);
     }
@@ -183,6 +185,8 @@ static void test_MapViewOfSection(void)
     LARGE_INTEGER offset, map_size;
     ULONG zero_bits;
 
+    if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE;
+
     map_size.QuadPart = 0x1000;
     status = NtCreateSection(&mapping, SECTION_MAP_READ | SECTION_MAP_WRITE, NULL,
                              &map_size, PAGE_READWRITE, SEC_COMMIT, NULL);
@@ -265,8 +269,7 @@ static void test_MapViewOfSection(void)
     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))
+    if (!is_win64 && !is_wow64)
     {
         ok(status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %08x\n", status);
     }
@@ -327,8 +330,7 @@ static void test_MapViewOfSection(void)
        broken(STATUS_MAPPED_ALIGNMENT) /* w1064v1809 inconsistently returns STATUS_MAPPED_ALIGNMENT or STATUS_INVALID_PARAMETER */,
        "NtMapViewOfSection returned %08x\n", status);
 
-    if (sizeof(void *) == sizeof(int) && (!pIsWow64Process ||
-        !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64))
+    if (!is_win64 && !is_wow64)
     {
         /* new memory region conflicts with previous mapping */
         ptr2 = ptr;
-- 
2.20.1




More information about the wine-devel mailing list