aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/elevation.cpp
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2026-02-04 20:47:04 -0500
committerBob Arnson <bob@firegiant.com>2026-02-04 20:47:04 -0500
commitedccb203c421d2bd820062024088c6698424d9ee (patch)
tree6b47c3eb5ca53bd9f79f3d032dc1a596d411bf38 /src/burn/engine/elevation.cpp
parenta3d3963f806117ce123d95e8b77e73e1c1545b25 (diff)
downloadwix-edccb203c421d2bd820062024088c6698424d9ee.tar.gz
wix-edccb203c421d2bd820062024088c6698424d9ee.tar.bz2
wix-edccb203c421d2bd820062024088c6698424d9ee.zip
Support dual-purpose packages in Burn.bob/ConfigurableScopeBundles
Fixes https://github.com/wixtoolset/issues/issues/8958
Diffstat (limited to 'src/burn/engine/elevation.cpp')
-rw-r--r--src/burn/engine/elevation.cpp43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp
index ef87841f..711ce4af 100644
--- a/src/burn/engine/elevation.cpp
+++ b/src/burn/engine/elevation.cpp
@@ -1191,7 +1191,6 @@ extern "C" HRESULT ElevationExecuteMsiPackage(
1191 hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); 1191 hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData);
1192 ExitOnFailure(hr, "Failed to write variables."); 1192 ExitOnFailure(hr, "Failed to write variables.");
1193 1193
1194
1195 // send message 1194 // send message
1196 context.pfnMessageHandler = pfnMessageHandler; 1195 context.pfnMessageHandler = pfnMessageHandler;
1197 context.pvContext = pvContext; 1196 context.pvContext = pvContext;
@@ -2572,6 +2571,11 @@ static HRESULT OnSessionBegin(
2572 ExitOnFailure(hr, "Failed to read variables."); 2571 ExitOnFailure(hr, "Failed to read variables.");
2573 2572
2574 // Begin session in per-machine process. 2573 // Begin session in per-machine process.
2574 pRegistration->fPerMachine = TRUE;
2575
2576 hr = RegistrationSetPaths(pRegistration, pCache);
2577 ExitOnFailure(hr, "Failed to set elevated registration paths.");
2578
2575 hr = RegistrationSessionBegin(sczEngineWorkingPath, pRegistration, pCache, pVariables, dwRegistrationOperations, qwEstimatedSize, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType); 2579 hr = RegistrationSessionBegin(sczEngineWorkingPath, pRegistration, pCache, pVariables, dwRegistrationOperations, qwEstimatedSize, (BOOTSTRAPPER_REGISTRATION_TYPE)dwRegistrationType);
2576 ExitOnFailure(hr, "Failed to begin registration session."); 2580 ExitOnFailure(hr, "Failed to begin registration session.");
2577 2581
@@ -2657,6 +2661,8 @@ static HRESULT OnCachePreparePackage(
2657 { 2661 {
2658 hr = PackageFindById(pPackages, scz, &pPackage); 2662 hr = PackageFindById(pPackages, scz, &pPackage);
2659 ExitOnFailure(hr, "Failed to find package: %ls", scz); 2663 ExitOnFailure(hr, "Failed to find package: %ls", scz);
2664
2665 pPackage->fPerMachine = TRUE;
2660 } 2666 }
2661 else 2667 else
2662 { 2668 {
@@ -2698,6 +2704,8 @@ static HRESULT OnCacheCompletePayload(
2698 { 2704 {
2699 hr = PackageFindById(pPackages, scz, &pPackage); 2705 hr = PackageFindById(pPackages, scz, &pPackage);
2700 ExitOnFailure(hr, "Failed to find package: %ls", scz); 2706 ExitOnFailure(hr, "Failed to find package: %ls", scz);
2707
2708 pPackage->fPerMachine = TRUE;
2701 } 2709 }
2702 2710
2703 hr = BuffReadString(pbData, cbData, &iData, &scz); 2711 hr = BuffReadString(pbData, cbData, &iData, &scz);
@@ -2717,8 +2725,8 @@ static HRESULT OnCacheCompletePayload(
2717 2725
2718 if (pPackage && pPayload) // complete payload. 2726 if (pPackage && pPayload) // complete payload.
2719 { 2727 {
2720 hr = CacheCompletePayload(pCache, pPackage->fPerMachine, pPayload, pPackage->sczCacheId, sczUnverifiedPath, fMove, BurnCacheMessageHandler, ElevatedProgressRoutine, hPipe); 2728 hr = CacheCompletePayload(pCache, TRUE/*fPerMachine*/, pPayload, pPackage->sczCacheId, sczUnverifiedPath, fMove, BurnCacheMessageHandler, ElevatedProgressRoutine, hPipe);
2721 ExitOnFailure(hr, "Failed to cache payload: %ls", pPayload->sczKey); 2729 ExitOnFailure(hr, "Failed to cache per-machine payload: %ls", pPayload->sczKey);
2722 } 2730 }
2723 else 2731 else
2724 { 2732 {
@@ -2755,6 +2763,8 @@ static HRESULT OnCacheVerifyPayload(
2755 { 2763 {
2756 hr = PackageFindById(pPackages, scz, &pPackage); 2764 hr = PackageFindById(pPackages, scz, &pPackage);
2757 ExitOnFailure(hr, "Failed to find package: %ls", scz); 2765 ExitOnFailure(hr, "Failed to find package: %ls", scz);
2766
2767 pPackage->fPerMachine = TRUE;
2758 } 2768 }
2759 2769
2760 hr = BuffReadString(pbData, cbData, &iData, &scz); 2770 hr = BuffReadString(pbData, cbData, &iData, &scz);
@@ -2970,6 +2980,8 @@ static HRESULT OnExecuteBundlePackage(
2970 hr = PackageFindById(pPackages, sczPackage, &executeAction.bundlePackage.pPackage); 2980 hr = PackageFindById(pPackages, sczPackage, &executeAction.bundlePackage.pPackage);
2971 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 2981 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
2972 2982
2983 executeAction.bundlePackage.pPackage->fPerMachine = TRUE;
2984
2973 if (BURN_PACKAGE_TYPE_BUNDLE != executeAction.bundlePackage.pPackage->type) 2985 if (BURN_PACKAGE_TYPE_BUNDLE != executeAction.bundlePackage.pPackage->type)
2974 { 2986 {
2975 ExitWithRootFailure(hr, E_INVALIDARG, "Package is not a BUNDLE package: %ls", sczPackage); 2987 ExitWithRootFailure(hr, E_INVALIDARG, "Package is not a BUNDLE package: %ls", sczPackage);
@@ -3052,6 +3064,8 @@ static HRESULT OnExecuteExePackage(
3052 hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage); 3064 hr = PackageFindById(pPackages, sczPackage, &executeAction.exePackage.pPackage);
3053 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3065 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3054 3066
3067 executeAction.exePackage.pPackage->fPerMachine = TRUE;
3068
3055 if (BURN_PACKAGE_TYPE_EXE != executeAction.exePackage.pPackage->type) 3069 if (BURN_PACKAGE_TYPE_EXE != executeAction.exePackage.pPackage->type)
3056 { 3070 {
3057 ExitWithRootFailure(hr, E_INVALIDARG, "Package is not an EXE package: %ls", sczPackage); 3071 ExitWithRootFailure(hr, E_INVALIDARG, "Package is not an EXE package: %ls", sczPackage);
@@ -3113,6 +3127,8 @@ static HRESULT OnExecuteMsiPackage(
3113 hr = PackageFindById(pPackages, sczPackage, &executeAction.msiPackage.pPackage); 3127 hr = PackageFindById(pPackages, sczPackage, &executeAction.msiPackage.pPackage);
3114 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3128 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3115 3129
3130 executeAction.msiPackage.pPackage->fPerMachine = TRUE;
3131
3116 hr = BuffReadPointer(pbData, cbData, &iData, (DWORD_PTR*)&hwndParent); 3132 hr = BuffReadPointer(pbData, cbData, &iData, (DWORD_PTR*)&hwndParent);
3117 ExitOnFailure(hr, "Failed to read parent hwnd."); 3133 ExitOnFailure(hr, "Failed to read parent hwnd.");
3118 3134
@@ -3205,6 +3221,8 @@ static HRESULT OnExecuteMspPackage(
3205 hr = PackageFindById(pPackages, sczPackage, &executeAction.mspTarget.pPackage); 3221 hr = PackageFindById(pPackages, sczPackage, &executeAction.mspTarget.pPackage);
3206 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3222 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3207 3223
3224 executeAction.mspTarget.pPackage->fPerMachine = TRUE;
3225
3208 hr = BuffReadPointer(pbData, cbData, &iData, (DWORD_PTR*)&hwndParent); 3226 hr = BuffReadPointer(pbData, cbData, &iData, (DWORD_PTR*)&hwndParent);
3209 ExitOnFailure(hr, "Failed to read parent hwnd."); 3227 ExitOnFailure(hr, "Failed to read parent hwnd.");
3210 3228
@@ -3246,6 +3264,8 @@ static HRESULT OnExecuteMspPackage(
3246 3264
3247 hr = PackageFindById(pPackages, sczPackage, &executeAction.mspTarget.rgOrderedPatches[i].pPackage); 3265 hr = PackageFindById(pPackages, sczPackage, &executeAction.mspTarget.rgOrderedPatches[i].pPackage);
3248 ExitOnFailure(hr, "Failed to find ordered patch package: %ls", sczPackage); 3266 ExitOnFailure(hr, "Failed to find ordered patch package: %ls", sczPackage);
3267
3268 executeAction.mspTarget.rgOrderedPatches[i].pPackage->fPerMachine = TRUE;
3249 } 3269 }
3250 } 3270 }
3251 3271
@@ -3310,6 +3330,8 @@ static HRESULT OnExecuteMsuPackage(
3310 hr = PackageFindById(pPackages, sczPackage, &executeAction.msuPackage.pPackage); 3330 hr = PackageFindById(pPackages, sczPackage, &executeAction.msuPackage.pPackage);
3311 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3331 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3312 3332
3333 executeAction.msuPackage.pPackage->fPerMachine = TRUE;
3334
3313 if (BURN_PACKAGE_TYPE_MSU != executeAction.msuPackage.pPackage->type) 3335 if (BURN_PACKAGE_TYPE_MSU != executeAction.msuPackage.pPackage->type)
3314 { 3336 {
3315 ExitWithRootFailure(hr, E_INVALIDARG, "Package is not an MSU package: %ls", sczPackage); 3337 ExitWithRootFailure(hr, E_INVALIDARG, "Package is not an MSU package: %ls", sczPackage);
@@ -3371,6 +3393,8 @@ static HRESULT OnUninstallMsiCompatiblePackage(
3371 hr = PackageFindById(pPackages, sczPackageId, &pPackage); 3393 hr = PackageFindById(pPackages, sczPackageId, &pPackage);
3372 ExitOnFailure(hr, "Failed to find package: %ls", sczPackageId); 3394 ExitOnFailure(hr, "Failed to find package: %ls", sczPackageId);
3373 3395
3396 pPackage->fPerMachine = TRUE;
3397
3374 executeAction.uninstallMsiCompatiblePackage.pParentPackage = pPackage; 3398 executeAction.uninstallMsiCompatiblePackage.pParentPackage = pPackage;
3375 pCompatiblePackage = &pPackage->compatiblePackage; 3399 pCompatiblePackage = &pPackage->compatiblePackage;
3376 3400
@@ -3424,6 +3448,8 @@ static HRESULT OnExecutePackageProviderAction(
3424 } 3448 }
3425 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3449 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3426 3450
3451 executeAction.packageProvider.pPackage->fPerMachine;
3452
3427 hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fRollback); 3453 hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fRollback);
3428 ExitOnFailure(hr, "Failed to read rollback flag."); 3454 ExitOnFailure(hr, "Failed to read rollback flag.");
3429 3455
@@ -3436,11 +3462,6 @@ static HRESULT OnExecutePackageProviderAction(
3436 ExitOnFailure(hr, "Failed to read provider action."); 3462 ExitOnFailure(hr, "Failed to read provider action.");
3437 } 3463 }
3438 3464
3439 if (!executeAction.packageProvider.pPackage->fPerMachine)
3440 {
3441 ExitWithRootFailure(hr, E_INVALIDARG, "ExecutePackageProviderAction called for per-user package.");
3442 }
3443
3444 // Execute the package provider action. 3465 // Execute the package provider action.
3445 hr = DependencyExecutePackageProviderAction(&executeAction, fRollback); 3466 hr = DependencyExecutePackageProviderAction(&executeAction, fRollback);
3446 ExitOnFailure(hr, "Failed to execute package provider action."); 3467 ExitOnFailure(hr, "Failed to execute package provider action.");
@@ -3479,6 +3500,8 @@ static HRESULT OnExecutePackageDependencyAction(
3479 } 3500 }
3480 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3501 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3481 3502
3503 executeAction.packageDependency.pPackage->fPerMachine = TRUE;
3504
3482 hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fRollback); 3505 hr = BuffReadNumber(pbData, cbData, &iData, (DWORD*)&fRollback);
3483 ExitOnFailure(hr, "Failed to read rollback flag."); 3506 ExitOnFailure(hr, "Failed to read rollback flag.");
3484 3507
@@ -3784,6 +3807,8 @@ static HRESULT OnCleanCompatiblePackage(
3784 hr = PackageFindById(pPackages, sczPackageId, &pPackage); 3807 hr = PackageFindById(pPackages, sczPackageId, &pPackage);
3785 ExitOnFailure(hr, "Failed to find package: %ls", sczPackageId); 3808 ExitOnFailure(hr, "Failed to find package: %ls", sczPackageId);
3786 3809
3810 pPackage->fPerMachine = TRUE;
3811
3787 pCompatiblePackage = &pPackage->compatiblePackage; 3812 pCompatiblePackage = &pPackage->compatiblePackage;
3788 3813
3789 if (!pCompatiblePackage->fDetected || !pCompatiblePackage->compatibleEntry.sczId || !pCompatiblePackage->sczCacheId || !*pCompatiblePackage->sczCacheId) 3814 if (!pCompatiblePackage->fDetected || !pCompatiblePackage->compatibleEntry.sczId || !pCompatiblePackage->sczCacheId || !*pCompatiblePackage->sczCacheId)
@@ -3826,6 +3851,8 @@ static HRESULT OnCleanPackage(
3826 hr = PackageFindById(pPackages, sczPackage, &pPackage); 3851 hr = PackageFindById(pPackages, sczPackage, &pPackage);
3827 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage); 3852 ExitOnFailure(hr, "Failed to find package: %ls", sczPackage);
3828 3853
3854 pPackage->fPerMachine = TRUE;
3855
3829 // Remove the package from the cache. 3856 // Remove the package from the cache.
3830 hr = CacheRemovePackage(pCache, TRUE, pPackage->sczId, pPackage->sczCacheId); 3857 hr = CacheRemovePackage(pCache, TRUE, pPackage->sczId, pPackage->sczCacheId);
3831 ExitOnFailure(hr, "Failed to remove from cache package: %ls", pPackage->sczId); 3858 ExitOnFailure(hr, "Failed to remove from cache package: %ls", pPackage->sczId);