@joebigelow / wix / commits / 6585189c

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.

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.

Sean Hall committed Apr 21, 2020 at 18:02 UTC 6585189c97d73dee54a490e1c98f1872f422f7c0
1 file changed +25 -11
src/wixstdba/WixStandardBootstrapperApplication.cpp
+25 -11
@@ -709,7 +709,9 @@ public: // IBootstrapperApplication
709 __inout BOOL* pfCancel
710 )
711 {
712 + HRESULT hr = S_OK;
713 LPWSTR sczFormattedString = NULL;
714 + BOOL fShowingInternalUiThisPackage = FALSE;
715
716 m_fStartedExecution = TRUE;
717
@@ -749,22 +751,23 @@ public: // IBootstrapperApplication
751 }
752
753 // Needs to match MsiEngineCalculateInstallUiLevel in msiengine.cpp in Burn.
752 - m_fShowingInternalUiThisPackage = pPackage && pPackage->fDisplayInternalUI &&
753 - BOOTSTRAPPER_ACTION_STATE_UNINSTALL != action &&
754 - BOOTSTRAPPER_ACTION_STATE_REPAIR != action &&
755 - (BOOTSTRAPPER_DISPLAY_FULL == m_command.display ||
756 - BOOTSTRAPPER_DISPLAY_PASSIVE == m_command.display);
754 + fShowingInternalUiThisPackage = pPackage && pPackage->fDisplayInternalUI &&
755 + BOOTSTRAPPER_ACTION_STATE_UNINSTALL != action &&
756 + BOOTSTRAPPER_ACTION_STATE_REPAIR != action &&
757 + (BOOTSTRAPPER_DISPLAY_FULL == m_command.display ||
758 + BOOTSTRAPPER_DISPLAY_PASSIVE == m_command.display);
759
760 ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_PACKAGE_TEXT, wz);
761 ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, wz);
762 }
761 - else
762 - {
763 - m_fShowingInternalUiThisPackage = FALSE;
764 - }
763 +
764 + ::EnterCriticalSection(&m_csShowingInternalUiThisPackage);
765 + m_fShowingInternalUiThisPackage = fShowingInternalUiThisPackage;
766 + hr = __super::OnExecutePackageBegin(wzPackageId, fExecute, action, pfCancel);
767 + ::LeaveCriticalSection(&m_csShowingInternalUiThisPackage);
768
769 ReleaseStr(sczFormattedString);
767 - return __super::OnExecutePackageBegin(wzPackageId, fExecute, action, pfCancel);
770 + return hr;
771 }
772
773
@@ -837,6 +840,7 @@ public: // IBootstrapperApplication
840 ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_ACTIONDATA_TEXT, L"");
841 ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, L"");
842 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, FALSE); // no more cancel.
843 + m_fShowingInternalUiThisPackage = FALSE;
844
845 SetState(WIXSTDBA_STATE_EXECUTED, S_OK); // we always return success here and let OnApplyComplete() deal with the error.
846 SetProgressState(hrStatus);
@@ -2975,7 +2979,14 @@ private: // privates
2979 }
2980 else // prompt the user or force the cancel if there is no UI.
2981 {
2978 - 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);
2982 + ::EnterCriticalSection(&m_csShowingInternalUiThisPackage);
2983 + fClose = PromptCancel(
2984 + m_hWnd,
2985 + BOOTSTRAPPER_DISPLAY_FULL != m_command.display || m_fShowingInternalUiThisPackage,
2986 + m_sczConfirmCloseMessage ? m_sczConfirmCloseMessage : L"Are you sure you want to cancel?",
2987 + m_pTheme->sczCaption);
2988 + ::LeaveCriticalSection(&m_csShowingInternalUiThisPackage);
2989 +
2990 fCancel = fClose;
2991 }
2992
@@ -3607,6 +3618,7 @@ public:
3618 m_pTaskbarList = NULL;
3619 m_uTaskbarButtonCreatedMessage = UINT_MAX;
3620 m_fTaskbarButtonOK = FALSE;
3621 + ::InitializeCriticalSection(&m_csShowingInternalUiThisPackage);
3622 m_fShowingInternalUiThisPackage = FALSE;
3623 m_fTriedToLaunchElevated = FALSE;
3624
@@ -3631,6 +3643,7 @@ public:
3643 AssertSz(!::IsWindow(m_hWnd), "Window should have been destroyed before destructor.");
3644 AssertSz(!m_pTheme, "Theme should have been released before destructor.");
3645
3646 + ::DeleteCriticalSection(&m_csShowingInternalUiThisPackage);
3647 ReleaseObject(m_pTaskbarList);
3648 ReleaseDict(m_sdOverridableVariables);
3649 ReleaseDict(m_shPrereqSupportPackages);
@@ -3713,6 +3726,7 @@ private:
3726 ITaskbarList3* m_pTaskbarList;
3727 UINT m_uTaskbarButtonCreatedMessage;
3728 BOOL m_fTaskbarButtonOK;
3729 + CRITICAL_SECTION m_csShowingInternalUiThisPackage;
3730 BOOL m_fShowingInternalUiThisPackage;
3731 BOOL m_fTriedToLaunchElevated;
3732