From 56c980318e7167be591f7807c2fc34cea7d5cb42 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 31 Jan 2022 15:44:00 -0600 Subject: The bundle provider's presence needs to follow ARP registration. --- src/burn/engine/apply.cpp | 41 +-- src/burn/engine/approvedexe.h | 2 + src/burn/engine/dependency.cpp | 5 + src/burn/engine/detect.cpp | 4 +- src/burn/engine/elevation.cpp | 18 +- src/burn/engine/elevation.h | 4 +- src/burn/engine/engine.mc | 7 + src/burn/engine/plan.cpp | 23 +- src/burn/engine/plan.h | 12 +- src/burn/engine/registration.cpp | 320 ++++++++++++------------ src/burn/engine/registration.h | 8 +- src/burn/test/BurnUnitTest/RegistrationTest.cpp | 42 ++-- 12 files changed, 233 insertions(+), 253 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp index 6bf3020c..9185e33a 100644 --- a/src/burn/engine/apply.cpp +++ b/src/burn/engine/apply.cpp @@ -432,12 +432,12 @@ extern "C" HRESULT ApplyRegister( // begin new session if (pEngineState->registration.fPerMachine) { - hr = ElevationSessionBegin(pEngineState->companionConnection.hPipe, sczEngineWorkingPath, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.dependencyRegistrationAction, pEngineState->plan.qwEstimatedSize, registrationType); + hr = ElevationSessionBegin(pEngineState->companionConnection.hPipe, sczEngineWorkingPath, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->registration.fDetectedForeignProviderKeyBundleId, pEngineState->plan.qwEstimatedSize, registrationType); ExitOnFailure(hr, "Failed to begin registration session in per-machine process."); } else { - hr = RegistrationSessionBegin(sczEngineWorkingPath, &pEngineState->registration, &pEngineState->cache, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.dependencyRegistrationAction, pEngineState->plan.qwEstimatedSize, registrationType); + hr = RegistrationSessionBegin(sczEngineWorkingPath, &pEngineState->registration, &pEngineState->cache, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.qwEstimatedSize, registrationType); ExitOnFailure(hr, "Failed to begin registration session."); } } @@ -521,12 +521,12 @@ extern "C" HRESULT ApplyUnregister( if (pEngineState->registration.fPerMachine) { - hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction, registrationType); + hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->registration.fDetectedForeignProviderKeyBundleId, registrationType); ExitOnFailure(hr, "Failed to end session in per-machine process."); } else { - hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->cache, &pEngineState->variables, &pEngineState->packages, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction, registrationType); + hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->cache, &pEngineState->variables, &pEngineState->packages, resumeMode, restart, registrationType); ExitOnFailure(hr, "Failed to end session in per-user process."); } @@ -2914,8 +2914,9 @@ static HRESULT ExecuteDependencyAction( ) { HRESULT hr = S_OK; + BURN_PACKAGE* pPackage = pAction->packageDependency.pPackage; - if (pAction->packageDependency.pPackage->fPerMachine) + if (pPackage->fPerMachine) { hr = ElevationExecutePackageDependencyAction(pEngineState->companionConnection.hPipe, pAction); ExitOnFailure(hr, "Failed to register the dependency on per-machine package."); @@ -2926,20 +2927,20 @@ static HRESULT ExecuteDependencyAction( ExitOnFailure(hr, "Failed to register the dependency on per-user package."); } - if (pAction->packageDependency.pPackage->fCanAffectRegistration) + if (pPackage->fCanAffectRegistration) { if (BURN_DEPENDENCY_ACTION_REGISTER == pAction->packageDependency.action) { - if (BURN_PACKAGE_REGISTRATION_STATE_IGNORED == pAction->packageDependency.pPackage->cacheRegistrationState) + if (BURN_PACKAGE_REGISTRATION_STATE_IGNORED == pPackage->cacheRegistrationState) { - pAction->packageDependency.pPackage->cacheRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_PRESENT; + pPackage->cacheRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_PRESENT; } - if (BURN_PACKAGE_TYPE_MSP == pAction->packageDependency.pPackage->type) + if (BURN_PACKAGE_TYPE_MSP == pPackage->type) { - for (DWORD i = 0; i < pAction->packageDependency.pPackage->Msp.cTargetProductCodes; ++i) + for (DWORD i = 0; i < pPackage->Msp.cTargetProductCodes; ++i) { - BURN_MSPTARGETPRODUCT* pTargetProduct = pAction->packageDependency.pPackage->Msp.rgTargetProducts + i; + BURN_MSPTARGETPRODUCT* pTargetProduct = pPackage->Msp.rgTargetProducts + i; if (BURN_PACKAGE_REGISTRATION_STATE_IGNORED == pTargetProduct->registrationState) { @@ -2947,23 +2948,23 @@ static HRESULT ExecuteDependencyAction( } } } - else if (BURN_PACKAGE_REGISTRATION_STATE_IGNORED == pAction->packageDependency.pPackage->installRegistrationState) + else if (BURN_PACKAGE_REGISTRATION_STATE_IGNORED == pPackage->installRegistrationState) { - pAction->packageDependency.pPackage->installRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_PRESENT; + pPackage->installRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_PRESENT; } } else if (BURN_DEPENDENCY_ACTION_UNREGISTER == pAction->packageDependency.action) { - if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pAction->packageDependency.pPackage->cacheRegistrationState) + if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState) { - pAction->packageDependency.pPackage->cacheRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_IGNORED; + pPackage->cacheRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_IGNORED; } - if (BURN_PACKAGE_TYPE_MSP == pAction->packageDependency.pPackage->type) + if (BURN_PACKAGE_TYPE_MSP == pPackage->type) { - for (DWORD i = 0; i < pAction->packageDependency.pPackage->Msp.cTargetProductCodes; ++i) + for (DWORD i = 0; i < pPackage->Msp.cTargetProductCodes; ++i) { - BURN_MSPTARGETPRODUCT* pTargetProduct = pAction->packageDependency.pPackage->Msp.rgTargetProducts + i; + BURN_MSPTARGETPRODUCT* pTargetProduct = pPackage->Msp.rgTargetProducts + i; if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pTargetProduct->registrationState) { @@ -2971,9 +2972,9 @@ static HRESULT ExecuteDependencyAction( } } } - else if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pAction->packageDependency.pPackage->installRegistrationState) + else if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->installRegistrationState) { - pAction->packageDependency.pPackage->installRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_IGNORED; + pPackage->installRegistrationState = BURN_PACKAGE_REGISTRATION_STATE_IGNORED; } } } diff --git a/src/burn/engine/approvedexe.h b/src/burn/engine/approvedexe.h index cd3bf271..8a3f6779 100644 --- a/src/burn/engine/approvedexe.h +++ b/src/burn/engine/approvedexe.h @@ -8,10 +8,12 @@ extern "C" { // forward declare +enum BURN_MODE; 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; +typedef struct _BURN_LOGGING BURN_LOGGING; // structs diff --git a/src/burn/engine/dependency.cpp b/src/burn/engine/dependency.cpp index 6ee95935..ce183a8a 100644 --- a/src/burn/engine/dependency.cpp +++ b/src/burn/engine/dependency.cpp @@ -246,6 +246,11 @@ extern "C" HRESULT DependencyDetectProviderKeyBundleId( hr = StrAllocString(&pRegistration->sczDetectedProviderKeyBundleId, pRegistration->sczProviderKey, 0); ExitOnFailure(hr, "Failed to initialize provider key bundle id."); } + else if (CSTR_EQUAL != ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczId, -1, pRegistration->sczDetectedProviderKeyBundleId, -1)) + { + pRegistration->fDetectedForeignProviderKeyBundleId = TRUE; + LogId(REPORT_STANDARD, MSG_DETECTED_FOREIGN_BUNDLE_PROVIDER_REGISTRATION, pRegistration->sczProviderKey, pRegistration->sczDetectedProviderKeyBundleId); + } LExit: return hr; diff --git a/src/burn/engine/detect.cpp b/src/burn/engine/detect.cpp index 37b034ae..617b418b 100644 --- a/src/burn/engine/detect.cpp +++ b/src/burn/engine/detect.cpp @@ -39,6 +39,7 @@ extern "C" void DetectReset( { RelatedBundlesUninitialize(&pRegistration->relatedBundles); ReleaseNullStr(pRegistration->sczDetectedProviderKeyBundleId); + pRegistration->fDetectedForeignProviderKeyBundleId = FALSE; pRegistration->fSelfRegisteredAsDependent = FALSE; pRegistration->fParentRegisteredAsDependent = FALSE; pRegistration->fForwardCompatibleBundleExists = FALSE; @@ -118,8 +119,7 @@ extern "C" HRESULT DetectForwardCompatibleBundles( HRESULT hr = S_OK; int nCompareResult = 0; - if (pRegistration->sczDetectedProviderKeyBundleId && - CSTR_EQUAL != ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczDetectedProviderKeyBundleId, -1, pRegistration->sczId, -1)) + if (pRegistration->fDetectedForeignProviderKeyBundleId) { for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) { diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp index 9ebba7c5..eafc08ee 100644 --- a/src/burn/engine/elevation.cpp +++ b/src/burn/engine/elevation.cpp @@ -525,7 +525,7 @@ extern "C" HRESULT ElevationSessionBegin( __in BOOL fDisableResume, __in BURN_VARIABLES* pVariables, __in DWORD dwRegistrationOperations, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, + __in BOOL fDetectedForeignProviderKeyBundleId, __in DWORD64 qwEstimatedSize, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ) @@ -548,7 +548,7 @@ extern "C" HRESULT ElevationSessionBegin( hr = BuffWriteNumber(&pbData, &cbData, dwRegistrationOperations); ExitOnFailure(hr, "Failed to write registration operations to message buffer."); - hr = BuffWriteNumber(&pbData, &cbData, (DWORD)dependencyRegistrationAction); + hr = BuffWriteNumber(&pbData, &cbData, (DWORD)fDetectedForeignProviderKeyBundleId); ExitOnFailure(hr, "Failed to write dependency registration action to message buffer."); hr = BuffWriteNumber64(&pbData, &cbData, qwEstimatedSize); @@ -622,7 +622,7 @@ extern "C" HRESULT ElevationSessionEnd( __in HANDLE hPipe, __in BURN_RESUME_MODE resumeMode, __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, + __in BOOL fDetectedForeignProviderKeyBundleId, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ) { @@ -638,7 +638,7 @@ extern "C" HRESULT ElevationSessionEnd( hr = BuffWriteNumber(&pbData, &cbData, (DWORD)restart); ExitOnFailure(hr, "Failed to write restart enum to message buffer."); - hr = BuffWriteNumber(&pbData, &cbData, (DWORD)dependencyRegistrationAction); + hr = BuffWriteNumber(&pbData, &cbData, (DWORD)fDetectedForeignProviderKeyBundleId); ExitOnFailure(hr, "Failed to write dependency registration action to message buffer."); hr = BuffWriteNumber(&pbData, &cbData, (DWORD)registrationType); @@ -2359,7 +2359,6 @@ static HRESULT OnSessionBegin( SIZE_T iData = 0; LPWSTR sczEngineWorkingPath = NULL; DWORD dwRegistrationOperations = 0; - DWORD dwDependencyRegistrationAction = 0; DWORD64 qwEstimatedSize = 0; DWORD dwRegistrationType = 0; @@ -2376,7 +2375,7 @@ static HRESULT OnSessionBegin( hr = BuffReadNumber(pbData, cbData, &iData, &dwRegistrationOperations); ExitOnFailure(hr, "Failed to read registration operations."); - hr = BuffReadNumber(pbData, cbData, &iData, &dwDependencyRegistrationAction); + hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&pRegistration->fDetectedForeignProviderKeyBundleId); ExitOnFailure(hr, "Failed to read dependency registration action."); hr = BuffReadNumber64(pbData, cbData, &iData, &qwEstimatedSize); @@ -2389,7 +2388,7 @@ static HRESULT OnSessionBegin( ExitOnFailure(hr, "Failed to read variables."); // Begin session in per-machine process. - hr = RegistrationSessionBegin(sczEngineWorkingPath, pRegistration, pCache, pVariables, dwRegistrationOperations, (BURN_DEPENDENCY_REGISTRATION_ACTION)dwDependencyRegistrationAction, qwEstimatedSize, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType); + hr = RegistrationSessionBegin(sczEngineWorkingPath, pRegistration, pCache, pVariables, dwRegistrationOperations, qwEstimatedSize, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType); ExitOnFailure(hr, "Failed to begin registration session."); LExit: @@ -2443,7 +2442,6 @@ static HRESULT OnSessionEnd( SIZE_T iData = 0; DWORD dwResumeMode = 0; DWORD dwRestart = 0; - DWORD dwDependencyRegistrationAction = 0; DWORD dwRegistrationType = 0; // Deserialize message data. @@ -2453,14 +2451,14 @@ static HRESULT OnSessionEnd( hr = BuffReadNumber(pbData, cbData, &iData, &dwRestart); ExitOnFailure(hr, "Failed to read restart enum."); - hr = BuffReadNumber(pbData, cbData, &iData, &dwDependencyRegistrationAction); + hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&pRegistration->fDetectedForeignProviderKeyBundleId); ExitOnFailure(hr, "Failed to read dependency registration action."); hr = BuffReadNumber(pbData, cbData, &iData, &dwRegistrationType); ExitOnFailure(hr, "Failed to read dependency registration action."); // suspend session in per-machine process - hr = RegistrationSessionEnd(pRegistration, pCache, pVariables, pPackages, (BURN_RESUME_MODE)dwResumeMode, (BOOTSTRAPPER_APPLY_RESTART)dwRestart, (BURN_DEPENDENCY_REGISTRATION_ACTION)dwDependencyRegistrationAction, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType); + hr = RegistrationSessionEnd(pRegistration, pCache, pVariables, pPackages, (BURN_RESUME_MODE)dwResumeMode, (BOOTSTRAPPER_APPLY_RESTART)dwRestart, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType); ExitOnFailure(hr, "Failed to suspend registration session."); LExit: diff --git a/src/burn/engine/elevation.h b/src/burn/engine/elevation.h index b4d0ca83..9659ef89 100644 --- a/src/burn/engine/elevation.h +++ b/src/burn/engine/elevation.h @@ -28,7 +28,7 @@ HRESULT ElevationSessionBegin( __in BOOL fDisableResume, __in BURN_VARIABLES* pVariables, __in DWORD dwRegistrationOperations, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, + __in BOOL fDetectedForeignProviderKeyBundleId, __in DWORD64 qwEstimatedSize, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ); @@ -43,7 +43,7 @@ HRESULT ElevationSessionEnd( __in HANDLE hPipe, __in BURN_RESUME_MODE resumeMode, __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, + __in BOOL fDetectedForeignProviderKeyBundleId, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ); HRESULT ElevationSaveState( diff --git a/src/burn/engine/engine.mc b/src/burn/engine/engine.mc index 6ce11564..b8c9a2d3 100644 --- a/src/burn/engine/engine.mc +++ b/src/burn/engine/engine.mc @@ -275,6 +275,13 @@ Language=English Detected related bundle missing from cache: %1!ls!, cache path: %2!ls! . +MessageId=110 +Severity=Success +SymbolicName=MSG_DETECTED_FOREIGN_BUNDLE_PROVIDER_REGISTRATION +Language=English +Detected bundle provider key: %1!ls! that is registered to a different bundle: %2!ls! +. + MessageId=120 Severity=Warning SymbolicName=MSG_DETECT_PACKAGE_NOT_FULLY_CACHED diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp index 2649ee39..a25b17d7 100644 --- a/src/burn/engine/plan.cpp +++ b/src/burn/engine/plan.cpp @@ -541,25 +541,14 @@ extern "C" HRESULT PlanRegistration( pPlan->dwRegistrationOperations |= BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE; } - // Always write registration since things may have changed or it just needs to be "fixed up". - pPlan->dwRegistrationOperations |= BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION; - - // Always update our estimated size registration when installing/modify/repair since things - // may have been added or removed or it just needs to be "fixed up". - pPlan->dwRegistrationOperations |= BURN_REGISTRATION_ACTION_OPERATIONS_UPDATE_SIZE; - if (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) { - // If our provider key was detected and it points to our current bundle then we can - // unregister the bundle dependency. - if (pRegistration->sczDetectedProviderKeyBundleId && - CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczId, -1, pRegistration->sczDetectedProviderKeyBundleId, -1)) + // If our provider key was not owned by a different bundle, + // then plan to write our provider key registration to "fix it" if broken + // in case the bundle isn't successfully uninstalled. + if (!pRegistration->fDetectedForeignProviderKeyBundleId) { - pPlan->dependencyRegistrationAction = BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER; - } - else // log that another bundle already owned our registration, hopefully this only happens when a newer version - { // of a bundle installed and is in the process of upgrading us. - LogId(REPORT_STANDARD, MSG_PLAN_SKIPPED_PROVIDER_KEY_REMOVAL, pRegistration->sczProviderKey, pRegistration->sczDetectedProviderKeyBundleId); + pPlan->dwRegistrationOperations |= BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY; } // Create the dictionary of dependents that should be ignored. @@ -651,7 +640,7 @@ extern "C" HRESULT PlanRegistration( // Always plan to write our provider key registration when installing/modify/repair to "fix it" // if broken. - pPlan->dependencyRegistrationAction = BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER; + pPlan->dwRegistrationOperations |= BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY; // Create the dictionary of bundle dependents. hr = DictCreateStringList(&sdBundleDependents, 5, DICT_FLAG_CASEINSENSITIVE); diff --git a/src/burn/engine/plan.h b/src/burn/engine/plan.h index 9bf72828..15092210 100644 --- a/src/burn/engine/plan.h +++ b/src/burn/engine/plan.h @@ -15,15 +15,7 @@ enum BURN_REGISTRATION_ACTION_OPERATIONS { BURN_REGISTRATION_ACTION_OPERATIONS_NONE = 0x0, BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE = 0x1, - BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION = 0x2, - BURN_REGISTRATION_ACTION_OPERATIONS_UPDATE_SIZE = 0x4, -}; - -enum BURN_DEPENDENCY_REGISTRATION_ACTION -{ - BURN_DEPENDENCY_REGISTRATION_ACTION_NONE, - BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, - BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, + BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY = 0x2, }; enum BURN_DEPENDENT_REGISTRATION_ACTION_TYPE @@ -272,8 +264,6 @@ typedef struct _BURN_PLAN BOOL fEnabledForwardCompatibleBundle; BURN_PACKAGE forwardCompatibleBundle; - BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction; - BURN_DEPENDENT_REGISTRATION_ACTION* rgRegistrationActions; DWORD cRegistrationActions; diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index c76dde53..59947867 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp @@ -605,7 +605,6 @@ extern "C" HRESULT RegistrationSessionBegin( __in BURN_CACHE* pCache, __in BURN_VARIABLES* pVariables, __in DWORD dwRegistrationOptions, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, __in DWORD64 qwEstimatedSize, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ) @@ -635,206 +634,199 @@ extern "C" HRESULT RegistrationSessionBegin( ExitOnFailure(hr, "Failed to create registration key."); // Write any ARP values and software tags. - if (dwRegistrationOptions & BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION) - { - // Upgrade information - hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH, pRegistration->sczCacheExecutablePath); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH); + hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH, pRegistration->sczCacheExecutablePath); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH); - hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE, pRegistration->rgsczUpgradeCodes, pRegistration->cUpgradeCodes); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE); + hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE, pRegistration->rgsczUpgradeCodes, pRegistration->cUpgradeCodes); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE); - hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_ADDON_CODE, pRegistration->rgsczAddonCodes, pRegistration->cAddonCodes); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_ADDON_CODE); + hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_ADDON_CODE, pRegistration->rgsczAddonCodes, pRegistration->cAddonCodes); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_ADDON_CODE); - hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_DETECT_CODE, pRegistration->rgsczDetectCodes, pRegistration->cDetectCodes); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_DETECT_CODE); + hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_DETECT_CODE, pRegistration->rgsczDetectCodes, pRegistration->cDetectCodes); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_DETECT_CODE); - hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_PATCH_CODE, pRegistration->rgsczPatchCodes, pRegistration->cPatchCodes); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_PATCH_CODE); + hr = RegWriteStringArray(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_PATCH_CODE, pRegistration->rgsczPatchCodes, pRegistration->cPatchCodes); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_PATCH_CODE); - hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION, pRegistration->pVersion->sczVersion); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION); + hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION, pRegistration->pVersion->sczVersion); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION); - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_VERSION_MAJOR, pRegistration->pVersion->dwMajor); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_VERSION_MAJOR); + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_VERSION_MAJOR, pRegistration->pVersion->dwMajor); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_VERSION_MAJOR); - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_VERSION_MINOR, pRegistration->pVersion->dwMinor); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_VERSION_MINOR); + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_VERSION_MINOR, pRegistration->pVersion->dwMinor); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_VERSION_MINOR); - if (pRegistration->sczProviderKey) - { - hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY, pRegistration->sczProviderKey); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY); - } + if (pRegistration->sczProviderKey) + { + hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY, pRegistration->sczProviderKey); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY); + } - if (pRegistration->sczTag) - { - hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_TAG, pRegistration->sczTag); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_TAG); - } + if (pRegistration->sczTag) + { + hr = RegWriteString(hkRegistration, BURN_REGISTRATION_REGISTRY_BUNDLE_TAG, pRegistration->sczTag); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_BUNDLE_TAG); + } - hr = RegWriteStringFormatted(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, L"%hs", szVerMajorMinorBuild); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_VERSION); + hr = RegWriteStringFormatted(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_VERSION, L"%hs", szVerMajorMinorBuild); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_VERSION); - hr = RegWriteNumber(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION, BURN_PROTOCOL_VERSION); - ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION); + hr = RegWriteNumber(hkRegistration, BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION, BURN_PROTOCOL_VERSION); + ExitOnFailure(hr, "Failed to write %ls value.", BURN_REGISTRATION_REGISTRY_ENGINE_PROTOCOL_VERSION); - // DisplayIcon: [path to exe] and ",0" to refer to the first icon in the executable. - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON); + // DisplayIcon: [path to exe] and ",0" to refer to the first icon in the executable. + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON); - // update display name - hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType); - ExitOnFailure(hr, "Failed to update name and publisher."); + // update display name + hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType); + ExitOnFailure(hr, "Failed to update name and publisher."); - // DisplayVersion: provided by UI - if (pRegistration->sczDisplayVersion) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_DISPLAY_VERSION, pRegistration->sczDisplayVersion); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_VERSION); - } + // DisplayVersion: provided by UI + if (pRegistration->sczDisplayVersion) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_DISPLAY_VERSION, pRegistration->sczDisplayVersion); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_VERSION); + } - // Publisher: provided by UI - hr = GetBundleManufacturer(pRegistration, pVariables, &sczPublisher); - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_PUBLISHER, SUCCEEDED(hr) ? sczPublisher : pRegistration->sczPublisher); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_PUBLISHER); + // Publisher: provided by UI + hr = GetBundleManufacturer(pRegistration, pVariables, &sczPublisher); + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_PUBLISHER, SUCCEEDED(hr) ? sczPublisher : pRegistration->sczPublisher); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_PUBLISHER); - // HelpLink: provided by UI - if (pRegistration->sczHelpLink) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_HELP_LINK, pRegistration->sczHelpLink); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_HELP_LINK); - } + // HelpLink: provided by UI + if (pRegistration->sczHelpLink) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_HELP_LINK, pRegistration->sczHelpLink); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_HELP_LINK); + } - // HelpTelephone: provided by UI - if (pRegistration->sczHelpTelephone) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_HELP_TELEPHONE, pRegistration->sczHelpTelephone); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_HELP_TELEPHONE); - } + // HelpTelephone: provided by UI + if (pRegistration->sczHelpTelephone) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_HELP_TELEPHONE, pRegistration->sczHelpTelephone); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_HELP_TELEPHONE); + } - // URLInfoAbout, provided by UI - if (pRegistration->sczAboutUrl) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_URL_INFO_ABOUT, pRegistration->sczAboutUrl); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_URL_INFO_ABOUT); - } + // URLInfoAbout, provided by UI + if (pRegistration->sczAboutUrl) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_URL_INFO_ABOUT, pRegistration->sczAboutUrl); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_URL_INFO_ABOUT); + } - // URLUpdateInfo, provided by UI - if (pRegistration->sczUpdateUrl) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_URL_UPDATE_INFO, pRegistration->sczUpdateUrl); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_URL_UPDATE_INFO); - } + // URLUpdateInfo, provided by UI + if (pRegistration->sczUpdateUrl) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_URL_UPDATE_INFO, pRegistration->sczUpdateUrl); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_URL_UPDATE_INFO); + } - // ParentDisplayName - if (pRegistration->sczParentDisplayName) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_PARENT_DISPLAY_NAME, pRegistration->sczParentDisplayName); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_PARENT_DISPLAY_NAME); + // ParentDisplayName + if (pRegistration->sczParentDisplayName) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_PARENT_DISPLAY_NAME, pRegistration->sczParentDisplayName); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_PARENT_DISPLAY_NAME); - // Need to write the ParentKeyName but can be set to anything. - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_PARENT_KEY_NAME, pRegistration->sczParentDisplayName); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_PARENT_KEY_NAME); - } + // Need to write the ParentKeyName but can be set to anything. + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_PARENT_KEY_NAME, pRegistration->sczParentDisplayName); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_PARENT_KEY_NAME); + } - // Comments, provided by UI - if (pRegistration->sczComments) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_COMMENTS, pRegistration->sczComments); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_COMMENTS); - } + // Comments, provided by UI + if (pRegistration->sczComments) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_COMMENTS, pRegistration->sczComments); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_COMMENTS); + } - // Contact, provided by UI - if (pRegistration->sczContact) - { - hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_CONTACT, pRegistration->sczContact); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_CONTACT); - } + // Contact, provided by UI + if (pRegistration->sczContact) + { + hr = RegWriteString(hkRegistration, REGISTRY_BUNDLE_CONTACT, pRegistration->sczContact); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_CONTACT); + } - // InstallLocation: provided by UI - // TODO: need to figure out what "InstallLocation" means in a chainer. + // InstallLocation: provided by UI + // TODO: need to figure out what "InstallLocation" means in a chainer. - // NoModify - if (BURN_REGISTRATION_MODIFY_DISABLE == pRegistration->modify) - { - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_MODIFY, 1); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_MODIFY); - } - else if (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON != pRegistration->modify) // if support modify (aka: did not disable anything) - { - // ModifyPath: [path to exe] /modify - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_MODIFY_PATH, L"\"%ls\" /%ls /modify", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_MODIFY_PATH); + // NoModify + if (BURN_REGISTRATION_MODIFY_DISABLE == pRegistration->modify) + { + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_MODIFY, 1); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_MODIFY); + } + else if (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON != pRegistration->modify) // if support modify (aka: did not disable anything) + { + // ModifyPath: [path to exe] /modify + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_MODIFY_PATH, L"\"%ls\" /%ls /modify", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_MODIFY_PATH); - // NoElevateOnModify: 1 - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_ELEVATE_ON_MODIFY, 1); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_ELEVATE_ON_MODIFY); - } + // NoElevateOnModify: 1 + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_ELEVATE_ON_MODIFY, 1); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_ELEVATE_ON_MODIFY); + } - // NoRemove: should this be allowed? - if (pRegistration->fNoRemoveDefined) - { - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_REMOVE, (DWORD)pRegistration->fNoRemove); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_REMOVE); - } + // NoRemove: should this be allowed? + if (pRegistration->fNoRemoveDefined) + { + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_REMOVE, (DWORD)pRegistration->fNoRemove); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_REMOVE); + } - // Conditionally hide the ARP entry. - if (!pRegistration->fRegisterArp) - { - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_SYSTEM_COMPONENT, 1); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_SYSTEM_COMPONENT); - } + // Conditionally hide the ARP entry. + if (!pRegistration->fRegisterArp) + { + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_SYSTEM_COMPONENT, 1); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_SYSTEM_COMPONENT); + } - // QuietUninstallString: [path to exe] /uninstall /quiet - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING, L"\"%ls\" /%ls /uninstall /quiet", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING); + // QuietUninstallString: [path to exe] /uninstall /quiet + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING, L"\"%ls\" /%ls /uninstall /quiet", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING); - // UninstallString, [path to exe] - // If the modify button is to be disabled, we'll add "/modify" to the uninstall string because the button is "Uninstall/Change". Otherwise, - // it's just the "Uninstall" button so we add "/uninstall" to make the program just go away. - LPCWSTR wzUninstallParameters = (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON == pRegistration->modify) ? L"/modify" : L" /uninstall"; - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_UNINSTALL_STRING, L"\"%ls\" /%ls %ls", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, wzUninstallParameters); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_UNINSTALL_STRING); + // UninstallString, [path to exe] + // If the modify button is to be disabled, we'll add "/modify" to the uninstall string because the button is "Uninstall/Change". Otherwise, + // it's just the "Uninstall" button so we add "/uninstall" to make the program just go away. + LPCWSTR wzUninstallParameters = (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON == pRegistration->modify) ? L"/modify" : L" /uninstall"; + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_UNINSTALL_STRING, L"\"%ls\" /%ls %ls", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, wzUninstallParameters); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_UNINSTALL_STRING); - if (pRegistration->softwareTags.cSoftwareTags) - { - hr = WriteSoftwareTags(pVariables, &pRegistration->softwareTags); - ExitOnFailure(hr, "Failed to write software tags."); - } + if (pRegistration->softwareTags.cSoftwareTags) + { + hr = WriteSoftwareTags(pVariables, &pRegistration->softwareTags); + ExitOnFailure(hr, "Failed to write software tags."); + } - // Update registration. - if (pRegistration->update.fRegisterUpdate) - { - hr = WriteUpdateRegistration(pRegistration, pVariables); - ExitOnFailure(hr, "Failed to write update registration."); - } + // Update registration. + if (pRegistration->update.fRegisterUpdate) + { + hr = WriteUpdateRegistration(pRegistration, pVariables); + ExitOnFailure(hr, "Failed to write update registration."); } // Update estimated size. - if (dwRegistrationOptions & BURN_REGISTRATION_ACTION_OPERATIONS_UPDATE_SIZE) + qwEstimatedSize /= 1024; // Convert bytes to KB + if (0 < qwEstimatedSize) { - qwEstimatedSize /= 1024; // Convert bytes to KB - if (0 < qwEstimatedSize) + if (DWORD_MAX < qwEstimatedSize) { - if (DWORD_MAX < qwEstimatedSize) - { - // ARP doesn't support QWORDs here - dwSize = DWORD_MAX; - } - else - { - dwSize = static_cast(qwEstimatedSize); - } - - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_ESTIMATED_SIZE, dwSize); - ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_ESTIMATED_SIZE); + // ARP doesn't support QWORDs here + dwSize = DWORD_MAX; } + else + { + dwSize = static_cast(qwEstimatedSize); + } + + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_ESTIMATED_SIZE, dwSize); + ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_ESTIMATED_SIZE); } // Register the bundle dependency key. - if (BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER == dependencyRegistrationAction) + if (dwRegistrationOptions & BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY) { hr = DependencyRegisterBundle(pRegistration); ExitOnFailure(hr, "Failed to register the bundle dependency key."); @@ -897,7 +889,6 @@ extern "C" HRESULT RegistrationSessionEnd( __in BURN_PACKAGES* pPackages, __in BURN_RESUME_MODE resumeMode, __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ) { @@ -909,11 +900,8 @@ extern "C" HRESULT RegistrationSessionEnd( { AssertSz(BOOTSTRAPPER_REGISTRATION_TYPE_NONE == registrationType, "Registration type must be NONE if resume mode is NONE"); - // If we just registered the bundle dependency but something went wrong and caused us to not - // keep the bundle registration (like rollback) or we are supposed to unregister the bundle - // dependency when unregistering the bundle, do so. - if (BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER == dependencyRegistrationAction || - BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER == dependencyRegistrationAction) + // If we own the bundle dependency then remove it. + if (!pRegistration->fDetectedForeignProviderKeyBundleId) { // Remove the bundle dependency key. DependencyUnregisterBundle(pRegistration, pPackages); diff --git a/src/burn/engine/registration.h b/src/burn/engine/registration.h index e33d5270..0ae61974 100644 --- a/src/burn/engine/registration.h +++ b/src/burn/engine/registration.h @@ -7,11 +7,6 @@ extern "C" { #endif -enum BURN_MODE; -enum BURN_DEPENDENCY_REGISTRATION_ACTION; -struct _BURN_LOGGING; -typedef _BURN_LOGGING BURN_LOGGING; - // constants const LPCWSTR BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; @@ -152,6 +147,7 @@ typedef struct _BURN_REGISTRATION BOOL fForwardCompatibleBundleExists; // Only valid after detect. BOOL fEligibleForCleanup; // Only valid after detect. + BOOL fDetectedForeignProviderKeyBundleId; LPWSTR sczDetectedProviderKeyBundleId; LPWSTR sczBundlePackageAncestors; } BURN_REGISTRATION; @@ -187,7 +183,6 @@ HRESULT RegistrationSessionBegin( __in BURN_CACHE* pCache, __in BURN_VARIABLES* pVariables, __in DWORD dwRegistrationOptions, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, __in DWORD64 qwEstimatedSize, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ); @@ -203,7 +198,6 @@ HRESULT RegistrationSessionEnd( __in BURN_PACKAGES* pPackages, __in BURN_RESUME_MODE resumeMode, __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BURN_DEPENDENCY_REGISTRATION_ACTION dependencyRegistrationAction, __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType ); HRESULT RegistrationSaveState( diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp index d2ec0a82..2ebab277 100644 --- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp +++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp @@ -79,6 +79,7 @@ namespace Bootstrapper 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)); + DWORD dwRegistrationOptions = BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE; try { @@ -125,7 +126,7 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to get current process path."); // write registration - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was created @@ -136,7 +137,7 @@ namespace Bootstrapper Assert::Equal(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.clean.room /burn.runonce"), (String^)(Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr))); // end session - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // verify that registration was removed @@ -179,6 +180,7 @@ namespace Bootstrapper 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)); + DWORD dwRegistrationOptions = 0; try { // set mock API's @@ -228,7 +230,7 @@ namespace Bootstrapper // // write registration - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was created @@ -237,7 +239,7 @@ namespace Bootstrapper Assert::Equal(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.clean.room /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); // complete registration - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // verify that registration was updated @@ -250,7 +252,7 @@ namespace Bootstrapper // // write registration - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was updated @@ -259,7 +261,7 @@ namespace Bootstrapper Assert::Equal(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.clean.room /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); // delete registration - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // verify that registration was removed @@ -301,6 +303,7 @@ namespace Bootstrapper 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)); + DWORD dwRegistrationOptions = 0; try { // set mock API's @@ -350,7 +353,7 @@ namespace Bootstrapper // // write registration - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was created @@ -358,7 +361,7 @@ namespace Bootstrapper Assert::Equal(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.clean.room /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); // complete registration - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // verify that registration variables were updated @@ -378,7 +381,7 @@ namespace Bootstrapper // // delete registration - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // verify that registration was removed @@ -420,6 +423,7 @@ namespace Bootstrapper 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)); + DWORD dwRegistrationOptions = 0; try { // set mock API's @@ -471,7 +475,7 @@ namespace Bootstrapper // // write registration - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was created @@ -479,7 +483,7 @@ namespace Bootstrapper Assert::Equal(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.clean.room /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); // finish registration - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was updated @@ -504,7 +508,7 @@ namespace Bootstrapper // // write registration - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); // verify that registration was updated @@ -512,7 +516,7 @@ namespace Bootstrapper Assert::Equal(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.clean.room /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); // delete registration - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // verify that registration was removed @@ -558,6 +562,7 @@ namespace Bootstrapper BURN_ENGINE_COMMAND internalCommand = { }; BYTE* pbBuffer = NULL; SIZE_T cbBuffer = 0; + DWORD dwRegistrationOptions = 0; String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); try @@ -614,7 +619,7 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to get current process path."); // begin session - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42); @@ -657,7 +662,7 @@ namespace Bootstrapper NativeAssert::StringEqual(L"42", sczValue); // end session - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); TestThrowOnFailure(hr, L"Failed to unregister bundle."); } finally @@ -700,6 +705,7 @@ namespace Bootstrapper SIZE_T cbBuffer = 0; SIZE_T piBuffer = 0; String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); + DWORD dwRegistrationOptions = 0; try { // set mock API's @@ -758,7 +764,7 @@ namespace Bootstrapper Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_NONE, (int)resumeType); // begin session - hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, dwRegistrationOptions, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to register bundle."); VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42); @@ -797,7 +803,7 @@ namespace Bootstrapper Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, (int)resumeType); // suspend session - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); TestThrowOnFailure(hr, L"Failed to suspend session."); // verify that run key was removed @@ -824,7 +830,7 @@ namespace Bootstrapper Assert::NotEqual((Object^)nullptr, Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); // end session - hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); + hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); TestThrowOnFailure(hr, L"Failed to unregister bundle."); // read resume type after session -- cgit v1.2.3-55-g6feb