ntdll: Fix RtlWow64GetCurrentMachine() result on ARM64EC.

This commit is contained in:
Alexandre Julliard 2024-02-08 16:30:24 +01:00
parent 1456b31eec
commit cf7c48e036
4 changed files with 33 additions and 31 deletions

View file

@ -51,19 +51,14 @@ WINE_DECLARE_DEBUG_CHANNEL(imports);
#ifdef __i386__
static const WCHAR pe_dir[] = L"\\i386-windows";
static const USHORT current_machine = IMAGE_FILE_MACHINE_I386;
#elif defined __x86_64__
static const WCHAR pe_dir[] = L"\\x86_64-windows";
static const USHORT current_machine = IMAGE_FILE_MACHINE_AMD64;
#elif defined __arm__
static const WCHAR pe_dir[] = L"\\arm-windows";
static const USHORT current_machine = IMAGE_FILE_MACHINE_ARMNT;
#elif defined __aarch64__
static const WCHAR pe_dir[] = L"\\aarch64-windows";
static const USHORT current_machine = IMAGE_FILE_MACHINE_ARM64;
#else
static const WCHAR pe_dir[] = L"";
static const USHORT current_machine = IMAGE_FILE_MACHINE_UNKNOWN;
#endif
/* we don't want to include winuser.h */

View file

@ -41,6 +41,18 @@
#define NTDLL_TLS_ERRNO 16 /* TLS slot for _errno() */
#ifdef __i386__
static const USHORT current_machine = IMAGE_FILE_MACHINE_I386;
#elif defined(__x86_64__)
static const USHORT current_machine = IMAGE_FILE_MACHINE_AMD64;
#elif defined(__arm__)
static const USHORT current_machine = IMAGE_FILE_MACHINE_ARMNT;
#elif defined(__aarch64__)
static const USHORT current_machine = IMAGE_FILE_MACHINE_ARM64;
#else
static const USHORT current_machine = IMAGE_FILE_MACHINE_UNKNOWN;
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
static const UINT_PTR page_size = 0x1000;
#else

View file

@ -94,10 +94,11 @@ NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
*/
USHORT WINAPI RtlWow64GetCurrentMachine(void)
{
USHORT current, native;
RtlWow64GetProcessMachines( GetCurrentProcess(), &current, &native );
return current ? current : native;
USHORT machine = current_machine;
#ifdef _WIN64
if (NtCurrentTeb()->WowTebOffset) RtlWow64GetCurrentCpuArea( &machine, NULL, NULL );
#endif
return machine;
}

View file

@ -289,7 +289,7 @@ static void test_query_architectures(void)
STARTUPINFOA si = { sizeof(si) };
NTSTATUS status;
HANDLE process;
ULONG len;
ULONG i, len;
#ifdef __arm64ec__
BOOL is_arm64ec = TRUE;
#else
@ -383,27 +383,21 @@ static void test_query_architectures(void)
}
if (pRtlWow64IsWowGuestMachineSupported)
{
BOOLEAN ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_I386, &ret );
ok( !status, "failed %lx\n", status );
ok( ret == (native_machine == IMAGE_FILE_MACHINE_AMD64 ||
native_machine == IMAGE_FILE_MACHINE_ARM64), "wrong result %u\n", ret );
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 );
ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( IMAGE_FILE_MACHINE_AMD64, &ret );
ok( !status, "failed %lx\n", status );
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 );
ok( !ret, "wrong result %u\n", ret );
ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( 0xdead, &ret );
ok( !status, "failed %lx\n", status );
ok( !ret, "wrong result %u\n", ret );
static const WORD machines[] = { IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_ARMNT,
IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_ARM64, 0xdead };
for (i = 0; i < ARRAY_SIZE(machines); i++)
{
BOOLEAN ret = 0xcc;
status = pRtlWow64IsWowGuestMachineSupported( machines[i], &ret );
ok( !status, "failed %lx\n", status );
if (is_machine_32bit( machines[i] ) && !is_machine_32bit( native_machine ))
ok( ret || machines[i] == IMAGE_FILE_MACHINE_ARMNT ||
broken(current_machine == IMAGE_FILE_MACHINE_I386), /* win10-1607 wow64 */
"%04x: got %u\n", machines[i], ret );
else
ok( !ret, "%04x: got %u\n", machines[i], ret );
}
}
}