From 0d3d54992104288e9ee0c834d0b96e8502fd2d42 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 11 Jan 2024 18:26:20 -0800 Subject: Move the BootstrapperApplication out of proc --- src/api/burn/balutil/BalBaseBAFunctionsProc.cpp | 1099 ++++ src/api/burn/balutil/BalBootstrapperEngine.cpp | 1148 ++++- src/api/burn/balutil/BalBootstrapperEngine.h | 7 + src/api/burn/balutil/balinfo.cpp | 11 +- src/api/burn/balutil/balutil.cpp | 300 +- src/api/burn/balutil/balutil.vcxproj | 7 +- src/api/burn/balutil/inc/BAFunctions.h | 12 +- src/api/burn/balutil/inc/BalBaseBAFunctions.h | 66 +- src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h | 180 +- .../balutil/inc/BalBaseBootstrapperApplication.h | 90 +- .../inc/BalBaseBootstrapperApplicationProc.h | 1045 ---- src/api/burn/balutil/inc/BalBootstrapperEngine.h | 17 - src/api/burn/balutil/inc/IBAFunctions.h | 2 + .../burn/balutil/inc/IBootstrapperApplication.h | 29 +- .../balutil/inc/IBootstrapperApplicationFactory.h | 13 - src/api/burn/balutil/inc/IBootstrapperEngine.h | 11 +- src/api/burn/balutil/inc/balinfo.h | 1 - src/api/burn/balutil/inc/balutil.h | 30 +- src/api/burn/balutil/msg.cpp | 5263 ++++++++++++++++++++ src/api/burn/balutil/msg.h | 8 + src/api/burn/balutil/precomp.h | 12 +- 21 files changed, 7838 insertions(+), 1513 deletions(-) create mode 100644 src/api/burn/balutil/BalBaseBAFunctionsProc.cpp create mode 100644 src/api/burn/balutil/BalBootstrapperEngine.h delete mode 100644 src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h delete mode 100644 src/api/burn/balutil/inc/BalBootstrapperEngine.h delete mode 100644 src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h create mode 100644 src/api/burn/balutil/msg.cpp create mode 100644 src/api/burn/balutil/msg.h (limited to 'src/api/burn/balutil') diff --git a/src/api/burn/balutil/BalBaseBAFunctionsProc.cpp b/src/api/burn/balutil/BalBaseBAFunctionsProc.cpp new file mode 100644 index 00000000..38ebf65c --- /dev/null +++ b/src/api/burn/balutil/BalBaseBAFunctionsProc.cpp @@ -0,0 +1,1099 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +static HRESULT BalBaseBAFunctionsProcOnDestroy( + __in IBAFunctions* pBAFunctions, + __in BA_ONDESTROY_ARGS* pArgs, + __inout BA_ONDESTROY_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnDestroy(pArgs->fReload); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTBEGIN_ARGS* pArgs, + __inout BA_ONDETECTBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectBegin(pArgs->fCached, pArgs->registrationType, pArgs->cPackages, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTCOMPLETE_ARGS* pArgs, + __inout BA_ONDETECTCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnDetectComplete(pArgs->hrStatus, pArgs->fEligibleForCleanup); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANBEGIN_ARGS* pArgs, + __inout BA_ONPLANBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanBegin(pArgs->cPackages, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANCOMPLETE_ARGS* pArgs, + __inout BA_ONPLANCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPlanComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnStartup( + __in IBAFunctions* pBAFunctions, + __in BA_ONSTARTUP_ARGS* /*pArgs*/, + __inout BA_ONSTARTUP_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnStartup(); +} + +static HRESULT BalBaseBAFunctionsProcOnShutdown( + __in IBAFunctions* pBAFunctions, + __in BA_ONSHUTDOWN_ARGS* /*pArgs*/, + __inout BA_ONSHUTDOWN_RESULTS* pResults + ) +{ + return pBAFunctions->OnShutdown(&pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectForwardCompatibleBundle( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, + __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fMissingFromCache, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectUpdateBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTUPDATEBEGIN_ARGS* pArgs, + __inout BA_ONDETECTUPDATEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectUpdateBegin(pArgs->wzUpdateLocation, &pResults->fCancel, &pResults->fSkip); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectUpdate( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTUPDATE_ARGS* pArgs, + __inout BA_ONDETECTUPDATE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->wzHash, pArgs->hashAlgorithm, pArgs->wzVersion, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectUpdateComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTUPDATECOMPLETE_ARGS* pArgs, + __inout BA_ONDETECTUPDATECOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectUpdateComplete(pArgs->hrStatus, &pResults->fIgnoreError); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectRelatedBundle( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTRELATEDBUNDLE_ARGS* pArgs, + __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fMissingFromCache, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectPackageBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONDETECTPACKAGEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectPackageBegin(pArgs->wzPackageId, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectCompatiblePackage( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectRelatedMsiPackage( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTRELATEDMSIPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTRELATEDMSIPACKAGE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectPatchTarget( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTPATCHTARGET_ARGS* pArgs, + __inout BA_ONDETECTPATCHTARGET_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectPatchTarget(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->patchState, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectMsiFeature( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTMSIFEATURE_ARGS* pArgs, + __inout BA_ONDETECTMSIFEATURE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectMsiFeature(pArgs->wzPackageId, pArgs->wzFeatureId, pArgs->state, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectPackageComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONDETECTPACKAGECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnDetectPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state, pArgs->fCached); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanRelatedBundle( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANRELATEDBUNDLE_ARGS* pArgs, + __inout BA_ONPLANRELATEDBUNDLE_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanRelatedBundle(pArgs->wzBundleId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanRollbackBoundary( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANROLLBACKBOUNDARY_ARGS* pArgs, + __inout BA_ONPLANROLLBACKBOUNDARY_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanRollbackBoundary(pArgs->wzRollbackBoundaryId, pArgs->fRecommendedTransaction, &pResults->fTransaction, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanPackageBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->state, pArgs->fCached, pArgs->installCondition, pArgs->repairCondition, pArgs->recommendedState, pArgs->recommendedCacheType, &pResults->requestedState, &pResults->requestedCacheType, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanCompatibleMsiPackageBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, pArgs->fRecommendedRemove, &pResults->fRequestRemove, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanCompatibleMsiPackageComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPlanCompatibleMsiPackageComplete(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->hrStatus, pArgs->fRequestedRemove); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanPatchTarget( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANPATCHTARGET_ARGS* pArgs, + __inout BA_ONPLANPATCHTARGET_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanPatchTarget(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanMsiFeature( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANMSIFEATURE_ARGS* pArgs, + __inout BA_ONPLANMSIFEATURE_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanMsiFeature(pArgs->wzPackageId, pArgs->wzFeatureId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanPackageComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONPLANPACKAGECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPlanPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->requested); +} + +static HRESULT BalBaseBAFunctionsProcOnPlannedCompatiblePackage( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS* pArgs, + __inout BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPlannedCompatiblePackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->fRemove); +} + +static HRESULT BalBaseBAFunctionsProcOnPlannedPackage( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANNEDPACKAGE_ARGS* pArgs, + __inout BA_ONPLANNEDPACKAGE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPlannedPackage(pArgs->wzPackageId, pArgs->execute, pArgs->rollback, pArgs->fPlannedCache, pArgs->fPlannedUncache); +} + +static HRESULT BalBaseBAFunctionsProcOnApplyBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONAPPLYBEGIN_ARGS* pArgs, + __inout BA_ONAPPLYBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnApplyBegin(pArgs->dwPhaseCount, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnElevateBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONELEVATEBEGIN_ARGS* /*pArgs*/, + __inout BA_ONELEVATEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnElevateBegin(&pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnElevateComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONELEVATECOMPLETE_ARGS* pArgs, + __inout BA_ONELEVATECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnElevateComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnProgress( + __in IBAFunctions* pBAFunctions, + __in BA_ONPROGRESS_ARGS* pArgs, + __inout BA_ONPROGRESS_RESULTS* pResults + ) +{ + return pBAFunctions->OnProgress(pArgs->dwProgressPercentage, pArgs->dwOverallPercentage, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnError( + __in IBAFunctions* pBAFunctions, + __in BA_ONERROR_ARGS* pArgs, + __inout BA_ONERROR_RESULTS* pResults + ) +{ + return pBAFunctions->OnError(pArgs->errorType, pArgs->wzPackageId, pArgs->dwCode, pArgs->wzError, pArgs->dwUIHint, pArgs->cData, pArgs->rgwzData, pArgs->nRecommendation, &pResults->nResult); +} + +static HRESULT BalBaseBAFunctionsProcOnRegisterBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONREGISTERBEGIN_ARGS* pArgs, + __inout BA_ONREGISTERBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnRegisterBegin(pArgs->recommendedRegistrationType, &pResults->fCancel, &pResults->registrationType); +} + +static HRESULT BalBaseBAFunctionsProcOnRegisterComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONREGISTERCOMPLETE_ARGS* pArgs, + __inout BA_ONREGISTERCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnRegisterComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEBEGIN_ARGS* /*pArgs*/, + __inout BA_ONCACHEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheBegin(&pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCachePackageBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONCACHEPACKAGEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCachePackageBegin(pArgs->wzPackageId, pArgs->cCachePayloads, pArgs->dw64PackageCacheSize, pArgs->fVital, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheAcquireBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEACQUIREBEGIN_ARGS* pArgs, + __inout BA_ONCACHEACQUIREBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzSource, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->action, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheAcquireProgress( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEACQUIREPROGRESS_ARGS* pArgs, + __inout BA_ONCACHEACQUIREPROGRESS_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheAcquireProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheAcquireResolving( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEACQUIRERESOLVING_ARGS* pArgs, + __inout BA_ONCACHEACQUIRERESOLVING_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheAcquireResolving(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->rgSearchPaths, pArgs->cSearchPaths, pArgs->fFoundLocal, pArgs->dwRecommendedSearchPath, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->dwChosenSearchPath, &pResults->action, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheAcquireComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEACQUIRECOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEACQUIRECOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheAcquireComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheVerifyBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEVERIFYBEGIN_ARGS* pArgs, + __inout BA_ONCACHEVERIFYBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheVerifyBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheVerifyProgress( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEVERIFYPROGRESS_ARGS* pArgs, + __inout BA_ONCACHEVERIFYPROGRESS_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheVerifyProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, pArgs->verifyStep, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheVerifyComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEVERIFYCOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEVERIFYCOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheVerifyComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnCachePackageComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEPACKAGECOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnCachePackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHECOMPLETE_ARGS* pArgs, + __inout BA_ONCACHECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnCacheComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnExecuteBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEBEGIN_ARGS* pArgs, + __inout BA_ONEXECUTEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecuteBegin(pArgs->cExecutingPackages, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnExecutePackageBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONEXECUTEPACKAGEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, pArgs->uiLevel, pArgs->fDisableExternalUiHandler, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnExecutePatchTarget( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEPATCHTARGET_ARGS* pArgs, + __inout BA_ONEXECUTEPATCHTARGET_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecutePatchTarget(pArgs->wzPackageId, pArgs->wzTargetProductCode, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnExecuteProgress( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEPROGRESS_ARGS* pArgs, + __inout BA_ONEXECUTEPROGRESS_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecuteProgress(pArgs->wzPackageId, pArgs->dwProgressPercentage, pArgs->dwOverallPercentage, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnExecuteMsiMessage( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEMSIMESSAGE_ARGS* pArgs, + __inout BA_ONEXECUTEMSIMESSAGE_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecuteMsiMessage(pArgs->wzPackageId, pArgs->messageType, pArgs->dwUIHint, pArgs->wzMessage, pArgs->cData, pArgs->rgwzData, pArgs->nRecommendation, &pResults->nResult); +} + +static HRESULT BalBaseBAFunctionsProcOnExecuteFilesInUse( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEFILESINUSE_ARGS* pArgs, + __inout BA_ONEXECUTEFILESINUSE_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecuteFilesInUse(pArgs->wzPackageId, pArgs->cFiles, pArgs->rgwzFiles, pArgs->nRecommendation, pArgs->source, &pResults->nResult); +} + +static HRESULT BalBaseBAFunctionsProcOnExecutePackageComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONEXECUTEPACKAGECOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecutePackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnExecuteProcessCancel( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTEPROCESSCANCEL_ARGS* pArgs, + __inout BA_ONEXECUTEPROCESSCANCEL_RESULTS* pResults + ) +{ + return pBAFunctions->OnExecuteProcessCancel(pArgs->wzPackageId, pArgs->dwProcessId, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnExecuteComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONEXECUTECOMPLETE_ARGS* pArgs, + __inout BA_ONEXECUTECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnExecuteComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnUnregisterBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONUNREGISTERBEGIN_ARGS* pArgs, + __inout BA_ONUNREGISTERBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnUnregisterBegin(pArgs->recommendedRegistrationType, &pResults->registrationType); +} + +static HRESULT BalBaseBAFunctionsProcOnUnregisterComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONUNREGISTERCOMPLETE_ARGS* pArgs, + __inout BA_ONUNREGISTERCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnUnregisterComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnApplyComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONAPPLYCOMPLETE_ARGS* pArgs, + __inout BA_ONAPPLYCOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnApplyComplete(pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnLaunchApprovedExeBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS* /*pArgs*/, + __inout BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnLaunchApprovedExeBegin(&pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnLaunchApprovedExeComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS* pArgs, + __inout BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnLaunchApprovedExeComplete(pArgs->hrStatus, pArgs->dwProcessId); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanMsiPackage( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANMSIPACKAGE_ARGS* pArgs, + __inout BA_ONPLANMSIPACKAGE_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanMsiPackage(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, pArgs->recommendedFileVersioning, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler, &pResults->fileVersioning); +} + +static HRESULT BalBaseBAFunctionsProcOnBeginMsiTransactionBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONBEGINMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnBeginMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnBeginMsiTransactionComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnBeginMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnCommitMsiTransactionBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCommitMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCommitMsiTransactionComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnRollbackMsiTransactionBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnRollbackMsiTransactionBegin(pArgs->wzTransactionId); +} + +static HRESULT BalBaseBAFunctionsProcOnRollbackMsiTransactionComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* pResults + ) +{ + return pBAFunctions->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnPauseAutomaticUpdatesBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS* /*pArgs*/, + __inout BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPauseAutomaticUpdatesBegin(); +} + +static HRESULT BalBaseBAFunctionsProcOnPauseAutomaticUpdatesComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS* pArgs, + __inout BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnPauseAutomaticUpdatesComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnSystemRestorePointBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS* /*pArgs*/, + __inout BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnSystemRestorePointBegin(); +} + +static HRESULT BalBaseBAFunctionsProcOnSystemRestorePointComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS* pArgs, + __inout BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnSystemRestorePointComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanForwardCompatibleBundle( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, + __inout BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fRecommendedIgnoreBundle, &pResults->fCancel, &pResults->fIgnoreBundle); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheContainerOrPayloadVerifyBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS* pArgs, + __inout BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheContainerOrPayloadVerifyBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheContainerOrPayloadVerifyProgress( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS* pArgs, + __inout BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS* pResults + ) +{ + return pBAFunctions->OnCacheContainerOrPayloadVerifyProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCacheContainerOrPayloadVerifyComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS* pArgs, + __inout BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnCacheContainerOrPayloadVerifyComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnCachePayloadExtractBegin( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS* pArgs, + __inout BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS* pResults + ) +{ + return pBAFunctions->OnCachePayloadExtractBegin(pArgs->wzContainerId, pArgs->wzPayloadId, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCachePayloadExtractProgress( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS* pArgs, + __inout BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS* pResults + ) +{ + return pBAFunctions->OnCachePayloadExtractProgress(pArgs->wzContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCachePayloadExtractComplete( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnCachePayloadExtractComplete(pArgs->wzContainerId, pArgs->wzPayloadId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanRestoreRelatedBundle( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANRESTORERELATEDBUNDLE_ARGS* pArgs, + __inout BA_ONPLANRESTORERELATEDBUNDLE_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanRestoreRelatedBundle(pArgs->wzBundleId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnPlanRelatedBundleType( + __in IBAFunctions* pBAFunctions, + __in BA_ONPLANRELATEDBUNDLETYPE_ARGS* pArgs, + __inout BA_ONPLANRELATEDBUNDLETYPE_RESULTS* pResults + ) +{ + return pBAFunctions->OnPlanRelatedBundleType(pArgs->wzBundleId, pArgs->recommendedType, &pResults->requestedType, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnApplyDowngrade( + __in IBAFunctions* pBAFunctions, + __in BA_ONAPPLYDOWNGRADE_ARGS* pArgs, + __inout BA_ONAPPLYDOWNGRADE_RESULTS* pResults + ) +{ + return pBAFunctions->OnApplyDowngrade(pArgs->hrRecommended, &pResults->hrStatus); +} + +static HRESULT BalBaseBAFunctionsProcOnDetectRelatedBundlePackage( + __in IBAFunctions* pBAFunctions, + __in BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS* pResults + ) +{ + return pBAFunctions->OnDetectRelatedBundlePackage(pArgs->wzPackageId, pArgs->wzBundleId, pArgs->relationType, pArgs->fPerMachine, pArgs->wzVersion, &pResults->fCancel); +} + +static HRESULT BalBaseBAFunctionsProcOnCachePackageNonVitalValidationFailure( + __in IBAFunctions* pBAFunctions, + __in BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS* pArgs, + __inout BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS* pResults + ) +{ + return pBAFunctions->OnCachePackageNonVitalValidationFailure(pArgs->wzPackageId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); +} + +static HRESULT BalBaseBAFunctionsProcOnThemeLoaded( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_ONTHEMELOADED_ARGS* pArgs, + __inout BA_FUNCTIONS_ONTHEMELOADED_RESULTS* /*pResults*/ + ) +{ + return pBAFunctions->OnThemeLoaded(pArgs->hWnd); +} + +static HRESULT BalBaseBAFunctionsProcWndProc( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_WNDPROC_ARGS* pArgs, + __inout BA_FUNCTIONS_WNDPROC_RESULTS* pResults + ) +{ + return pBAFunctions->WndProc(pArgs->hWnd, pArgs->uMsg, pArgs->wParam, pArgs->lParam, &pResults->fProcessed, &pResults->lResult); +} + +static HRESULT BalBaseBAFunctionsProcOnThemeControlLoading( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_ONTHEMECONTROLLOADING_ARGS* pArgs, + __inout BA_FUNCTIONS_ONTHEMECONTROLLOADING_RESULTS* pResults + ) +{ + return pBAFunctions->OnThemeControlLoading(pArgs->wzName, &pResults->fProcessed, &pResults->wId, &pResults->dwAutomaticBehaviorType); +} + +static HRESULT BalBaseBAFunctionsProcOnThemeControlWmCommand( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_ONTHEMECONTROLWMCOMMAND_ARGS* pArgs, + __inout BA_FUNCTIONS_ONTHEMECONTROLWMCOMMAND_RESULTS* pResults + ) +{ + return pBAFunctions->OnThemeControlWmCommand(pArgs->wParam, pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed, &pResults->lResult); +} + +static HRESULT BalBaseBAFunctionsProcOnThemeControlWmNotify( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_ONTHEMECONTROLWMNOTIFY_ARGS* pArgs, + __inout BA_FUNCTIONS_ONTHEMECONTROLWMNOTIFY_RESULTS* pResults + ) +{ + return pBAFunctions->OnThemeControlWmNotify(pArgs->lParam, pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed, &pResults->lResult); +} + +static HRESULT BalBaseBAFunctionsProcOnThemeControlLoaded( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_ONTHEMECONTROLLOADED_ARGS* pArgs, + __inout BA_FUNCTIONS_ONTHEMECONTROLLOADED_RESULTS* pResults + ) +{ + return pBAFunctions->OnThemeControlLoaded(pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed); +} + +/******************************************************************* +BalBaseBAFunctionsProc - requires pvContext to be of type IBAFunctions. +Provides a default mapping between the message based BAFunctions interface and +the COM-based BAFunctions interface. + +*******************************************************************/ +HRESULT WINAPI BalBaseBAFunctionsProc( + __in BA_FUNCTIONS_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) +{ + IBAFunctions* pBAFunctions = reinterpret_cast(pvContext); + HRESULT hr = pBAFunctions->BAFunctionsProc(message, pvArgs, pvResults, pvContext); + + if (E_NOTIMPL == hr) + { + switch (message) + { + case BA_FUNCTIONS_MESSAGE_ONCREATE: + // ONCREATE is handled when the function is created, not via callback. + break; + case BA_FUNCTIONS_MESSAGE_ONDESTROY: + hr = BalBaseBAFunctionsProcOnDestroy(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONSTARTUP: + hr = BalBaseBAFunctionsProcOnStartup(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONSHUTDOWN: + hr = BalBaseBAFunctionsProcOnShutdown(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTBEGIN: + hr = BalBaseBAFunctionsProcOnDetectBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPLETE: + hr = BalBaseBAFunctionsProcOnDetectComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANBEGIN: + hr = BalBaseBAFunctionsProcOnPlanBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE: + hr = BalBaseBAFunctionsProcOnPlanComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: + hr = BalBaseBAFunctionsProcOnDetectForwardCompatibleBundle(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN: + hr = BalBaseBAFunctionsProcOnDetectUpdateBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE: + hr = BalBaseBAFunctionsProcOnDetectUpdate(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE: + hr = BalBaseBAFunctionsProcOnDetectUpdateComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE: + hr = BalBaseBAFunctionsProcOnDetectRelatedBundle(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN: + hr = BalBaseBAFunctionsProcOnDetectPackageBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE: + hr = BalBaseBAFunctionsProcOnDetectRelatedMsiPackage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTPATCHTARGET: + hr = BalBaseBAFunctionsProcOnDetectPatchTarget(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE: + hr = BalBaseBAFunctionsProcOnDetectMsiFeature(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE: + hr = BalBaseBAFunctionsProcOnDetectPackageComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE: + hr = BalBaseBAFunctionsProcOnPlanRelatedBundle(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN: + hr = BalBaseBAFunctionsProcOnPlanPackageBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANPATCHTARGET: + hr = BalBaseBAFunctionsProcOnPlanPatchTarget(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE: + hr = BalBaseBAFunctionsProcOnPlanMsiFeature(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE: + hr = BalBaseBAFunctionsProcOnPlanPackageComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN: + hr = BalBaseBAFunctionsProcOnApplyBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN: + hr = BalBaseBAFunctionsProcOnElevateBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE: + hr = BalBaseBAFunctionsProcOnElevateComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPROGRESS: + hr = BalBaseBAFunctionsProcOnProgress(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONERROR: + hr = BalBaseBAFunctionsProcOnError(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN: + hr = BalBaseBAFunctionsProcOnRegisterBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE: + hr = BalBaseBAFunctionsProcOnRegisterComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN: + hr = BalBaseBAFunctionsProcOnCacheBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN: + hr = BalBaseBAFunctionsProcOnCachePackageBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN: + hr = BalBaseBAFunctionsProcOnCacheAcquireBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS: + hr = BalBaseBAFunctionsProcOnCacheAcquireProgress(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING: + hr = BalBaseBAFunctionsProcOnCacheAcquireResolving(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE: + hr = BalBaseBAFunctionsProcOnCacheAcquireComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN: + hr = BalBaseBAFunctionsProcOnCacheVerifyBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYPROGRESS: + hr = BalBaseBAFunctionsProcOnCacheVerifyProgress(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE: + hr = BalBaseBAFunctionsProcOnCacheVerifyComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE: + hr = BalBaseBAFunctionsProcOnCachePackageComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE: + hr = BalBaseBAFunctionsProcOnCacheComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN: + hr = BalBaseBAFunctionsProcOnExecuteBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN: + hr = BalBaseBAFunctionsProcOnExecutePackageBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET: + hr = BalBaseBAFunctionsProcOnExecutePatchTarget(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS: + hr = BalBaseBAFunctionsProcOnExecuteProgress(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE: + hr = BalBaseBAFunctionsProcOnExecuteMsiMessage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE: + hr = BalBaseBAFunctionsProcOnExecuteFilesInUse(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE: + hr = BalBaseBAFunctionsProcOnExecutePackageComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE: + hr = BalBaseBAFunctionsProcOnExecuteComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN: + hr = BalBaseBAFunctionsProcOnUnregisterBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE: + hr = BalBaseBAFunctionsProcOnUnregisterComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE: + hr = BalBaseBAFunctionsProcOnApplyComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: + hr = BalBaseBAFunctionsProcOnLaunchApprovedExeBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: + hr = BalBaseBAFunctionsProcOnLaunchApprovedExeComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE: + hr = BalBaseBAFunctionsProcOnPlanMsiPackage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + hr = BalBaseBAFunctionsProcOnBeginMsiTransactionBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + hr = BalBaseBAFunctionsProcOnBeginMsiTransactionComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + hr = BalBaseBAFunctionsProcOnCommitMsiTransactionBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + hr = BalBaseBAFunctionsProcOnCommitMsiTransactionComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + hr = BalBaseBAFunctionsProcOnRollbackMsiTransactionBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + hr = BalBaseBAFunctionsProcOnRollbackMsiTransactionComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + hr = BalBaseBAFunctionsProcOnPauseAutomaticUpdatesBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + hr = BalBaseBAFunctionsProcOnPauseAutomaticUpdatesComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + hr = BalBaseBAFunctionsProcOnSystemRestorePointBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: + hr = BalBaseBAFunctionsProcOnSystemRestorePointComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE: + hr = BalBaseBAFunctionsProcOnPlannedPackage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: + hr = BalBaseBAFunctionsProcOnPlanForwardCompatibleBundle(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN: + hr = BalBaseBAFunctionsProcOnCacheContainerOrPayloadVerifyBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS: + hr = BalBaseBAFunctionsProcOnCacheContainerOrPayloadVerifyProgress(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE: + hr = BalBaseBAFunctionsProcOnCacheContainerOrPayloadVerifyComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN: + hr = BalBaseBAFunctionsProcOnCachePayloadExtractBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS: + hr = BalBaseBAFunctionsProcOnCachePayloadExtractProgress(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE: + hr = BalBaseBAFunctionsProcOnCachePayloadExtractComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANROLLBACKBOUNDARY: + hr = BalBaseBAFunctionsProcOnPlanRollbackBoundary(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: + hr = BalBaseBAFunctionsProcOnDetectCompatiblePackage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: + hr = BalBaseBAFunctionsProcOnPlanCompatibleMsiPackageBegin(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: + hr = BalBaseBAFunctionsProcOnPlanCompatibleMsiPackageComplete(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: + hr = BalBaseBAFunctionsProcOnPlannedCompatiblePackage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANRESTORERELATEDBUNDLE: + hr = BalBaseBAFunctionsProcOnPlanRestoreRelatedBundle(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLETYPE: + hr = BalBaseBAFunctionsProcOnPlanRelatedBundleType(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONAPPLYDOWNGRADE: + hr = BalBaseBAFunctionsProcOnApplyDowngrade(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPROCESSCANCEL: + hr = BalBaseBAFunctionsProcOnExecuteProcessCancel(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE: + hr = BalBaseBAFunctionsProcOnDetectRelatedBundlePackage(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE: + hr = BalBaseBAFunctionsProcOnCachePackageNonVitalValidationFailure(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: + hr = BalBaseBAFunctionsProcOnThemeLoaded(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_WNDPROC: + hr = BalBaseBAFunctionsProcWndProc(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADING: + hr = BalBaseBAFunctionsProcOnThemeControlLoading(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMCOMMAND: + hr = BalBaseBAFunctionsProcOnThemeControlWmCommand(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMNOTIFY: + hr = BalBaseBAFunctionsProcOnThemeControlWmNotify(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADED: + hr = BalBaseBAFunctionsProcOnThemeControlLoaded(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + } + } + + return hr; +} diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp index be53c6b9..b924906e 100644 --- a/src/api/burn/balutil/BalBootstrapperEngine.cpp +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp @@ -2,7 +2,6 @@ #include "precomp.h" - class CBalBootstrapperEngine : public IBootstrapperEngine { public: // IUnknown @@ -64,18 +63,44 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETPACKAGECOUNT_ARGS args = { }; BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetPackageCount args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetPackageCount results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA GetPackageCount failed."); - results.cbSize = sizeof(results); + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read value length from GetPackageCount results."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &args, &results, m_pvBAEngineProcContext); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, (DWORD*)&results.cPackages); + ExitOnFailure(hr, "Failed to read value length from GetPackageCount results."); *pcPackages = results.cPackages; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -87,20 +112,50 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + LPWSTR sczValue = NULL; ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVariable = wzVariable; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetVariableNumeric args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable name of GetVariableNumeric args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetVariableNumeric results."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA GetVariableNumeric failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read value length from GetVariableNumeric results."); + + hr = BuffReadNumber64(rpc.pbData, rpc.cbData, &iBuffer, (DWORD64*)&results.llValue); + ExitOnFailure(hr, "Failed to read value length from GetVariableNumeric results."); *pllValue = results.llValue; LExit: - SecureZeroMemory(&results, sizeof(results)); + ReleaseStr(sczValue); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -113,21 +168,69 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETVARIABLESTRING_ARGS args = { }; BAENGINE_GETVARIABLESTRING_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + LPWSTR sczValue = NULL; ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVariable = wzVariable; - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + results.cchValue = static_cast(*pcchValue); + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetVariableString args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable name of GetVariableString args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetVariableString results."); + + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); + ExitOnFailure(hr, "Failed to write API version of GetVariableString results value."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA GetVariableString failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read value length from GetVariableString results."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchValue); + ExitOnFailure(hr, "Failed to read value length from GetVariableString results."); + + hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczValue); + ExitOnFailure(hr, "Failed to read value from GetVariableString results."); + + results.wzValue = sczValue; + + if (wzValue) + { + hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); + } + else if (results.cchValue) + { + hr = E_MOREDATA; + } *pcchValue = results.cchValue; + ExitOnFailure(hr, "Failed to copy value from GetVariableString results."); LExit: + ReleaseStr(sczValue); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -140,21 +243,70 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETVARIABLEVERSION_ARGS args = { }; BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + LPWSTR sczValue = NULL; ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVariable = wzVariable; - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + hr = DutilSizetToDword(*pcchValue, &results.cchValue); + ExitOnFailure(hr, "Failed to convert pcchValue to DWORD."); + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetVariableVersion args."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable name of GetVariableVersion args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetVariableVersion results."); + + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); + ExitOnFailure(hr, "Failed to write API version of GetVariableVersion results value."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA GetVariableVersion failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read value length from GetVariableVersion results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchValue); + ExitOnFailure(hr, "Failed to read value length from GetVariableVersion results."); + + hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczValue); + ExitOnFailure(hr, "Failed to read value from GetVariableVersion results."); + + results.wzValue = sczValue; + + if (wzValue) + { + hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); + } + else if (results.cchValue) + { + hr = E_MOREDATA; + } *pcchValue = results.cchValue; + ExitOnFailure(hr, "Failed to copy value from GetVariableVersion results."); LExit: + ReleaseStr(sczValue); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -168,21 +320,74 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS args = { }; BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + LPWSTR sczValue = NULL; ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzBundleId = wzBundleId; args.wzVariable = wzVariable; - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + hr = DutilSizetToDword(*pcchValue, &results.cchValue); + ExitOnFailure(hr, "Failed to convert pcchValue to DWORD."); + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetRelatedBundleVariable args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzBundleId); + ExitOnFailure(hr, "Failed to write bundle id of GetRelatedBundleVariable args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable name of GetRelatedBundleVariable args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of GetRelatedBundleVariable results."); + + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchValue); + ExitOnFailure(hr, "Failed to write API version of GetRelatedBundleVariable results value."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA GetRelatedBundleVariable failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read value length from GetRelatedBundleVariable results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchValue); + ExitOnFailure(hr, "Failed to read value length from GetRelatedBundleVariable results."); + + hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczValue); + ExitOnFailure(hr, "Failed to read value from GetRelatedBundleVariable results."); + + results.wzValue = sczValue; + + if (wzValue) + { + hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); + } + else if (results.cchValue) + { + hr = E_MOREDATA; + } *pcchValue = results.cchValue; + ExitOnFailure(hr, "Failed to copy value from GetRelatedBundleVariable results."); + LExit: + ReleaseStr(sczValue); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -195,21 +400,70 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_FORMATSTRING_ARGS args = { }; BAENGINE_FORMATSTRING_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + LPWSTR sczOut = NULL; ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzIn = wzIn; - results.cbSize = sizeof(results); - results.wzOut = wzOut; - results.cchOut = *pcchOut; + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + hr = DutilSizetToDword(*pcchOut, &results.cchOut); + ExitOnFailure(hr, "Failed to convert pcchOut to DWORD."); + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of FormatString args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzIn); + ExitOnFailure(hr, "Failed to write string to format of FormatString args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of FormatString results."); + + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchOut); + ExitOnFailure(hr, "Failed to write format string maximum size of FormatString results value."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA FormatString failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read size from FormatString results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchOut); + ExitOnFailure(hr, "Failed to read formatted string length from FormatString results."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBAEngineProcContext); + hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczOut); + ExitOnFailure(hr, "Failed to read formatted string from FormatString results."); + + results.wzOut = sczOut; + + if (wzOut) + { + hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut); + } + else if (results.cchOut) + { + hr = E_MOREDATA; + } *pcchOut = results.cchOut; + ExitOnFailure(hr, "Failed to copy formatted string from FormatString results."); LExit: + ReleaseStr(sczOut); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -222,21 +476,70 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_ESCAPESTRING_ARGS args = { }; BAENGINE_ESCAPESTRING_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + LPWSTR sczOut = NULL; ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzIn = wzIn; - results.cbSize = sizeof(results); - results.wzOut = wzOut; - results.cchOut = *pcchOut; + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + hr = DutilSizetToDword(*pcchOut, &results.cchOut); + ExitOnFailure(hr, "Failed to convert pcchOut to DWORD."); + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of EscapeString args."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBAEngineProcContext); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzIn); + ExitOnFailure(hr, "Failed to write string to escape of EscapeString args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of EscapeString results."); + + hr = BuffWriteNumberToBuffer(&bufferResults, results.cchOut); + ExitOnFailure(hr, "Failed to write escape string maximum size of EscapeString results value."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA EscapeString failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read size from EscapeString results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.cchOut); + ExitOnFailure(hr, "Failed to read escaped string length from EscapeString results."); + + hr = BuffReadString(rpc.pbData, rpc.cbData, &iBuffer, &sczOut); + ExitOnFailure(hr, "Failed to read escaped string from EscapeString results."); + + results.wzOut = sczOut; + + if (wzOut) + { + hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut); + } + else if (results.cchOut) + { + hr = E_MOREDATA; + } *pcchOut = results.cchOut; + ExitOnFailure(hr, "Failed to copy escaped string from EscapeString results."); LExit: + ReleaseStr(sczOut); + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -248,19 +551,56 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_EVALUATECONDITION_ARGS args = { }; BAENGINE_EVALUATECONDITION_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; + ExitOnNull(wzCondition, hr, E_INVALIDARG, "wzCondition is required"); ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); - args.cbSize = sizeof(args); + // Empty condition evaluates to true. + if (!*wzCondition) + { + *pf = TRUE; + ExitFunction(); + } + + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzCondition = wzCondition; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of EvaluateCondition args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzCondition); + ExitOnFailure(hr, "Failed to write condition of EvaluateCondition args."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBAEngineProcContext); + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of EvaluateCondition results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA EvaluateCondition failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read size from EvaluateCondition results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.f)); + ExitOnFailure(hr, "Failed to read result from EvaluateCondition results."); *pf = results.f; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -269,16 +609,44 @@ public: // IBootstrapperEngine __in_z LPCWSTR wzMessage ) { + HRESULT hr = S_OK; BAENGINE_LOG_ARGS args = { }; BAENGINE_LOG_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.level = level; args.wzMessage = wzMessage; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Log args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.level); + ExitOnFailure(hr, "Failed to write level of Log args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); + ExitOnFailure(hr, "Failed to write message of Log args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Log results."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA Log failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SendEmbeddedError( @@ -291,21 +659,56 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.dwErrorCode = dwErrorCode; args.wzMessage = wzMessage; args.dwUIHint = dwUIHint; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SendEmbeddedError args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwErrorCode); + ExitOnFailure(hr, "Failed to write error code of SendEmbeddedError args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzMessage); + ExitOnFailure(hr, "Failed to write message of SendEmbeddedError args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwUIHint); + ExitOnFailure(hr, "Failed to write UI hint of SendEmbeddedError args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SendEmbeddedError results."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SendEmbeddedError failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read size from SendEmbeddedError results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.nResult)); + ExitOnFailure(hr, "Failed to read result from SendEmbeddedError results."); *pnResult = results.nResult; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -318,20 +721,52 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.dwProgressPercentage = dwProgressPercentage; args.dwOverallProgressPercentage = dwOverallProgressPercentage; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SendEmbeddedProgress args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwProgressPercentage); + ExitOnFailure(hr, "Failed to write progress of SendEmbeddedProgress args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwOverallProgressPercentage); + ExitOnFailure(hr, "Failed to write overall progress of SendEmbeddedProgress args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SendEmbeddedProgress results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SendEmbeddedProgress failed."); + + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read size from SendEmbeddedProgress results."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &args, &results, m_pvBAEngineProcContext); + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.nResult)); + ExitOnFailure(hr, "Failed to read result from SendEmbeddedProgress results."); *pnResult = results.nResult; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } @@ -340,22 +775,67 @@ public: // IBootstrapperEngine __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_z_opt LPCWSTR wzHash + __in_z_opt LPCWSTR wzHash, + __in_z_opt LPCWSTR wzUpdatePackageId ) { + HRESULT hr = S_OK; BAENGINE_SETUPDATE_ARGS args = { }; BAENGINE_SETUPDATE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzLocalSource = wzLocalSource; args.wzDownloadSource = wzDownloadSource; args.qwSize = qwSize; args.hashType = hashType; args.wzHash = wzHash; + args.wzUpdatePackageId = wzUpdatePackageId; + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetUpdate args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzLocalSource); + ExitOnFailure(hr, "Failed to write local source of SetUpdate args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzDownloadSource); + ExitOnFailure(hr, "Failed to write download source of SetUpdate args."); + + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.qwSize); + ExitOnFailure(hr, "Failed to write udpate size of SetUpdate args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast(args.hashType)); + ExitOnFailure(hr, "Failed to write hash type of SetUpdate args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); + ExitOnFailure(hr, "Failed to write hash of SetUpdate args."); - results.cbSize = sizeof(results); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzHash); + ExitOnFailure(hr, "Failed to write hash of SetUpdate args."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &args, &results, m_pvBAEngineProcContext); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUpdatePackageId); + ExitOnFailure(hr, "Failed to write update package id to SetUpdate args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetUpdate results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetUpdate failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SetLocalSource( @@ -364,17 +844,48 @@ public: // IBootstrapperEngine __in_z LPCWSTR wzPath ) { + HRESULT hr = S_OK; BAENGINE_SETLOCALSOURCE_ARGS args = { }; BAENGINE_SETLOCALSOURCE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzPackageOrContainerId = wzPackageOrContainerId; args.wzPayloadId = wzPayloadId; args.wzPath = wzPath; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetLocalSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); + ExitOnFailure(hr, "Failed to write package or container id of SetLocalSource args."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &args, &results, m_pvBAEngineProcContext); + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); + ExitOnFailure(hr, "Failed to write payload id of SetLocalSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPath); + ExitOnFailure(hr, "Failed to write path of SetLocalSource args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetLocalSource results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetLocalSource failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SetDownloadSource( @@ -382,22 +893,64 @@ public: // IBootstrapperEngine __in_z_opt LPCWSTR wzPayloadId, __in_z LPCWSTR wzUrl, __in_z_opt LPCWSTR wzUser, - __in_z_opt LPCWSTR wzPassword + __in_z_opt LPCWSTR wzPassword, + __in_z_opt LPCWSTR wzAuthorizationHeader ) { + HRESULT hr = S_OK; BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzPackageOrContainerId = wzPackageOrContainerId; args.wzPayloadId = wzPayloadId; args.wzUrl = wzUrl; args.wzUser = wzUser; args.wzPassword = wzPassword; + args.wzAuthorizationHeader = wzAuthorizationHeader; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &args, &results, m_pvBAEngineProcContext); + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetDownloadSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPackageOrContainerId); + ExitOnFailure(hr, "Failed to write package or container id of SetDownloadSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPayloadId); + ExitOnFailure(hr, "Failed to write payload id of SetDownloadSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUrl); + ExitOnFailure(hr, "Failed to write url of SetDownloadSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUser); + ExitOnFailure(hr, "Failed to write user of SetDownloadSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzPassword); + ExitOnFailure(hr, "Failed to write password of SetDownloadSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzAuthorizationHeader); + ExitOnFailure(hr, "Failed to write authorization header of SetDownloadSource args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetDownloadSource results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetDownloadSource failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SetVariableNumeric( @@ -405,16 +958,44 @@ public: // IBootstrapperEngine __in LONGLONG llValue ) { + HRESULT hr = S_OK; BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVariable = wzVariable; args.llValue = llValue; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetVariableNumeric args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable of SetVariableNumeric args."); + + hr = BuffWriteNumber64ToBuffer(&bufferArgs, static_cast(args.llValue)); + ExitOnFailure(hr, "Failed to write value of SetVariableNumeric args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetVariableNumeric results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetVariableNumeric failed."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SetVariableString( @@ -423,17 +1004,48 @@ public: // IBootstrapperEngine __in BOOL fFormatted ) { + HRESULT hr = S_OK; BAENGINE_SETVARIABLESTRING_ARGS args = { }; BAENGINE_SETVARIABLESTRING_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVariable = wzVariable; args.wzValue = wzValue; args.fFormatted = fFormatted; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetVariableString args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable of SetVariableString args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzValue); + ExitOnFailure(hr, "Failed to write value of SetVariableString args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.fFormatted); + ExitOnFailure(hr, "Failed to write formatted flag of SetVariableString args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetVariableString results."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetVariableString failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SetVariableVersion( @@ -441,103 +1053,278 @@ public: // IBootstrapperEngine __in_z_opt LPCWSTR wzValue ) { + HRESULT hr = S_OK; BAENGINE_SETVARIABLEVERSION_ARGS args = { }; BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVariable = wzVariable; args.wzValue = wzValue; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetVariableVersion args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVariable); + ExitOnFailure(hr, "Failed to write variable of SetVariableVersion args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzValue); + ExitOnFailure(hr, "Failed to write value of SetVariableVersion args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetVariableVersion results."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetVariableVersion failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP CloseSplashScreen() { + HRESULT hr = S_OK; BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of CloseSplashScreen args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of CloseSplashScreen results."); - args.cbSize = sizeof(args); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA CloseSplashScreen failed."); - results.cbSize = sizeof(results); + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &args, &results, m_pvBAEngineProcContext); + return hr; } virtual STDMETHODIMP Detect( __in_opt HWND hwndParent ) { + HRESULT hr = S_OK; BAENGINE_DETECT_ARGS args = { }; BAENGINE_DETECT_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + args.hwndParent = reinterpret_cast(hwndParent); + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Detect args."); - results.cbSize = sizeof(results); + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); + ExitOnFailure(hr, "Failed to write parent window of Detect args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Detect results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA Detect failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &args, &results, m_pvBAEngineProcContext); + return hr; } virtual STDMETHODIMP Plan( __in BOOTSTRAPPER_ACTION action ) { + HRESULT hr = S_OK; BAENGINE_PLAN_ARGS args = { }; BAENGINE_PLAN_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.action = action; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Plan args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, static_cast(args.action)); + ExitOnFailure(hr, "Failed to write parent window of Plan args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Plan results."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA Plan failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP Elevate( __in_opt HWND hwndParent ) { + HRESULT hr = S_OK; BAENGINE_ELEVATE_ARGS args = { }; BAENGINE_ELEVATE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + args.hwndParent = reinterpret_cast(hwndParent); + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Elevate args."); - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); + ExitOnFailure(hr, "Failed to write parent window of Elevate args."); - results.cbSize = sizeof(results); + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Elevate results."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA Elevate failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP Apply( __in HWND hwndParent ) { + HRESULT hr = S_OK; BAENGINE_APPLY_ARGS args = { }; BAENGINE_APPLY_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + args.hwndParent = reinterpret_cast(hwndParent); + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Apply args."); + + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); + ExitOnFailure(hr, "Failed to write parent window of Apply args."); - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Apply results."); - results.cbSize = sizeof(results); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA Apply failed."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &args, &results, m_pvBAEngineProcContext); + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP Quit( __in DWORD dwExitCode ) { + HRESULT hr = S_OK; BAENGINE_QUIT_ARGS args = { }; BAENGINE_QUIT_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.dwExitCode = dwExitCode; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &args, &results, m_pvBAEngineProcContext); + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Quit args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwExitCode); + ExitOnFailure(hr, "Failed to write exit code of Quit args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of Quit results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA Quit failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP LaunchApprovedExe( @@ -547,33 +1334,101 @@ public: // IBootstrapperEngine __in DWORD dwWaitForInputIdleTimeout ) { + HRESULT hr = S_OK; BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + + ExitOnNull(wzApprovedExeForElevationId, hr, E_INVALIDARG, "wzApprovedExeForElevationId is required"); - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + args.hwndParent = reinterpret_cast(hwndParent); args.wzApprovedExeForElevationId = wzApprovedExeForElevationId; args.wzArguments = wzArguments; args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of LaunchApprovedExe args."); + + hr = BuffWriteNumber64ToBuffer(&bufferArgs, args.hwndParent); + ExitOnFailure(hr, "Failed to write parent window of LaunchApprovedExe args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzApprovedExeForElevationId); + ExitOnFailure(hr, "Failed to write approved exe elevation id of LaunchApprovedExe args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzArguments); + ExitOnFailure(hr, "Failed to write arguments of LaunchApprovedExe args."); + + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwWaitForInputIdleTimeout); + ExitOnFailure(hr, "Failed to write wait for idle input timeout of LaunchApprovedExe args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of LaunchApprovedExe results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA LaunchApprovedExe failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP SetUpdateSource( - __in_z LPCWSTR wzUrl + __in_z LPCWSTR wzUrl, + __in_z_opt LPCWSTR wzAuthorizationHeader ) { + HRESULT hr = S_OK; BAENGINE_SETUPDATESOURCE_ARGS args = { }; BAENGINE_SETUPDATESOURCE_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + + ExitOnNull(wzUrl, hr, E_INVALIDARG, "wzUrl is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzUrl = wzUrl; + args.wzAuthorizationHeader = wzAuthorizationHeader; + + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetUpdateSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzUrl); + ExitOnFailure(hr, "Failed to write url of SetUpdateSource args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzAuthorizationHeader); + ExitOnFailure(hr, "Failed to write authorization header of SetUpdateSource args."); - results.cbSize = sizeof(results); + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of SetUpdateSource results."); - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &args, &results, m_pvBAEngineProcContext); + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA SetUpdateSource failed."); + + LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + + return hr; } virtual STDMETHODIMP CompareVersions( @@ -585,66 +1440,133 @@ public: // IBootstrapperEngine HRESULT hr = S_OK; BAENGINE_COMPAREVERSIONS_ARGS args = { }; BAENGINE_COMPAREVERSIONS_RESULTS results = { }; + BUFF_BUFFER bufferArgs = { }; + BUFF_BUFFER bufferResults = { }; + PIPE_RPC_RESULT rpc = { }; + SIZE_T iBuffer = 0; ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - args.cbSize = sizeof(args); + // Init send structs. + args.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; args.wzVersion1 = wzVersion1; args.wzVersion2 = wzVersion2; - results.cbSize = sizeof(results); + results.dwApiVersion = WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION; + + // Send args. + hr = BuffWriteNumberToBuffer(&bufferArgs, args.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of CompareVersions args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion1); + ExitOnFailure(hr, "Failed to write first input of CompareVersions args."); + + hr = BuffWriteStringToBuffer(&bufferArgs, args.wzVersion2); + ExitOnFailure(hr, "Failed to write second input of CompareVersions args."); + + // Send results. + hr = BuffWriteNumberToBuffer(&bufferResults, results.dwApiVersion); + ExitOnFailure(hr, "Failed to write API version of CompareVersions results."); + + // Get results. + hr = SendRequest(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &bufferArgs, &bufferResults, &rpc); + ExitOnFailure(hr, "BA CompareVersions failed."); - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBAEngineProcContext); + // Read results. + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read size from CompareVersions results."); + + hr = BuffReadNumber(rpc.pbData, rpc.cbData, &iBuffer, reinterpret_cast(&results.nResult)); + ExitOnFailure(hr, "Failed to read result from CompareVersions results."); *pnResult = results.nResult; LExit: + PipeFreeRpcResult(&rpc); + ReleaseBuffer(bufferResults); + ReleaseBuffer(bufferArgs); + return hr; } -public: - HRESULT Init() +private: + HRESULT SendRequest( + __in DWORD dwMessageType, + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in PIPE_RPC_RESULT* pRpc + ) { - return ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); + HRESULT hr = S_OK; + BUFF_BUFFER buffer = { }; + + hr = CombineArgsAndResults(pBufferArgs, pBufferResults, &buffer); + if (SUCCEEDED(hr)) + { + hr = PipeRpcRequest(&m_hRpcPipe, dwMessageType, buffer.pbData, buffer.cbData, pRpc); + } + + ReleaseBuffer(buffer); + return hr; } + HRESULT CombineArgsAndResults( + __in BUFF_BUFFER* pBufferArgs, + __in BUFF_BUFFER* pBufferResults, + __in BUFF_BUFFER* pBufferCombined + ) + { + HRESULT hr = S_OK; + + // Write args to buffer. + hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferArgs->pbData, pBufferArgs->cbData); + ExitOnFailure(hr, "Failed to write args buffer."); + + // Write results to buffer. + hr = BuffWriteStreamToBuffer(pBufferCombined, pBufferResults->pbData, pBufferResults->cbData); + ExitOnFailure(hr, "Failed to write results buffer."); + + LExit: + return hr; + } + +public: CBalBootstrapperEngine( - __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, - __in_opt LPVOID pvBAEngineProcContext + __in HANDLE hPipe, + __out HRESULT* phr ) { m_cReferences = 1; - m_pfnBAEngineProc = pfnBAEngineProc; - m_pvBAEngineProcContext = pvBAEngineProcContext; - m_pFreeThreadedMarshaler = NULL; + + PipeRpcInitialize(&m_hRpcPipe, hPipe, FALSE); + + *phr = ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); } ~CBalBootstrapperEngine() { + PipeRpcUninitiailize(&m_hRpcPipe); ReleaseObject(m_pFreeThreadedMarshaler); } private: long m_cReferences; - PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc; - LPVOID m_pvBAEngineProcContext; + PIPE_RPC_HANDLE m_hRpcPipe; IUnknown* m_pFreeThreadedMarshaler; }; + HRESULT BalBootstrapperEngineCreate( - __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, - __in_opt LPVOID pvBAEngineProcContext, + __in HANDLE hPipe, __out IBootstrapperEngine** ppBootstrapperEngine ) { HRESULT hr = S_OK; CBalBootstrapperEngine* pBootstrapperEngine = NULL; - pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext); + pBootstrapperEngine = new CBalBootstrapperEngine(hPipe, &hr); ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); - - hr = pBootstrapperEngine->Init(); - ExitOnFailure(hr, "Failed to initialize CBalBootstrapperEngine."); + ExitOnFailure(hr, "Failed to initialize BalBootstrapperEngine."); hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); diff --git a/src/api/burn/balutil/BalBootstrapperEngine.h b/src/api/burn/balutil/BalBootstrapperEngine.h new file mode 100644 index 00000000..b3bd4ca7 --- /dev/null +++ b/src/api/burn/balutil/BalBootstrapperEngine.h @@ -0,0 +1,7 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +HRESULT BalBootstrapperEngineCreate( + __in HANDLE hEnginePipe, + __out IBootstrapperEngine** ppEngineForApplication + ); diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp index 751ba4f1..6f609a40 100644 --- a/src/api/burn/balutil/balinfo.cpp +++ b/src/api/burn/balutil/balinfo.cpp @@ -223,7 +223,6 @@ LExit: DAPI_(HRESULT) BalInfoAddUpdateBundleAsPackage( __in BAL_INFO_PACKAGES* pPackages, __in_z LPCWSTR wzId, - __in_z LPCWSTR /*wzPreviousId*/, __out_opt BAL_INFO_PACKAGE** ppPackage ) { @@ -356,7 +355,7 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast(&pOverridableVariable)); - if (E_NOTFOUND == hr) + if (E_NOTFOUND == hr || E_INVALIDARG == hr) { BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to set non-overridable variable: '%ls'.", wzVariableName); hr = S_OK; @@ -549,16 +548,16 @@ static HRESULT ParseBalPackageInfoFromXml( } ExitOnFailure(hr, "Failed to parse all WixBalPackageInfo elements."); - hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixMbaPrereqInformation", &pNodeList); + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPrereqInformation", &pNodeList); ExitOnFailure(hr, "Failed to select all packages."); while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) { hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); - ExitOnRequiredXmlQueryFailure(hr, "Failed to get package identifier for WixMbaPrereqInformation."); + ExitOnRequiredXmlQueryFailure(hr, "Failed to get package identifier for WixPrereqInformation."); hr = BalInfoFindPackageById(pPackages, scz, &pPackage); - ExitOnFailure(hr, "Failed to find package specified in WixMbaPrereqInformation: %ls", scz); + ExitOnFailure(hr, "Failed to find package specified in WixPrereqInformation: %ls", scz); pPackage->fPrereqPackage = TRUE; @@ -570,7 +569,7 @@ static HRESULT ParseBalPackageInfoFromXml( ReleaseNullObject(pNode); } - ExitOnFailure(hr, "Failed to parse all WixMbaPrereqInformation elements."); + ExitOnFailure(hr, "Failed to parse all WixPrereqInformation elements."); if (S_FALSE == hr) { diff --git a/src/api/burn/balutil/balutil.cpp b/src/api/burn/balutil/balutil.cpp index 2d80878c..a77ff7d0 100644 --- a/src/api/burn/balutil/balutil.cpp +++ b/src/api/burn/balutil/balutil.cpp @@ -3,8 +3,39 @@ #include "precomp.h" const DWORD VARIABLE_GROW_FACTOR = 80; +static DWORD vdwDebuggerCheck = 0; static IBootstrapperEngine* vpEngine = NULL; +static HRESULT ParseCommandLine( + __inout_z LPWSTR *psczPipeBaseName, + __inout_z LPWSTR *psczPipeSecret, + __out DWORD64 *pqwEngineAPIVersion + ); +static HRESULT ConnectToEngine( + __in_z LPCWSTR wzPipeBaseName, + __in_z LPCWSTR wzPipeSecret, + __out HANDLE *phBAPipe, + __out HANDLE *phEnginePipe + ); +static HRESULT ConnectAndVerify( + __in_z LPCWSTR wzPipeName, + __in_z LPCWSTR wzPipeSecret, + __in DWORD cbPipeSecret, + __out HANDLE *phPipe + ); +static HRESULT PumpMessages( + __in HANDLE hPipe, + __in IBootstrapperApplication* pApplication, + __in IBootstrapperEngine* pEngine + ); +static void MsgProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE messageType, + __in_bcount(cbData) LPVOID pvData, + __in DWORD cbData, + __in IBootstrapperApplication* pApplication, + __in IBootstrapperEngine* pEngine + ); + // prototypes DAPI_(void) BalInitialize( @@ -17,38 +48,136 @@ DAPI_(void) BalInitialize( vpEngine = pEngine; } -DAPI_(HRESULT) BalInitializeFromCreateArgs( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __out_opt IBootstrapperEngine** ppEngine +DAPI_(void) BalUninitialize() +{ + ReleaseNullObject(vpEngine); +} + +DAPI_(HRESULT) BootstrapperApplicationRun( + __in IBootstrapperApplication* pApplication ) { HRESULT hr = S_OK; + BOOL fComInitialized = FALSE; + DWORD64 qwEngineAPIVersion = 0; + LPWSTR sczPipeBaseName = NULL; + LPWSTR sczPipeSecret = NULL; + HANDLE hBAPipe = INVALID_HANDLE_VALUE; + HANDLE hEnginePipe = INVALID_HANDLE_VALUE; IBootstrapperEngine* pEngine = NULL; + BOOL fInitializedBal = FALSE; + + // initialize COM + hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + ExitOnFailure(hr, "Failed to initialize COM."); + fComInitialized = TRUE; + + hr = ParseCommandLine(&sczPipeBaseName, &sczPipeSecret, &qwEngineAPIVersion); + BalExitOnFailure(hr, "Failed to parse command line."); - hr = BalBootstrapperEngineCreate(pArgs->pfnBootstrapperEngineProc, pArgs->pvBootstrapperEngineProcContext, &pEngine); - ExitOnFailure(hr, "Failed to create BalBootstrapperEngine."); + // TODO: Validate the engine API version. + + hr = ConnectToEngine(sczPipeBaseName, sczPipeSecret, &hBAPipe, &hEnginePipe); + BalExitOnFailure(hr, "Failed to connect to engine."); + + hr = BalBootstrapperEngineCreate(hEnginePipe, &pEngine); + BalExitOnFailure(hr, "Failed to create bootstrapper engine."); BalInitialize(pEngine); + fInitializedBal = TRUE; + + BootstrapperApplicationDebuggerCheck(); - if (ppEngine) + hr = MsgPump(hBAPipe, pApplication, pEngine); + BalExitOnFailure(hr, "Failed while pumping messages."); + +LExit: + if (fInitializedBal) { - *ppEngine = pEngine; + BalUninitialize(); } - pEngine = NULL; -LExit: - ReleaseObject(pEngine); + ReleaseNullObject(pEngine); + ReleasePipeHandle(hEnginePipe); + ReleasePipeHandle(hBAPipe); + ReleaseStr(sczPipeSecret); + ReleaseStr(sczPipeBaseName); + + if (fComInitialized) + { + ::CoUninitialize(); + } return hr; } - -DAPI_(void) BalUninitialize() +DAPI_(VOID) BootstrapperApplicationDebuggerCheck() { - ReleaseNullObject(vpEngine); + HRESULT hr = S_OK; + HKEY hk = NULL; + BOOL fDebug = FALSE; + LPWSTR sczDebugBootstrapperApplications = NULL; + LPWSTR sczDebugBootstrapperApplication = NULL; + LPWSTR sczModulePath = NULL; + LPCWSTR wzModuleFilename = NULL; + WCHAR wzMessage[1024] = { }; + + if (0 == vdwDebuggerCheck) + { + ++vdwDebuggerCheck; + + hr = RegOpen(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", KEY_QUERY_VALUE, &hk); + if (SUCCEEDED(hr)) + { + hr = RegReadString(hk, L"WixDebugBootstrapperApplications", &sczDebugBootstrapperApplications); + if (SUCCEEDED(hr) && sczDebugBootstrapperApplications && *sczDebugBootstrapperApplications && + sczDebugBootstrapperApplications[0] != L'0' && !sczDebugBootstrapperApplications[1]) + { + hr = PathForCurrentProcess(&sczModulePath, NULL); + if (SUCCEEDED(hr) && sczModulePath && *sczModulePath) + { + wzModuleFilename = PathFile(sczModulePath); + if (wzModuleFilename) + { + fDebug = TRUE; + } + } + } + else + { + hr = RegReadString(hk, L"WixDebugBootstrapperApplication", &sczDebugBootstrapperApplication); + if (SUCCEEDED(hr) && sczDebugBootstrapperApplication && *sczDebugBootstrapperApplication) + { + hr = PathForCurrentProcess(&sczModulePath, NULL); + if (SUCCEEDED(hr) && sczModulePath && *sczModulePath) + { + wzModuleFilename = PathFile(sczModulePath); + if (wzModuleFilename && CSTR_EQUAL == ::CompareStringOrdinal(sczDebugBootstrapperApplication, -1, wzModuleFilename, -1, TRUE)) + { + fDebug = TRUE; + } + } + } + } + + if (fDebug) + { + hr = ::StringCchPrintfW(wzMessage, countof(wzMessage), L"To debug the boostrapper application process %ls\n\nSet breakpoints and attach a debugger to process id: %d (0x%x)", wzModuleFilename, ::GetCurrentProcessId(), ::GetCurrentProcessId()); + + if (SUCCEEDED(hr)) + { + ::MessageBoxW(NULL, wzMessage, L"WiX Bootstrapper Application", MB_SERVICE_NOTIFICATION | MB_TOPMOST | MB_ICONQUESTION | MB_OK | MB_SYSTEMMODAL); + } + } + } + } + + ReleaseRegKey(hk); + ReleaseStr(sczModulePath); + ReleaseStr(sczDebugBootstrapperApplication); + ReleaseStr(sczDebugBootstrapperApplications); } - DAPI_(HRESULT) BalManifestLoad( __in HMODULE hBootstrapperApplicationModule, __out IXMLDOMDocument** ppixdManifest @@ -671,3 +800,146 @@ LExit: return hr; } + + +static HRESULT ParseCommandLine( + __inout_z LPWSTR *psczPipeBaseName, + __inout_z LPWSTR *psczPipeSecret, + __out DWORD64 *pqwEngineAPIVersion + ) +{ + HRESULT hr = S_OK; + LPWSTR wzCommandLine = ::GetCommandLineW(); + int argc = 0; + LPWSTR* argv = NULL; + + *pqwEngineAPIVersion = 0; + + hr = AppParseCommandLine(wzCommandLine, &argc, &argv); + ExitOnFailure(hr, "Failed to parse command line."); + + // Skip the executable full path in argv[0]. + for (int i = 1; i < argc; ++i) + { + if (argv[i][0] == L'-') + { + if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, BOOTSTRAPPER_APPLICATION_COMMANDLINE_SWITCH_API_VERSION, -1, TRUE)) + { + if (i + 1 >= argc) + { + BalExitOnRootFailure(hr = E_INVALIDARG, "Must specify an api version."); + } + + ++i; + + hr = StrStringToUInt64(argv[i], 0, pqwEngineAPIVersion); + BalExitOnFailure(hr, "Failed to parse api version: %ls", argv[i]); + } + else if (CSTR_EQUAL == ::CompareStringOrdinal(&argv[i][1], -1, BOOTSTRAPPER_APPLICATION_COMMANDLINE_SWITCH_PIPE_NAME, -1, TRUE)) + { + if (i + 2 >= argc) + { + BalExitOnRootFailure(hr = E_INVALIDARG, "Must specify a pipe name and pipe secret."); + } + + ++i; + + hr = StrAllocString(psczPipeBaseName, argv[i], 0); + BalExitOnFailure(hr, "Failed to copy pipe name."); + + ++i; + + hr = StrAllocString(psczPipeSecret, argv[i], 0); + BalExitOnFailure(hr, "Failed to copy pipe secret."); + } + } + else + { + BalExitWithRootFailure(hr, E_INVALIDARG, "Invalid argument: %ls", argv[i]); + } + } + +LExit: + if (argv) + { + AppFreeCommandLineArgs(argv); + } + + return hr; +} + +static HRESULT ConnectToEngine( + __in_z LPCWSTR wzPipeBaseName, + __in_z LPCWSTR wzPipeSecret, + __out HANDLE *phBAPipe, + __out HANDLE *phEnginePipe + ) +{ + HRESULT hr = S_OK; + LPWSTR sczBAPipeName = NULL; + LPWSTR sczEnginePipeName = NULL; + HANDLE hBAPipe = INVALID_HANDLE_VALUE; + HANDLE hEnginePipe = INVALID_HANDLE_VALUE; + + DWORD cbPipeSecret = lstrlenW(wzPipeSecret) * sizeof(WCHAR); + + hr = StrAllocFormatted(&sczBAPipeName, L"%ls%ls", wzPipeBaseName, L".BA"); + ExitOnFailure(hr, "Failed to allocate BA pipe name."); + + hr = StrAllocFormatted(&sczEnginePipeName, L"%ls%ls", wzPipeBaseName, L".BAEngine"); + ExitOnFailure(hr, "Failed to allocate BA engine pipe name."); + + hr = ConnectAndVerify(sczBAPipeName, wzPipeSecret, cbPipeSecret, &hBAPipe); + BalExitOnFailure(hr, "Failed to connect to bootstrapper application pipe."); + + hr = ConnectAndVerify(sczEnginePipeName, wzPipeSecret, cbPipeSecret, &hEnginePipe); + BalExitOnFailure(hr, "Failed to connect to engine pipe."); + + *phBAPipe = hBAPipe; + hBAPipe = INVALID_HANDLE_VALUE; + + *phEnginePipe = hEnginePipe; + hEnginePipe = INVALID_HANDLE_VALUE; + +LExit: + ReleasePipeHandle(hEnginePipe); + ReleasePipeHandle(hBAPipe); + ReleaseStr(sczEnginePipeName); + ReleaseStr(sczBAPipeName); + + return hr; +} + +static HRESULT ConnectAndVerify( + __in_z LPCWSTR wzPipeName, + __in_z LPCWSTR wzPipeSecret, + __in DWORD cbPipeSecret, + __out HANDLE *phPipe + ) +{ + HRESULT hr = S_OK; + HRESULT hrConnect = S_OK; + HANDLE hPipe = INVALID_HANDLE_VALUE; + + hr = PipeClientConnect(wzPipeName, &hPipe); + BalExitOnFailure(hr, "Failed to connect to pipe."); + + hr = FileWriteHandle(hPipe, reinterpret_cast(&cbPipeSecret), sizeof(cbPipeSecret)); + BalExitOnFailure(hr, "Failed to write secret size to pipe."); + + hr = FileWriteHandle(hPipe, reinterpret_cast(wzPipeSecret), cbPipeSecret); + BalExitOnFailure(hr, "Failed to write secret size to pipe."); + + FileReadHandle(hPipe, reinterpret_cast(&hrConnect), sizeof(hrConnect)); + BalExitOnFailure(hr, "Failed to read connect result from pipe."); + + BalExitOnFailure(hrConnect, "Failed connect result from pipe."); + + *phPipe = hPipe; + hPipe = INVALID_HANDLE_VALUE; + +LExit: + ReleasePipeHandle(hPipe); + + return hr; +} diff --git a/src/api/burn/balutil/balutil.vcxproj b/src/api/burn/balutil/balutil.vcxproj index d5cd146b..8f93d636 100644 --- a/src/api/burn/balutil/balutil.vcxproj +++ b/src/api/burn/balutil/balutil.vcxproj @@ -53,6 +53,7 @@ + @@ -61,23 +62,23 @@ Create + - - - + + diff --git a/src/api/burn/balutil/inc/BAFunctions.h b/src/api/burn/balutil/inc/BAFunctions.h index 4a0b8599..7908a74c 100644 --- a/src/api/burn/balutil/inc/BAFunctions.h +++ b/src/api/burn/balutil/inc/BAFunctions.h @@ -1,6 +1,7 @@ #pragma once // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +#include "IBootstrapperEngine.h" #ifdef __cplusplus extern "C" { @@ -9,12 +10,14 @@ extern "C" { // The first 1024 messages are reserved so that the BA messages have the same value here. enum BA_FUNCTIONS_MESSAGE { + BA_FUNCTIONS_MESSAGE_ONCREATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, + BA_FUNCTIONS_MESSAGE_ONDESTROY = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, + BA_FUNCTIONS_MESSAGE_ONSTARTUP = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, + BA_FUNCTIONS_MESSAGE_ONSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, BA_FUNCTIONS_MESSAGE_ONDETECTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, BA_FUNCTIONS_MESSAGE_ONDETECTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, 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_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, @@ -81,8 +84,6 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, BA_FUNCTIONS_MESSAGE_ONPLANROLLBACKBOUNDARY = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, - BA_FUNCTIONS_MESSAGE_ONSETUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATEBEGIN, - BA_FUNCTIONS_MESSAGE_ONSETUPDATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATECOMPLETE, BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, @@ -117,7 +118,8 @@ struct BA_FUNCTIONS_CREATE_ARGS { DWORD cbSize; DWORD64 qwBAFunctionsAPIVersion; - BOOTSTRAPPER_CREATE_ARGS* pBootstrapperCreateArgs; + IBootstrapperEngine* pEngine; + BOOTSTRAPPER_COMMAND* pCommand; }; struct BA_FUNCTIONS_CREATE_RESULTS diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h index 6ad109c3..33b71324 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctions.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h @@ -1,16 +1,12 @@ #pragma once // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - #include #include -#include "BAFunctions.h" +#include + #include "IBAFunctions.h" -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" class CBalBaseBAFunctions : public IBAFunctions { @@ -69,8 +65,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ + __inout LPVOID /*pvResults*/ ) { return E_NOTIMPL; @@ -80,12 +75,31 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, __inout LPVOID /*pvResults*/, - __inout HRESULT* /*phr*/, - __in_opt LPVOID /*pvContext*/ + __inout HRESULT* /*phr*/ ) { } + virtual STDMETHODIMP OnCreate( + __in IBootstrapperEngine* pEngine, + __in BOOTSTRAPPER_COMMAND* /*pCommand*/ + ) + { + HRESULT hr = S_OK; + + pEngine->AddRef(); + m_pEngine = pEngine; + + return hr; + } + + virtual STDMETHODIMP OnDestroy( + __in BOOL /*fReload*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP OnStartup() { return S_OK; @@ -837,20 +851,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnSetUpdateBegin() - { - return S_OK; - } - - virtual STDMETHODIMP OnSetUpdateComplete( - __in HRESULT /*hrStatus*/, - __in_z_opt LPCWSTR /*wzPreviousPackageId*/, - __in_z_opt LPCWSTR /*wzNewPackageId*/ - ) - { - return S_OK; - } - virtual STDMETHODIMP OnPlanRestoreRelatedBundle( __in_z LPCWSTR /*wzBundleId*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, @@ -996,22 +996,13 @@ public: // IBAFunctions } protected: - CBalBaseBAFunctions( - __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, - __in const BA_FUNCTIONS_CREATE_ARGS* pArgs - ) + CBalBaseBAFunctions(HMODULE hModule) { m_cReferences = 1; m_hModule = hModule; - pEngine->AddRef(); - m_pEngine = pEngine; - memcpy_s(&m_command, sizeof(m_command), pArgs->pBootstrapperCreateArgs->pCommand, sizeof(BOOTSTRAPPER_COMMAND)); - memcpy_s(&m_baCreateArgs, sizeof(m_baCreateArgs), pArgs->pBootstrapperCreateArgs, sizeof(BOOTSTRAPPER_CREATE_ARGS)); - memcpy_s(&m_bafCreateArgs, sizeof(m_bafCreateArgs), pArgs, sizeof(BA_FUNCTIONS_CREATE_ARGS)); - m_baCreateArgs.pCommand = &m_command; - m_bafCreateArgs.pBootstrapperCreateArgs = &m_baCreateArgs; + m_hwndParent = NULL; + m_pEngine = NULL; } virtual ~CBalBaseBAFunctions() @@ -1025,8 +1016,5 @@ private: protected: IBootstrapperEngine* m_pEngine; HMODULE m_hModule; - BA_FUNCTIONS_CREATE_ARGS m_bafCreateArgs; - BOOTSTRAPPER_CREATE_ARGS m_baCreateArgs; - BOOTSTRAPPER_COMMAND m_command; HWND m_hwndParent; }; diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h index 728bd2b5..65eeb0b4 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h @@ -1,191 +1,15 @@ #pragma once // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "BalBaseBootstrapperApplicationProc.h" -#include "BAFunctions.h" -#include "IBAFunctions.h" - -static HRESULT BalBaseBAFunctionsProcOnThemeLoaded( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_ONTHEMELOADED_ARGS* pArgs, - __inout BA_FUNCTIONS_ONTHEMELOADED_RESULTS* /*pResults*/ - ) -{ - return pBAFunctions->OnThemeLoaded(pArgs->hWnd); -} - -static HRESULT BalBaseBAFunctionsProcWndProc( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_WNDPROC_ARGS* pArgs, - __inout BA_FUNCTIONS_WNDPROC_RESULTS* pResults - ) -{ - return pBAFunctions->WndProc(pArgs->hWnd, pArgs->uMsg, pArgs->wParam, pArgs->lParam, &pResults->fProcessed, &pResults->lResult); -} - -static HRESULT BalBaseBAFunctionsProcOnThemeControlLoading( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_ONTHEMECONTROLLOADING_ARGS* pArgs, - __inout BA_FUNCTIONS_ONTHEMECONTROLLOADING_RESULTS* pResults - ) -{ - return pBAFunctions->OnThemeControlLoading(pArgs->wzName, &pResults->fProcessed, &pResults->wId, &pResults->dwAutomaticBehaviorType); -} - -static HRESULT BalBaseBAFunctionsProcOnThemeControlWmCommand( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_ONTHEMECONTROLWMCOMMAND_ARGS* pArgs, - __inout BA_FUNCTIONS_ONTHEMECONTROLWMCOMMAND_RESULTS* pResults - ) -{ - return pBAFunctions->OnThemeControlWmCommand(pArgs->wParam, pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed, &pResults->lResult); -} - -static HRESULT BalBaseBAFunctionsProcOnThemeControlWmNotify( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_ONTHEMECONTROLWMNOTIFY_ARGS* pArgs, - __inout BA_FUNCTIONS_ONTHEMECONTROLWMNOTIFY_RESULTS* pResults - ) -{ - return pBAFunctions->OnThemeControlWmNotify(pArgs->lParam, pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed, &pResults->lResult); -} - -static HRESULT BalBaseBAFunctionsProcOnThemeControlLoaded( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_ONTHEMECONTROLLOADED_ARGS* pArgs, - __inout BA_FUNCTIONS_ONTHEMECONTROLLOADED_RESULTS* pResults - ) -{ - return pBAFunctions->OnThemeControlLoaded(pArgs->wzName, pArgs->wId, pArgs->hWnd, &pResults->fProcessed); -} - /******************************************************************* BalBaseBAFunctionsProc - requires pvContext to be of type IBAFunctions. Provides a default mapping between the message based BAFunctions interface and the COM-based BAFunctions interface. *******************************************************************/ -static HRESULT WINAPI BalBaseBAFunctionsProc( +HRESULT WINAPI BalBaseBAFunctionsProc( __in BA_FUNCTIONS_MESSAGE message, __in const LPVOID pvArgs, __inout LPVOID pvResults, __in_opt LPVOID pvContext - ) -{ - IBAFunctions* pBAFunctions = reinterpret_cast(pvContext); - HRESULT hr = pBAFunctions->BAFunctionsProc(message, pvArgs, pvResults, pvContext); - - if (E_NOTIMPL == hr) - { - switch (message) - { - case BA_FUNCTIONS_MESSAGE_ONDETECTBEGIN: - case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONPLANBEGIN: - case BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONSTARTUP: - case BA_FUNCTIONS_MESSAGE_ONSHUTDOWN: - case BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: - case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE: - case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE: - case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE: - case BA_FUNCTIONS_MESSAGE_ONDETECTPATCHTARGET: - case BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE: - case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE: - case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONPLANPATCHTARGET: - case BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE: - case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN: - case BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONERROR: - case BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN: - case BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN: - case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING: - case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN: - case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN: - case BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE: - 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: - case BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE: - case BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: - case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN: - case BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN: - case BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONPLANROLLBACKBOUNDARY: - case BA_FUNCTIONS_MESSAGE_ONSETUPDATEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONSETUPDATECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: - case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: - case BA_FUNCTIONS_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: - case BA_FUNCTIONS_MESSAGE_ONPLANRESTORERELATEDBUNDLE: - case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLETYPE: - case BA_FUNCTIONS_MESSAGE_ONAPPLYDOWNGRADE: - case BA_FUNCTIONS_MESSAGE_ONEXECUTEPROCESSCANCEL: - case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE: - case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE: - hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); - break; - case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: - hr = BalBaseBAFunctionsProcOnThemeLoaded(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BA_FUNCTIONS_MESSAGE_WNDPROC: - hr = BalBaseBAFunctionsProcWndProc(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADING: - hr = BalBaseBAFunctionsProcOnThemeControlLoading(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMCOMMAND: - hr = BalBaseBAFunctionsProcOnThemeControlWmCommand(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLWMNOTIFY: - hr = BalBaseBAFunctionsProcOnThemeControlWmNotify(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BA_FUNCTIONS_MESSAGE_ONTHEMECONTROLLOADED: - hr = BalBaseBAFunctionsProcOnThemeControlLoaded(pBAFunctions, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - } - } - - return hr; -} + ); diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h index ae7b2a93..30c75fb6 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h @@ -3,8 +3,6 @@ #include #include -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" #include "IBootstrapperEngine.h" #include "IBootstrapperApplication.h" @@ -12,7 +10,9 @@ #include "balinfo.h" #include "balretry.h" -class CBalBaseBootstrapperApplication : public IBootstrapperApplication +#define CBalBaseBootstrapperApplication CBootstrapperApplication + +class CBootstrapperApplication : public IBootstrapperApplication { public: // IUnknown virtual STDMETHODIMP QueryInterface( @@ -65,8 +65,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ + __inout LPVOID /*pvResults*/ ) { return E_NOTIMPL; @@ -76,10 +75,35 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, __inout LPVOID /*pvResults*/, - __inout HRESULT* /*phr*/, - __in_opt LPVOID /*pvContext*/ + __inout HRESULT* /*phr*/ + ) + { + } + + virtual STDMETHODIMP OnCreate( + __in IBootstrapperEngine* pEngine, + __in BOOTSTRAPPER_COMMAND* pCommand + ) + { + HRESULT hr = S_OK; + + m_commandDisplay = pCommand->display; + + hr = BalInfoParseCommandLine(&m_BalInfoCommand, pCommand); + BalExitOnFailure(hr, "Failed to parse command line with balutil."); + + pEngine->AddRef(); + m_pEngine = pEngine; + + LExit: + return hr; + } + + virtual STDMETHODIMP OnDestroy( + __in BOOL /*fReload*/ ) { + return S_OK; } virtual STDMETHODIMP OnStartup() @@ -429,7 +453,7 @@ public: // IBootstrapperApplication m_dwProgressPercentage = dwProgressPercentage; m_dwOverallProgressPercentage = dwOverallProgressPercentage; - if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_commandDisplay) { hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); BalExitOnFailure(hr, "Failed to send embedded overall progress."); @@ -463,7 +487,7 @@ public: // IBootstrapperApplication { BalRetryErrorOccurred(wzPackageId, dwCode); - if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_commandDisplay) { HRESULT hr = m_pEngine->SendEmbeddedError(dwCode, wzError, dwUIHint, pResult); if (FAILED(hr)) @@ -475,7 +499,7 @@ public: // IBootstrapperApplication { *pResult = IDCANCEL; } - else if (BOOTSTRAPPER_DISPLAY_FULL == m_display) + else if (BOOTSTRAPPER_DISPLAY_FULL == m_commandDisplay) { if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType) { @@ -553,7 +577,7 @@ public: // IBootstrapperApplication // Send progress even though we don't update the numbers to at least give the caller an opportunity // to cancel. - if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_commandDisplay) { hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); BalExitOnFailure(hr, "Failed to send embedded cache progress."); @@ -733,7 +757,7 @@ public: // IBootstrapperApplication // Send progress even though we don't update the numbers to at least give the caller an opportunity // to cancel. - if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_commandDisplay) { hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); BalExitOnFailure(hr, "Failed to send embedded execute progress."); @@ -848,7 +872,7 @@ public: // IBootstrapperApplication { HRESULT hr = S_OK; BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart; - BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BAL_INFO_RESTART_PROMPT >= m_BalInfoCommand.restart; + BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_commandDisplay && BAL_INFO_RESTART_PROMPT >= m_BalInfoCommand.restart; if (fRestartRequired && !fShouldBlockRestart) { @@ -1050,20 +1074,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnSetUpdateBegin() - { - return S_OK; - } - - virtual STDMETHODIMP OnSetUpdateComplete( - __in HRESULT /*hrStatus*/, - __in_z_opt LPCWSTR /*wzPreviousPackageId*/, - __in_z_opt LPCWSTR /*wzNewPackageId*/ - ) - { - return S_OK; - } - virtual STDMETHODIMP OnPlanRestoreRelatedBundle( __in_z LPCWSTR /*wzBundleId*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, @@ -1127,22 +1137,6 @@ public: // IBootstrapperApplication return S_OK; } -public: //CBalBaseBootstrapperApplication - virtual STDMETHODIMP Initialize( - __in const BOOTSTRAPPER_CREATE_ARGS* pCreateArgs - ) - { - HRESULT hr = S_OK; - - m_display = pCreateArgs->pCommand->display; - - hr = BalInfoParseCommandLine(&m_BalInfoCommand, pCreateArgs->pCommand); - BalExitOnFailure(hr, "Failed to parse command line with balutil."); - - LExit: - return hr; - } - protected: // // PromptCancel - prompts the user to close (if not forced). @@ -1195,16 +1189,14 @@ protected: } CBalBaseBootstrapperApplication( - __in IBootstrapperEngine* pEngine, __in DWORD dwRetryCount = 0, __in DWORD dwRetryTimeout = 1000 ) { m_cReferences = 1; - m_display = BOOTSTRAPPER_DISPLAY_UNKNOWN; + m_commandDisplay = BOOTSTRAPPER_DISPLAY_UNKNOWN; - pEngine->AddRef(); - m_pEngine = pEngine; + m_pEngine = NULL; ::InitializeCriticalSection(&m_csCanceled); m_fCanceled = FALSE; @@ -1230,12 +1222,12 @@ protected: CRITICAL_SECTION m_csCanceled; BOOL m_fCanceled; + IBootstrapperEngine* m_pEngine; BAL_INFO_COMMAND m_BalInfoCommand; private: long m_cReferences; - BOOTSTRAPPER_DISPLAY m_display; - IBootstrapperEngine* m_pEngine; + BOOTSTRAPPER_DISPLAY m_commandDisplay; BOOL m_fRollingBack; diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h deleted file mode 100644 index 34739ba3..00000000 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ /dev/null @@ -1,1045 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#include - -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" - -static HRESULT BalBaseBAProcOnDetectBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTBEGIN_ARGS* pArgs, - __inout BA_ONDETECTBEGIN_RESULTS* pResults - ) -{ - return pBA->OnDetectBegin(pArgs->fCached, pArgs->registrationType, pArgs->cPackages, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTCOMPLETE_ARGS* pArgs, - __inout BA_ONDETECTCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnDetectComplete(pArgs->hrStatus, pArgs->fEligibleForCleanup); -} - -static HRESULT BalBaseBAProcOnPlanBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANBEGIN_ARGS* pArgs, - __inout BA_ONPLANBEGIN_RESULTS* pResults - ) -{ - return pBA->OnPlanBegin(pArgs->cPackages, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANCOMPLETE_ARGS* pArgs, - __inout BA_ONPLANCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPlanComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnStartup( - __in IBootstrapperApplication* pBA, - __in BA_ONSTARTUP_ARGS* /*pArgs*/, - __inout BA_ONSTARTUP_RESULTS* /*pResults*/ - ) -{ - return pBA->OnStartup(); -} - -static HRESULT BalBaseBAProcOnShutdown( - __in IBootstrapperApplication* pBA, - __in BA_ONSHUTDOWN_ARGS* /*pArgs*/, - __inout BA_ONSHUTDOWN_RESULTS* pResults - ) -{ - return pBA->OnShutdown(&pResults->action); -} - -static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, - __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults - ) -{ - return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fMissingFromCache, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectUpdateBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTUPDATEBEGIN_ARGS* pArgs, - __inout BA_ONDETECTUPDATEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnDetectUpdateBegin(pArgs->wzUpdateLocation, &pResults->fCancel, &pResults->fSkip); -} - -static HRESULT BalBaseBAProcOnDetectUpdate( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTUPDATE_ARGS* pArgs, - __inout BA_ONDETECTUPDATE_RESULTS* pResults - ) -{ - return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->wzHash, pArgs->hashAlgorithm, pArgs->wzVersion, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); -} - -static HRESULT BalBaseBAProcOnDetectUpdateComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTUPDATECOMPLETE_ARGS* pArgs, - __inout BA_ONDETECTUPDATECOMPLETE_RESULTS* pResults - ) -{ - return pBA->OnDetectUpdateComplete(pArgs->hrStatus, &pResults->fIgnoreError); -} - -static HRESULT BalBaseBAProcOnDetectRelatedBundle( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTRELATEDBUNDLE_ARGS* pArgs, - __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults - ) -{ - return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fMissingFromCache, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectPackageBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTPACKAGEBEGIN_ARGS* pArgs, - __inout BA_ONDETECTPACKAGEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnDetectPackageBegin(pArgs->wzPackageId, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectCompatiblePackage( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS* pArgs, - __inout BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS* pResults - ) -{ - return pBA->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTRELATEDMSIPACKAGE_ARGS* pArgs, - __inout BA_ONDETECTRELATEDMSIPACKAGE_RESULTS* pResults - ) -{ - return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectPatchTarget( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTPATCHTARGET_ARGS* pArgs, - __inout BA_ONDETECTPATCHTARGET_RESULTS* pResults - ) -{ - return pBA->OnDetectPatchTarget(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->patchState, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectMsiFeature( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTMSIFEATURE_ARGS* pArgs, - __inout BA_ONDETECTMSIFEATURE_RESULTS* pResults - ) -{ - return pBA->OnDetectMsiFeature(pArgs->wzPackageId, pArgs->wzFeatureId, pArgs->state, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectPackageComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTPACKAGECOMPLETE_ARGS* pArgs, - __inout BA_ONDETECTPACKAGECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnDetectPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state, pArgs->fCached); -} - -static HRESULT BalBaseBAProcOnPlanRelatedBundle( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANRELATEDBUNDLE_ARGS* pArgs, - __inout BA_ONPLANRELATEDBUNDLE_RESULTS* pResults - ) -{ - return pBA->OnPlanRelatedBundle(pArgs->wzBundleId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanRollbackBoundary( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANROLLBACKBOUNDARY_ARGS* pArgs, - __inout BA_ONPLANROLLBACKBOUNDARY_RESULTS* pResults - ) -{ - return pBA->OnPlanRollbackBoundary(pArgs->wzRollbackBoundaryId, pArgs->fRecommendedTransaction, &pResults->fTransaction, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanPackageBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANPACKAGEBEGIN_ARGS* pArgs, - __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->state, pArgs->fCached, pArgs->installCondition, pArgs->repairCondition, pArgs->recommendedState, pArgs->recommendedCacheType, &pResults->requestedState, &pResults->requestedCacheType, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS* pArgs, - __inout BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, pArgs->fRecommendedRemove, &pResults->fRequestRemove, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS* pArgs, - __inout BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPlanCompatibleMsiPackageComplete(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->hrStatus, pArgs->fRequestedRemove); -} - -static HRESULT BalBaseBAProcOnPlanPatchTarget( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANPATCHTARGET_ARGS* pArgs, - __inout BA_ONPLANPATCHTARGET_RESULTS* pResults - ) -{ - return pBA->OnPlanPatchTarget(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanMsiFeature( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANMSIFEATURE_ARGS* pArgs, - __inout BA_ONPLANMSIFEATURE_RESULTS* pResults - ) -{ - return pBA->OnPlanMsiFeature(pArgs->wzPackageId, pArgs->wzFeatureId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanPackageComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANPACKAGECOMPLETE_ARGS* pArgs, - __inout BA_ONPLANPACKAGECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPlanPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->requested); -} - -static HRESULT BalBaseBAProcOnPlannedCompatiblePackage( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS* pArgs, - __inout BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPlannedCompatiblePackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->fRemove); -} - -static HRESULT BalBaseBAProcOnPlannedPackage( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANNEDPACKAGE_ARGS* pArgs, - __inout BA_ONPLANNEDPACKAGE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPlannedPackage(pArgs->wzPackageId, pArgs->execute, pArgs->rollback, pArgs->fPlannedCache, pArgs->fPlannedUncache); -} - -static HRESULT BalBaseBAProcOnApplyBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONAPPLYBEGIN_ARGS* pArgs, - __inout BA_ONAPPLYBEGIN_RESULTS* pResults - ) -{ - return pBA->OnApplyBegin(pArgs->dwPhaseCount, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnElevateBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONELEVATEBEGIN_ARGS* /*pArgs*/, - __inout BA_ONELEVATEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnElevateBegin(&pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnElevateComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONELEVATECOMPLETE_ARGS* pArgs, - __inout BA_ONELEVATECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnElevateComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnProgress( - __in IBootstrapperApplication* pBA, - __in BA_ONPROGRESS_ARGS* pArgs, - __inout BA_ONPROGRESS_RESULTS* pResults - ) -{ - return pBA->OnProgress(pArgs->dwProgressPercentage, pArgs->dwOverallPercentage, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnError( - __in IBootstrapperApplication* pBA, - __in BA_ONERROR_ARGS* pArgs, - __inout BA_ONERROR_RESULTS* pResults - ) -{ - return pBA->OnError(pArgs->errorType, pArgs->wzPackageId, pArgs->dwCode, pArgs->wzError, pArgs->dwUIHint, pArgs->cData, pArgs->rgwzData, pArgs->nRecommendation, &pResults->nResult); -} - -static HRESULT BalBaseBAProcOnRegisterBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONREGISTERBEGIN_ARGS* pArgs, - __inout BA_ONREGISTERBEGIN_RESULTS* pResults - ) -{ - return pBA->OnRegisterBegin(pArgs->recommendedRegistrationType, &pResults->fCancel, &pResults->registrationType); -} - -static HRESULT BalBaseBAProcOnRegisterComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONREGISTERCOMPLETE_ARGS* pArgs, - __inout BA_ONREGISTERCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnRegisterComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnCacheBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEBEGIN_ARGS* /*pArgs*/, - __inout BA_ONCACHEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCacheBegin(&pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCachePackageBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEPACKAGEBEGIN_ARGS* pArgs, - __inout BA_ONCACHEPACKAGEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCachePackageBegin(pArgs->wzPackageId, pArgs->cCachePayloads, pArgs->dw64PackageCacheSize, pArgs->fVital, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheAcquireBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEACQUIREBEGIN_ARGS* pArgs, - __inout BA_ONCACHEACQUIREBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzSource, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->action, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheAcquireProgress( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEACQUIREPROGRESS_ARGS* pArgs, - __inout BA_ONCACHEACQUIREPROGRESS_RESULTS* pResults - ) -{ - return pBA->OnCacheAcquireProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheAcquireResolving( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEACQUIRERESOLVING_ARGS* pArgs, - __inout BA_ONCACHEACQUIRERESOLVING_RESULTS* pResults - ) -{ - return pBA->OnCacheAcquireResolving(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->rgSearchPaths, pArgs->cSearchPaths, pArgs->fFoundLocal, pArgs->dwRecommendedSearchPath, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->dwChosenSearchPath, &pResults->action, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheAcquireComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEACQUIRECOMPLETE_ARGS* pArgs, - __inout BA_ONCACHEACQUIRECOMPLETE_RESULTS* pResults - ) -{ - return pBA->OnCacheAcquireComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); -} - -static HRESULT BalBaseBAProcOnCacheVerifyBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEVERIFYBEGIN_ARGS* pArgs, - __inout BA_ONCACHEVERIFYBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCacheVerifyBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheVerifyProgress( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEVERIFYPROGRESS_ARGS* pArgs, - __inout BA_ONCACHEVERIFYPROGRESS_RESULTS* pResults - ) -{ - return pBA->OnCacheVerifyProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, pArgs->verifyStep, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheVerifyComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEVERIFYCOMPLETE_ARGS* pArgs, - __inout BA_ONCACHEVERIFYCOMPLETE_RESULTS* pResults - ) -{ - return pBA->OnCacheVerifyComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); -} - -static HRESULT BalBaseBAProcOnCachePackageComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEPACKAGECOMPLETE_ARGS* pArgs, - __inout BA_ONCACHEPACKAGECOMPLETE_RESULTS* pResults - ) -{ - return pBA->OnCachePackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); -} - -static HRESULT BalBaseBAProcOnCacheComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHECOMPLETE_ARGS* pArgs, - __inout BA_ONCACHECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnCacheComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnExecuteBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEBEGIN_ARGS* pArgs, - __inout BA_ONEXECUTEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnExecuteBegin(pArgs->cExecutingPackages, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnExecutePackageBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEPACKAGEBEGIN_ARGS* pArgs, - __inout BA_ONEXECUTEPACKAGEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, pArgs->uiLevel, pArgs->fDisableExternalUiHandler, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnExecutePatchTarget( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEPATCHTARGET_ARGS* pArgs, - __inout BA_ONEXECUTEPATCHTARGET_RESULTS* pResults - ) -{ - return pBA->OnExecutePatchTarget(pArgs->wzPackageId, pArgs->wzTargetProductCode, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnExecuteProgress( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEPROGRESS_ARGS* pArgs, - __inout BA_ONEXECUTEPROGRESS_RESULTS* pResults - ) -{ - return pBA->OnExecuteProgress(pArgs->wzPackageId, pArgs->dwProgressPercentage, pArgs->dwOverallPercentage, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnExecuteMsiMessage( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEMSIMESSAGE_ARGS* pArgs, - __inout BA_ONEXECUTEMSIMESSAGE_RESULTS* pResults - ) -{ - return pBA->OnExecuteMsiMessage(pArgs->wzPackageId, pArgs->messageType, pArgs->dwUIHint, pArgs->wzMessage, pArgs->cData, pArgs->rgwzData, pArgs->nRecommendation, &pResults->nResult); -} - -static HRESULT BalBaseBAProcOnExecuteFilesInUse( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEFILESINUSE_ARGS* pArgs, - __inout BA_ONEXECUTEFILESINUSE_RESULTS* pResults - ) -{ - return pBA->OnExecuteFilesInUse(pArgs->wzPackageId, pArgs->cFiles, pArgs->rgwzFiles, pArgs->nRecommendation, pArgs->source, &pResults->nResult); -} - -static HRESULT BalBaseBAProcOnExecutePackageComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEPACKAGECOMPLETE_ARGS* pArgs, - __inout BA_ONEXECUTEPACKAGECOMPLETE_RESULTS* pResults - ) -{ - return pBA->OnExecutePackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action); -} - -static HRESULT BalBaseBAProcOnExecuteProcessCancel( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTEPROCESSCANCEL_ARGS* pArgs, - __inout BA_ONEXECUTEPROCESSCANCEL_RESULTS* pResults - ) -{ - return pBA->OnExecuteProcessCancel(pArgs->wzPackageId, pArgs->dwProcessId, pArgs->recommendation, &pResults->action); -} - -static HRESULT BalBaseBAProcOnExecuteComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONEXECUTECOMPLETE_ARGS* pArgs, - __inout BA_ONEXECUTECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnExecuteComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnUnregisterBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONUNREGISTERBEGIN_ARGS* pArgs, - __inout BA_ONUNREGISTERBEGIN_RESULTS* pResults - ) -{ - return pBA->OnUnregisterBegin(pArgs->recommendedRegistrationType, &pResults->registrationType); -} - -static HRESULT BalBaseBAProcOnUnregisterComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONUNREGISTERCOMPLETE_ARGS* pArgs, - __inout BA_ONUNREGISTERCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnUnregisterComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnApplyComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONAPPLYCOMPLETE_ARGS* pArgs, - __inout BA_ONAPPLYCOMPLETE_RESULTS* pResults - ) -{ - return pBA->OnApplyComplete(pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action); -} - -static HRESULT BalBaseBAProcOnLaunchApprovedExeBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS* /*pArgs*/, - __inout BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS* pResults - ) -{ - return pBA->OnLaunchApprovedExeBegin(&pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnLaunchApprovedExeComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS* pArgs, - __inout BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnLaunchApprovedExeComplete(pArgs->hrStatus, pArgs->dwProcessId); -} - -static HRESULT BalBaseBAProcOnPlanMsiPackage( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANMSIPACKAGE_ARGS* pArgs, - __inout BA_ONPLANMSIPACKAGE_RESULTS* pResults - ) -{ - return pBA->OnPlanMsiPackage(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, pArgs->recommendedFileVersioning, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler, &pResults->fileVersioning); -} - -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, pArgs->restart, pArgs->recommendation, &pResults->action); -} - -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, pArgs->restart, pArgs->recommendation, &pResults->action); -} - -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); -} - -static HRESULT BalBaseBAProcOnPlanForwardCompatibleBundle( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, - __inout BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults - ) -{ - return pBA->OnPlanForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fRecommendedIgnoreBundle, &pResults->fCancel, &pResults->fIgnoreBundle); -} - -static HRESULT BalBaseBAProcOnCacheContainerOrPayloadVerifyBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS* pArgs, - __inout BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCacheContainerOrPayloadVerifyBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheContainerOrPayloadVerifyProgress( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS* pArgs, - __inout BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS* pResults - ) -{ - return pBA->OnCacheContainerOrPayloadVerifyProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCacheContainerOrPayloadVerifyComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS* pArgs, - __inout BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnCacheContainerOrPayloadVerifyComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnCachePayloadExtractBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS* pArgs, - __inout BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCachePayloadExtractBegin(pArgs->wzContainerId, pArgs->wzPayloadId, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCachePayloadExtractProgress( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS* pArgs, - __inout BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS* pResults - ) -{ - return pBA->OnCachePayloadExtractProgress(pArgs->wzContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCachePayloadExtractComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS* pArgs, - __inout BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnCachePayloadExtractComplete(pArgs->wzContainerId, pArgs->wzPayloadId, pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnSetUpdateBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONSETUPDATEBEGIN_ARGS* /*pArgs*/, - __inout BA_ONSETUPDATEBEGIN_RESULTS* /*pResults*/ - ) -{ - return pBA->OnSetUpdateBegin(); -} - -static HRESULT BalBaseBAProcOnSetUpdateComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONSETUPDATECOMPLETE_ARGS* pArgs, - __inout BA_ONSETUPDATECOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnSetUpdateComplete(pArgs->hrStatus, pArgs->wzPreviousPackageId, pArgs->wzNewPackageId); -} - -static HRESULT BalBaseBAProcOnPlanRestoreRelatedBundle( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANRESTORERELATEDBUNDLE_ARGS* pArgs, - __inout BA_ONPLANRESTORERELATEDBUNDLE_RESULTS* pResults - ) -{ - return pBA->OnPlanRestoreRelatedBundle(pArgs->wzBundleId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnPlanRelatedBundleType( - __in IBootstrapperApplication* pBA, - __in BA_ONPLANRELATEDBUNDLETYPE_ARGS* pArgs, - __inout BA_ONPLANRELATEDBUNDLETYPE_RESULTS* pResults - ) -{ - return pBA->OnPlanRelatedBundleType(pArgs->wzBundleId, pArgs->recommendedType, &pResults->requestedType, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnApplyDowngrade( - __in IBootstrapperApplication* pBA, - __in BA_ONAPPLYDOWNGRADE_ARGS* pArgs, - __inout BA_ONAPPLYDOWNGRADE_RESULTS* pResults - ) -{ - return pBA->OnApplyDowngrade(pArgs->hrRecommended, &pResults->hrStatus); -} - -static HRESULT BalBaseBAProcOnDetectRelatedBundlePackage( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS* pArgs, - __inout BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS* pResults - ) -{ - return pBA->OnDetectRelatedBundlePackage(pArgs->wzPackageId, pArgs->wzBundleId, pArgs->relationType, pArgs->fPerMachine, pArgs->wzVersion, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCachePackageNonVitalValidationFailure( - __in IBootstrapperApplication* pBA, - __in BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS* pArgs, - __inout BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS* pResults - ) -{ - return pBA->OnCachePackageNonVitalValidationFailure(pArgs->wzPackageId, pArgs->hrStatus, pArgs->recommendation, &pResults->action); -} - -/******************************************************************* -BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. - Provides a default mapping between the new message based BA interface and - the old COM-based BA interface. - -*******************************************************************/ -static HRESULT WINAPI BalBaseBootstrapperApplicationProc( - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ) -{ - IBootstrapperApplication* pBA = reinterpret_cast(pvContext); - HRESULT hr = pBA->BAProc(message, pvArgs, pvResults, pvContext); - - if (E_NOTIMPL == hr) - { - switch (message) - { - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN: - hr = BalBaseBAProcOnDetectBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE: - hr = BalBaseBAProcOnDetectComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN: - hr = BalBaseBAProcOnPlanBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE: - hr = BalBaseBAProcOnPlanComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP: - hr = BalBaseBAProcOnStartup(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN: - hr = BalBaseBAProcOnShutdown(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: - hr = BalBaseBAProcOnDetectForwardCompatibleBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN: - hr = BalBaseBAProcOnDetectUpdateBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE: - hr = BalBaseBAProcOnDetectUpdate(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE: - hr = BalBaseBAProcOnDetectUpdateComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE: - hr = BalBaseBAProcOnDetectRelatedBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN: - hr = BalBaseBAProcOnDetectPackageBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE: - hr = BalBaseBAProcOnDetectRelatedMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET: - hr = BalBaseBAProcOnDetectPatchTarget(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE: - hr = BalBaseBAProcOnDetectMsiFeature(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE: - hr = BalBaseBAProcOnDetectPackageComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE: - hr = BalBaseBAProcOnPlanRelatedBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: - hr = BalBaseBAProcOnPlanPackageBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET: - hr = BalBaseBAProcOnPlanPatchTarget(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE: - hr = BalBaseBAProcOnPlanMsiFeature(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE: - hr = BalBaseBAProcOnPlanPackageComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN: - hr = BalBaseBAProcOnApplyBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN: - hr = BalBaseBAProcOnElevateBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE: - hr = BalBaseBAProcOnElevateComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS: - hr = BalBaseBAProcOnProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR: - hr = BalBaseBAProcOnError(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN: - hr = BalBaseBAProcOnRegisterBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE: - hr = BalBaseBAProcOnRegisterComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN: - hr = BalBaseBAProcOnCacheBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN: - hr = BalBaseBAProcOnCachePackageBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN: - hr = BalBaseBAProcOnCacheAcquireBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: - hr = BalBaseBAProcOnCacheAcquireProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING: - hr = BalBaseBAProcOnCacheAcquireResolving(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE: - hr = BalBaseBAProcOnCacheAcquireComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN: - hr = BalBaseBAProcOnCacheVerifyBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS: - hr = BalBaseBAProcOnCacheVerifyProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE: - hr = BalBaseBAProcOnCacheVerifyComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE: - hr = BalBaseBAProcOnCachePackageComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE: - hr = BalBaseBAProcOnCacheComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN: - hr = BalBaseBAProcOnExecuteBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN: - hr = BalBaseBAProcOnExecutePackageBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET: - hr = BalBaseBAProcOnExecutePatchTarget(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS: - hr = BalBaseBAProcOnExecuteProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE: - hr = BalBaseBAProcOnExecuteMsiMessage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE: - hr = BalBaseBAProcOnExecuteFilesInUse(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE: - hr = BalBaseBAProcOnExecutePackageComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE: - hr = BalBaseBAProcOnExecuteComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN: - hr = BalBaseBAProcOnUnregisterBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE: - hr = BalBaseBAProcOnUnregisterComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE: - hr = BalBaseBAProcOnApplyComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: - hr = BalBaseBAProcOnLaunchApprovedExeBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: - hr = BalBaseBAProcOnLaunchApprovedExeComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - 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; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE: - hr = BalBaseBAProcOnPlannedPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: - hr = BalBaseBAProcOnPlanForwardCompatibleBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN: - hr = BalBaseBAProcOnCacheContainerOrPayloadVerifyBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS: - hr = BalBaseBAProcOnCacheContainerOrPayloadVerifyProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE: - hr = BalBaseBAProcOnCacheContainerOrPayloadVerifyComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN: - hr = BalBaseBAProcOnCachePayloadExtractBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS: - hr = BalBaseBAProcOnCachePayloadExtractProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE: - hr = BalBaseBAProcOnCachePayloadExtractComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY: - hr = BalBaseBAProcOnPlanRollbackBoundary(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATEBEGIN: - hr = BalBaseBAProcOnSetUpdateBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATECOMPLETE: - hr = BalBaseBAProcOnSetUpdateComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: - hr = BalBaseBAProcOnDetectCompatiblePackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: - hr = BalBaseBAProcOnPlanCompatibleMsiPackageBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: - hr = BalBaseBAProcOnPlanCompatibleMsiPackageComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: - hr = BalBaseBAProcOnPlannedCompatiblePackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE: - hr = BalBaseBAProcOnPlanRestoreRelatedBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE: - hr = BalBaseBAProcOnPlanRelatedBundleType(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE: - hr = BalBaseBAProcOnApplyDowngrade(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL: - hr = BalBaseBAProcOnExecuteProcessCancel(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE: - hr = BalBaseBAProcOnDetectRelatedBundlePackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE: - hr = BalBaseBAProcOnCachePackageNonVitalValidationFailure(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - } - } - - pBA->BAProcFallback(message, pvArgs, pvResults, &hr, pvContext); - - return hr; -} diff --git a/src/api/burn/balutil/inc/BalBootstrapperEngine.h b/src/api/burn/balutil/inc/BalBootstrapperEngine.h deleted file mode 100644 index 45131d98..00000000 --- a/src/api/burn/balutil/inc/BalBootstrapperEngine.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#ifdef __cplusplus -extern "C" { -#endif - -// function declarations - -HRESULT BalBootstrapperEngineCreate( - __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, - __in_opt LPVOID pvBAEngineProcContext, - __out IBootstrapperEngine** ppEngineForApplication - ); - -#ifdef __cplusplus -} -#endif diff --git a/src/api/burn/balutil/inc/IBAFunctions.h b/src/api/burn/balutil/inc/IBAFunctions.h index bb911040..b0afabb3 100644 --- a/src/api/burn/balutil/inc/IBAFunctions.h +++ b/src/api/burn/balutil/inc/IBAFunctions.h @@ -2,6 +2,8 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +#include "IBootstrapperApplication.h" + DECLARE_INTERFACE_IID_(IBAFunctions, IBootstrapperApplication, "0FB445ED-17BD-49C7-BE19-479776F8AE96") { // OnThemeLoaded - Called after the BA finished loading all the controls for the theme. diff --git a/src/api/burn/balutil/inc/IBootstrapperApplication.h b/src/api/burn/balutil/inc/IBootstrapperApplication.h index faa211e4..6eb32ee6 100644 --- a/src/api/burn/balutil/inc/IBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/IBootstrapperApplication.h @@ -1,6 +1,8 @@ #pragma once // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +#include + DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-AB06-099D717C67FE") { @@ -9,8 +11,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(BAProc)( __in BOOTSTRAPPER_APPLICATION_MESSAGE message, __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext + __inout LPVOID pvResults ) = 0; // BAProcFallback - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method @@ -20,10 +21,22 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in BOOTSTRAPPER_APPLICATION_MESSAGE message, __in const LPVOID pvArgs, __inout LPVOID pvResults, - __inout HRESULT* phr, - __in_opt LPVOID pvContext + __inout HRESULT* phr + ) = 0; + + // OnCreate - called when the bootstrapper application is created. + // + virtual STDMETHODIMP OnCreate( + __in IBootstrapperEngine* pEngine, + __in BOOTSTRAPPER_COMMAND* pCommand ) = 0; + // OnDestroy - called before the bootstrapper application stops. + // + STDMETHOD(OnDestroy)( + __in BOOL fReload + ) = 0; + // OnStartup - called when the engine is ready for the bootstrapper application to start. // STDMETHOD(OnStartup)() = 0; @@ -688,14 +701,6 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in HRESULT hrStatus ) = 0; - STDMETHOD(OnSetUpdateBegin)() = 0; - - STDMETHOD(OnSetUpdateComplete)( - __in HRESULT hrStatus, - __in_z_opt LPCWSTR wzPreviousPackageId, - __in_z_opt LPCWSTR wzNewPackageId - ) = 0; - // OnPlanRestoreRelatedBundle - called when the engine begins planning an upgrade related bundle for restoring in case of failure. STDMETHOD(OnPlanRestoreRelatedBundle)( __in_z LPCWSTR wzBundleId, diff --git a/src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h b/src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h deleted file mode 100644 index fd603e50..00000000 --- a/src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#include "precomp.h" - -DECLARE_INTERFACE_IID_(IBootstrapperApplicationFactory, IUnknown, "2965A12F-AC7B-43A0-85DF-E4B2168478A4") -{ - STDMETHOD(Create)( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __inout BOOTSTRAPPER_CREATE_RESULTS *pResults - ); -}; diff --git a/src/api/burn/balutil/inc/IBootstrapperEngine.h b/src/api/burn/balutil/inc/IBootstrapperEngine.h index bfa13997..3c1afb77 100644 --- a/src/api/burn/balutil/inc/IBootstrapperEngine.h +++ b/src/api/burn/balutil/inc/IBootstrapperEngine.h @@ -1,6 +1,7 @@ #pragma once // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +#include DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-81512C29C2FB") { @@ -65,7 +66,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_z_opt LPCWSTR wzHash + __in_z_opt LPCWSTR wzHash, + __in_z_opt LPCWSTR wzUpdatePackageId ) = 0; STDMETHOD(SetLocalSource)( @@ -79,7 +81,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 __in_z_opt LPCWSTR wzPayloadId, __in_z LPCWSTR wzUrl, __in_z_opt LPCWSTR wzUser, - __in_z_opt LPCWSTR wzPassword + __in_z_opt LPCWSTR wzPassword, + __in_z_opt LPCWSTR wzAuthorizationHeader ) = 0; STDMETHOD(SetVariableNumeric)( @@ -128,7 +131,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 ) = 0; STDMETHOD(SetUpdateSource)( - __in_z LPCWSTR wzUrl + __in_z LPCWSTR wzUrl, + __in_z_opt LPCWSTR wzAuthorizationHeader ) = 0; STDMETHOD(CompareVersions)( @@ -143,5 +147,4 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 __out_ecount_opt(*pcchValue) LPWSTR wzValue, __inout SIZE_T* pcchValue ) = 0; - }; diff --git a/src/api/burn/balutil/inc/balinfo.h b/src/api/burn/balutil/inc/balinfo.h index 7c607c44..234284f6 100644 --- a/src/api/burn/balutil/inc/balinfo.h +++ b/src/api/burn/balutil/inc/balinfo.h @@ -152,7 +152,6 @@ DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( DAPI_(HRESULT) BalInfoAddUpdateBundleAsPackage( __in BAL_INFO_PACKAGES* pPackages, __in_z LPCWSTR wzId, - __in_z LPCWSTR wzPreviousId, __out_opt BAL_INFO_PACKAGE** ppPackage ); diff --git a/src/api/burn/balutil/inc/balutil.h b/src/api/burn/balutil/inc/balutil.h index 36c165a3..4f8cb23d 100644 --- a/src/api/burn/balutil/inc/balutil.h +++ b/src/api/burn/balutil/inc/balutil.h @@ -39,28 +39,34 @@ const LPCWSTR BAL_MANIFEST_FILENAME = L"BootstrapperApplicationData.xml"; static const HRESULT E_WIXSTDBA_CONDITION_FAILED = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1); -static const HRESULT E_MBAHOST_NET452_ON_WIN7RTM = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1000); -static const HRESULT E_DNCHOST_SCD_RUNTIME_FAILURE = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1001); static const HRESULT E_PREREQBA_INFINITE_LOOP = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1002); /******************************************************************* - BalInitialize - remembers the engine interface to enable logging and - other functions. + BootstrapperApplicationDebuggerCheck - allows bootstrapper application to + explicitly check whether a debugger should be attached to the boostrapper + application. + Note: Automatically called in BootstrapperApplicationRun(). ********************************************************************/ -DAPI_(void) BalInitialize( - __in IBootstrapperEngine* pEngine +DAPI_(VOID) BootstrapperApplicationDebuggerCheck(); + +/******************************************************************* + BootstrapperApplicationRun - runs the IBootstrapperApplication until + the application quits. + +********************************************************************/ +DAPI_(HRESULT) BootstrapperApplicationRun( + __in IBootstrapperApplication* pApplication ); /******************************************************************* - BalInitializeFromCreateArgs - convenience function to call BalBootstrapperEngineCreate - then pass it along to BalInitialize. + BalInitialize - remembers the engine interface to enable logging and + other functions. ********************************************************************/ -DAPI_(HRESULT) BalInitializeFromCreateArgs( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __out_opt IBootstrapperEngine** ppEngine +DAPI_(void) BalInitialize( + __in IBootstrapperEngine* pEngine ); /******************************************************************* @@ -292,7 +298,7 @@ DAPI_(HRESULT) BalLogErrorArgs( ); /******************************************************************* -BalLogId - logs a message with the engine with a string embedded in a +BalLogId - logs a message with the engine with a string embedded in a MESSAGETABLE resource. ********************************************************************/ diff --git a/src/api/burn/balutil/msg.cpp b/src/api/burn/balutil/msg.cpp new file mode 100644 index 00000000..690108a5 --- /dev/null +++ b/src/api/burn/balutil/msg.cpp @@ -0,0 +1,5263 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +static HRESULT OnApplyBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONAPPLYBEGIN_ARGS args = { }; + BA_ONAPPLYBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnApplyBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwPhaseCount); + ExitOnFailure(hr, "Failed to read phase count of OnApplyBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnApplyBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnApplyBegin(args.dwPhaseCount, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnApplyBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnApplyBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnApplyBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnApplyComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONAPPLYCOMPLETE_ARGS args = { }; + BA_ONAPPLYCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnApplyComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnApplyComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); + ExitOnFailure(hr, "Failed to read restart of OnApplyComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnApplyComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnApplyComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnApplyComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnApplyComplete(args.hrStatus, args.restart, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnApplyComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnApplyComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnApplyComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnApplyDowngrade( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONAPPLYDOWNGRADE_ARGS args = { }; + BA_ONAPPLYDOWNGRADE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnApplyDowngrade args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrRecommended)); + ExitOnFailure(hr, "Failed to read recommended of OnApplyDowngrade args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnApplyDowngrade results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnApplyDowngrade results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnApplyDowngrade(args.hrRecommended, &results.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnApplyDowngrade failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnApplyDowngrade struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.hrStatus); + ExitOnFailure(hr, "Failed to write status of OnApplyDowngrade struct."); + +LExit: + return hr; +} + +static HRESULT OnBeginMsiTransactionBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONBEGINMSITRANSACTIONBEGIN_ARGS args = { }; + BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS results = { }; + LPWSTR sczTransactionId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); + ExitOnFailure(hr, "Failed to read recommended of OnBeginMsiTransactionBegin args."); + + args.wzTransactionId = sczTransactionId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnBeginMsiTransactionBegin(args.wzTransactionId, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnBeginMsiTransactionBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnBeginMsiTransactionBegin struct."); + +LExit: + ReleaseStr(sczTransactionId); + return hr; +} + +static HRESULT OnBeginMsiTransactionComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS args = { }; + BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS results = { }; + LPWSTR sczTransactionId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); + ExitOnFailure(hr, "Failed to read transaction id of OnBeginMsiTransactionComplete args."); + + args.wzTransactionId = sczTransactionId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnBeginMsiTransactionComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnBeginMsiTransactionComplete(args.wzTransactionId, args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnBeginMsiTransactionComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionComplete struct."); + +LExit: + ReleaseStr(sczTransactionId); + return hr; +} + +static HRESULT OnCacheAcquireBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEACQUIREBEGIN_ARGS args = { }; + BA_ONCACHEACQUIREBEGIN_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + LPWSTR sczSource = NULL; + LPWSTR sczDownloadUrl = NULL; + LPWSTR sczPayloadContainerId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireBegin args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireBegin args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadString(pReaderArgs, &sczSource); + ExitOnFailure(hr, "Failed to read source of OnCacheAcquireBegin args."); + + args.wzSource = sczSource; + + hr = BuffReaderReadString(pReaderArgs, &sczDownloadUrl); + ExitOnFailure(hr, "Failed to read download url of OnCacheAcquireBegin args."); + + args.wzDownloadUrl = sczDownloadUrl; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadContainerId); + ExitOnFailure(hr, "Failed to read payload container id of OnCacheAcquireBegin args."); + + args.wzPayloadContainerId = sczPayloadContainerId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnCacheAcquireBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCacheAcquireBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheAcquireBegin(args.wzPackageOrContainerId, args.wzPayloadId, args.wzSource, args.wzDownloadUrl, args.wzPayloadContainerId, args.recommendation, &results.action, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheAcquireBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheAcquireBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheAcquireBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCacheAcquireBegin struct."); + +LExit: + ReleaseStr(sczPayloadContainerId); + ReleaseStr(sczDownloadUrl); + ReleaseStr(sczSource); + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheAcquireComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEACQUIRECOMPLETE_ARGS args = { }; + BA_ONCACHEACQUIRECOMPLETE_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireComplete args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireComplete args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCacheAcquireComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnCacheAcquireComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCacheAcquireComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheAcquireComplete(args.wzPackageOrContainerId, args.wzPayloadId, args.hrStatus, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheAcquireComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheAcquireComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCacheAcquireComplete struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheAcquireProgress( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEACQUIREPROGRESS_ARGS args = { }; + BA_ONCACHEACQUIREPROGRESS_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireProgress args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireProgress args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireProgress args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); + ExitOnFailure(hr, "Failed to read progress of OnCacheAcquireProgress args."); + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); + ExitOnFailure(hr, "Failed to read total progress of OnCacheAcquireProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); + ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireProgress args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireProgress results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheAcquireProgress(args.wzPackageOrContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheAcquireProgress failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheAcquireProgress struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheAcquireProgress struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheAcquireResolving( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEACQUIRERESOLVING_ARGS args = { }; + BA_ONCACHEACQUIRERESOLVING_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + DWORD cSearchPaths = 0; + LPWSTR* rgsczSearchPaths = NULL; + LPWSTR sczDownloadUrl = NULL; + LPWSTR sczPayloadContainerId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireResolving args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireResolving args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireResolving args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber(pReaderArgs, &cSearchPaths); + ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireResolving args."); + + if (cSearchPaths) + { + rgsczSearchPaths = static_cast(MemAlloc(sizeof(LPWSTR) * cSearchPaths, TRUE)); + ExitOnNull(rgsczSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths of OnCacheAcquireResolving args."); + + for (DWORD i = 0; i < cSearchPaths; ++i) + { + hr = BuffReaderReadString(pReaderArgs, &rgsczSearchPaths[i]); + ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i); + } + } + + args.cSearchPaths = cSearchPaths; + args.rgSearchPaths = const_cast(rgsczSearchPaths); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fFoundLocal)); + ExitOnFailure(hr, "Failed to read found local of OnCacheAcquireResolving args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwRecommendedSearchPath); + ExitOnFailure(hr, "Failed to read recommended search path of OnCacheAcquireResolving args."); + + hr = BuffReaderReadString(pReaderArgs, &sczDownloadUrl); + ExitOnFailure(hr, "Failed to read download url of OnCacheAcquireResolving args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadContainerId); + ExitOnFailure(hr, "Failed to read payload container id of OnCacheAcquireResolving args."); + + args.wzPayloadContainerId = sczPayloadContainerId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendedation of OnCacheAcquireResolving args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireResolving results."); + + hr = BuffReaderReadNumber(pReaderResults, &results.dwChosenSearchPath); + ExitOnFailure(hr, "Failed to read chosen search path of OnCacheAcquireResolving results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCacheAcquireResolving results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheAcquireResolving(args.wzPackageOrContainerId, args.wzPayloadId, args.rgSearchPaths, args.cSearchPaths, args.fFoundLocal, args.dwRecommendedSearchPath, args.wzDownloadUrl, args.wzPayloadContainerId, args.recommendation, &results.dwChosenSearchPath, &results.action, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheAcquireResolving failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheAcquireResolving struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.dwChosenSearchPath); + ExitOnFailure(hr, "Failed to write chosen search path of OnCacheAcquireResolving struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCacheAcquireResolving struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheAcquireResolving struct."); + +LExit: + for (DWORD i = 0; rgsczSearchPaths && i < cSearchPaths; ++i) + { + ReleaseStr(rgsczSearchPaths[i]); + } + ReleaseMem(rgsczSearchPaths); + + ReleaseStr(sczPayloadContainerId); + ReleaseStr(sczDownloadUrl); + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + + return hr; +} + +static HRESULT OnCacheBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEBEGIN_ARGS args = { }; + BA_ONCACHEBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheBegin(&results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnCacheComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHECOMPLETE_ARGS args = { }; + BA_ONCACHECOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCacheComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnCacheContainerOrPayloadVerifyBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS args = { }; + BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyBegin args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyBegin args."); + + args.wzPayloadId = sczPayloadId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheContainerOrPayloadVerifyBegin(args.wzPackageOrContainerId, args.wzPayloadId, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheContainerOrPayloadVerifyBegin struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheContainerOrPayloadVerifyComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS args = { }; + BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyComplete args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyComplete args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCacheContainerOrPayloadVerifyComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheContainerOrPayloadVerifyComplete(args.wzPackageOrContainerId, args.wzPayloadId, args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyComplete struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheContainerOrPayloadVerifyProgress( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS args = { }; + BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyProgress args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyProgress args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyProgress args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); + ExitOnFailure(hr, "Failed to read progress of OnCacheContainerOrPayloadVerifyProgress args."); + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); + ExitOnFailure(hr, "Failed to read total progress of OnCacheContainerOrPayloadVerifyProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); + ExitOnFailure(hr, "Failed to read overall percentage of OnCacheContainerOrPayloadVerifyProgress args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyProgress results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheContainerOrPayloadVerifyProgress(args.wzPackageOrContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyProgress failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyProgress struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheContainerOrPayloadVerifyProgress struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCachePackageBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEPACKAGEBEGIN_ARGS args = { }; + BA_ONCACHEPACKAGEBEGIN_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePackageBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnCachePackageBegin args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, &args.cCachePayloads); + ExitOnFailure(hr, "Failed to read count of cached payloads of OnCachePackageBegin args."); + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64PackageCacheSize); + ExitOnFailure(hr, "Failed to read package cache size of OnCachePackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fVital)); + ExitOnFailure(hr, "Failed to read vital of OnCachePackageBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePackageBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCachePackageBegin(args.wzPackageId, args.cCachePayloads, args.dw64PackageCacheSize, args.fVital, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCachePackageBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCachePackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCachePackageBegin struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnCachePackageComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEPACKAGECOMPLETE_ARGS args = { }; + BA_ONCACHEPACKAGECOMPLETE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePackageComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnCachePackageComplete args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCachePackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnCachePackageComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePackageComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCachePackageComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCachePackageComplete(args.wzPackageId, args.hrStatus, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCachePackageComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCachePackageComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCachePackageComplete struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnCachePackageNonVitalValidationFailure( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS args = { }; + BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePackageNonVitalValidationFailure args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnCachePackageNonVitalValidationFailure args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCachePackageNonVitalValidationFailure args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnCachePackageNonVitalValidationFailure args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePackageNonVitalValidationFailure results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCachePackageNonVitalValidationFailure results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCachePackageNonVitalValidationFailure(args.wzPackageId, args.hrStatus, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCachePackageNonVitalValidationFailure failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCachePackageNonVitalValidationFailure struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCachePackageNonVitalValidationFailure struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnCachePayloadExtractBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS args = { }; + BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS results = { }; + LPWSTR sczContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczContainerId); + ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractBegin args."); + + args.wzContainerId = sczContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractBegin args."); + + args.wzPayloadId = sczPayloadId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCachePayloadExtractBegin(args.wzContainerId, args.wzPayloadId, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCachePayloadExtractBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCachePayloadExtractBegin struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczContainerId); + return hr; +} + +static HRESULT OnCachePayloadExtractComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS args = { }; + BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS results = { }; + LPWSTR sczContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczContainerId); + ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractComplete args."); + + args.wzContainerId = sczContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractComplete args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCachePayloadExtractComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCachePayloadExtractComplete(args.wzContainerId, args.wzPayloadId, args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCachePayloadExtractComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractComplete struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczContainerId); + return hr; +} + +static HRESULT OnCachePayloadExtractProgress( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS args = { }; + BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS results = { }; + LPWSTR sczContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractProgress args."); + + hr = BuffReaderReadString(pReaderArgs, &sczContainerId); + ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractProgress args."); + + args.wzContainerId = sczContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractProgress args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); + ExitOnFailure(hr, "Failed to read progress of OnCachePayloadExtractProgress args."); + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); + ExitOnFailure(hr, "Failed to read total progress of OnCachePayloadExtractProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); + ExitOnFailure(hr, "Failed to read overall percentage of OnCachePayloadExtractProgress args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractProgress results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCachePayloadExtractProgress(args.wzContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCachePayloadExtractProgress failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractProgress struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCachePayloadExtractProgress struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczContainerId); + return hr; +} + +static HRESULT OnCacheVerifyBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEVERIFYBEGIN_ARGS args = { }; + BA_ONCACHEVERIFYBEGIN_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyBegin args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyBegin args."); + + args.wzPayloadId = sczPayloadId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheVerifyBegin(args.wzPackageOrContainerId, args.wzPayloadId, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheVerifyBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheVerifyBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheVerifyBegin struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheVerifyComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEVERIFYCOMPLETE_ARGS args = { }; + BA_ONCACHEVERIFYCOMPLETE_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyComplete args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyComplete args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCacheVerifyComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnCacheVerifyComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheVerifyComplete(args.wzPackageOrContainerId, args.wzPayloadId, args.hrStatus, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheVerifyComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheVerifyComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCacheVerifyComplete struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCacheVerifyProgress( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCACHEVERIFYPROGRESS_ARGS args = { }; + BA_ONCACHEVERIFYPROGRESS_RESULTS results = { }; + LPWSTR sczPackageOrContainerId = NULL; + LPWSTR sczPayloadId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyProgress args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId); + ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyProgress args."); + + args.wzPackageOrContainerId = sczPackageOrContainerId; + + hr = BuffReaderReadString(pReaderArgs, &sczPayloadId); + ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyProgress args."); + + args.wzPayloadId = sczPayloadId; + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress); + ExitOnFailure(hr, "Failed to read progress of OnCacheVerifyProgress args."); + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total); + ExitOnFailure(hr, "Failed to read total progress of OnCacheVerifyProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); + ExitOnFailure(hr, "Failed to read overall percentage of OnCacheVerifyProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.verifyStep)); + ExitOnFailure(hr, "Failed to read verify step of OnCacheVerifyProgress args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyProgress results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCacheVerifyProgress(args.wzPackageOrContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, args.verifyStep, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCacheVerifyProgress failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCacheVerifyProgress struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCacheVerifyProgress struct."); + +LExit: + ReleaseStr(sczPayloadId); + ReleaseStr(sczPackageOrContainerId); + return hr; +} + +static HRESULT OnCommitMsiTransactionBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS args = { }; + BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS results = { }; + LPWSTR sczTransactionId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); + ExitOnFailure(hr, "Failed to read transaction id of OnCommitMsiTransactionBegin args."); + + args.wzTransactionId = sczTransactionId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCommitMsiTransactionBegin(args.wzTransactionId, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCommitMsiTransactionBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnCommitMsiTransactionBegin struct."); + +LExit: + ReleaseStr(sczTransactionId); + return hr; +} + +static HRESULT OnCommitMsiTransactionComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS args = { }; + BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS results = { }; + LPWSTR sczTransactionId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); + ExitOnFailure(hr, "Failed to read transaction id of OnCommitMsiTransactionComplete args."); + + args.wzTransactionId = sczTransactionId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnCommitMsiTransactionComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); + ExitOnFailure(hr, "Failed to read restart of OnCommitMsiTransactionComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnCommitMsiTransactionComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnCommitMsiTransactionComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCommitMsiTransactionComplete(args.wzTransactionId, args.hrStatus, args.restart, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCommitMsiTransactionComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnCommitMsiTransactionComplete struct."); + +LExit: + ReleaseStr(sczTransactionId); + return hr; +} + +static HRESULT OnCreate( + __in IBootstrapperApplication* pApplication, + __in IBootstrapperEngine* pEngine, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONCREATE_ARGS args = { }; + BA_ONCREATE_RESULTS results = { }; + LPWSTR sczCommandLine = NULL; + LPWSTR sczLayoutDirectory = NULL; + LPWSTR sczBootstrapperWorkingFolder = NULL; + LPWSTR sczBootstrapperApplicationDataPath = NULL; + DWORD64 dw64 = 0; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCreate args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.cbSize)); + ExitOnFailure(hr, "Failed to size of of OnCreate args command."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.action)); + ExitOnFailure(hr, "Failed to read action of OnCreate args command."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.display)); + ExitOnFailure(hr, "Failed to read action of OnCreate args command."); + + hr = BuffReaderReadString(pReaderArgs, &sczCommandLine); + ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); + + args.command.wzCommandLine = sczCommandLine; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.nCmdShow)); + ExitOnFailure(hr, "Failed to read show command of OnCreate args command."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.resumeType)); + ExitOnFailure(hr, "Failed to read resume type of OnCreate args command."); + + hr = BuffReaderReadNumber64(pReaderArgs, &dw64); + ExitOnFailure(hr, "Failed to read splash screen handle of OnCreate args command."); + + args.command.hwndSplashScreen = reinterpret_cast(dw64); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.relationType)); + ExitOnFailure(hr, "Failed to read relation type of OnCreate args command."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.command.fPassthrough)); + ExitOnFailure(hr, "Failed to read passthrough of OnCreate args command."); + + hr = BuffReaderReadString(pReaderArgs, &sczLayoutDirectory); + ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); + + args.command.wzLayoutDirectory = sczLayoutDirectory; + + hr = BuffReaderReadString(pReaderArgs, &sczBootstrapperWorkingFolder); + ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); + + args.command.wzBootstrapperWorkingFolder = sczBootstrapperWorkingFolder; + + hr = BuffReaderReadString(pReaderArgs, &sczBootstrapperApplicationDataPath); + ExitOnFailure(hr, "Failed to read command-line of OnCreate args command."); + + args.command.wzBootstrapperApplicationDataPath = sczBootstrapperApplicationDataPath; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnCreate results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnCreate(pEngine, &args.command); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnCreate failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of BA_ONCREATE_RESULTS struct."); + +LExit: + ReleaseStr(sczBootstrapperApplicationDataPath); + ReleaseStr(sczBootstrapperWorkingFolder); + ReleaseStr(sczLayoutDirectory); + ReleaseStr(sczCommandLine); + + return hr; +} + +static HRESULT OnDestroy( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDESTROY_ARGS args = { }; + BA_ONDESTROY_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDestroy args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fReload)); + ExitOnFailure(hr, "Failed to read reload of OnDestroy args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDestroy results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDestroy(args.fReload); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDestroy failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDestroy struct."); + +LExit: + return hr; +} + +static HRESULT OnDetectBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTBEGIN_ARGS args = { }; + BA_ONDETECTBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.registrationType)); + ExitOnFailure(hr, "Failed to read registration type of OnDetectBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.cPackages); + ExitOnFailure(hr, "Failed to read package count of OnDetectBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fCached)); + ExitOnFailure(hr, "Failed to read cached of OnDetectBegin args."); + + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectBegin(args.fCached, args.registrationType, args.cPackages, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnDetectCompatibleMsiPackage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS args = { }; + BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczCompatiblePackageId = NULL; + LPWSTR sczCompatiblePackageVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectCompatibleMsiPackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectCompatibleMsiPackage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); + ExitOnFailure(hr, "Failed to read compatible package id of OnDetectCompatibleMsiPackage args."); + + args.wzCompatiblePackageId = sczCompatiblePackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageVersion); + ExitOnFailure(hr, "Failed to read compatible package version of OnDetectCompatibleMsiPackage args."); + + args.wzCompatiblePackageVersion = sczCompatiblePackageVersion; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectCompatibleMsiPackage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectCompatibleMsiPackage(args.wzPackageId, args.wzCompatiblePackageId, args.wzCompatiblePackageVersion, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectCompatibleMsiPackage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectCompatibleMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectCompatibleMsiPackage struct."); + +LExit: + ReleaseStr(sczCompatiblePackageVersion); + ReleaseStr(sczCompatiblePackageId); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTCOMPLETE_ARGS args = { }; + BA_ONDETECTCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnDetectComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fEligibleForCleanup)); + ExitOnFailure(hr, "Failed to read eligible for cleanup of OnDetectComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectComplete(args.hrStatus, args.fEligibleForCleanup); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnDetectForwardCompatibleBundle( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS args = { }; + BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS results = { }; + LPWSTR sczBundleId = NULL; + LPWSTR sczBundleTag = NULL; + LPWSTR sczVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectForwardCompatibleBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read bundle id of OnDetectForwardCompatibleBundle args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); + ExitOnFailure(hr, "Failed to read relation type of OnDetectForwardCompatibleBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleTag); + ExitOnFailure(hr, "Failed to read bundle tag of OnDetectForwardCompatibleBundle args."); + + args.wzBundleTag = sczBundleTag; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); + ExitOnFailure(hr, "Failed to read per-machine of OnDetectForwardCompatibleBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczVersion); + ExitOnFailure(hr, "Failed to read version of OnDetectForwardCompatibleBundle args."); + + args.wzVersion = sczVersion; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fMissingFromCache)); + ExitOnFailure(hr, "Failed to read missing from cache of OnDetectForwardCompatibleBundle args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectForwardCompatibleBundle results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectForwardCompatibleBundle(args.wzBundleId, args.relationType, args.wzBundleTag, args.fPerMachine, args.wzVersion, args.fMissingFromCache, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectForwardCompatibleBundle failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectForwardCompatibleBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectForwardCompatibleBundle struct."); + +LExit: + ReleaseStr(sczVersion); + ReleaseStr(sczBundleTag); + ReleaseStr(sczBundleId); + return hr; +} + +static HRESULT OnDetectMsiFeature( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTMSIFEATURE_ARGS args = { }; + BA_ONDETECTMSIFEATURE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczFeatureId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectMsiFeature args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectMsiFeature args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczFeatureId); + ExitOnFailure(hr, "Failed to read feature id of OnDetectMsiFeature args."); + + args.wzFeatureId = sczFeatureId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.state)); + ExitOnFailure(hr, "Failed to read state of OnDetectMsiFeature args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectMsiFeature results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectMsiFeature(args.wzPackageId, args.wzFeatureId, args.state, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectMsiFeature failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectMsiFeature struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectMsiFeature struct."); + +LExit: + ReleaseStr(sczFeatureId); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectPackageBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTPACKAGEBEGIN_ARGS args = { }; + BA_ONDETECTPACKAGEBEGIN_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectPackageBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectPackageBegin args."); + + args.wzPackageId = sczPackageId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectPackageBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectPackageBegin(args.wzPackageId, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectPackageBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectPackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectPackageBegin struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectPackageComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTPACKAGECOMPLETE_ARGS args = { }; + BA_ONDETECTPACKAGECOMPLETE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectPackageComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectPackageComplete args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnDetectPackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.state)); + ExitOnFailure(hr, "Failed to read state of OnDetectPackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fCached)); + ExitOnFailure(hr, "Failed to read cached of OnDetectPackageComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectPackageComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectPackageComplete(args.wzPackageId, args.hrStatus, args.state, args.fCached); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectPackageComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectPackageComplete struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectRelatedBundle( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTRELATEDBUNDLE_ARGS args = { }; + BA_ONDETECTRELATEDBUNDLE_RESULTS results = { }; + LPWSTR sczBundleId = NULL; + LPWSTR sczBundleTag = NULL; + LPWSTR sczVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read bundle id of OnDetectRelatedBundle args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); + ExitOnFailure(hr, "Failed to read relation type of OnDetectRelatedBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleTag); + ExitOnFailure(hr, "Failed to read bundle tag of OnDetectRelatedBundle args."); + + args.wzBundleTag = sczBundleTag; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); + ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczVersion); + ExitOnFailure(hr, "Failed to read version of OnDetectRelatedBundle args."); + + args.wzVersion = sczVersion; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fMissingFromCache)); + ExitOnFailure(hr, "Failed to read missing from cache of OnDetectRelatedBundle args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundle results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectRelatedBundle(args.wzBundleId, args.relationType, args.wzBundleTag, args.fPerMachine, args.wzVersion, args.fMissingFromCache, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectRelatedBundle failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectRelatedBundle struct."); + +LExit: + ReleaseStr(sczVersion); + ReleaseStr(sczBundleTag); + ReleaseStr(sczBundleId); + return hr; +} + +static HRESULT OnDetectRelatedBundlePackage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS args = { }; + BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczBundleId = NULL; + LPWSTR sczVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundlePackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectRelatedBundlePackage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read bundle id of OnDetectRelatedBundlePackage args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); + ExitOnFailure(hr, "Failed to read relation type of OnDetectRelatedBundlePackage args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); + ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedBundlePackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczVersion); + ExitOnFailure(hr, "Failed to read version of OnDetectRelatedBundlePackage args."); + + args.wzVersion = sczVersion; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundlePackage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectRelatedBundlePackage(args.wzPackageId, args.wzBundleId, args.relationType, args.fPerMachine, args.wzVersion, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectRelatedBundlePackage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundlePackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectRelatedBundlePackage struct."); + +LExit: + ReleaseStr(sczVersion); + ReleaseStr(sczBundleId); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectRelatedMsiPackage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTRELATEDMSIPACKAGE_ARGS args = { }; + BA_ONDETECTRELATEDMSIPACKAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczUpgradeCode = NULL; + LPWSTR sczProductCode = NULL; + LPWSTR sczVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedMsiPackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectRelatedMsiPackage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczUpgradeCode); + ExitOnFailure(hr, "Failed to read upgrade code of OnDetectRelatedMsiPackage args."); + + args.wzUpgradeCode = sczUpgradeCode; + + hr = BuffReaderReadString(pReaderArgs, &sczProductCode); + ExitOnFailure(hr, "Failed to read product code of OnDetectRelatedMsiPackage args."); + + args.wzProductCode = sczProductCode; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); + ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedMsiPackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczVersion); + ExitOnFailure(hr, "Failed to read version of OnDetectRelatedMsiPackage args."); + + args.wzVersion = sczVersion; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.operation)); + ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedMsiPackage args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedMsiPackage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectRelatedMsiPackage(args.wzPackageId, args.wzUpgradeCode, args.wzProductCode, args.fPerMachine, args.wzVersion, args.operation, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectRelatedMsiPackage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectRelatedMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectRelatedMsiPackage struct."); + +LExit: + ReleaseStr(sczVersion); + ReleaseStr(sczProductCode); + ReleaseStr(sczUpgradeCode); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectPatchTarget( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTPATCHTARGET_ARGS args = { }; + BA_ONDETECTPATCHTARGET_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczProductCode = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectPatchTarget args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnDetectPatchTarget args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczProductCode); + ExitOnFailure(hr, "Failed to read product code of OnDetectPatchTarget args."); + + args.wzProductCode = sczProductCode; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.patchState)); + ExitOnFailure(hr, "Failed to read patch state of OnDetectPatchTarget args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectPatchTarget results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectPatchTarget(args.wzPackageId, args.wzProductCode, args.patchState, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectPatchTarget failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectPatchTarget struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectPatchTarget struct."); + +LExit: + ReleaseStr(sczProductCode); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnDetectUpdate( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTUPDATE_ARGS args = { }; + BA_ONDETECTUPDATE_RESULTS results = { }; + LPWSTR sczUpdateLocation = NULL; + LPWSTR sczHash = NULL; + LPWSTR sczVersion = NULL; + LPWSTR sczTitle = NULL; + LPWSTR sczSummary = NULL; + LPWSTR sczContentType = NULL; + LPWSTR sczContent = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectUpdate args."); + + hr = BuffReaderReadString(pReaderArgs, &sczUpdateLocation); + ExitOnFailure(hr, "Failed to read update location of OnDetectUpdate args."); + + args.wzUpdateLocation = sczUpdateLocation; + + hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Size); + ExitOnFailure(hr, "Failed to read update size of OnDetectUpdate args."); + + hr = BuffReaderReadString(pReaderArgs, &sczHash); + ExitOnFailure(hr, "Failed to read hash of OnDetectUpdate args."); + + args.wzHash = sczHash; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hashAlgorithm)); + ExitOnFailure(hr, "Failed to read hash algorithm of OnDetectUpdate args."); + + hr = BuffReaderReadString(pReaderArgs, &sczVersion); + ExitOnFailure(hr, "Failed to read version of OnDetectUpdate args."); + + args.wzVersion = sczVersion; + + hr = BuffReaderReadString(pReaderArgs, &sczTitle); + ExitOnFailure(hr, "Failed to read title of OnDetectUpdate args."); + + args.wzTitle = sczTitle; + + hr = BuffReaderReadString(pReaderArgs, &sczSummary); + ExitOnFailure(hr, "Failed to read summary of OnDetectUpdate args."); + + args.wzSummary = sczSummary; + + hr = BuffReaderReadString(pReaderArgs, &sczContentType); + ExitOnFailure(hr, "Failed to read content type of OnDetectUpdate args."); + + args.wzContentType = sczContentType; + + hr = BuffReaderReadString(pReaderArgs, &sczContent); + ExitOnFailure(hr, "Failed to read content of OnDetectUpdate args."); + + args.wzContent = sczContent; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectUpdate results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fStopProcessingUpdates)); + ExitOnFailure(hr, "Failed to read stop processing updates of OnDetectUpdate results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectUpdate(args.wzUpdateLocation, args.dw64Size, args.wzHash, args.hashAlgorithm, args.wzVersion, args.wzTitle, args.wzSummary, args.wzContentType, args.wzContent, &results.fCancel, &results.fStopProcessingUpdates); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectUpdate failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectUpdate struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectUpdate struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fStopProcessingUpdates); + ExitOnFailure(hr, "Failed to write stop processing updates of OnDetectUpdate struct."); + +LExit: + ReleaseStr(sczContent); + ReleaseStr(sczContentType); + ReleaseStr(sczSummary); + ReleaseStr(sczTitle); + ReleaseStr(sczVersion); + ReleaseStr(sczHash); + ReleaseStr(sczUpdateLocation); + return hr; +} + +static HRESULT OnDetectUpdateBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTUPDATEBEGIN_ARGS args = { }; + BA_ONDETECTUPDATEBEGIN_RESULTS results = { }; + LPWSTR sczUpdateLocation = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczUpdateLocation); + ExitOnFailure(hr, "Failed to read update location of OnDetectUpdateBegin args."); + + args.wzUpdateLocation = sczUpdateLocation; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fSkip)); + ExitOnFailure(hr, "Failed to read skip of OnDetectUpdateBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectUpdateBegin(args.wzUpdateLocation, &results.fCancel, &results.fSkip); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectUpdateBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectUpdateBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnDetectUpdateBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fSkip); + ExitOnFailure(hr, "Failed to write skip processing updates of OnDetectUpdateBegin struct."); + +LExit: + ReleaseStr(sczUpdateLocation); + return hr; +} + + +static HRESULT OnDetectUpdateComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONDETECTUPDATECOMPLETE_ARGS args = { }; + BA_ONDETECTUPDATECOMPLETE_RESULTS results = { }; + LPWSTR sczUpdateLocation = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnDetectUpdateComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fIgnoreError)); + ExitOnFailure(hr, "Failed to read ignore error of OnDetectUpdateComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnDetectUpdateComplete(args.hrStatus, &results.fIgnoreError); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnDetectUpdateComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnDetectUpdateComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fIgnoreError); + ExitOnFailure(hr, "Failed to write ignore error of OnDetectUpdateComplete struct."); + +LExit: + ReleaseStr(sczUpdateLocation); + return hr; +} + +static HRESULT OnElevateBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONELEVATEBEGIN_ARGS args = { }; + BA_ONELEVATEBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnElevateBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnElevateBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnElevateBegin(&results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnElevateBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnElevateBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnElevateBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnElevateComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONELEVATECOMPLETE_ARGS args = { }; + BA_ONELEVATECOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnElevateComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnElevateComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnElevateComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnElevateComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnElevateComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnElevateComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnError( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONERROR_ARGS args = { }; + BA_ONERROR_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczError = NULL; + DWORD cData = 0; + LPWSTR* rgsczData = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnError args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.errorType)); + ExitOnFailure(hr, "Failed to read error type of OnError args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnError args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwCode); + ExitOnFailure(hr, "Failed to read code of OnError args."); + + hr = BuffReaderReadString(pReaderArgs, &sczError); + ExitOnFailure(hr, "Failed to read error of OnError args."); + + args.wzError = sczError; + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint); + ExitOnFailure(hr, "Failed to read UI hint of OnError args."); + + hr = BuffReaderReadNumber(pReaderArgs, &cData); + ExitOnFailure(hr, "Failed to read count of data of OnError args."); + + if (cData) + { + rgsczData = static_cast(MemAlloc(sizeof(LPWSTR) * cData, TRUE)); + ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnError args."); + + for (DWORD i = 0; i < cData; ++i) + { + hr = BuffReaderReadString(pReaderArgs, &rgsczData[i]); + ExitOnFailure(hr, "Failed to read search path[%u] of OnError args.", i); + } + } + + args.cData = cData; + args.rgwzData = const_cast(rgsczData); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.nRecommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnError args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnError results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.nResult)); + ExitOnFailure(hr, "Failed to read cancel of OnError results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnError(args.errorType, args.wzPackageId, args.dwCode, args.wzError, args.dwUIHint, args.cData, args.rgwzData, args.nRecommendation, &results.nResult); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnError failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnError struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.nResult); + ExitOnFailure(hr, "Failed to write result of OnError struct."); + +LExit: + for (DWORD i = 0; rgsczData && i < cData; ++i) + { + ReleaseStr(rgsczData[i]); + } + ReleaseMem(rgsczData); + + ReleaseStr(sczError); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecuteBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEBEGIN_ARGS args = { }; + BA_ONEXECUTEBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.cExecutingPackages); + ExitOnFailure(hr, "Failed to executing packages of OnExecuteBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecuteBegin(args.cExecutingPackages, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecuteBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecuteBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnExecuteBegin struct."); + +LExit: + return hr; +} + + +static HRESULT OnExecuteComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTECOMPLETE_ARGS args = { }; + BA_ONEXECUTECOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to status of OnExecuteComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecuteComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecuteComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecuteComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnExecuteFilesInUse( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEFILESINUSE_ARGS args = { }; + BA_ONEXECUTEFILESINUSE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + DWORD cFiles = 0; + LPWSTR* rgsczFiles = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteFilesInUse args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecuteFilesInUse args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, &cFiles); + ExitOnFailure(hr, "Failed to read count of files of OnExecuteFilesInUse args."); + + if (cFiles) + { + rgsczFiles = static_cast(MemAlloc(sizeof(LPWSTR) * cFiles, TRUE)); + ExitOnNull(rgsczFiles, hr, E_OUTOFMEMORY, "Failed to allocate memory for files of OnExecuteFilesInUse args."); + + for (DWORD i = 0; i < cFiles; ++i) + { + hr = BuffReaderReadString(pReaderArgs, &rgsczFiles[i]); + ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i); + } + } + + args.cFiles = cFiles; + args.rgwzFiles = const_cast(rgsczFiles); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.nRecommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnExecuteFilesInUse args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.source)); + ExitOnFailure(hr, "Failed to read source of OnExecuteFilesInUse args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteFilesInUse results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.nResult)); + ExitOnFailure(hr, "Failed to read result of OnExecuteFilesInUse results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecuteFilesInUse(args.wzPackageId, args.cFiles, args.rgwzFiles, args.nRecommendation, args.source, &results.nResult); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecuteFilesInUse failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecuteFilesInUse struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.nResult); + ExitOnFailure(hr, "Failed to write result of OnExecuteFilesInUse struct."); + +LExit: + for (DWORD i = 0; rgsczFiles && i < cFiles; ++i) + { + ReleaseStr(rgsczFiles[i]); + } + ReleaseMem(rgsczFiles); + + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecuteMsiMessage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEMSIMESSAGE_ARGS args = { }; + BA_ONEXECUTEMSIMESSAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczMessage = NULL; + DWORD cData = 0; + LPWSTR* rgsczData = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteMsiMessage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecuteMsiMessage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.messageType)); + ExitOnFailure(hr, "Failed to read messageType of OnExecuteMsiMessage args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint); + ExitOnFailure(hr, "Failed to read UI hint of OnExecuteMsiMessage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczMessage); + ExitOnFailure(hr, "Failed to read message of OnExecuteMsiMessage args."); + + args.wzMessage = sczMessage; + + hr = BuffReaderReadNumber(pReaderArgs, &cData); + ExitOnFailure(hr, "Failed to read count of files of OnExecuteMsiMessage args."); + + if (cData) + { + rgsczData = static_cast(MemAlloc(sizeof(LPWSTR) * cData, TRUE)); + ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnExecuteMsiMessage args."); + + for (DWORD i = 0; i < cData; ++i) + { + hr = BuffReaderReadString(pReaderArgs, &rgsczData[i]); + ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i); + } + } + + args.cData = cData; + args.rgwzData = const_cast(rgsczData); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.nRecommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnExecuteMsiMessage args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteMsiMessage results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.nResult)); + ExitOnFailure(hr, "Failed to read result of OnExecuteMsiMessage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecuteMsiMessage(args.wzPackageId, args.messageType, args.dwUIHint, args.wzMessage, args.cData, args.rgwzData, args.nRecommendation, &results.nResult); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecuteMsiMessage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecuteMsiMessage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.nResult); + ExitOnFailure(hr, "Failed to write result of OnExecuteMsiMessage struct."); + +LExit: + for (DWORD i = 0; rgsczData && i < cData; ++i) + { + ReleaseStr(rgsczData[i]); + } + ReleaseMem(rgsczData); + + ReleaseStr(sczMessage); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecutePackageBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEPACKAGEBEGIN_ARGS args = { }; + BA_ONEXECUTEPACKAGEBEGIN_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecutePackageBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecutePackageBegin args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fExecute)); + ExitOnFailure(hr, "Failed to read execute of OnExecutePackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.action)); + ExitOnFailure(hr, "Failed to read action of OnExecutePackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.uiLevel)); + ExitOnFailure(hr, "Failed to read UI level of OnExecutePackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fDisableExternalUiHandler)); + ExitOnFailure(hr, "Failed to read disable external UI handler of OnExecutePackageBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecutePackageBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecutePackageBegin(args.wzPackageId, args.fExecute, args.action, args.uiLevel, args.fDisableExternalUiHandler, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecutePackageBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecutePackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnExecutePackageBegin struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecutePackageComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEPACKAGECOMPLETE_ARGS args = { }; + BA_ONEXECUTEPACKAGECOMPLETE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecutePackageComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecutePackageComplete args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnExecutePackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); + ExitOnFailure(hr, "Failed to read restart of OnExecutePackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnExecutePackageComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecutePackageComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnExecutePackageComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecutePackageComplete(args.wzPackageId, args.hrStatus, args.restart, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecutePackageComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecutePackageComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnExecutePackageComplete struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecutePatchTarget( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEPATCHTARGET_ARGS args = { }; + BA_ONEXECUTEPATCHTARGET_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczTargetProductCode = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecutePatchTarget args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecutePatchTarget args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczTargetProductCode); + ExitOnFailure(hr, "Failed to read target product code of OnExecutePatchTarget args."); + + args.wzTargetProductCode = sczTargetProductCode; + + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecutePatchTarget results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecutePatchTarget(args.wzPackageId, args.wzTargetProductCode, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecutePatchTarget failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecutePatchTarget struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnExecutePatchTarget struct."); + +LExit: + ReleaseStr(sczTargetProductCode); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecuteProcessCancel( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEPROCESSCANCEL_ARGS args = { }; + BA_ONEXECUTEPROCESSCANCEL_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteProcessCancel args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecuteProcessCancel args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProcessId); + ExitOnFailure(hr, "Failed to read process id of OnExecuteProcessCancel args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnExecuteProcessCancel args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteProcessCancel results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnExecuteProcessCancel results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecuteProcessCancel(args.wzPackageId, args.dwProcessId, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecuteProcessCancel failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecuteProcessCancel struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnExecuteProcessCancel struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnExecuteProgress( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONEXECUTEPROGRESS_ARGS args = { }; + BA_ONEXECUTEPROGRESS_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteProgress args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnExecuteProgress args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage); + ExitOnFailure(hr, "Failed to read progress of OnExecuteProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); + ExitOnFailure(hr, "Failed to read overall progress of OnExecuteProgress args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnExecuteProgress results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnExecuteProgress(args.wzPackageId, args.dwProgressPercentage, args.dwOverallPercentage, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnExecuteProgress failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnExecuteProgress struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnExecuteProgress struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnLaunchApprovedExeBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS args = { }; + BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnLaunchApprovedExeBegin(&results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnLaunchApprovedExeBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnLaunchApprovedExeBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnLaunchApprovedExeComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS args = { }; + BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnLaunchApprovedExeComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProcessId); + ExitOnFailure(hr, "Failed to read process id of OnLaunchApprovedExeComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnLaunchApprovedExeComplete(args.hrStatus, args.dwProcessId); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnLaunchApprovedExeComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnPauseAutomaticUpdatesBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS args = { }; + BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPauseAutomaticUpdatesBegin(); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPauseAutomaticUpdatesBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPauseAutomaticUpdatesBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnPauseAutomaticUpdatesComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS args = { }; + BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnPauseAutomaticUpdatesComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPauseAutomaticUpdatesComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPauseAutomaticUpdatesComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPauseAutomaticUpdatesComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnPlanBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANBEGIN_ARGS args = { }; + BA_ONPLANBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.cPackages); + ExitOnFailure(hr, "Failed to read count of packages of OnPlanBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanBegin(args.cPackages, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnPlanCompatibleMsiPackageBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS args = { }; + BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczCompatiblePackageId = NULL; + LPWSTR sczCompatiblePackageVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanCompatibleMsiPackageBegin args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); + ExitOnFailure(hr, "Failed to read compatible package id of OnPlanCompatibleMsiPackageBegin args."); + + args.wzCompatiblePackageId = sczCompatiblePackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageVersion); + ExitOnFailure(hr, "Failed to read compatible package version of OnPlanCompatibleMsiPackageBegin args."); + + args.wzCompatiblePackageVersion = sczCompatiblePackageVersion; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRecommendedRemove)); + ExitOnFailure(hr, "Failed to read recommend remove of OnPlanCompatibleMsiPackageBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fRequestRemove)); + ExitOnFailure(hr, "Failed to read request remove of OnPlanCompatibleMsiPackageBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanCompatibleMsiPackageBegin(args.wzPackageId, args.wzCompatiblePackageId, args.wzCompatiblePackageVersion, args.fRecommendedRemove, &results.fCancel, &results.fRequestRemove); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanCompatibleMsiPackageBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanCompatibleMsiPackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fRequestRemove); + ExitOnFailure(hr, "Failed to write requested remove of OnPlanCompatibleMsiPackageBegin struct."); + +LExit: + ReleaseStr(sczCompatiblePackageVersion); + ReleaseStr(sczCompatiblePackageId); + ReleaseStr(sczPackageId); + + return hr; +} + +static HRESULT OnPlanCompatibleMsiPackageComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS args = { }; + BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczCompatiblePackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanCompatibleMsiPackageComplete args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); + ExitOnFailure(hr, "Failed to read compatible package id of OnPlanCompatibleMsiPackageComplete args."); + + args.wzCompatiblePackageId = sczCompatiblePackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnPlanCompatibleMsiPackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRequestedRemove)); + ExitOnFailure(hr, "Failed to read requested remove of OnPlanCompatibleMsiPackageComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanCompatibleMsiPackageComplete(args.wzPackageId, args.wzCompatiblePackageId, args.hrStatus, args.fRequestedRemove); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanCompatibleMsiPackageComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageComplete struct."); + + +LExit: + ReleaseStr(sczCompatiblePackageId); + ReleaseStr(sczPackageId); + + return hr; +} + +static HRESULT OnPlanMsiFeature( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANMSIFEATURE_ARGS args = { }; + BA_ONPLANMSIFEATURE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczFeatureId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanMsiFeature args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanMsiFeature args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczFeatureId); + ExitOnFailure(hr, "Failed to read feature id of OnPlanMsiFeature args."); + + args.wzFeatureId = sczFeatureId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); + ExitOnFailure(hr, "Failed to read recommended state of OnPlanMsiFeature args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanMsiFeature results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); + ExitOnFailure(hr, "Failed to read requested state of OnPlanMsiFeature results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanMsiFeature(args.wzPackageId, args.wzFeatureId, args.recommendedState, &results.requestedState, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanMsiFeature failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanMsiFeature struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState); + ExitOnFailure(hr, "Failed to write requested state of OnPlanMsiFeature struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanMsiFeature struct."); + +LExit: + ReleaseStr(sczFeatureId); + ReleaseStr(sczPackageId); + + return hr; +} + +static HRESULT OnPlanComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANCOMPLETE_ARGS args = { }; + BA_ONPLANCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnPlanComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnPlanForwardCompatibleBundle( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS args = { }; + BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS results = { }; + LPWSTR sczBundleId = NULL; + LPWSTR sczBundleTag = NULL; + LPWSTR sczVersion = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanForwardCompatibleBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read bundle id of OnPlanForwardCompatibleBundle args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.relationType)); + ExitOnFailure(hr, "Failed to read relation type of OnPlanForwardCompatibleBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleTag); + ExitOnFailure(hr, "Failed to read bundle tag of OnPlanForwardCompatibleBundle args."); + + args.wzBundleTag = sczBundleTag; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPerMachine)); + ExitOnFailure(hr, "Failed to read per-machine of OnPlanForwardCompatibleBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczVersion); + ExitOnFailure(hr, "Failed to read version of OnPlanForwardCompatibleBundle args."); + + args.wzVersion = sczVersion; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRecommendedIgnoreBundle)); + ExitOnFailure(hr, "Failed to read recommended ignore bundle of OnPlanForwardCompatibleBundle args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanForwardCompatibleBundle results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fIgnoreBundle)); + ExitOnFailure(hr, "Failed to read requested ignore bundle of OnPlanForwardCompatibleBundle results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanForwardCompatibleBundle(args.wzBundleId, args.relationType, args.wzBundleTag, args.fPerMachine, args.wzVersion, args.fRecommendedIgnoreBundle, &results.fCancel, &results.fIgnoreBundle); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanForwardCompatibleBundle failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanForwardCompatibleBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanForwardCompatibleBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fIgnoreBundle); + ExitOnFailure(hr, "Failed to write ignore bundle of OnPlanForwardCompatibleBundle struct."); + +LExit: + ReleaseStr(sczVersion); + ReleaseStr(sczBundleTag); + ReleaseStr(sczBundleId); + return hr; +} + +static HRESULT OnPlanMsiPackage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANMSIPACKAGE_ARGS args = { }; + BA_ONPLANMSIPACKAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanMsiPackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanMsiPackage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fExecute)); + ExitOnFailure(hr, "Failed to read execute of OnPlanMsiPackage args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.action)); + ExitOnFailure(hr, "Failed to read action of OnPlanMsiPackage args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedFileVersioning)); + ExitOnFailure(hr, "Failed to read recommended file versioning of OnPlanMsiPackage args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanMsiPackage results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.actionMsiProperty)); + ExitOnFailure(hr, "Failed to read action msi property of OnPlanMsiPackage results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.uiLevel)); + ExitOnFailure(hr, "Failed to read UI level of OnPlanMsiPackage results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fDisableExternalUiHandler)); + ExitOnFailure(hr, "Failed to read disable external UI handler of OnPlanMsiPackage results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fileVersioning)); + ExitOnFailure(hr, "Failed to read file versioning of OnPlanMsiPackage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanMsiPackage(args.wzPackageId, args.fExecute, args.action, args.recommendedFileVersioning, &results.fCancel, &results.actionMsiProperty, &results.uiLevel, &results.fDisableExternalUiHandler, &results.fileVersioning); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanMsiPackage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.actionMsiProperty); + ExitOnFailure(hr, "Failed to write action MSI property of OnPlanMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.uiLevel); + ExitOnFailure(hr, "Failed to write UI level of OnPlanMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fDisableExternalUiHandler); + ExitOnFailure(hr, "Failed to write external UI handler of OnPlanMsiPackage struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fileVersioning); + ExitOnFailure(hr, "Failed to write file versioning of OnPlanMsiPackage struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnPlannedCompatiblePackage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS args = { }; + BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczCompatiblePackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlannedCompatiblePackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlannedCompatiblePackage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId); + ExitOnFailure(hr, "Failed to read compatible package id of OnPlannedCompatiblePackage args."); + + args.wzCompatiblePackageId = sczCompatiblePackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRemove)); + ExitOnFailure(hr, "Failed to read remove of OnPlannedCompatiblePackage args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlannedCompatiblePackage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlannedCompatiblePackage(args.wzPackageId, args.wzCompatiblePackageId, args.fRemove); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlannedCompatiblePackage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlannedCompatiblePackage struct."); + +LExit: + ReleaseStr(sczCompatiblePackageId); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnPlannedPackage( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANNEDPACKAGE_ARGS args = { }; + BA_ONPLANNEDPACKAGE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlannedPackage args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlannedPackage args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.execute)); + ExitOnFailure(hr, "Failed to read execute of OnPlannedPackage args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.rollback)); + ExitOnFailure(hr, "Failed to read rollback of OnPlannedPackage args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPlannedCache)); + ExitOnFailure(hr, "Failed to read planned cache of OnPlannedPackage args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fPlannedUncache)); + ExitOnFailure(hr, "Failed to read planned uncache of OnPlannedPackage args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlannedPackage results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlannedPackage(args.wzPackageId, args.execute, args.rollback, args.fPlannedCache, args.fPlannedUncache); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlannedPackage failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlannedPackage struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnPlanPackageBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANPACKAGEBEGIN_ARGS args = { }; + BA_ONPLANPACKAGEBEGIN_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanPackageBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanPackageBegin args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.state)); + ExitOnFailure(hr, "Failed to read state of OnPlanPackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fCached)); + ExitOnFailure(hr, "Failed to read cached of OnPlanPackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.installCondition)); + ExitOnFailure(hr, "Failed to read install condition of OnPlanPackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.repairCondition)); + ExitOnFailure(hr, "Failed to read repair condition of OnPlanPackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); + ExitOnFailure(hr, "Failed to read recommended state of OnPlanPackageBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedCacheType)); + ExitOnFailure(hr, "Failed to read recommended cache type of OnPlanPackageBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanPackageBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); + ExitOnFailure(hr, "Failed to read requested state of OnPlanPackageBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedCacheType)); + ExitOnFailure(hr, "Failed to read requested cache type of OnPlanPackageBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanPackageBegin(args.wzPackageId, args.state, args.fCached, args.installCondition, args.repairCondition, args.recommendedState, args.recommendedCacheType, &results.requestedState, &results.requestedCacheType, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanPackageBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanPackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanPackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState); + ExitOnFailure(hr, "Failed to write requested state of OnPlanPackageBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedCacheType); + ExitOnFailure(hr, "Failed to write requested cache type of OnPlanPackageBegin struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnPlanPackageComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANPACKAGECOMPLETE_ARGS args = { }; + BA_ONPLANPACKAGECOMPLETE_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanPackageComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanPackageComplete args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnPlanPackageComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.requested)); + ExitOnFailure(hr, "Failed to read requested of OnPlanPackageComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanPackageComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanPackageComplete(args.wzPackageId, args.hrStatus, args.requested); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanPackageComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanPackageComplete struct."); + +LExit: + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnPlanRelatedBundle( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANRELATEDBUNDLE_ARGS args = { }; + BA_ONPLANRELATEDBUNDLE_RESULTS results = { }; + LPWSTR sczBundleId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read package id of OnPlanRelatedBundle args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); + ExitOnFailure(hr, "Failed to read recommended state of OnPlanRelatedBundle args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundle results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); + ExitOnFailure(hr, "Failed to read requested state of OnPlanRelatedBundle results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanRelatedBundle(args.wzBundleId, args.recommendedState, &results.requestedState, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanRelatedBundle failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanRelatedBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState); + ExitOnFailure(hr, "Failed to write requested state of OnPlanRelatedBundle struct."); + +LExit: + ReleaseStr(sczBundleId); + return hr; +} + +static HRESULT OnPlanRelatedBundleType( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANRELATEDBUNDLETYPE_ARGS args = { }; + BA_ONPLANRELATEDBUNDLETYPE_RESULTS results = { }; + LPWSTR sczBundleId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundleType args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read package id of OnPlanRelatedBundleType args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedType)); + ExitOnFailure(hr, "Failed to read recommended type of OnPlanRelatedBundleType args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundleType results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedType)); + ExitOnFailure(hr, "Failed to read requested type of OnPlanRelatedBundleType results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanRelatedBundleType(args.wzBundleId, args.recommendedType, &results.requestedType, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanRelatedBundleType failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundleType struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanRelatedBundleType struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedType); + ExitOnFailure(hr, "Failed to write requested type of OnPlanRelatedBundleType struct."); + +LExit: + ReleaseStr(sczBundleId); + return hr; +} + +static HRESULT OnPlanRestoreRelatedBundle( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANRESTORERELATEDBUNDLE_ARGS args = { }; + BA_ONPLANRESTORERELATEDBUNDLE_RESULTS results = { }; + LPWSTR sczBundleId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRestoreRelatedBundle args."); + + hr = BuffReaderReadString(pReaderArgs, &sczBundleId); + ExitOnFailure(hr, "Failed to read package id of OnPlanRestoreRelatedBundle args."); + + args.wzBundleId = sczBundleId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); + ExitOnFailure(hr, "Failed to read recommended state of OnPlanRestoreRelatedBundle args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRestoreRelatedBundle results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); + ExitOnFailure(hr, "Failed to read requested state of OnPlanRestoreRelatedBundle results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanRestoreRelatedBundle(args.wzBundleId, args.recommendedState, &results.requestedState, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanRestoreRelatedBundle failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanRestoreRelatedBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanRestoreRelatedBundle struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState); + ExitOnFailure(hr, "Failed to write requested state of OnPlanRestoreRelatedBundle struct."); + +LExit: + ReleaseStr(sczBundleId); + return hr; +} + +static HRESULT OnPlanRollbackBoundary( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANROLLBACKBOUNDARY_ARGS args = { }; + BA_ONPLANROLLBACKBOUNDARY_RESULTS results = { }; + LPWSTR sczRollbackBoundaryId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRollbackBoundary args."); + + hr = BuffReaderReadString(pReaderArgs, &sczRollbackBoundaryId); + ExitOnFailure(hr, "Failed to read rollback boundary id of OnPlanRollbackBoundary args."); + + args.wzRollbackBoundaryId = sczRollbackBoundaryId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.fRecommendedTransaction)); + ExitOnFailure(hr, "Failed to read recommended transaction of OnPlanRollbackBoundary args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanRollbackBoundary results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.fTransaction)); + ExitOnFailure(hr, "Failed to read transaction of OnPlanRollbackBoundary results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanRollbackBoundary(args.wzRollbackBoundaryId, args.fRecommendedTransaction, &results.fTransaction, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanRollbackBoundary failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanRollbackBoundary struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fTransaction); + ExitOnFailure(hr, "Failed to write transaction of OnPlanRollbackBoundary struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanRollbackBoundary struct."); + +LExit: + ReleaseStr(sczRollbackBoundaryId); + return hr; +} + +static HRESULT OnPlanPatchTarget( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPLANPATCHTARGET_ARGS args = { }; + BA_ONPLANPATCHTARGET_RESULTS results = { }; + LPWSTR sczPackageId = NULL; + LPWSTR sczProductCode = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanPatchTarget args."); + + hr = BuffReaderReadString(pReaderArgs, &sczPackageId); + ExitOnFailure(hr, "Failed to read package id of OnPlanPatchTarget args."); + + args.wzPackageId = sczPackageId; + + hr = BuffReaderReadString(pReaderArgs, &sczProductCode); + ExitOnFailure(hr, "Failed to read product code of OnPlanPatchTarget args."); + + args.wzProductCode = sczProductCode; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedState)); + ExitOnFailure(hr, "Failed to read recommended state transaction of OnPlanPatchTarget args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnPlanPatchTarget results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.requestedState)); + ExitOnFailure(hr, "Failed to read requested state of OnPlanPatchTarget results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnPlanPatchTarget(args.wzPackageId, args.wzProductCode, args.recommendedState, &results.requestedState, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnPlanPatchTarget failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnPlanPatchTarget struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnPlanPatchTarget struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState); + ExitOnFailure(hr, "Failed to write transaction of OnPlanPatchTarget struct."); + +LExit: + ReleaseStr(sczProductCode); + ReleaseStr(sczPackageId); + return hr; +} + +static HRESULT OnProgress( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONPROGRESS_ARGS args = { }; + BA_ONPROGRESS_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage); + ExitOnFailure(hr, "Failed to read progress of OnProgress args."); + + hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage); + ExitOnFailure(hr, "Failed to read overall progress of OnProgress args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnProgress results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnProgress(args.dwProgressPercentage, args.dwOverallPercentage, &results.fCancel); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnProgress failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnProgress struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnProgress struct."); + +LExit: + return hr; +} + +static HRESULT OnRegisterBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONREGISTERBEGIN_ARGS args = { }; + BA_ONREGISTERBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRegisterBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedRegistrationType)); + ExitOnFailure(hr, "Failed to read recommended registration type of OnRegisterBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRegisterBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.registrationType)); + ExitOnFailure(hr, "Failed to read registration type of OnRegisterBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnRegisterBegin(args.recommendedRegistrationType, &results.fCancel, &results.registrationType); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnRegisterBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnRegisterBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel); + ExitOnFailure(hr, "Failed to write cancel of OnRegisterBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.registrationType); + ExitOnFailure(hr, "Failed to write registration type of OnRegisterBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnRegisterComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONREGISTERCOMPLETE_ARGS args = { }; + BA_ONREGISTERCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRegisterComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnRegisterComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRegisterComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnRegisterComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnRegisterComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnRegisterComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnRollbackMsiTransactionBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS args = { }; + BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS results = { }; + LPWSTR sczTransactionId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionBegin args."); + + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); + ExitOnFailure(hr, "Failed to read transaction id of OnRollbackMsiTransactionBegin args."); + + args.wzTransactionId = sczTransactionId; + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnRollbackMsiTransactionBegin(args.wzTransactionId); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnRollbackMsiTransactionBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionBegin struct."); + +LExit: + ReleaseStr(sczTransactionId); + return hr; +} + +static HRESULT OnRollbackMsiTransactionComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS args = { }; + BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS results = { }; + LPWSTR sczTransactionId = NULL; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionComplete args."); + + hr = BuffReaderReadString(pReaderArgs, &sczTransactionId); + ExitOnFailure(hr, "Failed to read transaction id of OnRollbackMsiTransactionComplete args."); + + args.wzTransactionId = sczTransactionId; + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnRollbackMsiTransactionComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.restart)); + ExitOnFailure(hr, "Failed to read restart of OnRollbackMsiTransactionComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendation)); + ExitOnFailure(hr, "Failed to read recommendation of OnRollbackMsiTransactionComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionComplete results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnRollbackMsiTransactionComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnRollbackMsiTransactionComplete(args.wzTransactionId, args.hrStatus, args.restart, args.recommendation, &results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnRollbackMsiTransactionComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionComplete struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnRollbackMsiTransactionComplete struct."); + +LExit: + ReleaseStr(sczTransactionId); + return hr; +} + +static HRESULT OnShutdown( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONSHUTDOWN_ARGS args = { }; + BA_ONSHUTDOWN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnShutdown args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnShutdown results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.action)); + ExitOnFailure(hr, "Failed to read action of OnShutdown results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnShutdown(&results.action); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnStartup failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnShutdown struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.action); + ExitOnFailure(hr, "Failed to write action of OnShutdown struct."); + +LExit: + return hr; +} + +static HRESULT OnStartup( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONSTARTUP_ARGS args = { }; + BA_ONSTARTUP_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnStartup args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnStartup results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnStartup(); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnStartup failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnStartup struct."); + +LExit: + return hr; +} + +static HRESULT OnSystemRestorePointBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS args = { }; + BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnSystemRestorePointBegin(); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnSystemRestorePointBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnSystemRestorePointComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS args = { }; + BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnSystemRestorePointComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnSystemRestorePointComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnSystemRestorePointComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointComplete struct."); + +LExit: + return hr; +} + +static HRESULT OnUnregisterBegin( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONUNREGISTERBEGIN_ARGS args = { }; + BA_ONUNREGISTERBEGIN_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnUnregisterBegin args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.recommendedRegistrationType)); + ExitOnFailure(hr, "Failed to read recommended registration type of OnUnregisterBegin args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnUnregisterBegin results."); + + hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast(&results.registrationType)); + ExitOnFailure(hr, "Failed to read registration type of OnUnregisterBegin results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnUnregisterBegin(args.recommendedRegistrationType, &results.registrationType); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnUnregisterBegin failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnUnregisterBegin struct."); + + hr = BuffWriteNumberToBuffer(pBuffer, results.registrationType); + ExitOnFailure(hr, "Failed to write registration type of OnUnregisterBegin struct."); + +LExit: + return hr; +} + +static HRESULT OnUnregisterComplete( + __in IBootstrapperApplication* pApplication, + __in BUFF_READER* pReaderArgs, + __in BUFF_READER* pReaderResults, + __in BUFF_BUFFER* pBuffer + ) +{ + HRESULT hr = S_OK; + BA_ONUNREGISTERCOMPLETE_ARGS args = { }; + BA_ONUNREGISTERCOMPLETE_RESULTS results = { }; + + // Read args. + hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnUnregisterComplete args."); + + hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast(&args.hrStatus)); + ExitOnFailure(hr, "Failed to read status of OnUnregisterComplete args."); + + // Read results. + hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion); + ExitOnFailure(hr, "Failed to read API version of OnUnregisterComplete results."); + + // Callback. + hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, &args, &results); + + if (E_NOTIMPL == hr) + { + hr = pApplication->OnUnregisterComplete(args.hrStatus); + } + + pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, &args, &results, &hr); + BalExitOnFailure(hr, "BA OnUnregisterComplete failed."); + + // Write results. + hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results)); + ExitOnFailure(hr, "Failed to write size of OnUnregisterComplete struct."); + +LExit: + return hr; +} + +static HRESULT ParseArgsAndResults( + __in_bcount(cbData) LPCBYTE pbData, + __in SIZE_T cbData, + __in BUFF_READER* pBufferArgs, + __in BUFF_READER* pBufferResults +) +{ + HRESULT hr = S_OK; + SIZE_T iData = 0; + DWORD dw = 0; + + // Get the args reader size and point to the data just after the size. + hr = BuffReadNumber(pbData, cbData, &iData, &dw); + ExitOnFailure(hr, "Failed to parse size of args"); + + pBufferArgs->pbData = pbData + iData; + pBufferArgs->cbData = dw; + pBufferArgs->iBuffer = 0; + + // Get the results reader size and point to the data just after the size. + hr = ::SIZETAdd(iData, dw, &iData); + ExitOnFailure(hr, "Failed to advance index beyond args"); + + hr = BuffReadNumber(pbData, cbData, &iData, &dw); + ExitOnFailure(hr, "Failed to parse size of results"); + + pBufferResults->pbData = pbData + iData; + pBufferResults->cbData = dw; + pBufferResults->iBuffer = 0; + +LExit: + return hr; +} + +static HRESULT ProcessMessage( + __in PIPE_RPC_HANDLE* phRpcPipe, + __in IBootstrapperApplication* pApplication, + __in IBootstrapperEngine* pEngine, + __in BOOTSTRAPPER_APPLICATION_MESSAGE messageType, + __in_bcount(cbData) LPCBYTE pbData, + __in SIZE_T cbData + ) +{ + HRESULT hr = S_OK; + BUFF_READER readerArgs = { }; + BUFF_READER readerResults = { }; + BUFF_BUFFER bufferResponse = { }; + + hr = ParseArgsAndResults(pbData, cbData, &readerArgs, &readerResults); + if (SUCCEEDED(hr)) + { + switch (messageType) + { + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE: + hr = OnCreate(pApplication, pEngine, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY: + hr = OnDestroy(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP: + hr = OnStartup(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN: + hr = OnShutdown(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN: + hr = OnDetectBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE: + hr = OnDetectComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: + hr = OnDetectForwardCompatibleBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE: + hr = OnDetectMsiFeature(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE: + hr = OnDetectRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN: + hr = OnDetectPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE: + hr = OnDetectPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE: + hr = OnDetectRelatedMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET: + hr = OnDetectPatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN: + hr = OnDetectUpdateBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE: + hr = OnDetectUpdate(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE: + hr = OnDetectUpdateComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN: + hr = OnPlanBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE: + hr = OnPlanComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE: + hr = OnPlanMsiFeature(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: + hr = OnPlanPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE: + hr = OnPlanPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET: + hr = OnPlanPatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE: + hr = OnPlanRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN: + hr = OnApplyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN: + hr = OnElevateBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE: + hr = OnElevateComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS: + hr = OnProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR: + hr = OnError(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN: + hr = OnRegisterBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE: + hr = OnRegisterComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN: + hr = OnCacheBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN: + hr = OnCachePackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN: + hr = OnCacheAcquireBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: + hr = OnCacheAcquireProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING: + hr = OnCacheAcquireResolving(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE: + hr = OnCacheAcquireComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN: + hr = OnCacheVerifyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE: + hr = OnCacheVerifyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE: + hr = OnCachePackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE: + hr = OnCacheComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN: + hr = OnExecuteBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN: + hr = OnExecutePackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET: + hr = OnExecutePatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS: + hr = OnExecuteProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE: + hr = OnExecuteMsiMessage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE: + hr = OnExecuteFilesInUse(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE: + hr = OnExecutePackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE: + hr = OnExecuteComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN: + hr = OnUnregisterBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE: + hr = OnUnregisterComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE: + hr = OnApplyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: + hr = OnLaunchApprovedExeBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: + hr = OnLaunchApprovedExeComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE: + hr = OnPlanMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + hr = OnBeginMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + hr = OnBeginMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + hr = OnCommitMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + hr = OnCommitMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + hr = OnRollbackMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + hr = OnRollbackMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + hr = OnPauseAutomaticUpdatesBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + hr = OnPauseAutomaticUpdatesComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + hr = OnSystemRestorePointBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: + hr = OnSystemRestorePointComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE: + hr = OnPlannedPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: + hr = OnPlanForwardCompatibleBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS: + hr = OnCacheVerifyProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN: + hr = OnCacheContainerOrPayloadVerifyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE: + hr = OnCacheContainerOrPayloadVerifyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS: + hr = OnCacheContainerOrPayloadVerifyProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN: + hr = OnCachePayloadExtractBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE: + hr = OnCachePayloadExtractComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS: + hr = OnCachePayloadExtractProgress(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY: + hr = OnPlanRollbackBoundary(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: + hr = OnDetectCompatibleMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: + hr = OnPlanCompatibleMsiPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: + hr = OnPlanCompatibleMsiPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: + hr = OnPlannedCompatiblePackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE: + hr = OnPlanRestoreRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE: + hr = OnPlanRelatedBundleType(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE: + hr = OnApplyDowngrade(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL: + hr = OnExecuteProcessCancel(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE: + hr = OnDetectRelatedBundlePackage(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE: + hr = OnCachePackageNonVitalValidationFailure(pApplication, &readerArgs, &readerResults, &bufferResponse); + break; + + default: + hr = E_NOTIMPL; + break; + // BalExitWithRootFailure(hr, E_NOTIMPL, "Unknown message type %d sent to bootstrapper application.", messageType) + } + } + + hr = PipeRpcResponse(phRpcPipe, messageType, hr, bufferResponse.pbData, bufferResponse.cbData); + BalExitOnFailure(hr, "Failed to send bootstrapper application callback result to engine."); + +LExit: + ReleaseBuffer(bufferResponse); + + return hr; +} + +EXTERN_C HRESULT MsgPump( + __in HANDLE hPipe, + __in IBootstrapperApplication* pApplication, + __in IBootstrapperEngine* pEngine + ) +{ + HRESULT hr = S_OK; + PIPE_RPC_HANDLE hRpcPipe = { INVALID_HANDLE_VALUE }; + PIPE_MESSAGE msg = { }; + + PipeRpcInitialize(&hRpcPipe, hPipe, FALSE); + + // Pump messages sent to bootstrapper application until the pipe is closed. + while (S_OK == (hr = PipeRpcReadMessage(&hRpcPipe, &msg))) + { + ProcessMessage(&hRpcPipe, pApplication, pEngine, static_cast(msg.dwMessageType), reinterpret_cast(msg.pvData), msg.cbData); + + ReleasePipeMessage(&msg); + } + BalExitOnFailure(hr, "Failed to get message over bootstrapper application pipe"); + + if (S_FALSE == hr) + { + hr = S_OK; + } + +LExit: + ReleasePipeMessage(&msg); + + PipeRpcUninitiailize(&hRpcPipe); + + return hr; +} diff --git a/src/api/burn/balutil/msg.h b/src/api/burn/balutil/msg.h new file mode 100644 index 00000000..ae8a60c1 --- /dev/null +++ b/src/api/burn/balutil/msg.h @@ -0,0 +1,8 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +EXTERN_C HRESULT MsgPump( + __in HANDLE hPipe, + __in IBootstrapperApplication* pApplication, + __in IBootstrapperEngine* pEngine + ); diff --git a/src/api/burn/balutil/precomp.h b/src/api/burn/balutil/precomp.h index 64d4a6cf..ace4f3ec 100644 --- a/src/api/burn/balutil/precomp.h +++ b/src/api/burn/balutil/precomp.h @@ -13,20 +13,25 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include +#include +#include +#include #include #include #include -#include -#include +#include +#include #include "IBootstrapperEngine.h" #include "IBootstrapperApplication.h" @@ -39,3 +44,6 @@ #include "balcondition.h" #include "balinfo.h" #include "balretry.h" + +#include "BalBaseBAFunctionsProc.h" +#include "msg.h" -- cgit v1.2.3-55-g6feb