aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting
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
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')
-rw-r--r--src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp133
-rw-r--r--src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def6
-rw-r--r--src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj66
-rw-r--r--src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp48
-rw-r--r--src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h43
5 files changed, 296 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}
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def
new file mode 100644
index 00000000..6e016dad
--- /dev/null
+++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def
@@ -0,0 +1,6 @@
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
4EXPORTS
5 BAFunctionsCreate
6 BAFunctionsDestroy
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj
new file mode 100644
index 00000000..94d44ac3
--- /dev/null
+++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj
@@ -0,0 +1,66 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project DefaultTargets="Build" Toolsxmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <ItemGroup Label="ProjectConfigurations">
6 <ProjectConfiguration Include="Debug|ARM64">
7 <Configuration>Debug</Configuration>
8 <Platform>ARM64</Platform>
9 </ProjectConfiguration>
10 <ProjectConfiguration Include="Release|ARM64">
11 <Configuration>Release</Configuration>
12 <Platform>ARM64</Platform>
13 </ProjectConfiguration>
14 <ProjectConfiguration Include="Debug|Win32">
15 <Configuration>Debug</Configuration>
16 <Platform>Win32</Platform>
17 </ProjectConfiguration>
18 <ProjectConfiguration Include="Release|Win32">
19 <Configuration>Release</Configuration>
20 <Platform>Win32</Platform>
21 </ProjectConfiguration>
22 <ProjectConfiguration Include="Debug|x64">
23 <Configuration>Debug</Configuration>
24 <Platform>x64</Platform>
25 </ProjectConfiguration>
26 <ProjectConfiguration Include="Release|x64">
27 <Configuration>Release</Configuration>
28 <Platform>x64</Platform>
29 </ProjectConfiguration>
30 </ItemGroup>
31
32 <PropertyGroup Label="Globals">
33 <ProjectGuid>{DDD02BDE-B44F-4F37-A359-CE802750CB45}</ProjectGuid>
34 <ConfigurationType>DynamicLibrary</ConfigurationType>
35 <CharacterSet>Unicode</CharacterSet>
36 <TargetName>BafRelatedBundleVariableTesting</TargetName>
37 <ProjectModuleDefinitionFile>BafRelatedBundleVariableTesting.def</ProjectModuleDefinitionFile>
38 <IsWixTestProject>true</IsWixTestProject>
39 </PropertyGroup>
40
41 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
42 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
43
44 <PropertyGroup>
45 <ProjectAdditionalLinkLibraries>comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib</ProjectAdditionalLinkLibraries>
46 </PropertyGroup>
47
48 <ItemGroup>
49 <ClCompile Include="BafRelatedBundleVariableTesting.cpp" />
50 <ClCompile Include="precomp.cpp">
51 <PrecompiledHeader>Create</PrecompiledHeader>
52 </ClCompile>
53 </ItemGroup>
54 <ItemGroup>
55 <ClInclude Include="precomp.h" />
56 </ItemGroup>
57 <ItemGroup>
58 <None Include="BafRelatedBundleVariableTesting.def" />
59 </ItemGroup>
60
61 <ItemGroup>
62 <PackageReference Include="WixToolset.BalUtil" />
63 </ItemGroup>
64
65 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
66</Project>
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp
new file mode 100644
index 00000000..fc9d1177
--- /dev/null
+++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp
@@ -0,0 +1,48 @@
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
5static HINSTANCE vhInstance = NULL;
6
7extern "C" BOOL WINAPI DllMain(
8 IN HINSTANCE hInstance,
9 IN DWORD dwReason,
10 IN LPVOID /* pvReserved */
11 )
12{
13 switch (dwReason)
14 {
15 case DLL_PROCESS_ATTACH:
16 ::DisableThreadLibraryCalls(hInstance);
17 vhInstance = hInstance;
18 break;
19
20 case DLL_PROCESS_DETACH:
21 vhInstance = NULL;
22 break;
23 }
24
25 return TRUE;
26}
27
28extern "C" HRESULT WINAPI BAFunctionsCreate(
29 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
30 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
31 )
32{
33 HRESULT hr = S_OK;
34
35 hr = CreateBAFunctions(vhInstance, pArgs, pResults);
36 BalExitOnFailure(hr, "Failed to create BAFunctions interface.");
37
38LExit:
39 return hr;
40}
41
42extern "C" void WINAPI BAFunctionsDestroy(
43 __in const BA_FUNCTIONS_DESTROY_ARGS* /*pArgs*/,
44 __inout BA_FUNCTIONS_DESTROY_RESULTS* /*pResults*/
45 )
46{
47 BalUninitialize();
48}
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h
new file mode 100644
index 00000000..2e14786a
--- /dev/null
+++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h
@@ -0,0 +1,43 @@
1#pragma once
2// 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.
3
4
5#include <windows.h>
6
7#pragma warning(push)
8#pragma warning(disable:4458) // declaration of 'xxx' hides class member
9#include <gdiplus.h>
10#pragma warning(pop)
11
12#include <msiquery.h>
13#include <objbase.h>
14#include <shlobj.h>
15#include <shlwapi.h>
16#include <stdlib.h>
17#include <strsafe.h>
18#include <CommCtrl.h>
19#include <sddl.h>
20
21#include "dutil.h"
22#include "dictutil.h"
23#include "fileutil.h"
24#include "locutil.h"
25#include "memutil.h"
26#include "pathutil.h"
27#include "procutil.h"
28#include "strutil.h"
29#include "thmutil.h"
30#include "regutil.h"
31#include "xmlutil.h"
32
33#include "BalBaseBootstrapperApplication.h"
34#include "balutil.h"
35
36#include "BAFunctions.h"
37#include "IBAFunctions.h"
38
39HRESULT WINAPI CreateBAFunctions(
40 __in HMODULE hModule,
41 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
42 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
43 );