From fa393914f12f6d6bc88a73e4d5b009da765f6dd5 Mon Sep 17 00:00:00 2001 From: Jacob Hoover Date: Thu, 10 Nov 2022 10:48:23 -0600 Subject: WIXFEAT-3704 - Allow access to persisted variables from related bundles --- src/burn/engine/EngineForApplication.cpp | 19 +++++++++++++++++++ src/burn/engine/EngineForExtension.cpp | 19 +++++++++++++++++++ src/burn/engine/externalengine.cpp | 20 ++++++++++++++++++++ src/burn/engine/externalengine.h | 8 ++++++++ src/burn/test/BurnUnitTest/VariantTest.cpp | 8 +++----- 5 files changed, 69 insertions(+), 5 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/EngineForApplication.cpp b/src/burn/engine/EngineForApplication.cpp index 45bfaf83..eb77cc50 100644 --- a/src/burn/engine/EngineForApplication.cpp +++ b/src/burn/engine/EngineForApplication.cpp @@ -427,6 +427,22 @@ LExit: return hr; } +static HRESULT BAEngineGetRelatedBundleVariable( + __in BOOTSTRAPPER_ENGINE_CONTEXT* pContext, + __in const LPVOID pvArgs, + __inout LPVOID pvResults + ) +{ + HRESULT hr = S_OK; + ValidateMessageArgs(hr, pvArgs, BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS, pArgs); + ValidateMessageResults(hr, pvResults, BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS, pResults); + + hr = ExternalEngineGetRelatedBundleVariable(pContext->pEngineState, pArgs->wzBundleId, pArgs->wzVariable, pResults->wzValue, &pResults->cchValue); + +LExit: + return hr; +} + HRESULT WINAPI EngineForApplicationProc( __in BOOTSTRAPPER_ENGINE_MESSAGE message, __in const LPVOID pvArgs, @@ -519,6 +535,9 @@ HRESULT WINAPI EngineForApplicationProc( case BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS: hr = BAEngineCompareVersions(pContext, pvArgs, pvResults); break; + case BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE: + hr = BAEngineGetRelatedBundleVariable(pContext, pvArgs, pvResults); + break; default: hr = E_NOTIMPL; break; diff --git a/src/burn/engine/EngineForExtension.cpp b/src/burn/engine/EngineForExtension.cpp index 2e1c98fd..bb134a61 100644 --- a/src/burn/engine/EngineForExtension.cpp +++ b/src/burn/engine/EngineForExtension.cpp @@ -203,6 +203,22 @@ LExit: return hr; } +static HRESULT BEEngineGetRelatedBundleVariable( + __in BURN_EXTENSION_ENGINE_CONTEXT* pContext, + __in const LPVOID pvArgs, + __inout LPVOID pvResults +) +{ + HRESULT hr = S_OK; + ValidateMessageArgs(hr, pvArgs, BUNDLE_EXTENSION_ENGINE_GETRELATEDBUNDLEVARIABLE_ARGS, pArgs); + ValidateMessageResults(hr, pvResults, BUNDLE_EXTENSION_ENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS, pResults); + + hr = ExternalEngineGetRelatedBundleVariable(pContext->pEngineState, pArgs->wzBundleId, pArgs->wzVariable, pResults->wzValue, &pResults->cchValue); + +LExit: + return hr; +} + HRESULT WINAPI EngineForExtensionProc( __in BUNDLE_EXTENSION_ENGINE_MESSAGE message, __in const LPVOID pvArgs, @@ -253,6 +269,9 @@ HRESULT WINAPI EngineForExtensionProc( case BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS: hr = BEEngineCompareVersions(pContext, pvArgs, pvResults); break; + case BUNDLE_EXTENSION_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE: + hr = BEEngineGetRelatedBundleVariable(pContext, pvArgs, pvResults); + break; default: hr = E_NOTIMPL; break; diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index 262bb1a9..c38d8fc3 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp @@ -801,6 +801,26 @@ LExit: return hr; } +HRESULT ExternalEngineGetRelatedBundleVariable( + __in BURN_ENGINE_STATE* /*pEngineState*/, + __in_z LPCWSTR wzBundleId, + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) +{ + HRESULT hr = S_OK; + if (wzVariable && *wzVariable && pcchValue) + { + hr = BundleGetBundleVariableFixed(wzBundleId, wzVariable, wzValue, pcchValue); + } + else + { + hr = E_INVALIDARG; + } + return hr; +} + // TODO: callers need to provide the original size (at the time of first public release) of the struct instead of the current size. HRESULT WINAPI ExternalEngineValidateMessageParameter( __in_opt const LPVOID pv, diff --git a/src/burn/engine/externalengine.h b/src/burn/engine/externalengine.h index 9322234a..0c8a8cbb 100644 --- a/src/burn/engine/externalengine.h +++ b/src/burn/engine/externalengine.h @@ -129,6 +129,14 @@ HRESULT ExternalEngineCompareVersions( __out int* pnResult ); +HRESULT ExternalEngineGetRelatedBundleVariable( + __in BURN_ENGINE_STATE* pEngineState, + __in_z LPCWSTR wzBundleId, + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue +); + HRESULT ExternalEngineDetect( __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, __in_opt const HWND hwndParent diff --git a/src/burn/test/BurnUnitTest/VariantTest.cpp b/src/burn/test/BurnUnitTest/VariantTest.cpp index 43899a2b..035864cf 100644 --- a/src/burn/test/BurnUnitTest/VariantTest.cpp +++ b/src/burn/test/BurnUnitTest/VariantTest.cpp @@ -27,11 +27,9 @@ namespace Bootstrapper { BURN_VARIANT expectedVariants[10]; BURN_VARIANT actualVariants[10]; - for (DWORD i = 0; i < 10; i++) - { - BVariantUninitialize(expectedVariants + i); - BVariantUninitialize(actualVariants + i); - } + + memset(expectedVariants, 0, sizeof(expectedVariants)); + memset(actualVariants, 0, sizeof(actualVariants)); try { -- cgit v1.2.3-55-g6feb