From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/ntdll/tests/wow64.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/dlls/ntdll/tests/wow64.c b/dlls/ntdll/tests/wow64.c index 160979d2940..59601c49563 100644 --- a/dlls/ntdll/tests/wow64.c +++ b/dlls/ntdll/tests/wow64.c @@ -153,8 +153,11 @@ static void init(void) { SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION machines[8]; HANDLE process = GetCurrentProcess(); - NTSTATUS status = pNtQuerySystemInformationEx( SystemSupportedProcessorArchitectures, &process, + NTSTATUS status = pNtQuerySystemInformationEx( SystemSupportedProcessorArchitectures2, &process, sizeof(process), machines, sizeof(machines), NULL ); + if (status) + status = pNtQuerySystemInformationEx( SystemSupportedProcessorArchitectures, &process, + sizeof(process), machines, sizeof(machines), NULL ); if (!status) for (int i = 0; machines[i].Machine; i++) trace( "machine %04x kernel %u user %u native %u process %u wow64 %u\n", @@ -209,6 +212,10 @@ static void test_process_architecture( SYSTEM_INFORMATION_CLASS class, HANDLE pr NTSTATUS status; ULONG i, len; + if (class == SystemSupportedProcessorArchitectures && + native_machine == IMAGE_FILE_MACHINE_ARM64 && expect_machine == IMAGE_FILE_MACHINE_AMD64) + expect_machine = IMAGE_FILE_MACHINE_ARM64; + len = 0xdead; status = pNtQuerySystemInformationEx( class, &process, sizeof(process), machines, sizeof(machines), &len ); @@ -230,6 +237,10 @@ static void test_process_architecture( SYSTEM_INFORMATION_CLASS class, HANDLE pr if (machines[i].WoW64Container) ok( is_machine_32bit( machines[i].Machine ) && !is_machine_32bit( native_machine ), "wrong wow64 %x\n", machines[i].Machine); + + if (class == SystemSupportedProcessorArchitectures && native_machine == IMAGE_FILE_MACHINE_ARM64) + ok( machines[i].Machine != IMAGE_FILE_MACHINE_AMD64, + "SystemSupportedProcessorArchitectures returned AMD64\n"); } ok( !*(DWORD *)&machines[i], "missing terminating null\n" ); @@ -244,7 +255,8 @@ static void test_process_architecture( SYSTEM_INFORMATION_CLASS class, HANDLE pr USHORT current = 0xdead, native = 0xbeef; status = pRtlWow64GetProcessMachines( process, ¤t, &native ); ok( !status, "failed %lx\n", status ); - if (expect_machine == expect_native) + if (expect_machine != IMAGE_FILE_MACHINE_I386 && + expect_machine != IMAGE_FILE_MACHINE_ARMNT) ok( current == 0, "wrong current machine %x / %x\n", current, expect_machine ); else ok( current == expect_machine, "wrong current machine %x / %x\n", current, expect_machine ); @@ -315,6 +327,7 @@ static void test_query_architectures(SYSTEM_INFORMATION_CLASS class) NTSTATUS status; HANDLE process; ULONG i, len; + USHORT machine; #ifdef __arm64ec__ BOOL is_arm64ec = TRUE; #else @@ -328,7 +341,8 @@ static void test_query_architectures(SYSTEM_INFORMATION_CLASS class) machines, sizeof(machines), &len ); if (status == STATUS_INVALID_INFO_CLASS) { - win_skip( "SystemSupportedProcessorArchitectures not supported\n" ); + win_skip( "SystemSupportedProcessorArchitectures%s not supported\n", + class == SystemSupportedProcessorArchitectures2 ? "2" : "" ); return; } ok( !status, "failed %lx\n", status ); @@ -352,7 +366,7 @@ static void test_query_architectures(SYSTEM_INFORMATION_CLASS class) ok( status == STATUS_INVALID_PARAMETER, "failed %lx\n", status ); winetest_push_context( "current" ); - test_process_architecture( class, GetCurrentProcess(), is_win64 ? native_machine : current_machine, + test_process_architecture( class, GetCurrentProcess(), current_machine, native_machine ); test_process_machine( GetCurrentProcess(), GetCurrentThread(), current_machine, is_arm64ec ? native_machine : current_machine ); @@ -362,11 +376,11 @@ static void test_query_architectures(SYSTEM_INFORMATION_CLASS class) test_process_architecture( class, 0, 0, native_machine ); winetest_pop_context(); - if (CreateProcessA( NULL, is_win64 ? cmd_system32 : cmd_sysnative, NULL, NULL, - FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi )) + machine = (is_win64 && native_machine == IMAGE_FILE_MACHINE_ARM64) ? current_machine : IMAGE_FILE_MACHINE_AMD64; + if (create_process_machine( is_win64 ? cmd_system32 : cmd_sysnative, CREATE_SUSPENDED, machine, &pi )) { winetest_push_context( "system32" ); - test_process_architecture( class, pi.hProcess, native_machine, native_machine ); + test_process_architecture( class, pi.hProcess, machine, native_machine ); test_process_machine( pi.hProcess, pi.hThread, is_win64 ? current_machine : native_machine, native_machine ); TerminateProcess( pi.hProcess, 0 ); @@ -392,7 +406,7 @@ static void test_query_architectures(SYSTEM_INFORMATION_CLASS class) if (create_process_machine( cmd_system32, CREATE_SUSPENDED, machine, &pi )) { winetest_push_context( "%04x", machine ); - test_process_architecture( class, pi.hProcess, native_machine, native_machine ); + test_process_architecture( class, pi.hProcess, machine, native_machine ); test_process_machine( pi.hProcess, pi.hThread, machine, native_machine ); TerminateProcess( pi.hProcess, 0 ); CloseHandle( pi.hProcess ); @@ -3213,6 +3227,7 @@ START_TEST(wow64) { init(); test_query_architectures(SystemSupportedProcessorArchitectures); + test_query_architectures(SystemSupportedProcessorArchitectures2); test_peb_teb(); test_selectors(); test_image_mappings(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10526