From fe77e96629575d6cfc16f8a868f13af89c198d13 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Mon, 13 Sep 2021 13:52:09 -0700 Subject: Don't set NativeMachine variables when IsWow64Process2 is unavailable --- src/burn/engine/variable.cpp | 7 +++++-- src/ext/Util/ca/OsInfo.cpp | 5 ++++- src/libs/dutil/WixToolset.DUtil/procutil.cpp | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp index e81704ce..04d64f18 100644 --- a/src/burn/engine/variable.cpp +++ b/src/burn/engine/variable.cpp @@ -1845,8 +1845,11 @@ static HRESULT InitializeVariableNativeMachine( hr = ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); ExitOnFailure(hr, "Failed to get native machine value."); - hr = BVariantSetNumeric(pValue, usNativeMachine); - ExitOnFailure(hr, "Failed to set variant value."); + if (hr != S_FALSE) + { + hr = BVariantSetNumeric(pValue, usNativeMachine); + ExitOnFailure(hr, "Failed to set variant value."); + } LExit: return hr; diff --git a/src/ext/Util/ca/OsInfo.cpp b/src/ext/Util/ca/OsInfo.cpp index eb76a3a0..3f91a9e5 100644 --- a/src/ext/Util/ca/OsInfo.cpp +++ b/src/ext/Util/ca/OsInfo.cpp @@ -506,7 +506,10 @@ extern "C" UINT __stdcall WixQueryNativeMachine( hr = ::ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); ExitOnFailure(hr, "Failed to get native machine value."); - WcaSetIntProperty(L"WIX_NATIVE_MACHINE", usNativeMachine); + if (hr != S_FALSE) + { + WcaSetIntProperty(L"WIX_NATIVE_MACHINE", usNativeMachine); + } LExit: if (FAILED(hr)) diff --git a/src/libs/dutil/WixToolset.DUtil/procutil.cpp b/src/libs/dutil/WixToolset.DUtil/procutil.cpp index 5cd067f0..a3131b7a 100644 --- a/src/libs/dutil/WixToolset.DUtil/procutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/procutil.cpp @@ -124,7 +124,8 @@ extern "C" HRESULT DAPI ProcNativeMachine( __out USHORT* pusNativeMachine ) { - HRESULT hr = S_OK; + // S_FALSE will indicate that the method is not supported. + HRESULT hr = S_FALSE; typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *); LPFN_ISWOW64PROCESS2 pfnIsWow64Process2 = (LPFN_ISWOW64PROCESS2)::GetProcAddress(::GetModuleHandleW(L"kernel32"), "IsWow64Process2"); @@ -136,6 +137,7 @@ extern "C" HRESULT DAPI ProcNativeMachine( { ExitWithLastError(hr, "Failed to check WOW64 process - IsWow64Process2."); } + hr = S_OK; } LExit: -- cgit v1.2.3-55-g6feb