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
static BOOL is_wow64;
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)
{
HMODULE ntdll = GetModuleHandleA( "ntdll.dll" );
......@@ -67,7 +84,28 @@ static void init(void)
#endif
#undef GET_PROC
code_mem = VirtualAlloc( NULL, 65536, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE );
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 );
}
static void test_process_architecture( HANDLE process, USHORT expect_machine, USHORT expect_native )
......@@ -122,22 +160,6 @@ static void test_process_architecture( HANDLE process, USHORT expect_machine, US
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;
STARTUPINFOA si = { sizeof(si) };
NTSTATUS status;
......@@ -209,11 +231,11 @@ static void test_query_architectures(void)
ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_ARMNT, &ret );
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;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_AMD64, &ret );
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;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_ARM64, &ret );
ok( !status, "failed %lx\n", status );
......@@ -439,13 +461,14 @@ static void test_selectors(void)
if (!pRtlWow64GetThreadContext || pRtlWow64GetThreadContext( GetCurrentThread(), &context ))
{
/* hardcoded values */
context.SegCs = 0x23;
#ifdef __x86_64__
context.SegCs = 0x23;
__asm__( "movw %%fs,%0" : "=m" (context.SegFs) );
__asm__( "movw %%ss,%0" : "=m" (context.SegSs) );
#else
context.SegSs = 0x2b;
context.SegFs = 0x53;
context.SegCs = 0x1b;
context.SegSs = 0x23;
context.SegFs = 0x3b;
#endif
}
#define GET_ENTRY(info,size,ret) \
......@@ -570,7 +593,7 @@ static void test_cpu_area(void)
{
USHORT machine;
NTSTATUS expect;
ULONG align, size, offset, flag;
ULONG_PTR align, size, offset, flag;
} tests[] =
{
{ IMAGE_FILE_MACHINE_I386, 0, 4, 0x2cc, 0x00, 0x00010000 },
......@@ -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,
wow64cpu_module, wow64win_module;
wow64cpu_module, xtajit_module, wow64win_module;
static void enum_modules64( void (*func)(ULONG64,const WCHAR *) )
{
......@@ -774,13 +797,16 @@ static void check_module( ULONG64 base, const WCHAR *name )
main_module = base;
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(wow64);
CHECK_MODULE(wow64base);
CHECK_MODULE(wow64con);
CHECK_MODULE(wow64cpu);
CHECK_MODULE(wow64win);
if (native_machine == IMAGE_FILE_MACHINE_ARM64)
CHECK_MODULE(xtajit);
else
CHECK_MODULE(wow64cpu);
#undef CHECK_MODULE
ok( 0, "unknown module %s %s found\n", wine_dbgstr_longlong(base), wine_dbgstr_w(name));
}
......@@ -795,7 +821,10 @@ static void test_modules(void)
ok( main_module, "main module not found\n" );
ok( ntdll_module, "64-bit ntdll not found\n" );
ok( wow64_module, "wow64.dll not found\n" );
ok( wow64cpu_module, "wow64cpu.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( wow64win_module, "wow64win.dll not found\n" );
}
}
......@@ -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 };
if (!is_wow64) return;
if (!code_mem) return;
if (!ntdll_module) return;
func = get_proc_address64( ntdll_module, "NtFsControlFile" );
......@@ -1217,6 +1247,7 @@ static void test_syscalls(void)
NTSTATUS status;
if (!is_wow64) return;
if (!code_mem) return;
if (!ntdll_module) return;
func = get_proc_address64( wow64_module, "Wow64SystemServiceEx" );
......@@ -1300,6 +1331,7 @@ static void test_cpu_area(void)
NTSTATUS status;
if (!is_wow64) return;
if (!code_mem) return;
if (!ntdll_module) return;
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