diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-01-03 15:35:14 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-01-04 19:19:43 -0600 |
commit | 1f5314302b3c8bc1977aed79df1d05c52608f382 (patch) | |
tree | f0fef3a4462352c914a4cc9413515d07f2244703 /src/burn/engine/pseudobundle.cpp | |
parent | db44f6cf3b1eb476e47384f2eccba5712808def5 (diff) | |
download | wix-1f5314302b3c8bc1977aed79df1d05c52608f382.tar.gz wix-1f5314302b3c8bc1977aed79df1d05c52608f382.tar.bz2 wix-1f5314302b3c8bc1977aed79df1d05c52608f382.zip |
Don't assume Exe packages with Burn protocol are bundles.
Related to #3693
Diffstat (limited to 'src/burn/engine/pseudobundle.cpp')
-rw-r--r-- | src/burn/engine/pseudobundle.cpp | 153 |
1 files changed, 23 insertions, 130 deletions
diff --git a/src/burn/engine/pseudobundle.cpp b/src/burn/engine/pseudobundle.cpp index 14dd2b77..7b670035 100644 --- a/src/burn/engine/pseudobundle.cpp +++ b/src/burn/engine/pseudobundle.cpp | |||
@@ -3,36 +3,24 @@ | |||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | 5 | ||
6 | extern "C" HRESULT PseudoBundleInitialize( | 6 | extern "C" HRESULT PseudoBundleInitializeRelated( |
7 | __in BURN_PACKAGE* pPackage, | 7 | __in BURN_PACKAGE* pPackage, |
8 | __in BOOL fSupportsBurnProtocol, | 8 | __in BOOL fSupportsBurnProtocol, |
9 | __in BOOL fPerMachine, | 9 | __in BOOL fPerMachine, |
10 | __in_z LPCWSTR wzId, | 10 | __in_z LPCWSTR wzId, |
11 | #ifdef DEBUG | ||
11 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | 12 | __in BOOTSTRAPPER_RELATION_TYPE relationType, |
12 | __in BOOTSTRAPPER_PACKAGE_STATE state, | 13 | #endif |
13 | __in BOOL fCached, | 14 | __in BOOL fCached, |
14 | __in_z LPCWSTR wzFilePath, | 15 | __in_z LPCWSTR wzFilePath, |
15 | __in_z LPCWSTR wzLocalSource, | ||
16 | __in_z_opt LPCWSTR wzDownloadSource, | ||
17 | __in DWORD64 qwSize, | 16 | __in DWORD64 qwSize, |
18 | __in BOOL fVital, | 17 | __in_opt BURN_DEPENDENCY_PROVIDER* pDependencyProvider |
19 | __in_z_opt LPCWSTR wzInstallArguments, | ||
20 | __in_z_opt LPCWSTR wzRepairArguments, | ||
21 | __in_z_opt LPCWSTR wzUninstallArguments, | ||
22 | __in_opt BURN_DEPENDENCY_PROVIDER* pDependencyProvider, | ||
23 | __in_opt const BYTE* pbHash, | ||
24 | __in const DWORD cbHash | ||
25 | ) | 18 | ) |
26 | { | 19 | { |
27 | HRESULT hr = S_OK; | 20 | HRESULT hr = S_OK; |
28 | LPWSTR sczRelationTypeCommandLineSwitch = NULL; | ||
29 | BURN_PAYLOAD* pPayload = NULL; | 21 | BURN_PAYLOAD* pPayload = NULL; |
30 | 22 | ||
31 | LPCWSTR wzRelationTypeCommandLine = CoreRelationTypeToCommandLineString(relationType); | 23 | AssertSz(BOOTSTRAPPER_RELATION_UPDATE != relationType, "Update pseudo bundles must use PseudoBundleInitializeUpdateBundle instead."); |
32 | if (wzRelationTypeCommandLine) | ||
33 | { | ||
34 | hr = StrAllocFormatted(&sczRelationTypeCommandLineSwitch, L" -%ls", wzRelationTypeCommandLine); | ||
35 | } | ||
36 | 24 | ||
37 | // Initialize the single payload, and fill out all the necessary fields | 25 | // Initialize the single payload, and fill out all the necessary fields |
38 | pPackage->payloads.rgItems = (BURN_PAYLOAD_GROUP_ITEM*)MemAlloc(sizeof(BURN_PAYLOAD_GROUP_ITEM), TRUE); | 26 | pPackage->payloads.rgItems = (BURN_PAYLOAD_GROUP_ITEM*)MemAlloc(sizeof(BURN_PAYLOAD_GROUP_ITEM), TRUE); |
@@ -51,41 +39,21 @@ extern "C" HRESULT PseudoBundleInitialize( | |||
51 | hr = StrAllocString(&pPayload->sczFilePath, wzFilePath, 0); | 39 | hr = StrAllocString(&pPayload->sczFilePath, wzFilePath, 0); |
52 | ExitOnFailure(hr, "Failed to copy filename for pseudo bundle."); | 40 | ExitOnFailure(hr, "Failed to copy filename for pseudo bundle."); |
53 | 41 | ||
54 | hr = StrAllocString(&pPayload->sczSourcePath, wzLocalSource, 0); | 42 | hr = StrAllocString(&pPayload->sczSourcePath, wzFilePath, 0); |
55 | ExitOnFailure(hr, "Failed to copy local source path for pseudo bundle."); | 43 | ExitOnFailure(hr, "Failed to copy local source path for pseudo bundle."); |
56 | 44 | ||
57 | if (wzDownloadSource && *wzDownloadSource) | 45 | pPackage->type = BURN_PACKAGE_TYPE_BUNDLE; |
58 | { | ||
59 | hr = StrAllocString(&pPayload->downloadSource.sczUrl, wzDownloadSource, 0); | ||
60 | ExitOnFailure(hr, "Failed to copy download source for pseudo bundle."); | ||
61 | } | ||
62 | |||
63 | if (pbHash) | ||
64 | { | ||
65 | pPayload->pbHash = static_cast<BYTE*>(MemAlloc(cbHash, FALSE)); | ||
66 | ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for pseudo bundle payload hash."); | ||
67 | |||
68 | pPayload->cbHash = cbHash; | ||
69 | memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); | ||
70 | } | ||
71 | |||
72 | if (BOOTSTRAPPER_RELATION_UPDATE == relationType) | ||
73 | { | ||
74 | pPayload->verification = BURN_PAYLOAD_VERIFICATION_UPDATE_BUNDLE; | ||
75 | } | ||
76 | |||
77 | pPackage->Exe.fPseudoBundle = TRUE; | ||
78 | |||
79 | pPackage->type = BURN_PACKAGE_TYPE_EXE; | ||
80 | pPackage->fPerMachine = fPerMachine; | 46 | pPackage->fPerMachine = fPerMachine; |
81 | pPackage->currentState = state; | 47 | pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_PRESENT; |
82 | pPackage->fCached = fCached; | 48 | pPackage->fCached = fCached; |
83 | pPackage->qwInstallSize = qwSize; | 49 | pPackage->qwInstallSize = qwSize; |
84 | pPackage->qwSize = qwSize; | 50 | pPackage->qwSize = qwSize; |
85 | pPackage->fVital = fVital; | 51 | pPackage->fVital = FALSE; |
86 | 52 | ||
87 | pPackage->Exe.protocol = fSupportsBurnProtocol ? BURN_EXE_PROTOCOL_TYPE_BURN : BURN_EXE_PROTOCOL_TYPE_NONE; | 53 | pPackage->fUninstallable = TRUE; |
88 | pPackage->Exe.fSupportsAncestors = TRUE; | 54 | pPackage->Bundle.fPseudoBundle = TRUE; |
55 | pPackage->Bundle.fRepairable = TRUE; | ||
56 | pPackage->Bundle.fSupportsBurnProtocol = fSupportsBurnProtocol; | ||
89 | 57 | ||
90 | hr = StrAllocString(&pPackage->sczId, wzId, 0); | 58 | hr = StrAllocString(&pPackage->sczId, wzId, 0); |
91 | ExitOnFailure(hr, "Failed to copy key for pseudo bundle."); | 59 | ExitOnFailure(hr, "Failed to copy key for pseudo bundle."); |
@@ -93,47 +61,6 @@ extern "C" HRESULT PseudoBundleInitialize( | |||
93 | hr = StrAllocString(&pPackage->sczCacheId, wzId, 0); | 61 | hr = StrAllocString(&pPackage->sczCacheId, wzId, 0); |
94 | ExitOnFailure(hr, "Failed to copy cache id for pseudo bundle."); | 62 | ExitOnFailure(hr, "Failed to copy cache id for pseudo bundle."); |
95 | 63 | ||
96 | // If we are a self updating bundle, we don't have to have Install arguments. | ||
97 | if (wzInstallArguments) | ||
98 | { | ||
99 | hr = StrAllocString(&pPackage->Exe.sczInstallArguments, wzInstallArguments, 0); | ||
100 | ExitOnFailure(hr, "Failed to copy install arguments for related bundle package"); | ||
101 | } | ||
102 | |||
103 | if (sczRelationTypeCommandLineSwitch) | ||
104 | { | ||
105 | hr = StrAllocConcat(&pPackage->Exe.sczInstallArguments, sczRelationTypeCommandLineSwitch, 0); | ||
106 | ExitOnFailure(hr, "Failed to append relation type to install arguments for related bundle package"); | ||
107 | } | ||
108 | |||
109 | if (wzRepairArguments) | ||
110 | { | ||
111 | hr = StrAllocString(&pPackage->Exe.sczRepairArguments, wzRepairArguments, 0); | ||
112 | ExitOnFailure(hr, "Failed to copy repair arguments for related bundle package"); | ||
113 | |||
114 | if (sczRelationTypeCommandLineSwitch) | ||
115 | { | ||
116 | hr = StrAllocConcat(&pPackage->Exe.sczRepairArguments, sczRelationTypeCommandLineSwitch, 0); | ||
117 | ExitOnFailure(hr, "Failed to append relation type to repair arguments for related bundle package"); | ||
118 | } | ||
119 | |||
120 | pPackage->Exe.fRepairable = TRUE; | ||
121 | } | ||
122 | |||
123 | if (wzUninstallArguments) | ||
124 | { | ||
125 | hr = StrAllocString(&pPackage->Exe.sczUninstallArguments, wzUninstallArguments, 0); | ||
126 | ExitOnFailure(hr, "Failed to copy uninstall arguments for related bundle package"); | ||
127 | |||
128 | if (sczRelationTypeCommandLineSwitch) | ||
129 | { | ||
130 | hr = StrAllocConcat(&pPackage->Exe.sczUninstallArguments, sczRelationTypeCommandLineSwitch, 0); | ||
131 | ExitOnFailure(hr, "Failed to append relation type to uninstall arguments for related bundle package"); | ||
132 | } | ||
133 | |||
134 | pPackage->fUninstallable = TRUE; | ||
135 | } | ||
136 | |||
137 | if (pDependencyProvider) | 64 | if (pDependencyProvider) |
138 | { | 65 | { |
139 | pPackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER), TRUE); | 66 | pPackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER), TRUE); |
@@ -153,8 +80,6 @@ extern "C" HRESULT PseudoBundleInitialize( | |||
153 | } | 80 | } |
154 | 81 | ||
155 | LExit: | 82 | LExit: |
156 | ReleaseStr(sczRelationTypeCommandLineSwitch); | ||
157 | |||
158 | return hr; | 83 | return hr; |
159 | } | 84 | } |
160 | 85 | ||
@@ -165,7 +90,7 @@ extern "C" HRESULT PseudoBundleInitializePassthrough( | |||
165 | __in BURN_PACKAGE* pPackage | 90 | __in BURN_PACKAGE* pPackage |
166 | ) | 91 | ) |
167 | { | 92 | { |
168 | Assert(BURN_PACKAGE_TYPE_EXE == pPackage->type); | 93 | Assert(BURN_PACKAGE_TYPE_BUNDLE == pPackage->type); |
169 | 94 | ||
170 | HRESULT hr = S_OK; | 95 | HRESULT hr = S_OK; |
171 | LPWSTR sczArguments = NULL; | 96 | LPWSTR sczArguments = NULL; |
@@ -180,59 +105,29 @@ extern "C" HRESULT PseudoBundleInitializePassthrough( | |||
180 | pPassthroughPackage->payloads.rgItems[iPayload].pPayload = pPackage->payloads.rgItems[iPayload].pPayload; | 105 | pPassthroughPackage->payloads.rgItems[iPayload].pPayload = pPackage->payloads.rgItems[iPayload].pPayload; |
181 | } | 106 | } |
182 | 107 | ||
183 | pPassthroughPackage->Exe.fPseudoBundle = TRUE; | ||
184 | |||
185 | pPassthroughPackage->fPerMachine = FALSE; // passthrough bundles are always launched per-user. | 108 | pPassthroughPackage->fPerMachine = FALSE; // passthrough bundles are always launched per-user. |
186 | pPassthroughPackage->type = pPackage->type; | 109 | pPassthroughPackage->type = BURN_PACKAGE_TYPE_EXE; |
187 | pPassthroughPackage->currentState = pPackage->currentState; | 110 | pPassthroughPackage->currentState = pPackage->currentState; |
188 | pPassthroughPackage->fCached = pPackage->fCached; | 111 | pPassthroughPackage->fCached = pPackage->fCached; |
189 | pPassthroughPackage->qwInstallSize = pPackage->qwInstallSize; | 112 | pPassthroughPackage->qwInstallSize = pPackage->qwInstallSize; |
190 | pPassthroughPackage->qwSize = pPackage->qwSize; | 113 | pPassthroughPackage->qwSize = pPackage->qwSize; |
191 | pPassthroughPackage->fVital = pPackage->fVital; | 114 | pPassthroughPackage->fVital = pPackage->fVital; |
192 | 115 | ||
116 | pPassthroughPackage->Exe.fPseudoBundle = TRUE; | ||
117 | pPassthroughPackage->Exe.protocol = pPackage->Bundle.fSupportsBurnProtocol ? BURN_EXE_PROTOCOL_TYPE_BURN : BURN_EXE_PROTOCOL_TYPE_NONE; | ||
118 | |||
193 | hr = StrAllocString(&pPassthroughPackage->sczId, pPackage->sczId, 0); | 119 | hr = StrAllocString(&pPassthroughPackage->sczId, pPackage->sczId, 0); |
194 | ExitOnFailure(hr, "Failed to copy key for passthrough pseudo bundle."); | 120 | ExitOnFailure(hr, "Failed to copy key for passthrough pseudo bundle."); |
195 | 121 | ||
196 | hr = StrAllocString(&pPassthroughPackage->sczCacheId, pPackage->sczCacheId, 0); | 122 | hr = StrAllocString(&pPassthroughPackage->sczCacheId, pPackage->sczCacheId, 0); |
197 | ExitOnFailure(hr, "Failed to copy cache id for passthrough pseudo bundle."); | 123 | ExitOnFailure(hr, "Failed to copy cache id for passthrough pseudo bundle."); |
198 | 124 | ||
199 | pPassthroughPackage->Exe.protocol = pPackage->Exe.protocol; | ||
200 | |||
201 | hr = CoreCreatePassthroughBundleCommandLine(&sczArguments, pInternalCommand, pCommand); | 125 | hr = CoreCreatePassthroughBundleCommandLine(&sczArguments, pInternalCommand, pCommand); |
202 | ExitOnFailure(hr, "Failed to create command-line arguments."); | 126 | ExitOnFailure(hr, "Failed to create command-line arguments."); |
203 | 127 | ||
204 | hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0); | 128 | hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0); |
205 | ExitOnFailure(hr, "Failed to copy install arguments for passthrough bundle package"); | 129 | ExitOnFailure(hr, "Failed to copy install arguments for passthrough bundle package"); |
206 | 130 | ||
207 | hr = StrAllocString(&pPassthroughPackage->Exe.sczRepairArguments, sczArguments, 0); | ||
208 | ExitOnFailure(hr, "Failed to copy related arguments for passthrough bundle package"); | ||
209 | |||
210 | pPassthroughPackage->Exe.fRepairable = TRUE; | ||
211 | |||
212 | hr = StrAllocString(&pPassthroughPackage->Exe.sczUninstallArguments, sczArguments, 0); | ||
213 | ExitOnFailure(hr, "Failed to copy uninstall arguments for passthrough bundle package"); | ||
214 | |||
215 | pPassthroughPackage->fUninstallable = TRUE; | ||
216 | |||
217 | // TODO: consider bringing this back in the near future. | ||
218 | //if (pDependencyProvider) | ||
219 | //{ | ||
220 | // pPassthroughPackage->rgDependencyProviders = (BURN_DEPENDENCY_PROVIDER*)MemAlloc(sizeof(BURN_DEPENDENCY_PROVIDER), TRUE); | ||
221 | // ExitOnNull(pPassthroughPackage->rgDependencyProviders, hr, E_OUTOFMEMORY, "Failed to allocate memory for dependency providers."); | ||
222 | // pPassthroughPackage->cDependencyProviders = 1; | ||
223 | |||
224 | // pPassthroughPackage->rgDependencyProviders[0].fImported = pDependencyProvider->fImported; | ||
225 | |||
226 | // hr = StrAllocString(&pPassthroughPackage->rgDependencyProviders[0].sczKey, pDependencyProvider->sczKey, 0); | ||
227 | // ExitOnFailure(hr, "Failed to copy key for pseudo bundle."); | ||
228 | |||
229 | // hr = StrAllocString(&pPassthroughPackage->rgDependencyProviders[0].sczVersion, pDependencyProvider->sczVersion, 0); | ||
230 | // ExitOnFailure(hr, "Failed to copy version for pseudo bundle."); | ||
231 | |||
232 | // hr = StrAllocString(&pPassthroughPackage->rgDependencyProviders[0].sczDisplayName, pDependencyProvider->sczDisplayName, 0); | ||
233 | // ExitOnFailure(hr, "Failed to copy display name for pseudo bundle."); | ||
234 | //} | ||
235 | |||
236 | LExit: | 131 | LExit: |
237 | ReleaseStr(sczArguments); | 132 | ReleaseStr(sczArguments); |
238 | return hr; | 133 | return hr; |
@@ -290,14 +185,16 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle( | |||
290 | memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); | 185 | memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); |
291 | } | 186 | } |
292 | 187 | ||
293 | pPackage->Exe.fPseudoBundle = TRUE; | ||
294 | |||
295 | pPackage->type = BURN_PACKAGE_TYPE_EXE; | 188 | pPackage->type = BURN_PACKAGE_TYPE_EXE; |
296 | pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT; | 189 | pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT; |
297 | pPackage->qwInstallSize = qwSize; | 190 | pPackage->qwInstallSize = qwSize; |
298 | pPackage->qwSize = qwSize; | 191 | pPackage->qwSize = qwSize; |
299 | pPackage->fVital = TRUE; | 192 | pPackage->fVital = TRUE; |
300 | 193 | ||
194 | // Trust the BA to only use UPDATE_REPLACE_EMBEDDED when appropriate. | ||
195 | pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN; | ||
196 | pPackage->Exe.fPseudoBundle = TRUE; | ||
197 | |||
301 | hr = StrAllocString(&pPackage->sczId, wzId, 0); | 198 | hr = StrAllocString(&pPackage->sczId, wzId, 0); |
302 | ExitOnFailure(hr, "Failed to copy id for update bundle."); | 199 | ExitOnFailure(hr, "Failed to copy id for update bundle."); |
303 | 200 | ||
@@ -307,10 +204,6 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle( | |||
307 | hr = StrAllocString(&pPackage->Exe.sczInstallArguments, wzInstallArguments, 0); | 204 | hr = StrAllocString(&pPackage->Exe.sczInstallArguments, wzInstallArguments, 0); |
308 | ExitOnFailure(hr, "Failed to copy install arguments for update bundle package"); | 205 | ExitOnFailure(hr, "Failed to copy install arguments for update bundle package"); |
309 | 206 | ||
310 | // Trust the BA to only use UPDATE_REPLACE_EMBEDDED when appropriate. | ||
311 | pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN; | ||
312 | pPackage->Exe.fSupportsAncestors = TRUE; | ||
313 | |||
314 | LExit: | 207 | LExit: |
315 | return hr; | 208 | return hr; |
316 | } \ No newline at end of file | 209 | } |