aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-09-02 16:12:42 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-09-03 15:29:26 -0500
commit237bdc6a97c0dd455da99c16e6b3b7cac4c79e86 (patch)
tree1f2c789a7aa752e068fac8a4ca08815d13bf527a /src/ext/Bal
parent7728e34e48a4fdb710ecc92dd8dca833bff3993f (diff)
downloadwix-237bdc6a97c0dd455da99c16e6b3b7cac4c79e86.tar.gz
wix-237bdc6a97c0dd455da99c16e6b3b7cac4c79e86.tar.bz2
wix-237bdc6a97c0dd455da99c16e6b3b7cac4c79e86.zip
Add WixCanRestart and make wixstdba elevate for restart when required.
Fixes 5499
Diffstat (limited to 'src/ext/Bal')
-rw-r--r--src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp63
1 files changed, 56 insertions, 7 deletions
diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
index 8c4b0b35..50de2c7f 100644
--- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
@@ -4,6 +4,7 @@
4#include "BalBaseBootstrapperApplicationProc.h" 4#include "BalBaseBootstrapperApplicationProc.h"
5#include "BalBaseBootstrapperApplication.h" 5#include "BalBaseBootstrapperApplication.h"
6 6
7static const LPCWSTR WIXBUNDLE_VARIABLE_CANRESTART = L"WixCanRestart";
7static const LPCWSTR WIXBUNDLE_VARIABLE_ELEVATED = L"WixBundleElevated"; 8static const LPCWSTR WIXBUNDLE_VARIABLE_ELEVATED = L"WixBundleElevated";
8 9
9static const LPCWSTR WIXSTDBA_WINDOW_CLASS = L"WixStdBA"; 10static const LPCWSTR WIXSTDBA_WINDOW_CLASS = L"WixStdBA";
@@ -1289,6 +1290,28 @@ public: // IBootstrapperApplication
1289 return S_OK; 1290 return S_OK;
1290 } 1291 }
1291 1292
1293
1294 virtual STDMETHODIMP OnElevateComplete(
1295 __in HRESULT hrStatus
1296 )
1297 {
1298 if (m_fElevatingForRestart)
1299 {
1300 m_fElevatingForRestart = FALSE;
1301
1302 if (SUCCEEDED(hrStatus))
1303 {
1304 m_fAllowRestart = TRUE;
1305
1306 ::SendMessageW(m_hWnd, WM_CLOSE, 0, 0);
1307 }
1308 // else if failed then OnError showed the user an error message box
1309 }
1310
1311 return __super::OnElevateComplete(hrStatus);
1312 }
1313
1314
1292 virtual STDMETHODIMP_(void) BAProcFallback( 1315 virtual STDMETHODIMP_(void) BAProcFallback(
1293 __in BOOTSTRAPPER_APPLICATION_MESSAGE message, 1316 __in BOOTSTRAPPER_APPLICATION_MESSAGE message,
1294 __in const LPVOID pvArgs, 1317 __in const LPVOID pvArgs,
@@ -3734,14 +3757,16 @@ private:
3734 3757
3735 if (dwOldPageId != dwNewPageId) 3758 if (dwOldPageId != dwNewPageId)
3736 { 3759 {
3760 LONGLONG llCanRestart = 0;
3761 LONGLONG llElevated = 0;
3762
3763 BalGetNumericVariable(WIXBUNDLE_VARIABLE_CANRESTART, &llCanRestart);
3764 BalGetNumericVariable(WIXBUNDLE_VARIABLE_ELEVATED, &llElevated);
3765 m_fRestartRequiresElevation = !llCanRestart && !llElevated;
3766
3737 // Enable disable controls per-page. 3767 // Enable disable controls per-page.
3738 if (m_rgdwPageIds[WIXSTDBA_PAGE_INSTALL] == dwNewPageId) // on the "Install" page, ensure the install button is enabled/disabled correctly. 3768 if (m_rgdwPageIds[WIXSTDBA_PAGE_INSTALL] == dwNewPageId) // on the "Install" page, ensure the install button is enabled/disabled correctly.
3739 { 3769 {
3740 LONGLONG llElevated = 0;
3741 if (m_Bundle.fPerMachine)
3742 {
3743 BalGetNumericVariable(WIXBUNDLE_VARIABLE_ELEVATED, &llElevated);
3744 }
3745 ThemeControlElevates(m_pControlInstallButton, (m_Bundle.fPerMachine && !llElevated)); 3770 ThemeControlElevates(m_pControlInstallButton, (m_Bundle.fPerMachine && !llElevated));
3746 3771
3747 // If the EULA control exists, show it only if a license URL is provided as well. 3772 // If the EULA control exists, show it only if a license URL is provided as well.
@@ -3757,12 +3782,18 @@ private:
3757 } 3782 }
3758 else if (m_rgdwPageIds[WIXSTDBA_PAGE_MODIFY] == dwNewPageId) 3783 else if (m_rgdwPageIds[WIXSTDBA_PAGE_MODIFY] == dwNewPageId)
3759 { 3784 {
3785 ThemeControlElevates(m_pControlRepairButton, (m_Bundle.fPerMachine && !llElevated));
3786 ThemeControlElevates(m_pControlUninstallButton, (m_Bundle.fPerMachine && !llElevated));
3787
3760 ThemeControlEnable(m_pControlRepairButton, !m_fSuppressRepair); 3788 ThemeControlEnable(m_pControlRepairButton, !m_fSuppressRepair);
3761 } 3789 }
3762 else if (m_rgdwPageIds[WIXSTDBA_PAGE_SUCCESS] == dwNewPageId) // on the "Success" page, check if the restart or launch button should be enabled. 3790 else if (m_rgdwPageIds[WIXSTDBA_PAGE_SUCCESS] == dwNewPageId) // on the "Success" page, check if the restart or launch button should be enabled.
3763 { 3791 {
3764 BOOL fEnableRestartButton = FALSE; 3792 BOOL fEnableRestartButton = FALSE;
3765 BOOL fLaunchTargetExists = FALSE; 3793 BOOL fLaunchTargetExists = FALSE;
3794
3795 ThemeControlElevates(m_pControlSuccessRestartButton, m_fRestartRequiresElevation);
3796
3766 if (m_fShouldRestart) 3797 if (m_fShouldRestart)
3767 { 3798 {
3768 if (BAL_INFO_RESTART_PROMPT == m_BalInfoCommand.restart) 3799 if (BAL_INFO_RESTART_PROMPT == m_BalInfoCommand.restart)
@@ -3784,6 +3815,8 @@ private:
3784 BOOL fShowErrorMessage = FALSE; 3815 BOOL fShowErrorMessage = FALSE;
3785 BOOL fEnableRestartButton = FALSE; 3816 BOOL fEnableRestartButton = FALSE;
3786 3817
3818 ThemeControlElevates(m_pControlFailureRestartButton, m_fRestartRequiresElevation);
3819
3787 if (FAILED(m_hrFinal)) 3820 if (FAILED(m_hrFinal))
3788 { 3821 {
3789 // If we know the failure message, use that. 3822 // If we know the failure message, use that.
@@ -4156,8 +4189,20 @@ private:
4156 { 4189 {
4157 AssertSz(m_fRestartRequired, "Restart must be requested to be able to click on the restart button."); 4190 AssertSz(m_fRestartRequired, "Restart must be requested to be able to click on the restart button.");
4158 4191
4159 m_fAllowRestart = TRUE; 4192 if (m_fRestartRequiresElevation)
4160 ::SendMessageW(m_hWnd, WM_CLOSE, 0, 0); 4193 {
4194 m_fElevatingForRestart = TRUE;
4195 ThemeControlEnable(m_pControlFailureRestartButton, FALSE);
4196 ThemeControlEnable(m_pControlSuccessRestartButton, FALSE);
4197
4198 m_pEngine->Elevate(m_hWnd);
4199 }
4200 else
4201 {
4202 m_fAllowRestart = TRUE;
4203
4204 ::SendMessageW(m_hWnd, WM_CLOSE, 0, 0);
4205 }
4161 } 4206 }
4162 4207
4163 4208
@@ -4649,6 +4694,8 @@ public:
4649 m_fRestartRequired = FALSE; 4694 m_fRestartRequired = FALSE;
4650 m_fShouldRestart = FALSE; 4695 m_fShouldRestart = FALSE;
4651 m_fAllowRestart = FALSE; 4696 m_fAllowRestart = FALSE;
4697 m_fRestartRequiresElevation = FALSE;
4698 m_fElevatingForRestart = FALSE;
4652 4699
4653 m_sczLicenseFile = NULL; 4700 m_sczLicenseFile = NULL;
4654 m_sczLicenseUrl = NULL; 4701 m_sczLicenseUrl = NULL;
@@ -4956,6 +5003,8 @@ private:
4956 BOOL m_fRestartRequired; 5003 BOOL m_fRestartRequired;
4957 BOOL m_fShouldRestart; 5004 BOOL m_fShouldRestart;
4958 BOOL m_fAllowRestart; 5005 BOOL m_fAllowRestart;
5006 BOOL m_fRestartRequiresElevation;
5007 BOOL m_fElevatingForRestart;
4959 5008
4960 LPWSTR m_sczLicenseFile; 5009 LPWSTR m_sczLicenseFile;
4961 LPWSTR m_sczLicenseUrl; 5010 LPWSTR m_sczLicenseUrl;