summaryrefslogtreecommitdiff
path: root/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
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/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
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/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp')
-rw-r--r--src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
new file mode 100644
index 00000000..5da7b170
--- /dev/null
+++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
@@ -0,0 +1,133 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#include "precomp.h"
4#include "BalBaseBAFunctions.h"
5#include "BalBaseBAFunctionsProc.h"
6
7const DWORD VARIABLE_GROW_FACTOR = 80;
8const LPCWSTR STRING_VARIABLE = L"AString";
9const LPCWSTR NUMBER_VARIABLE = L"ANumber";
10
11static void CALLBACK BafRelatedBundleVariableTestingTraceError(
12 __in_z LPCSTR szFile,
13 __in int iLine,
14 __in REPORT_LEVEL rl,
15 __in UINT source,
16 __in HRESULT hrError,
17 __in_z __format_string LPCSTR szFormat,
18 __in va_list args
19 );
20
21class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions
22{
23public: // IBAFunctions
24
25
26public: //IBootstrapperApplication
27 virtual STDMETHODIMP OnDetectRelatedBundle(
28 __in_z LPCWSTR wzBundleId,
29 __in BOOTSTRAPPER_RELATION_TYPE relationType,
30 __in_z LPCWSTR wzBundleTag,
31 __in BOOL fPerMachine,
32 __in LPCWSTR wzVersion,
33 __in BOOL fMissingFromCache,
34 __inout BOOL* pfCancel
35 )
36 {
37
38 HRESULT hr = S_OK;
39 LPWSTR wzValue = NULL;
40
41 hr = BalGetRelatedBundleVariable(wzBundleId, STRING_VARIABLE, &wzValue);
42
43 ExitOnFailure(hr, "Failed to get related bundle string variable.");
44
45 if (wzValue)
46 {
47 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "AString = %ws", wzValue);
48 }
49
50 hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue);
51
52 if (wzValue)
53 {
54 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "ANumber = %ws", wzValue);
55 }
56
57 hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel);
58 LExit:
59 ReleaseStr(wzValue);
60 return hr;
61 }
62private:
63
64
65public:
66 //
67 // Constructor - initialize member variables.
68 //
69 CBafRelatedBundleVariableTesting(
70 __in HMODULE hModule,
71 __in IBootstrapperEngine* pEngine,
72 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs
73 ) : CBalBaseBAFunctions(hModule, pEngine, pArgs)
74 {
75 }
76
77 //
78 // Destructor - release member variables.
79 //
80 ~CBafRelatedBundleVariableTesting()
81 {
82 }
83
84private:
85};
86
87
88HRESULT WINAPI CreateBAFunctions(
89 __in HMODULE hModule,
90 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
91 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
92 )
93{
94 HRESULT hr = S_OK;
95 CBafRelatedBundleVariableTesting* pBAFunctions = NULL;
96 IBootstrapperEngine* pEngine = NULL;
97
98 DutilInitialize(&BafRelatedBundleVariableTestingTraceError);
99
100 hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine);
101 ExitOnFailure(hr, "Failed to initialize Bal.");
102
103 pBAFunctions = new CBafRelatedBundleVariableTesting(hModule, pEngine, pArgs);
104 ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CBafRelatedBundleVariableTesting object.");
105
106 pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc;
107 pResults->pvBAFunctionsProcContext = pBAFunctions;
108 pBAFunctions = NULL;
109
110LExit:
111 ReleaseObject(pBAFunctions);
112 ReleaseObject(pEngine);
113
114 return hr;
115}
116
117static void CALLBACK BafRelatedBundleVariableTestingTraceError(
118 __in_z LPCSTR /*szFile*/,
119 __in int /*iLine*/,
120 __in REPORT_LEVEL /*rl*/,
121 __in UINT source,
122 __in HRESULT hrError,
123 __in_z __format_string LPCSTR szFormat,
124 __in va_list args
125 )
126{
127 // BalLogError currently uses the Exit... macros,
128 // so if expanding the scope need to ensure this doesn't get called recursively.
129 if (DUTIL_SOURCE_THMUTIL == source)
130 {
131 BalLogErrorArgs(hrError, szFormat, args);
132 }
133}