aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2026-03-09 16:21:15 -0400
committerBob Arnson <github@bobs.org>2026-03-09 17:32:22 -0400
commitb4da272e25c5c776cc5c66ee069bd3fb7548dd92 (patch)
treec505aa7fcde1638b8b67bdb41db0b56f9930a246 /src/burn/engine
parentdd827742e060db17fb61acc1534556a821c1f2c2 (diff)
downloadwix-b4da272e25c5c776cc5c66ee069bd3fb7548dd92.tar.gz
wix-b4da272e25c5c776cc5c66ee069bd3fb7548dd92.tar.bz2
wix-b4da272e25c5c776cc5c66ee069bd3fb7548dd92.zip
Set more detect-phase values when falling back.
When configurable-scope bundle is already installed, find it during detect by falling back from machine to user. Set the scope as early as possible so detect-phase checks (e.g., cache path, state file) work as expected. Fixes https://github.com/wixtoolset/issues/issues/9257
Diffstat (limited to 'src/burn/engine')
-rw-r--r--src/burn/engine/apply.cpp4
-rw-r--r--src/burn/engine/core.cpp5
-rw-r--r--src/burn/engine/engine.mc2
-rw-r--r--src/burn/engine/registration.cpp38
-rw-r--r--src/burn/engine/registration.h3
5 files changed, 34 insertions, 18 deletions
diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp
index b7a54246..818427ac 100644
--- a/src/burn/engine/apply.cpp
+++ b/src/burn/engine/apply.cpp
@@ -536,8 +536,6 @@ extern "C" HRESULT ApplyUnregister(
536 IgnoreRollbackError(hrRegistrationRollback, "Dependent registration actions failed"); 536 IgnoreRollbackError(hrRegistrationRollback, "Dependent registration actions failed");
537 } 537 }
538 538
539 LogId(REPORT_STANDARD, MSG_SESSION_END, pEngineState->registration.sczRegistrationKey, LoggingInstallScopeToString(pEngineState->registration.fPerMachine), LoggingResumeModeToString(resumeMode), LoggingRestartToString(restart), LoggingBoolToString(pEngineState->registration.fDisableResume), LoggingRegistrationTypeToString(defaultRegistrationType), LoggingRegistrationTypeToString(registrationType));
540
541 if (BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL == pEngineState->plan.action) 539 if (BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL == pEngineState->plan.action)
542 { 540 {
543 registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; 541 registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
@@ -546,6 +544,8 @@ extern "C" HRESULT ApplyUnregister(
546 LogId(REPORT_STANDARD, MSG_UNSAFE_SESSION_END); 544 LogId(REPORT_STANDARD, MSG_UNSAFE_SESSION_END);
547 } 545 }
548 546
547 LogId(REPORT_STANDARD, MSG_SESSION_END, pEngineState->registration.sczRegistrationKey, LoggingInstallScopeToString(pEngineState->registration.fPerMachine), LoggingResumeModeToString(resumeMode), LoggingRestartToString(restart), LoggingBoolToString(pEngineState->registration.fDisableResume), LoggingRegistrationTypeToString(defaultRegistrationType), LoggingRegistrationTypeToString(registrationType));
548
549 if (pEngineState->registration.fPerMachine) 549 if (pEngineState->registration.fPerMachine)
550 { 550 {
551 hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->registration.fDetectedForeignProviderKeyBundleCode, qwEstimatedSize, registrationType); 551 hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->registration.fDetectedForeignProviderKeyBundleCode, qwEstimatedSize, registrationType);
diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp
index da4ea91b..926c327b 100644
--- a/src/burn/engine/core.cpp
+++ b/src/burn/engine/core.cpp
@@ -256,6 +256,10 @@ extern "C" HRESULT CoreQueryRegistration(
256 SIZE_T cbBuffer = 0; 256 SIZE_T cbBuffer = 0;
257 SIZE_T iBuffer = 0; 257 SIZE_T iBuffer = 0;
258 258
259 // Detect if bundle is already installed.
260 hr = RegistrationDetectInstalled(&pEngineState->registration, &pEngineState->cache);
261 ExitOnFailure(hr, "Failed to detect bundle install state.");
262
259 // detect resume type 263 // detect resume type
260 hr = RegistrationDetectResumeType(&pEngineState->registration, &pEngineState->command.resumeType); 264 hr = RegistrationDetectResumeType(&pEngineState->registration, &pEngineState->command.resumeType);
261 ExitOnFailure(hr, "Failed to detect resume type."); 265 ExitOnFailure(hr, "Failed to detect resume type.");
@@ -2280,6 +2284,7 @@ static HRESULT DetectPackagePayloadsCached(
2280LExit: 2284LExit:
2281 ReleaseStr(sczPayloadCachePath); 2285 ReleaseStr(sczPayloadCachePath);
2282 ReleaseStr(sczCachePath); 2286 ReleaseStr(sczCachePath);
2287
2283 return hr; 2288 return hr;
2284} 2289}
2285 2290
diff --git a/src/burn/engine/engine.mc b/src/burn/engine/engine.mc
index edafef97..72e62fe4 100644
--- a/src/burn/engine/engine.mc
+++ b/src/burn/engine/engine.mc
@@ -1055,7 +1055,7 @@ MessageId=371
1055Severity=Success 1055Severity=Success
1056SymbolicName=MSG_SESSION_UPDATE 1056SymbolicName=MSG_SESSION_UPDATE
1057Language=English 1057Language=English
1058Updating session, registration key: %1!ls!, scope: %2!hs!, resume: %3!hs!, restart initiated: %4!hs!, disable resume: %5!hs! 1058Updating session, registration key: %1!ls!, scope: %2!hs!, resume: %3!hs!, restart initiated: %4!hs!, disable resume: %5!hs!, registration: %6!hs!
1059. 1059.
1060 1060
1061MessageId=372 1061MessageId=372
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp
index e7a9b95f..855ebf04 100644
--- a/src/burn/engine/registration.cpp
+++ b/src/burn/engine/registration.cpp
@@ -64,7 +64,7 @@ static HRESULT EnsureRegistrationVariable(
64 ); 64 );
65static HRESULT UpdateResumeMode( 65static HRESULT UpdateResumeMode(
66 __in BURN_REGISTRATION* pRegistration, 66 __in BURN_REGISTRATION* pRegistration,
67 __in HKEY hkRegistration, 67 __in_opt HKEY hkRegistration,
68 __in BURN_RESUME_MODE resumeMode, 68 __in BURN_RESUME_MODE resumeMode,
69 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType, 69 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
70 __in BOOL fRestartInitiated 70 __in BOOL fRestartInitiated
@@ -461,13 +461,7 @@ extern "C" HRESULT RegistrationSetDynamicVariables(
461 ) 461 )
462{ 462{
463 HRESULT hr = S_OK; 463 HRESULT hr = S_OK;
464 LONGLONG llInstalled = 0; 464 LONGLONG llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0;
465
466 // Detect if bundle is already installed.
467 hr = RegistrationDetectInstalled(pRegistration);
468 ExitOnFailure(hr, "Failed to detect bundle install state.");
469
470 llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0;
471 465
472 hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE); 466 hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE);
473 ExitOnFailure(hr, "Failed to set the bundle installed built-in variable."); 467 ExitOnFailure(hr, "Failed to set the bundle installed built-in variable.");
@@ -483,7 +477,8 @@ LExit:
483} 477}
484 478
485extern "C" HRESULT RegistrationDetectInstalled( 479extern "C" HRESULT RegistrationDetectInstalled(
486 __in BURN_REGISTRATION* pRegistration 480 __in BURN_REGISTRATION* pRegistration,
481 __in BURN_CACHE* pCache
487) 482)
488{ 483{
489 HRESULT hr = S_OK; 484 HRESULT hr = S_OK;
@@ -496,14 +491,28 @@ extern "C" HRESULT RegistrationDetectInstalled(
496 { 491 {
497 // For PUOM/PMOU bundles, check per-machine then fall back to per-user. 492 // For PUOM/PMOU bundles, check per-machine then fall back to per-user.
498 hr = DetectInstalled(pRegistration, HKEY_LOCAL_MACHINE); 493 hr = DetectInstalled(pRegistration, HKEY_LOCAL_MACHINE);
494 if (SUCCEEDED(hr))
495 {
496 pRegistration->fPerMachine = TRUE;
499 497
500 if (FAILED(hr)) 498 hr = RegistrationSetPaths(pRegistration, pCache);
499 ExitOnFailure(hr, "Failed to set registration paths for per-machine configurable scope.");
500 }
501 else
501 { 502 {
502 hr = DetectInstalled(pRegistration, HKEY_CURRENT_USER); 503 hr = DetectInstalled(pRegistration, HKEY_CURRENT_USER);
504
505 if (SUCCEEDED(hr))
506 {
507 pRegistration->fPerMachine = FALSE;
508
509 hr = RegistrationSetPaths(pRegistration, pCache);
510 ExitOnFailure(hr, "Failed to set registration paths for per-user configurable scope.");
511 }
503 } 512 }
504 } 513 }
505 514
506//LExit: 515LExit:
507 // Not finding the key or value is okay. 516 // Not finding the key or value is okay.
508 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) 517 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
509 { 518 {
@@ -1086,6 +1095,8 @@ extern "C" HRESULT RegistrationSetPaths(
1086 hr = PathConcatRelativeToFullyQualifiedBase(sczCacheDirectory, pRegistration->sczExecutableName, &pRegistration->sczCacheExecutablePath); 1095 hr = PathConcatRelativeToFullyQualifiedBase(sczCacheDirectory, pRegistration->sczExecutableName, &pRegistration->sczCacheExecutablePath);
1087 ExitOnFailure(hr, "Failed to build cached executable path."); 1096 ExitOnFailure(hr, "Failed to build cached executable path.");
1088 1097
1098 pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx(pRegistration->sczCacheExecutablePath, NULL);
1099
1089 // build state file path 1100 // build state file path
1090 hr = StrAllocFormatted(&pRegistration->sczStateFile, L"%ls\\state.rsm", sczCacheDirectory); 1101 hr = StrAllocFormatted(&pRegistration->sczStateFile, L"%ls\\state.rsm", sczCacheDirectory);
1091 ExitOnFailure(hr, "Failed to build state file path."); 1102 ExitOnFailure(hr, "Failed to build state file path.");
@@ -1242,7 +1253,7 @@ LExit:
1242 1253
1243static HRESULT UpdateResumeMode( 1254static HRESULT UpdateResumeMode(
1244 __in BURN_REGISTRATION* pRegistration, 1255 __in BURN_REGISTRATION* pRegistration,
1245 __in HKEY hkRegistration, 1256 __in_opt HKEY hkRegistration,
1246 __in BURN_RESUME_MODE resumeMode, 1257 __in BURN_RESUME_MODE resumeMode,
1247 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType, 1258 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
1248 __in BOOL fRestartInitiated 1259 __in BOOL fRestartInitiated
@@ -1254,7 +1265,7 @@ static HRESULT UpdateResumeMode(
1254 LPWSTR sczRunOnceCommandLine = NULL; 1265 LPWSTR sczRunOnceCommandLine = NULL;
1255 LPCWSTR sczResumeKey = REGISTRY_RUN_ONCE_KEY; 1266 LPCWSTR sczResumeKey = REGISTRY_RUN_ONCE_KEY;
1256 1267
1257 LogId(REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey, LoggingInstallScopeToString(pRegistration->fPerMachine), LoggingResumeModeToString(resumeMode), LoggingBoolToString(fRestartInitiated), LoggingBoolToString(pRegistration->fDisableResume)); 1268 LogId(REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey, LoggingInstallScopeToString(pRegistration->fPerMachine), LoggingResumeModeToString(resumeMode), LoggingBoolToString(fRestartInitiated), LoggingBoolToString(pRegistration->fDisableResume), LoggingRegistrationTypeToString(registrationType));
1258 1269
1259 // write resume information 1270 // write resume information
1260 if (hkRegistration) 1271 if (hkRegistration)
@@ -1776,7 +1787,6 @@ static HRESULT DetectInstalled(
1776 DWORD dwInstalled = 0; 1787 DWORD dwInstalled = 0;
1777 DWORD dwScope = 0; 1788 DWORD dwScope = 0;
1778 1789
1779 pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx(pRegistration->sczCacheExecutablePath, NULL);
1780 pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; 1790 pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
1781 pRegistration->detectedScope = BOOTSTRAPPER_SCOPE_DEFAULT; 1791 pRegistration->detectedScope = BOOTSTRAPPER_SCOPE_DEFAULT;
1782 1792
diff --git a/src/burn/engine/registration.h b/src/burn/engine/registration.h
index 97c6951b..050a1a4b 100644
--- a/src/burn/engine/registration.h
+++ b/src/burn/engine/registration.h
@@ -186,7 +186,8 @@ HRESULT RegistrationSetDynamicVariables(
186 __in BURN_VARIABLES* pVariables 186 __in BURN_VARIABLES* pVariables
187 ); 187 );
188HRESULT RegistrationDetectInstalled( 188HRESULT RegistrationDetectInstalled(
189 __in BURN_REGISTRATION* pRegistration 189 __in BURN_REGISTRATION* pRegistration,
190 __in BURN_CACHE* pCache
190 ); 191 );
191HRESULT RegistrationDetectResumeType( 192HRESULT RegistrationDetectResumeType(
192 __in BURN_REGISTRATION* pRegistration, 193 __in BURN_REGISTRATION* pRegistration,