kernelbase: Native machine is optional for IsWow64Process2.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49716
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2020-08-18 17:59:01 +03:00 committed by Alexandre Julliard
parent cd9f30f35b
commit 3786462a56
2 changed files with 23 additions and 3 deletions

View File

@ -2238,6 +2238,12 @@ static void test_IsWow64Process2(void)
ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine); ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
ok(native_machine == expect_native, "got %#x\n", native_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); ret = TerminateProcess(pi.hProcess, 0);
ok(ret, "TerminateProcess error\n"); 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(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
ok(native_machine == expect_native, "got %#x\n", native_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) static void test_SystemInfo(void)

View File

@ -899,8 +899,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process2( HANDLE process, USHORT *machine,
if (wow64) if (wow64)
{ {
GetNativeSystemInfo( &si );
if (process != GetCurrentProcess()) if (process != GetCurrentProcess())
{ {
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
@ -916,15 +914,22 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process2( HANDLE process, USHORT *machine,
nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress ); nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress );
*machine = nt->FileHeader.Machine; *machine = nt->FileHeader.Machine;
} }
if (!native_machine) return TRUE;
GetNativeSystemInfo( &si );
} }
else else
{ {
*machine = IMAGE_FILE_MACHINE_UNKNOWN;
if (!native_machine) return TRUE;
#ifdef _WIN64 #ifdef _WIN64
GetSystemInfo( &si ); GetSystemInfo( &si );
#else #else
GetNativeSystemInfo( &si ); GetNativeSystemInfo( &si );
#endif #endif
*machine = IMAGE_FILE_MACHINE_UNKNOWN;
} }
switch (si.u.s.wProcessorArchitecture) switch (si.u.s.wProcessorArchitecture)