summaryrefslogtreecommitdiff
path: root/src/api/burn/balutil
diff options
context:
space:
mode:
authorJacob Hoover <jacob.hoover@greenheck.com>2022-11-10 10:48:23 -0600
committerSean Hall <r.sean.hall@gmail.com>2022-11-10 23:49:10 -0600
commitfa393914f12f6d6bc88a73e4d5b009da765f6dd5 (patch)
tree6dbf354d4542b3e085795b0a917eaafc1eead415 /src/api/burn/balutil
parentc843b47d6233153fa961c6d0e61edf7cedf255bb (diff)
downloadwix-fa393914f12f6d6bc88a73e4d5b009da765f6dd5.tar.gz
wix-fa393914f12f6d6bc88a73e4d5b009da765f6dd5.tar.bz2
wix-fa393914f12f6d6bc88a73e4d5b009da765f6dd5.zip
WIXFEAT-3704 - Allow access to persisted variables from related bundles
Diffstat (limited to 'src/api/burn/balutil')
-rw-r--r--src/api/burn/balutil/BalBootstrapperEngine.cpp28
-rw-r--r--src/api/burn/balutil/balutil.cpp51
-rw-r--r--src/api/burn/balutil/inc/IBootstrapperEngine.h8
-rw-r--r--src/api/burn/balutil/inc/balutil.h24
4 files changed, 111 insertions, 0 deletions
diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp
index 898a8a15..be53c6b9 100644
--- a/src/api/burn/balutil/BalBootstrapperEngine.cpp
+++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp
@@ -158,6 +158,34 @@ public: // IBootstrapperEngine
158 return hr; 158 return hr;
159 } 159 }
160 160
161 virtual STDMETHODIMP GetRelatedBundleVariable(
162 __in_z LPCWSTR wzBundleId,
163 __in_z LPCWSTR wzVariable,
164 __out_ecount_opt(*pcchValue) LPWSTR wzValue,
165 __inout SIZE_T* pcchValue
166 )
167 {
168 HRESULT hr = S_OK;
169 BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS args = { };
170 BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS results = { };
171
172 ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required");
173
174 args.cbSize = sizeof(args);
175 args.wzBundleId = wzBundleId;
176 args.wzVariable = wzVariable;
177
178 results.cbSize = sizeof(results);
179 results.wzValue = wzValue;
180 results.cchValue = *pcchValue;
181
182 hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, &args, &results, m_pvBAEngineProcContext);
183
184 *pcchValue = results.cchValue;
185 LExit:
186 return hr;
187 }
188
161 virtual STDMETHODIMP FormatString( 189 virtual STDMETHODIMP FormatString(
162 __in_z LPCWSTR wzIn, 190 __in_z LPCWSTR wzIn,
163 __out_ecount_opt(*pcchOut) LPWSTR wzOut, 191 __out_ecount_opt(*pcchOut) LPWSTR wzOut,
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:
421 return hr; 421 return hr;
422} 422}
423 423
424DAPI_(HRESULT) BalGetRelatedBundleVariable(
425 __in_z LPCWSTR wzBundleId,
426 __in_z LPCWSTR wzVariable,
427 __inout LPWSTR* psczValue
428)
429{
430 HRESULT hr = S_OK;
431
432 if (!vpEngine)
433 {
434 hr = E_POINTER;
435 ExitOnRootFailure(hr, "BalInitialize() must be called first.");
436 }
437
438 hr = BalGetRelatedBundleVariableFromEngine(vpEngine, wzBundleId, wzVariable, psczValue);
439
440LExit:
441 return hr;
442}
443
444DAPI_(HRESULT) BalGetRelatedBundleVariableFromEngine(
445 __in IBootstrapperEngine* pEngine,
446 __in_z LPCWSTR wzBundleId,
447 __in_z LPCWSTR wzVariable,
448 __inout LPWSTR* psczValue
449)
450{
451 HRESULT hr = S_OK;
452 SIZE_T cch = 0;
453
454 if (*psczValue)
455 {
456 hr = StrMaxLength(*psczValue, reinterpret_cast<DWORD_PTR*>(&cch));
457 ExitOnFailure(hr, "Failed to determine length of value.");
458 }
459
460 hr = pEngine->GetRelatedBundleVariable(wzBundleId, wzVariable, *psczValue, &cch);
461 if (E_MOREDATA == hr)
462 {
463 ++cch;
464
465 hr = StrAllocSecure(psczValue, cch);
466 ExitOnFailure(hr, "Failed to allocate value.");
467
468 hr = pEngine->GetRelatedBundleVariable(wzBundleId, wzVariable, *psczValue, &cch);
469 }
470
471LExit:
472 return hr;
473}
474
424DAPI_(HRESULT) BalSetVersionVariable( 475DAPI_(HRESULT) BalSetVersionVariable(
425 __in_z LPCWSTR wzVariable, 476 __in_z LPCWSTR wzVariable,
426 __in_z_opt LPCWSTR wzValue 477 __in_z_opt LPCWSTR wzValue
diff --git a/src/api/burn/balutil/inc/IBootstrapperEngine.h b/src/api/burn/balutil/inc/IBootstrapperEngine.h
index 2a108223..bfa13997 100644
--- a/src/api/burn/balutil/inc/IBootstrapperEngine.h
+++ b/src/api/burn/balutil/inc/IBootstrapperEngine.h
@@ -136,4 +136,12 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8
136 __in_z LPCWSTR wzVersion2, 136 __in_z LPCWSTR wzVersion2,
137 __out int* pnResult 137 __out int* pnResult
138 ) = 0; 138 ) = 0;
139
140 STDMETHOD(GetRelatedBundleVariable)(
141 __in_z LPCWSTR wzBundleId,
142 __in_z LPCWSTR wzVariable,
143 __out_ecount_opt(*pcchValue) LPWSTR wzValue,
144 __inout SIZE_T* pcchValue
145 ) = 0;
146
139}; 147};
diff --git a/src/api/burn/balutil/inc/balutil.h b/src/api/burn/balutil/inc/balutil.h
index 3040cfe8..36c165a3 100644
--- a/src/api/burn/balutil/inc/balutil.h
+++ b/src/api/burn/balutil/inc/balutil.h
@@ -140,6 +140,30 @@ DAPI_(HRESULT) BalGetNumericVariable(
140 ); 140 );
141 141
142/******************************************************************* 142/*******************************************************************
143BalGetRelatedBundleVariable - gets a string from a shared variable in the engine.
144
145Note: Use StrFree() to release psczValue.
146********************************************************************/
147DAPI_(HRESULT) BalGetRelatedBundleVariable(
148 __in_z LPCWSTR wzBundleId,
149 __in_z LPCWSTR wzVariable,
150 __inout LPWSTR* psczValue
151);
152
153/*******************************************************************
154BalGetRelatedBundleVariableFromEngine - gets a string from a shared variable in the engine.
155
156 Note: Use StrFree() to release psczValue.
157********************************************************************/
158DAPI_(HRESULT) BalGetRelatedBundleVariableFromEngine(
159 __in IBootstrapperEngine* pEngine,
160 __in_z LPCWSTR wzBundleId,
161 __in_z LPCWSTR wzVariable,
162 __inout LPWSTR* psczValue
163);
164
165
166/*******************************************************************
143BalSetNumericVariable - sets a numeric variable in the engine. 167BalSetNumericVariable - sets a numeric variable in the engine.
144 168
145********************************************************************/ 169********************************************************************/