@joebigelow / wix-1 / commits / ce8acddf

Add BURN_DEPENDENCIES struct to store Dependency state.

Sean Hall committed Aug 3, 2021 at 15:41 UTC ce8acddf52bde840571535c3dfd56a2371d80684
18 files changed +148 -95
src/burn/engine/approvedexe.h
+1
@@ -10,6 +10,7 @@ extern "C" {
10
11 typedef struct _BOOTSTRAPPER_ENGINE_CONTEXT BOOTSTRAPPER_ENGINE_CONTEXT;
12 typedef struct _BURN_CACHE BURN_CACHE;
13 +typedef struct _BURN_DEPENDENCIES BURN_DEPENDENCIES;
14 typedef struct _BURN_ENGINE_COMMAND BURN_ENGINE_COMMAND;
15
16 // structs
src/burn/engine/core.cpp
+18 -11
@@ -111,6 +111,12 @@ extern "C" HRESULT CoreInitialize(
111 hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_UILEVEL, pEngineState->command.display, TRUE);
112 ExitOnFailure(hr, "Failed to overwrite the %ls built-in variable.", BURN_BUNDLE_UILEVEL);
113
114 + if (pEngineState->internalCommand.sczActiveParent && *pEngineState->internalCommand.sczActiveParent)
115 + {
116 + hr = VariableSetString(&pEngineState->variables, BURN_BUNDLE_ACTIVE_PARENT, pEngineState->internalCommand.sczActiveParent, TRUE, FALSE);
117 + ExitOnFailure(hr, "Failed to overwrite the bundle active parent built-in variable.");
118 + }
119 +
120 if (pEngineState->internalCommand.sczSourceProcessPath)
121 {
122 hr = VariableSetString(&pEngineState->variables, BURN_BUNDLE_SOURCE_PROCESS_PATH, pEngineState->internalCommand.sczSourceProcessPath, TRUE, FALSE);
@@ -172,7 +178,7 @@ extern "C" HRESULT CoreInitializeConstants(
178 HRESULT hr = S_OK;
179 BURN_REGISTRATION* pRegistration = &pEngineState->registration;
180
175 - hr = DependencyInitialize(pRegistration, pEngineState->sczIgnoreDependencies);
181 + hr = DependencyInitialize(&pEngineState->internalCommand, &pEngineState->dependencies, pRegistration);
182 ExitOnFailure(hr, "Failed to initialize dependency data.");
183
184 // Support passing Ancestors to embedded burn bundles.
@@ -360,7 +366,7 @@ extern "C" HRESULT CoreDetect(
366 }
367 }
368
363 - hr = DependencyDetect(pEngineState);
369 + hr = DependencyDetect(&pEngineState->dependencies, &pEngineState->packages, &pEngineState->registration);
370 ExitOnFailure(hr, "Failed to detect the dependencies.");
371
372 // Log the detected states.
@@ -453,6 +459,7 @@ extern "C" HRESULT CorePlan(
459 // we make everywhere.
460 pEngineState->plan.action = action;
461 pEngineState->plan.pCache = &pEngineState->cache;
462 + pEngineState->plan.pInternalCommand = &pEngineState->internalCommand;
463 pEngineState->plan.pPayloads = &pEngineState->payloads;
464 pEngineState->plan.wzBundleId = pEngineState->registration.sczId;
465 pEngineState->plan.wzBundleProviderKey = pEngineState->registration.sczId;
@@ -463,10 +470,10 @@ extern "C" HRESULT CorePlan(
470 ExitOnFailure(hr, "Failed to update action.");
471
472 // Set resume commandline
466 - hr = PlanSetResumeCommand(&pEngineState->registration, action, &pEngineState->command, &pEngineState->log);
473 + hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->command, &pEngineState->log);
474 ExitOnFailure(hr, "Failed to set resume command");
475
469 - hr = DependencyPlanInitialize(&pEngineState->registration, &pEngineState->plan);
476 + hr = DependencyPlanInitialize(&pEngineState->dependencies, &pEngineState->plan);
477 ExitOnFailure(hr, "Failed to initialize the dependencies for the plan.");
478
479 if (BOOTSTRAPPER_ACTION_LAYOUT == action)
@@ -508,7 +515,7 @@ extern "C" HRESULT CorePlan(
515 {
516 pEngineState->plan.fPerMachine = pEngineState->registration.fPerMachine; // default the scope of the plan to the per-machine state of the bundle.
517
511 - hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning);
518 + hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, &pEngineState->dependencies, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning);
519 ExitOnFailure(hr, "Failed to plan registration.");
520
521 if (fContinuePlanning)
@@ -921,10 +928,10 @@ extern "C" LPCWSTR CoreRelationTypeToCommandLineString(
928 extern "C" HRESULT CoreRecreateCommandLine(
929 __deref_inout_z LPWSTR* psczCommandLine,
930 __in BOOTSTRAPPER_ACTION action,
924 - __in BOOTSTRAPPER_DISPLAY display,
931 + __in BURN_ENGINE_COMMAND* pInternalCommand,
932 + __in BOOTSTRAPPER_COMMAND* pCommand,
933 __in BOOTSTRAPPER_RELATION_TYPE relationType,
934 __in BOOL fPassthrough,
927 - __in_z_opt LPCWSTR wzActiveParent,
935 __in_z_opt LPCWSTR wzAncestors,
936 __in_z_opt LPCWSTR wzAppendLogPath,
937 __in_z_opt LPCWSTR wzAdditionalCommandLineArguments
@@ -937,7 +944,7 @@ extern "C" HRESULT CoreRecreateCommandLine(
944 hr = StrAllocString(psczCommandLine, L"", 0);
945 ExitOnFailure(hr, "Failed to empty command line.");
946
940 - switch (display)
947 + switch (pCommand->display)
948 {
949 case BOOTSTRAPPER_DISPLAY_NONE:
950 hr = StrAllocConcat(psczCommandLine, L" /quiet", 0);
@@ -962,11 +969,11 @@ extern "C" HRESULT CoreRecreateCommandLine(
969 }
970 ExitOnFailure(hr, "Failed to append action state to command-line");
971
965 - if (wzActiveParent)
972 + if (pInternalCommand->sczActiveParent)
973 {
967 - if (*wzActiveParent)
974 + if (*pInternalCommand->sczActiveParent)
975 {
969 - hr = StrAllocFormatted(&scz, L" /%ls \"%ls\"", BURN_COMMANDLINE_SWITCH_PARENT, wzActiveParent);
976 + hr = StrAllocFormatted(&scz, L" /%ls \"%ls\"", BURN_COMMANDLINE_SWITCH_PARENT, pInternalCommand->sczActiveParent);
977 ExitOnFailure(hr, "Failed to format active parent command-line for command-line.");
978 }
979 else
src/burn/engine/core.h
+7 -4
@@ -81,6 +81,10 @@ enum BURN_AU_PAUSE_ACTION
81 typedef struct _BURN_ENGINE_COMMAND
82 {
83 BOOL fInitiallyElevated;
84 +
85 + LPWSTR sczActiveParent;
86 + LPWSTR sczIgnoreDependencies;
87 +
88 LPWSTR sczSourceProcessPath;
89 LPWSTR sczOriginalSource;
90 } BURN_ENGINE_COMMAND;
@@ -111,6 +115,7 @@ typedef struct _BURN_ENGINE_STATE
115 BURN_UPDATE update;
116 BURN_APPROVED_EXES approvedExes;
117 BURN_CACHE cache;
118 + BURN_DEPENDENCIES dependencies;
119 BURN_EXTENSIONS extensions;
120
121 HWND hMessageWindow;
@@ -138,8 +143,6 @@ typedef struct _BURN_ENGINE_STATE
143 BURN_RESUME_MODE resumeMode;
144 BOOL fDisableUnelevate;
145
141 - LPWSTR sczIgnoreDependencies;
142 -
146 int argc;
147 LPWSTR* argv;
148 BOOL fInvalidCommandLine;
@@ -211,10 +214,10 @@ LPCWSTR CoreRelationTypeToCommandLineString(
214 HRESULT CoreRecreateCommandLine(
215 __deref_inout_z LPWSTR* psczCommandLine,
216 __in BOOTSTRAPPER_ACTION action,
214 - __in BOOTSTRAPPER_DISPLAY display,
217 + __in BURN_ENGINE_COMMAND* pInternalCommand,
218 + __in BOOTSTRAPPER_COMMAND* pCommand,
219 __in BOOTSTRAPPER_RELATION_TYPE relationType,
220 __in BOOL fPassthrough,
217 - __in_z_opt LPCWSTR wzActiveParent,
221 __in_z_opt LPCWSTR wzAncestors,
222 __in_z_opt LPCWSTR wzAppendLogPath,
223 __in_z_opt LPCWSTR wzAdditionalCommandLineArguments
src/burn/engine/dependency.cpp
+43 -23
@@ -171,38 +171,58 @@ LExit:
171 }
172
173 extern "C" HRESULT DependencyInitialize(
174 - __in BURN_REGISTRATION* pRegistration,
175 - __in_z_opt LPCWSTR wzIgnoreDependencies
174 + __in BURN_ENGINE_COMMAND* pInternalCommand,
175 + __in BURN_DEPENDENCIES* pDependencies,
176 + __in BURN_REGISTRATION* pRegistration
177 )
178 {
179 + AssertSz(!pDependencies->cIgnoredDependencies, "Dependencies already initalized.");
180 +
181 HRESULT hr = S_OK;
182
183 // If no parent was specified at all, use the bundle id as the self dependent.
181 - if (!pRegistration->sczActiveParent)
184 + if (!pInternalCommand->sczActiveParent)
185 {
183 - pRegistration->wzSelfDependent = pRegistration->sczId;
186 + pDependencies->wzSelfDependent = pRegistration->sczId;
187 }
185 - else if (*pRegistration->sczActiveParent) // if parent was specified use that as the self dependent.
188 + else if (*pInternalCommand->sczActiveParent) // if parent was specified use that as the self dependent.
189 {
187 - pRegistration->wzSelfDependent = pRegistration->sczActiveParent;
190 + pDependencies->wzSelfDependent = pInternalCommand->sczActiveParent;
191 }
192 // else parent:none was used which means we should not register a dependency on ourself.
193
194 + pDependencies->wzActiveParent = pInternalCommand->sczActiveParent;
195 +
196 // The current bundle provider key should always be ignored for dependency checks.
192 - hr = DepDependencyArrayAlloc(&pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, pRegistration->sczProviderKey, NULL);
197 + hr = DepDependencyArrayAlloc(&pDependencies->rgIgnoredDependencies, &pDependencies->cIgnoredDependencies, pRegistration->sczProviderKey, NULL);
198 ExitOnFailure(hr, "Failed to add the bundle provider key to the list of dependencies to ignore.");
199
200 // Add the list of dependencies to ignore.
196 - if (wzIgnoreDependencies)
201 + if (pInternalCommand->sczIgnoreDependencies)
202 {
198 - hr = SplitIgnoreDependencies(wzIgnoreDependencies, &pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, &pRegistration->fIgnoreAllDependents);
203 + hr = SplitIgnoreDependencies(pInternalCommand->sczIgnoreDependencies, &pDependencies->rgIgnoredDependencies, &pDependencies->cIgnoredDependencies, &pDependencies->fIgnoreAllDependents);
204 ExitOnFailure(hr, "Failed to split the list of dependencies to ignore.");
205 }
206
207 + pDependencies->fSelfDependent = NULL != pDependencies->wzSelfDependent;
208 + pDependencies->fActiveParent = NULL != pInternalCommand->sczActiveParent && NULL != *pInternalCommand->sczActiveParent;
209 +
210 LExit:
211 return hr;
212 }
213
214 +extern "C" void DependencyUninitialize(
215 + __in BURN_DEPENDENCIES* pDependencies
216 + )
217 +{
218 + if (pDependencies->rgIgnoredDependencies)
219 + {
220 + ReleaseDependencyArray(pDependencies->rgIgnoredDependencies, pDependencies->cIgnoredDependencies);
221 + }
222 +
223 + memset(pDependencies, 0, sizeof(BURN_DEPENDENCIES));
224 +}
225 +
226 extern "C" HRESULT DependencyDetectProviderKeyBundleId(
227 __in BURN_REGISTRATION* pRegistration
228 )
@@ -228,15 +248,14 @@ LExit:
248 }
249
250 extern "C" HRESULT DependencyDetect(
231 - __in BURN_ENGINE_STATE* pEngineState
251 + __in BURN_DEPENDENCIES* pDependencies,
252 + __in BURN_PACKAGES* pPackages,
253 + __in BURN_REGISTRATION* pRegistration
254 )
255 {
256 HRESULT hr = S_OK;
235 - BURN_REGISTRATION* pRegistration = &pEngineState->registration;
257 STRINGDICT_HANDLE sdIgnoredDependents = NULL;
258 BURN_PACKAGE* pPackage = NULL;
238 - BOOL fSelfDependent = NULL != pRegistration->wzSelfDependent;
239 - BOOL fActiveParent = NULL != pRegistration->sczActiveParent && NULL != *pRegistration->sczActiveParent;
259
260 // Always leave this empty so that all dependents get detected. Plan will ignore dependents based on its own logic.
261 hr = DictCreateStringList(&sdIgnoredDependents, INITIAL_STRINGDICT_SIZE, DICT_FLAG_CASEINSENSITIVE);
@@ -252,16 +271,16 @@ extern "C" HRESULT DependencyDetect(
271 hr = S_OK;
272 }
273
255 - for (DWORD iPackage = 0; iPackage < pEngineState->packages.cPackages; ++iPackage)
274 + for (DWORD iPackage = 0; iPackage < pPackages->cPackages; ++iPackage)
275 {
257 - pPackage = pEngineState->packages.rgPackages + iPackage;
276 + pPackage = pPackages->rgPackages + iPackage;
277 hr = DetectPackageDependents(pPackage, sdIgnoredDependents, pRegistration);
278 ExitOnFailure(hr, "Failed to detect dependents for package '%ls'", pPackage->sczId);
279 }
280
262 - for (DWORD iRelatedBundle = 0; iRelatedBundle < pEngineState->registration.relatedBundles.cRelatedBundles; ++iRelatedBundle)
281 + for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle)
282 {
264 - BURN_RELATED_BUNDLE* pRelatedBundle = pEngineState->registration.relatedBundles.rgRelatedBundles + iRelatedBundle;
283 + BURN_RELATED_BUNDLE* pRelatedBundle = pRegistration->relatedBundles.rgRelatedBundles + iRelatedBundle;
284 if (!pRelatedBundle->fPlannable)
285 {
286 continue;
@@ -272,18 +291,18 @@ extern "C" HRESULT DependencyDetect(
291 ExitOnFailure(hr, "Failed to detect dependents for related bundle '%ls'", pPackage->sczId);
292 }
293
275 - if (fSelfDependent || fActiveParent)
294 + if (pDependencies->fSelfDependent || pDependencies->fActiveParent)
295 {
296 for (DWORD i = 0; i < pRegistration->cDependents; ++i)
297 {
298 DEPENDENCY* pDependent = pRegistration->rgDependents + i;
299
281 - if (fActiveParent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczActiveParent, -1, pDependent->sczKey, -1))
300 + if (pDependencies->fActiveParent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pDependencies->wzActiveParent, -1, pDependent->sczKey, -1))
301 {
302 pRegistration->fParentRegisteredAsDependent = TRUE;
303 }
304
286 - if (fSelfDependent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->wzSelfDependent, -1, pDependent->sczKey, -1))
305 + if (pDependencies->fSelfDependent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pDependencies->wzSelfDependent, -1, pDependent->sczKey, -1))
306 {
307 pRegistration->fSelfRegisteredAsDependent = TRUE;
308 }
@@ -297,16 +316,16 @@ LExit:
316 }
317
318 extern "C" HRESULT DependencyPlanInitialize(
300 - __in const BURN_REGISTRATION* pRegistration,
319 + __in BURN_DEPENDENCIES* pDependencies,
320 __in BURN_PLAN* pPlan
321 )
322 {
323 HRESULT hr = S_OK;
324
325 // TODO: After adding enumeration to STRINGDICT, a single STRINGDICT_HANDLE can be used everywhere.
307 - for (DWORD i = 0; i < pRegistration->cIgnoredDependencies; ++i)
326 + for (DWORD i = 0; i < pDependencies->cIgnoredDependencies; ++i)
327 {
309 - DEPENDENCY* pDependency = pRegistration->rgIgnoredDependencies + i;
328 + DEPENDENCY* pDependency = pDependencies->rgIgnoredDependencies + i;
329
330 hr = DepDependencyArrayAlloc(&pPlan->rgPlannedProviders, &pPlan->cPlannedProviders, pDependency->sczKey, pDependency->sczName);
331 ExitOnFailure(hr, "Failed to add the detected provider to the list of dependencies to ignore.");
@@ -952,6 +971,7 @@ static HRESULT GetIgnoredDependents(
971 {
972 ExitOnFailure(hr, "Failed to get the package property: %ls", DEPENDENCY_IGNOREDEPENDENCIES);
973
974 + // TODO: this is the raw value of the property, all property values are currently formatted in a different part of planning.
975 hr = DependencyAddIgnoreDependencies(*psdIgnoredDependents, sczIgnoreDependencies);
976 ExitOnFailure(hr, "Failed to add the authored ignored dependencies to the cumulative list of ignored dependencies.");
977 }
src/burn/engine/dependency.h
+23 -4
@@ -11,6 +11,18 @@ extern "C" {
11 const LPCWSTR DEPENDENCY_IGNOREDEPENDENCIES = L"IGNOREDEPENDENCIES";
12
13
14 +typedef struct _BURN_DEPENDENCIES
15 +{
16 + DEPENDENCY* rgIgnoredDependencies;
17 + UINT cIgnoredDependencies;
18 + LPCWSTR wzActiveParent;
19 + LPCWSTR wzSelfDependent;
20 + BOOL fIgnoreAllDependents;
21 + BOOL fSelfDependent;
22 + BOOL fActiveParent;
23 +} BURN_DEPENDENCIES;
24 +
25 +
26 // function declarations
27
28 /********************************************************************
@@ -33,8 +45,13 @@ HRESULT DependencyParseProvidersFromXml(
45 );
46
47 HRESULT DependencyInitialize(
36 - __in BURN_REGISTRATION* pRegistration,
37 - __in_z_opt LPCWSTR wzIgnoreDependencies
48 + __in BURN_ENGINE_COMMAND* pInternalCommand,
49 + __in BURN_DEPENDENCIES* pDependencies,
50 + __in BURN_REGISTRATION* pRegistration
51 + );
52 +
53 +void DependencyUninitialize(
54 + __in BURN_DEPENDENCIES* pDependencies
55 );
56
57 /********************************************************************
@@ -52,7 +69,9 @@ HRESULT DependencyDetectProviderKeyBundleId(
69
70 *********************************************************************/
71 HRESULT DependencyDetect(
55 - __in BURN_ENGINE_STATE* pEngineState
72 + __in BURN_DEPENDENCIES* pDependencies,
73 + __in BURN_PACKAGES* pPackages,
74 + __in BURN_REGISTRATION* pRegistration
75 );
76
77 /********************************************************************
@@ -60,7 +79,7 @@ HRESULT DependencyDetect(
79
80 *********************************************************************/
81 HRESULT DependencyPlanInitialize(
63 - __in const BURN_REGISTRATION* pRegistration,
82 + __in BURN_DEPENDENCIES* pDependencies,
83 __in BURN_PLAN* pPlan
84 );
85
src/burn/engine/detect.cpp
-7
@@ -44,13 +44,6 @@ extern "C" void DetectReset(
44 pRegistration->fForwardCompatibleBundleExists = FALSE;
45 pRegistration->fEligibleForCleanup = FALSE;
46
47 - if (pRegistration->rgIgnoredDependencies)
48 - {
49 - ReleaseDependencyArray(pRegistration->rgIgnoredDependencies, pRegistration->cIgnoredDependencies);
50 - }
51 - pRegistration->rgIgnoredDependencies = NULL;
52 - pRegistration->cIgnoredDependencies = 0;
53 -
47 if (pRegistration->rgDependents)
48 {
49 ReleaseDependencyArray(pRegistration->rgDependents, pRegistration->cDependents);
src/burn/engine/engine.cpp
+4 -3
@@ -338,7 +338,7 @@ static HRESULT InitializeEngineState(
338 ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated);
339
340 // Parse command line.
341 - hr = CoreParseCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &pEngineState->mode, &pEngineState->automaticUpdates, &pEngineState->fDisableSystemRestore, &pEngineState->internalCommand.sczSourceProcessPath, &pEngineState->internalCommand.sczOriginalSource, &hSectionFile, &hSourceEngineFile, &pEngineState->fDisableUnelevate, &pEngineState->log.dwAttributes, &pEngineState->log.sczPath, &pEngineState->registration.sczActiveParent, &pEngineState->sczIgnoreDependencies, &pEngineState->registration.sczAncestors, &pEngineState->fInvalidCommandLine, &pEngineState->cUnknownArgs, &pEngineState->rgUnknownArgs);
341 + hr = CoreParseCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &pEngineState->mode, &pEngineState->automaticUpdates, &pEngineState->fDisableSystemRestore, &pEngineState->internalCommand.sczSourceProcessPath, &pEngineState->internalCommand.sczOriginalSource, &hSectionFile, &hSourceEngineFile, &pEngineState->fDisableUnelevate, &pEngineState->log.dwAttributes, &pEngineState->log.sczPath, &pEngineState->internalCommand.sczActiveParent, &pEngineState->internalCommand.sczIgnoreDependencies, &pEngineState->registration.sczAncestors, &pEngineState->fInvalidCommandLine, &pEngineState->cUnknownArgs, &pEngineState->rgUnknownArgs);
342 ExitOnFailure(hr, "Fatal error while parsing command line.");
343
344 hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile);
@@ -362,8 +362,6 @@ static void UninitializeEngineState(
362
363 ReleaseMem(pEngineState->rgUnknownArgs);
364
365 - ReleaseStr(pEngineState->sczIgnoreDependencies);
366 -
365 PipeConnectionUninitialize(&pEngineState->embeddedConnection);
366 PipeConnectionUninitialize(&pEngineState->companionConnection);
367 ReleaseStr(pEngineState->sczBundleEngineWorkingPath)
@@ -376,6 +374,7 @@ static void UninitializeEngineState(
374 UserExperienceUninitialize(&pEngineState->userExperience);
375
376 ApprovedExesUninitialize(&pEngineState->approvedExes);
377 + DependencyUninitialize(&pEngineState->dependencies);
378 UpdateUninitialize(&pEngineState->update);
379 VariablesUninitialize(&pEngineState->variables);
380 SearchesUninitialize(&pEngineState->searches);
@@ -390,6 +389,8 @@ static void UninitializeEngineState(
389 ReleaseStr(pEngineState->command.wzLayoutDirectory);
390 ReleaseStr(pEngineState->command.wzCommandLine);
391
392 + ReleaseStr(pEngineState->internalCommand.sczActiveParent);
393 + ReleaseStr(pEngineState->internalCommand.sczIgnoreDependencies);
394 ReleaseStr(pEngineState->internalCommand.sczOriginalSource);
395 ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath);
396
src/burn/engine/externalengine.cpp
+1 -1
@@ -295,7 +295,7 @@ HRESULT ExternalEngineSetUpdate(
295 {
296 UpdateUninitialize(&pEngineState->update);
297
298 - hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, pEngineState->command.display, BOOTSTRAPPER_RELATION_NONE, FALSE, pEngineState->registration.sczActiveParent, pEngineState->registration.sczAncestors, NULL, pEngineState->command.wzCommandLine);
298 + hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, &pEngineState->internalCommand, &pEngineState->command, BOOTSTRAPPER_RELATION_NONE, FALSE, pEngineState->registration.sczAncestors, NULL, pEngineState->command.wzCommandLine);
299 ExitOnFailure(hr, "Failed to recreate command-line for update bundle.");
300
301 // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths.
src/burn/engine/plan.cpp
+12 -11
@@ -444,7 +444,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles(
444 }
445
446 // Only change the recommendation if an active parent was provided.
447 - if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent)
447 + if (pPlan->pInternalCommand->sczActiveParent && *pPlan->pInternalCommand->sczActiveParent)
448 {
449 // On install, recommend running the forward compatible bundle because there is an active parent. This
450 // will essentially register the parent with the forward compatible bundle.
@@ -480,7 +480,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles(
480
481 if (!fIgnoreBundle)
482 {
483 - hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pCommand, NULL, pRegistration->sczActiveParent, pRegistration->sczAncestors, &pRelatedBundle->package);
483 + hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pPlan->pInternalCommand, pCommand, NULL, pRegistration->sczAncestors, &pRelatedBundle->package);
484 ExitOnFailure(hr, "Failed to initialize pass through bundle.");
485
486 pPlan->fEnabledForwardCompatibleBundle = TRUE;
@@ -512,6 +512,7 @@ extern "C" HRESULT PlanPackages(
512 extern "C" HRESULT PlanRegistration(
513 __in BURN_PLAN* pPlan,
514 __in BURN_REGISTRATION* pRegistration,
515 + __in BURN_DEPENDENCIES* pDependencies,
516 __in BOOTSTRAPPER_RESUME_TYPE /*resumeType*/,
517 __in BOOTSTRAPPER_RELATION_TYPE relationType,
518 __inout BOOL* pfContinuePlanning
@@ -523,7 +524,7 @@ extern "C" HRESULT PlanRegistration(
524
525 pPlan->fCanAffectMachineState = TRUE; // register the bundle since we're modifying machine state.
526 pPlan->fDisallowRemoval = FALSE; // by default the bundle can be planned to be removed
526 - pPlan->fIgnoreAllDependents = pRegistration->fIgnoreAllDependents;
527 + pPlan->fIgnoreAllDependents = pDependencies->fIgnoreAllDependents;
528
529 // Ensure the bundle is cached if not running from the cache.
530 if (!CacheBundleRunningFromCache(pPlan->pCache))
@@ -560,10 +561,10 @@ extern "C" HRESULT PlanRegistration(
561 // would prevent self-removal.
562 if (pRegistration->fSelfRegisteredAsDependent)
563 {
563 - hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_UNREGISTER, pRegistration->wzSelfDependent, pRegistration->sczId);
564 + hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_UNREGISTER, pDependencies->wzSelfDependent, pRegistration->sczId);
565 ExitOnFailure(hr, "Failed to allocate registration action.");
566
566 - hr = DependencyAddIgnoreDependencies(sdIgnoreDependents, pRegistration->wzSelfDependent);
567 + hr = DependencyAddIgnoreDependencies(sdIgnoreDependents, pDependencies->wzSelfDependent);
568 ExitOnFailure(hr, "Failed to add self-dependent to ignore dependents.");
569 }
570
@@ -575,9 +576,9 @@ extern "C" HRESULT PlanRegistration(
576 if (BOOTSTRAPPER_RELATION_UPGRADE != relationType)
577 {
578 // If there were other dependencies to ignore, add them.
578 - for (DWORD iDependency = 0; iDependency < pRegistration->cIgnoredDependencies; ++iDependency)
579 + for (DWORD iDependency = 0; iDependency < pDependencies->cIgnoredDependencies; ++iDependency)
580 {
580 - DEPENDENCY* pDependency = pRegistration->rgIgnoredDependencies + iDependency;
581 + DEPENDENCY* pDependency = pDependencies->rgIgnoredDependencies + iDependency;
582
583 hr = DictKeyExists(sdIgnoreDependents, pDependency->sczKey);
584 if (E_NOTFOUND != hr)
@@ -689,9 +690,9 @@ extern "C" HRESULT PlanRegistration(
690 // Only do the following if we decided there was a dependent self to register. If so and and an explicit parent was
691 // provided, register dependent self. Otherwise, if this bundle is not an addon or patch bundle then self-regisiter
692 // as our own dependent.
692 - if (pRegistration->wzSelfDependent && !pRegistration->fSelfRegisteredAsDependent && (pRegistration->sczActiveParent || !fAddonOrPatchBundle))
693 + if (pDependencies->wzSelfDependent && !pRegistration->fSelfRegisteredAsDependent && (pDependencies->wzActiveParent || !fAddonOrPatchBundle))
694 {
694 - hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_REGISTER, pRegistration->wzSelfDependent, pRegistration->sczId);
695 + hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_REGISTER, pDependencies->wzSelfDependent, pRegistration->sczId);
696 ExitOnFailure(hr, "Failed to add registration action for self dependent.");
697 }
698 }
@@ -1774,8 +1775,8 @@ LExit:
1775
1776 *******************************************************************/
1777 extern "C" HRESULT PlanSetResumeCommand(
1778 + __in BURN_PLAN* pPlan,
1779 __in BURN_REGISTRATION* pRegistration,
1778 - __in BOOTSTRAPPER_ACTION action,
1780 __in BOOTSTRAPPER_COMMAND* pCommand,
1781 __in BURN_LOGGING* pLog
1782 )
@@ -1783,7 +1784,7 @@ extern "C" HRESULT PlanSetResumeCommand(
1784 HRESULT hr = S_OK;
1785
1786 // build the resume command-line.
1786 - hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, action, pCommand->display, pCommand->relationType, pCommand->fPassthrough, pRegistration->sczActiveParent, pRegistration->sczAncestors, pLog->sczPath, pCommand->wzCommandLine);
1787 + hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, pPlan->action, pPlan->pInternalCommand, pCommand, pCommand->relationType, pCommand->fPassthrough, pRegistration->sczAncestors, pLog->sczPath, pCommand->wzCommandLine);
1788 ExitOnFailure(hr, "Failed to recreate resume command-line.");
1789
1790 LExit:
src/burn/engine/plan.h
+3 -1
@@ -230,6 +230,7 @@ typedef struct _BURN_PLAN
230 {
231 BOOTSTRAPPER_ACTION action;
232 BURN_CACHE* pCache;
233 + BURN_ENGINE_COMMAND* pInternalCommand;
234 BURN_PAYLOADS* pPayloads;
235 LPWSTR wzBundleId; // points directly into parent the ENGINE_STATE.
236 LPWSTR wzBundleProviderKey; // points directly into parent the ENGINE_STATE.
@@ -342,6 +343,7 @@ HRESULT PlanPackages(
343 HRESULT PlanRegistration(
344 __in BURN_PLAN* pPlan,
345 __in BURN_REGISTRATION* pRegistration,
346 + __in BURN_DEPENDENCIES* pDependencies,
347 __in BOOTSTRAPPER_RESUME_TYPE resumeType,
348 __in BOOTSTRAPPER_RELATION_TYPE relationType,
349 __inout BOOL* pfContinuePlanning
@@ -442,8 +444,8 @@ HRESULT PlanRollbackBoundaryComplete(
444 __in BURN_PLAN* pPlan
445 );
446 HRESULT PlanSetResumeCommand(
447 + __in BURN_PLAN* pPlan,
448 __in BURN_REGISTRATION* pRegistration,
446 - __in BOOTSTRAPPER_ACTION action,
449 __in BOOTSTRAPPER_COMMAND* pCommand,
450 __in BURN_LOGGING* pLog
451 );
src/burn/engine/precomp.h
+1 -1
@@ -83,13 +83,13 @@
83 #include "logging.h"
84 #include "pipe.h"
85 #include "cache.h"
86 +#include "dependency.h"
87 #include "core.h"
88 #include "apply.h"
89 #include "exeengine.h"
90 #include "msiengine.h"
91 #include "mspengine.h"
92 #include "msuengine.h"
92 -#include "dependency.h"
93 #include "elevation.h"
94 #include "embedded.h"
95 #include "manifest.h"
src/burn/engine/pseudobundle.cpp
+2 -2
@@ -163,9 +163,9 @@ LExit:
163
164 extern "C" HRESULT PseudoBundleInitializePassthrough(
165 __in BURN_PACKAGE* pPassthroughPackage,
166 + __in BURN_ENGINE_COMMAND* pInternalCommand,
167 __in BOOTSTRAPPER_COMMAND* pCommand,
168 __in_z_opt LPCWSTR wzAppendLogPath,
168 - __in_z_opt LPCWSTR wzActiveParent,
169 __in_z_opt LPCWSTR wzAncestors,
170 __in BURN_PACKAGE* pPackage
171 )
@@ -205,7 +205,7 @@ extern "C" HRESULT PseudoBundleInitializePassthrough(
205
206 // No matter the operation, we're passing the same command-line. That's what makes
207 // this a passthrough bundle.
208 - hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pCommand->display, pCommand->relationType, TRUE, wzActiveParent, wzAncestors, wzAppendLogPath, pCommand->wzCommandLine);
208 + hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pInternalCommand, pCommand, pCommand->relationType, TRUE, wzAncestors, wzAppendLogPath, pCommand->wzCommandLine);
209 ExitOnFailure(hr, "Failed to recreate command-line arguments.");
210
211 hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0);
src/burn/engine/pseudobundle.h
+1 -1
@@ -28,9 +28,9 @@ HRESULT PseudoBundleInitialize(
28 );
29 HRESULT PseudoBundleInitializePassthrough(
30 __in BURN_PACKAGE* pPassthroughPackage,
31 + __in BURN_ENGINE_COMMAND* pInternalCommand,
32 __in BOOTSTRAPPER_COMMAND* pCommand,
33 __in_z_opt LPCWSTR wzAppendLogPath,
33 - __in_z_opt LPCWSTR wzActiveParent,
34 __in_z_opt LPCWSTR wzAncestors,
35 __in BURN_PACKAGE* pPackage
36 );
src/burn/engine/registration.cpp
-7
@@ -385,7 +385,6 @@ extern "C" void RegistrationUninitialize(
385 ReleaseMem(pRegistration->rgsczPatchCodes);
386
387 ReleaseStr(pRegistration->sczProviderKey);
388 - ReleaseStr(pRegistration->sczActiveParent);
388 ReleaseStr(pRegistration->sczExecutableName);
389
390 ReleaseStr(pRegistration->sczRegistrationKey);
@@ -462,12 +461,6 @@ extern "C" HRESULT RegistrationSetVariables(
461 hr = GetBundleManufacturer(pRegistration, pVariables, &scz);
462 ExitOnFailure(hr, "Failed to initialize bundle manufacturer.");
463
465 - if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent)
466 - {
467 - hr = VariableSetString(pVariables, BURN_BUNDLE_ACTIVE_PARENT, pRegistration->sczActiveParent, TRUE, FALSE);
468 - ExitOnFailure(hr, "Failed to overwrite the bundle active parent built-in variable.");
469 - }
470 -
464 hr = VariableSetString(pVariables, BURN_BUNDLE_PROVIDER_KEY, pRegistration->sczProviderKey, TRUE, FALSE);
465 ExitOnFailure(hr, "Failed to overwrite the bundle provider key built-in variable.");
466
src/burn/engine/registration.h
-5
@@ -110,7 +110,6 @@ typedef struct _BURN_REGISTRATION
110 DWORD cPatchCodes;
111
112 VERUTIL_VERSION* pVersion;
113 - LPWSTR sczActiveParent;
113 LPWSTR sczProviderKey;
114 LPWSTR sczExecutableName;
115
@@ -145,12 +144,8 @@ typedef struct _BURN_REGISTRATION
144 BURN_UPDATE_REGISTRATION update;
145
146 BURN_RELATED_BUNDLES relatedBundles; // Only valid after detect.
148 - DEPENDENCY* rgIgnoredDependencies; // Only valid after detect.
149 - UINT cIgnoredDependencies; // Only valid after detect.
147 DEPENDENCY* rgDependents; // Only valid after detect.
148 UINT cDependents; // Only valid after detect.
152 - BOOL fIgnoreAllDependents; // Only valid after detect.
153 - LPCWSTR wzSelfDependent; // Only valid after detect.
149 BOOL fSelfRegisteredAsDependent; // Only valid after detect.
150 BOOL fParentRegisteredAsDependent; // Only valid after detect.
151 BOOL fForwardCompatibleBundleExists; // Only valid after detect.
src/burn/test/BurnUnitTest/PlanTest.cpp
+1 -7
@@ -959,15 +959,9 @@ namespace Bootstrapper
959
960 void PlanTestDetect(BURN_ENGINE_STATE* pEngineState)
961 {
962 - HRESULT hr = S_OK;
963 - BURN_REGISTRATION* pRegistration = &pEngineState->registration;
964 -
965 - DetectReset(pRegistration, &pEngineState->packages);
962 + DetectReset(&pEngineState->registration, &pEngineState->packages);
963 PlanReset(&pEngineState->plan, &pEngineState->containers, &pEngineState->packages, &pEngineState->layoutPayloads);
964
968 - hr = DepDependencyArrayAlloc(&pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, pRegistration->sczProviderKey, NULL);
969 - NativeAssert::Succeeded(hr, "Failed to add the bundle provider key to the list of dependencies to ignore.");
970 -
965 pEngineState->userExperience.fEngineActive = TRUE;
966 pEngineState->fDetected = TRUE;
967 }
src/burn/test/BurnUnitTest/RegistrationTest.cpp
+30 -6
@@ -75,6 +75,7 @@ namespace Bootstrapper
75 BURN_REGISTRATION registration = { };
76 BURN_LOGGING logging = { };
77 BURN_PACKAGES packages = { };
78 + BURN_PLAN plan = { };
79 BURN_CACHE cache = { };
80 BURN_ENGINE_COMMAND internalCommand = { };
81 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
@@ -113,7 +114,10 @@ namespace Bootstrapper
114 hr = RegistrationParseFromXml(&registration, &cache, pixeBundle);
115 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
116
116 - hr = PlanSetResumeCommand(&registration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging);
117 + plan.action = BOOTSTRAPPER_ACTION_INSTALL;
118 + plan.pInternalCommand = &internalCommand;
119 +
120 + hr = PlanSetResumeCommand(&plan, &registration, &command, &logging);
121 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
122
123 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -170,6 +174,7 @@ namespace Bootstrapper
174 BURN_REGISTRATION registration = { };
175 BURN_LOGGING logging = { };
176 BURN_PACKAGES packages = { };
177 + BURN_PLAN plan = { };
178 BURN_CACHE cache = { };
179 BURN_ENGINE_COMMAND internalCommand = { };
180 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
@@ -207,7 +212,10 @@ namespace Bootstrapper
212 hr = RegistrationParseFromXml(&registration, &cache, pixeBundle);
213 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
214
210 - hr = PlanSetResumeCommand(&registration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging);
215 + plan.action = BOOTSTRAPPER_ACTION_INSTALL;
216 + plan.pInternalCommand = &internalCommand;
217 +
218 + hr = PlanSetResumeCommand(&plan, &registration, &command, &logging);
219 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
220
221 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -287,6 +295,7 @@ namespace Bootstrapper
295 BURN_REGISTRATION registration = { };
296 BURN_LOGGING logging = { };
297 BURN_PACKAGES packages = { };
298 + BURN_PLAN plan = { };
299 BURN_CACHE cache = { };
300 BURN_ENGINE_COMMAND internalCommand = { };
301 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
@@ -324,7 +333,10 @@ namespace Bootstrapper
333 hr = RegistrationParseFromXml(&registration, &cache, pixeBundle);
334 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
335
327 - hr = PlanSetResumeCommand(&registration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging);
336 + plan.action = BOOTSTRAPPER_ACTION_INSTALL;
337 + plan.pInternalCommand = &internalCommand;
338 +
339 + hr = PlanSetResumeCommand(&plan, &registration, &command, &logging);
340 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
341
342 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -402,6 +414,7 @@ namespace Bootstrapper
414 BURN_REGISTRATION registration = { };
415 BURN_LOGGING logging = { };
416 BURN_PACKAGES packages = { };
417 + BURN_PLAN plan = { };
418 BURN_CACHE cache = { };
419 BURN_ENGINE_COMMAND internalCommand = { };
420 String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID));
@@ -441,7 +454,10 @@ namespace Bootstrapper
454 hr = RegistrationParseFromXml(&registration, &cache, pixeBundle);
455 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
456
444 - hr = PlanSetResumeCommand(&registration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging);
457 + plan.action = BOOTSTRAPPER_ACTION_INSTALL;
458 + plan.pInternalCommand = &internalCommand;
459 +
460 + hr = PlanSetResumeCommand(&plan, &registration, &command, &logging);
461 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
462
463 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -534,6 +550,7 @@ namespace Bootstrapper
550 BURN_REGISTRATION registration = { };
551 BURN_LOGGING logging = { };
552 BURN_PACKAGES packages = { };
553 + BURN_PLAN plan = { };
554 BURN_CACHE cache = { };
555 BURN_ENGINE_COMMAND internalCommand = { };
556 BYTE* pbBuffer = NULL;
@@ -583,7 +600,10 @@ namespace Bootstrapper
600 hr = RegistrationParseFromXml(&registration, &cache, pixeBundle);
601 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
602
586 - hr = PlanSetResumeCommand(&registration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging);
603 + plan.action = BOOTSTRAPPER_ACTION_INSTALL;
604 + plan.pInternalCommand = &internalCommand;
605 +
606 + hr = PlanSetResumeCommand(&plan, &registration, &command, &logging);
607 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
608
609 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -668,6 +688,7 @@ namespace Bootstrapper
688 BURN_REGISTRATION registration = { };
689 BURN_LOGGING logging = { };
690 BURN_PACKAGES packages = { };
691 + BURN_PLAN plan = { };
692 BURN_CACHE cache = { };
693 BURN_ENGINE_COMMAND internalCommand = { };
694 BOOTSTRAPPER_RESUME_TYPE resumeType = BOOTSTRAPPER_RESUME_TYPE_NONE;
@@ -716,7 +737,10 @@ namespace Bootstrapper
737 hr = RegistrationParseFromXml(&registration, &cache, pixeBundle);
738 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
739
719 - hr = PlanSetResumeCommand(&registration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging);
740 + plan.action = BOOTSTRAPPER_ACTION_INSTALL;
741 + plan.pInternalCommand = &internalCommand;
742 +
743 + hr = PlanSetResumeCommand(&plan, &registration, &command, &logging);
744 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
745
746 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
src/burn/test/BurnUnitTest/precomp.h
+1 -1
@@ -57,13 +57,13 @@
57 #include "pipe.h"
58 #include "logging.h"
59 #include "cache.h"
60 +#include "dependency.h"
61 #include "core.h"
62 #include "apply.h"
63 #include "exeengine.h"
64 #include "msiengine.h"
65 #include "mspengine.h"
66 #include "msuengine.h"
66 -#include "dependency.h"
67 #include "elevation.h"
68 #include "embedded.h"
69 #include "manifest.h"