From ce8acddf52bde840571535c3dfd56a2371d80684 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 Aug 2021 15:41:34 -0500 Subject: Add BURN_DEPENDENCIES struct to store Dependency state. --- src/burn/engine/approvedexe.h | 1 + src/burn/engine/core.cpp | 29 ++++++----- src/burn/engine/core.h | 11 +++-- src/burn/engine/dependency.cpp | 66 ++++++++++++++++--------- src/burn/engine/dependency.h | 27 ++++++++-- src/burn/engine/detect.cpp | 7 --- src/burn/engine/engine.cpp | 7 +-- src/burn/engine/externalengine.cpp | 2 +- src/burn/engine/plan.cpp | 23 ++++----- src/burn/engine/plan.h | 4 +- src/burn/engine/precomp.h | 2 +- src/burn/engine/pseudobundle.cpp | 4 +- src/burn/engine/pseudobundle.h | 2 +- src/burn/engine/registration.cpp | 7 --- src/burn/engine/registration.h | 5 -- src/burn/test/BurnUnitTest/PlanTest.cpp | 8 +-- src/burn/test/BurnUnitTest/RegistrationTest.cpp | 36 +++++++++++--- src/burn/test/BurnUnitTest/precomp.h | 2 +- 18 files changed, 148 insertions(+), 95 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/approvedexe.h b/src/burn/engine/approvedexe.h index 076d86c4..cd3bf271 100644 --- a/src/burn/engine/approvedexe.h +++ b/src/burn/engine/approvedexe.h @@ -10,6 +10,7 @@ extern "C" { typedef struct _BOOTSTRAPPER_ENGINE_CONTEXT BOOTSTRAPPER_ENGINE_CONTEXT; typedef struct _BURN_CACHE BURN_CACHE; +typedef struct _BURN_DEPENDENCIES BURN_DEPENDENCIES; typedef struct _BURN_ENGINE_COMMAND BURN_ENGINE_COMMAND; // structs diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 8985ab27..bccdfa9f 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -111,6 +111,12 @@ extern "C" HRESULT CoreInitialize( hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_UILEVEL, pEngineState->command.display, TRUE); ExitOnFailure(hr, "Failed to overwrite the %ls built-in variable.", BURN_BUNDLE_UILEVEL); + if (pEngineState->internalCommand.sczActiveParent && *pEngineState->internalCommand.sczActiveParent) + { + hr = VariableSetString(&pEngineState->variables, BURN_BUNDLE_ACTIVE_PARENT, pEngineState->internalCommand.sczActiveParent, TRUE, FALSE); + ExitOnFailure(hr, "Failed to overwrite the bundle active parent built-in variable."); + } + if (pEngineState->internalCommand.sczSourceProcessPath) { hr = VariableSetString(&pEngineState->variables, BURN_BUNDLE_SOURCE_PROCESS_PATH, pEngineState->internalCommand.sczSourceProcessPath, TRUE, FALSE); @@ -172,7 +178,7 @@ extern "C" HRESULT CoreInitializeConstants( HRESULT hr = S_OK; BURN_REGISTRATION* pRegistration = &pEngineState->registration; - hr = DependencyInitialize(pRegistration, pEngineState->sczIgnoreDependencies); + hr = DependencyInitialize(&pEngineState->internalCommand, &pEngineState->dependencies, pRegistration); ExitOnFailure(hr, "Failed to initialize dependency data."); // Support passing Ancestors to embedded burn bundles. @@ -360,7 +366,7 @@ extern "C" HRESULT CoreDetect( } } - hr = DependencyDetect(pEngineState); + hr = DependencyDetect(&pEngineState->dependencies, &pEngineState->packages, &pEngineState->registration); ExitOnFailure(hr, "Failed to detect the dependencies."); // Log the detected states. @@ -453,6 +459,7 @@ extern "C" HRESULT CorePlan( // we make everywhere. pEngineState->plan.action = action; pEngineState->plan.pCache = &pEngineState->cache; + pEngineState->plan.pInternalCommand = &pEngineState->internalCommand; pEngineState->plan.pPayloads = &pEngineState->payloads; pEngineState->plan.wzBundleId = pEngineState->registration.sczId; pEngineState->plan.wzBundleProviderKey = pEngineState->registration.sczId; @@ -463,10 +470,10 @@ extern "C" HRESULT CorePlan( ExitOnFailure(hr, "Failed to update action."); // Set resume commandline - hr = PlanSetResumeCommand(&pEngineState->registration, action, &pEngineState->command, &pEngineState->log); + hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->command, &pEngineState->log); ExitOnFailure(hr, "Failed to set resume command"); - hr = DependencyPlanInitialize(&pEngineState->registration, &pEngineState->plan); + hr = DependencyPlanInitialize(&pEngineState->dependencies, &pEngineState->plan); ExitOnFailure(hr, "Failed to initialize the dependencies for the plan."); if (BOOTSTRAPPER_ACTION_LAYOUT == action) @@ -508,7 +515,7 @@ extern "C" HRESULT CorePlan( { pEngineState->plan.fPerMachine = pEngineState->registration.fPerMachine; // default the scope of the plan to the per-machine state of the bundle. - hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning); + hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, &pEngineState->dependencies, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning); ExitOnFailure(hr, "Failed to plan registration."); if (fContinuePlanning) @@ -921,10 +928,10 @@ extern "C" LPCWSTR CoreRelationTypeToCommandLineString( extern "C" HRESULT CoreRecreateCommandLine( __deref_inout_z LPWSTR* psczCommandLine, __in BOOTSTRAPPER_ACTION action, - __in BOOTSTRAPPER_DISPLAY display, + __in BURN_ENGINE_COMMAND* pInternalCommand, + __in BOOTSTRAPPER_COMMAND* pCommand, __in BOOTSTRAPPER_RELATION_TYPE relationType, __in BOOL fPassthrough, - __in_z_opt LPCWSTR wzActiveParent, __in_z_opt LPCWSTR wzAncestors, __in_z_opt LPCWSTR wzAppendLogPath, __in_z_opt LPCWSTR wzAdditionalCommandLineArguments @@ -937,7 +944,7 @@ extern "C" HRESULT CoreRecreateCommandLine( hr = StrAllocString(psczCommandLine, L"", 0); ExitOnFailure(hr, "Failed to empty command line."); - switch (display) + switch (pCommand->display) { case BOOTSTRAPPER_DISPLAY_NONE: hr = StrAllocConcat(psczCommandLine, L" /quiet", 0); @@ -962,11 +969,11 @@ extern "C" HRESULT CoreRecreateCommandLine( } ExitOnFailure(hr, "Failed to append action state to command-line"); - if (wzActiveParent) + if (pInternalCommand->sczActiveParent) { - if (*wzActiveParent) + if (*pInternalCommand->sczActiveParent) { - hr = StrAllocFormatted(&scz, L" /%ls \"%ls\"", BURN_COMMANDLINE_SWITCH_PARENT, wzActiveParent); + hr = StrAllocFormatted(&scz, L" /%ls \"%ls\"", BURN_COMMANDLINE_SWITCH_PARENT, pInternalCommand->sczActiveParent); ExitOnFailure(hr, "Failed to format active parent command-line for command-line."); } else diff --git a/src/burn/engine/core.h b/src/burn/engine/core.h index 9bb06147..9a6305d3 100644 --- a/src/burn/engine/core.h +++ b/src/burn/engine/core.h @@ -81,6 +81,10 @@ enum BURN_AU_PAUSE_ACTION typedef struct _BURN_ENGINE_COMMAND { BOOL fInitiallyElevated; + + LPWSTR sczActiveParent; + LPWSTR sczIgnoreDependencies; + LPWSTR sczSourceProcessPath; LPWSTR sczOriginalSource; } BURN_ENGINE_COMMAND; @@ -111,6 +115,7 @@ typedef struct _BURN_ENGINE_STATE BURN_UPDATE update; BURN_APPROVED_EXES approvedExes; BURN_CACHE cache; + BURN_DEPENDENCIES dependencies; BURN_EXTENSIONS extensions; HWND hMessageWindow; @@ -138,8 +143,6 @@ typedef struct _BURN_ENGINE_STATE BURN_RESUME_MODE resumeMode; BOOL fDisableUnelevate; - LPWSTR sczIgnoreDependencies; - int argc; LPWSTR* argv; BOOL fInvalidCommandLine; @@ -211,10 +214,10 @@ LPCWSTR CoreRelationTypeToCommandLineString( HRESULT CoreRecreateCommandLine( __deref_inout_z LPWSTR* psczCommandLine, __in BOOTSTRAPPER_ACTION action, - __in BOOTSTRAPPER_DISPLAY display, + __in BURN_ENGINE_COMMAND* pInternalCommand, + __in BOOTSTRAPPER_COMMAND* pCommand, __in BOOTSTRAPPER_RELATION_TYPE relationType, __in BOOL fPassthrough, - __in_z_opt LPCWSTR wzActiveParent, __in_z_opt LPCWSTR wzAncestors, __in_z_opt LPCWSTR wzAppendLogPath, __in_z_opt LPCWSTR wzAdditionalCommandLineArguments diff --git a/src/burn/engine/dependency.cpp b/src/burn/engine/dependency.cpp index 876cd8b3..f6cfe2c6 100644 --- a/src/burn/engine/dependency.cpp +++ b/src/burn/engine/dependency.cpp @@ -171,38 +171,58 @@ LExit: } extern "C" HRESULT DependencyInitialize( - __in BURN_REGISTRATION* pRegistration, - __in_z_opt LPCWSTR wzIgnoreDependencies + __in BURN_ENGINE_COMMAND* pInternalCommand, + __in BURN_DEPENDENCIES* pDependencies, + __in BURN_REGISTRATION* pRegistration ) { + AssertSz(!pDependencies->cIgnoredDependencies, "Dependencies already initalized."); + HRESULT hr = S_OK; // If no parent was specified at all, use the bundle id as the self dependent. - if (!pRegistration->sczActiveParent) + if (!pInternalCommand->sczActiveParent) { - pRegistration->wzSelfDependent = pRegistration->sczId; + pDependencies->wzSelfDependent = pRegistration->sczId; } - else if (*pRegistration->sczActiveParent) // if parent was specified use that as the self dependent. + else if (*pInternalCommand->sczActiveParent) // if parent was specified use that as the self dependent. { - pRegistration->wzSelfDependent = pRegistration->sczActiveParent; + pDependencies->wzSelfDependent = pInternalCommand->sczActiveParent; } // else parent:none was used which means we should not register a dependency on ourself. + pDependencies->wzActiveParent = pInternalCommand->sczActiveParent; + // The current bundle provider key should always be ignored for dependency checks. - hr = DepDependencyArrayAlloc(&pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, pRegistration->sczProviderKey, NULL); + hr = DepDependencyArrayAlloc(&pDependencies->rgIgnoredDependencies, &pDependencies->cIgnoredDependencies, pRegistration->sczProviderKey, NULL); ExitOnFailure(hr, "Failed to add the bundle provider key to the list of dependencies to ignore."); // Add the list of dependencies to ignore. - if (wzIgnoreDependencies) + if (pInternalCommand->sczIgnoreDependencies) { - hr = SplitIgnoreDependencies(wzIgnoreDependencies, &pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, &pRegistration->fIgnoreAllDependents); + hr = SplitIgnoreDependencies(pInternalCommand->sczIgnoreDependencies, &pDependencies->rgIgnoredDependencies, &pDependencies->cIgnoredDependencies, &pDependencies->fIgnoreAllDependents); ExitOnFailure(hr, "Failed to split the list of dependencies to ignore."); } + pDependencies->fSelfDependent = NULL != pDependencies->wzSelfDependent; + pDependencies->fActiveParent = NULL != pInternalCommand->sczActiveParent && NULL != *pInternalCommand->sczActiveParent; + LExit: return hr; } +extern "C" void DependencyUninitialize( + __in BURN_DEPENDENCIES* pDependencies + ) +{ + if (pDependencies->rgIgnoredDependencies) + { + ReleaseDependencyArray(pDependencies->rgIgnoredDependencies, pDependencies->cIgnoredDependencies); + } + + memset(pDependencies, 0, sizeof(BURN_DEPENDENCIES)); +} + extern "C" HRESULT DependencyDetectProviderKeyBundleId( __in BURN_REGISTRATION* pRegistration ) @@ -228,15 +248,14 @@ LExit: } extern "C" HRESULT DependencyDetect( - __in BURN_ENGINE_STATE* pEngineState + __in BURN_DEPENDENCIES* pDependencies, + __in BURN_PACKAGES* pPackages, + __in BURN_REGISTRATION* pRegistration ) { HRESULT hr = S_OK; - BURN_REGISTRATION* pRegistration = &pEngineState->registration; STRINGDICT_HANDLE sdIgnoredDependents = NULL; BURN_PACKAGE* pPackage = NULL; - BOOL fSelfDependent = NULL != pRegistration->wzSelfDependent; - BOOL fActiveParent = NULL != pRegistration->sczActiveParent && NULL != *pRegistration->sczActiveParent; // Always leave this empty so that all dependents get detected. Plan will ignore dependents based on its own logic. hr = DictCreateStringList(&sdIgnoredDependents, INITIAL_STRINGDICT_SIZE, DICT_FLAG_CASEINSENSITIVE); @@ -252,16 +271,16 @@ extern "C" HRESULT DependencyDetect( hr = S_OK; } - for (DWORD iPackage = 0; iPackage < pEngineState->packages.cPackages; ++iPackage) + for (DWORD iPackage = 0; iPackage < pPackages->cPackages; ++iPackage) { - pPackage = pEngineState->packages.rgPackages + iPackage; + pPackage = pPackages->rgPackages + iPackage; hr = DetectPackageDependents(pPackage, sdIgnoredDependents, pRegistration); ExitOnFailure(hr, "Failed to detect dependents for package '%ls'", pPackage->sczId); } - for (DWORD iRelatedBundle = 0; iRelatedBundle < pEngineState->registration.relatedBundles.cRelatedBundles; ++iRelatedBundle) + for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) { - BURN_RELATED_BUNDLE* pRelatedBundle = pEngineState->registration.relatedBundles.rgRelatedBundles + iRelatedBundle; + BURN_RELATED_BUNDLE* pRelatedBundle = pRegistration->relatedBundles.rgRelatedBundles + iRelatedBundle; if (!pRelatedBundle->fPlannable) { continue; @@ -272,18 +291,18 @@ extern "C" HRESULT DependencyDetect( ExitOnFailure(hr, "Failed to detect dependents for related bundle '%ls'", pPackage->sczId); } - if (fSelfDependent || fActiveParent) + if (pDependencies->fSelfDependent || pDependencies->fActiveParent) { for (DWORD i = 0; i < pRegistration->cDependents; ++i) { DEPENDENCY* pDependent = pRegistration->rgDependents + i; - if (fActiveParent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczActiveParent, -1, pDependent->sczKey, -1)) + if (pDependencies->fActiveParent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pDependencies->wzActiveParent, -1, pDependent->sczKey, -1)) { pRegistration->fParentRegisteredAsDependent = TRUE; } - if (fSelfDependent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->wzSelfDependent, -1, pDependent->sczKey, -1)) + if (pDependencies->fSelfDependent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pDependencies->wzSelfDependent, -1, pDependent->sczKey, -1)) { pRegistration->fSelfRegisteredAsDependent = TRUE; } @@ -297,16 +316,16 @@ LExit: } extern "C" HRESULT DependencyPlanInitialize( - __in const BURN_REGISTRATION* pRegistration, + __in BURN_DEPENDENCIES* pDependencies, __in BURN_PLAN* pPlan ) { HRESULT hr = S_OK; // TODO: After adding enumeration to STRINGDICT, a single STRINGDICT_HANDLE can be used everywhere. - for (DWORD i = 0; i < pRegistration->cIgnoredDependencies; ++i) + for (DWORD i = 0; i < pDependencies->cIgnoredDependencies; ++i) { - DEPENDENCY* pDependency = pRegistration->rgIgnoredDependencies + i; + DEPENDENCY* pDependency = pDependencies->rgIgnoredDependencies + i; hr = DepDependencyArrayAlloc(&pPlan->rgPlannedProviders, &pPlan->cPlannedProviders, pDependency->sczKey, pDependency->sczName); ExitOnFailure(hr, "Failed to add the detected provider to the list of dependencies to ignore."); @@ -952,6 +971,7 @@ static HRESULT GetIgnoredDependents( { ExitOnFailure(hr, "Failed to get the package property: %ls", DEPENDENCY_IGNOREDEPENDENCIES); + // TODO: this is the raw value of the property, all property values are currently formatted in a different part of planning. hr = DependencyAddIgnoreDependencies(*psdIgnoredDependents, sczIgnoreDependencies); ExitOnFailure(hr, "Failed to add the authored ignored dependencies to the cumulative list of ignored dependencies."); } diff --git a/src/burn/engine/dependency.h b/src/burn/engine/dependency.h index 06a01a20..3dacaf99 100644 --- a/src/burn/engine/dependency.h +++ b/src/burn/engine/dependency.h @@ -11,6 +11,18 @@ extern "C" { const LPCWSTR DEPENDENCY_IGNOREDEPENDENCIES = L"IGNOREDEPENDENCIES"; +typedef struct _BURN_DEPENDENCIES +{ + DEPENDENCY* rgIgnoredDependencies; + UINT cIgnoredDependencies; + LPCWSTR wzActiveParent; + LPCWSTR wzSelfDependent; + BOOL fIgnoreAllDependents; + BOOL fSelfDependent; + BOOL fActiveParent; +} BURN_DEPENDENCIES; + + // function declarations /******************************************************************** @@ -33,8 +45,13 @@ HRESULT DependencyParseProvidersFromXml( ); HRESULT DependencyInitialize( - __in BURN_REGISTRATION* pRegistration, - __in_z_opt LPCWSTR wzIgnoreDependencies + __in BURN_ENGINE_COMMAND* pInternalCommand, + __in BURN_DEPENDENCIES* pDependencies, + __in BURN_REGISTRATION* pRegistration + ); + +void DependencyUninitialize( + __in BURN_DEPENDENCIES* pDependencies ); /******************************************************************** @@ -52,7 +69,9 @@ HRESULT DependencyDetectProviderKeyBundleId( *********************************************************************/ HRESULT DependencyDetect( - __in BURN_ENGINE_STATE* pEngineState + __in BURN_DEPENDENCIES* pDependencies, + __in BURN_PACKAGES* pPackages, + __in BURN_REGISTRATION* pRegistration ); /******************************************************************** @@ -60,7 +79,7 @@ HRESULT DependencyDetect( *********************************************************************/ HRESULT DependencyPlanInitialize( - __in const BURN_REGISTRATION* pRegistration, + __in BURN_DEPENDENCIES* pDependencies, __in BURN_PLAN* pPlan ); diff --git a/src/burn/engine/detect.cpp b/src/burn/engine/detect.cpp index dc35e747..5f68a240 100644 --- a/src/burn/engine/detect.cpp +++ b/src/burn/engine/detect.cpp @@ -44,13 +44,6 @@ extern "C" void DetectReset( pRegistration->fForwardCompatibleBundleExists = FALSE; pRegistration->fEligibleForCleanup = FALSE; - if (pRegistration->rgIgnoredDependencies) - { - ReleaseDependencyArray(pRegistration->rgIgnoredDependencies, pRegistration->cIgnoredDependencies); - } - pRegistration->rgIgnoredDependencies = NULL; - pRegistration->cIgnoredDependencies = 0; - if (pRegistration->rgDependents) { ReleaseDependencyArray(pRegistration->rgDependents, pRegistration->cDependents); diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp index 0c2c8dc5..66eee27e 100644 --- a/src/burn/engine/engine.cpp +++ b/src/burn/engine/engine.cpp @@ -338,7 +338,7 @@ static HRESULT InitializeEngineState( ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated); // Parse command line. - 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); + 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); ExitOnFailure(hr, "Fatal error while parsing command line."); hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile); @@ -362,8 +362,6 @@ static void UninitializeEngineState( ReleaseMem(pEngineState->rgUnknownArgs); - ReleaseStr(pEngineState->sczIgnoreDependencies); - PipeConnectionUninitialize(&pEngineState->embeddedConnection); PipeConnectionUninitialize(&pEngineState->companionConnection); ReleaseStr(pEngineState->sczBundleEngineWorkingPath) @@ -376,6 +374,7 @@ static void UninitializeEngineState( UserExperienceUninitialize(&pEngineState->userExperience); ApprovedExesUninitialize(&pEngineState->approvedExes); + DependencyUninitialize(&pEngineState->dependencies); UpdateUninitialize(&pEngineState->update); VariablesUninitialize(&pEngineState->variables); SearchesUninitialize(&pEngineState->searches); @@ -390,6 +389,8 @@ static void UninitializeEngineState( ReleaseStr(pEngineState->command.wzLayoutDirectory); ReleaseStr(pEngineState->command.wzCommandLine); + ReleaseStr(pEngineState->internalCommand.sczActiveParent); + ReleaseStr(pEngineState->internalCommand.sczIgnoreDependencies); ReleaseStr(pEngineState->internalCommand.sczOriginalSource); ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath); diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index a5f75bd4..60497640 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp @@ -295,7 +295,7 @@ HRESULT ExternalEngineSetUpdate( { UpdateUninitialize(&pEngineState->update); - hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, pEngineState->command.display, BOOTSTRAPPER_RELATION_NONE, FALSE, pEngineState->registration.sczActiveParent, pEngineState->registration.sczAncestors, NULL, pEngineState->command.wzCommandLine); + hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, &pEngineState->internalCommand, &pEngineState->command, BOOTSTRAPPER_RELATION_NONE, FALSE, pEngineState->registration.sczAncestors, NULL, pEngineState->command.wzCommandLine); ExitOnFailure(hr, "Failed to recreate command-line for update bundle."); // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths. diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp index 79b7c98f..8c5b7051 100644 --- a/src/burn/engine/plan.cpp +++ b/src/burn/engine/plan.cpp @@ -444,7 +444,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles( } // Only change the recommendation if an active parent was provided. - if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent) + if (pPlan->pInternalCommand->sczActiveParent && *pPlan->pInternalCommand->sczActiveParent) { // On install, recommend running the forward compatible bundle because there is an active parent. This // will essentially register the parent with the forward compatible bundle. @@ -480,7 +480,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles( if (!fIgnoreBundle) { - hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pCommand, NULL, pRegistration->sczActiveParent, pRegistration->sczAncestors, &pRelatedBundle->package); + hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pPlan->pInternalCommand, pCommand, NULL, pRegistration->sczAncestors, &pRelatedBundle->package); ExitOnFailure(hr, "Failed to initialize pass through bundle."); pPlan->fEnabledForwardCompatibleBundle = TRUE; @@ -512,6 +512,7 @@ extern "C" HRESULT PlanPackages( extern "C" HRESULT PlanRegistration( __in BURN_PLAN* pPlan, __in BURN_REGISTRATION* pRegistration, + __in BURN_DEPENDENCIES* pDependencies, __in BOOTSTRAPPER_RESUME_TYPE /*resumeType*/, __in BOOTSTRAPPER_RELATION_TYPE relationType, __inout BOOL* pfContinuePlanning @@ -523,7 +524,7 @@ extern "C" HRESULT PlanRegistration( pPlan->fCanAffectMachineState = TRUE; // register the bundle since we're modifying machine state. pPlan->fDisallowRemoval = FALSE; // by default the bundle can be planned to be removed - pPlan->fIgnoreAllDependents = pRegistration->fIgnoreAllDependents; + pPlan->fIgnoreAllDependents = pDependencies->fIgnoreAllDependents; // Ensure the bundle is cached if not running from the cache. if (!CacheBundleRunningFromCache(pPlan->pCache)) @@ -560,10 +561,10 @@ extern "C" HRESULT PlanRegistration( // would prevent self-removal. if (pRegistration->fSelfRegisteredAsDependent) { - hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_UNREGISTER, pRegistration->wzSelfDependent, pRegistration->sczId); + hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_UNREGISTER, pDependencies->wzSelfDependent, pRegistration->sczId); ExitOnFailure(hr, "Failed to allocate registration action."); - hr = DependencyAddIgnoreDependencies(sdIgnoreDependents, pRegistration->wzSelfDependent); + hr = DependencyAddIgnoreDependencies(sdIgnoreDependents, pDependencies->wzSelfDependent); ExitOnFailure(hr, "Failed to add self-dependent to ignore dependents."); } @@ -575,9 +576,9 @@ extern "C" HRESULT PlanRegistration( if (BOOTSTRAPPER_RELATION_UPGRADE != relationType) { // If there were other dependencies to ignore, add them. - for (DWORD iDependency = 0; iDependency < pRegistration->cIgnoredDependencies; ++iDependency) + for (DWORD iDependency = 0; iDependency < pDependencies->cIgnoredDependencies; ++iDependency) { - DEPENDENCY* pDependency = pRegistration->rgIgnoredDependencies + iDependency; + DEPENDENCY* pDependency = pDependencies->rgIgnoredDependencies + iDependency; hr = DictKeyExists(sdIgnoreDependents, pDependency->sczKey); if (E_NOTFOUND != hr) @@ -689,9 +690,9 @@ extern "C" HRESULT PlanRegistration( // Only do the following if we decided there was a dependent self to register. If so and and an explicit parent was // provided, register dependent self. Otherwise, if this bundle is not an addon or patch bundle then self-regisiter // as our own dependent. - if (pRegistration->wzSelfDependent && !pRegistration->fSelfRegisteredAsDependent && (pRegistration->sczActiveParent || !fAddonOrPatchBundle)) + if (pDependencies->wzSelfDependent && !pRegistration->fSelfRegisteredAsDependent && (pDependencies->wzActiveParent || !fAddonOrPatchBundle)) { - hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_REGISTER, pRegistration->wzSelfDependent, pRegistration->sczId); + hr = AddRegistrationAction(pPlan, BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_REGISTER, pDependencies->wzSelfDependent, pRegistration->sczId); ExitOnFailure(hr, "Failed to add registration action for self dependent."); } } @@ -1774,8 +1775,8 @@ LExit: *******************************************************************/ extern "C" HRESULT PlanSetResumeCommand( + __in BURN_PLAN* pPlan, __in BURN_REGISTRATION* pRegistration, - __in BOOTSTRAPPER_ACTION action, __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_LOGGING* pLog ) @@ -1783,7 +1784,7 @@ extern "C" HRESULT PlanSetResumeCommand( HRESULT hr = S_OK; // build the resume command-line. - hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, action, pCommand->display, pCommand->relationType, pCommand->fPassthrough, pRegistration->sczActiveParent, pRegistration->sczAncestors, pLog->sczPath, pCommand->wzCommandLine); + hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, pPlan->action, pPlan->pInternalCommand, pCommand, pCommand->relationType, pCommand->fPassthrough, pRegistration->sczAncestors, pLog->sczPath, pCommand->wzCommandLine); ExitOnFailure(hr, "Failed to recreate resume command-line."); LExit: diff --git a/src/burn/engine/plan.h b/src/burn/engine/plan.h index 28fc1639..00a5bf0d 100644 --- a/src/burn/engine/plan.h +++ b/src/burn/engine/plan.h @@ -230,6 +230,7 @@ typedef struct _BURN_PLAN { BOOTSTRAPPER_ACTION action; BURN_CACHE* pCache; + BURN_ENGINE_COMMAND* pInternalCommand; BURN_PAYLOADS* pPayloads; LPWSTR wzBundleId; // points directly into parent the ENGINE_STATE. LPWSTR wzBundleProviderKey; // points directly into parent the ENGINE_STATE. @@ -342,6 +343,7 @@ HRESULT PlanPackages( HRESULT PlanRegistration( __in BURN_PLAN* pPlan, __in BURN_REGISTRATION* pRegistration, + __in BURN_DEPENDENCIES* pDependencies, __in BOOTSTRAPPER_RESUME_TYPE resumeType, __in BOOTSTRAPPER_RELATION_TYPE relationType, __inout BOOL* pfContinuePlanning @@ -442,8 +444,8 @@ HRESULT PlanRollbackBoundaryComplete( __in BURN_PLAN* pPlan ); HRESULT PlanSetResumeCommand( + __in BURN_PLAN* pPlan, __in BURN_REGISTRATION* pRegistration, - __in BOOTSTRAPPER_ACTION action, __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_LOGGING* pLog ); diff --git a/src/burn/engine/precomp.h b/src/burn/engine/precomp.h index 647a3b33..f76bb198 100644 --- a/src/burn/engine/precomp.h +++ b/src/burn/engine/precomp.h @@ -83,13 +83,13 @@ #include "logging.h" #include "pipe.h" #include "cache.h" +#include "dependency.h" #include "core.h" #include "apply.h" #include "exeengine.h" #include "msiengine.h" #include "mspengine.h" #include "msuengine.h" -#include "dependency.h" #include "elevation.h" #include "embedded.h" #include "manifest.h" diff --git a/src/burn/engine/pseudobundle.cpp b/src/burn/engine/pseudobundle.cpp index 351fe044..df3edef6 100644 --- a/src/burn/engine/pseudobundle.cpp +++ b/src/burn/engine/pseudobundle.cpp @@ -163,9 +163,9 @@ LExit: extern "C" HRESULT PseudoBundleInitializePassthrough( __in BURN_PACKAGE* pPassthroughPackage, + __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in_z_opt LPCWSTR wzAppendLogPath, - __in_z_opt LPCWSTR wzActiveParent, __in_z_opt LPCWSTR wzAncestors, __in BURN_PACKAGE* pPackage ) @@ -205,7 +205,7 @@ extern "C" HRESULT PseudoBundleInitializePassthrough( // No matter the operation, we're passing the same command-line. That's what makes // this a passthrough bundle. - hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pCommand->display, pCommand->relationType, TRUE, wzActiveParent, wzAncestors, wzAppendLogPath, pCommand->wzCommandLine); + hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pInternalCommand, pCommand, pCommand->relationType, TRUE, wzAncestors, wzAppendLogPath, pCommand->wzCommandLine); ExitOnFailure(hr, "Failed to recreate command-line arguments."); hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0); diff --git a/src/burn/engine/pseudobundle.h b/src/burn/engine/pseudobundle.h index 9fb530aa..75ad08d2 100644 --- a/src/burn/engine/pseudobundle.h +++ b/src/burn/engine/pseudobundle.h @@ -28,9 +28,9 @@ HRESULT PseudoBundleInitialize( ); HRESULT PseudoBundleInitializePassthrough( __in BURN_PACKAGE* pPassthroughPackage, + __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in_z_opt LPCWSTR wzAppendLogPath, - __in_z_opt LPCWSTR wzActiveParent, __in_z_opt LPCWSTR wzAncestors, __in BURN_PACKAGE* pPackage ); diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index d1c32b3e..51e75b78 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp @@ -385,7 +385,6 @@ extern "C" void RegistrationUninitialize( ReleaseMem(pRegistration->rgsczPatchCodes); ReleaseStr(pRegistration->sczProviderKey); - ReleaseStr(pRegistration->sczActiveParent); ReleaseStr(pRegistration->sczExecutableName); ReleaseStr(pRegistration->sczRegistrationKey); @@ -462,12 +461,6 @@ extern "C" HRESULT RegistrationSetVariables( hr = GetBundleManufacturer(pRegistration, pVariables, &scz); ExitOnFailure(hr, "Failed to initialize bundle manufacturer."); - if (pRegistration->sczActiveParent && *pRegistration->sczActiveParent) - { - hr = VariableSetString(pVariables, BURN_BUNDLE_ACTIVE_PARENT, pRegistration->sczActiveParent, TRUE, FALSE); - ExitOnFailure(hr, "Failed to overwrite the bundle active parent built-in variable."); - } - hr = VariableSetString(pVariables, BURN_BUNDLE_PROVIDER_KEY, pRegistration->sczProviderKey, TRUE, FALSE); ExitOnFailure(hr, "Failed to overwrite the bundle provider key built-in variable."); diff --git a/src/burn/engine/registration.h b/src/burn/engine/registration.h index aa5bf842..4da792d3 100644 --- a/src/burn/engine/registration.h +++ b/src/burn/engine/registration.h @@ -110,7 +110,6 @@ typedef struct _BURN_REGISTRATION DWORD cPatchCodes; VERUTIL_VERSION* pVersion; - LPWSTR sczActiveParent; LPWSTR sczProviderKey; LPWSTR sczExecutableName; @@ -145,12 +144,8 @@ typedef struct _BURN_REGISTRATION BURN_UPDATE_REGISTRATION update; BURN_RELATED_BUNDLES relatedBundles; // Only valid after detect. - DEPENDENCY* rgIgnoredDependencies; // Only valid after detect. - UINT cIgnoredDependencies; // Only valid after detect. DEPENDENCY* rgDependents; // Only valid after detect. UINT cDependents; // Only valid after detect. - BOOL fIgnoreAllDependents; // Only valid after detect. - LPCWSTR wzSelfDependent; // Only valid after detect. BOOL fSelfRegisteredAsDependent; // Only valid after detect. BOOL fParentRegisteredAsDependent; // Only valid after detect. BOOL fForwardCompatibleBundleExists; // Only valid after detect. diff --git a/src/burn/test/BurnUnitTest/PlanTest.cpp b/src/burn/test/BurnUnitTest/PlanTest.cpp index 2e3b1092..c7f2037d 100644 --- a/src/burn/test/BurnUnitTest/PlanTest.cpp +++ b/src/burn/test/BurnUnitTest/PlanTest.cpp @@ -959,15 +959,9 @@ namespace Bootstrapper void PlanTestDetect(BURN_ENGINE_STATE* pEngineState) { - HRESULT hr = S_OK; - BURN_REGISTRATION* pRegistration = &pEngineState->registration; - - DetectReset(pRegistration, &pEngineState->packages); + DetectReset(&pEngineState->registration, &pEngineState->packages); PlanReset(&pEngineState->plan, &pEngineState->containers, &pEngineState->packages, &pEngineState->layoutPayloads); - hr = DepDependencyArrayAlloc(&pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, pRegistration->sczProviderKey, NULL); - NativeAssert::Succeeded(hr, "Failed to add the bundle provider key to the list of dependencies to ignore."); - pEngineState->userExperience.fEngineActive = TRUE; pEngineState->fDetected = TRUE; } diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp index 7c0dde5a..af52e893 100644 --- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp +++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp @@ -75,6 +75,7 @@ namespace Bootstrapper BURN_REGISTRATION registration = { }; BURN_LOGGING logging = { }; BURN_PACKAGES packages = { }; + BURN_PLAN plan = { }; BURN_CACHE cache = { }; BURN_ENGINE_COMMAND internalCommand = { }; 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 hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); - hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pInternalCommand = &internalCommand; + + hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -170,6 +174,7 @@ namespace Bootstrapper BURN_REGISTRATION registration = { }; BURN_LOGGING logging = { }; BURN_PACKAGES packages = { }; + BURN_PLAN plan = { }; BURN_CACHE cache = { }; BURN_ENGINE_COMMAND internalCommand = { }; 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 hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); - hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pInternalCommand = &internalCommand; + + hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -287,6 +295,7 @@ namespace Bootstrapper BURN_REGISTRATION registration = { }; BURN_LOGGING logging = { }; BURN_PACKAGES packages = { }; + BURN_PLAN plan = { }; BURN_CACHE cache = { }; BURN_ENGINE_COMMAND internalCommand = { }; 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 hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); - hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pInternalCommand = &internalCommand; + + hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -402,6 +414,7 @@ namespace Bootstrapper BURN_REGISTRATION registration = { }; BURN_LOGGING logging = { }; BURN_PACKAGES packages = { }; + BURN_PLAN plan = { }; BURN_CACHE cache = { }; BURN_ENGINE_COMMAND internalCommand = { }; 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 hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); - hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pInternalCommand = &internalCommand; + + hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -534,6 +550,7 @@ namespace Bootstrapper BURN_REGISTRATION registration = { }; BURN_LOGGING logging = { }; BURN_PACKAGES packages = { }; + BURN_PLAN plan = { }; BURN_CACHE cache = { }; BURN_ENGINE_COMMAND internalCommand = { }; BYTE* pbBuffer = NULL; @@ -583,7 +600,10 @@ namespace Bootstrapper hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); - hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pInternalCommand = &internalCommand; + + hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -668,6 +688,7 @@ namespace Bootstrapper BURN_REGISTRATION registration = { }; BURN_LOGGING logging = { }; BURN_PACKAGES packages = { }; + BURN_PLAN plan = { }; BURN_CACHE cache = { }; BURN_ENGINE_COMMAND internalCommand = { }; BOOTSTRAPPER_RESUME_TYPE resumeType = BOOTSTRAPPER_RESUME_TYPE_NONE; @@ -716,7 +737,10 @@ namespace Bootstrapper hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); - hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pInternalCommand = &internalCommand; + + hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); diff --git a/src/burn/test/BurnUnitTest/precomp.h b/src/burn/test/BurnUnitTest/precomp.h index a77dfe32..a31917b4 100644 --- a/src/burn/test/BurnUnitTest/precomp.h +++ b/src/burn/test/BurnUnitTest/precomp.h @@ -57,13 +57,13 @@ #include "pipe.h" #include "logging.h" #include "cache.h" +#include "dependency.h" #include "core.h" #include "apply.h" #include "exeengine.h" #include "msiengine.h" #include "mspengine.h" #include "msuengine.h" -#include "dependency.h" #include "elevation.h" #include "embedded.h" #include "manifest.h" -- cgit v1.2.3-55-g6feb