From 29f7e00586412163a20e298fbf84505f8a917425 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 May 2022 15:30:50 -0500 Subject: Only block shutdown during Apply. --- .../inc/BootstrapperApplication.h | 13 -------- .../WixToolset.Mba.Core/BootstrapperApplication.cs | 38 ---------------------- src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 26 --------------- .../IBootstrapperApplication.cs | 13 -------- .../IDefaultBootstrapperApplication.cs | 16 --------- src/api/burn/balutil/inc/BAFunctions.h | 1 - src/api/burn/balutil/inc/BalBaseBAFunctions.h | 8 ----- src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h | 1 - .../balutil/inc/BalBaseBootstrapperApplication.h | 19 ----------- .../inc/BalBaseBootstrapperApplicationProc.h | 12 ------- .../burn/balutil/inc/IBootstrapperApplication.h | 6 ---- 11 files changed, 153 deletions(-) (limited to 'src/api') diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h index f0b5dad4..228cb6ff 100644 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h @@ -149,7 +149,6 @@ enum BOOTSTRAPPER_APPLICATION_MESSAGE BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, @@ -1463,18 +1462,6 @@ struct BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS DWORD cbSize; }; -struct BA_ONSYSTEMSHUTDOWN_ARGS -{ - DWORD cbSize; - DWORD dwEndSession; -}; - -struct BA_ONSYSTEMSHUTDOWN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - struct BA_ONUNREGISTERBEGIN_ARGS { DWORD cbSize; diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index 6738a4a6..bb34a33e 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -22,15 +22,12 @@ namespace WixToolset.Mba.Core /// protected readonly IEngine engine; - private bool applying; - /// /// Creates a new instance of the class. /// protected BootstrapperApplication(IEngine engine) { this.engine = engine; - this.applying = false; this.asyncExecution = true; } @@ -40,9 +37,6 @@ namespace WixToolset.Mba.Core /// public event EventHandler Shutdown; - /// - public event EventHandler SystemShutdown; - /// public event EventHandler DetectBegin; @@ -331,25 +325,6 @@ namespace WixToolset.Mba.Core } } - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSystemShutdown(SystemShutdownEventArgs args) - { - EventHandler handler = this.SystemShutdown; - if (null != handler) - { - handler(this, args); - } - else if (null != args) - { - // Allow requests to shut down when critical or not applying. - bool critical = EndSessionReasons.Critical == (EndSessionReasons.Critical & args.Reasons); - args.Cancel = !critical && this.applying; - } - } - /// /// Called by the engine, raises the event. /// @@ -1433,15 +1408,6 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnSystemShutdown(EndSessionReasons dwEndSession, ref bool fCancel) - { - SystemShutdownEventArgs args = new SystemShutdownEventArgs(dwEndSession, fCancel); - this.OnSystemShutdown(args); - - fCancel = args.Cancel; - return args.HResult; - } - int IBootstrapperApplication.OnDetectBegin(bool fCached, RegistrationType registrationType, int cPackages, ref bool fCancel) { DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, registrationType, cPackages, fCancel); @@ -1693,8 +1659,6 @@ namespace WixToolset.Mba.Core int IBootstrapperApplication.OnApplyBegin(int dwPhaseCount, ref bool fCancel) { - this.applying = true; - ApplyBeginEventArgs args = new ApplyBeginEventArgs(dwPhaseCount, fCancel); this.OnApplyBegin(args); @@ -1949,8 +1913,6 @@ namespace WixToolset.Mba.Core ApplyCompleteEventArgs args = new ApplyCompleteEventArgs(hrStatus, restart, recommendation, pAction); this.OnApplyComplete(args); - this.applying = false; - pAction = args.Action; return args.HResult; } diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index d79ac402..be113700 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -216,32 +216,6 @@ namespace WixToolset.Mba.Core public BOOTSTRAPPER_SHUTDOWN_ACTION Action { get; set; } } - /// - /// Event arguments for - /// - [Serializable] - public class SystemShutdownEventArgs : CancellableHResultEventArgs - { - /// - public SystemShutdownEventArgs(EndSessionReasons reasons, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.Reasons = reasons; - } - - /// - /// Gets the reason the application is requested to close or being closed. - /// - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// - public EndSessionReasons Reasons { get; private set; } - } - /// /// Event arguments for /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs index 2877d4de..8ce99808 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -50,19 +50,6 @@ namespace WixToolset.Mba.Core [return: MarshalAs(UnmanagedType.I4)] int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSystemShutdown( - [MarshalAs(UnmanagedType.U4)] EndSessionReasons dwEndSession, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - /// /// See . /// diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 77089e83..2535f756 100644 --- a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -418,22 +418,6 @@ namespace WixToolset.Mba.Core /// event EventHandler SystemRestorePointComplete; - /// - /// Fired when the system is shutting down or user is logging off. - /// - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// By default setup will prevent shutting down or logging off between - /// and . - /// Derivatives can change this behavior by handling . - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// This event may be fired on a different thread. - /// - event EventHandler SystemShutdown; - /// /// Fired when the engine unregisters the bundle. /// diff --git a/src/api/burn/balutil/inc/BAFunctions.h b/src/api/burn/balutil/inc/BAFunctions.h index 9be3f62f..c1057ab6 100644 --- a/src/api/burn/balutil/inc/BAFunctions.h +++ b/src/api/burn/balutil/inc/BAFunctions.h @@ -15,7 +15,6 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, BA_FUNCTIONS_MESSAGE_ONSTARTUP = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, BA_FUNCTIONS_MESSAGE_ONSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, - BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN, BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h index 9ff58d2b..ca070553 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctions.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h @@ -98,14 +98,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnSystemShutdown( - __in DWORD /*dwEndSession*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - virtual STDMETHODIMP OnDetectBegin( __in BOOL /*fCached*/, __in BOOTSTRAPPER_REGISTRATION_TYPE /*registrationType*/, diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h index 4564ad0c..ff92717d 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h @@ -86,7 +86,6 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE: case BA_FUNCTIONS_MESSAGE_ONSTARTUP: case BA_FUNCTIONS_MESSAGE_ONSHUTDOWN: - case BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN: case BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN: case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE: diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h index 2e848df7..fc9c4dd7 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h @@ -94,19 +94,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnSystemShutdown( - __in DWORD dwEndSession, - __inout BOOL* pfCancel - ) - { - HRESULT hr = S_OK; - - // Allow requests to shut down when critical or not applying. - *pfCancel = !(ENDSESSION_CRITICAL & dwEndSession || !m_fApplying); - - return hr; - } - virtual STDMETHODIMP OnDetectBegin( __in BOOL /*fCached*/, __in BOOTSTRAPPER_REGISTRATION_TYPE /*registrationType*/, @@ -406,8 +393,6 @@ public: // IBootstrapperApplication __inout BOOL* pfCancel ) { - m_fApplying = TRUE; - m_dwProgressPercentage = 0; m_dwOverallProgressPercentage = 0; @@ -859,8 +844,6 @@ public: // IBootstrapperApplication *pAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART; } - m_fApplying = FALSE; - return hr; } @@ -1183,7 +1166,6 @@ protected: ::InitializeCriticalSection(&m_csCanceled); m_fCanceled = FALSE; m_BalInfoCommand = { }; - m_fApplying = FALSE; m_fRollingBack = FALSE; m_dwProgressPercentage = 0; @@ -1212,7 +1194,6 @@ private: BOOTSTRAPPER_DISPLAY m_display; IBootstrapperEngine* m_pEngine; - BOOL m_fApplying; BOOL m_fRollingBack; DWORD m_dwProgressPercentage; diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h index e35678ad..92243540 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -63,15 +63,6 @@ static HRESULT BalBaseBAProcOnShutdown( return pBA->OnShutdown(&pResults->action); } -static HRESULT BalBaseBAProcOnSystemShutdown( - __in IBootstrapperApplication* pBA, - __in BA_ONSYSTEMSHUTDOWN_ARGS* pArgs, - __inout BA_ONSYSTEMSHUTDOWN_RESULTS* pResults - ) -{ - return pBA->OnSystemShutdown(pArgs->dwEndSession, &pResults->fCancel); -} - static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( __in IBootstrapperApplication* pBA, __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, @@ -803,9 +794,6 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN: hr = BalBaseBAProcOnShutdown(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN: - hr = BalBaseBAProcOnSystemShutdown(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: hr = BalBaseBAProcOnDetectForwardCompatibleBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; diff --git a/src/api/burn/balutil/inc/IBootstrapperApplication.h b/src/api/burn/balutil/inc/IBootstrapperApplication.h index 6eca90fa..382d5aad 100644 --- a/src/api/burn/balutil/inc/IBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/IBootstrapperApplication.h @@ -33,12 +33,6 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction ) = 0; - // OnSystemShutdown - called when the operating system is instructed to shutdown the machine. - STDMETHOD(OnSystemShutdown)( - __in DWORD dwEndSession, - __inout BOOL* pfCancel - ) = 0; - // OnDetectBegin - called when the engine begins detection. STDMETHOD(OnDetectBegin)( __in BOOL fCached, -- cgit v1.2.3-55-g6feb