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/api/burn/balutil/balutil.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/api/burn/balutil/balutil.cpp') diff --git a/src/api/burn/balutil/balutil.cpp b/src/api/burn/balutil/balutil.cpp index 5671da4e..2d80878c 100644 --- a/src/api/burn/balutil/balutil.cpp +++ b/src/api/burn/balutil/balutil.cpp @@ -421,6 +421,57 @@ LExit: return hr; } +DAPI_(HRESULT) BalGetRelatedBundleVariable( + __in_z LPCWSTR wzBundleId, + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue +) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = BalGetRelatedBundleVariableFromEngine(vpEngine, wzBundleId, wzVariable, psczValue); + +LExit: + return hr; +} + +DAPI_(HRESULT) BalGetRelatedBundleVariableFromEngine( + __in IBootstrapperEngine* pEngine, + __in_z LPCWSTR wzBundleId, + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue +) +{ + HRESULT hr = S_OK; + SIZE_T cch = 0; + + if (*psczValue) + { + hr = StrMaxLength(*psczValue, reinterpret_cast(&cch)); + ExitOnFailure(hr, "Failed to determine length of value."); + } + + hr = pEngine->GetRelatedBundleVariable(wzBundleId, wzVariable, *psczValue, &cch); + if (E_MOREDATA == hr) + { + ++cch; + + hr = StrAllocSecure(psczValue, cch); + ExitOnFailure(hr, "Failed to allocate value."); + + hr = pEngine->GetRelatedBundleVariable(wzBundleId, wzVariable, *psczValue, &cch); + } + +LExit: + return hr; +} + DAPI_(HRESULT) BalSetVersionVariable( __in_z LPCWSTR wzVariable, __in_z_opt LPCWSTR wzValue -- cgit v1.2.3-55-g6feb