aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/registration.cpp
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/registration.cpp
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/registration.cpp')
-rw-r--r--src/burn/engine/registration.cpp38
1 files changed, 24 insertions, 14 deletions
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