diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2022-06-16 00:02:39 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2022-06-22 15:33:12 -0700 |
| commit | 29ddd0e6f05d0489a0e92e0014d2db10dfcd4095 (patch) | |
| tree | 71b623a537f063c167a0a45a4efa6d2081d97350 /Source/Core/Common/x64CPUDetect.cpp | |
| parent | 57750f3d8f21dc240b9ba48ba55a66f108305a5d (diff) | |
windows: detect and warn if running x64 dolphin on arm64
Diffstat (limited to 'Source/Core/Common/x64CPUDetect.cpp')
| -rw-r--r-- | Source/Core/Common/x64CPUDetect.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/Core/Common/x64CPUDetect.cpp b/Source/Core/Common/x64CPUDetect.cpp index 644d485ed8..5f90246302 100644 --- a/Source/Core/Common/x64CPUDetect.cpp +++ b/Source/Core/Common/x64CPUDetect.cpp @@ -3,12 +3,17 @@ #include "Common/CPUDetect.h" +#ifdef _WIN32 +#include <processthreadsapi.h> +#endif + #include <cstring> #include <string> #include <thread> #include "Common/CommonTypes.h" #include "Common/Intrinsics.h" +#include "Common/MsgHandler.h" #ifndef _WIN32 @@ -48,6 +53,29 @@ static u64 xgetbv(u32 index) } constexpr u32 XCR_XFEATURE_ENABLED_MASK = _XCR_XFEATURE_ENABLED_MASK; +static void WarnIfRunningUnderEmulation() +{ + // Starting with win11, arm64 windows can run x64 processes under emulation. + // This detects such a scenario and informs the user they probably want to run a native build. + PROCESS_MACHINE_INFORMATION info{}; + if (!GetProcessInformation(GetCurrentProcess(), ProcessMachineTypeInfo, &info, sizeof(info))) + { + // Possibly we are running on version of windows which doesn't support ProcessMachineTypeInfo. + return; + } + if (info.MachineAttributes & MACHINE_ATTRIBUTES::KernelEnabled) + { + // KernelEnabled will be set if process arch matches the kernel arch - how we want people to run + // dolphin. + return; + } + + // The process is not native; could use IsWow64Process2 to get native machine type, but for now + // we can assume it is arm64. + PanicAlertFmtT("This build of Dolphin is not natively compiled for your CPU.\n" + "Please run the ARM64 build of Dolphin for a better experience."); +} + #else static u64 xgetbv(u32 index) @@ -69,6 +97,10 @@ CPUInfo::CPUInfo() // Detects the various CPU features void CPUInfo::Detect() { +#ifdef _WIN32 + WarnIfRunningUnderEmulation(); +#endif + #ifdef _M_X86_64 Mode64bit = true; OS64bit = true; |
