@joebigelow / wix-1 / commits / fe77e966

Don't set NativeMachine variables when IsWow64Process2 is unavailable

Eric StJohn committed Sep 13, 2021 at 13:52 UTC fe77e96629575d6cfc16f8a868f13af89c198d13
3 files changed +12 -4
src/burn/engine/variable.cpp
+5 -2
@@ -1845,8 +1845,11 @@ static HRESULT InitializeVariableNativeMachine(
1845 hr = ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine);
1846 ExitOnFailure(hr, "Failed to get native machine value.");
1847
1848 - hr = BVariantSetNumeric(pValue, usNativeMachine);
1849 - ExitOnFailure(hr, "Failed to set variant value.");
1848 + if (hr != S_FALSE)
1849 + {
1850 + hr = BVariantSetNumeric(pValue, usNativeMachine);
1851 + ExitOnFailure(hr, "Failed to set variant value.");
1852 + }
1853
1854 LExit:
1855 return hr;
src/ext/Util/ca/OsInfo.cpp
+4 -1
@@ -506,7 +506,10 @@ extern "C" UINT __stdcall WixQueryNativeMachine(
506 hr = ::ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine);
507 ExitOnFailure(hr, "Failed to get native machine value.");
508
509 - WcaSetIntProperty(L"WIX_NATIVE_MACHINE", usNativeMachine);
509 + if (hr != S_FALSE)
510 + {
511 + WcaSetIntProperty(L"WIX_NATIVE_MACHINE", usNativeMachine);
512 + }
513
514 LExit:
515 if (FAILED(hr))
src/libs/dutil/WixToolset.DUtil/procutil.cpp
+3 -1
@@ -124,7 +124,8 @@ extern "C" HRESULT DAPI ProcNativeMachine(
124 __out USHORT* pusNativeMachine
125 )
126 {
127 - HRESULT hr = S_OK;
127 + // S_FALSE will indicate that the method is not supported.
128 + HRESULT hr = S_FALSE;
129
130 typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *);
131 LPFN_ISWOW64PROCESS2 pfnIsWow64Process2 = (LPFN_ISWOW64PROCESS2)::GetProcAddress(::GetModuleHandleW(L"kernel32"), "IsWow64Process2");
@@ -136,6 +137,7 @@ extern "C" HRESULT DAPI ProcNativeMachine(
137 {
138 ExitWithLastError(hr, "Failed to check WOW64 process - IsWow64Process2.");
139 }
140 + hr = S_OK;
141 }
142
143 LExit: