Commit 6f2cf11d authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll/tests: Fix Wow64 tests failures on Windows 11 ARM64.

parent 29cd7982
...@@ -42,6 +42,23 @@ static NTSTATUS (WINAPI *pNtWow64WriteVirtualMemory64)(HANDLE,ULONG64,const void ...@@ -42,6 +42,23 @@ static NTSTATUS (WINAPI *pNtWow64WriteVirtualMemory64)(HANDLE,ULONG64,const void
static BOOL is_wow64; static BOOL is_wow64;
static void *code_mem; static void *code_mem;
#ifdef __i386__
static USHORT current_machine = IMAGE_FILE_MACHINE_I386;
static USHORT native_machine = IMAGE_FILE_MACHINE_I386;
#elif defined __x86_64__
static USHORT current_machine = IMAGE_FILE_MACHINE_AMD64;
static USHORT native_machine = IMAGE_FILE_MACHINE_AMD64;
#elif defined __arm__
static USHORT current_machine = IMAGE_FILE_MACHINE_ARMNT;
static USHORT native_machine = IMAGE_FILE_MACHINE_ARMNT;
#elif defined __aarch64__
static USHORT current_machine = IMAGE_FILE_MACHINE_ARM64;
static USHORT native_machine = IMAGE_FILE_MACHINE_ARM64;
#else
static USHORT current_machine;
static USHORT native_machine;
#endif
static void init(void) static void init(void)
{ {
HMODULE ntdll = GetModuleHandleA( "ntdll.dll" ); HMODULE ntdll = GetModuleHandleA( "ntdll.dll" );
...@@ -67,6 +84,27 @@ static void init(void) ...@@ -67,6 +84,27 @@ static void init(void)
#endif #endif
#undef GET_PROC #undef GET_PROC
if (is_wow64)
{
SYSTEM_CPU_INFORMATION info;
ULONG len;
pRtlGetNativeSystemInformation( SystemCpuInformation, &info, sizeof(info), &len );
switch (info.ProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_ARM64:
native_machine = IMAGE_FILE_MACHINE_ARM64;
break;
case PROCESSOR_ARCHITECTURE_AMD64:
native_machine = IMAGE_FILE_MACHINE_AMD64;
break;
case PROCESSOR_ARCHITECTURE_INTEL:
native_machine = IMAGE_FILE_MACHINE_AMD64;
break;
}
}
if (native_machine == IMAGE_FILE_MACHINE_AMD64)
code_mem = VirtualAlloc( NULL, 65536, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE ); code_mem = VirtualAlloc( NULL, 65536, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE );
} }
...@@ -122,22 +160,6 @@ static void test_process_architecture( HANDLE process, USHORT expect_machine, US ...@@ -122,22 +160,6 @@ static void test_process_architecture( HANDLE process, USHORT expect_machine, US
static void test_query_architectures(void) static void test_query_architectures(void)
{ {
#ifdef __i386__
USHORT current_machine = IMAGE_FILE_MACHINE_I386;
USHORT native_machine = is_wow64 ? IMAGE_FILE_MACHINE_AMD64 : IMAGE_FILE_MACHINE_I386;
#elif defined __x86_64__
USHORT current_machine = IMAGE_FILE_MACHINE_AMD64;
USHORT native_machine = IMAGE_FILE_MACHINE_AMD64;
#elif defined __arm__
USHORT current_machine = IMAGE_FILE_MACHINE_ARMNT;
USHORT native_machine = is_wow64 ? IMAGE_FILE_MACHINE_ARM64 : IMAGE_FILE_MACHINE_ARMNT;
#elif defined __aarch64__
USHORT current_machine = IMAGE_FILE_MACHINE_ARM64;
USHORT native_machine = IMAGE_FILE_MACHINE_ARM64;
#else
USHORT current_machine = 0;
USHORT native_machine = 0;
#endif
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFOA si = { sizeof(si) }; STARTUPINFOA si = { sizeof(si) };
NTSTATUS status; NTSTATUS status;
...@@ -209,11 +231,11 @@ static void test_query_architectures(void) ...@@ -209,11 +231,11 @@ static void test_query_architectures(void)
ret = 0xcc; ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_ARMNT, &ret ); status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_ARMNT, &ret );
ok( !status, "failed %lx\n", status ); ok( !status, "failed %lx\n", status );
ok( ret == (native_machine == IMAGE_FILE_MACHINE_ARM64), "wrong result %u\n", ret ); ok( !ret || native_machine == IMAGE_FILE_MACHINE_ARM64, "wrong result %u\n", ret );
ret = 0xcc; ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_AMD64, &ret ); status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_AMD64, &ret );
ok( !status, "failed %lx\n", status ); ok( !status, "failed %lx\n", status );
ok( !ret, "wrong result %u\n", ret ); ok( !ret || native_machine == IMAGE_FILE_MACHINE_ARM64, "wrong result %u\n", ret );
ret = 0xcc; ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_ARM64, &ret ); status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_ARM64, &ret );
ok( !status, "failed %lx\n", status ); ok( !status, "failed %lx\n", status );
...@@ -439,13 +461,14 @@ static void test_selectors(void) ...@@ -439,13 +461,14 @@ static void test_selectors(void)
if (!pRtlWow64GetThreadContext || pRtlWow64GetThreadContext( GetCurrentThread(), &context )) if (!pRtlWow64GetThreadContext || pRtlWow64GetThreadContext( GetCurrentThread(), &context ))
{ {
/* hardcoded values */ /* hardcoded values */
context.SegCs = 0x23;
#ifdef __x86_64__ #ifdef __x86_64__
context.SegCs = 0x23;
__asm__( "movw %%fs,%0" : "=m" (context.SegFs) ); __asm__( "movw %%fs,%0" : "=m" (context.SegFs) );
__asm__( "movw %%ss,%0" : "=m" (context.SegSs) ); __asm__( "movw %%ss,%0" : "=m" (context.SegSs) );
#else #else
context.SegSs = 0x2b; context.SegCs = 0x1b;
context.SegFs = 0x53; context.SegSs = 0x23;
context.SegFs = 0x3b;
#endif #endif
} }
#define GET_ENTRY(info,size,ret) \ #define GET_ENTRY(info,size,ret) \
...@@ -570,7 +593,7 @@ static void test_cpu_area(void) ...@@ -570,7 +593,7 @@ static void test_cpu_area(void)
{ {
USHORT machine; USHORT machine;
NTSTATUS expect; NTSTATUS expect;
ULONG align, size, offset, flag; ULONG_PTR align, size, offset, flag;
} tests[] = } tests[] =
{ {
{ IMAGE_FILE_MACHINE_I386, 0, 4, 0x2cc, 0x00, 0x00010000 }, { IMAGE_FILE_MACHINE_I386, 0, 4, 0x2cc, 0x00, 0x00010000 },
...@@ -663,7 +686,7 @@ static NTSTATUS call_func64( ULONG64 func64, int nb_args, ULONG64 *args ) ...@@ -663,7 +686,7 @@ static NTSTATUS call_func64( ULONG64 func64, int nb_args, ULONG64 *args )
} }
static ULONG64 main_module, ntdll_module, wow64_module, wow64base_module, wow64con_module, static ULONG64 main_module, ntdll_module, wow64_module, wow64base_module, wow64con_module,
wow64cpu_module, wow64win_module; wow64cpu_module, xtajit_module, wow64win_module;
static void enum_modules64( void (*func)(ULONG64,const WCHAR *) ) static void enum_modules64( void (*func)(ULONG64,const WCHAR *) )
{ {
...@@ -774,13 +797,16 @@ static void check_module( ULONG64 base, const WCHAR *name ) ...@@ -774,13 +797,16 @@ static void check_module( ULONG64 base, const WCHAR *name )
main_module = base; main_module = base;
return; return;
} }
#define CHECK_MODULE(mod) if (!wcsicmp( name, L"" #mod ".dll" )) { mod ## _module = base; return; } #define CHECK_MODULE(mod) do { if (!wcsicmp( name, L"" #mod ".dll" )) { mod ## _module = base; return; } } while(0)
CHECK_MODULE(ntdll); CHECK_MODULE(ntdll);
CHECK_MODULE(wow64); CHECK_MODULE(wow64);
CHECK_MODULE(wow64base); CHECK_MODULE(wow64base);
CHECK_MODULE(wow64con); CHECK_MODULE(wow64con);
CHECK_MODULE(wow64cpu);
CHECK_MODULE(wow64win); CHECK_MODULE(wow64win);
if (native_machine == IMAGE_FILE_MACHINE_ARM64)
CHECK_MODULE(xtajit);
else
CHECK_MODULE(wow64cpu);
#undef CHECK_MODULE #undef CHECK_MODULE
ok( 0, "unknown module %s %s found\n", wine_dbgstr_longlong(base), wine_dbgstr_w(name)); ok( 0, "unknown module %s %s found\n", wine_dbgstr_longlong(base), wine_dbgstr_w(name));
} }
...@@ -795,6 +821,9 @@ static void test_modules(void) ...@@ -795,6 +821,9 @@ static void test_modules(void)
ok( main_module, "main module not found\n" ); ok( main_module, "main module not found\n" );
ok( ntdll_module, "64-bit ntdll not found\n" ); ok( ntdll_module, "64-bit ntdll not found\n" );
ok( wow64_module, "wow64.dll not found\n" ); ok( wow64_module, "wow64.dll not found\n" );
if (native_machine == IMAGE_FILE_MACHINE_ARM64)
ok( xtajit_module, "xtajit.dll not found\n" );
else
ok( wow64cpu_module, "wow64cpu.dll not found\n" ); ok( wow64cpu_module, "wow64cpu.dll not found\n" );
ok( wow64win_module, "wow64win.dll not found\n" ); ok( wow64win_module, "wow64win.dll not found\n" );
} }
...@@ -1111,6 +1140,7 @@ static void test_iosb(void) ...@@ -1111,6 +1140,7 @@ static void test_iosb(void)
ULONG64 args[] = { 0, 0, 0, 0, (ULONG_PTR)&iosb64, FSCTL_PIPE_LISTEN, 0, 0, 0, 0 }; ULONG64 args[] = { 0, 0, 0, 0, (ULONG_PTR)&iosb64, FSCTL_PIPE_LISTEN, 0, 0, 0, 0 };
if (!is_wow64) return; if (!is_wow64) return;
if (!code_mem) return;
if (!ntdll_module) return; if (!ntdll_module) return;
func = get_proc_address64( ntdll_module, "NtFsControlFile" ); func = get_proc_address64( ntdll_module, "NtFsControlFile" );
...@@ -1217,6 +1247,7 @@ static void test_syscalls(void) ...@@ -1217,6 +1247,7 @@ static void test_syscalls(void)
NTSTATUS status; NTSTATUS status;
if (!is_wow64) return; if (!is_wow64) return;
if (!code_mem) return;
if (!ntdll_module) return; if (!ntdll_module) return;
func = get_proc_address64( wow64_module, "Wow64SystemServiceEx" ); func = get_proc_address64( wow64_module, "Wow64SystemServiceEx" );
...@@ -1300,6 +1331,7 @@ static void test_cpu_area(void) ...@@ -1300,6 +1331,7 @@ static void test_cpu_area(void)
NTSTATUS status; NTSTATUS status;
if (!is_wow64) return; if (!is_wow64) return;
if (!code_mem) return;
if (!ntdll_module) return; if (!ntdll_module) return;
if ((ptr = get_proc_address64( ntdll_module, "RtlWow64GetCurrentCpuArea" ))) if ((ptr = get_proc_address64( ntdll_module, "RtlWow64GetCurrentCpuArea" )))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment