diff --git a/app/backend/systemproperties.cpp b/app/backend/systemproperties.cpp index 10c64015..c5d7c5d2 100644 --- a/app/backend/systemproperties.cpp +++ b/app/backend/systemproperties.cpp @@ -6,19 +6,55 @@ #include "streaming/session.h" #include "streaming/streamutils.h" +#ifdef Q_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + SystemProperties::SystemProperties() { versionString = QString(VERSION_STR); hasWindowManager = WMUtils::isRunningWindowManager(); isRunningWayland = WMUtils::isRunningWayland(); isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb"; + QString nativeArch = QSysInfo::currentCpuArchitecture(); #ifdef Q_OS_WIN32 - isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture(); + { + USHORT processArch, machineArch; + + // Use IsWow64Process2 on TH2 and later, because it supports ARM64 + auto isWow64Process2 = (decltype(IsWow64Process2)*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process2"); + if (isWow64Process2 != nullptr && IsWow64Process2(GetCurrentProcess(), &processArch, &machineArch)) { + switch (machineArch) { + case IMAGE_FILE_MACHINE_I386: + nativeArch = "i386"; + break; + case IMAGE_FILE_MACHINE_AMD64: + nativeArch = "x86_64"; + break; + case IMAGE_FILE_MACHINE_ARM64: + nativeArch = "arm64"; + break; + } + } + + isWow64 = nativeArch != QSysInfo::buildCpuArchitecture(); + } #else isWow64 = false; #endif + if (nativeArch == "i386") { + friendlyNativeArchName = "x86"; + } + else if (nativeArch == "x86_64") { + friendlyNativeArchName = "x64"; + } + else { + friendlyNativeArchName = nativeArch.toUpper(); + } + #ifndef STEAM_LINK // Assume we can probably launch a browser if we're in a GUI environment hasBrowser = hasWindowManager; diff --git a/app/backend/systemproperties.h b/app/backend/systemproperties.h index 817ac750..0ee6541a 100644 --- a/app/backend/systemproperties.h +++ b/app/backend/systemproperties.h @@ -15,6 +15,7 @@ public: Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT) Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT) Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT) + Q_PROPERTY(QString friendlyNativeArchName MEMBER friendlyNativeArchName CONSTANT) Q_PROPERTY(bool hasWindowManager MEMBER hasWindowManager CONSTANT) Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT) Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT) @@ -38,6 +39,7 @@ private: bool isRunningWayland; bool isRunningXWayland; bool isWow64; + QString friendlyNativeArchName; bool hasWindowManager; bool hasBrowser; bool hasDiscordIntegration; diff --git a/app/gui/main.qml b/app/gui/main.qml index 4a081f70..8763a79a 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -405,7 +405,7 @@ ApplicationWindow { NavigableMessageDialog { id: wow64Dialog standardButtons: Dialog.Ok | Dialog.Cancel - text: qsTr("This PC is running a 64-bit version of Windows. Please download the x64 version of Moonlight for the best streaming performance.") + text: qsTr("This PC is running the %1 version of Windows. Please download the %1 version of Moonlight for the best streaming performance.").arg(SystemProperties.friendlyNativeArchName) onAccepted: { Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-qt/releases"); }