From 495370ff9311d406da9c043cd208ce836a0303ff Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Mon, 30 Aug 2021 15:26:42 -0700 Subject: Add NativeMachine to Burn and WIX_NATIVE_MACHINE to UtilExtension --- src/burn/engine/variable.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/burn/engine/variable.cpp') diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp index e7391a9f..e81704ce 100644 --- a/src/burn/engine/variable.cpp +++ b/src/burn/engine/variable.cpp @@ -97,6 +97,10 @@ static HRESULT InitializeVariableVersionNT( __in DWORD_PTR dwpData, __inout BURN_VARIANT* pValue ); +static HRESULT InitializeVariableNativeMachine( + __in DWORD_PTR dwpData, + __inout BURN_VARIANT* pValue + ); static HRESULT InitializeVariableOsInfo( __in DWORD_PTR dwpData, __inout BURN_VARIANT* pValue @@ -223,6 +227,7 @@ extern "C" HRESULT VariableInitialize( {L"LocalAppDataFolder", InitializeVariableCsidlFolder, CSIDL_LOCAL_APPDATA}, {VARIABLE_LOGONUSER, InitializeVariableLogonUser, 0}, {L"MyPicturesFolder", InitializeVariableCsidlFolder, CSIDL_MYPICTURES}, + {L"NativeMachine", InitializeVariableNativeMachine, 0}, {L"NTProductType", InitializeVariableOsInfo, OS_INFO_VARIABLE_NTProductType}, {L"NTSuiteBackOffice", InitializeVariableOsInfo, OS_INFO_VARIABLE_NTSuiteBackOffice}, {L"NTSuiteDataCenter", InitializeVariableOsInfo, OS_INFO_VARIABLE_NTSuiteDataCenter}, @@ -1827,6 +1832,26 @@ LExit: return hr; } +static HRESULT InitializeVariableNativeMachine( + __in DWORD_PTR dwpData, + __inout BURN_VARIANT* pValue + ) +{ + UNREFERENCED_PARAMETER(dwpData); + + HRESULT hr = S_OK; + USHORT usNativeMachine = IMAGE_FILE_MACHINE_UNKNOWN; + + hr = ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); + ExitOnFailure(hr, "Failed to get native machine value."); + + hr = BVariantSetNumeric(pValue, usNativeMachine); + ExitOnFailure(hr, "Failed to set variant value."); + +LExit: + return hr; +} + static HRESULT InitializeVariableComputerName( __in DWORD_PTR dwpData, __inout BURN_VARIANT* pValue -- cgit v1.2.3-55-g6feb 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(-) (limited to 'src/burn/engine/variable.cpp') 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 From f958aeb8eea975ef76b72e73c0e40303b3a6b0d0 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 18 Sep 2021 19:16:58 -0400 Subject: Bring Sean's fixes to `wix4`. --- src/burn/engine/variable.cpp | 2 +- src/ext/Util/ca/OsInfo.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/burn/engine/variable.cpp') diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp index 04d64f18..fa6190dd 100644 --- a/src/burn/engine/variable.cpp +++ b/src/burn/engine/variable.cpp @@ -1845,7 +1845,7 @@ static HRESULT InitializeVariableNativeMachine( hr = ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); ExitOnFailure(hr, "Failed to get native machine value."); - if (hr != S_FALSE) + if (S_FALSE != hr) { hr = BVariantSetNumeric(pValue, usNativeMachine); ExitOnFailure(hr, "Failed to set variant value."); diff --git a/src/ext/Util/ca/OsInfo.cpp b/src/ext/Util/ca/OsInfo.cpp index 3f91a9e5..005407af 100644 --- a/src/ext/Util/ca/OsInfo.cpp +++ b/src/ext/Util/ca/OsInfo.cpp @@ -503,10 +503,10 @@ extern "C" UINT __stdcall WixQueryNativeMachine( hr = WcaInitialize(hInstall, "WixQueryNativeMachine"); ExitOnFailure(hr, "WixQueryNativeMachine failed to initialize"); - hr = ::ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); + hr = ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); ExitOnFailure(hr, "Failed to get native machine value."); - if (hr != S_FALSE) + if (S_FALSE != hr) { WcaSetIntProperty(L"WIX_NATIVE_MACHINE", usNativeMachine); } -- cgit v1.2.3-55-g6feb