@joebigelow / wix / commits / dbd55be5

Initialize exe package ancestors during CoreInitialize instead of Plan.

Sean Hall committed Feb 15, 2021 at 17:36 UTC dbd55be5e707f07eb044c8c7f13c3dfd246148c0
10 files changed +58 -41
src/engine/core.cpp
+40 -3
@@ -104,9 +104,9 @@ extern "C" HRESULT CoreInitialize(
104 ExitOnFailure(hr, "Failed to parse command line.");
105
106 LogId(REPORT_STANDARD, MSG_BURN_COMMAND_LINE, sczSanitizedCommandLine ? sczSanitizedCommandLine : L"");
107 -
108 - hr = DependencyInitialize(&pEngineState->registration, pEngineState->sczIgnoreDependencies);
109 - ExitOnFailure(hr, "Failed to initialize dependency data.");
107 +
108 + hr = CoreInitializeConstants(pEngineState);
109 + ExitOnFailure(hr, "Failed to initialize contants.");
110
111 // Retain whether bundle was initially run elevated.
112 ProcElevated(::GetCurrentProcess(), &fElevated);
@@ -173,6 +173,43 @@ LExit:
173 return hr;
174 }
175
176 +extern "C" HRESULT CoreInitializeConstants(
177 + __in BURN_ENGINE_STATE* pEngineState
178 + )
179 +{
180 + HRESULT hr = S_OK;
181 + BURN_REGISTRATION* pRegistration = &pEngineState->registration;
182 +
183 + hr = DependencyInitialize(pRegistration, pEngineState->sczIgnoreDependencies);
184 + ExitOnFailure(hr, "Failed to initialize dependency data.");
185 +
186 + // Support passing Ancestors to embedded burn bundles.
187 + if (pRegistration->sczAncestors && *pRegistration->sczAncestors)
188 + {
189 + hr = StrAllocFormatted(&pRegistration->sczBundlePackageAncestors, L"%ls;%ls", pRegistration->sczAncestors, pRegistration->sczId);
190 + ExitOnFailure(hr, "Failed to copy ancestors and self to bundle package ancestors.");
191 + }
192 + else
193 + {
194 + hr = StrAllocString(&pRegistration->sczBundlePackageAncestors, pRegistration->sczId, 0);
195 + ExitOnFailure(hr, "Failed to copy self to bundle package ancestors.");
196 + }
197 +
198 + for (DWORD i = 0; i < pEngineState->packages.cPackages; ++i)
199 + {
200 + BURN_PACKAGE* pPackage = pEngineState->packages.rgPackages + i;
201 +
202 + if (BURN_PACKAGE_TYPE_EXE == pPackage->type && BURN_EXE_PROTOCOL_TYPE_BURN == pPackage->Exe.protocol) // TODO: Don't assume exePackages with burn protocol are bundles.
203 + {
204 + // Pass along any ancestors and ourself to prevent infinite loops.
205 + pPackage->Exe.wzAncestors = pRegistration->sczBundlePackageAncestors;
206 + }
207 + }
208 +
209 +LExit:
210 + return hr;
211 +}
212 +
213 extern "C" HRESULT CoreSerializeEngineState(
214 __in BURN_ENGINE_STATE* pEngineState,
215 __inout BYTE** ppbBuffer,
src/engine/core.h
+3
@@ -138,6 +138,9 @@ typedef struct _BURN_ENGINE_STATE
138 HRESULT CoreInitialize(
139 __in BURN_ENGINE_STATE* pEngineState
140 );
141 +HRESULT CoreInitializeConstants(
142 + __in BURN_ENGINE_STATE* pEngineState
143 + );
144 HRESULT CoreSerializeEngineState(
145 __in BURN_ENGINE_STATE* pEngineState,
146 __inout BYTE** ppbBuffer,
src/engine/exeengine.cpp
+4 -5
@@ -105,7 +105,6 @@ extern "C" void ExeEnginePackageUninitialize(
105 ReleaseStr(pPackage->Exe.sczRepairArguments);
106 ReleaseStr(pPackage->Exe.sczUninstallArguments);
107 ReleaseStr(pPackage->Exe.sczIgnoreDependencies);
108 - ReleaseStr(pPackage->Exe.sczAncestors);
108 //ReleaseStr(pPackage->Exe.sczProgressSwitch);
109 ReleaseMem(pPackage->Exe.rgExitCodes);
110
@@ -334,9 +333,9 @@ extern "C" HRESULT ExeEnginePlanAddPackage(
333 ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore.");
334 }
335
337 - if (pPackage->Exe.sczAncestors)
336 + if (pPackage->Exe.wzAncestors)
337 {
339 - hr = StrAllocString(&pAction->exePackage.sczAncestors, pPackage->Exe.sczAncestors, 0);
338 + hr = StrAllocString(&pAction->exePackage.sczAncestors, pPackage->Exe.wzAncestors, 0);
339 ExitOnFailure(hr, "Failed to allocate the list of ancestors.");
340 }
341
@@ -359,9 +358,9 @@ extern "C" HRESULT ExeEnginePlanAddPackage(
358 ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore.");
359 }
360
362 - if (pPackage->Exe.sczAncestors)
361 + if (pPackage->Exe.wzAncestors)
362 {
364 - hr = StrAllocString(&pAction->exePackage.sczAncestors, pPackage->Exe.sczAncestors, 0);
363 + hr = StrAllocString(&pAction->exePackage.sczAncestors, pPackage->Exe.wzAncestors, 0);
364 ExitOnFailure(hr, "Failed to allocate the list of ancestors.");
365 }
366
src/engine/package.h
+1 -1
@@ -250,7 +250,7 @@ typedef struct _BURN_PACKAGE
250 LPWSTR sczRepairArguments;
251 LPWSTR sczUninstallArguments;
252 LPWSTR sczIgnoreDependencies;
253 - LPWSTR sczAncestors;
253 + LPCWSTR wzAncestors; // points directly into engine state.
254
255 BOOL fPseudoBundle;
256
src/engine/plan.cpp
+2 -27
@@ -475,7 +475,7 @@ LExit:
475 }
476
477 extern "C" HRESULT PlanPackages(
478 - __in BURN_REGISTRATION* pRegistration,
478 + __in BURN_REGISTRATION* /*pRegistration*/,
479 __in BURN_USER_EXPERIENCE* pUX,
480 __in BURN_PACKAGES* pPackages,
481 __in BURN_PLAN* pPlan,
@@ -498,22 +498,6 @@ extern "C" HRESULT PlanPackages(
498 DWORD iPackage = (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) ? pPackages->cPackages - 1 - i : i;
499 BURN_PACKAGE* pPackage = pPackages->rgPackages + iPackage;
500
501 - // Support passing Ancestors to embedded burn bundles
502 - if (BURN_PACKAGE_TYPE_EXE == pPackage->type && BURN_EXE_PROTOCOL_TYPE_BURN == pPackage->Exe.protocol)
503 - {
504 - // Pass along any ancestors and ourself to prevent infinite loops.
505 - if (pRegistration->sczAncestors && *pRegistration->sczAncestors)
506 - {
507 - hr = StrAllocFormatted(&pPackage->Exe.sczAncestors, L"%ls;%ls", pRegistration->sczAncestors, pRegistration->sczId);
508 - ExitOnFailure(hr, "Failed to copy ancestors and self to related bundle ancestors.");
509 - }
510 - else
511 - {
512 - hr = StrAllocString(&pPackage->Exe.sczAncestors, pRegistration->sczId, 0);
513 - ExitOnFailure(hr, "Failed to copy self to related bundle ancestors.");
514 - }
515 - }
516 -
501 hr = ProcessPackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary);
502 ExitOnFailure(hr, "Failed to process package.");
503 }
@@ -1230,16 +1214,7 @@ extern "C" HRESULT PlanRelatedBundlesBegin(
1214 }
1215
1216 // Pass along any ancestors and ourself to prevent infinite loops.
1233 - if (pRegistration->sczAncestors && *pRegistration->sczAncestors)
1234 - {
1235 - hr = StrAllocFormatted(&pRelatedBundle->package.Exe.sczAncestors, L"%ls;%ls", pRegistration->sczAncestors, pRegistration->sczId);
1236 - ExitOnFailure(hr, "Failed to copy ancestors and self to related bundle ancestors.");
1237 - }
1238 - else
1239 - {
1240 - hr = StrAllocString(&pRelatedBundle->package.Exe.sczAncestors, pRegistration->sczId, 0);
1241 - ExitOnFailure(hr, "Failed to copy self to related bundle ancestors.");
1242 - }
1217 + pRelatedBundle->package.Exe.wzAncestors = pRegistration->sczBundlePackageAncestors;
1218
1219 hr = PlanDefaultRelatedBundleRequestState(relationType, pRelatedBundle->relationType, pPlan->action, pRegistration->pVersion, pRelatedBundle->pVersion, &pRelatedBundle->package.requested);
1220 ExitOnFailure(hr, "Failed to get default request state for related bundle.");
src/engine/pseudobundle.cpp
+2 -2
@@ -159,8 +159,8 @@ extern "C" HRESULT PseudoBundleInitializePassthrough(
159 __in BURN_PACKAGE* pPassthroughPackage,
160 __in BOOTSTRAPPER_COMMAND* pCommand,
161 __in_z_opt LPCWSTR wzAppendLogPath,
162 - __in_z_opt LPWSTR wzActiveParent,
163 - __in_z_opt LPWSTR wzAncestors,
162 + __in_z_opt LPCWSTR wzActiveParent,
163 + __in_z_opt LPCWSTR wzAncestors,
164 __in BURN_PACKAGE* pPackage
165 )
166 {
src/engine/pseudobundle.h
+2 -2
@@ -29,8 +29,8 @@ HRESULT PseudoBundleInitializePassthrough(
29 __in BURN_PACKAGE* pPassthroughPackage,
30 __in BOOTSTRAPPER_COMMAND* pCommand,
31 __in_z_opt LPCWSTR wzAppendLogPath,
32 - __in_z_opt LPWSTR wzActiveParent,
33 - __in_z_opt LPWSTR wzAncestors,
32 + __in_z_opt LPCWSTR wzActiveParent,
33 + __in_z_opt LPCWSTR wzAncestors,
34 __in BURN_PACKAGE* pPackage
35 );
36
src/engine/registration.cpp
+1
@@ -396,6 +396,7 @@ extern "C" void RegistrationUninitialize(
396
397 ReleaseStr(pRegistration->sczDetectedProviderKeyBundleId);
398 ReleaseStr(pRegistration->sczAncestors);
399 + ReleaseStr(pRegistration->sczBundlePackageAncestors);
400 RelatedBundlesUninitialize(&pRegistration->relatedBundles);
401
402 // clear struct
src/engine/registration.h
+1
@@ -150,6 +150,7 @@ typedef struct _BURN_REGISTRATION
150
151 LPWSTR sczDetectedProviderKeyBundleId;
152 LPWSTR sczAncestors;
153 + LPWSTR sczBundlePackageAncestors;
154
155 BOOL fEnabledForwardCompatibleBundle;
156 BURN_PACKAGE forwardCompatibleBundle;
src/test/BurnUnitTest/PlanTest.cpp
+2 -1
@@ -679,7 +679,8 @@ namespace Bootstrapper
679 ReleaseStr(sczFilePath);
680 }
681
682 - DependencyInitialize(&pEngineState->registration, NULL);
682 + hr = CoreInitializeConstants(pEngineState);
683 + NativeAssert::Succeeded(hr, "Failed to initialize core constants");
684
685 pEngineState->userExperience.pfnBAProc = PlanTestBAProc;
686 }