Module: wine Branch: master Commit: da7411fdb3b87dc4549470c70f6fe73562c78b9e URL: https://gitlab.winehq.org/wine/wine/-/commit/da7411fdb3b87dc4549470c70f6fe73...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Mar 23 13:17:52 2023 +0100
ntdll: Fixup CPU information for old Wow64 mode.
---
dlls/ntdll/tests/wow64.c | 15 +++++++++++---- dlls/ntdll/unix/system.c | 9 +++++++-- 2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/tests/wow64.c b/dlls/ntdll/tests/wow64.c index eff3ff59dc2..8ecbbe68c12 100644 --- a/dlls/ntdll/tests/wow64.c +++ b/dlls/ntdll/tests/wow64.c @@ -68,6 +68,17 @@ static void init(void)
if (!IsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
+ if (is_wow64) + { + TEB64 *teb64 = ULongToPtr( NtCurrentTeb()->GdiBatchCount ); + + if (teb64) + { + PEB64 *peb64 = ULongToPtr(teb64->Peb); + old_wow64 = !peb64->LdrData; + } + } + #define GET_PROC(func) p##func = (void *)GetProcAddress( ntdll, #func ) GET_PROC( NtQuerySystemInformation ); GET_PROC( NtQuerySystemInformationEx ); @@ -102,10 +113,6 @@ static void init(void) case PROCESSOR_ARCHITECTURE_AMD64: native_machine = IMAGE_FILE_MACHINE_AMD64; break; - case PROCESSOR_ARCHITECTURE_INTEL: - old_wow64 = TRUE; - native_machine = IMAGE_FILE_MACHINE_AMD64; - break; } }
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 54fd72e56ba..0ba38f88038 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -2570,8 +2570,13 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class, case SystemCpuInformation: /* 1 */ if (size >= (len = sizeof(cpu_info))) { - if (!info) ret = STATUS_ACCESS_VIOLATION; - else memcpy(info, &cpu_info, len); + SYSTEM_CPU_INFORMATION cpu = cpu_info; + +#ifndef _WIN64 + if (is_wow64 && cpu.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) + cpu.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64; +#endif + memcpy(info, &cpu, len); } else ret = STATUS_INFO_LENGTH_MISMATCH; break;