WIXBUG:5980 Fix bugs around INSTALLUILEVEL_SOURCERESONLY.
Apply requires a valid hWnd since otherwise a source resolution prompt could hang the bundle. Burn now defaults to INSTALLUILEVEL_NONE by itself if the bundle is not showing UI.
Sean Hall committed
May 21, 2020 at 14:13 UTC
513286d4798572cc82a78554ef15ef2fe79f407e
8 files changed
+47
-17
src/engine/EngineForApplication.cpp
+6
@@ -709,6 +709,12 @@ static HRESULT BAEngineApply(
709
{
710
HRESULT hr = S_OK;
711
712
+ ExitOnNull(pArgs->hwndParent, hr, E_INVALIDARG, "BA passed NULL hwndParent to Apply.");
713
+ if (!::IsWindow(pArgs->hwndParent))
714
+ {
715
+ ExitOnFailure(hr = E_INVALIDARG, "BA passed invalid hwndParent to Apply.");
716
+ }
717
+
718
if (!::PostThreadMessageW(pContext->dwThreadId, WM_BURN_APPLY, 0, reinterpret_cast<LPARAM>(pArgs->hwndParent)))
719
{
720
ExitWithLastError(hr, "Failed to post apply message.");
src/engine/core.cpp
+4
-4
@@ -431,7 +431,7 @@ extern "C" HRESULT CorePlan(
431
ExitOnFailure(hr, "Failed to plan the layout of the bundle.");
432
433
// Plan the packages' layout.
434
- hr = PlanPackages(&pEngineState->registration, &pEngineState->userExperience, &pEngineState->packages, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, FALSE, pEngineState->command.relationType, sczLayoutDirectory, &hSyncpointEvent);
434
+ hr = PlanPackages(&pEngineState->registration, &pEngineState->userExperience, &pEngineState->packages, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, FALSE, pEngineState->command.display, pEngineState->command.relationType, sczLayoutDirectory, &hSyncpointEvent);
435
ExitOnFailure(hr, "Failed to plan packages.");
436
}
437
else if (BOOTSTRAPPER_ACTION_UPDATE_REPLACE == action || BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED == action)
@@ -440,7 +440,7 @@ extern "C" HRESULT CorePlan(
440
441
pUpgradeBundlePackage = &pEngineState->update.package;
442
443
- hr = PlanUpdateBundle(&pEngineState->userExperience, pUpgradeBundlePackage, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, pEngineState->command.relationType, &hSyncpointEvent);
443
+ hr = PlanUpdateBundle(&pEngineState->userExperience, pUpgradeBundlePackage, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, pEngineState->command.display, pEngineState->command.relationType, &hSyncpointEvent);
444
ExitOnFailure(hr, "Failed to plan update.");
445
}
446
else if (pEngineState->registration.fEnabledForwardCompatibleBundle)
@@ -449,7 +449,7 @@ extern "C" HRESULT CorePlan(
449
450
pForwardCompatibleBundlePackage = &pEngineState->registration.forwardCompatibleBundle;
451
452
- hr = PlanPassThroughBundle(&pEngineState->userExperience, pForwardCompatibleBundlePackage, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, pEngineState->command.relationType, &hSyncpointEvent);
452
+ hr = PlanPassThroughBundle(&pEngineState->userExperience, pForwardCompatibleBundlePackage, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, pEngineState->command.display, pEngineState->command.relationType, &hSyncpointEvent);
453
ExitOnFailure(hr, "Failed to plan passthrough.");
454
}
455
else // doing an action that modifies the machine state.
@@ -471,7 +471,7 @@ extern "C" HRESULT CorePlan(
471
hr = PlanRelatedBundlesBegin(&pEngineState->userExperience, &pEngineState->registration, pEngineState->command.relationType, &pEngineState->plan);
472
ExitOnFailure(hr, "Failed to plan related bundles.");
473
474
- hr = PlanPackages(&pEngineState->registration, &pEngineState->userExperience, &pEngineState->packages, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, pEngineState->registration.fInstalled, pEngineState->command.relationType, NULL, &hSyncpointEvent);
474
+ hr = PlanPackages(&pEngineState->registration, &pEngineState->userExperience, &pEngineState->packages, &pEngineState->plan, &pEngineState->log, &pEngineState->variables, pEngineState->registration.fInstalled, pEngineState->command.display, pEngineState->command.relationType, NULL, &hSyncpointEvent);
475
ExitOnFailure(hr, "Failed to plan packages.");
476
477
// Schedule the update of related bundles last.
src/engine/msiengine.cpp
+11
-3
@@ -873,6 +873,7 @@ LExit:
873
// PlanAdd - adds the calculated execute and rollback actions for the package.
874
//
875
extern "C" HRESULT MsiEnginePlanAddPackage(
876
+ __in BOOTSTRAPPER_DISPLAY display,
877
__in BURN_USER_EXPERIENCE* pUserExperience,
878
__in BURN_PACKAGE* pPackage,
879
__in BURN_PLAN* pPlan,
@@ -928,7 +929,7 @@ extern "C" HRESULT MsiEnginePlanAddPackage(
929
pAction->msiPackage.rgFeatures = rgRollbackFeatureActions;
930
rgRollbackFeatureActions = NULL;
931
931
- hr = MsiEngineCalculateInstallUiLevel(pUserExperience, pPackage->sczId, FALSE, pAction->msiPackage.action,
932
+ hr = MsiEngineCalculateInstallUiLevel(display, pUserExperience, pPackage->sczId, FALSE, pAction->msiPackage.action,
933
&pAction->msiPackage.actionMsiProperty, &pAction->msiPackage.uiLevel, &pAction->msiPackage.fDisableExternalUiHandler);
934
ExitOnFailure(hr, "Failed to get msi ui options.");
935
@@ -954,7 +955,7 @@ extern "C" HRESULT MsiEnginePlanAddPackage(
955
pAction->msiPackage.rgFeatures = rgFeatureActions;
956
rgFeatureActions = NULL;
957
957
- hr = MsiEngineCalculateInstallUiLevel(pUserExperience, pPackage->sczId, TRUE, pAction->msiPackage.action,
958
+ hr = MsiEngineCalculateInstallUiLevel(display, pUserExperience, pPackage->sczId, TRUE, pAction->msiPackage.action,
959
&pAction->msiPackage.actionMsiProperty, &pAction->msiPackage.uiLevel, &pAction->msiPackage.fDisableExternalUiHandler);
960
ExitOnFailure(hr, "Failed to get msi ui options.");
961
@@ -1416,6 +1417,7 @@ LExit:
1417
}
1418
1419
extern "C" HRESULT MsiEngineCalculateInstallUiLevel(
1420
+ __in BOOTSTRAPPER_DISPLAY display,
1421
__in BURN_USER_EXPERIENCE* pUserExperience,
1422
__in LPCWSTR wzPackageId,
1423
__in BOOL fExecute,
@@ -1425,9 +1427,15 @@ extern "C" HRESULT MsiEngineCalculateInstallUiLevel(
1427
__out BOOL* pfDisableExternalUiHandler
1428
)
1429
{
1428
- *pUiLevel = static_cast<INSTALLUILEVEL>(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY);
1430
+ *pUiLevel = INSTALLUILEVEL_NONE;
1431
*pfDisableExternalUiHandler = FALSE;
1432
1433
+ if (BOOTSTRAPPER_DISPLAY_FULL == display ||
1434
+ BOOTSTRAPPER_DISPLAY_PASSIVE == display)
1435
+ {
1436
+ *pUiLevel = static_cast<INSTALLUILEVEL>(*pUiLevel | INSTALLUILEVEL_SOURCERESONLY);
1437
+ }
1438
+
1439
switch (actionState)
1440
{
1441
case BOOTSTRAPPER_ACTION_STATE_UNINSTALL:
src/engine/msiengine.h
+2
@@ -32,6 +32,7 @@ HRESULT MsiEnginePlanCalculatePackage(
32
__out_opt BOOL* pfBARequestedCache
33
);
34
HRESULT MsiEnginePlanAddPackage(
35
+ __in BOOTSTRAPPER_DISPLAY display,
36
__in BURN_USER_EXPERIENCE* pUserExperience,
37
__in BURN_PACKAGE* pPackage,
38
__in BURN_PLAN* pPlan,
@@ -67,6 +68,7 @@ HRESULT MsiEngineConcatProperties(
68
__in BOOL fObfuscateHiddenVariables
69
);
70
HRESULT MsiEngineCalculateInstallUiLevel(
71
+ __in BOOTSTRAPPER_DISPLAY display,
72
__in BURN_USER_EXPERIENCE* pUserExperience,
73
__in LPCWSTR wzPackageId,
74
__in BOOL fExecute,
src/engine/mspengine.cpp
+6
-3
@@ -44,6 +44,7 @@ static void DeterminePatchChainedTarget(
44
__out BOOL* pfSlipstreamed
45
);
46
static HRESULT PlanTargetProduct(
47
+ __in BOOTSTRAPPER_DISPLAY display,
48
__in BURN_USER_EXPERIENCE* pUserExperience,
49
__in BOOL fRollback,
50
__in BURN_PLAN* pPlan,
@@ -396,6 +397,7 @@ LExit:
397
// PlanAdd - adds the calculated execute and rollback actions for the package.
398
//
399
extern "C" HRESULT MspEnginePlanAddPackage(
400
+ __in BOOTSTRAPPER_DISPLAY display,
401
__in BURN_USER_EXPERIENCE* pUserExperience,
402
__in BURN_PACKAGE* pPackage,
403
__in BURN_PLAN* pPlan,
@@ -433,13 +435,13 @@ extern "C" HRESULT MspEnginePlanAddPackage(
435
436
if (BOOTSTRAPPER_ACTION_STATE_NONE != pTargetProduct->execute)
437
{
436
- hr = PlanTargetProduct(pUserExperience, FALSE, pPlan, pLog, pVariables, pTargetProduct->execute, pPackage, pTargetProduct, hCacheEvent);
438
+ hr = PlanTargetProduct(display, pUserExperience, FALSE, pPlan, pLog, pVariables, pTargetProduct->execute, pPackage, pTargetProduct, hCacheEvent);
439
ExitOnFailure(hr, "Failed to plan target product.");
440
}
441
442
if (BOOTSTRAPPER_ACTION_STATE_NONE != pTargetProduct->rollback)
443
{
442
- hr = PlanTargetProduct(pUserExperience, TRUE, pPlan, pLog, pVariables, pTargetProduct->rollback, pPackage, pTargetProduct, hCacheEvent);
444
+ hr = PlanTargetProduct(display, pUserExperience, TRUE, pPlan, pLog, pVariables, pTargetProduct->rollback, pPackage, pTargetProduct, hCacheEvent);
445
ExitOnFailure(hr, "Failed to plan rollack target product.");
446
}
447
}
@@ -877,6 +879,7 @@ static void DeterminePatchChainedTarget(
879
}
880
881
static HRESULT PlanTargetProduct(
882
+ __in BOOTSTRAPPER_DISPLAY display,
883
__in BURN_USER_EXPERIENCE* pUserExperience,
884
__in BOOL fRollback,
885
__in BURN_PLAN* pPlan,
@@ -934,7 +937,7 @@ static HRESULT PlanTargetProduct(
937
hr = StrAllocString(&pAction->mspTarget.sczTargetProductCode, pTargetProduct->wzTargetProductCode, 0);
938
ExitOnFailure(hr, "Failed to copy target product code.");
939
937
- hr = MsiEngineCalculateInstallUiLevel(pUserExperience, pPackage->sczId, !fRollback, pAction->mspTarget.action,
940
+ hr = MsiEngineCalculateInstallUiLevel(display, pUserExperience, pPackage->sczId, !fRollback, pAction->mspTarget.action,
941
&pAction->mspTarget.actionMsiProperty, &pAction->mspTarget.uiLevel, &pAction->mspTarget.fDisableExternalUiHandler);
942
ExitOnFailure(hr, "Failed to get msp ui options.");
943
src/engine/mspengine.h
+1
@@ -38,6 +38,7 @@ HRESULT MspEnginePlanCalculatePackage(
38
__out_opt BOOL* pfBARequestedCache
39
);
40
HRESULT MspEnginePlanAddPackage(
41
+ __in BOOTSTRAPPER_DISPLAY display,
42
__in BURN_USER_EXPERIENCE* pUserExperience,
43
__in BURN_PACKAGE* pPackage,
44
__in BURN_PLAN* pPlan,
src/engine/plan.cpp
+13
-7
@@ -31,6 +31,7 @@ static HRESULT ProcessPackage(
31
__in BURN_PACKAGE* pPackage,
32
__in BURN_LOGGING* pLog,
33
__in BURN_VARIABLES* pVariables,
34
+ __in BOOTSTRAPPER_DISPLAY display,
35
__in BOOTSTRAPPER_RELATION_TYPE relationType,
36
__in_z_opt LPCWSTR wzLayoutDirectory,
37
__inout HANDLE* phSyncpointEvent,
@@ -472,6 +473,7 @@ extern "C" HRESULT PlanPackages(
473
__in BURN_LOGGING* pLog,
474
__in BURN_VARIABLES* pVariables,
475
__in BOOL fBundleInstalled,
476
+ __in BOOTSTRAPPER_DISPLAY display,
477
__in BOOTSTRAPPER_RELATION_TYPE relationType,
478
__in_z_opt LPCWSTR wzLayoutDirectory,
479
__inout HANDLE* phSyncpointEvent
@@ -509,7 +511,7 @@ extern "C" HRESULT PlanPackages(
511
}
512
}
513
512
- hr = ProcessPackage(fBundlePerMachine, NULL, pUX, pPlan, pPackage, pLog, pVariables, relationType, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary, &nonpermanentPackageIndices);
514
+ hr = ProcessPackage(fBundlePerMachine, NULL, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary, &nonpermanentPackageIndices);
515
ExitOnFailure(hr, "Failed to process package.");
516
517
// Attempt to remove orphaned packages during uninstall. Currently only MSI packages are supported and should not require source.
@@ -534,7 +536,7 @@ extern "C" HRESULT PlanPackages(
536
ExitOnFailure(hr, "Failed to copy installed ProductCode");
537
538
// Process the compatible MSI package like any other.
537
- hr = ProcessPackage(fBundlePerMachine, pPackage, pUX, pPlan, pCompatiblePackage, pLog, pVariables, relationType, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary, &nonpermanentPackageIndices);
539
+ hr = ProcessPackage(fBundlePerMachine, pPackage, pUX, pPlan, pCompatiblePackage, pLog, pVariables, display, relationType, wzLayoutDirectory, phSyncpointEvent, &pRollbackBoundary, &nonpermanentPackageIndices);
540
ExitOnFailure(hr, "Failed to process compatible package.");
541
542
if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL == pCompatiblePackage->execute)
@@ -785,6 +787,7 @@ extern "C" HRESULT PlanPassThroughBundle(
787
__in BURN_PLAN* pPlan,
788
__in BURN_LOGGING* pLog,
789
__in BURN_VARIABLES* pVariables,
790
+ __in BOOTSTRAPPER_DISPLAY display,
791
__in BOOTSTRAPPER_RELATION_TYPE relationType,
792
__inout HANDLE* phSyncpointEvent
793
)
@@ -794,7 +797,7 @@ extern "C" HRESULT PlanPassThroughBundle(
797
BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL;
798
799
// Plan passthrough package.
797
- hr = ProcessPackage(fBundlePerMachine, NULL, pUX, pPlan, pPackage, pLog, pVariables, relationType, NULL, phSyncpointEvent, &pRollbackBoundary, NULL);
800
+ hr = ProcessPackage(fBundlePerMachine, NULL, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, NULL, phSyncpointEvent, &pRollbackBoundary, NULL);
801
ExitOnFailure(hr, "Failed to process passthrough package.");
802
803
// If we still have an open rollback boundary, complete it.
@@ -818,6 +821,7 @@ extern "C" HRESULT PlanUpdateBundle(
821
__in BURN_PLAN* pPlan,
822
__in BURN_LOGGING* pLog,
823
__in BURN_VARIABLES* pVariables,
824
+ __in BOOTSTRAPPER_DISPLAY display,
825
__in BOOTSTRAPPER_RELATION_TYPE relationType,
826
__inout HANDLE* phSyncpointEvent
827
)
@@ -827,7 +831,7 @@ extern "C" HRESULT PlanUpdateBundle(
831
BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL;
832
833
// Plan update package.
830
- hr = ProcessPackage(fBundlePerMachine, NULL, pUX, pPlan, pPackage, pLog, pVariables, relationType, NULL, phSyncpointEvent, &pRollbackBoundary, NULL);
834
+ hr = ProcessPackage(fBundlePerMachine, NULL, pUX, pPlan, pPackage, pLog, pVariables, display, relationType, NULL, phSyncpointEvent, &pRollbackBoundary, NULL);
835
ExitOnFailure(hr, "Failed to process update package.");
836
837
// If we still have an open rollback boundary, complete it.
@@ -853,6 +857,7 @@ static HRESULT ProcessPackage(
857
__in BURN_PACKAGE* pPackage,
858
__in BURN_LOGGING* pLog,
859
__in BURN_VARIABLES* pVariables,
860
+ __in BOOTSTRAPPER_DISPLAY display,
861
__in BOOTSTRAPPER_RELATION_TYPE relationType,
862
__in_z_opt LPCWSTR wzLayoutDirectory,
863
__inout HANDLE* phSyncpointEvent,
@@ -906,7 +911,7 @@ static HRESULT ProcessPackage(
911
}
912
}
913
909
- hr = PlanExecutePackage(fBundlePerMachine, pUX, pPlan, pPackage, pLog, pVariables, phSyncpointEvent);
914
+ hr = PlanExecutePackage(fBundlePerMachine, display, pUX, pPlan, pPackage, pLog, pVariables, phSyncpointEvent);
915
ExitOnFailure(hr, "Failed to plan execute package.");
916
917
if (pPackage->fUninstallable && pNonpermanentPackageIndices)
@@ -1086,6 +1091,7 @@ LExit:
1091
1092
extern "C" HRESULT PlanExecutePackage(
1093
__in BOOL fPerMachine,
1094
+ __in BOOTSTRAPPER_DISPLAY display,
1095
__in BURN_USER_EXPERIENCE* pUserExperience,
1096
__in BURN_PLAN* pPlan,
1097
__in BURN_PACKAGE* pPackage,
@@ -1150,11 +1156,11 @@ extern "C" HRESULT PlanExecutePackage(
1156
break;
1157
1158
case BURN_PACKAGE_TYPE_MSI:
1153
- hr = MsiEnginePlanAddPackage(pUserExperience, pPackage, pPlan, pLog, pVariables, *phSyncpointEvent, pPackage->fAcquire);
1159
+ hr = MsiEnginePlanAddPackage(display, pUserExperience, pPackage, pPlan, pLog, pVariables, *phSyncpointEvent, pPackage->fAcquire);
1160
break;
1161
1162
case BURN_PACKAGE_TYPE_MSP:
1157
- hr = MspEnginePlanAddPackage(pUserExperience, pPackage, pPlan, pLog, pVariables, *phSyncpointEvent, pPackage->fAcquire);
1163
+ hr = MspEnginePlanAddPackage(display, pUserExperience, pPackage, pPlan, pLog, pVariables, *phSyncpointEvent, pPackage->fAcquire);
1164
break;
1165
1166
case BURN_PACKAGE_TYPE_MSU:
src/engine/plan.h
+4
@@ -408,6 +408,7 @@ HRESULT PlanPackages(
408
__in BURN_LOGGING* pLog,
409
__in BURN_VARIABLES* pVariables,
410
__in BOOL fBundleInstalled,
411
+ __in BOOTSTRAPPER_DISPLAY display,
412
__in BOOTSTRAPPER_RELATION_TYPE relationType,
413
__in_z_opt LPCWSTR wzLayoutDirectory,
414
__inout HANDLE* phSyncpointEvent
@@ -426,6 +427,7 @@ HRESULT PlanPassThroughBundle(
427
__in BURN_PLAN* pPlan,
428
__in BURN_LOGGING* pLog,
429
__in BURN_VARIABLES* pVariables,
430
+ __in BOOTSTRAPPER_DISPLAY display,
431
__in BOOTSTRAPPER_RELATION_TYPE relationType,
432
__inout HANDLE* phSyncpointEvent
433
);
@@ -435,6 +437,7 @@ HRESULT PlanUpdateBundle(
437
__in BURN_PLAN* pPlan,
438
__in BURN_LOGGING* pLog,
439
__in BURN_VARIABLES* pVariables,
440
+ __in BOOTSTRAPPER_DISPLAY display,
441
__in BOOTSTRAPPER_RELATION_TYPE relationType,
442
__inout HANDLE* phSyncpointEvent
443
);
@@ -453,6 +456,7 @@ HRESULT PlanCachePackage(
456
);
457
HRESULT PlanExecutePackage(
458
__in BOOL fPerMachine,
459
+ __in BOOTSTRAPPER_DISPLAY display,
460
__in BURN_USER_EXPERIENCE* pUserExperience,
461
__in BURN_PLAN* pPlan,
462
__in BURN_PACKAGE* pPackage,