aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/burn/engine')
-rw-r--r--src/burn/engine/core.cpp39
-rw-r--r--src/burn/engine/engine.mc14
-rw-r--r--src/burn/engine/plan.cpp19
-rw-r--r--src/burn/engine/plan.h1
-rw-r--r--src/burn/engine/userexperience.cpp24
-rw-r--r--src/burn/engine/userexperience.h4
6 files changed, 90 insertions, 11 deletions
diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp
index 9d4ea43e..37872e52 100644
--- a/src/burn/engine/core.cpp
+++ b/src/burn/engine/core.cpp
@@ -527,8 +527,15 @@ extern "C" HRESULT CorePlan(
527 hr = PlanRelatedBundlesInitialize(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, &pEngineState->plan); 527 hr = PlanRelatedBundlesInitialize(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, &pEngineState->plan);
528 ExitOnFailure(hr, "Failed to initialize related bundles for plan."); 528 ExitOnFailure(hr, "Failed to initialize related bundles for plan.");
529 529
530 hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, &pEngineState->dependencies, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning); 530 if (pEngineState->plan.fDowngrade)
531 ExitOnFailure(hr, "Failed to plan registration."); 531 {
532 fContinuePlanning = FALSE;
533 }
534 else
535 {
536 hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, &pEngineState->dependencies, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning);
537 ExitOnFailure(hr, "Failed to plan registration.");
538 }
532 539
533 if (fContinuePlanning) 540 if (fContinuePlanning)
534 { 541 {
@@ -615,6 +622,7 @@ extern "C" HRESULT CoreApply(
615{ 622{
616 HRESULT hr = S_OK; 623 HRESULT hr = S_OK;
617 HANDLE hLock = NULL; 624 HANDLE hLock = NULL;
625 BOOL fApplyBegan = FALSE;
618 BOOL fApplyInitialize = FALSE; 626 BOOL fApplyInitialize = FALSE;
619 BOOL fElevated = FALSE; 627 BOOL fElevated = FALSE;
620 BOOL fRegistered = FALSE; 628 BOOL fRegistered = FALSE;
@@ -627,8 +635,6 @@ extern "C" HRESULT CoreApply(
627 DWORD dwPhaseCount = 0; 635 DWORD dwPhaseCount = 0;
628 BOOTSTRAPPER_APPLYCOMPLETE_ACTION applyCompleteAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE; 636 BOOTSTRAPPER_APPLYCOMPLETE_ACTION applyCompleteAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE;
629 637
630 LogId(REPORT_STANDARD, MSG_APPLY_BEGIN);
631
632 if (!pEngineState->fPlanned) 638 if (!pEngineState->fPlanned)
633 { 639 {
634 ExitOnFailure(hr = E_INVALIDSTATE, "Apply cannot be done without a successful Plan."); 640 ExitOnFailure(hr = E_INVALIDSTATE, "Apply cannot be done without a successful Plan.");
@@ -638,6 +644,10 @@ extern "C" HRESULT CoreApply(
638 ExitOnFailure(hr = E_INVALIDSTATE, "Plans cannot be applied multiple times."); 644 ExitOnFailure(hr = E_INVALIDSTATE, "Plans cannot be applied multiple times.");
639 } 645 }
640 646
647 fApplyBegan = TRUE;
648
649 LogId(REPORT_STANDARD, MSG_APPLY_BEGIN);
650
641 // Ensure any previous attempts to execute are reset. 651 // Ensure any previous attempts to execute are reset.
642 ApplyReset(&pEngineState->userExperience, &pEngineState->packages); 652 ApplyReset(&pEngineState->userExperience, &pEngineState->packages);
643 653
@@ -653,6 +663,14 @@ extern "C" HRESULT CoreApply(
653 hr = UserExperienceOnApplyBegin(&pEngineState->userExperience, dwPhaseCount); 663 hr = UserExperienceOnApplyBegin(&pEngineState->userExperience, dwPhaseCount);
654 ExitOnRootFailure(hr, "BA aborted apply begin."); 664 ExitOnRootFailure(hr, "BA aborted apply begin.");
655 665
666 if (pEngineState->plan.fDowngrade)
667 {
668 hr = HRESULT_FROM_WIN32(ERROR_PRODUCT_VERSION);
669 UserExperienceOnApplyDowngrade(&pEngineState->userExperience, &hr);
670
671 ExitFunction();
672 }
673
656 pEngineState->plan.fAffectedMachineState = pEngineState->plan.fCanAffectMachineState; 674 pEngineState->plan.fAffectedMachineState = pEngineState->plan.fCanAffectMachineState;
657 675
658 hr = ApplyLock(FALSE, &hLock); 676 hr = ApplyLock(FALSE, &hLock);
@@ -804,13 +822,16 @@ LExit:
804 DeleteCriticalSection(&applyContext.csApply); 822 DeleteCriticalSection(&applyContext.csApply);
805 } 823 }
806 824
807 UserExperienceOnApplyComplete(&pEngineState->userExperience, hr, restart, &applyCompleteAction); 825 if (fApplyBegan)
808 if (BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART == applyCompleteAction)
809 { 826 {
810 pEngineState->fRestart = TRUE; 827 UserExperienceOnApplyComplete(&pEngineState->userExperience, hr, restart, &applyCompleteAction);
811 } 828 if (BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART == applyCompleteAction)
829 {
830 pEngineState->fRestart = TRUE;
831 }
812 832
813 LogId(REPORT_STANDARD, MSG_APPLY_COMPLETE, hr, LoggingRestartToString(restart), LoggingBoolToString(pEngineState->fRestart)); 833 LogId(REPORT_STANDARD, MSG_APPLY_COMPLETE, hr, LoggingRestartToString(restart), LoggingBoolToString(pEngineState->fRestart));
834 }
814 835
815 return hr; 836 return hr;
816} 837}
diff --git a/src/burn/engine/engine.mc b/src/burn/engine/engine.mc
index a5c4e2ba..53e6b256 100644
--- a/src/burn/engine/engine.mc
+++ b/src/burn/engine/engine.mc
@@ -499,6 +499,20 @@ Language=English
499Ignoring bundle dependents due to action UnsafeUninstall... 499Ignoring bundle dependents due to action UnsafeUninstall...
500. 500.
501 501
502MessageId=224
503Severity=Warning
504SymbolicName=MSG_PLAN_SKIPPED_DUE_TO_DOWNGRADE
505Language=English
506Plan skipped due to related bundle of plan type Downgrade:
507.
508
509MessageId=225
510Severity=Warning
511SymbolicName=MSG_UPGRADE_BUNDLE_DOWNGRADE
512Language=English
513 id: %1!ls!, version: %2!ls!
514.
515
502MessageId=299 516MessageId=299
503Severity=Success 517Severity=Success
504SymbolicName=MSG_PLAN_COMPLETE 518SymbolicName=MSG_PLAN_COMPLETE
diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp
index dcb919c7..46680636 100644
--- a/src/burn/engine/plan.cpp
+++ b/src/burn/engine/plan.cpp
@@ -1328,11 +1328,12 @@ LExit:
1328extern "C" HRESULT PlanRelatedBundlesInitialize( 1328extern "C" HRESULT PlanRelatedBundlesInitialize(
1329 __in BURN_USER_EXPERIENCE* pUserExperience, 1329 __in BURN_USER_EXPERIENCE* pUserExperience,
1330 __in BURN_REGISTRATION* pRegistration, 1330 __in BURN_REGISTRATION* pRegistration,
1331 __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, 1331 __in BOOTSTRAPPER_RELATION_TYPE relationType,
1332 __in BURN_PLAN* /*pPlan*/ 1332 __in BURN_PLAN* pPlan
1333 ) 1333 )
1334{ 1334{
1335 HRESULT hr = S_OK; 1335 HRESULT hr = S_OK;
1336 BOOL fUninstalling = BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action || BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL == pPlan->action;
1336 1337
1337 for (DWORD i = 0; i < pRegistration->relatedBundles.cRelatedBundles; ++i) 1338 for (DWORD i = 0; i < pRegistration->relatedBundles.cRelatedBundles; ++i)
1338 { 1339 {
@@ -1356,6 +1357,19 @@ extern "C" HRESULT PlanRelatedBundlesInitialize(
1356 1357
1357 hr = UserExperienceOnPlanRelatedBundleType(pUserExperience, pRelatedBundle->package.sczId, &pRelatedBundle->planRelationType); 1358 hr = UserExperienceOnPlanRelatedBundleType(pUserExperience, pRelatedBundle->package.sczId, &pRelatedBundle->planRelationType);
1358 ExitOnRootFailure(hr, "BA aborted plan related bundle type."); 1359 ExitOnRootFailure(hr, "BA aborted plan related bundle type.");
1360
1361 if (BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DOWNGRADE == pRelatedBundle->planRelationType &&
1362 pRelatedBundle->fPlannable && !fUninstalling && BOOTSTRAPPER_RELATION_UPGRADE != relationType)
1363 {
1364 if (!pPlan->fDowngrade)
1365 {
1366 pPlan->fDowngrade = TRUE;
1367
1368 LogId(REPORT_STANDARD, MSG_PLAN_SKIPPED_DUE_TO_DOWNGRADE);
1369 }
1370
1371 LogId(REPORT_VERBOSE, MSG_UPGRADE_BUNDLE_DOWNGRADE, pRelatedBundle->package.sczId, pRelatedBundle->pVersion->sczVersion);
1372 }
1359 } 1373 }
1360 1374
1361 RelatedBundlesSortPlan(&pRegistration->relatedBundles); 1375 RelatedBundlesSortPlan(&pRegistration->relatedBundles);
@@ -3011,6 +3025,7 @@ extern "C" void PlanDump(
3011 LogStringLine(PlanDumpLevel, " can affect machine state: %hs", LoggingTrueFalseToString(pPlan->fCanAffectMachineState)); 3025 LogStringLine(PlanDumpLevel, " can affect machine state: %hs", LoggingTrueFalseToString(pPlan->fCanAffectMachineState));
3012 LogStringLine(PlanDumpLevel, " disable-rollback: %hs", LoggingTrueFalseToString(pPlan->fDisableRollback)); 3026 LogStringLine(PlanDumpLevel, " disable-rollback: %hs", LoggingTrueFalseToString(pPlan->fDisableRollback));
3013 LogStringLine(PlanDumpLevel, " disallow-removal: %hs", LoggingTrueFalseToString(pPlan->fDisallowRemoval)); 3027 LogStringLine(PlanDumpLevel, " disallow-removal: %hs", LoggingTrueFalseToString(pPlan->fDisallowRemoval));
3028 LogStringLine(PlanDumpLevel, " downgrade: %hs", LoggingTrueFalseToString(pPlan->fDowngrade));
3014 LogStringLine(PlanDumpLevel, " registration options: %hs", LoggingRegistrationOptionsToString(pPlan->dwRegistrationOperations)); 3029 LogStringLine(PlanDumpLevel, " registration options: %hs", LoggingRegistrationOptionsToString(pPlan->dwRegistrationOperations));
3015 LogStringLine(PlanDumpLevel, " estimated size: %llu", pPlan->qwEstimatedSize); 3030 LogStringLine(PlanDumpLevel, " estimated size: %llu", pPlan->qwEstimatedSize);
3016 if (pPlan->sczLayoutDirectory) 3031 if (pPlan->sczLayoutDirectory)
diff --git a/src/burn/engine/plan.h b/src/burn/engine/plan.h
index 1f3fe07c..e73cbcfa 100644
--- a/src/burn/engine/plan.h
+++ b/src/burn/engine/plan.h
@@ -250,6 +250,7 @@ typedef struct _BURN_PLAN
250 BOOL fAffectedMachineState; 250 BOOL fAffectedMachineState;
251 LPWSTR sczLayoutDirectory; 251 LPWSTR sczLayoutDirectory;
252 BOOL fPlanPackageCacheRollback; 252 BOOL fPlanPackageCacheRollback;
253 BOOL fDowngrade;
253 254
254 DWORD64 qwCacheSizeTotal; 255 DWORD64 qwCacheSizeTotal;
255 256
diff --git a/src/burn/engine/userexperience.cpp b/src/burn/engine/userexperience.cpp
index 8668cf6f..81ce8bb9 100644
--- a/src/burn/engine/userexperience.cpp
+++ b/src/burn/engine/userexperience.cpp
@@ -335,6 +335,30 @@ LExit:
335 return hr; 335 return hr;
336} 336}
337 337
338EXTERN_C BAAPI UserExperienceOnApplyDowngrade(
339 __in BURN_USER_EXPERIENCE* pUserExperience,
340 __inout HRESULT* phrStatus
341 )
342{
343 HRESULT hr = S_OK;
344 BA_ONAPPLYDOWNGRADE_ARGS args = { };
345 BA_ONAPPLYDOWNGRADE_RESULTS results = { };
346
347 args.cbSize = sizeof(args);
348 args.hrRecommended = *phrStatus;
349
350 results.cbSize = sizeof(results);
351 results.hrStatus = *phrStatus;
352
353 hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &args, &results);
354 ExitOnFailure(hr, "BA OnApplyDowngrade failed.");
355
356 *phrStatus = results.hrStatus;
357
358LExit:
359 return hr;
360}
361
338EXTERN_C BAAPI UserExperienceOnBeginMsiTransactionBegin( 362EXTERN_C BAAPI UserExperienceOnBeginMsiTransactionBegin(
339 __in BURN_USER_EXPERIENCE* pUserExperience, 363 __in BURN_USER_EXPERIENCE* pUserExperience,
340 __in LPCWSTR wzTransactionId 364 __in LPCWSTR wzTransactionId
diff --git a/src/burn/engine/userexperience.h b/src/burn/engine/userexperience.h
index 11344365..2f18acdd 100644
--- a/src/burn/engine/userexperience.h
+++ b/src/burn/engine/userexperience.h
@@ -110,6 +110,10 @@ BAAPI UserExperienceOnApplyComplete(
110 __in BOOTSTRAPPER_APPLY_RESTART restart, 110 __in BOOTSTRAPPER_APPLY_RESTART restart,
111 __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction 111 __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction
112 ); 112 );
113BAAPI UserExperienceOnApplyDowngrade(
114 __in BURN_USER_EXPERIENCE* pUserExperience,
115 __inout HRESULT* phrStatus
116 );
113BAAPI UserExperienceOnBeginMsiTransactionBegin( 117BAAPI UserExperienceOnBeginMsiTransactionBegin(
114 __in BURN_USER_EXPERIENCE* pUserExperience, 118 __in BURN_USER_EXPERIENCE* pUserExperience,
115 __in LPCWSTR wzTransactionId 119 __in LPCWSTR wzTransactionId