Bug 1619317, ensure we set isWow64 to the correct value after taking it off the main thread r=aklotz

Differential Revision: https://phabricator.services.mozilla.com/D65127

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emma Malysz 2020-03-09 14:29:32 +00:00
Родитель 8511f106a4
Коммит ff6fc06f79
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -570,20 +570,20 @@ nsresult CollectProcessInfo(ProcessInfo& info) {
typedef BOOL(WINAPI * LPFN_IWP2)(HANDLE, USHORT*, USHORT*);
LPFN_IWP2 iwp2 = reinterpret_cast<LPFN_IWP2>(
GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process2"));
BOOL isWow64 = false;
BOOL isWow64 = FALSE;
USHORT processMachine = IMAGE_FILE_MACHINE_UNKNOWN;
USHORT nativeMachine = IMAGE_FILE_MACHINE_UNKNOWN;
BOOL gotWow64Value;
if (iwp2) {
gotWow64Value = iwp2(GetCurrentProcess(), &processMachine, &nativeMachine);
if (gotWow64Value) {
info.isWow64 = (processMachine != IMAGE_FILE_MACHINE_UNKNOWN);
isWow64 = (processMachine != IMAGE_FILE_MACHINE_UNKNOWN);
}
} else {
gotWow64Value = IsWow64Process(GetCurrentProcess(), &isWow64);
// The function only indicates a WOW64 environment if it's 32-bit x86
// running on x86-64, so emulate what IsWow64Process2 would have given.
if (gotWow64Value && info.isWow64) {
if (gotWow64Value && isWow64) {
processMachine = IMAGE_FILE_MACHINE_I386;
nativeMachine = IMAGE_FILE_MACHINE_AMD64;
}
@ -591,6 +591,7 @@ nsresult CollectProcessInfo(ProcessInfo& info) {
NS_WARNING_ASSERTION(gotWow64Value, "IsWow64Process failed");
if (gotWow64Value) {
// Set this always, even for the x86-on-arm64 case.
info.isWow64 = !!isWow64;
// Additional information if we're running x86-on-arm64
info.isWowARM64 = (processMachine == IMAGE_FILE_MACHINE_I386 &&
nativeMachine == IMAGE_FILE_MACHINE_ARM64);