Dmitry Timoshkov : kernelbase: Native machine is optional for IsWow64Process2.

Alexandre Julliard julliard at winehq.org
Tue Aug 18 16:34:24 CDT 2020


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Aug 18 17:59:01 2020 +0300

kernelbase: Native machine is optional for IsWow64Process2.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49716
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/process.c | 15 +++++++++++++++
 dlls/kernelbase/process.c     | 11 ++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index eaa5da2e95..3162ba3c53 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -2238,6 +2238,12 @@ static void test_IsWow64Process2(void)
     ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
     ok(native_machine == expect_native, "got %#x\n", native_machine);
 
+    SetLastError(0xdeadbeef);
+    machine = 0xdead;
+    ret = pIsWow64Process2(pi.hProcess, &machine, NULL);
+    ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+    ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
+
     ret = TerminateProcess(pi.hProcess, 0);
     ok(ret, "TerminateProcess error\n");
 
@@ -2263,6 +2269,15 @@ static void test_IsWow64Process2(void)
         ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
         ok(native_machine == expect_native, "got %#x\n", native_machine);
     }
+
+    SetLastError(0xdeadbeef);
+    machine = 0xdead;
+    ret = pIsWow64Process2(GetCurrentProcess(), &machine, NULL);
+    ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+    if (is_wow64)
+        ok(machine == IMAGE_FILE_MACHINE_I386, "got %#x\n", machine);
+    else
+        ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
 }
 
 static void test_SystemInfo(void)
diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c
index 936eed4d18..2b9b1c019e 100644
--- a/dlls/kernelbase/process.c
+++ b/dlls/kernelbase/process.c
@@ -899,8 +899,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process2( HANDLE process, USHORT *machine,
 
     if (wow64)
     {
-        GetNativeSystemInfo( &si );
-
         if (process != GetCurrentProcess())
         {
 #if defined(__i386__) || defined(__x86_64__)
@@ -916,15 +914,22 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process2( HANDLE process, USHORT *machine,
             nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress );
             *machine = nt->FileHeader.Machine;
         }
+
+        if (!native_machine) return TRUE;
+
+        GetNativeSystemInfo( &si );
     }
     else
     {
+        *machine = IMAGE_FILE_MACHINE_UNKNOWN;
+
+        if (!native_machine) return TRUE;
+
 #ifdef _WIN64
         GetSystemInfo( &si );
 #else
         GetNativeSystemInfo( &si );
 #endif
-        *machine = IMAGE_FILE_MACHINE_UNKNOWN;
     }
 
     switch (si.u.s.wProcessorArchitecture)




More information about the wine-cvs mailing list