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/ext/Util/ca/OsInfo.cpp | 28 ++++++++++++++++++++++++++ src/ext/Util/ca/utilca.def | 1 + src/ext/Util/wixlib/UtilExtension_Platform.wxi | 12 +++++++++++ 3 files changed, 41 insertions(+) (limited to 'src/ext/Util') diff --git a/src/ext/Util/ca/OsInfo.cpp b/src/ext/Util/ca/OsInfo.cpp index 4783673e..eb76a3a0 100644 --- a/src/ext/Util/ca/OsInfo.cpp +++ b/src/ext/Util/ca/OsInfo.cpp @@ -485,3 +485,31 @@ LExit: } return WcaFinalize(er); } + +/******************************************************************** +WixQueryNativeMachine - entry point for WixQueryNativeMachine custom action + + Called as Type 1 custom action (DLL from the Binary table) from + Windows Installer to set properties that indicates the native machine architecture +********************************************************************/ +extern "C" UINT __stdcall WixQueryNativeMachine( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + USHORT usNativeMachine = IMAGE_FILE_MACHINE_UNKNOWN; + DWORD er = ERROR_SUCCESS; + + hr = WcaInitialize(hInstall, "WixQueryNativeMachine"); + ExitOnFailure(hr, "WixQueryNativeMachine failed to initialize"); + + hr = ::ProcNativeMachine(::GetCurrentProcess(), &usNativeMachine); + ExitOnFailure(hr, "Failed to get native machine value."); + + WcaSetIntProperty(L"WIX_NATIVE_MACHINE", usNativeMachine); + +LExit: + if (FAILED(hr)) + er = ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} \ No newline at end of file diff --git a/src/ext/Util/ca/utilca.def b/src/ext/Util/ca/utilca.def index 412d86a3..3912ce56 100644 --- a/src/ext/Util/ca/utilca.def +++ b/src/ext/Util/ca/utilca.def @@ -22,6 +22,7 @@ EXPORTS WixQueryOsDirs WixQueryOsWellKnownSID WixQueryOsDriverInfo + WixQueryNativeMachine ; netshortcuts.cpp WixSchedInternetShortcuts WixCreateInternetShortcuts diff --git a/src/ext/Util/wixlib/UtilExtension_Platform.wxi b/src/ext/Util/wixlib/UtilExtension_Platform.wxi index 913c01b9..ab436adc 100644 --- a/src/ext/Util/wixlib/UtilExtension_Platform.wxi +++ b/src/ext/Util/wixlib/UtilExtension_Platform.wxi @@ -353,6 +353,18 @@ + + + + + + + + + + + + -- 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/ext/Util') 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/ext/Util') 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