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 --- .../inc/BootstrapperApplication.h | 1576 ------ .../inc/BootstrapperEngine.h | 454 -- .../inc/baenginetypes.h | 460 ++ .../inc/batypes.h | 1597 ++++++ .../BaseBootstrapperApplicationFactory.cs | 48 +- .../WixToolset.Mba.Core/BootstrapperApplication.cs | 149 +- .../BootstrapperApplicationFactoryAttribute.cs | 18 +- .../WixToolset.Mba.Core/BootstrapperCommand.cs | 44 + src/api/burn/WixToolset.Mba.Core/BundleInfo.cs | 8 +- src/api/burn/WixToolset.Mba.Core/Engine.cs | 4 +- src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 91 +- .../IBootstrapperApplication.cs | 38 +- .../IBootstrapperApplicationFactory.cs | 54 +- .../WixToolset.Mba.Core/IBootstrapperEngine.cs | 9 +- src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs | 11 +- .../IDefaultBootstrapperApplication.cs | 20 +- src/api/burn/WixToolset.Mba.Core/IEngine.cs | 3 +- .../ManagedBootstrapperApplication.cs | 19 + src/api/burn/WixToolset.Mba.Core/MbaNative.cs | 10 +- src/api/burn/WixToolset.Mba.Core/PackageInfo.cs | 6 +- 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 +- src/api/burn/mbanative/mbanative.cpp | 29 - src/api/burn/mbanative/mbanative.def | 4 +- src/api/burn/mbanative/mbanative.vcxproj | 1 - src/api/burn/mbanative/precomp.h | 4 +- .../burn/test/BalUtilUnitTest/BAFunctionsTests.cpp | 18 +- .../BootstrapperApplicationTests.cpp | 21 +- .../burn/test/BalUtilUnitTest/TestBAFunctions.cpp | 26 +- .../burn/test/BalUtilUnitTest/TestBAFunctions.h | 4 +- .../TestBootstrapperApplication.cpp | 15 +- .../BalUtilUnitTest/TestBootstrapperApplication.h | 3 - src/api/burn/test/BalUtilUnitTest/precomp.h | 4 +- .../BaseBootstrapperApplicationFactoryFixture.cs | 141 - .../WixToolset.Data/Symbols/SymbolDefinitions.cs | 2 + .../Symbols/WixBootstrapperApplicationDllSymbol.cs | 6 + .../Symbols/WixBootstrapperApplicationSymbol.cs | 16 + .../Data/IComponentKeyPath.cs | 20 +- 57 files changed, 10242 insertions(+), 4042 deletions(-) delete mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h delete mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/baenginetypes.h create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/batypes.h create mode 100644 src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs 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 delete mode 100644 src/api/burn/mbanative/mbanative.cpp delete mode 100644 src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs (limited to 'src/api') diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h deleted file mode 100644 index 2633a9c2..00000000 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h +++ /dev/null @@ -1,1576 +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. - - -enum BOOTSTRAPPER_DISPLAY -{ - BOOTSTRAPPER_DISPLAY_UNKNOWN, - BOOTSTRAPPER_DISPLAY_EMBEDDED, - BOOTSTRAPPER_DISPLAY_NONE, - BOOTSTRAPPER_DISPLAY_PASSIVE, - BOOTSTRAPPER_DISPLAY_FULL, -}; - -enum BOOTSTRAPPER_REGISTRATION_TYPE -{ - BOOTSTRAPPER_REGISTRATION_TYPE_NONE, // The engine will ignore NONE if it recommended INPROGRESS or FULL. - BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS, - BOOTSTRAPPER_REGISTRATION_TYPE_FULL, -}; - -enum BOOTSTRAPPER_RESUME_TYPE -{ - BOOTSTRAPPER_RESUME_TYPE_NONE, - BOOTSTRAPPER_RESUME_TYPE_INVALID, // resume information is present but invalid - BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, // relaunched after an unexpected interruption - BOOTSTRAPPER_RESUME_TYPE_REBOOT, // relaunched after reboot - BOOTSTRAPPER_RESUME_TYPE_SUSPEND, // relaunched after suspend - BOOTSTRAPPER_RESUME_TYPE_ARP, // launched from ARP -}; - -enum BOOTSTRAPPER_ERROR_TYPE -{ - BOOTSTRAPPER_ERROR_TYPE_ELEVATE, // error occurred trying to elevate. - BOOTSTRAPPER_ERROR_TYPE_WINDOWS_INSTALLER, // error came from windows installer. - BOOTSTRAPPER_ERROR_TYPE_EXE_PACKAGE, // error came from an exe package. - BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER, // error occurred trying to authenticate with HTTP server. - BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY, // error occurred trying to authenticate with HTTP proxy. - BOOTSTRAPPER_ERROR_TYPE_APPLY, // error occurred during apply. -}; - -enum BOOTSTRAPPER_FILES_IN_USE_TYPE -{ - BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI, // INSTALLMESSAGE_FILESINUSE - BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI_RM, // INSTALLMESSAGE_RMFILESINUSE - BOOTSTRAPPER_FILES_IN_USE_TYPE_NETFX, // MMIO_CLOSE_APPS -}; - -enum BOOTSTRAPPER_RELATED_OPERATION -{ - BOOTSTRAPPER_RELATED_OPERATION_NONE, - BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE, - BOOTSTRAPPER_RELATED_OPERATION_MINOR_UPDATE, - BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE, - BOOTSTRAPPER_RELATED_OPERATION_REMOVE, - BOOTSTRAPPER_RELATED_OPERATION_INSTALL, - BOOTSTRAPPER_RELATED_OPERATION_REPAIR, -}; - -enum BOOTSTRAPPER_CACHE_OPERATION -{ - // There is no source available. - BOOTSTRAPPER_CACHE_OPERATION_NONE, - // Copy the payload or container from the chosen local source. - BOOTSTRAPPER_CACHE_OPERATION_COPY, - // Download the payload or container using the download URL. - BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD, - // Extract the payload from the container. - BOOTSTRAPPER_CACHE_OPERATION_EXTRACT, -}; - -enum BOOTSTRAPPER_CACHE_RESOLVE_OPERATION -{ - // There is no source available. - BOOTSTRAPPER_CACHE_RESOLVE_NONE, - // Copy the payload or container from the chosen local source. - BOOTSTRAPPER_CACHE_RESOLVE_LOCAL, - // Download the payload or container from the download URL. - BOOTSTRAPPER_CACHE_RESOLVE_DOWNLOAD, - // Extract the payload from the container. - BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER, - // Look again for the payload or container locally. - BOOTSTRAPPER_CACHE_RESOLVE_RETRY, -}; - -enum BOOTSTRAPPER_CACHE_VERIFY_STEP -{ - BOOTSTRAPPER_CACHE_VERIFY_STEP_STAGE, - BOOTSTRAPPER_CACHE_VERIFY_STEP_HASH, - BOOTSTRAPPER_CACHE_VERIFY_STEP_FINALIZE, -}; - -enum BOOTSTRAPPER_APPLY_RESTART -{ - BOOTSTRAPPER_APPLY_RESTART_NONE, - BOOTSTRAPPER_APPLY_RESTART_REQUIRED, - BOOTSTRAPPER_APPLY_RESTART_INITIATED, -}; - -enum BOOTSTRAPPER_RELATION_TYPE -{ - BOOTSTRAPPER_RELATION_NONE, - BOOTSTRAPPER_RELATION_DETECT, - BOOTSTRAPPER_RELATION_UPGRADE, - BOOTSTRAPPER_RELATION_ADDON, - BOOTSTRAPPER_RELATION_PATCH, - BOOTSTRAPPER_RELATION_DEPENDENT_ADDON, - BOOTSTRAPPER_RELATION_DEPENDENT_PATCH, - BOOTSTRAPPER_RELATION_UPDATE, - BOOTSTRAPPER_RELATION_CHAIN_PACKAGE, -}; - -enum BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE -{ - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_NONE, - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DOWNGRADE, - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_UPGRADE, - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_ADDON, - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_PATCH, - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DEPENDENT_ADDON, - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DEPENDENT_PATCH, -}; - -enum BOOTSTRAPPER_CACHE_TYPE -{ - BOOTSTRAPPER_CACHE_TYPE_REMOVE, - BOOTSTRAPPER_CACHE_TYPE_KEEP, - BOOTSTRAPPER_CACHE_TYPE_FORCE, -}; - -enum BOOTSTRAPPER_PACKAGE_CONDITION_RESULT -{ - BOOTSTRAPPER_PACKAGE_CONDITION_DEFAULT, - BOOTSTRAPPER_PACKAGE_CONDITION_FALSE, - BOOTSTRAPPER_PACKAGE_CONDITION_TRUE, -}; - -enum BOOTSTRAPPER_MSI_FILE_VERSIONING -{ - BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER, //o - BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER_OR_EQUAL, //e - BOOTSTRAPPER_MSI_FILE_VERSIONING_ALL, //a -}; - -enum BOOTSTRAPPER_APPLICATION_MESSAGE -{ - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, - BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, -}; - -enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION -{ - BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE, - // Instructs the engine to restart. - // The engine will not launch again after the machine is rebooted. - // Ignored if reboot was already initiated by OnExecutePackageComplete(). - BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART, -}; - -enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION -{ - BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_NONE, - // Instructs the engine to try the acquisition of the payload again. - // Ignored if hrStatus is a success. - BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY, -}; - -enum BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION -{ - BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE, - // Instructs the engine to ignore non-vital package failures and - // continue with the caching. - // Ignored if hrStatus is a success or the package is vital. - BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_IGNORE, - // Instructs the engine to try the acquisition and verification of the package again. - // Ignored if hrStatus is a success. - BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_RETRY, -}; - -enum BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION -{ - BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION_NONE, - // Instructs the engine to try to acquire the package so execution can use it. - // Most of the time this is used for installing the package during rollback. - BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION_ACQUIRE, -}; - -enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION -{ - BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_NONE, - // Ignored if hrStatus is a success. - BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_RETRYVERIFICATION, - // Ignored if hrStatus is a success. - BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_RETRYACQUISITION, -}; - -enum BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION -{ - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_NONE, - // Instructs the engine to ignore non-vital package failures and - // continue with the install. - // Ignored if hrStatus is a success or the package is vital. - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_IGNORE, - // Instructs the engine to try the execution of the package again. - // Ignored if hrStatus is a success. - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RETRY, - // Instructs the engine to stop processing the chain and restart. - // The engine will launch again after the machine is restarted. - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RESTART, - // Instructs the engine to stop processing the chain and - // suspend the current state. - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_SUSPEND, -}; - -enum BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION -{ - BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE, - // Instructs the engine to stop processing the chain and restart. - // The engine will launch again after the machine is restarted. - BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART, -}; - -enum BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION -{ - // Instructs the engine to stop waiting for the process to exit. - // The package is immediately considered to have failed with ERROR_INSTALL_USEREXIT. - // The engine will never rollback the package. - BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION_ABANDON, - // Instructs the engine to wait for the process to exit. - // Once the process has exited, the package is considered to have failed with ERROR_INSTALL_USEREXIT. - // This allows the engine to rollback the package if necessary. - BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION_WAIT, -}; - -enum BOOTSTRAPPER_SHUTDOWN_ACTION -{ - BOOTSTRAPPER_SHUTDOWN_ACTION_NONE, - // Instructs the engine to restart. - // The engine will not launch again after the machine is rebooted. - // Ignored if reboot was already initiated by OnExecutePackageComplete(). - BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART, - // Instructs the engine to unload the bootstrapper application and - // restart the engine which will load the bootstrapper application again. - // Typically used to switch from a native bootstrapper application to a managed one. - BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER, - // Opts out of the engine behavior of trying to uninstall itself - // when no non-permanent packages are installed. - BOOTSTRAPPER_SHUTDOWN_ACTION_SKIP_CLEANUP, -}; - -enum BURN_MSI_PROPERTY -{ - BURN_MSI_PROPERTY_NONE, // no property added - BURN_MSI_PROPERTY_INSTALL, // add BURNMSIINSTALL=1 - BURN_MSI_PROPERTY_MODIFY, // add BURNMSIMODIFY=1 - BURN_MSI_PROPERTY_REPAIR, // add BURNMSIREPAIR=1 - BURN_MSI_PROPERTY_UNINSTALL,// add BURNMSIUNINSTALL=1 -}; - -struct BOOTSTRAPPER_COMMAND -{ - DWORD cbSize; - BOOTSTRAPPER_ACTION action; - BOOTSTRAPPER_DISPLAY display; - - LPWSTR wzCommandLine; - int nCmdShow; - - BOOTSTRAPPER_RESUME_TYPE resumeType; - HWND hwndSplashScreen; - - // If this was run from a related bundle, specifies the relation type - BOOTSTRAPPER_RELATION_TYPE relationType; - BOOL fPassthrough; - - LPWSTR wzLayoutDirectory; - LPWSTR wzBootstrapperWorkingFolder; - LPWSTR wzBootstrapperApplicationDataPath; -}; - -struct BA_ONAPPLYBEGIN_ARGS -{ - DWORD cbSize; - DWORD dwPhaseCount; -}; - -struct BA_ONAPPLYBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONAPPLYCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; - // Indicates whether any package required a reboot or initiated the reboot already. - BOOTSTRAPPER_APPLY_RESTART restart; - BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation; -}; - -struct BA_ONAPPLYCOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_APPLYCOMPLETE_ACTION action; -}; - -struct BA_ONAPPLYDOWNGRADE_ARGS -{ - DWORD cbSize; - HRESULT hrRecommended; -}; - -struct BA_ONAPPLYDOWNGRADE_RESULTS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONBEGINMSITRANSACTIONBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzTransactionId; -}; - -struct BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzTransactionId; - HRESULT hrStatus; -}; - -struct BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONCACHEACQUIREBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - LPCWSTR wzSource; - LPCWSTR wzDownloadUrl; - LPCWSTR wzPayloadContainerId; - BOOTSTRAPPER_CACHE_OPERATION recommendation; -}; - -struct BA_ONCACHEACQUIREBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOTSTRAPPER_CACHE_OPERATION action; -}; - -struct BA_ONCACHEACQUIRECOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - HRESULT hrStatus; - BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation; -}; - -struct BA_ONCACHEACQUIRECOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action; -}; - -struct BA_ONCACHEACQUIREPROGRESS_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - DWORD64 dw64Progress; - DWORD64 dw64Total; - DWORD dwOverallPercentage; -}; - -struct BA_ONCACHEACQUIREPROGRESS_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHEACQUIRERESOLVING_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - LPCWSTR* rgSearchPaths; - DWORD cSearchPaths; - BOOL fFoundLocal; - DWORD dwRecommendedSearchPath; - LPCWSTR wzDownloadUrl; - LPCWSTR wzPayloadContainerId; - BOOTSTRAPPER_CACHE_RESOLVE_OPERATION recommendation; -}; - -struct BA_ONCACHEACQUIRERESOLVING_RESULTS -{ - DWORD cbSize; - DWORD dwChosenSearchPath; - BOOTSTRAPPER_CACHE_RESOLVE_OPERATION action; - BOOL fCancel; -}; - -struct BA_ONCACHEBEGIN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONCACHEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHECOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONCACHECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; -}; - -struct BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - HRESULT hrStatus; -}; - -struct BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - DWORD64 dw64Progress; - DWORD64 dw64Total; - DWORD dwOverallPercentage; -}; - -struct BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHEPACKAGEBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - DWORD cCachePayloads; - DWORD64 dw64PackageCacheSize; - // If caching a package is not vital, then acquisition will be skipped unless the BA opts in through OnCachePackageNonVitalValidationFailure. - BOOL fVital; -}; - -struct BA_ONCACHEPACKAGEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHEPACKAGECOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - HRESULT hrStatus; - BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation; -}; - -struct BA_ONCACHEPACKAGECOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action; -}; - -struct BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - HRESULT hrStatus; - BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION recommendation; -}; - -struct BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION action; -}; - -struct BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzContainerId; - LPCWSTR wzPayloadId; -}; - -struct BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzContainerId; - LPCWSTR wzPayloadId; - HRESULT hrStatus; -}; - -struct BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS -{ - DWORD cbSize; - LPCWSTR wzContainerId; - LPCWSTR wzPayloadId; - DWORD64 dw64Progress; - DWORD64 dw64Total; - DWORD dwOverallPercentage; -}; - -struct BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHEVERIFYBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; -}; - -struct BA_ONCACHEVERIFYBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCACHEVERIFYCOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - HRESULT hrStatus; - BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation; -}; - -struct BA_ONCACHEVERIFYCOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action; -}; - -struct BA_ONCACHEVERIFYPROGRESS_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - DWORD64 dw64Progress; - DWORD64 dw64Total; - DWORD dwOverallPercentage; - BOOTSTRAPPER_CACHE_VERIFY_STEP verifyStep; -}; - -struct BA_ONCACHEVERIFYPROGRESS_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzTransactionId; -}; - -struct BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzTransactionId; - HRESULT hrStatus; - BOOTSTRAPPER_APPLY_RESTART restart; - BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation; -}; - -struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action; -}; - -struct BA_ONDETECTBEGIN_ARGS -{ - DWORD cbSize; - BOOTSTRAPPER_REGISTRATION_TYPE registrationType; - DWORD cPackages; - BOOL fCached; -}; - -struct BA_ONDETECTBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzCompatiblePackageId; - LPCWSTR wzCompatiblePackageVersion; -}; - -struct BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; - BOOL fEligibleForCleanup; -}; - -struct BA_ONDETECTCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - BOOTSTRAPPER_RELATION_TYPE relationType; - LPCWSTR wzBundleTag; - BOOL fPerMachine; - LPCWSTR wzVersion; - BOOL fMissingFromCache; -}; - -struct BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTMSIFEATURE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzFeatureId; - BOOTSTRAPPER_FEATURE_STATE state; -}; - -struct BA_ONDETECTMSIFEATURE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTPACKAGEBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; -}; - -struct BA_ONDETECTPACKAGEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTPACKAGECOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - HRESULT hrStatus; - BOOTSTRAPPER_PACKAGE_STATE state; - BOOL fCached; -}; - -struct BA_ONDETECTPACKAGECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONDETECTRELATEDBUNDLE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - BOOTSTRAPPER_RELATION_TYPE relationType; - LPCWSTR wzBundleTag; - BOOL fPerMachine; - LPCWSTR wzVersion; - BOOL fMissingFromCache; -}; - -struct BA_ONDETECTRELATEDBUNDLE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzBundleId; - BOOTSTRAPPER_RELATION_TYPE relationType; - BOOL fPerMachine; - LPCWSTR wzVersion; -}; - -struct BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTRELATEDMSIPACKAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzUpgradeCode; - LPCWSTR wzProductCode; - BOOL fPerMachine; - LPCWSTR wzVersion; - BOOTSTRAPPER_RELATED_OPERATION operation; -}; - -struct BA_ONDETECTRELATEDMSIPACKAGE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTPATCHTARGET_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzProductCode; - BOOTSTRAPPER_PACKAGE_STATE patchState; -}; - -struct BA_ONDETECTPATCHTARGET_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONDETECTUPDATE_ARGS -{ - DWORD cbSize; - LPCWSTR wzUpdateLocation; - DWORD64 dw64Size; - LPCWSTR wzHash; - BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm; - LPCWSTR wzVersion; - LPCWSTR wzTitle; - LPCWSTR wzSummary; - LPCWSTR wzContentType; - LPCWSTR wzContent; -}; - -struct BA_ONDETECTUPDATE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOL fStopProcessingUpdates; -}; - -struct BA_ONDETECTUPDATEBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzUpdateLocation; -}; - -struct BA_ONDETECTUPDATEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOL fSkip; -}; - -struct BA_ONDETECTUPDATECOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONDETECTUPDATECOMPLETE_RESULTS -{ - DWORD cbSize; - BOOL fIgnoreError; -}; - -struct BA_ONELEVATEBEGIN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONELEVATEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONELEVATECOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONELEVATECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONERROR_ARGS -{ - DWORD cbSize; - BOOTSTRAPPER_ERROR_TYPE errorType; - LPCWSTR wzPackageId; - DWORD dwCode; - LPCWSTR wzError; - DWORD dwUIHint; - DWORD cData; - LPCWSTR* rgwzData; - int nRecommendation; -}; - -struct BA_ONERROR_RESULTS -{ - DWORD cbSize; - int nResult; -}; - -struct BA_ONEXECUTEBEGIN_ARGS -{ - DWORD cbSize; - DWORD cExecutingPackages; -}; - -struct BA_ONEXECUTEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONEXECUTECOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONEXECUTECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONEXECUTEFILESINUSE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - DWORD cFiles; - LPCWSTR* rgwzFiles; - int nRecommendation; - BOOTSTRAPPER_FILES_IN_USE_TYPE source; -}; - -struct BA_ONEXECUTEFILESINUSE_RESULTS -{ - DWORD cbSize; - int nResult; -}; - -struct BA_ONEXECUTEMSIMESSAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - INSTALLMESSAGE messageType; - DWORD dwUIHint; - LPCWSTR wzMessage; - DWORD cData; - LPCWSTR* rgwzData; - int nRecommendation; -}; - -struct BA_ONEXECUTEMSIMESSAGE_RESULTS -{ - DWORD cbSize; - int nResult; -}; - -struct BA_ONEXECUTEPACKAGEBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - BOOL fExecute; // false means rollback. - BOOTSTRAPPER_ACTION_STATE action; - INSTALLUILEVEL uiLevel; - BOOL fDisableExternalUiHandler; -}; - -struct BA_ONEXECUTEPACKAGEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONEXECUTEPACKAGECOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - HRESULT hrStatus; - // Indicates whether this package requires a reboot or initiated the reboot already. - BOOTSTRAPPER_APPLY_RESTART restart; - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation; -}; - -struct BA_ONEXECUTEPACKAGECOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION action; -}; - -struct BA_ONEXECUTEPATCHTARGET_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzTargetProductCode; -}; - -struct BA_ONEXECUTEPATCHTARGET_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONEXECUTEPROCESSCANCEL_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - DWORD dwProcessId; - BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION recommendation; -}; - -struct BA_ONEXECUTEPROCESSCANCEL_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION action; -}; - -struct BA_ONEXECUTEPROGRESS_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - DWORD dwProgressPercentage; - DWORD dwOverallPercentage; -}; - -struct BA_ONEXECUTEPROGRESS_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; - // Only valid if the operation succeeded. - DWORD dwProcessId; -}; - -struct BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPLANBEGIN_ARGS -{ - DWORD cbSize; - DWORD cPackages; -}; - -struct BA_ONPLANBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzCompatiblePackageId; - LPCWSTR wzCompatiblePackageVersion; - BOOL fRecommendedRemove; -}; - -struct BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOL fRequestRemove; -}; - -struct BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzCompatiblePackageId; - HRESULT hrStatus; - BOOL fRequestedRemove; -}; - -struct BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPLANCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONPLANCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - BOOTSTRAPPER_RELATION_TYPE relationType; - LPCWSTR wzBundleTag; - BOOL fPerMachine; - LPCWSTR wzVersion; - BOOL fRecommendedIgnoreBundle; -}; - -struct BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOL fIgnoreBundle; -}; - -struct BA_ONPLANMSIFEATURE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzFeatureId; - BOOTSTRAPPER_FEATURE_STATE recommendedState; -}; - -struct BA_ONPLANMSIFEATURE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_FEATURE_STATE requestedState; - BOOL fCancel; -}; - -struct BA_ONPLANMSIPACKAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - BOOL fExecute; // false means rollback. - BOOTSTRAPPER_ACTION_STATE action; - BOOTSTRAPPER_MSI_FILE_VERSIONING recommendedFileVersioning; -}; - -struct BA_ONPLANMSIPACKAGE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BURN_MSI_PROPERTY actionMsiProperty; - INSTALLUILEVEL uiLevel; - BOOL fDisableExternalUiHandler; - BOOTSTRAPPER_MSI_FILE_VERSIONING fileVersioning; -}; - -struct BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzCompatiblePackageId; - BOOL fRemove; -}; - -struct BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPLANNEDPACKAGE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - BOOTSTRAPPER_ACTION_STATE execute; - BOOTSTRAPPER_ACTION_STATE rollback; - BOOL fPlannedCache; - BOOL fPlannedUncache; -}; - -struct BA_ONPLANNEDPACKAGE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPLANPACKAGEBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - BOOTSTRAPPER_PACKAGE_STATE state; - BOOL fCached; - BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition; - BOOTSTRAPPER_REQUEST_STATE recommendedState; - BOOTSTRAPPER_CACHE_TYPE recommendedCacheType; - BOOTSTRAPPER_PACKAGE_CONDITION_RESULT repairCondition; -}; - -struct BA_ONPLANPACKAGEBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOTSTRAPPER_REQUEST_STATE requestedState; - BOOTSTRAPPER_CACHE_TYPE requestedCacheType; -}; - -struct BA_ONPLANPACKAGECOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - HRESULT hrStatus; - BOOTSTRAPPER_REQUEST_STATE requested; -}; - -struct BA_ONPLANPACKAGECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONPLANRELATEDBUNDLE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - BOOTSTRAPPER_REQUEST_STATE recommendedState; -}; - -struct BA_ONPLANRELATEDBUNDLE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOTSTRAPPER_REQUEST_STATE requestedState; -}; - -struct BA_ONPLANRELATEDBUNDLETYPE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE recommendedType; -}; - -struct BA_ONPLANRELATEDBUNDLETYPE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE requestedType; -}; - -struct BA_ONPLANRESTORERELATEDBUNDLE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - BOOTSTRAPPER_REQUEST_STATE recommendedState; -}; - -struct BA_ONPLANRESTORERELATEDBUNDLE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOTSTRAPPER_REQUEST_STATE requestedState; -}; - -struct BA_ONPLANROLLBACKBOUNDARY_ARGS -{ - DWORD cbSize; - LPCWSTR wzRollbackBoundaryId; - BOOL fRecommendedTransaction; -}; - -struct BA_ONPLANROLLBACKBOUNDARY_RESULTS -{ - DWORD cbSize; - BOOL fTransaction; - BOOL fCancel; -}; - -struct BA_ONPLANPATCHTARGET_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageId; - LPCWSTR wzProductCode; - BOOTSTRAPPER_REQUEST_STATE recommendedState; -}; - -struct BA_ONPLANPATCHTARGET_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_REQUEST_STATE requestedState; - BOOL fCancel; -}; - -struct BA_ONPROGRESS_ARGS -{ - DWORD cbSize; - DWORD dwProgressPercentage; - DWORD dwOverallPercentage; -}; - -struct BA_ONPROGRESS_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONREGISTERBEGIN_ARGS -{ - DWORD cbSize; - BOOTSTRAPPER_REGISTRATION_TYPE recommendedRegistrationType; -}; - -struct BA_ONREGISTERBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BOOTSTRAPPER_REGISTRATION_TYPE registrationType; -}; - -struct BA_ONREGISTERCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONREGISTERCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS -{ - DWORD cbSize; - LPCWSTR wzTransactionId; -}; - -struct BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS -{ - DWORD cbSize; - LPCWSTR wzTransactionId; - HRESULT hrStatus; - BOOTSTRAPPER_APPLY_RESTART restart; - BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation; -}; - -struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action; -}; - -struct BA_ONSETUPDATEBEGIN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONSETUPDATEBEGIN_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONSETUPDATECOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; - LPCWSTR wzPreviousPackageId; - LPCWSTR wzNewPackageId; -}; - -struct BA_ONSETUPDATECOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONSHUTDOWN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONSHUTDOWN_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_SHUTDOWN_ACTION action; -}; - -struct BA_ONSTARTUP_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONSTARTUP_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS -{ - DWORD cbSize; -}; - -struct BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONUNREGISTERBEGIN_ARGS -{ - DWORD cbSize; - BOOTSTRAPPER_REGISTRATION_TYPE recommendedRegistrationType; -}; - -struct BA_ONUNREGISTERBEGIN_RESULTS -{ - DWORD cbSize; - BOOTSTRAPPER_REGISTRATION_TYPE registrationType; -}; - -struct BA_ONUNREGISTERCOMPLETE_ARGS -{ - DWORD cbSize; - HRESULT hrStatus; -}; - -struct BA_ONUNREGISTERCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - - - -extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_APPLICATION_PROC)( - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ); - -struct BOOTSTRAPPER_DESTROY_ARGS -{ - DWORD cbSize; - BOOL fReload; -}; - -struct BOOTSTRAPPER_DESTROY_RESULTS -{ - DWORD cbSize; - BOOL fDisableUnloading; // indicates the BA dll must not be unloaded after BootstrapperApplicationDestroy. -}; - -extern "C" typedef void (WINAPI *PFN_BOOTSTRAPPER_APPLICATION_DESTROY)( - __in const BOOTSTRAPPER_DESTROY_ARGS* pArgs, - __inout BOOTSTRAPPER_DESTROY_RESULTS* pResults - ); - - - -struct BOOTSTRAPPER_CREATE_ARGS -{ - DWORD cbSize; - DWORD64 qwEngineAPIVersion; - PFN_BOOTSTRAPPER_ENGINE_PROC pfnBootstrapperEngineProc; - LPVOID pvBootstrapperEngineProcContext; - BOOTSTRAPPER_COMMAND* pCommand; -}; - -struct BOOTSTRAPPER_CREATE_RESULTS -{ - DWORD cbSize; - PFN_BOOTSTRAPPER_APPLICATION_PROC pfnBootstrapperApplicationProc; - LPVOID pvBootstrapperApplicationProcContext; -}; - -extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_APPLICATION_CREATE)( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __inout BOOTSTRAPPER_CREATE_RESULTS* pResults - ); diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h deleted file mode 100644 index 96302bd1..00000000 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h +++ /dev/null @@ -1,454 +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. - - -#if defined(__cplusplus) -extern "C" { -#endif - -#define IDERROR -1 -#define IDNOACTION 0 - -#ifndef FACILITY_WIX -#define FACILITY_WIX 500 -#endif - -static const HRESULT E_SUSPECTED_AV_INTERFERENCE = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 2000); - -enum BOOTSTRAPPER_ACTION -{ - BOOTSTRAPPER_ACTION_UNKNOWN, - BOOTSTRAPPER_ACTION_HELP, - BOOTSTRAPPER_ACTION_LAYOUT, - BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL, - BOOTSTRAPPER_ACTION_UNINSTALL, - BOOTSTRAPPER_ACTION_CACHE, - BOOTSTRAPPER_ACTION_INSTALL, - BOOTSTRAPPER_ACTION_MODIFY, - BOOTSTRAPPER_ACTION_REPAIR, - BOOTSTRAPPER_ACTION_UPDATE_REPLACE, - BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED, -}; - -enum BOOTSTRAPPER_ACTION_STATE -{ - BOOTSTRAPPER_ACTION_STATE_NONE, - BOOTSTRAPPER_ACTION_STATE_UNINSTALL, - BOOTSTRAPPER_ACTION_STATE_INSTALL, - BOOTSTRAPPER_ACTION_STATE_MODIFY, - BOOTSTRAPPER_ACTION_STATE_REPAIR, - BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE, -}; - -enum BOOTSTRAPPER_PACKAGE_STATE -{ - BOOTSTRAPPER_PACKAGE_STATE_UNKNOWN, - BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE, - BOOTSTRAPPER_PACKAGE_STATE_ABSENT, - BOOTSTRAPPER_PACKAGE_STATE_PRESENT, - BOOTSTRAPPER_PACKAGE_STATE_SUPERSEDED, -}; - -enum BOOTSTRAPPER_REQUEST_STATE -{ - BOOTSTRAPPER_REQUEST_STATE_NONE, - BOOTSTRAPPER_REQUEST_STATE_FORCE_ABSENT, - BOOTSTRAPPER_REQUEST_STATE_ABSENT, - BOOTSTRAPPER_REQUEST_STATE_CACHE, - BOOTSTRAPPER_REQUEST_STATE_PRESENT, - BOOTSTRAPPER_REQUEST_STATE_FORCE_PRESENT, - BOOTSTRAPPER_REQUEST_STATE_REPAIR, -}; - -enum BOOTSTRAPPER_FEATURE_STATE -{ - BOOTSTRAPPER_FEATURE_STATE_UNKNOWN, - BOOTSTRAPPER_FEATURE_STATE_ABSENT, - BOOTSTRAPPER_FEATURE_STATE_ADVERTISED, - BOOTSTRAPPER_FEATURE_STATE_LOCAL, - BOOTSTRAPPER_FEATURE_STATE_SOURCE, -}; - -enum BOOTSTRAPPER_LOG_LEVEL -{ - BOOTSTRAPPER_LOG_LEVEL_NONE, // turns off report (only valid for XXXSetLevel()) - BOOTSTRAPPER_LOG_LEVEL_STANDARD, // written if reporting is on - BOOTSTRAPPER_LOG_LEVEL_VERBOSE, // written only if verbose reporting is on - BOOTSTRAPPER_LOG_LEVEL_DEBUG, // reporting useful when debugging code - BOOTSTRAPPER_LOG_LEVEL_ERROR, // always gets reported, but can never be specified -}; - -enum BOOTSTRAPPER_UPDATE_HASH_TYPE -{ - BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE, - BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512, -}; - -enum BOOTSTRAPPER_ENGINE_MESSAGE -{ - BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, - BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, - BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, - BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, - BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, - BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, - BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, - BOOTSTRAPPER_ENGINE_MESSAGE_LOG, - BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, - BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, - BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, - BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, - BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, - BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, - BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, - BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, - BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, - BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, - BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, - BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, - BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, - BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, - BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, - BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, - BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, - BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, -}; - -typedef struct _BAENGINE_APPLY_ARGS -{ - DWORD cbSize; - HWND hwndParent; -} BAENGINE_APPLY_ARGS; - -typedef struct _BAENGINE_APPLY_RESULTS -{ - DWORD cbSize; -} BAENGINE_APPLY_RESULTS; - -typedef struct _BAENGINE_CLOSESPLASHSCREEN_ARGS -{ - DWORD cbSize; -} BAENGINE_CLOSESPLASHSCREEN_ARGS; - -typedef struct _BAENGINE_CLOSESPLASHSCREEN_RESULTS -{ - DWORD cbSize; -} BAENGINE_CLOSESPLASHSCREEN_RESULTS; - -typedef struct _BAENGINE_COMPAREVERSIONS_ARGS -{ - DWORD cbSize; - LPCWSTR wzVersion1; - LPCWSTR wzVersion2; -} BAENGINE_COMPAREVERSIONS_ARGS; - -typedef struct _BAENGINE_COMPAREVERSIONS_RESULTS -{ - DWORD cbSize; - int nResult; -} BAENGINE_COMPAREVERSIONS_RESULTS; - -typedef struct _BAENGINE_DETECT_ARGS -{ - DWORD cbSize; - HWND hwndParent; -} BAENGINE_DETECT_ARGS; - -typedef struct _BAENGINE_DETECT_RESULTS -{ - DWORD cbSize; -} BAENGINE_DETECT_RESULTS; - -typedef struct _BAENGINE_ELEVATE_ARGS -{ - DWORD cbSize; - HWND hwndParent; -} BAENGINE_ELEVATE_ARGS; - -typedef struct _BAENGINE_ELEVATE_RESULTS -{ - DWORD cbSize; -} BAENGINE_ELEVATE_RESULTS; - -typedef struct _BAENGINE_ESCAPESTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzIn; -} BAENGINE_ESCAPESTRING_ARGS; - -typedef struct _BAENGINE_ESCAPESTRING_RESULTS -{ - DWORD cbSize; - LPWSTR wzOut; - // Should be initialized to the size of wzOut. - SIZE_T cchOut; -} BAENGINE_ESCAPESTRING_RESULTS; - -typedef struct _BAENGINE_EVALUATECONDITION_ARGS -{ - DWORD cbSize; - LPCWSTR wzCondition; -} BAENGINE_EVALUATECONDITION_ARGS; - -typedef struct _BAENGINE_EVALUATECONDITION_RESULTS -{ - DWORD cbSize; - BOOL f; -} BAENGINE_EVALUATECONDITION_RESULTS; - -typedef struct _BAENGINE_FORMATSTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzIn; -} BAENGINE_FORMATSTRING_ARGS; - -typedef struct _BAENGINE_FORMATSTRING_RESULTS -{ - DWORD cbSize; - LPWSTR wzOut; - // Should be initialized to the size of wzOut. - SIZE_T cchOut; -} BAENGINE_FORMATSTRING_RESULTS; - -typedef struct _BAENGINE_GETPACKAGECOUNT_ARGS -{ - DWORD cbSize; -} BAENGINE_GETPACKAGECOUNT_ARGS; - -typedef struct _BAENGINE_GETPACKAGECOUNT_RESULTS -{ - DWORD cbSize; - DWORD cPackages; -} BAENGINE_GETPACKAGECOUNT_RESULTS; - -typedef struct _BAENGINE_GETVARIABLENUMERIC_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; -} BAENGINE_GETVARIABLENUMERIC_ARGS; - -typedef struct _BAENGINE_GETVARIABLENUMERIC_RESULTS -{ - DWORD cbSize; - LONGLONG llValue; -} BAENGINE_GETVARIABLENUMERIC_RESULTS; - -typedef struct _BAENGINE_GETVARIABLESTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; -} BAENGINE_GETVARIABLESTRING_ARGS; - -typedef struct _BAENGINE_GETVARIABLESTRING_RESULTS -{ - DWORD cbSize; - LPWSTR wzValue; - // Should be initialized to the size of wzValue. - SIZE_T cchValue; -} BAENGINE_GETVARIABLESTRING_RESULTS; - -typedef struct _BAENGINE_GETVARIABLEVERSION_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; -} BAENGINE_GETVARIABLEVERSION_ARGS; - -typedef struct _BAENGINE_GETVARIABLEVERSION_RESULTS -{ - DWORD cbSize; - LPWSTR wzValue; - // Should be initialized to the size of wzValue. - SIZE_T cchValue; -} BAENGINE_GETVARIABLEVERSION_RESULTS; - -typedef struct _BAENGINE_LAUNCHAPPROVEDEXE_ARGS -{ - DWORD cbSize; - HWND hwndParent; - LPCWSTR wzApprovedExeForElevationId; - LPCWSTR wzArguments; - DWORD dwWaitForInputIdleTimeout; -} BAENGINE_LAUNCHAPPROVEDEXE_ARGS; - -typedef struct _BAENGINE_LAUNCHAPPROVEDEXE_RESULTS -{ - DWORD cbSize; -} BAENGINE_LAUNCHAPPROVEDEXE_RESULTS; - -typedef struct _BAENGINE_SETUPDATESOURCE_ARGS -{ - DWORD cbSize; - LPCWSTR wzUrl; -} BAENGINE_SETUPDATESOURCE_ARGS; - -typedef struct _BAENGINE_SETUPDATESOURCE_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETUPDATESOURCE_RESULTS; - -typedef struct _BAENGINE_LOG_ARGS -{ - DWORD cbSize; - BOOTSTRAPPER_LOG_LEVEL level; - LPCWSTR wzMessage; -} BAENGINE_LOG_ARGS; - -typedef struct _BAENGINE_LOG_RESULTS -{ - DWORD cbSize; -} BAENGINE_LOG_RESULTS; - -typedef struct _BAENGINE_PLAN_ARGS -{ - DWORD cbSize; - BOOTSTRAPPER_ACTION action; -} BAENGINE_PLAN_ARGS; - -typedef struct _BAENGINE_PLAN_RESULTS -{ - DWORD cbSize; -} BAENGINE_PLAN_RESULTS; - -typedef struct _BAENGINE_QUIT_ARGS -{ - DWORD cbSize; - DWORD dwExitCode; -} BAENGINE_QUIT_ARGS; - -typedef struct _BAENGINE_QUIT_RESULTS -{ - DWORD cbSize; -} BAENGINE_QUIT_RESULTS; - -typedef struct _BAENGINE_SENDEMBEDDEDERROR_ARGS -{ - DWORD cbSize; - DWORD dwErrorCode; - LPCWSTR wzMessage; - DWORD dwUIHint; -} BAENGINE_SENDEMBEDDEDERROR_ARGS; - -typedef struct _BAENGINE_SENDEMBEDDEDERROR_RESULTS -{ - DWORD cbSize; - int nResult; -} BAENGINE_SENDEMBEDDEDERROR_RESULTS; - -typedef struct _BAENGINE_SENDEMBEDDEDPROGRESS_ARGS -{ - DWORD cbSize; - DWORD dwProgressPercentage; - DWORD dwOverallProgressPercentage; -} BAENGINE_SENDEMBEDDEDPROGRESS_ARGS; - -typedef struct _BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS -{ - DWORD cbSize; - int nResult; -} BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS; - -typedef struct _BAENGINE_SETDOWNLOADSOURCE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - LPCWSTR wzUrl; - LPCWSTR wzUser; - LPCWSTR wzPassword; -} BAENGINE_SETDOWNLOADSOURCE_ARGS; - -typedef struct _BAENGINE_SETDOWNLOADSOURCE_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETDOWNLOADSOURCE_RESULTS; - -typedef struct _BAENGINE_SETLOCALSOURCE_ARGS -{ - DWORD cbSize; - LPCWSTR wzPackageOrContainerId; - LPCWSTR wzPayloadId; - LPCWSTR wzPath; -} BAENGINE_SETLOCALSOURCE_ARGS; - -typedef struct _BAENGINE_SETLOCALSOURCE_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETLOCALSOURCE_RESULTS; - -typedef struct _BAENGINE_SETUPDATE_ARGS -{ - DWORD cbSize; - LPCWSTR wzLocalSource; - LPCWSTR wzDownloadSource; - DWORD64 qwSize; - BOOTSTRAPPER_UPDATE_HASH_TYPE hashType; - LPCWSTR wzHash; -} BAENGINE_SETUPDATE_ARGS; - -typedef struct _BAENGINE_SETUPDATE_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETUPDATE_RESULTS; - -typedef struct _BAENGINE_SETVARIABLENUMERIC_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; - LONGLONG llValue; -} BAENGINE_SETVARIABLENUMERIC_ARGS; - -typedef struct _BAENGINE_SETVARIABLENUMERIC_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETVARIABLENUMERIC_RESULTS; - -typedef struct _BAENGINE_SETVARIABLESTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; - LPCWSTR wzValue; - BOOL fFormatted; -} BAENGINE_SETVARIABLESTRING_ARGS; - -typedef struct _BAENGINE_SETVARIABLESTRING_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETVARIABLESTRING_RESULTS; - -typedef struct _BAENGINE_SETVARIABLEVERSION_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; - LPCWSTR wzValue; -} BAENGINE_SETVARIABLEVERSION_ARGS; - -typedef struct _BAENGINE_SETVARIABLEVERSION_RESULTS -{ - DWORD cbSize; -} BAENGINE_SETVARIABLEVERSION_RESULTS; - -typedef struct _BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS -{ - DWORD cbSize; - LPCWSTR wzBundleId; - LPCWSTR wzVariable; -} BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS; - -typedef struct _BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS -{ - DWORD cbSize; - LPWSTR wzValue; - // Should be initialized to the size of wzValue. - SIZE_T cchValue; -} BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS; - -extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_ENGINE_PROC)( - __in BOOTSTRAPPER_ENGINE_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ); - -#if defined(__cplusplus) -} -#endif diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/baenginetypes.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/baenginetypes.h new file mode 100644 index 00000000..7af41d97 --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/baenginetypes.h @@ -0,0 +1,460 @@ +#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. + + +#if defined(__cplusplus) +extern "C" { +#endif + +#define IDERROR -1 +#define IDNOACTION 0 + +#ifndef FACILITY_WIX +#define FACILITY_WIX 500 +#endif + +static const HRESULT E_SUSPECTED_AV_INTERFERENCE = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 2000); + +enum BOOTSTRAPPER_ACTION +{ + BOOTSTRAPPER_ACTION_UNKNOWN, + BOOTSTRAPPER_ACTION_HELP, + BOOTSTRAPPER_ACTION_LAYOUT, + BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL, + BOOTSTRAPPER_ACTION_UNINSTALL, + BOOTSTRAPPER_ACTION_CACHE, + BOOTSTRAPPER_ACTION_INSTALL, + BOOTSTRAPPER_ACTION_MODIFY, + BOOTSTRAPPER_ACTION_REPAIR, + BOOTSTRAPPER_ACTION_UPDATE_REPLACE, + BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED, +}; + +enum BOOTSTRAPPER_ACTION_STATE +{ + BOOTSTRAPPER_ACTION_STATE_NONE, + BOOTSTRAPPER_ACTION_STATE_UNINSTALL, + BOOTSTRAPPER_ACTION_STATE_INSTALL, + BOOTSTRAPPER_ACTION_STATE_MODIFY, + BOOTSTRAPPER_ACTION_STATE_REPAIR, + BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE, +}; + +enum BOOTSTRAPPER_PACKAGE_STATE +{ + BOOTSTRAPPER_PACKAGE_STATE_UNKNOWN, + BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE, + BOOTSTRAPPER_PACKAGE_STATE_ABSENT, + BOOTSTRAPPER_PACKAGE_STATE_PRESENT, + BOOTSTRAPPER_PACKAGE_STATE_SUPERSEDED, +}; + +enum BOOTSTRAPPER_REQUEST_STATE +{ + BOOTSTRAPPER_REQUEST_STATE_NONE, + BOOTSTRAPPER_REQUEST_STATE_FORCE_ABSENT, + BOOTSTRAPPER_REQUEST_STATE_ABSENT, + BOOTSTRAPPER_REQUEST_STATE_CACHE, + BOOTSTRAPPER_REQUEST_STATE_PRESENT, + BOOTSTRAPPER_REQUEST_STATE_FORCE_PRESENT, + BOOTSTRAPPER_REQUEST_STATE_REPAIR, +}; + +enum BOOTSTRAPPER_FEATURE_STATE +{ + BOOTSTRAPPER_FEATURE_STATE_UNKNOWN, + BOOTSTRAPPER_FEATURE_STATE_ABSENT, + BOOTSTRAPPER_FEATURE_STATE_ADVERTISED, + BOOTSTRAPPER_FEATURE_STATE_LOCAL, + BOOTSTRAPPER_FEATURE_STATE_SOURCE, +}; + +enum BOOTSTRAPPER_LOG_LEVEL +{ + BOOTSTRAPPER_LOG_LEVEL_NONE, // turns off report (only valid for XXXSetLevel()) + BOOTSTRAPPER_LOG_LEVEL_STANDARD, // written if reporting is on + BOOTSTRAPPER_LOG_LEVEL_VERBOSE, // written only if verbose reporting is on + BOOTSTRAPPER_LOG_LEVEL_DEBUG, // reporting useful when debugging code + BOOTSTRAPPER_LOG_LEVEL_ERROR, // always gets reported, but can never be specified +}; + +enum BOOTSTRAPPER_UPDATE_HASH_TYPE +{ + BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE, + BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512, +}; + +enum BOOTSTRAPPER_ENGINE_MESSAGE +{ + BOOTSTRAPPER_ENGINE_MESSAGE_UNKNOWN, + BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, + BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, + BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, + BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, + BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, + BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, + BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, + BOOTSTRAPPER_ENGINE_MESSAGE_LOG, + BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, + BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, + BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, + BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, + BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, + BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, + BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, + BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, + BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, + BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, + BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, + BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, + BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, + BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, + BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, + BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, + BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, + BOOTSTRAPPER_ENGINE_MESSAGE_GETRELATEDBUNDLEVARIABLE, + + BOOTSTRAPPER_APPLICATION_MESSAGE_LAST = 65535 +}; + +typedef struct _BAENGINE_APPLY_ARGS +{ + DWORD dwApiVersion; + DWORD64 hwndParent; +} BAENGINE_APPLY_ARGS; + +typedef struct _BAENGINE_APPLY_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_APPLY_RESULTS; + +typedef struct _BAENGINE_CLOSESPLASHSCREEN_ARGS +{ + DWORD dwApiVersion; +} BAENGINE_CLOSESPLASHSCREEN_ARGS; + +typedef struct _BAENGINE_CLOSESPLASHSCREEN_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_CLOSESPLASHSCREEN_RESULTS; + +typedef struct _BAENGINE_COMPAREVERSIONS_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVersion1; + LPCWSTR wzVersion2; +} BAENGINE_COMPAREVERSIONS_ARGS; + +typedef struct _BAENGINE_COMPAREVERSIONS_RESULTS +{ + DWORD dwApiVersion; + INT32 nResult; +} BAENGINE_COMPAREVERSIONS_RESULTS; + +typedef struct _BAENGINE_DETECT_ARGS +{ + DWORD dwApiVersion; + DWORD64 hwndParent; +} BAENGINE_DETECT_ARGS; + +typedef struct _BAENGINE_DETECT_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_DETECT_RESULTS; + +typedef struct _BAENGINE_ELEVATE_ARGS +{ + DWORD dwApiVersion; + DWORD64 hwndParent; +} BAENGINE_ELEVATE_ARGS; + +typedef struct _BAENGINE_ELEVATE_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_ELEVATE_RESULTS; + +typedef struct _BAENGINE_ESCAPESTRING_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzIn; +} BAENGINE_ESCAPESTRING_ARGS; + +typedef struct _BAENGINE_ESCAPESTRING_RESULTS +{ + DWORD dwApiVersion; + LPWSTR wzOut; + // Should be initialized to the size of wzOut. + DWORD cchOut; +} BAENGINE_ESCAPESTRING_RESULTS; + +typedef struct _BAENGINE_EVALUATECONDITION_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzCondition; +} BAENGINE_EVALUATECONDITION_ARGS; + +typedef struct _BAENGINE_EVALUATECONDITION_RESULTS +{ + DWORD dwApiVersion; + BOOL f; +} BAENGINE_EVALUATECONDITION_RESULTS; + +typedef struct _BAENGINE_FORMATSTRING_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzIn; +} BAENGINE_FORMATSTRING_ARGS; + +typedef struct _BAENGINE_FORMATSTRING_RESULTS +{ + DWORD dwApiVersion; + LPWSTR wzOut; + // Should be initialized to the size of wzOut. + DWORD cchOut; +} BAENGINE_FORMATSTRING_RESULTS; + +typedef struct _BAENGINE_GETPACKAGECOUNT_ARGS +{ + DWORD dwApiVersion; +} BAENGINE_GETPACKAGECOUNT_ARGS; + +typedef struct _BAENGINE_GETPACKAGECOUNT_RESULTS +{ + DWORD dwApiVersion; + DWORD cPackages; +} BAENGINE_GETPACKAGECOUNT_RESULTS; + +typedef struct _BAENGINE_GETVARIABLENUMERIC_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVariable; +} BAENGINE_GETVARIABLENUMERIC_ARGS; + +typedef struct _BAENGINE_GETVARIABLENUMERIC_RESULTS +{ + DWORD dwApiVersion; + LONGLONG llValue; +} BAENGINE_GETVARIABLENUMERIC_RESULTS; + +typedef struct _BAENGINE_GETVARIABLESTRING_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVariable; +} BAENGINE_GETVARIABLESTRING_ARGS; + +typedef struct _BAENGINE_GETVARIABLESTRING_RESULTS +{ + DWORD dwApiVersion; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + DWORD cchValue; +} BAENGINE_GETVARIABLESTRING_RESULTS; + +typedef struct _BAENGINE_GETVARIABLEVERSION_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVariable; +} BAENGINE_GETVARIABLEVERSION_ARGS; + +typedef struct _BAENGINE_GETVARIABLEVERSION_RESULTS +{ + DWORD dwApiVersion; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + DWORD cchValue; +} BAENGINE_GETVARIABLEVERSION_RESULTS; + +typedef struct _BAENGINE_LAUNCHAPPROVEDEXE_ARGS +{ + DWORD dwApiVersion; + DWORD64 hwndParent; + LPCWSTR wzApprovedExeForElevationId; + LPCWSTR wzArguments; + DWORD dwWaitForInputIdleTimeout; +} BAENGINE_LAUNCHAPPROVEDEXE_ARGS; + +typedef struct _BAENGINE_LAUNCHAPPROVEDEXE_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_LAUNCHAPPROVEDEXE_RESULTS; + +typedef struct _BAENGINE_SETUPDATESOURCE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzUrl; + LPCWSTR wzAuthorizationHeader; +} BAENGINE_SETUPDATESOURCE_ARGS; + +typedef struct _BAENGINE_SETUPDATESOURCE_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETUPDATESOURCE_RESULTS; + +typedef struct _BAENGINE_LOG_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_LOG_LEVEL level; + LPCWSTR wzMessage; +} BAENGINE_LOG_ARGS; + +typedef struct _BAENGINE_LOG_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_LOG_RESULTS; + +typedef struct _BAENGINE_PLAN_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_ACTION action; +} BAENGINE_PLAN_ARGS; + +typedef struct _BAENGINE_PLAN_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_PLAN_RESULTS; + +typedef struct _BAENGINE_QUIT_ARGS +{ + DWORD dwApiVersion; + DWORD dwExitCode; +} BAENGINE_QUIT_ARGS; + +typedef struct _BAENGINE_QUIT_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_QUIT_RESULTS; + +typedef struct _BAENGINE_SENDEMBEDDEDERROR_ARGS +{ + DWORD dwApiVersion; + DWORD dwErrorCode; + LPCWSTR wzMessage; + DWORD dwUIHint; +} BAENGINE_SENDEMBEDDEDERROR_ARGS; + +typedef struct _BAENGINE_SENDEMBEDDEDERROR_RESULTS +{ + DWORD dwApiVersion; + INT32 nResult; +} BAENGINE_SENDEMBEDDEDERROR_RESULTS; + +typedef struct _BAENGINE_SENDEMBEDDEDPROGRESS_ARGS +{ + DWORD dwApiVersion; + DWORD dwProgressPercentage; + DWORD dwOverallProgressPercentage; +} BAENGINE_SENDEMBEDDEDPROGRESS_ARGS; + +typedef struct _BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS +{ + DWORD dwApiVersion; + INT32 nResult; +} BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS; + +typedef struct _BAENGINE_SETDOWNLOADSOURCE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + LPCWSTR wzUrl; + LPCWSTR wzUser; + LPCWSTR wzPassword; + LPCWSTR wzAuthorizationHeader; +} BAENGINE_SETDOWNLOADSOURCE_ARGS; + +typedef struct _BAENGINE_SETDOWNLOADSOURCE_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETDOWNLOADSOURCE_RESULTS; + +typedef struct _BAENGINE_SETLOCALSOURCE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + LPCWSTR wzPath; +} BAENGINE_SETLOCALSOURCE_ARGS; + +typedef struct _BAENGINE_SETLOCALSOURCE_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETLOCALSOURCE_RESULTS; + +typedef struct _BAENGINE_SETUPDATE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzLocalSource; + LPCWSTR wzDownloadSource; + DWORD64 qwSize; + BOOTSTRAPPER_UPDATE_HASH_TYPE hashType; + LPCWSTR wzHash; + LPCWSTR wzUpdatePackageId; +} BAENGINE_SETUPDATE_ARGS; + +typedef struct _BAENGINE_SETUPDATE_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETUPDATE_RESULTS; + +typedef struct _BAENGINE_SETVARIABLENUMERIC_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVariable; + LONGLONG llValue; +} BAENGINE_SETVARIABLENUMERIC_ARGS; + +typedef struct _BAENGINE_SETVARIABLENUMERIC_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETVARIABLENUMERIC_RESULTS; + +typedef struct _BAENGINE_SETVARIABLESTRING_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVariable; + LPCWSTR wzValue; + BOOL fFormatted; +} BAENGINE_SETVARIABLESTRING_ARGS; + +typedef struct _BAENGINE_SETVARIABLESTRING_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETVARIABLESTRING_RESULTS; + +typedef struct _BAENGINE_SETVARIABLEVERSION_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzVariable; + LPCWSTR wzValue; +} BAENGINE_SETVARIABLEVERSION_ARGS; + +typedef struct _BAENGINE_SETVARIABLEVERSION_RESULTS +{ + DWORD dwApiVersion; +} BAENGINE_SETVARIABLEVERSION_RESULTS; + +typedef struct _BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + LPCWSTR wzVariable; +} BAENGINE_GETRELATEDBUNDLEVARIABLE_ARGS; + +typedef struct _BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS +{ + DWORD dwApiVersion; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + DWORD cchValue; +} BAENGINE_GETRELATEDBUNDLEVARIABLE_RESULTS; + +// extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_ENGINE_PROC)( +// __in BOOTSTRAPPER_ENGINE_MESSAGE message, +// __in const LPVOID pvArgs, +// __inout LPVOID pvResults, +// __in_opt LPVOID pvContext +// ); + +#if defined(__cplusplus) +} +#endif diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/batypes.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/batypes.h new file mode 100644 index 00000000..0116364c --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/batypes.h @@ -0,0 +1,1597 @@ +#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. + + +const LPCWSTR BOOTSTRAPPER_APPLICATION_COMMANDLINE_SWITCH_API_VERSION = L"burn.ba.apiver"; +const LPCWSTR BOOTSTRAPPER_APPLICATION_COMMANDLINE_SWITCH_PIPE_NAME = L"burn.ba.pipe"; +const DWORD WIX_5_BOOTSTRAPPER_APPLICATION_API_VERSION = 5; + +enum BOOTSTRAPPER_DISPLAY +{ + BOOTSTRAPPER_DISPLAY_UNKNOWN, + BOOTSTRAPPER_DISPLAY_EMBEDDED, + BOOTSTRAPPER_DISPLAY_NONE, + BOOTSTRAPPER_DISPLAY_PASSIVE, + BOOTSTRAPPER_DISPLAY_FULL, +}; + +enum BOOTSTRAPPER_REGISTRATION_TYPE +{ + BOOTSTRAPPER_REGISTRATION_TYPE_NONE, // The engine will ignore NONE if it recommended INPROGRESS or FULL. + BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS, + BOOTSTRAPPER_REGISTRATION_TYPE_FULL, +}; + +enum BOOTSTRAPPER_RESUME_TYPE +{ + BOOTSTRAPPER_RESUME_TYPE_NONE, + BOOTSTRAPPER_RESUME_TYPE_INVALID, // resume information is present but invalid + BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, // relaunched after an unexpected interruption + BOOTSTRAPPER_RESUME_TYPE_REBOOT, // relaunched after reboot + BOOTSTRAPPER_RESUME_TYPE_SUSPEND, // relaunched after suspend + BOOTSTRAPPER_RESUME_TYPE_ARP, // launched from ARP +}; + +enum BOOTSTRAPPER_ERROR_TYPE +{ + BOOTSTRAPPER_ERROR_TYPE_ELEVATE, // error occurred trying to elevate. + BOOTSTRAPPER_ERROR_TYPE_WINDOWS_INSTALLER, // error came from windows installer. + BOOTSTRAPPER_ERROR_TYPE_EXE_PACKAGE, // error came from an exe package. + BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER, // error occurred trying to authenticate with HTTP server. + BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY, // error occurred trying to authenticate with HTTP proxy. + BOOTSTRAPPER_ERROR_TYPE_APPLY, // error occurred during apply. +}; + +enum BOOTSTRAPPER_FILES_IN_USE_TYPE +{ + BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI, // INSTALLMESSAGE_FILESINUSE + BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI_RM, // INSTALLMESSAGE_RMFILESINUSE + BOOTSTRAPPER_FILES_IN_USE_TYPE_NETFX, // MMIO_CLOSE_APPS +}; + +enum BOOTSTRAPPER_RELATED_OPERATION +{ + BOOTSTRAPPER_RELATED_OPERATION_NONE, + BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE, + BOOTSTRAPPER_RELATED_OPERATION_MINOR_UPDATE, + BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE, + BOOTSTRAPPER_RELATED_OPERATION_REMOVE, + BOOTSTRAPPER_RELATED_OPERATION_INSTALL, + BOOTSTRAPPER_RELATED_OPERATION_REPAIR, +}; + +enum BOOTSTRAPPER_CACHE_OPERATION +{ + // There is no source available. + BOOTSTRAPPER_CACHE_OPERATION_NONE, + // Copy the payload or container from the chosen local source. + BOOTSTRAPPER_CACHE_OPERATION_COPY, + // Download the payload or container using the download URL. + BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD, + // Extract the payload from the container. + BOOTSTRAPPER_CACHE_OPERATION_EXTRACT, +}; + +enum BOOTSTRAPPER_CACHE_RESOLVE_OPERATION +{ + // There is no source available. + BOOTSTRAPPER_CACHE_RESOLVE_NONE, + // Copy the payload or container from the chosen local source. + BOOTSTRAPPER_CACHE_RESOLVE_LOCAL, + // Download the payload or container from the download URL. + BOOTSTRAPPER_CACHE_RESOLVE_DOWNLOAD, + // Extract the payload from the container. + BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER, + // Look again for the payload or container locally. + BOOTSTRAPPER_CACHE_RESOLVE_RETRY, +}; + +enum BOOTSTRAPPER_CACHE_VERIFY_STEP +{ + BOOTSTRAPPER_CACHE_VERIFY_STEP_STAGE, + BOOTSTRAPPER_CACHE_VERIFY_STEP_HASH, + BOOTSTRAPPER_CACHE_VERIFY_STEP_FINALIZE, +}; + +enum BOOTSTRAPPER_APPLY_RESTART +{ + BOOTSTRAPPER_APPLY_RESTART_NONE, + BOOTSTRAPPER_APPLY_RESTART_REQUIRED, + BOOTSTRAPPER_APPLY_RESTART_INITIATED, +}; + +enum BOOTSTRAPPER_RELATION_TYPE +{ + BOOTSTRAPPER_RELATION_NONE, + BOOTSTRAPPER_RELATION_DETECT, + BOOTSTRAPPER_RELATION_UPGRADE, + BOOTSTRAPPER_RELATION_ADDON, + BOOTSTRAPPER_RELATION_PATCH, + BOOTSTRAPPER_RELATION_DEPENDENT_ADDON, + BOOTSTRAPPER_RELATION_DEPENDENT_PATCH, + BOOTSTRAPPER_RELATION_UPDATE, + BOOTSTRAPPER_RELATION_CHAIN_PACKAGE, +}; + +enum BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE +{ + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_NONE, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DOWNGRADE, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_UPGRADE, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_ADDON, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_PATCH, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DEPENDENT_ADDON, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DEPENDENT_PATCH, +}; + +enum BOOTSTRAPPER_CACHE_TYPE +{ + BOOTSTRAPPER_CACHE_TYPE_REMOVE, + BOOTSTRAPPER_CACHE_TYPE_KEEP, + BOOTSTRAPPER_CACHE_TYPE_FORCE, +}; + +enum BOOTSTRAPPER_PACKAGE_CONDITION_RESULT +{ + BOOTSTRAPPER_PACKAGE_CONDITION_DEFAULT, + BOOTSTRAPPER_PACKAGE_CONDITION_FALSE, + BOOTSTRAPPER_PACKAGE_CONDITION_TRUE, +}; + +enum BOOTSTRAPPER_MSI_FILE_VERSIONING +{ + BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER, //o + BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER_OR_EQUAL, //e + BOOTSTRAPPER_MSI_FILE_VERSIONING_ALL, //a +}; + +enum BOOTSTRAPPER_APPLICATION_MESSAGE +{ + BOOTSTRAPPER_APPLICATION_MESSAGE_UNKNOWN = 65536, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, +}; + +enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION +{ + BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE, + // Instructs the engine to restart. + // The engine will not launch again after the machine is rebooted. + // Ignored if reboot was already initiated by OnExecutePackageComplete(). + BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART, +}; + +enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION +{ + BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_NONE, + // Instructs the engine to try the acquisition of the payload again. + // Ignored if hrStatus is a success. + BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY, +}; + +enum BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION +{ + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE, + // Instructs the engine to ignore non-vital package failures and + // continue with the caching. + // Ignored if hrStatus is a success or the package is vital. + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_IGNORE, + // Instructs the engine to try the acquisition and verification of the package again. + // Ignored if hrStatus is a success. + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_RETRY, +}; + +enum BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION +{ + BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION_NONE, + // Instructs the engine to try to acquire the package so execution can use it. + // Most of the time this is used for installing the package during rollback. + BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION_ACQUIRE, +}; + +enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION +{ + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_NONE, + // Ignored if hrStatus is a success. + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_RETRYVERIFICATION, + // Ignored if hrStatus is a success. + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_RETRYACQUISITION, +}; + +enum BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION +{ + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_NONE, + // Instructs the engine to ignore non-vital package failures and + // continue with the install. + // Ignored if hrStatus is a success or the package is vital. + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_IGNORE, + // Instructs the engine to try the execution of the package again. + // Ignored if hrStatus is a success. + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RETRY, + // Instructs the engine to stop processing the chain and restart. + // The engine will launch again after the machine is restarted. + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RESTART, + // Instructs the engine to stop processing the chain and + // suspend the current state. + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_SUSPEND, +}; + +enum BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION +{ + BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE, + // Instructs the engine to stop processing the chain and restart. + // The engine will launch again after the machine is restarted. + BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART, +}; + +enum BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION +{ + // Instructs the engine to stop waiting for the process to exit. + // The package is immediately considered to have failed with ERROR_INSTALL_USEREXIT. + // The engine will never rollback the package. + BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION_ABANDON, + // Instructs the engine to wait for the process to exit. + // Once the process has exited, the package is considered to have failed with ERROR_INSTALL_USEREXIT. + // This allows the engine to rollback the package if necessary. + BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION_WAIT, +}; + +enum BOOTSTRAPPER_SHUTDOWN_ACTION +{ + BOOTSTRAPPER_SHUTDOWN_ACTION_NONE, + // Instructs the engine to restart. + // The engine will not launch again after the machine is rebooted. + // Ignored if reboot was already initiated by OnExecutePackageComplete(). + BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART, + // Instructs the engine to unload the bootstrapper application and + // restart the engine which will load the bootstrapper application again. + // Typically used to switch from a native bootstrapper application to a managed one. + BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER, + // Opts out of the engine behavior of trying to uninstall itself + // when no non-permanent packages are installed. + BOOTSTRAPPER_SHUTDOWN_ACTION_SKIP_CLEANUP, +}; + +enum BURN_MSI_PROPERTY +{ + BURN_MSI_PROPERTY_NONE, // no property added + BURN_MSI_PROPERTY_INSTALL, // add BURNMSIINSTALL=1 + BURN_MSI_PROPERTY_MODIFY, // add BURNMSIMODIFY=1 + BURN_MSI_PROPERTY_REPAIR, // add BURNMSIREPAIR=1 + BURN_MSI_PROPERTY_UNINSTALL,// add BURNMSIUNINSTALL=1 +}; + +struct BOOTSTRAPPER_COMMAND +{ + DWORD cbSize; + BOOTSTRAPPER_ACTION action; + BOOTSTRAPPER_DISPLAY display; + + LPWSTR wzCommandLine; + INT32 nCmdShow; + + BOOTSTRAPPER_RESUME_TYPE resumeType; + HWND hwndSplashScreen; + + // If this was run from a related bundle, specifies the relation type + BOOTSTRAPPER_RELATION_TYPE relationType; + BOOL fPassthrough; + + LPWSTR wzLayoutDirectory; + LPWSTR wzBootstrapperWorkingFolder; + LPWSTR wzBootstrapperApplicationDataPath; +}; + +struct BA_ONAPPLYBEGIN_ARGS +{ + DWORD dwApiVersion; + DWORD dwPhaseCount; +}; + +struct BA_ONAPPLYBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONAPPLYCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; + // Indicates whether any package required a reboot or initiated the reboot already. + BOOTSTRAPPER_APPLY_RESTART restart; + BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation; +}; + +struct BA_ONAPPLYCOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_APPLYCOMPLETE_ACTION action; +}; + +struct BA_ONAPPLYDOWNGRADE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrRecommended; +}; + +struct BA_ONAPPLYDOWNGRADE_RESULTS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONBEGINMSITRANSACTIONBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzTransactionId; +}; + +struct BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzTransactionId; + HRESULT hrStatus; +}; + +struct BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONCACHEACQUIREBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + LPCWSTR wzSource; + LPCWSTR wzDownloadUrl; + LPCWSTR wzPayloadContainerId; + BOOTSTRAPPER_CACHE_OPERATION recommendation; +}; + +struct BA_ONCACHEACQUIREBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_CACHE_OPERATION action; +}; + +struct BA_ONCACHEACQUIRECOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + HRESULT hrStatus; + BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation; +}; + +struct BA_ONCACHEACQUIRECOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action; +}; + +struct BA_ONCACHEACQUIREPROGRESS_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + DWORD64 dw64Progress; + DWORD64 dw64Total; + DWORD dwOverallPercentage; +}; + +struct BA_ONCACHEACQUIREPROGRESS_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHEACQUIRERESOLVING_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + LPCWSTR* rgSearchPaths; + DWORD cSearchPaths; + BOOL fFoundLocal; + DWORD dwRecommendedSearchPath; + LPCWSTR wzDownloadUrl; + LPCWSTR wzPayloadContainerId; + BOOTSTRAPPER_CACHE_RESOLVE_OPERATION recommendation; +}; + +struct BA_ONCACHEACQUIRERESOLVING_RESULTS +{ + DWORD dwApiVersion; + DWORD dwChosenSearchPath; + BOOTSTRAPPER_CACHE_RESOLVE_OPERATION action; + BOOL fCancel; +}; + +struct BA_ONCACHEBEGIN_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONCACHEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHECOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONCACHECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; +}; + +struct BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + HRESULT hrStatus; +}; + +struct BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + DWORD64 dw64Progress; + DWORD64 dw64Total; + DWORD dwOverallPercentage; +}; + +struct BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHEPACKAGEBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + DWORD cCachePayloads; + DWORD64 dw64PackageCacheSize; + // If caching a package is not vital, then acquisition will be skipped unless the BA opts in through OnCachePackageNonVitalValidationFailure. + BOOL fVital; +}; + +struct BA_ONCACHEPACKAGEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHEPACKAGECOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + HRESULT hrStatus; + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation; +}; + +struct BA_ONCACHEPACKAGECOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action; +}; + +struct BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + HRESULT hrStatus; + BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION recommendation; +}; + +struct BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_CACHEPACKAGENONVITALVALIDATIONFAILURE_ACTION action; +}; + +struct BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzContainerId; + LPCWSTR wzPayloadId; +}; + +struct BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzContainerId; + LPCWSTR wzPayloadId; + HRESULT hrStatus; +}; + +struct BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzContainerId; + LPCWSTR wzPayloadId; + DWORD64 dw64Progress; + DWORD64 dw64Total; + DWORD dwOverallPercentage; +}; + +struct BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHEVERIFYBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; +}; + +struct BA_ONCACHEVERIFYBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCACHEVERIFYCOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + HRESULT hrStatus; + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation; +}; + +struct BA_ONCACHEVERIFYCOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action; +}; + +struct BA_ONCACHEVERIFYPROGRESS_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageOrContainerId; + LPCWSTR wzPayloadId; + DWORD64 dw64Progress; + DWORD64 dw64Total; + DWORD dwOverallPercentage; + BOOTSTRAPPER_CACHE_VERIFY_STEP verifyStep; +}; + +struct BA_ONCACHEVERIFYPROGRESS_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzTransactionId; +}; + +struct BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzTransactionId; + HRESULT hrStatus; + BOOTSTRAPPER_APPLY_RESTART restart; + BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation; +}; + +struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action; +}; + +struct BA_ONCREATE_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_COMMAND command; + // BOOTSTRAPPER_ACTION action; + // BOOTSTRAPPER_DISPLAY display; + + // LPWSTR wzCommandLine; + // INT32 nCmdShow; + + // BOOTSTRAPPER_RESUME_TYPE resumeType; + // HWND hwndSplashScreen; + + // BOOTSTRAPPER_RELATION_TYPE relationType; + // BOOL fPassthrough; + + // LPWSTR wzLayoutDirectory; + // LPWSTR wzBootstrapperWorkingFolder; + // LPWSTR wzBootstrapperApplicationDataPath; +}; + +struct BA_ONCREATE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONDESTROY_ARGS +{ + DWORD dwApiVersion; + BOOL fReload; +}; + +struct BA_ONDESTROY_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONDETECTBEGIN_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_REGISTRATION_TYPE registrationType; + DWORD cPackages; + BOOL fCached; +}; + +struct BA_ONDETECTBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzCompatiblePackageId; + LPCWSTR wzCompatiblePackageVersion; +}; + +struct BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; + BOOL fEligibleForCleanup; +}; + +struct BA_ONDETECTCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + BOOTSTRAPPER_RELATION_TYPE relationType; + LPCWSTR wzBundleTag; + BOOL fPerMachine; + LPCWSTR wzVersion; + BOOL fMissingFromCache; +}; + +struct BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTMSIFEATURE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzFeatureId; + BOOTSTRAPPER_FEATURE_STATE state; +}; + +struct BA_ONDETECTMSIFEATURE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTPACKAGEBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; +}; + +struct BA_ONDETECTPACKAGEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTPACKAGECOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + HRESULT hrStatus; + BOOTSTRAPPER_PACKAGE_STATE state; + BOOL fCached; +}; + +struct BA_ONDETECTPACKAGECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONDETECTRELATEDBUNDLE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + BOOTSTRAPPER_RELATION_TYPE relationType; + LPCWSTR wzBundleTag; + BOOL fPerMachine; + LPCWSTR wzVersion; + BOOL fMissingFromCache; +}; + +struct BA_ONDETECTRELATEDBUNDLE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzBundleId; + BOOTSTRAPPER_RELATION_TYPE relationType; + BOOL fPerMachine; + LPCWSTR wzVersion; +}; + +struct BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTRELATEDMSIPACKAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzUpgradeCode; + LPCWSTR wzProductCode; + BOOL fPerMachine; + LPCWSTR wzVersion; + BOOTSTRAPPER_RELATED_OPERATION operation; +}; + +struct BA_ONDETECTRELATEDMSIPACKAGE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTPATCHTARGET_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzProductCode; + BOOTSTRAPPER_PACKAGE_STATE patchState; +}; + +struct BA_ONDETECTPATCHTARGET_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONDETECTUPDATE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzUpdateLocation; + DWORD64 dw64Size; + LPCWSTR wzHash; + BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm; + LPCWSTR wzVersion; + LPCWSTR wzTitle; + LPCWSTR wzSummary; + LPCWSTR wzContentType; + LPCWSTR wzContent; +}; + +struct BA_ONDETECTUPDATE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOL fStopProcessingUpdates; +}; + +struct BA_ONDETECTUPDATEBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzUpdateLocation; +}; + +struct BA_ONDETECTUPDATEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOL fSkip; +}; + +struct BA_ONDETECTUPDATECOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONDETECTUPDATECOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOL fIgnoreError; +}; + +struct BA_ONELEVATEBEGIN_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONELEVATEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONELEVATECOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONELEVATECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONERROR_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_ERROR_TYPE errorType; + LPCWSTR wzPackageId; + DWORD dwCode; + LPCWSTR wzError; + DWORD dwUIHint; + DWORD cData; + LPCWSTR* rgwzData; + INT32 nRecommendation; +}; + +struct BA_ONERROR_RESULTS +{ + DWORD dwApiVersion; + INT32 nResult; +}; + +struct BA_ONEXECUTEBEGIN_ARGS +{ + DWORD dwApiVersion; + DWORD cExecutingPackages; +}; + +struct BA_ONEXECUTEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONEXECUTECOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONEXECUTECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONEXECUTEFILESINUSE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + DWORD cFiles; + LPCWSTR* rgwzFiles; + INT32 nRecommendation; + BOOTSTRAPPER_FILES_IN_USE_TYPE source; +}; + +struct BA_ONEXECUTEFILESINUSE_RESULTS +{ + DWORD dwApiVersion; + INT32 nResult; +}; + +struct BA_ONEXECUTEMSIMESSAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + INSTALLMESSAGE messageType; + DWORD dwUIHint; + LPCWSTR wzMessage; + DWORD cData; + LPCWSTR* rgwzData; + INT32 nRecommendation; +}; + +struct BA_ONEXECUTEMSIMESSAGE_RESULTS +{ + DWORD dwApiVersion; + INT32 nResult; +}; + +struct BA_ONEXECUTEPACKAGEBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + BOOL fExecute; // false means rollback. + BOOTSTRAPPER_ACTION_STATE action; + INSTALLUILEVEL uiLevel; + BOOL fDisableExternalUiHandler; +}; + +struct BA_ONEXECUTEPACKAGEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONEXECUTEPACKAGECOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + HRESULT hrStatus; + // Indicates whether this package requires a reboot or initiated the reboot already. + BOOTSTRAPPER_APPLY_RESTART restart; + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation; +}; + +struct BA_ONEXECUTEPACKAGECOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION action; +}; + +struct BA_ONEXECUTEPATCHTARGET_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzTargetProductCode; +}; + +struct BA_ONEXECUTEPATCHTARGET_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONEXECUTEPROCESSCANCEL_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + DWORD dwProcessId; + BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION recommendation; +}; + +struct BA_ONEXECUTEPROCESSCANCEL_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION action; +}; + +struct BA_ONEXECUTEPROGRESS_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + DWORD dwProgressPercentage; + DWORD dwOverallPercentage; +}; + +struct BA_ONEXECUTEPROGRESS_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; + // Only valid if the operation succeeded. + DWORD dwProcessId; +}; + +struct BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPLANBEGIN_ARGS +{ + DWORD dwApiVersion; + DWORD cPackages; +}; + +struct BA_ONPLANBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzCompatiblePackageId; + LPCWSTR wzCompatiblePackageVersion; + BOOL fRecommendedRemove; +}; + +struct BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOL fRequestRemove; +}; + +struct BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzCompatiblePackageId; + HRESULT hrStatus; + BOOL fRequestedRemove; +}; + +struct BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPLANCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONPLANCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + BOOTSTRAPPER_RELATION_TYPE relationType; + LPCWSTR wzBundleTag; + BOOL fPerMachine; + LPCWSTR wzVersion; + BOOL fRecommendedIgnoreBundle; +}; + +struct BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOL fIgnoreBundle; +}; + +struct BA_ONPLANMSIFEATURE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzFeatureId; + BOOTSTRAPPER_FEATURE_STATE recommendedState; +}; + +struct BA_ONPLANMSIFEATURE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_FEATURE_STATE requestedState; + BOOL fCancel; +}; + +struct BA_ONPLANMSIPACKAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + BOOL fExecute; // false means rollback. + BOOTSTRAPPER_ACTION_STATE action; + BOOTSTRAPPER_MSI_FILE_VERSIONING recommendedFileVersioning; +}; + +struct BA_ONPLANMSIPACKAGE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BURN_MSI_PROPERTY actionMsiProperty; + INSTALLUILEVEL uiLevel; + BOOL fDisableExternalUiHandler; + BOOTSTRAPPER_MSI_FILE_VERSIONING fileVersioning; +}; + +struct BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzCompatiblePackageId; + BOOL fRemove; +}; + +struct BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPLANNEDPACKAGE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + BOOTSTRAPPER_ACTION_STATE execute; + BOOTSTRAPPER_ACTION_STATE rollback; + BOOL fPlannedCache; + BOOL fPlannedUncache; +}; + +struct BA_ONPLANNEDPACKAGE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPLANPACKAGEBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + BOOTSTRAPPER_PACKAGE_STATE state; + BOOL fCached; + BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition; + BOOTSTRAPPER_REQUEST_STATE recommendedState; + BOOTSTRAPPER_CACHE_TYPE recommendedCacheType; + BOOTSTRAPPER_PACKAGE_CONDITION_RESULT repairCondition; +}; + +struct BA_ONPLANPACKAGEBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_REQUEST_STATE requestedState; + BOOTSTRAPPER_CACHE_TYPE requestedCacheType; +}; + +struct BA_ONPLANPACKAGECOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + HRESULT hrStatus; + BOOTSTRAPPER_REQUEST_STATE requested; +}; + +struct BA_ONPLANPACKAGECOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONPLANRELATEDBUNDLE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + BOOTSTRAPPER_REQUEST_STATE recommendedState; +}; + +struct BA_ONPLANRELATEDBUNDLE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_REQUEST_STATE requestedState; +}; + +struct BA_ONPLANRELATEDBUNDLETYPE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE recommendedType; +}; + +struct BA_ONPLANRELATEDBUNDLETYPE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE requestedType; +}; + +struct BA_ONPLANRESTORERELATEDBUNDLE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzBundleId; + BOOTSTRAPPER_REQUEST_STATE recommendedState; +}; + +struct BA_ONPLANRESTORERELATEDBUNDLE_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_REQUEST_STATE requestedState; +}; + +struct BA_ONPLANROLLBACKBOUNDARY_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzRollbackBoundaryId; + BOOL fRecommendedTransaction; +}; + +struct BA_ONPLANROLLBACKBOUNDARY_RESULTS +{ + DWORD dwApiVersion; + BOOL fTransaction; + BOOL fCancel; +}; + +struct BA_ONPLANPATCHTARGET_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzPackageId; + LPCWSTR wzProductCode; + BOOTSTRAPPER_REQUEST_STATE recommendedState; +}; + +struct BA_ONPLANPATCHTARGET_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_REQUEST_STATE requestedState; +}; + +struct BA_ONPROGRESS_ARGS +{ + DWORD dwApiVersion; + DWORD dwProgressPercentage; + DWORD dwOverallPercentage; +}; + +struct BA_ONPROGRESS_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; +}; + +struct BA_ONREGISTERBEGIN_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_REGISTRATION_TYPE recommendedRegistrationType; +}; + +struct BA_ONREGISTERBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOL fCancel; + BOOTSTRAPPER_REGISTRATION_TYPE registrationType; +}; + +struct BA_ONREGISTERCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONREGISTERCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzTransactionId; +}; + +struct BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS +{ + DWORD dwApiVersion; + LPCWSTR wzTransactionId; + HRESULT hrStatus; + BOOTSTRAPPER_APPLY_RESTART restart; + BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION recommendation; +}; + +struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action; +}; + +struct BA_ONSHUTDOWN_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONSHUTDOWN_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_SHUTDOWN_ACTION action; +}; + +struct BA_ONSTARTUP_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONSTARTUP_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS +{ + DWORD dwApiVersion; +}; + +struct BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +struct BA_ONUNREGISTERBEGIN_ARGS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_REGISTRATION_TYPE recommendedRegistrationType; +}; + +struct BA_ONUNREGISTERBEGIN_RESULTS +{ + DWORD dwApiVersion; + BOOTSTRAPPER_REGISTRATION_TYPE registrationType; +}; + +struct BA_ONUNREGISTERCOMPLETE_ARGS +{ + DWORD dwApiVersion; + HRESULT hrStatus; +}; + +struct BA_ONUNREGISTERCOMPLETE_RESULTS +{ + DWORD dwApiVersion; +}; + +#ifdef TODO_DELETE + +extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_APPLICATION_PROC)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + +struct BOOTSTRAPPER_DESTROY_ARGS +{ + DWORD dwApiVersion; + BOOL fReload; +}; + +struct BOOTSTRAPPER_DESTROY_RESULTS +{ + DWORD dwApiVersion; + BOOL fDisableUnloading; // indicates the BA dll must not be unloaded after BootstrapperApplicationDestroy. +}; + +extern "C" typedef void (WINAPI *PFN_BOOTSTRAPPER_APPLICATION_DESTROY)( + __in const BOOTSTRAPPER_DESTROY_ARGS* pArgs, + __inout BOOTSTRAPPER_DESTROY_RESULTS* pResults + ); + + + +struct BOOTSTRAPPER_CREATE_ARGS +{ + DWORD dwApiVersion; + DWORD64 qwEngineAPIVersion; + PFN_BOOTSTRAPPER_ENGINE_PROC pfnBootstrapperEngineProc; + LPVOID pvBootstrapperEngineProcContext; + BOOTSTRAPPER_COMMAND* pCommand; +}; + +struct BOOTSTRAPPER_CREATE_RESULTS +{ + DWORD dwApiVersion; + PFN_BOOTSTRAPPER_APPLICATION_PROC pfnBootstrapperApplicationProc; + LPVOID pvBootstrapperApplicationProcContext; +}; + +extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_APPLICATION_CREATE)( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ); + +#endif diff --git a/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index 339bfd8f..25995e27 100644 --- a/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -6,58 +6,48 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; /// - /// Default implementation of . + /// This is no longer used. /// + [Obsolete("Bootstrapper applications now run out of proc and do not use a BootstrapperApplicationFactory. Remove your BootstrapperApplicationFactory class. See https://wixtoolset.org/docs/fiveforfour/ for more details.")] public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory { /// - /// Default implementation of + /// This is no longer used. /// - /// The args struct given by the engine when initially creating the BA. - /// The results struct given by the engine when initially creating the BA + /// This is no longer used. + /// This is no longer used. public void Create(IntPtr pArgs, IntPtr pResults) { - InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); - - var ba = this.Create(engine, bootstrapperCommand); - StoreBAInCreateResults(pResults, ba); + throw new NotImplementedException(); } /// - /// Called by to get the . + /// This is no longer used. /// - /// The bundle engine. - /// Command information passed from the engine for the BA to perform. - /// The for the bundle. + /// This is no longer used. + /// This is no longer used. + /// This is no longer used. protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); /// - /// Initializes the native part of . - /// Most users should inherit from instead of calling this method. + /// This is no longer used. /// - /// The args struct given by the engine when initially creating the BA. - /// The bundle engine interface. - /// The context of the current run of the bundle. + /// This is no longer used. + /// This is no longer used. + /// This is no longer used. public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) { - Command pCommand = new Command - { - cbSize = Marshal.SizeOf(typeof(Command)) - }; - var pEngine = MbaNative.InitializeFromCreateArgs(pArgs, ref pCommand); - engine = new Engine(pEngine); - bootstrapperCommand = pCommand.GetBootstrapperCommand(); + throw new NotImplementedException(); } /// - /// Registers the BA with the engine using the default mapping between the message based interface and the COM interface. - /// Most users should inherit from instead of calling this method. + /// This is no longer used. /// - /// The results struct given by the engine when initially creating the BA - /// The . + /// This is no longer used. + /// This is no longer used. public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) { - MbaNative.StoreBAInCreateResults(pResults, ba); + throw new NotImplementedException(); } } } diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index a0ec6ab9..98b34217 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -12,24 +12,16 @@ namespace WixToolset.Mba.Core [ClassInterface(ClassInterfaceType.None)] public abstract class BootstrapperApplication : MarshalByRefObject, IDefaultBootstrapperApplication { - /// - /// Specifies whether this bootstrapper should run asynchronously. The default is true. - /// - protected readonly bool asyncExecution; - /// /// Gets the for interaction with the engine. /// - protected readonly IEngine engine; + protected IEngine engine; - /// - /// Creates a new instance of the class. - /// - protected BootstrapperApplication(IEngine engine) - { - this.engine = engine; - this.asyncExecution = true; - } + /// + public event EventHandler Create; + + /// + public event EventHandler Destroy; /// public event EventHandler Startup; @@ -265,12 +257,6 @@ namespace WixToolset.Mba.Core /// public event EventHandler CachePayloadExtractComplete; - /// - public event EventHandler SetUpdateBegin; - - /// - public event EventHandler SetUpdateComplete; - /// public event EventHandler PlanRestoreRelatedBundle; @@ -283,36 +269,74 @@ namespace WixToolset.Mba.Core /// public event EventHandler CachePackageNonVitalValidationFailure; + /// + /// The default constructor. + /// + /// + /// The engine object will be valid after handling the OnCreate() event. + /// + protected BootstrapperApplication() + { + } + + /// + /// This constructor is no longer used. + /// + [Obsolete("This constructor is no longer used. Use the default constructor. The engine object will be valid after handling the OnCreate() event.")] + protected BootstrapperApplication(IEngine engine) + { + throw new NotImplementedException("This constructor is no longer used. Use the default constructor. The engine object will be valid after handling the OnCreate() event."); + } + /// /// Entry point that is called when the bootstrapper application is ready to run. /// protected abstract void Run(); /// - /// Called by the engine, raises the event. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - protected virtual void OnStartup(StartupEventArgs args) + protected virtual void OnCreate(CreateEventArgs args) { - EventHandler handler = this.Startup; + this.engine = args.Engine; + + EventHandler handler = this.Create; if (null != handler) { handler(this, args); } + } - if (this.asyncExecution) + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDestroy(DestroyEventArgs args) + { + EventHandler handler = this.Destroy; + if (null != handler) { - this.engine.Log(LogLevel.Verbose, "Creating BA thread to run asynchronously."); - Thread uiThread = new Thread(this.Run); - uiThread.Name = "UIThread"; - uiThread.SetApartmentState(ApartmentState.STA); - uiThread.Start(); + handler(this, args); } - else + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnStartup(StartupEventArgs args) + { + EventHandler handler = this.Startup; + if (null != handler) { - this.engine.Log(LogLevel.Verbose, "Creating BA thread to run synchronously."); - this.Run(); + handler(this, args); } + + Thread uiThread = new Thread(this.Run); + uiThread.Name = "UIThread"; + uiThread.SetApartmentState(ApartmentState.STA); + uiThread.Start(); } /// @@ -1315,31 +1339,6 @@ namespace WixToolset.Mba.Core } } - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSetUpdateBegin(SetUpdateBeginEventArgs args) - { - EventHandler handler = this.SetUpdateBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSetUpdateComplete(SetUpdateCompleteEventArgs args) - { - EventHandler handler = this.SetUpdateComplete; - if (null != handler) - { - handler(this, args); - } - } /// /// Called by the engine, raises the event. @@ -1395,7 +1394,7 @@ namespace WixToolset.Mba.Core #region IBootstrapperApplication Members - int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults) { switch (message) { @@ -1404,8 +1403,24 @@ namespace WixToolset.Mba.Core } } - void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr) + { + } + + int IBootstrapperApplication.OnCreate(IBootstrapperEngine engine, ref Command command) { + CreateEventArgs args = new CreateEventArgs(new Engine(engine), command.GetBootstrapperCommand()); + this.OnCreate(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnDestroy(bool reload) + { + DestroyEventArgs args = new DestroyEventArgs(reload); + this.OnDestroy(args); + + return args.HResult; } int IBootstrapperApplication.OnStartup() @@ -2107,22 +2122,6 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnSetUpdateBegin() - { - SetUpdateBeginEventArgs args = new SetUpdateBeginEventArgs(); - this.OnSetUpdateBegin(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnSetUpdateComplete(int hrStatus, string wzPreviousPackageId, string wzNewPackageId) - { - SetUpdateCompleteEventArgs args = new SetUpdateCompleteEventArgs(hrStatus, wzPreviousPackageId, wzNewPackageId); - this.OnSetUpdateComplete(args); - - return args.HResult; - } - int IBootstrapperApplication.OnPlanRestoreRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { PlanRestoreRelatedBundleEventArgs args = new PlanRestoreRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel); diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs index 95252cf3..6b465408 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs @@ -5,31 +5,27 @@ namespace WixToolset.Mba.Core using System; /// - /// Identifies the bootstrapper application factory class. + /// This is no longer used. /// - /// - /// This required assembly attribute identifies the bootstrapper application factory class. - /// + [Obsolete("Bootstrapper applications now run out of proc and do not use a BootstrapperApplicationFactory. Remove your BootstrapperApplicationFactory class. See https://wixtoolset.org/docs/fiveforfour/ for more details.")] [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class BootstrapperApplicationFactoryAttribute : Attribute { - private Type bootstrapperApplicationFactoryType; - /// - /// Creates a new instance of the class. + /// This is no longer used. /// - /// The of the BA factory. + /// This is no longer used public BootstrapperApplicationFactoryAttribute(Type bootstrapperApplicationFactoryType) { - this.bootstrapperApplicationFactoryType = bootstrapperApplicationFactoryType; + throw new NotImplementedException(); } /// - /// Gets the type of the bootstrapper application factory class to create. + /// This is no longer used. /// public Type BootstrapperApplicationFactoryType { - get { return this.bootstrapperApplicationFactoryType; } + get { throw new NotImplementedException(); } } } } diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs index ed1dc191..b96a8f95 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -3,10 +3,54 @@ namespace WixToolset.Mba.Core { using System; + using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.InteropServices; + /// + /// Command-line provided to the bootstrapper application. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public struct Command + { + // Strings must be declared as pointers so that Marshaling doesn't free them. + [MarshalAs(UnmanagedType.I4)] internal int cbSize; + [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; + [MarshalAs(UnmanagedType.U4)] private readonly Display display; + private readonly IntPtr wzCommandLine; + [MarshalAs(UnmanagedType.I4)] private readonly int nCmdShow; + [MarshalAs(UnmanagedType.U4)] private readonly ResumeType resume; + private readonly IntPtr hwndSplashScreen; + [MarshalAs(UnmanagedType.I4)] private readonly RelationType relation; + [MarshalAs(UnmanagedType.Bool)] private readonly bool passthrough; + private readonly IntPtr wzLayoutDirectory; + private readonly IntPtr wzBootstrapperWorkingFolder; + private readonly IntPtr wzBootstrapperApplicationDataPath; + + /// + /// Gets the IBootstrapperCommand for this Command. + /// + /// IBootstrapperCommand + public IBootstrapperCommand GetBootstrapperCommand() + { + return new BootstrapperCommand( + this.action, + this.display, + Marshal.PtrToStringUni(this.wzCommandLine), + this.nCmdShow, + this.resume, + this.hwndSplashScreen, + this.relation, + this.passthrough, + Marshal.PtrToStringUni(this.wzLayoutDirectory), + Marshal.PtrToStringUni(this.wzBootstrapperWorkingFolder), + Marshal.PtrToStringUni(this.wzBootstrapperApplicationDataPath)); + } + } + /// /// Default implementation of . /// diff --git a/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs b/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs index ee751ebf..0039f375 100644 --- a/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs +++ b/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs @@ -34,17 +34,17 @@ namespace WixToolset.Mba.Core } /// - public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) + public IPackageInfo AddRelatedBundleAsPackage(string productCode, RelationType relationType, bool perMachine, string version) { - var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); + var package = PackageInfo.GetRelatedBundleAsPackage(productCode, relationType, perMachine, version); this.Packages.Add(package.Id, package); return package; } /// - public IPackageInfo AddUpdateBundleAsPackage(SetUpdateCompleteEventArgs e) + public IPackageInfo AddUpdateBundleAsPackage(string packageId) { - var package = PackageInfo.GetUpdateBundleAsPackage(e.NewPackageId); + var package = PackageInfo.GetUpdateBundleAsPackage(packageId); this.Packages.Add(package.Id, package); return package; } diff --git a/src/api/burn/WixToolset.Mba.Core/Engine.cs b/src/api/burn/WixToolset.Mba.Core/Engine.cs index 1120fb1c..df412e8c 100644 --- a/src/api/burn/WixToolset.Mba.Core/Engine.cs +++ b/src/api/burn/WixToolset.Mba.Core/Engine.cs @@ -253,9 +253,9 @@ namespace WixToolset.Mba.Core } /// - public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash) + public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash, string updatePackageId) { - this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash); + this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, updatePackageId); } /// diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index 4b7f2245..6506c840 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -197,6 +197,54 @@ namespace WixToolset.Mba.Core public int OverallPercentage { get; private set; } } + /// + /// Event arguments for . + /// + [Serializable] + public class CreateEventArgs : HResultEventArgs + { + /// + /// This class is for events raised by the engine. + /// It is not intended to be instantiated by user code. + /// + public CreateEventArgs(IEngine engine, IBootstrapperCommand command) + { + this.Engine = engine; + this.Command = command; + } + + /// + /// Engine running the application. + /// + public IEngine Engine { get; } + + /// + /// Command line arguments. + /// + public IBootstrapperCommand Command { get; } + } + + /// + /// Event arguments for . + /// + [Serializable] + public class DestroyEventArgs : HResultEventArgs + { + /// + /// This class is for events raised by the engine. + /// It is not intended to be instantiated by user code. + /// + public DestroyEventArgs(bool reload) + { + this.Reload = reload; + } + + /// + /// Bootstrapper application is being reloaded. + /// + public bool Reload { get; } + } + /// /// Event arguments for . /// @@ -2566,49 +2614,6 @@ namespace WixToolset.Mba.Core public string PayloadId { get; private set; } } - /// - /// EventArgs for . - /// - [Serializable] - public class SetUpdateBeginEventArgs : HResultEventArgs - { - /// - /// This class is for events raised by the engine. - /// It is not intended to be instantiated by user code. - /// - public SetUpdateBeginEventArgs() - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class SetUpdateCompleteEventArgs : StatusEventArgs - { - /// - /// This class is for events raised by the engine. - /// It is not intended to be instantiated by user code. - /// - public SetUpdateCompleteEventArgs(int hrStatus, string previousPackageId, string newPackageId) - : base(hrStatus) - { - this.PreviousPackageId = previousPackageId; - this.NewPackageId = newPackageId; - } - - /// - /// Gets the identifier of the update package that was removed. - /// - public string PreviousPackageId { get; private set; } - - /// - /// Gets the identifier of the update package that was added. - /// - public string NewPackageId { get; private set; } - } - /// /// Event arguments for /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs index 36c7fd33..8a255c44 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -21,8 +21,7 @@ namespace WixToolset.Mba.Core int BAProc( int message, IntPtr pvArgs, - IntPtr pvResults, - IntPtr pvContext + IntPtr pvResults ); /// @@ -32,10 +31,23 @@ namespace WixToolset.Mba.Core int message, IntPtr pvArgs, IntPtr pvResults, - ref int phr, - IntPtr pvContext + ref int phr ); + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCreate(IBootstrapperEngine engine, ref Command command); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDestroy(bool reload); + /// /// See . /// @@ -939,24 +951,6 @@ namespace WixToolset.Mba.Core int hrStatus ); - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSetUpdateBegin(); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSetUpdateComplete( - int hrStatus, - [MarshalAs(UnmanagedType.LPWStr)] string wzPreviousPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzNewPackageId - ); - /// /// See . /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index 2e84de67..393c7e31 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -7,58 +7,16 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; /// - /// Interface used by the native host to dynamically load the BA. + /// This is no longer used. /// - [ComVisible(true)] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("2965A12F-AC7B-43A0-85DF-E4B2168478A4")] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + [Obsolete("Bootstrapper applications now run out of proc and do not use a BootstrapperApplicationFactory. Remove your BootstrapperApplicationFactory class. See https://wixtoolset.org/docs/fiveforfour/ for more details.")] public interface IBootstrapperApplicationFactory { /// - /// Low level method called by the native host. + /// This is no longer used. /// - /// - /// - void Create( - IntPtr pArgs, - IntPtr pResults - ); - } - - [Serializable] - [StructLayout(LayoutKind.Sequential)] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] - internal struct Command - { - // Strings must be declared as pointers so that Marshaling doesn't free them. - [MarshalAs(UnmanagedType.I4)] internal int cbSize; - [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; - [MarshalAs(UnmanagedType.U4)] private readonly Display display; - private readonly IntPtr wzCommandLine; - [MarshalAs(UnmanagedType.I4)] private readonly int nCmdShow; - [MarshalAs(UnmanagedType.U4)] private readonly ResumeType resume; - private readonly IntPtr hwndSplashScreen; - [MarshalAs(UnmanagedType.I4)] private readonly RelationType relation; - [MarshalAs(UnmanagedType.Bool)] private readonly bool passthrough; - private readonly IntPtr wzLayoutDirectory; - private readonly IntPtr wzBootstrapperWorkingFolder; - private readonly IntPtr wzBootstrapperApplicationDataPath; - - public IBootstrapperCommand GetBootstrapperCommand() - { - return new BootstrapperCommand( - this.action, - this.display, - Marshal.PtrToStringUni(this.wzCommandLine), - this.nCmdShow, - this.resume, - this.hwndSplashScreen, - this.relation, - this.passthrough, - Marshal.PtrToStringUni(this.wzLayoutDirectory), - Marshal.PtrToStringUni(this.wzBootstrapperWorkingFolder), - Marshal.PtrToStringUni(this.wzBootstrapperApplicationDataPath)); - } + /// This is no longer used. + /// This is no longer used. + void Create(IntPtr pArgs, IntPtr pResults); } } diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs index 3f90639f..a175bead 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -108,14 +108,15 @@ namespace WixToolset.Mba.Core ); /// - /// See . + /// See . /// void SetUpdate( [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, [MarshalAs(UnmanagedType.U8)] long qwValue, [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, - [MarshalAs(UnmanagedType.LPWStr)] string wzHash + [MarshalAs(UnmanagedType.LPWStr)] string wzHash, + [MarshalAs(UnmanagedType.LPWStr)] string wzUpdatePackageId ); /// @@ -330,12 +331,12 @@ namespace WixToolset.Mba.Core Repair, /// - /// Launch the update registered with and then exit without waiting for it to complete. + /// Launch the update registered with and then exit without waiting for it to complete. /// UpdateReplace, /// - /// Launch the update registered with as an embedded bundle. + /// Launch the update registered with as an embedded bundle. /// UpdateReplaceEmbedded, } diff --git a/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs b/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs index 951f511a..3c52fc02 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs @@ -37,15 +37,18 @@ namespace WixToolset.Mba.Core /// /// Adds a related bundle as a package. /// - /// + /// + /// + /// + /// /// The created . - IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); + IPackageInfo AddRelatedBundleAsPackage(string productCode, RelationType relationType, bool perMachine, string version); /// /// Adds an update bundle as a package. /// - /// + /// Package id added as update bundle. /// The created . - IPackageInfo AddUpdateBundleAsPackage(SetUpdateCompleteEventArgs e); + IPackageInfo AddUpdateBundleAsPackage(string packageId); } } diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 2fa88bdb..51ea4e4d 100644 --- a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -138,6 +138,16 @@ namespace WixToolset.Mba.Core /// event EventHandler CommitMsiTransactionComplete; + /// + /// Fired when the application is being created. + /// + event EventHandler Create; + + /// + /// Fired when the application is being destroyed. + /// + event EventHandler Destroy; + /// /// Fired when the overall detection phase has begun. /// @@ -393,16 +403,6 @@ namespace WixToolset.Mba.Core /// event EventHandler RollbackMsiTransactionComplete; - /// - /// Fired when the engine has begun to setup the update package. - /// - event EventHandler SetUpdateBegin; - - /// - /// Fired when the engine has completed setting up the update package. - /// - event EventHandler SetUpdateComplete; - /// /// Fired when the engine is shutting down the bootstrapper application. /// diff --git a/src/api/burn/WixToolset.Mba.Core/IEngine.cs b/src/api/burn/WixToolset.Mba.Core/IEngine.cs index 7ffa80d7..dde97a70 100644 --- a/src/api/burn/WixToolset.Mba.Core/IEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IEngine.cs @@ -149,7 +149,8 @@ namespace WixToolset.Mba.Core /// Size of the expected update. /// Type of the hash expected on the update. /// Optional hash expected for the update. - void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash); + /// Optional package id for the update. + void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash, string updatePackageId); /// /// Sets the URL to the update feed. diff --git a/src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs new file mode 100644 index 00000000..74bfbd73 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/ManagedBootstrapperApplication.cs @@ -0,0 +1,19 @@ +// 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. + +namespace WixToolset.Mba.Core +{ + /// + /// Managed bootstrapper application entry point. + /// + public static class ManagedBootstrapperApplication + { + /// + /// Run the managed bootstrapper application. + /// + /// Bootstrapper applciation to run. + public static void Run(IBootstrapperApplication application) + { + MbaNative.BootstrapperApplicationRun(application); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/MbaNative.cs b/src/api/burn/WixToolset.Mba.Core/MbaNative.cs index a68a3907..e8e9d576 100644 --- a/src/api/burn/WixToolset.Mba.Core/MbaNative.cs +++ b/src/api/burn/WixToolset.Mba.Core/MbaNative.cs @@ -8,14 +8,10 @@ namespace WixToolset.Mba.Core internal static class MbaNative { [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern IBootstrapperEngine InitializeFromCreateArgs( - IntPtr pArgs, - ref Command pCommand - ); + internal static extern void BootstrapperApplicationDebuggerCheck(); - [DllImport("mbanative.dll", ExactSpelling = true)] - internal static extern void StoreBAInCreateResults( - IntPtr pResults, + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern void BootstrapperApplicationRun( [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA ); } diff --git a/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs b/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs index c6373647..b91c52c9 100644 --- a/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs @@ -365,19 +365,19 @@ namespace WixToolset.Mba.Core package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); } - nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", namespaceManager); + nodes = root.Select("/p:BootstrapperApplicationData/p:WixPrereqInformation", namespaceManager); foreach (XPathNavigator node in nodes) { string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); if (id == null) { - throw new Exception("Failed to get package identifier for WixMbaPrereqInformation."); + throw new Exception("Failed to get package identifier for WixPrereqInformation."); } if (!packagesById.TryGetValue(id, out var ipackage)) { - throw new Exception(String.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); + throw new Exception(String.Format("Failed to find package specified in WixPrereqInformation: {0}", id)); } var package = (PackageInfo)ipackage; 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" diff --git a/src/api/burn/mbanative/mbanative.cpp b/src/api/burn/mbanative/mbanative.cpp deleted file mode 100644 index 98ea3c30..00000000 --- a/src/api/burn/mbanative/mbanative.cpp +++ /dev/null @@ -1,29 +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. - -#include "precomp.h" -#include "BalBaseBootstrapperApplicationProc.h" - -extern "C" HRESULT WINAPI InitializeFromCreateArgs( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __inout BOOTSTRAPPER_COMMAND* pCommand, - __out IBootstrapperEngine** ppEngine - ) -{ - HRESULT hr = S_OK; - - hr = BalInitializeFromCreateArgs(pArgs, ppEngine); - ExitOnFailure(hr, "Failed to initialize Bal."); - - memcpy_s(pCommand, pCommand->cbSize, pArgs->pCommand, min(pArgs->pCommand->cbSize, pCommand->cbSize)); -LExit: - return hr; -} - -extern "C" void WINAPI StoreBAInCreateResults( - __inout BOOTSTRAPPER_CREATE_RESULTS* pResults, - __in IBootstrapperApplication* pBA - ) -{ - pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; - pResults->pvBootstrapperApplicationProcContext = pBA; -} diff --git a/src/api/burn/mbanative/mbanative.def b/src/api/burn/mbanative/mbanative.def index b7a858df..bd013699 100644 --- a/src/api/burn/mbanative/mbanative.def +++ b/src/api/burn/mbanative/mbanative.def @@ -8,8 +8,8 @@ EXPORTS BalGetVersionVariableFromEngine BalGetRelatedBundleVariableFromEngine BalVariableExistsFromEngine - InitializeFromCreateArgs - StoreBAInCreateResults + BootstrapperApplicationDebuggerCheck + BootstrapperApplicationRun StrFree VerCompareParsedVersions VerCompareStringVersions diff --git a/src/api/burn/mbanative/mbanative.vcxproj b/src/api/burn/mbanative/mbanative.vcxproj index 47d09591..a1f79f4d 100644 --- a/src/api/burn/mbanative/mbanative.vcxproj +++ b/src/api/burn/mbanative/mbanative.vcxproj @@ -46,7 +46,6 @@ - Create diff --git a/src/api/burn/mbanative/precomp.h b/src/api/burn/mbanative/precomp.h index 2e2f3ff8..622f341a 100644 --- a/src/api/burn/mbanative/precomp.h +++ b/src/api/burn/mbanative/precomp.h @@ -8,8 +8,8 @@ #include #include -#include -#include +// #include +// #include #include #include diff --git a/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp b/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp index 2ae539ee..ba04c1bb 100644 --- a/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp +++ b/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp @@ -12,32 +12,30 @@ namespace BalUtilTests public ref class BAFunctions { public: - [Fact] + [Fact(Skip = "Need a mock implementation of IBootstrapperEngine to test BAFunctions.")] void CanCreateTestBAFunctions() { HRESULT hr = S_OK; - BOOTSTRAPPER_CREATE_ARGS bootstrapperArgs = { }; - BOOTSTRAPPER_COMMAND bootstrapperCommand = { }; BA_FUNCTIONS_CREATE_ARGS args = { }; BA_FUNCTIONS_CREATE_RESULTS results = { }; IBootstrapperEngine* pEngine = NULL; + BOOTSTRAPPER_COMMAND command = { }; IBAFunctions* pBAFunctions = NULL; - bootstrapperArgs.cbSize = sizeof(bootstrapperArgs); - bootstrapperArgs.pCommand = &bootstrapperCommand; - args.cbSize = sizeof(args); - args.pBootstrapperCreateArgs = &bootstrapperArgs; + args.pEngine = pEngine; + args.pCommand = &command; results.cbSize = sizeof(results); try { - hr = BalInitializeFromCreateArgs(&bootstrapperArgs, &pEngine); - NativeAssert::Succeeded(hr, "Failed to create engine."); + BalInitialize(pEngine); - hr = CreateBAFunctions(NULL, pEngine, &args, &results, &pBAFunctions); + hr = CreateBAFunctions(NULL, &args, &results); NativeAssert::Succeeded(hr, "Failed to create BAFunctions."); + + pBAFunctions = reinterpret_cast(results.pvBAFunctionsProcContext); } finally { diff --git a/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp b/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp index 70b01a42..9a68c738 100644 --- a/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp +++ b/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp @@ -12,28 +12,21 @@ namespace BalUtilTests public ref class BootstrapperApplication { public: - [Fact] + [Fact(Skip = "Need a mock implementation of IBootstrapperEngine to test BootstrapperApplication.")] void CanCreateTestBootstrapperApplication() { HRESULT hr = S_OK; - BOOTSTRAPPER_CREATE_ARGS args = { }; - BOOTSTRAPPER_COMMAND command = { }; - BOOTSTRAPPER_CREATE_RESULTS results = { }; - IBootstrapperEngine* pEngine = NULL; IBootstrapperApplication* pApplication = NULL; - - args.cbSize = sizeof(args); - args.pCommand = &command; - - results.cbSize = sizeof(results); + IBootstrapperEngine* pEngine = NULL; + BOOTSTRAPPER_COMMAND command = { }; try { - hr = BalInitializeFromCreateArgs(&args, &pEngine); - NativeAssert::Succeeded(hr, "Failed to create engine."); - - hr = CreateBootstrapperApplication(pEngine, &args, &results, &pApplication); + hr = CreateBootstrapperApplication(&pApplication); NativeAssert::Succeeded(hr, "Failed to create BootstrapperApplication."); + + hr = pApplication->OnCreate(pEngine, &command); + NativeAssert::Succeeded(hr, "Failed to initialize BootstrapperApplication."); } finally { diff --git a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp index 927a8d10..3e850442 100644 --- a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp +++ b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp @@ -8,34 +8,32 @@ class CTestBAFunctions : public CBalBaseBAFunctions { public: CTestBAFunctions( - __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, - __in const BA_FUNCTIONS_CREATE_ARGS* pArgs - ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) + __in HMODULE hModule + ) : CBalBaseBAFunctions(hModule) { } }; HRESULT CreateBAFunctions( __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, - __in BA_FUNCTIONS_CREATE_RESULTS* pResults, - __out IBAFunctions** ppApplication + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults ) { HRESULT hr = S_OK; - CTestBAFunctions* pApplication = NULL; + CTestBAFunctions* pFunction = NULL; - pApplication = new CTestBAFunctions(hModule, pEngine, pArgs); - ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object."); + pFunction = new CTestBAFunctions(hModule); + ExitOnNull(pFunction, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object."); + + hr = pFunction->OnCreate(pArgs->pEngine, pArgs->pCommand); + ExitOnFailure(hr, "Failed to initialize new test bafunctions."); pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; - pResults->pvBAFunctionsProcContext = pApplication; - *ppApplication = pApplication; - pApplication = NULL; + pResults->pvBAFunctionsProcContext = pFunction; + pFunction = NULL; LExit: - ReleaseObject(pApplication); + ReleaseObject(pFunction); return hr; } diff --git a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h index 41f36df8..e25e40c3 100644 --- a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h +++ b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h @@ -3,8 +3,6 @@ HRESULT CreateBAFunctions( __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, - __in BA_FUNCTIONS_CREATE_RESULTS* pResults, - __out IBAFunctions** ppApplication + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults ); diff --git a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp index daa1d690..b345ab9f 100644 --- a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp +++ b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp @@ -2,36 +2,25 @@ #include "precomp.h" #include "BalBaseBootstrapperApplication.h" -#include "BalBaseBootstrapperApplicationProc.h" class CTestBootstrapperApplication : public CBalBaseBootstrapperApplication { public: - CTestBootstrapperApplication( - __in IBootstrapperEngine* pEngine - ) : CBalBaseBootstrapperApplication(pEngine) + CTestBootstrapperApplication() : CBalBaseBootstrapperApplication() { } }; HRESULT CreateBootstrapperApplication( - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __inout BOOTSTRAPPER_CREATE_RESULTS* pResults, __out IBootstrapperApplication** ppApplication ) { HRESULT hr = S_OK; CTestBootstrapperApplication* pApplication = NULL; - pApplication = new CTestBootstrapperApplication(pEngine); + pApplication = new CTestBootstrapperApplication(); ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bootstrapper application object."); - hr = pApplication->Initialize(pArgs); - ExitOnFailure(hr, "CTestBootstrapperApplication initialization failed."); - - pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; - pResults->pvBootstrapperApplicationProcContext = pApplication; *ppApplication = pApplication; pApplication = NULL; diff --git a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h index c173e9ee..313bfede 100644 --- a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h +++ b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h @@ -2,8 +2,5 @@ // 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 CreateBootstrapperApplication( - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __inout BOOTSTRAPPER_CREATE_RESULTS* pResults, __out IBootstrapperApplication** ppApplication ); diff --git a/src/api/burn/test/BalUtilUnitTest/precomp.h b/src/api/burn/test/BalUtilUnitTest/precomp.h index 218cab68..57487bc5 100644 --- a/src/api/burn/test/BalUtilUnitTest/precomp.h +++ b/src/api/burn/test/BalUtilUnitTest/precomp.h @@ -15,8 +15,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs deleted file mode 100644 index 7074c166..00000000 --- a/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs +++ /dev/null @@ -1,141 +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. - -namespace WixToolsetTest.Mba.Core -{ - using System; - using System.Collections.Generic; - using System.Runtime.InteropServices; - using WixInternal.TestSupport; - using WixToolset.Mba.Core; - using Xunit; - - public class BaseBootstrapperApplicationFactoryFixture - { - [Fact] - public void CanCreateBA() - { - var command = new TestCommand - { - action = LaunchAction.Install, - cbSize = Marshal.SizeOf(typeof(TestCommand)), - display = Display.Full, - wzCommandLine = "this \"is a\" test VariableA=AVariable =EmptyName EmptyValue=", - }; - var pCommand = Marshal.AllocHGlobal(command.cbSize); - try - { - Marshal.StructureToPtr(command, pCommand, false); - var createArgs = new BootstrapperCreateArgs(0, IntPtr.Zero, IntPtr.Zero, pCommand); - var pArgs = Marshal.AllocHGlobal(createArgs.cbSize); - try - { - Marshal.StructureToPtr(createArgs, pArgs, false); - var createResults = new TestCreateResults - { - cbSize = Marshal.SizeOf(), - }; - var pResults = Marshal.AllocHGlobal(createResults.cbSize); - try - { - var baFactory = new TestBAFactory(); - baFactory.Create(pArgs, pResults); - - createResults = Marshal.PtrToStructure(pResults); - Assert.Equal(baFactory.BA, createResults.pBA); - Assert.Equal(baFactory.BA.Command.Action, command.action); - Assert.Equal(baFactory.BA.Command.Display, command.display); - - var mbaCommand = baFactory.BA.Command.ParseCommandLine(); - WixAssert.CompareLineByLine(mbaCommand.UnknownCommandLineArgs, new string[] { "this", "is a", "test" }); - Assert.Equal(mbaCommand.Variables, new KeyValuePair[] - { - new KeyValuePair("VariableA", "AVariable"), - new KeyValuePair("", "EmptyName"), - new KeyValuePair("EmptyValue", ""), - }); - } - finally - { - Marshal.FreeHGlobal(pResults); - } - } - finally - { - Marshal.FreeHGlobal(pArgs); - } - } - finally - { - Marshal.FreeHGlobal(pCommand); - } - } - - internal class TestBAFactory : BaseBootstrapperApplicationFactory - { - public TestBA BA { get; private set; } - - protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) - { - this.BA = new TestBA(engine, bootstrapperCommand); - return this.BA; - } - } - - internal class TestBA : BootstrapperApplication - { - public IBootstrapperCommand Command { get; } - - public TestBA(IEngine engine, IBootstrapperCommand command) - : base(engine) - { - this.Command = command; - } - - protected override void Run() - { - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct TestCommand - { - public int cbSize; - public LaunchAction action; - public Display display; - [MarshalAs(UnmanagedType.LPWStr)] public string wzCommandLine; - public int nCmdShow; - public ResumeType resume; - public IntPtr hwndSplashScreen; - public RelationType relation; - [MarshalAs(UnmanagedType.Bool)] public bool passthrough; - [MarshalAs(UnmanagedType.LPWStr)] public string wzLayoutDirectory; - } - - [StructLayout(LayoutKind.Sequential)] - public struct BootstrapperCreateArgs - { - [MarshalAs(UnmanagedType.I4)] public readonly int cbSize; - [MarshalAs(UnmanagedType.I8)] public readonly long qwEngineAPIVersion; - public readonly IntPtr pfnBootstrapperEngineProc; - public readonly IntPtr pvBootstrapperEngineProcContext; - public readonly IntPtr pCommand; - - public BootstrapperCreateArgs(long version, IntPtr pEngineProc, IntPtr pEngineContext, IntPtr pCommand) - { - this.cbSize = Marshal.SizeOf(typeof(BootstrapperCreateArgs)); - this.qwEngineAPIVersion = version; - this.pfnBootstrapperEngineProc = pEngineProc; - this.pvBootstrapperEngineProcContext = pEngineContext; - this.pCommand = pCommand; - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct TestCreateResults - { - public int cbSize; - public IntPtr pBAProc; - [MarshalAs(UnmanagedType.Interface)] public IBootstrapperApplication pBA; - } - } -} diff --git a/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs b/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs index 67c00431..688c34ed 100644 --- a/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs +++ b/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs @@ -550,8 +550,10 @@ namespace WixToolset.Data case SymbolDefinitionType.WixBootstrapperApplication: return SymbolDefinitions.WixBootstrapperApplication; +#pragma warning disable 612 case SymbolDefinitionType.WixBootstrapperApplicationDll: return SymbolDefinitions.WixBootstrapperApplicationDll; +#pragma warning restore 612 case SymbolDefinitionType.WixBuildInfo: return SymbolDefinitions.WixBuildInfo; diff --git a/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationDllSymbol.cs b/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationDllSymbol.cs index d3a66754..250028d0 100644 --- a/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationDllSymbol.cs +++ b/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationDllSymbol.cs @@ -2,10 +2,12 @@ namespace WixToolset.Data { + using System; using WixToolset.Data.Symbols; public static partial class SymbolDefinitions { + [Obsolete] public static readonly IntermediateSymbolDefinition WixBootstrapperApplicationDll = new IntermediateSymbolDefinition( SymbolDefinitionType.WixBootstrapperApplicationDll, new IntermediateFieldDefinition[] @@ -18,11 +20,14 @@ namespace WixToolset.Data namespace WixToolset.Data.Symbols { + using System; + public enum WixBootstrapperApplicationDllSymbolFields { DpiAwareness, } + [Obsolete] public enum WixBootstrapperApplicationDpiAwarenessType { Unaware, @@ -32,6 +37,7 @@ namespace WixToolset.Data.Symbols GdiScaled, } + [Obsolete] public class WixBootstrapperApplicationDllSymbol : IntermediateSymbol { public WixBootstrapperApplicationDllSymbol() : base(SymbolDefinitions.WixBootstrapperApplicationDll, null, null) diff --git a/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationSymbol.cs b/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationSymbol.cs index 3d7876fd..abef2cfc 100644 --- a/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationSymbol.cs +++ b/src/api/wix/WixToolset.Data/Symbols/WixBootstrapperApplicationSymbol.cs @@ -10,6 +10,8 @@ namespace WixToolset.Data SymbolDefinitionType.WixBootstrapperApplication, new IntermediateFieldDefinition[] { + new IntermediateFieldDefinition(nameof(WixBootstrapperApplicationSymbolFields.ExePayloadRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixBootstrapperApplicationSymbolFields.Secondary), IntermediateFieldType.Number), }, typeof(WixBootstrapperApplicationSymbol)); } @@ -19,6 +21,8 @@ namespace WixToolset.Data.Symbols { public enum WixBootstrapperApplicationSymbolFields { + ExePayloadRef, + Secondary } public class WixBootstrapperApplicationSymbol : IntermediateSymbol @@ -32,5 +36,17 @@ namespace WixToolset.Data.Symbols } public IntermediateField this[WixBootstrapperApplicationSymbolFields index] => this.Fields[(int)index]; + + public string ExePayloadRef + { + get => (string)this.Fields[(int)WixBootstrapperApplicationSymbolFields.ExePayloadRef]; + set => this.Set((int)WixBootstrapperApplicationSymbolFields.ExePayloadRef, value); + } + + public bool? Secondary + { + get => (bool?)this.Fields[(int)WixBootstrapperApplicationSymbolFields.Secondary]; + set => this.Set((int)WixBootstrapperApplicationSymbolFields.Secondary, value); + } } } diff --git a/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs b/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs index 2de9c028..cc4f6963 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs @@ -2,13 +2,29 @@ namespace WixToolset.Extensibility.Data { -#pragma warning disable 1591 // TODO: add documentation + using WixToolset.Data; + + /// + /// Interface used to by extensions to define a component key path or + /// (non-intuitively) the executable payload for a the bootstrapper application. + /// public interface IComponentKeyPath { + /// + /// Indicates whether the key path was specified explicitly. + /// bool Explicit { get; set; } - string Id { get; set; } + /// + /// Gets or sets the key path or executable payload identifier. + /// + Identifier Id { get; set; } + /// + /// Gets or sets the key path type for the component or if the + /// executable payload for a bootstrapper application is provided + /// as a File. + /// PossibleKeyPathType Type { get; set; } } } -- cgit v1.2.3-55-g6feb