From 6a8b70639ba20655812fbd8201380fd0769ca70b Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 20 Sep 2023 22:15:19 +0200 Subject: [PATCH] fix: `app.runningUnderARM64Translation()` always returning true on Windows ARM64 (#39920) fix: app.runningUnderARM64Translation() always returning true on ARM64 --- shell/browser/api/electron_api_app.cc | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index ac6b1c79d0e5..675818dfb4ef 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -19,6 +19,7 @@ #include "base/path_service.h" #include "base/system/sys_info.h" #include "base/values.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/icon_manager.h" #include "chrome/common/chrome_features.h" @@ -1475,23 +1476,8 @@ void App::SetUserAgentFallback(const std::string& user_agent) { } #if BUILDFLAG(IS_WIN) - bool App::IsRunningUnderARM64Translation() const { - USHORT processMachine = 0; - USHORT nativeMachine = 0; - - auto IsWow64Process2 = reinterpret_cast( - GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process2")); - - if (IsWow64Process2 == nullptr) { - return false; - } - - if (!IsWow64Process2(GetCurrentProcess(), &processMachine, &nativeMachine)) { - return false; - } - - return nativeMachine == IMAGE_FILE_MACHINE_ARM64; + return base::win::OSInfo::IsRunningEmulatedOnArm64(); } #endif