diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-12 20:51:23 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-14 12:15:52 -0700 |
| commit | 648133ee7f1206d1208630d5935a4846508fd5b9 (patch) | |
| tree | af8048aadc412188ae70d9d673233a2111cfed05 /src/engine | |
| parent | ad5aeb25c459196938cc88c404406bbbe1df9061 (diff) | |
| download | wix-648133ee7f1206d1208630d5935a4846508fd5b9.tar.gz wix-648133ee7f1206d1208630d5935a4846508fd5b9.tar.bz2 wix-648133ee7f1206d1208630d5935a4846508fd5b9.zip | |
Enhanced reboot pending detection
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/engine.mc | 6 | ||||
| -rw-r--r-- | src/engine/registration.cpp | 64 |
2 files changed, 69 insertions, 1 deletions
diff --git a/src/engine/engine.mc b/src/engine/engine.mc index a793540a..d0897a95 100644 --- a/src/engine/engine.mc +++ b/src/engine/engine.mc | |||
| @@ -1068,3 +1068,9 @@ Language=English | |||
| 1068 | Skipping MSI property '%1!ls!' because condition '%2!ls!' evaluates to %3!hs!. | 1068 | Skipping MSI property '%1!ls!' because condition '%2!ls!' evaluates to %3!hs!. |
| 1069 | . | 1069 | . |
| 1070 | 1070 | ||
| 1071 | MessageId=701 | ||
| 1072 | Severity=Warning | ||
| 1073 | SymbolicName=MSG_PENDING_REBOOT_DETECTED | ||
| 1074 | Language=English | ||
| 1075 | A reboot is pending from a prior execution of this bundle: %1!ls!. Apply will be blocked. Continuing... | ||
| 1076 | . | ||
diff --git a/src/engine/registration.cpp b/src/engine/registration.cpp index b8a2283f..9e27b177 100644 --- a/src/engine/registration.cpp +++ b/src/engine/registration.cpp | |||
| @@ -97,6 +97,7 @@ static BOOL IsWuRebootPending(); | |||
| 97 | static BOOL IsBundleRebootPending( | 97 | static BOOL IsBundleRebootPending( |
| 98 | __in BURN_REGISTRATION* pRegistration | 98 | __in BURN_REGISTRATION* pRegistration |
| 99 | ); | 99 | ); |
| 100 | static BOOL IsRegistryRebootPending(); | ||
| 100 | 101 | ||
| 101 | // function definitions | 102 | // function definitions |
| 102 | 103 | ||
| @@ -451,7 +452,7 @@ extern "C" HRESULT RegistrationSetVariables( | |||
| 451 | hr = VariableSetVersion(pVariables, BURN_BUNDLE_VERSION, pRegistration->pVersion, TRUE); | 452 | hr = VariableSetVersion(pVariables, BURN_BUNDLE_VERSION, pRegistration->pVersion, TRUE); |
| 452 | ExitOnFailure(hr, "Failed to overwrite the bundle version built-in variable."); | 453 | ExitOnFailure(hr, "Failed to overwrite the bundle version built-in variable."); |
| 453 | 454 | ||
| 454 | hr = VariableSetNumeric(pVariables, BURN_REBOOT_PENDING, IsBundleRebootPending(pRegistration) || IsWuRebootPending(), TRUE); | 455 | hr = VariableSetNumeric(pVariables, BURN_REBOOT_PENDING, IsBundleRebootPending(pRegistration) || IsWuRebootPending() || IsRegistryRebootPending(), TRUE); |
| 455 | ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); | 456 | ExitOnFailure(hr, "Failed to overwrite the bundle reboot-pending built-in variable."); |
| 456 | 457 | ||
| 457 | LExit: | 458 | LExit: |
| @@ -505,6 +506,8 @@ extern "C" HRESULT RegistrationDetectResumeType( | |||
| 505 | 506 | ||
| 506 | if (IsBundleRebootPending(pRegistration)) | 507 | if (IsBundleRebootPending(pRegistration)) |
| 507 | { | 508 | { |
| 509 | LogId(REPORT_STANDARD, MSG_PENDING_REBOOT_DETECTED, pRegistration->sczRegistrationKey); | ||
| 510 | |||
| 508 | *pResumeType = BOOTSTRAPPER_RESUME_TYPE_REBOOT_PENDING; | 511 | *pResumeType = BOOTSTRAPPER_RESUME_TYPE_REBOOT_PENDING; |
| 509 | ExitFunction1(hr = S_OK); | 512 | ExitFunction1(hr = S_OK); |
| 510 | } | 513 | } |
| @@ -1638,3 +1641,62 @@ LExit: | |||
| 1638 | 1641 | ||
| 1639 | return fBundleRebootPending; | 1642 | return fBundleRebootPending; |
| 1640 | } | 1643 | } |
| 1644 | |||
| 1645 | static BOOL IsRegistryRebootPending() | ||
| 1646 | { | ||
| 1647 | HRESULT hr = S_OK; | ||
| 1648 | DWORD dwValue; | ||
| 1649 | HKEY hk = NULL; | ||
| 1650 | BOOL fRebootPending = FALSE; | ||
| 1651 | |||
| 1652 | hr = RegKeyReadNumber(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\ServerManager", L"CurrentRebootAttempts", TRUE, &dwValue); | ||
| 1653 | fRebootPending = SUCCEEDED(hr) && 0 < dwValue; | ||
| 1654 | |||
| 1655 | if (!fRebootPending) | ||
| 1656 | { | ||
| 1657 | hr = RegKeyReadNumber(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Updates", L"UpdateExeVolatile", TRUE, &dwValue); | ||
| 1658 | fRebootPending = SUCCEEDED(hr) && 0 < dwValue; | ||
| 1659 | |||
| 1660 | if (!fRebootPending) | ||
| 1661 | { | ||
| 1662 | fRebootPending = RegValueExists(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\RebootPending", NULL, TRUE); | ||
| 1663 | |||
| 1664 | if (!fRebootPending) | ||
| 1665 | { | ||
| 1666 | fRebootPending = RegValueExists(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\RebootInProgress", NULL, TRUE); | ||
| 1667 | |||
| 1668 | if (!fRebootPending) | ||
| 1669 | { | ||
| 1670 | hr = RegKeyReadNumber(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update", L"AUState", TRUE, &dwValue); | ||
| 1671 | fRebootPending = SUCCEEDED(hr) && 8 == dwValue; | ||
| 1672 | |||
| 1673 | if (!fRebootPending) | ||
| 1674 | { | ||
| 1675 | fRebootPending = RegValueExists(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager", L"PendingFileRenameOperations", TRUE); | ||
| 1676 | |||
| 1677 | if (!fRebootPending) | ||
| 1678 | { | ||
| 1679 | fRebootPending = RegValueExists(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager", L"PendingFileRenameOperations2", TRUE); | ||
| 1680 | |||
| 1681 | if (!fRebootPending) | ||
| 1682 | { | ||
| 1683 | hr = RegOpen(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\FileRenameOperations", KEY_READ | KEY_WOW64_64KEY, &hk); | ||
| 1684 | if (SUCCEEDED(hr)) | ||
| 1685 | { | ||
| 1686 | DWORD cSubKeys = 0; | ||
| 1687 | DWORD cValues = 0; | ||
| 1688 | hr = RegQueryKey(hk, &cSubKeys, &cValues); | ||
| 1689 | fRebootPending = SUCCEEDED(hr) && (0 < cSubKeys || 0 < cValues); | ||
| 1690 | } | ||
| 1691 | } | ||
| 1692 | } | ||
| 1693 | } | ||
| 1694 | } | ||
| 1695 | } | ||
| 1696 | } | ||
| 1697 | } | ||
| 1698 | |||
| 1699 | ReleaseRegKey(hk); | ||
| 1700 | |||
| 1701 | return fRebootPending; | ||
| 1702 | } | ||
