diff options
| author | Bob Arnson <bob@firegiant.com> | 2026-02-10 20:33:03 -0500 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2026-02-10 20:33:03 -0500 |
| commit | 702b38fe565781f3bfc5b1d92a3404b535ace2a1 (patch) | |
| tree | 1eb70c137c84ae7c9d8c73370c7e39b4cf76a377 /src/burn/engine/registration.cpp | |
| parent | cd5f73d939b6d91ce3d9efcc5b8a800542041698 (diff) | |
| download | wix-702b38fe565781f3bfc5b1d92a3404b535ace2a1.tar.gz wix-702b38fe565781f3bfc5b1d92a3404b535ace2a1.tar.bz2 wix-702b38fe565781f3bfc5b1d92a3404b535ace2a1.zip | |
Log detected package scope and lock bundle scope.bob/BurnScopeDetect
- Fixes https://github.com/wixtoolset/issues/issues/9232
- Fixes https://github.com/wixtoolset/issues/issues/9240
Diffstat (limited to 'src/burn/engine/registration.cpp')
| -rw-r--r-- | src/burn/engine/registration.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index fa1b024a..e588bef0 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp | |||
| @@ -29,6 +29,7 @@ const LPCWSTR REGISTRY_BUNDLE_UNINSTALL_STRING = L"UninstallString"; | |||
| 29 | const LPCWSTR REGISTRY_BUNDLE_RESUME_COMMAND_LINE = L"BundleResumeCommandLine"; | 29 | const LPCWSTR REGISTRY_BUNDLE_RESUME_COMMAND_LINE = L"BundleResumeCommandLine"; |
| 30 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MAJOR = L"VersionMajor"; | 30 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MAJOR = L"VersionMajor"; |
| 31 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MINOR = L"VersionMinor"; | 31 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MINOR = L"VersionMinor"; |
| 32 | const LPCWSTR REGISTRY_BUNDLE_SCOPE = L"BundleScope"; | ||
| 32 | const LPCWSTR SWIDTAG_FOLDER = L"swidtag"; | 33 | const LPCWSTR SWIDTAG_FOLDER = L"swidtag"; |
| 33 | const LPCWSTR REGISTRY_BUNDLE_VARIABLE_KEY = L"variables"; | 34 | const LPCWSTR REGISTRY_BUNDLE_VARIABLE_KEY = L"variables"; |
| 34 | 35 | ||
| @@ -303,6 +304,10 @@ extern "C" HRESULT RegistrationParseFromXml( | |||
| 303 | pRegistration->hkRoot = reinterpret_cast<HKEY>(0ull); | 304 | pRegistration->hkRoot = reinterpret_cast<HKEY>(0ull); |
| 304 | } | 305 | } |
| 305 | 306 | ||
| 307 | // build uninstall registry key path | ||
| 308 | hr = StrAllocFormatted(&pRegistration->sczRegistrationKey, L"%ls\\%ls", BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY, pRegistration->sczCode); | ||
| 309 | ExitOnFailure(hr, "Failed to build uninstall registry key path."); | ||
| 310 | |||
| 306 | LExit: | 311 | LExit: |
| 307 | ReleaseObject(pixnRegistrationNode); | 312 | ReleaseObject(pixnRegistrationNode); |
| 308 | ReleaseObject(pixnArpNode); | 313 | ReleaseObject(pixnArpNode); |
| @@ -458,6 +463,9 @@ extern "C" HRESULT RegistrationSetDynamicVariables( | |||
| 458 | hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE); | 463 | hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE); |
| 459 | ExitOnFailure(hr, "Failed to set the bundle installed built-in variable."); | 464 | ExitOnFailure(hr, "Failed to set the bundle installed built-in variable."); |
| 460 | 465 | ||
| 466 | hr = VariableSetNumeric(pVariables, BURN_BUNDLE_DETECTED_SCOPE, pRegistration->detectedScope, TRUE); | ||
| 467 | ExitOnFailure(hr, "Failed to set the bundle detected scope built-in variable."); | ||
| 468 | |||
| 461 | hr = VariableSetNumeric(pVariables, VARIABLE_REBOOTPENDING, IsWuRebootPending() || IsRegistryRebootPending(), TRUE); | 469 | hr = VariableSetNumeric(pVariables, VARIABLE_REBOOTPENDING, IsWuRebootPending() || IsRegistryRebootPending(), TRUE); |
| 462 | ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); | 470 | ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); |
| 463 | 471 | ||
| @@ -479,16 +487,20 @@ extern "C" HRESULT RegistrationDetectInstalled( | |||
| 479 | { | 487 | { |
| 480 | // For PUOM/PMOU bundles, check per-machine then fall back to per-user. | 488 | // For PUOM/PMOU bundles, check per-machine then fall back to per-user. |
| 481 | hr = DetectInstalled(pRegistration, HKEY_LOCAL_MACHINE); | 489 | hr = DetectInstalled(pRegistration, HKEY_LOCAL_MACHINE); |
| 482 | ExitOnFailure(hr, "Failed to detect HKEY_LOCAL_MACHINE bundle registration install state."); | ||
| 483 | 490 | ||
| 484 | if (BOOTSTRAPPER_REGISTRATION_TYPE_NONE == pRegistration->detectedRegistrationType) | 491 | if (FAILED(hr)) |
| 485 | { | 492 | { |
| 486 | hr = DetectInstalled(pRegistration, HKEY_CURRENT_USER); | 493 | hr = DetectInstalled(pRegistration, HKEY_CURRENT_USER); |
| 487 | ExitOnFailure(hr, "Failed to detect HKEY_CURRENT_USER bundle registration install state."); | ||
| 488 | } | 494 | } |
| 489 | } | 495 | } |
| 490 | 496 | ||
| 491 | LExit: | 497 | //LExit: |
| 498 | // Not finding the key or value is okay. | ||
| 499 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) | ||
| 500 | { | ||
| 501 | hr = S_OK; | ||
| 502 | } | ||
| 503 | |||
| 492 | return hr; | 504 | return hr; |
| 493 | } | 505 | } |
| 494 | 506 | ||
| @@ -654,6 +666,9 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
| 654 | hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath); | 666 | hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_DISPLAY_ICON, L"%s,0", pRegistration->sczCacheExecutablePath); |
| 655 | ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON); | 667 | ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_DISPLAY_ICON); |
| 656 | 668 | ||
| 669 | hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_SCOPE, pRegistration->fPerMachine ? BOOTSTRAPPER_SCOPE_PER_MACHINE : BOOTSTRAPPER_SCOPE_PER_USER); | ||
| 670 | ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_SCOPE); | ||
| 671 | |||
| 657 | // update display name | 672 | // update display name |
| 658 | hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType); | 673 | hr = UpdateBundleNameRegistration(pRegistration, pVariables, hkRegistration, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS == registrationType); |
| 659 | ExitOnFailure(hr, "Failed to update name and publisher."); | 674 | ExitOnFailure(hr, "Failed to update name and publisher."); |
| @@ -1054,10 +1069,6 @@ extern "C" HRESULT RegistrationSetPaths( | |||
| 1054 | // save registration key root | 1069 | // save registration key root |
| 1055 | pRegistration->hkRoot = pRegistration->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 1070 | pRegistration->hkRoot = pRegistration->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 1056 | 1071 | ||
| 1057 | // build uninstall registry key path | ||
| 1058 | hr = StrAllocFormatted(&pRegistration->sczRegistrationKey, L"%ls\\%ls", BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY, pRegistration->sczCode); | ||
| 1059 | ExitOnFailure(hr, "Failed to build uninstall registry key path."); | ||
| 1060 | |||
| 1061 | // build cache directory | 1072 | // build cache directory |
| 1062 | hr = CacheGetCompletedPath(pCache, pRegistration->fPerMachine, pRegistration->sczCode, &sczCacheDirectory); | 1073 | hr = CacheGetCompletedPath(pCache, pRegistration->fPerMachine, pRegistration->sczCode, &sczCacheDirectory); |
| 1063 | ExitOnFailure(hr, "Failed to build cache directory."); | 1074 | ExitOnFailure(hr, "Failed to build cache directory."); |
| @@ -1754,25 +1765,28 @@ static HRESULT DetectInstalled( | |||
| 1754 | HRESULT hr = S_OK; | 1765 | HRESULT hr = S_OK; |
| 1755 | HKEY hkRegistration = NULL; | 1766 | HKEY hkRegistration = NULL; |
| 1756 | DWORD dwInstalled = 0; | 1767 | DWORD dwInstalled = 0; |
| 1768 | DWORD dwScope = 0; | ||
| 1757 | 1769 | ||
| 1758 | pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx(pRegistration->sczCacheExecutablePath, NULL); | 1770 | pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx(pRegistration->sczCacheExecutablePath, NULL); |
| 1759 | pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; | 1771 | pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; |
| 1772 | pRegistration->detectedScope = BOOTSTRAPPER_SCOPE_DEFAULT; | ||
| 1760 | 1773 | ||
| 1761 | // open registration key | 1774 | // open registration key |
| 1762 | hr = RegOpen(hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration); | 1775 | hr = RegOpen(hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration); |
| 1763 | if (SUCCEEDED(hr)) | 1776 | if (SUCCEEDED(hr)) |
| 1764 | { | 1777 | { |
| 1765 | hr = RegReadNumber(hkRegistration, REGISTRY_BUNDLE_INSTALLED, &dwInstalled); | 1778 | hr = RegReadNumber(hkRegistration, REGISTRY_BUNDLE_INSTALLED, &dwInstalled); |
| 1779 | ExitOnFailure(hr, "Failed to read registration %ls@%ls.", pRegistration->sczRegistrationKey, REGISTRY_BUNDLE_INSTALLED); | ||
| 1766 | 1780 | ||
| 1767 | pRegistration->detectedRegistrationType = (1 == dwInstalled) ? BOOTSTRAPPER_REGISTRATION_TYPE_FULL : BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS; | 1781 | pRegistration->detectedRegistrationType = (1 == dwInstalled) ? BOOTSTRAPPER_REGISTRATION_TYPE_FULL : BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS; |
| 1768 | } | ||
| 1769 | 1782 | ||
| 1770 | // Not finding the key or value is okay. | 1783 | hr = RegReadNumber(hkRegistration, REGISTRY_BUNDLE_SCOPE, &dwScope); |
| 1771 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) | 1784 | ExitOnFailure(hr, "Failed to read registration %ls@%ls.", pRegistration->sczRegistrationKey, REGISTRY_BUNDLE_SCOPE); |
| 1772 | { | 1785 | |
| 1773 | hr = S_OK; | 1786 | pRegistration->detectedScope = static_cast<BOOTSTRAPPER_SCOPE>(dwScope); |
| 1774 | } | 1787 | } |
| 1775 | 1788 | ||
| 1789 | LExit: | ||
| 1776 | ReleaseRegKey(hkRegistration); | 1790 | ReleaseRegKey(hkRegistration); |
| 1777 | 1791 | ||
| 1778 | return hr; | 1792 | return hr; |
