From ca5d60d267051b4b75e22763ad8eda06f0501451 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 2 Dec 2020 22:38:23 -0600 Subject: WIXFEAT:4626,5386 - Add more BA events. OnBeginMsiTransactionBegin, OnBeginMsiTransactionComplete, OnCommitMsiTransactionBegin, OnCommitMsiTransactionComplete, OnRollbackMsiTransactionBegin, OnRollbackMsiTransactionComplete, OnPauseAutomaticUpdatesBegin, OnPauseAutomaticUpdatesComplete, OnSystemRestorePointBegin, OnSystemRestorePointComplete --- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BAFunctions.h | 10 ++ src/balutil/inc/BalBaseBAFunctions.h | 73 +++++++++++++ src/balutil/inc/BalBaseBAFunctionsProc.h | 10 ++ src/balutil/inc/BalBaseBootstrapperApplication.h | 75 +++++++++++++ .../inc/BalBaseBootstrapperApplicationProc.h | 119 +++++++++++++++++++++ src/balutil/inc/IBootstrapperApplication.h | 43 ++++++++ src/balutil/packages.config | 4 +- 8 files changed, 336 insertions(+), 6 deletions(-) (limited to 'src/balutil') diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index d35a7a77..4793770a 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 8101afdb..a95b7a03 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -65,6 +65,16 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, + BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, + BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 72edadd5..39934128 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -612,6 +612,79 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnBeginMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index f6ebd9f6..69843301 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -100,6 +100,16 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + case BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + case BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + case BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); break; case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 612faf54..ad0c60e5 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -798,6 +798,81 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnBeginMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 7d5de8e4..648252b5 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -513,6 +513,96 @@ static HRESULT BalBaseBAProcOnPlanMsiPackage( return pBA->OnPlanMsiPackage(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler); } +static HRESULT BalBaseBAProcOnBeginMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONBEGINMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBA->OnBeginMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnBeginMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnBeginMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnCommitMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBA->OnCommitMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnCommitMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnRollbackMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnRollbackMsiTransactionBegin(pArgs->wzTransactionId); +} + +static HRESULT BalBaseBAProcOnRollbackMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS* /*pArgs*/, + __inout BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnPauseAutomaticUpdatesBegin(); +} + +static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS* pArgs, + __inout BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnPauseAutomaticUpdatesComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnSystemRestorePointBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS* /*pArgs*/, + __inout BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnSystemRestorePointBegin(); +} + +static HRESULT BalBaseBAProcOnSystemRestorePointComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS* pArgs, + __inout BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnSystemRestorePointComplete(pArgs->hrStatus); +} + /******************************************************************* BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. Provides a default mapping between the new message based BA interface and @@ -701,6 +791,35 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE: hr = BalBaseBAProcOnPlanMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + hr = BalBaseBAProcOnBeginMsiTransactionBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + hr = BalBaseBAProcOnBeginMsiTransactionComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + hr = BalBaseBAProcOnCommitMsiTransactionBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + hr = BalBaseBAProcOnCommitMsiTransactionComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + hr = BalBaseBAProcOnRollbackMsiTransactionBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + hr = BalBaseBAProcOnRollbackMsiTransactionComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + hr = BalBaseBAProcOnPauseAutomaticUpdatesBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + hr = BalBaseBAProcOnPauseAutomaticUpdatesComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + hr = BalBaseBAProcOnSystemRestorePointBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: + hr = BalBaseBAProcOnSystemRestorePointComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; } } diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 75ea7bc9..dd8f8024 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -518,6 +518,49 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in DWORD dwProcessId ) = 0; + STDMETHOD(OnBeginMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnBeginMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnCommitMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCommitMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnRollbackMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId + ) = 0; + + STDMETHOD(OnRollbackMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnPauseAutomaticUpdatesBegin)( + ) = 0; + + STDMETHOD(OnPauseAutomaticUpdatesComplete)( + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnSystemRestorePointBegin)( + ) = 0; + + STDMETHOD(OnSystemRestorePointComplete)( + __in HRESULT hrStatus + ) = 0; + // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. // This might be used to help the BA support more than one version of the engine. STDMETHOD(BAProc)( diff --git a/src/balutil/packages.config b/src/balutil/packages.config index dbc4eb18..e6716363 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb