From 6585189c97d73dee54a490e1c98f1872f422f7c0 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 21 Apr 2020 18:02:51 +1000 Subject: WIXBUG:4342 - Force cancel if m_fShowingInternalUiThisPackage Add critical section for m_fShowingInternalUiThisPackage since OnExecutePackageBegin happens on the Burn thread and OnClose happens on the UI thread. --- .../WixStandardBootstrapperApplication.cpp | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/wixstdba/WixStandardBootstrapperApplication.cpp b/src/wixstdba/WixStandardBootstrapperApplication.cpp index e78b37b0..4aef8ce5 100644 --- a/src/wixstdba/WixStandardBootstrapperApplication.cpp +++ b/src/wixstdba/WixStandardBootstrapperApplication.cpp @@ -709,7 +709,9 @@ public: // IBootstrapperApplication __inout BOOL* pfCancel ) { + HRESULT hr = S_OK; LPWSTR sczFormattedString = NULL; + BOOL fShowingInternalUiThisPackage = FALSE; m_fStartedExecution = TRUE; @@ -749,22 +751,23 @@ public: // IBootstrapperApplication } // Needs to match MsiEngineCalculateInstallUiLevel in msiengine.cpp in Burn. - m_fShowingInternalUiThisPackage = pPackage && pPackage->fDisplayInternalUI && - BOOTSTRAPPER_ACTION_STATE_UNINSTALL != action && - BOOTSTRAPPER_ACTION_STATE_REPAIR != action && - (BOOTSTRAPPER_DISPLAY_FULL == m_command.display || - BOOTSTRAPPER_DISPLAY_PASSIVE == m_command.display); + fShowingInternalUiThisPackage = pPackage && pPackage->fDisplayInternalUI && + BOOTSTRAPPER_ACTION_STATE_UNINSTALL != action && + BOOTSTRAPPER_ACTION_STATE_REPAIR != action && + (BOOTSTRAPPER_DISPLAY_FULL == m_command.display || + BOOTSTRAPPER_DISPLAY_PASSIVE == m_command.display); ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_PACKAGE_TEXT, wz); ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, wz); } - else - { - m_fShowingInternalUiThisPackage = FALSE; - } + + ::EnterCriticalSection(&m_csShowingInternalUiThisPackage); + m_fShowingInternalUiThisPackage = fShowingInternalUiThisPackage; + hr = __super::OnExecutePackageBegin(wzPackageId, fExecute, action, pfCancel); + ::LeaveCriticalSection(&m_csShowingInternalUiThisPackage); ReleaseStr(sczFormattedString); - return __super::OnExecutePackageBegin(wzPackageId, fExecute, action, pfCancel); + return hr; } @@ -837,6 +840,7 @@ public: // IBootstrapperApplication ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_ACTIONDATA_TEXT, L""); ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, L""); ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, FALSE); // no more cancel. + m_fShowingInternalUiThisPackage = FALSE; SetState(WIXSTDBA_STATE_EXECUTED, S_OK); // we always return success here and let OnApplyComplete() deal with the error. SetProgressState(hrStatus); @@ -2975,7 +2979,14 @@ private: // privates } else // prompt the user or force the cancel if there is no UI. { - fClose = PromptCancel(m_hWnd, BOOTSTRAPPER_DISPLAY_FULL != m_command.display, m_sczConfirmCloseMessage ? m_sczConfirmCloseMessage : L"Are you sure you want to cancel?", m_pTheme->sczCaption); + ::EnterCriticalSection(&m_csShowingInternalUiThisPackage); + fClose = PromptCancel( + m_hWnd, + BOOTSTRAPPER_DISPLAY_FULL != m_command.display || m_fShowingInternalUiThisPackage, + m_sczConfirmCloseMessage ? m_sczConfirmCloseMessage : L"Are you sure you want to cancel?", + m_pTheme->sczCaption); + ::LeaveCriticalSection(&m_csShowingInternalUiThisPackage); + fCancel = fClose; } @@ -3607,6 +3618,7 @@ public: m_pTaskbarList = NULL; m_uTaskbarButtonCreatedMessage = UINT_MAX; m_fTaskbarButtonOK = FALSE; + ::InitializeCriticalSection(&m_csShowingInternalUiThisPackage); m_fShowingInternalUiThisPackage = FALSE; m_fTriedToLaunchElevated = FALSE; @@ -3631,6 +3643,7 @@ public: AssertSz(!::IsWindow(m_hWnd), "Window should have been destroyed before destructor."); AssertSz(!m_pTheme, "Theme should have been released before destructor."); + ::DeleteCriticalSection(&m_csShowingInternalUiThisPackage); ReleaseObject(m_pTaskbarList); ReleaseDict(m_sdOverridableVariables); ReleaseDict(m_shPrereqSupportPackages); @@ -3713,6 +3726,7 @@ private: ITaskbarList3* m_pTaskbarList; UINT m_uTaskbarButtonCreatedMessage; BOOL m_fTaskbarButtonOK; + CRITICAL_SECTION m_csShowingInternalUiThisPackage; BOOL m_fShowingInternalUiThisPackage; BOOL m_fTriedToLaunchElevated; -- cgit v1.2.3-55-g6feb