From 7d45238e97c35ccea1f77be9065b9a3ed9213bfb Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 16 Nov 2020 19:05:29 -0600 Subject: Add logging and BA messages around MSI transactions. --- .../inc/BootstrapperApplication.h | 77 +++++++++++ src/engine/apply.cpp | 47 +++++-- src/engine/elevation.cpp | 70 ++++++++-- src/engine/elevation.h | 6 +- src/engine/engine.mc | 42 ++++++ src/engine/msiengine.cpp | 20 ++- src/engine/msiengine.h | 8 +- src/engine/userexperience.cpp | 142 +++++++++++++++++++++ src/engine/userexperience.h | 33 ++++- 9 files changed, 414 insertions(+), 31 deletions(-) diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h index 77d5b2c6..cfbb0571 100644 --- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h +++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h @@ -135,6 +135,12 @@ enum BOOTSTRAPPER_APPLICATION_MESSAGE BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, }; enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION @@ -274,6 +280,30 @@ struct BA_ONAPPLYCOMPLETE_RESULTS BOOTSTRAPPER_APPLYCOMPLETE_ACTION action; }; +struct BA_ONBEGINMSITRANSACTIONBEGIN_ARGS +{ + DWORD cbSize; + LPCWSTR wzTransactionId; +}; + +struct BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS +{ + DWORD cbSize; + BOOL fCancel; +}; + +struct BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS +{ + DWORD cbSize; + LPCWSTR wzTransactionId; + HRESULT hrStatus; +}; + +struct BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD cbSize; +}; + struct BA_ONCACHEACQUIREBEGIN_ARGS { DWORD cbSize; @@ -398,6 +428,30 @@ struct BA_ONCACHEVERIFYCOMPLETE_RESULTS BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action; }; +struct BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS +{ + DWORD cbSize; + LPCWSTR wzTransactionId; +}; + +struct BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS +{ + DWORD cbSize; + BOOL fCancel; +}; + +struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS +{ + DWORD cbSize; + LPCWSTR wzTransactionId; + HRESULT hrStatus; +}; + +struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD cbSize; +}; + struct BA_ONDETECTBEGIN_ARGS { DWORD cbSize; @@ -963,6 +1017,29 @@ struct BA_ONRESOLVESOURCE_RESULTS BOOL fCancel; }; +struct BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS +{ + DWORD cbSize; + LPCWSTR wzTransactionId; +}; + +struct BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS +{ + DWORD cbSize; +}; + +struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS +{ + DWORD cbSize; + LPCWSTR wzTransactionId; + HRESULT hrStatus; +}; + +struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD cbSize; +}; + struct BA_ONSHUTDOWN_ARGS { DWORD cbSize; diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index 53422807..833d750c 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp @@ -783,7 +783,7 @@ extern "C" HRESULT ApplyExecute( if (pCheckpoint && pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction) { hr = E_INVALIDSTATE; - LogString(REPORT_ERROR, "Ilegal state: Reboot requested within an MSI transaction. Transaction will rollback."); + LogId(REPORT_ERROR, MSG_RESTART_REQUEST_DURING_MSI_TRANSACTION, pCheckpoint->pActiveRollbackBoundary->sczId); } else { @@ -796,6 +796,8 @@ extern "C" HRESULT ApplyExecute( // If rollback is disabled, keep what we have and always end execution here. if (pEngineState->plan.fDisableRollback) { + LogId(REPORT_WARNING, MSG_PLAN_ROLLBACK_DISABLED); + if (pCheckpoint && pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction) { hrRollback = ExecuteMsiCommitTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context); @@ -1732,13 +1734,11 @@ static HRESULT DoExecuteAction( break; case BURN_EXECUTE_ACTION_TYPE_BEGIN_MSI_TRANSACTION: - LogString(REPORT_STANDARD, "Starting a new MSI transaction\n"); hr = ExecuteMsiBeginTransaction(pEngineState, pExecuteAction->msiTransaction.pRollbackBoundary, pContext); ExitOnFailure(hr, "Failed to execute begin MSI transaction action."); break; case BURN_EXECUTE_ACTION_TYPE_COMMIT_MSI_TRANSACTION: - LogString(REPORT_STANDARD, "Committing MSI transaction\n"); hr = ExecuteMsiCommitTransaction(pEngineState, pExecuteAction->msiTransaction.pRollbackBoundary, pContext); ExitOnFailure(hr, "Failed to execute commit MSI transaction action."); break; @@ -1899,7 +1899,7 @@ static HRESULT ExecuteExePackage( fBeginCalled = TRUE; // Send package execute begin to BA. - hr = UserExperienceOnExecutePackageBegin(&pEngineState->userExperience, pExecuteAction->exePackage.pPackage->sczId, !fRollback, pExecuteAction->exePackage.action, INSTALLUILEVEL_NOCHANGE, false); + hr = UserExperienceOnExecutePackageBegin(&pEngineState->userExperience, pExecuteAction->exePackage.pPackage->sczId, !fRollback, pExecuteAction->exePackage.action, INSTALLUILEVEL_NOCHANGE, FALSE); ExitOnRootFailure(hr, "BA aborted execute EXE package begin."); message.type = GENERIC_EXECUTE_MESSAGE_PROGRESS; @@ -2090,7 +2090,7 @@ static HRESULT ExecuteMsuPackage( fBeginCalled = TRUE; // Send package execute begin to BA. - hr = UserExperienceOnExecutePackageBegin(&pEngineState->userExperience, pExecuteAction->msuPackage.pPackage->sczId, !fRollback, pExecuteAction->msuPackage.action, INSTALLUILEVEL_NOCHANGE, false); + hr = UserExperienceOnExecutePackageBegin(&pEngineState->userExperience, pExecuteAction->msuPackage.pPackage->sczId, !fRollback, pExecuteAction->msuPackage.action, INSTALLUILEVEL_NOCHANGE, FALSE); ExitOnRootFailure(hr, "BA aborted execute MSU package begin."); message.type = GENERIC_EXECUTE_MESSAGE_PROGRESS; @@ -2206,12 +2206,17 @@ static HRESULT ExecuteMsiBeginTransaction( ) { HRESULT hr = S_OK; + BOOL fBeginCalled = FALSE; if (pRollbackBoundary->fActiveTransaction) { ExitFunction1(hr = E_INVALIDSTATE); } + fBeginCalled = TRUE; + hr = UserExperienceOnBeginMsiTransactionBegin(&pEngineState->userExperience, pRollbackBoundary->sczId); + ExitOnRootFailure(hr, "BA aborted execute begin MSI transaction."); + if (pEngineState->plan.fPerMachine) { hr = ElevationMsiBeginTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary->sczId); @@ -2228,6 +2233,11 @@ static HRESULT ExecuteMsiBeginTransaction( } LExit: + if (fBeginCalled) + { + UserExperienceOnBeginMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); + } + return hr; } @@ -2238,20 +2248,25 @@ static HRESULT ExecuteMsiCommitTransaction( ) { HRESULT hr = S_OK; + BOOL fBeginCalled = FALSE; if (!pRollbackBoundary->fActiveTransaction) { ExitFunction1(hr = E_INVALIDSTATE); } + fBeginCalled = TRUE; + hr = UserExperienceOnCommitMsiTransactionBegin(&pEngineState->userExperience, pRollbackBoundary->sczId); + ExitOnRootFailure(hr, "BA aborted execute commit MSI transaction."); + if (pEngineState->plan.fPerMachine) { - hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe); + hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary->sczId); ExitOnFailure(hr, "Failed to commit an elevated MSI transaction."); } else { - hr = MsiEngineCommitTransaction(); + hr = MsiEngineCommitTransaction(pRollbackBoundary->sczId); } if (SUCCEEDED(hr)) @@ -2260,6 +2275,11 @@ static HRESULT ExecuteMsiCommitTransaction( } LExit: + if (fBeginCalled) + { + UserExperienceOnCommitMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); + } + return hr; } @@ -2270,25 +2290,34 @@ static HRESULT ExecuteMsiRollbackTransaction( ) { HRESULT hr = S_OK; + BOOL fBeginCalled = FALSE; if (!pRollbackBoundary->fActiveTransaction) { ExitFunction(); } + fBeginCalled = TRUE; + UserExperienceOnRollbackMsiTransactionBegin(&pEngineState->userExperience, pRollbackBoundary->sczId); + if (pEngineState->plan.fPerMachine) { - hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe); + hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary->sczId); ExitOnFailure(hr, "Failed to rollback an elevated MSI transaction."); } else { - hr = MsiEngineRollbackTransaction(); + hr = MsiEngineRollbackTransaction(pRollbackBoundary->sczId); } LExit: pRollbackBoundary->fActiveTransaction = FALSE; + if (fBeginCalled) + { + UserExperienceOnRollbackMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); + } + return hr; } diff --git a/src/engine/elevation.cpp b/src/engine/elevation.cpp index 81a48316..1d0e1f1d 100644 --- a/src/engine/elevation.cpp +++ b/src/engine/elevation.cpp @@ -237,8 +237,14 @@ static HRESULT OnMsiBeginTransaction( __in BYTE* pbData, __in DWORD cbData ); -static HRESULT OnMsiCommitTransaction(); -static HRESULT OnMsiRollbackTransaction(); +static HRESULT OnMsiCommitTransaction( + __in BYTE* pbData, + __in DWORD cbData + ); +static HRESULT OnMsiRollbackTransaction( + __in BYTE* pbData, + __in DWORD cbData + ); @@ -730,7 +736,7 @@ extern "C" HRESULT ElevationMsiBeginTransaction( hr = BuffWriteString(&pbData, &cbData, wzName); ExitOnFailure(hr, "Failed to write transaction name to message buffer."); - hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION, NULL, 0, NULL, NULL, &dwResult); + hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION, pbData, cbData, NULL, NULL, &dwResult); ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION message to per-machine process."); hr = static_cast(dwResult); @@ -742,13 +748,20 @@ LExit: } extern "C" HRESULT ElevationMsiCommitTransaction( - __in HANDLE hPipe + __in HANDLE hPipe, + __in LPCWSTR wzName ) { HRESULT hr = S_OK; + BYTE* pbData = NULL; + SIZE_T cbData = 0; DWORD dwResult = ERROR_SUCCESS; - hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION, NULL, 0, NULL, NULL, &dwResult); + // serialize message data + hr = BuffWriteString(&pbData, &cbData, wzName); + ExitOnFailure(hr, "Failed to write transaction name to message buffer."); + + hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION, pbData, cbData, NULL, NULL, &dwResult); ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION message to per-machine process."); hr = static_cast(dwResult); @@ -758,13 +771,20 @@ LExit: } extern "C" HRESULT ElevationMsiRollbackTransaction( - __in HANDLE hPipe + __in HANDLE hPipe, + __in LPCWSTR wzName ) { HRESULT hr = S_OK; + BYTE* pbData = NULL; + SIZE_T cbData = 0; DWORD dwResult = ERROR_SUCCESS; - hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION, NULL, 0, NULL, NULL, &dwResult); + // serialize message data + hr = BuffWriteString(&pbData, &cbData, wzName); + ExitOnFailure(hr, "Failed to write transaction name to message buffer."); + + hr = PipeSendMessage(hPipe, BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION, pbData, cbData, NULL, NULL, &dwResult); ExitOnFailure(hr, "Failed to send BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION message to per-machine process."); hr = static_cast(dwResult); @@ -1534,11 +1554,11 @@ static HRESULT ProcessElevatedChildMessage( break; case BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION: - hrResult = OnMsiCommitTransaction(); + hrResult = OnMsiCommitTransaction((BYTE*)pMsg->pvData, pMsg->cbData); break; case BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION: - hrResult = OnMsiRollbackTransaction(); + hrResult = OnMsiRollbackTransaction((BYTE*)pMsg->pvData, pMsg->cbData); break; case BURN_ELEVATION_MESSAGE_TYPE_APPLY_INITIALIZE: @@ -2806,20 +2826,44 @@ LExit: return hr; } -static HRESULT OnMsiCommitTransaction() +static HRESULT OnMsiCommitTransaction( + __in BYTE* pbData, + __in DWORD cbData + ) { HRESULT hr = S_OK; + SIZE_T iData = 0; + LPWSTR sczName = NULL; + + // Deserialize message data. + hr = BuffReadString(pbData, cbData, &iData, &sczName); + ExitOnFailure(hr, "Failed to read transaction name."); - hr = MsiEngineCommitTransaction(); + hr = MsiEngineCommitTransaction(sczName); + +LExit: + ReleaseStr(sczName); return hr; } -static HRESULT OnMsiRollbackTransaction() +static HRESULT OnMsiRollbackTransaction( + __in BYTE* pbData, + __in DWORD cbData + ) { HRESULT hr = S_OK; + SIZE_T iData = 0; + LPWSTR sczName = NULL; + + // Deserialize message data. + hr = BuffReadString(pbData, cbData, &iData, &sczName); + ExitOnFailure(hr, "Failed to read transaction name."); - hr = MsiEngineRollbackTransaction(); + hr = MsiEngineRollbackTransaction(sczName); + +LExit: + ReleaseStr(sczName); return hr; } diff --git a/src/engine/elevation.h b/src/engine/elevation.h index 975981da..96111ae2 100644 --- a/src/engine/elevation.h +++ b/src/engine/elevation.h @@ -162,10 +162,12 @@ HRESULT ElevationMsiBeginTransaction( __in LPCWSTR wzName ); HRESULT ElevationMsiCommitTransaction( - __in HANDLE hPipe + __in HANDLE hPipe, + __in LPCWSTR wzName ); HRESULT ElevationMsiRollbackTransaction( - __in HANDLE hPipe + __in HANDLE hPipe, + __in LPCWSTR wzName ); #ifdef __cplusplus diff --git a/src/engine/engine.mc b/src/engine/engine.mc index 4bb517f8..b36a9527 100644 --- a/src/engine/engine.mc +++ b/src/engine/engine.mc @@ -843,6 +843,48 @@ Language=English Ignoring application request to cancel from %1!ls! during rollback. . +MessageId=382 +Severity=Warning +SymbolicName=MSG_PLAN_ROLLBACK_DISABLED +Language=English +Rollback is disabled for this bundle. +. + +MessageId=383 +Severity=Error +SymbolicName=MSG_MSI_TRANSACTIONS_DISABLED +Language=English +Windows Installer rollback is disabled on this computer. It must be enabled for this bundle to proceed. +. + +MessageId=384 +Severity=Success +SymbolicName=MSG_MSI_TRANSACTION_BEGIN +Language=English +Starting a new MSI transaction, id: %1!ls! +. + +MessageId=385 +Severity=Success +SymbolicName=MSG_MSI_TRANSACTION_COMMIT +Language=English +Committing MSI transaction, id: %1!ls! +. + +MessageId=386 +Severity=Warning +SymbolicName=MSG_MSI_TRANSACTION_ROLLBACK +Language=English +Rolling back MSI transaction, id: %1!ls! +. + +MessageId=387 +Severity=Error +SymbolicName=MSG_RESTART_REQUEST_DURING_MSI_TRANSACTION +Language=English +Illegal state: Reboot requested within an MSI transaction, id: %1!ls! +. + MessageId=399 Severity=Success SymbolicName=MSG_APPLY_COMPLETE diff --git a/src/engine/msiengine.cpp b/src/engine/msiengine.cpp index b056cb7e..c298e219 100644 --- a/src/engine/msiengine.cpp +++ b/src/engine/msiengine.cpp @@ -1147,18 +1147,30 @@ extern "C" HRESULT MsiEngineBeginTransaction( MSIHANDLE hTransactionHandle = NULL; HANDLE hChangeOfOwnerEvent = NULL; + LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_BEGIN, wzName); + uResult = ::MsiBeginTransaction(wzName, 0, &hTransactionHandle, &hChangeOfOwnerEvent); + + if (ERROR_ROLLBACK_DISABLED == uResult) + { + LogId(REPORT_ERROR, MSG_MSI_TRANSACTIONS_DISABLED); + } + ExitOnWin32Error(uResult, hr, "Failed to begin an MSI transaction"); LExit: return hr; } -extern "C" HRESULT MsiEngineCommitTransaction() +extern "C" HRESULT MsiEngineCommitTransaction( + __in LPCWSTR wzName + ) { HRESULT hr = S_OK; UINT uResult = ERROR_SUCCESS; + LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_COMMIT, wzName); + uResult = ::MsiEndTransaction(MSITRANSACTIONSTATE_COMMIT); ExitOnWin32Error(uResult, hr, "Failed to commit the MSI transaction"); @@ -1167,11 +1179,15 @@ LExit: return hr; } -extern "C" HRESULT MsiEngineRollbackTransaction() +extern "C" HRESULT MsiEngineRollbackTransaction( + __in LPCWSTR wzName + ) { HRESULT hr = S_OK; UINT uResult = ERROR_SUCCESS; + LogId(REPORT_WARNING, MSG_MSI_TRANSACTION_ROLLBACK, wzName); + uResult = ::MsiEndTransaction(MSITRANSACTIONSTATE_ROLLBACK); ExitOnWin32Error(uResult, hr, "Failed to rollback the MSI transaction"); diff --git a/src/engine/msiengine.h b/src/engine/msiengine.h index 76030528..c7cc3bef 100644 --- a/src/engine/msiengine.h +++ b/src/engine/msiengine.h @@ -56,8 +56,12 @@ HRESULT MsiEngineAddCompatiblePackage( HRESULT MsiEngineBeginTransaction( __in LPCWSTR wzName ); -HRESULT MsiEngineCommitTransaction(); -HRESULT MsiEngineRollbackTransaction(); +HRESULT MsiEngineCommitTransaction( + __in LPCWSTR wzName + ); +HRESULT MsiEngineRollbackTransaction( + __in LPCWSTR wzName + ); HRESULT MsiEngineExecutePackage( __in_opt HWND hwndParent, __in BURN_EXECUTE_ACTION* pExecuteAction, diff --git a/src/engine/userexperience.cpp b/src/engine/userexperience.cpp index 5f18cdbc..08451f93 100644 --- a/src/engine/userexperience.cpp +++ b/src/engine/userexperience.cpp @@ -348,6 +348,55 @@ LExit: return hr; } +EXTERN_C BAAPI UserExperienceOnBeginMsiTransactionBegin( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId + ) +{ + HRESULT hr = S_OK; + BA_ONBEGINMSITRANSACTIONBEGIN_ARGS args = { }; + BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzTransactionId = wzTransactionId; + + results.cbSize = sizeof(results); + + hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &args, &results, pUserExperience->pvBAProcContext); + ExitOnFailure(hr, "BA OnBeginMsiTransactionBegin failed."); + + if (results.fCancel) + { + hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT); + } + +LExit: + return hr; +} + +EXTERN_C BAAPI UserExperienceOnBeginMsiTransactionComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) +{ + HRESULT hr = S_OK; + BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS args = { }; + BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzTransactionId = wzTransactionId; + args.hrStatus = hrStatus; + + results.cbSize = sizeof(results); + + hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &args, &results, pUserExperience->pvBAProcContext); + ExitOnFailure(hr, "BA OnBeginMsiTransactionComplete failed."); + +LExit: + return hr; +} + EXTERN_C BAAPI UserExperienceOnCacheAcquireBegin( __in BURN_USER_EXPERIENCE* pUserExperience, __in_z_opt LPCWSTR wzPackageOrContainerId, @@ -614,6 +663,55 @@ LExit: return hr; } +EXTERN_C BAAPI UserExperienceOnCommitMsiTransactionBegin( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId + ) +{ + HRESULT hr = S_OK; + BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS args = { }; + BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzTransactionId = wzTransactionId; + + results.cbSize = sizeof(results); + + hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &args, &results, pUserExperience->pvBAProcContext); + ExitOnFailure(hr, "BA OnCommitMsiTransactionBegin failed."); + + if (results.fCancel) + { + hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT); + } + +LExit: + return hr; +} + +EXTERN_C BAAPI UserExperienceOnCommitMsiTransactionComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) +{ + HRESULT hr = S_OK; + BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS args = { }; + BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzTransactionId = wzTransactionId; + args.hrStatus = hrStatus; + + results.cbSize = sizeof(results); + + hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &args, &results, pUserExperience->pvBAProcContext); + ExitOnFailure(hr, "BA OnCommitMsiTransactionComplete failed."); + +LExit: + return hr; +} + EXTERN_C BAAPI UserExperienceOnDetectBegin( __in BURN_USER_EXPERIENCE* pUserExperience, __in BOOL fInstalled, @@ -1799,6 +1897,50 @@ LExit: return hr; } +EXTERN_C BAAPI UserExperienceOnRollbackMsiTransactionBegin( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId + ) +{ + HRESULT hr = S_OK; + BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS args = { }; + BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzTransactionId = wzTransactionId; + + results.cbSize = sizeof(results); + + hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &args, &results, pUserExperience->pvBAProcContext); + ExitOnFailure(hr, "BA OnRollbackMsiTransactionBegin failed."); + +LExit: + return hr; +} + +EXTERN_C BAAPI UserExperienceOnRollbackMsiTransactionComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) +{ + HRESULT hr = S_OK; + BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS args = { }; + BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzTransactionId = wzTransactionId; + args.hrStatus = hrStatus; + + results.cbSize = sizeof(results); + + hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &args, &results, pUserExperience->pvBAProcContext); + ExitOnFailure(hr, "BA OnRollbackMsiTransactionComplete failed."); + +LExit: + return hr; +} + EXTERN_C BAAPI UserExperienceOnShutdown( __in BURN_USER_EXPERIENCE* pUserExperience, __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction diff --git a/src/engine/userexperience.h b/src/engine/userexperience.h index 0ebd1b68..387ed62b 100644 --- a/src/engine/userexperience.h +++ b/src/engine/userexperience.h @@ -108,7 +108,16 @@ BAAPI UserExperienceOnApplyComplete( __in HRESULT hrStatus, __in BOOTSTRAPPER_APPLY_RESTART restart, __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction -); + ); +BAAPI UserExperienceOnBeginMsiTransactionBegin( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId + ); +BAAPI UserExperienceOnBeginMsiTransactionComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ); BAAPI UserExperienceOnCacheAcquireBegin( __in BURN_USER_EXPERIENCE* pUserExperience, __in_z_opt LPCWSTR wzPackageOrContainerId, @@ -162,6 +171,15 @@ BAAPI UserExperienceOnCacheVerifyComplete( __in HRESULT hrStatus, __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction ); +BAAPI UserExperienceOnCommitMsiTransactionBegin( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId + ); +BAAPI UserExperienceOnCommitMsiTransactionComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ); BAAPI UserExperienceOnDetectBegin( __in BURN_USER_EXPERIENCE* pUserExperience, __in BOOL fInstalled, @@ -272,7 +290,7 @@ BAAPI UserExperienceOnExecuteBegin( BAAPI UserExperienceOnExecuteComplete( __in BURN_USER_EXPERIENCE* pUserExperience, __in HRESULT hrStatus -); + ); BAAPI UserExperienceOnExecuteFilesInUse( __in BURN_USER_EXPERIENCE* pUserExperience, __in_z LPCWSTR wzPackageId, @@ -315,7 +333,7 @@ BAAPI UserExperienceOnExecuteProgress( __in_z LPCWSTR wzPackageId, __in DWORD dwProgressPercentage, __in DWORD dwOverallPercentage, - __inout int* pnResult + __out int* pnResult ); BAAPI UserExperienceOnLaunchApprovedExeBegin( __in BURN_USER_EXPERIENCE* pUserExperience @@ -411,6 +429,15 @@ BAAPI UserExperienceOnResolveSource( __in_z_opt LPCWSTR wzDownloadSource, __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* pAction ); +BAAPI UserExperienceOnRollbackMsiTransactionBegin( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId + ); +BAAPI UserExperienceOnRollbackMsiTransactionComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ); BAAPI UserExperienceOnShutdown( __in BURN_USER_EXPERIENCE* pUserExperience, __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction -- cgit v1.2.3-55-g6feb