From 60069b189db09521558b99827aee47fe3f81309b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 29 Dec 2018 22:24:05 -0600 Subject: Import code from old v4 repo --- src/balutil/BalBootstrapperEngine.cpp | 720 +++++++++++++++++ src/balutil/balcondition.cpp | 124 +++ src/balutil/balinfo.cpp | 288 +++++++ src/balutil/balretry.cpp | 191 +++++ src/balutil/balutil.cpp | 382 +++++++++ src/balutil/inc/BAFunctions.h | 130 +++ src/balutil/inc/BalBaseBAFunctions.h | 700 ++++++++++++++++ src/balutil/inc/BalBaseBAFunctionsProc.h | 114 +++ src/balutil/inc/BalBaseBootstrapperApplication.h | 900 +++++++++++++++++++++ .../inc/BalBaseBootstrapperApplicationProc.h | 698 ++++++++++++++++ src/balutil/inc/BalBootstrapperEngine.h | 17 + src/balutil/inc/IBAFunctions.h | 34 + src/balutil/inc/balcondition.h | 58 ++ src/balutil/inc/balinfo.h | 107 +++ src/balutil/inc/balretry.h | 65 ++ src/balutil/inc/balutil.h | 165 ++++ src/balutil/precomp.h | 31 + 17 files changed, 4724 insertions(+) create mode 100644 src/balutil/BalBootstrapperEngine.cpp create mode 100644 src/balutil/balcondition.cpp create mode 100644 src/balutil/balinfo.cpp create mode 100644 src/balutil/balretry.cpp create mode 100644 src/balutil/balutil.cpp create mode 100644 src/balutil/inc/BAFunctions.h create mode 100644 src/balutil/inc/BalBaseBAFunctions.h create mode 100644 src/balutil/inc/BalBaseBAFunctionsProc.h create mode 100644 src/balutil/inc/BalBaseBootstrapperApplication.h create mode 100644 src/balutil/inc/BalBaseBootstrapperApplicationProc.h create mode 100644 src/balutil/inc/BalBootstrapperEngine.h create mode 100644 src/balutil/inc/IBAFunctions.h create mode 100644 src/balutil/inc/balcondition.h create mode 100644 src/balutil/inc/balinfo.h create mode 100644 src/balutil/inc/balretry.h create mode 100644 src/balutil/inc/balutil.h create mode 100644 src/balutil/precomp.h (limited to 'src') diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp new file mode 100644 index 00000000..945940c5 --- /dev/null +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -0,0 +1,720 @@ +// 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" + + +class CBalBootstrapperEngine : public IBootstrapperEngine, public IMarshal +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBootstrapperEngine), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IMarshal, riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = reinterpret_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBootstrapperEngine + virtual STDMETHODIMP GetPackageCount( + __out DWORD* pcPackages + ) + { + HRESULT hr = S_OK; + BAENGINE_GETPACKAGECOUNT_ARGS args = { }; + BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; + + ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required"); + + args.cbSize = sizeof(args); + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &args, &results, m_pvBAEngineProcContext); + + *pcPackages = results.cPackages; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableNumeric( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) + { + HRESULT hr = S_OK; + BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; + BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; + + ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); + + *pllValue = results.llValue; + + LExit: + SecureZeroMemory(&results, sizeof(results)); + return hr; + } + + virtual STDMETHODIMP GetVariableString( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue + ) + { + HRESULT hr = S_OK; + BAENGINE_GETVARIABLESTRING_ARGS args = { }; + BAENGINE_GETVARIABLESTRING_RESULTS results = { }; + + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); + + *pcchValue = results.cchValue; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableVersion( + __in_z LPCWSTR wzVariable, + __out DWORD64* pqwValue + ) + { + HRESULT hr = S_OK; + BAENGINE_GETVARIABLEVERSION_ARGS args = { }; + BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; + + ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); + + *pqwValue = results.qwValue; + + LExit: + SecureZeroMemory(&results, sizeof(results)); + return hr; + } + + virtual STDMETHODIMP FormatString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD* pcchOut + ) + { + HRESULT hr = S_OK; + BAENGINE_FORMATSTRING_ARGS args = { }; + BAENGINE_FORMATSTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBAEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP EscapeString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD* pcchOut + ) + { + HRESULT hr = S_OK; + BAENGINE_ESCAPESTRING_ARGS args = { }; + BAENGINE_ESCAPESTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBAEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP EvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) + { + HRESULT hr = S_OK; + BAENGINE_EVALUATECONDITION_ARGS args = { }; + BAENGINE_EVALUATECONDITION_RESULTS results = { }; + + ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); + + args.cbSize = sizeof(args); + args.wzCondition = wzCondition; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBAEngineProcContext); + + *pf = results.f; + + LExit: + return hr; + } + + virtual STDMETHODIMP Log( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) + { + BAENGINE_LOG_ARGS args = { }; + BAENGINE_LOG_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.level = level; + args.wzMessage = wzMessage; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SendEmbeddedError( + __in DWORD dwErrorCode, + __in_z_opt LPCWSTR wzMessage, + __in DWORD dwUIHint, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; + BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.dwErrorCode = dwErrorCode; + args.wzMessage = wzMessage; + args.dwUIHint = dwUIHint; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &args, &results, m_pvBAEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + + virtual STDMETHODIMP SendEmbeddedProgress( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; + BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.dwProgressPercentage = dwProgressPercentage; + args.dwOverallProgressPercentage = dwOverallProgressPercentage; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &args, &results, m_pvBAEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + + virtual STDMETHODIMP SetUpdate( + __in_z_opt LPCWSTR wzLocalSource, + __in_z_opt LPCWSTR wzDownloadSource, + __in DWORD64 qwSize, + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, + __in_bcount_opt(cbHash) BYTE* rgbHash, + __in DWORD cbHash + ) + { + BAENGINE_SETUPDATE_ARGS args = { }; + BAENGINE_SETUPDATE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzLocalSource = wzLocalSource; + args.wzDownloadSource = wzDownloadSource; + args.qwSize = qwSize; + args.hashType = hashType; + args.rgbHash = rgbHash; + args.cbHash = cbHash; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetLocalSource( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzPath + ) + { + BAENGINE_SETLOCALSOURCE_ARGS args = { }; + BAENGINE_SETLOCALSOURCE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzPackageOrContainerId = wzPackageOrContainerId; + args.wzPayloadId = wzPayloadId; + args.wzPath = wzPath; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetDownloadSource( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzUrl, + __in_z_opt LPCWSTR wzUser, + __in_z_opt LPCWSTR wzPassword + ) + { + BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; + BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzPackageOrContainerId = wzPackageOrContainerId; + args.wzPayloadId = wzPayloadId; + args.wzUrl = wzUrl; + args.wzUser = wzUser; + args.wzPassword = wzPassword; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetVariableNumeric( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) + { + BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; + BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.llValue = llValue; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetVariableString( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) + { + BAENGINE_SETVARIABLESTRING_ARGS args = { }; + BAENGINE_SETVARIABLESTRING_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetVariableVersion( + __in_z LPCWSTR wzVariable, + __in DWORD64 qwValue + ) + { + BAENGINE_SETVARIABLEVERSION_ARGS args = { }; + BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.qwValue = qwValue; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP CloseSplashScreen() + { + BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; + BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; + + args.cbSize = sizeof(args); + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Detect( + __in_opt HWND hwndParent + ) + { + BAENGINE_DETECT_ARGS args = { }; + BAENGINE_DETECT_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Plan( + __in BOOTSTRAPPER_ACTION action + ) + { + BAENGINE_PLAN_ARGS args = { }; + BAENGINE_PLAN_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.action = action; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Elevate( + __in_opt HWND hwndParent + ) + { + BAENGINE_ELEVATE_ARGS args = { }; + BAENGINE_ELEVATE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Apply( + __in_opt HWND hwndParent + ) + { + BAENGINE_APPLY_ARGS args = { }; + BAENGINE_APPLY_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Quit( + __in DWORD dwExitCode + ) + { + BAENGINE_QUIT_ARGS args = { }; + BAENGINE_QUIT_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.dwExitCode = dwExitCode; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP LaunchApprovedExe( + __in_opt HWND hwndParent, + __in_z LPCWSTR wzApprovedExeForElevationId, + __in_z_opt LPCWSTR wzArguments, + __in DWORD dwWaitForInputIdleTimeout + ) + { + BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; + BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + args.wzApprovedExeForElevationId = wzApprovedExeForElevationId; + args.wzArguments = wzArguments; + args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); + } + +public: // IMarshal + virtual STDMETHODIMP GetUnmarshalClass( + __in REFIID /*riid*/, + __in_opt LPVOID /*pv*/, + __in DWORD /*dwDestContext*/, + __reserved LPVOID /*pvDestContext*/, + __in DWORD /*mshlflags*/, + __out LPCLSID /*pCid*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP GetMarshalSizeMax( + __in REFIID riid, + __in_opt LPVOID /*pv*/, + __in DWORD dwDestContext, + __reserved LPVOID /*pvDestContext*/, + __in DWORD /*mshlflags*/, + __out DWORD *pSize + ) + { + HRESULT hr = S_OK; + + // We only support marshaling the IBootstrapperEngine interface in-proc. + if (__uuidof(IBootstrapperEngine) != riid) + { + // Skip logging the following message since it appears way too often in the log. + // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface." + ExitFunction1(hr = E_NOINTERFACE); + } + else if (0 == (MSHCTX_INPROC & dwDestContext)) + { + hr = E_FAIL; + ExitOnRootFailure(hr, "Cannot marshal IBootstrapperEngine interface out of proc."); + } + + // E_FAIL is used because E_INVALIDARG is not a supported return value. + ExitOnNull(pSize, hr, E_FAIL, "Invalid size output parameter is NULL."); + + // Specify enough size to marshal just the interface pointer across threads. + *pSize = sizeof(LPVOID); + + LExit: + return hr; + } + + virtual STDMETHODIMP MarshalInterface( + __in IStream* pStm, + __in REFIID riid, + __in_opt LPVOID pv, + __in DWORD dwDestContext, + __reserved LPVOID /*pvDestContext*/, + __in DWORD /*mshlflags*/ + ) + { + HRESULT hr = S_OK; + IBootstrapperEngine *pThis = NULL; + ULONG ulWritten = 0; + + // We only support marshaling the IBootstrapperEngine interface in-proc. + if (__uuidof(IBootstrapperEngine) != riid) + { + // Skip logging the following message since it appears way too often in the log. + // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface." + ExitFunction1(hr = E_NOINTERFACE); + } + else if (0 == (MSHCTX_INPROC & dwDestContext)) + { + hr = E_FAIL; + ExitOnRootFailure(hr, "Cannot marshal IBootstrapperEngine interface out of proc."); + } + + // "pv" may not be set, so we should us "this" otherwise. + if (pv) + { + pThis = reinterpret_cast(pv); + } + else + { + pThis = static_cast(this); + } + + // E_INVALIDARG is not a supported return value. + ExitOnNull(pStm, hr, E_FAIL, "The marshaling stream parameter is NULL."); + + // Marshal the interface pointer in-proc as is. + hr = pStm->Write(pThis, sizeof(pThis), &ulWritten); + if (STG_E_MEDIUMFULL == hr) + { + ExitOnFailure(hr, "Failed to write the stream because the stream is full."); + } + else if (FAILED(hr)) + { + // All other STG error must be converted into E_FAIL based on IMarshal documentation. + hr = E_FAIL; + ExitOnFailure(hr, "Failed to write the IBootstrapperEngine interface pointer to the marshaling stream."); + } + + LExit: + return hr; + } + + virtual STDMETHODIMP UnmarshalInterface( + __in IStream* pStm, + __in REFIID riid, + __deref_out LPVOID* ppv + ) + { + HRESULT hr = S_OK; + ULONG ulRead = 0; + + // We only support marshaling the engine in-proc. + if (__uuidof(IBootstrapperEngine) != riid) + { + // Skip logging the following message since it appears way too often in the log. + // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface." + ExitFunction1(hr = E_NOINTERFACE); + } + + // E_FAIL is used because E_INVALIDARG is not a supported return value. + ExitOnNull(pStm, hr, E_FAIL, "The marshaling stream parameter is NULL."); + ExitOnNull(ppv, hr, E_FAIL, "The interface output parameter is NULL."); + + // Unmarshal the interface pointer in-proc as is. + hr = pStm->Read(*ppv, sizeof(LPVOID), &ulRead); + if (FAILED(hr)) + { + // All STG errors must be converted into E_FAIL based on IMarshal documentation. + hr = E_FAIL; + ExitOnFailure(hr, "Failed to read the IBootstrapperEngine interface pointer from the marshaling stream."); + } + + LExit: + return hr; + } + + virtual STDMETHODIMP ReleaseMarshalData( + __in IStream* /*pStm*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP DisconnectObject( + __in DWORD /*dwReserved*/ + ) + { + return E_NOTIMPL; + } + +public: + CBalBootstrapperEngine( + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, + __in_opt LPVOID pvBAEngineProcContext + ) + { + m_cReferences = 1; + m_pfnBAEngineProc = pfnBAEngineProc; + m_pvBAEngineProcContext = pvBAEngineProcContext; + } + +private: + long m_cReferences; + PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc; + LPVOID m_pvBAEngineProcContext; +}; + +HRESULT BalBootstrapperEngineCreate( + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, + __in_opt LPVOID pvBAEngineProcContext, + __out IBootstrapperEngine** ppBootstrapperEngine + ) +{ + HRESULT hr = S_OK; + CBalBootstrapperEngine* pBootstrapperEngine = NULL; + + pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext); + ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); + + hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); + ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); + +LExit: + ReleaseObject(pBootstrapperEngine); + return hr; +} diff --git a/src/balutil/balcondition.cpp b/src/balutil/balcondition.cpp new file mode 100644 index 00000000..11d3e218 --- /dev/null +++ b/src/balutil/balcondition.cpp @@ -0,0 +1,124 @@ +// 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" + +// prototypes + + +DAPI_(HRESULT) BalConditionsParseFromXml( + __in BAL_CONDITIONS* pConditions, + __in IXMLDOMDocument* pixdManifest, + __in_opt WIX_LOCALIZATION* pWixLoc + ) +{ + HRESULT hr = S_OK; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + BAL_CONDITION* prgConditions = NULL; + DWORD cConditions = 0; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalCondition", &pNodeList); + ExitOnFailure(hr, "Failed to select all conditions."); + + hr = pNodeList->get_length(reinterpret_cast(&cConditions)); + ExitOnFailure(hr, "Failed to get the condition count."); + + if (!cConditions) + { + ExitFunction(); + } + + prgConditions = static_cast(MemAlloc(sizeof(BAL_CONDITION) * cConditions, TRUE)); + ExitOnNull(prgConditions, hr, E_OUTOFMEMORY, "Failed to allocate memory for conditions."); + + DWORD iCondition = 0; + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"Condition", &prgConditions[iCondition].sczCondition); + ExitOnFailure(hr, "Failed to get condition for condition."); + + hr = XmlGetAttributeEx(pNode, L"Message", &prgConditions[iCondition].sczMessage); + ExitOnFailure(hr, "Failed to get message for condition."); + + if (pWixLoc && prgConditions[iCondition].sczMessage && *prgConditions[iCondition].sczMessage) + { + hr = LocLocalizeString(pWixLoc, &prgConditions[iCondition].sczMessage); + ExitOnFailure(hr, "Failed to localize condition message."); + } + + ++iCondition; + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all condition elements."); + + if (S_FALSE == hr) + { + hr = S_OK; + } + + pConditions->cConditions = cConditions; + pConditions->rgConditions = prgConditions; + prgConditions = NULL; + +LExit: + ReleaseMem(prgConditions); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + + return hr; +} + + +//the contents of psczMessage may be sensitive, should keep encrypted and SecureZeroFree +DAPI_(HRESULT) BalConditionEvaluate( + __in BAL_CONDITION* pCondition, + __in IBootstrapperEngine* pEngine, + __out BOOL* pfResult, + __out_z_opt LPWSTR* psczMessage + ) +{ + HRESULT hr = S_OK; + DWORD_PTR cchMessage = 0; + + hr = pEngine->EvaluateCondition(pCondition->sczCondition, pfResult); + ExitOnFailure(hr, "Failed to evaluate condition with bootstrapper engine."); + + if (psczMessage) + { + if (*psczMessage) + { + hr = StrMaxLength(*psczMessage, &cchMessage); + ExitOnFailure(hr, "Failed to get length of message."); + } + + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, reinterpret_cast(&cchMessage)); + if (E_MOREDATA == hr) + { + ++cchMessage; + + hr = StrAllocSecure(psczMessage, cchMessage); + ExitOnFailure(hr, "Failed to allocate string for condition's formatted message."); + + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, reinterpret_cast(&cchMessage)); + } + ExitOnFailure(hr, "Failed to format condition's message."); + } + +LExit: + return hr; +} + + +DAPI_(void) BalConditionsUninitialize( + __in BAL_CONDITIONS* pConditions + ) +{ + for (DWORD i = 0; i < pConditions->cConditions; ++i) + { + ReleaseStr(pConditions->rgConditions[i].sczMessage); + ReleaseStr(pConditions->rgConditions[i].sczCondition); + } + + ReleaseMem(pConditions->rgConditions); + memset(pConditions, 0, sizeof(BAL_CONDITIONS)); +} diff --git a/src/balutil/balinfo.cpp b/src/balutil/balinfo.cpp new file mode 100644 index 00000000..b36e3741 --- /dev/null +++ b/src/balutil/balinfo.cpp @@ -0,0 +1,288 @@ +// 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" + +// prototypes +static HRESULT ParsePackagesFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ); + + +DAPI_(HRESULT) BalInfoParseFromXml( + __in BAL_INFO_BUNDLE* pBundle, + __in IXMLDOMDocument* pixdManifest + ) +{ + HRESULT hr = S_OK; + IXMLDOMNode* pNode = NULL; + + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBundleProperties", &pNode); + ExitOnFailure(hr, "Failed to select bundle information."); + + if (S_OK == hr) + { + hr = XmlGetYesNoAttribute(pNode, L"PerMachine", &pBundle->fPerMachine); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to read bundle information per-machine."); + } + + hr = XmlGetAttributeEx(pNode, L"DisplayName", &pBundle->sczName); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to read bundle information display name."); + } + + hr = XmlGetAttributeEx(pNode, L"LogPathVariable", &pBundle->sczLogVariable); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to read bundle information log path variable."); + } + } + + hr = ParsePackagesFromXml(&pBundle->packages, pixdManifest); + BalExitOnFailure(hr, "Failed to parse package information from bootstrapper application data."); + +LExit: + ReleaseObject(pNode); + + return hr; +} + + +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in BOOL /*fPerMachine*/ + ) +{ + HRESULT hr = S_OK; + BAL_INFO_PACKAGE_TYPE type = BAL_INFO_PACKAGE_TYPE_UNKNOWN; + BAL_INFO_PACKAGE* pPackage = NULL; + + // Ensure we have a supported relation type. + switch (relationType) + { + case BOOTSTRAPPER_RELATION_ADDON: + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON; + break; + + case BOOTSTRAPPER_RELATION_PATCH: + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH; + break; + + case BOOTSTRAPPER_RELATION_UPGRADE: + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE; + break; + + default: + ExitOnFailure(hr = E_INVALIDARG, "Unknown related bundle type: %u", relationType); + } + + // Check to see if the bundle is already in the list of packages. + for (DWORD i = 0; i < pPackages->cPackages; ++i) + { + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1)) + { + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)); + } + } + + // Add the related bundle as a package. + hr = MemEnsureArraySize(reinterpret_cast(&pPackages->rgPackages), pPackages->cPackages + 1, sizeof(BAL_INFO_PACKAGE), 2); + ExitOnFailure(hr, "Failed to allocate memory for related bundle package information."); + + pPackage = pPackages->rgPackages + pPackages->cPackages; + ++pPackages->cPackages; + + hr = StrAllocString(&pPackage->sczId, wzId, 0); + ExitOnFailure(hr, "Failed to copy related bundle package id."); + + pPackage->type = type; + + // TODO: try to look up the DisplayName and Description in Add/Remove Programs with the wzId. + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalInfoFindPackageById( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __out BAL_INFO_PACKAGE** ppPackage + ) +{ + *ppPackage = NULL; + + for (DWORD i = 0; i < pPackages->cPackages; ++i) + { + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1)) + { + *ppPackage = pPackages->rgPackages + i; + break; + } + } + + return *ppPackage ? S_OK : E_NOTFOUND; +} + + +DAPI_(void) BalInfoUninitialize( + __in BAL_INFO_BUNDLE* pBundle + ) +{ + for (DWORD i = 0; i < pBundle->packages.cPackages; ++i) + { + ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayName); + ReleaseStr(pBundle->packages.rgPackages[i].sczDescription); + ReleaseStr(pBundle->packages.rgPackages[i].sczId); + ReleaseStr(pBundle->packages.rgPackages[i].sczProductCode); + ReleaseStr(pBundle->packages.rgPackages[i].sczUpgradeCode); + ReleaseStr(pBundle->packages.rgPackages[i].sczVersion); + ReleaseStr(pBundle->packages.rgPackages[i].sczInstallCondition); + } + + ReleaseMem(pBundle->packages.rgPackages); + + ReleaseStr(pBundle->sczName); + ReleaseStr(pBundle->sczLogVariable); + memset(pBundle, 0, sizeof(BAL_INFO_BUNDLE)); +} + + +static HRESULT ParsePackagesFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ) +{ + HRESULT hr = S_OK; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + BAL_INFO_PACKAGE* prgPackages = NULL; + DWORD cPackages = 0; + LPWSTR scz = NULL; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPackageProperties", &pNodeList); + ExitOnFailure(hr, "Failed to select all packages."); + + hr = pNodeList->get_length(reinterpret_cast(&cPackages)); + ExitOnFailure(hr, "Failed to get the package count."); + + prgPackages = static_cast(MemAlloc(sizeof(BAL_INFO_PACKAGE) * cPackages, TRUE)); + ExitOnNull(prgPackages, hr, E_OUTOFMEMORY, "Failed to allocate memory for packages."); + + DWORD iPackage = 0; + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"Package", &prgPackages[iPackage].sczId); + ExitOnFailure(hr, "Failed to get package identifier for package."); + + hr = XmlGetAttributeEx(pNode, L"DisplayName", &prgPackages[iPackage].sczDisplayName); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get display name for package."); + } + + hr = XmlGetAttributeEx(pNode, L"Description", &prgPackages[iPackage].sczDescription); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get description for package."); + } + + hr = XmlGetAttributeEx(pNode, L"PackageType", &scz); + ExitOnFailure(hr, "Failed to get package type for package."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Exe", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_EXE; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msi", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSI; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msp", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSP; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msu", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSU; + } + + hr = XmlGetYesNoAttribute(pNode, L"Permanent", &prgPackages[iPackage].fPermanent); + ExitOnFailure(hr, "Failed to get permanent setting for package."); + + hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital); + ExitOnFailure(hr, "Failed to get vital setting for package."); + + hr = XmlGetYesNoAttribute(pNode, L"DisplayInternalUI", &prgPackages[iPackage].fDisplayInternalUI); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get DisplayInternalUI setting for package."); + } + + hr = XmlGetAttributeEx(pNode, L"ProductCode", &prgPackages[iPackage].sczProductCode); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get product code for package."); + } + + hr = XmlGetAttributeEx(pNode, L"UpgradeCode", &prgPackages[iPackage].sczUpgradeCode); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get upgrade code for package."); + } + + hr = XmlGetAttributeEx(pNode, L"Version", &prgPackages[iPackage].sczVersion); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get version for package."); + } + + hr = XmlGetAttributeEx(pNode, L"InstallCondition", &prgPackages[iPackage].sczInstallCondition); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get install condition for package."); + } + + hr = XmlGetAttributeEx(pNode, L"Cache", &scz); + ExitOnFailure(hr, "Failed to get cache type for package."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"no", -1)) + { + prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_NO; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"yes", -1)) + { + prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_YES; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"always", -1)) + { + prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_ALWAYS; + } + + ++iPackage; + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all package property elements."); + + if (S_FALSE == hr) + { + hr = S_OK; + } + + pPackages->cPackages = cPackages; + pPackages->rgPackages = prgPackages; + prgPackages = NULL; + +LExit: + ReleaseStr(scz); + ReleaseMem(prgPackages); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + + return hr; +} diff --git a/src/balutil/balretry.cpp b/src/balutil/balretry.cpp new file mode 100644 index 00000000..d95d86b2 --- /dev/null +++ b/src/balutil/balretry.cpp @@ -0,0 +1,191 @@ +// 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" + +struct BALRETRY_INFO +{ + LPWSTR sczId; // package or container id. + LPWSTR sczPayloadId; // optional payload id. + DWORD cRetries; + DWORD dwLastError; +}; + +static DWORD vdwMaxRetries = 0; +static DWORD vdwTimeout = 0; +static BALRETRY_INFO vrgRetryInfo[2]; + +// prototypes +static BOOL IsActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR wzPackageId, + __in_z_opt LPCWSTR wzPayloadId + ); + + +DAPI_(void) BalRetryInitialize( + __in DWORD dwMaxRetries, + __in DWORD dwTimeout + ) +{ + BalRetryUninitialize(); // clean everything out. + + vdwMaxRetries = dwMaxRetries; + vdwTimeout = dwTimeout; +} + + +DAPI_(void) BalRetryUninitialize() +{ + for (DWORD i = 0; i < countof(vrgRetryInfo); ++i) + { + ReleaseStr(vrgRetryInfo[i].sczId); + ReleaseStr(vrgRetryInfo[i].sczPayloadId); + memset(vrgRetryInfo + i, 0, sizeof(BALRETRY_INFO)); + } + + vdwMaxRetries = 0; + vdwTimeout = 0; +} + + +DAPI_(void) BalRetryStartPackage( + __in BALRETRY_TYPE type, + __in_z_opt LPCWSTR wzPackageId, + __in_z_opt LPCWSTR wzPayloadId + ) +{ + if (!wzPackageId || !*wzPackageId) + { + ReleaseNullStr(vrgRetryInfo[type].sczId); + ReleaseNullStr(vrgRetryInfo[type].sczPayloadId); + } + else if (IsActiveRetryEntry(type, wzPackageId, wzPayloadId)) + { + ++vrgRetryInfo[type].cRetries; + ::Sleep(vdwTimeout); + } + else + { + StrAllocString(&vrgRetryInfo[type].sczId, wzPackageId, 0); + if (wzPayloadId) + { + StrAllocString(&vrgRetryInfo[type].sczPayloadId, wzPayloadId, 0); + } + + vrgRetryInfo[type].cRetries = 0; + } + + vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; +} + + +DAPI_(void) BalRetryErrorOccurred( + __in_z LPCWSTR wzPackageId, + __in DWORD dwError + ) +{ + if (IsActiveRetryEntry(BALRETRY_TYPE_CACHE, wzPackageId, NULL)) + { + vrgRetryInfo[BALRETRY_TYPE_CACHE].dwLastError = dwError; + } + else if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL)) + { + vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; + } +} + + +DAPI_(HRESULT) BalRetryEndPackage( + __in BALRETRY_TYPE type, + __in_z_opt LPCWSTR wzPackageId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ) +{ + HRESULT hr = S_OK; + + if (!wzPackageId || !*wzPackageId) + { + ReleaseNullStr(vrgRetryInfo[type].sczId); + ReleaseNullStr(vrgRetryInfo[type].sczPayloadId); + } + else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId, wzPayloadId)) + { + if (BALRETRY_TYPE_CACHE == type) + { + // Retry on all errors except the following. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && + BG_E_NETWORK_DISCONNECTED != hrError && + HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && + HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) + { + *pfRetry = TRUE; + } + } + else if (BALRETRY_TYPE_EXECUTE == type) + { + // If the service is out of whack, just try again. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) + { + *pfRetry = TRUE; + } + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) + { + DWORD dwError = vrgRetryInfo[type].dwLastError; + + // If we failed with one of these specific error codes, then retry since + // we've seen these have a high success of succeeding on retry. + if (1303 == dwError || + 1304 == dwError || + 1306 == dwError || + 1307 == dwError || + 1309 == dwError || + 1310 == dwError || + 1311 == dwError || + 1312 == dwError || + 1316 == dwError || + 1317 == dwError || + 1321 == dwError || + 1335 == dwError || + 1402 == dwError || + 1406 == dwError || + 1606 == dwError || + 1706 == dwError || + 1719 == dwError || + 1723 == dwError || + 1923 == dwError || + 1931 == dwError) + { + *pfRetry = TRUE; + } + } + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) + { + *pfRetry = TRUE; + } + } + } + + return hr; +} + + +// Internal functions. + +static BOOL IsActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR wzPackageId, + __in_z_opt LPCWSTR wzPayloadId + ) +{ + BOOL fActive = FALSE; + + fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, vrgRetryInfo[type].sczId, -1); + if (fActive && wzPayloadId) // if a payload id was provided ensure it matches. + { + fActive = vrgRetryInfo[type].sczPayloadId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPayloadId, -1, vrgRetryInfo[type].sczPayloadId, -1); + } + + return fActive; +} diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp new file mode 100644 index 00000000..df254359 --- /dev/null +++ b/src/balutil/balutil.cpp @@ -0,0 +1,382 @@ +// 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" + +const DWORD VARIABLE_GROW_FACTOR = 80; +static IBootstrapperEngine* vpEngine = NULL; + +// prototypes + +DAPI_(void) BalInitialize( + __in IBootstrapperEngine* pEngine + ) +{ + pEngine->AddRef(); + + ReleaseObject(vpEngine); + vpEngine = pEngine; +} + +DAPI_(HRESULT) BalInitializeFromCreateArgs( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __out_opt IBootstrapperEngine** ppEngine + ) +{ + HRESULT hr = S_OK; + IBootstrapperEngine* pEngine = NULL; + + hr = BalBootstrapperEngineCreate(pArgs->pfnBootstrapperEngineProc, pArgs->pvBootstrapperEngineProcContext, &pEngine); + ExitOnFailure(hr, "Failed to create BalBootstrapperEngine."); + + BalInitialize(pEngine); + + if (ppEngine) + { + *ppEngine = pEngine; + } + pEngine = NULL; + +LExit: + ReleaseObject(pEngine); + + return hr; +} + + +DAPI_(void) BalUninitialize() +{ + ReleaseNullObject(vpEngine); +} + + +DAPI_(HRESULT) BalManifestLoad( + __in HMODULE hBootstrapperApplicationModule, + __out IXMLDOMDocument** ppixdManifest + ) +{ + HRESULT hr = S_OK; + LPWSTR sczPath = NULL; + + hr = PathRelativeToModule(&sczPath, BAL_MANIFEST_FILENAME, hBootstrapperApplicationModule); + ExitOnFailure(hr, "Failed to get path to bootstrapper application manifest: %ls", BAL_MANIFEST_FILENAME); + + hr = XmlLoadDocumentFromFile(sczPath, ppixdManifest); + ExitOnFailure(hr, "Failed to load bootstrapper application manifest '%ls' from path: %ls", BAL_MANIFEST_FILENAME, sczPath); + +LExit: + ReleaseStr(sczPath); + return hr; +} + + +DAPI_(HRESULT) BalEvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->EvaluateCondition(wzCondition, pf); + +LExit: + return hr; +} + + +// The contents of psczOut may be sensitive, should keep encrypted and SecureZeroFree. +DAPI_(HRESULT) BalFormatString( + __in_z LPCWSTR wzFormat, + __inout LPWSTR* psczOut + ) +{ + HRESULT hr = S_OK; + DWORD cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + if (*psczOut) + { + hr = StrMaxLength(*psczOut, reinterpret_cast(&cch)); + ExitOnFailure(hr, "Failed to determine length of value."); + } + + hr = vpEngine->FormatString(wzFormat, *psczOut, &cch); + if (E_MOREDATA == hr) + { + ++cch; + + hr = StrAllocSecure(psczOut, cch); + ExitOnFailure(hr, "Failed to allocate value."); + + hr = vpEngine->FormatString(wzFormat, *psczOut, &cch); + } + +LExit: + return hr; +} + + +// The contents of pllValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroMemory. +DAPI_(HRESULT) BalGetNumericVariable( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->GetVariableNumeric(wzVariable, pllValue); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalSetNumericVariable( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->SetVariableNumeric(wzVariable, llValue); + +LExit: + return hr; +} + + +DAPI_(BOOL) BalStringVariableExists( + __in_z LPCWSTR wzVariable + ) +{ + HRESULT hr = S_OK; + DWORD cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->GetVariableString(wzVariable, NULL, &cch); + +LExit: + return E_MOREDATA == hr; // string exists only if there are more than zero characters in the variable. +} + + +// The contents of psczValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroFree. +DAPI_(HRESULT) BalGetStringVariable( + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue + ) +{ + HRESULT hr = S_OK; + DWORD cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + if (*psczValue) + { + hr = StrMaxLength(*psczValue, reinterpret_cast(&cch)); + ExitOnFailure(hr, "Failed to determine length of value."); + } + + hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch); + if (E_MOREDATA == hr) + { + ++cch; + + hr = StrAllocSecure(psczValue, cch); + ExitOnFailure(hr, "Failed to allocate value."); + + hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch); + } + +LExit: + return hr; +} + +DAPI_(HRESULT) BalSetStringVariable( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->SetVariableString(wzVariable, wzValue); + +LExit: + return hr; +} + + +DAPIV_(HRESULT) BalLog( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + va_end(args); + ExitOnFailure(hr, "Failed to format log string."); + + hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); + ExitOnFailure(hr, "Failed to convert log string to Unicode."); + + hr = vpEngine->Log(level, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} + + +DAPIV_(HRESULT) BalLogError( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + va_end(args); + ExitOnFailure(hr, "Failed to format error log string."); + + hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); + ExitOnFailure(hr, "Failed to prepend error number to error log string."); + + hr = vpEngine->Log(BOOTSTRAPPER_LOG_LEVEL_ERROR, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} + +DAPIV_(HRESULT) BalLogId( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, hModule); + hr = BalLogIdArgs(level, dwLogId, hModule, args); + va_end(args); + +LExit: + return hr; +} + +DAPI_(HRESULT) BalLogIdArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + __in va_list args + ) +{ + + HRESULT hr = S_OK; + LPWSTR pwz = NULL; + DWORD cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + // Get the string for the id. +#pragma prefast(push) +#pragma prefast(disable:25028) +#pragma prefast(disable:25068) + cch = ::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE, + static_cast(hModule), dwLogId, 0, reinterpret_cast(&pwz), 0, &args); +#pragma prefast(pop) + + if (0 == cch) + { + ExitOnLastError(hr, "Failed to log id: %d", dwLogId); + } + + if (2 <= cch && L'\r' == pwz[cch - 2] && L'\n' == pwz[cch - 1]) + { + pwz[cch - 2] = L'\0'; // remove newline from message table. + } + + hr = vpEngine->Log(level, pwz); + +LExit: + if (pwz) + { + ::LocalFree(pwz); + } + + return hr; +} diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h new file mode 100644 index 00000000..1338253d --- /dev/null +++ b/src/balutil/inc/BAFunctions.h @@ -0,0 +1,130 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +// The first 1024 messages are reserved so that the BA messages have the same value here. +enum BA_FUNCTIONS_MESSAGE +{ + 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_ONSYSTEMSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN, + BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, + BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, + BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, + BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, + BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, + BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, + BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, + BA_FUNCTIONS_MESSAGE_ONERROR = BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, + BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, + BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, + BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, + BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, + BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, + BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, + BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, + + BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, + BA_FUNCTIONS_MESSAGE_WNDPROC, +}; + +typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_PROC)( + __in BA_FUNCTIONS_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + +struct BA_FUNCTIONS_CREATE_ARGS +{ + DWORD cbSize; + DWORD64 qwBAFunctionsAPIVersion; + BOOTSTRAPPER_CREATE_ARGS* pBootstrapperCreateArgs; +}; + +struct BA_FUNCTIONS_CREATE_RESULTS +{ + DWORD cbSize; + PFN_BA_FUNCTIONS_PROC pfnBAFunctionsProc; + LPVOID pvBAFunctionsProcContext; +}; + +struct BA_FUNCTIONS_ONTHEMELOADED_ARGS +{ + DWORD cbSize; + THEME* pTheme; + WIX_LOCALIZATION* pWixLoc; +}; + +struct BA_FUNCTIONS_ONTHEMELOADED_RESULTS +{ + DWORD cbSize; +}; + +struct BA_FUNCTIONS_WNDPROC_ARGS +{ + DWORD cbSize; + THEME* pTheme; + HWND hWnd; + UINT uMsg; + WPARAM wParam; + LPARAM lParam; +}; + +struct BA_FUNCTIONS_WNDPROC_RESULTS +{ + DWORD cbSize; + LRESULT lres; +}; + +typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_CREATE)( + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ); + +typedef void (WINAPI *PFN_BA_FUNCTIONS_DESTROY)(); + +#ifdef __cplusplus +} +#endif diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h new file mode 100644 index 00000000..dd190ee9 --- /dev/null +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -0,0 +1,700 @@ +#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 "dutil.h" +#include "locutil.h" +#include "thmutil.h" +#include "BAFunctions.h" +#include "IBAFunctions.h" +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +class CBalBaseBAFunctions : public IBAFunctions +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBAFunctions), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = static_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBootstrapperApplication + virtual STDMETHODIMP OnStartup() + { + return S_OK; + } + + virtual STDMETHODIMP OnShutdown( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemShutdown( + __in DWORD /*dwEndSession*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fInstalled*/, + __in DWORD /*cPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in DWORD64 /*dw64Version*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfIgnoreBundle*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateBegin( + __in_z LPCWSTR /*wzUpdateLocation*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfSkip*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdate( + __in_z LPCWSTR /*wzUpdateLocation*/, + __in DWORD64 /*dw64Size*/, + __in DWORD64 /*dw64Version*/, + __in_z LPCWSTR /*wzTitle*/, + __in_z LPCWSTR /*wzSummary*/, + __in_z LPCWSTR /*wzContentType*/, + __in_z LPCWSTR /*wzContent*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfStopProcessingUpdates*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateComplete( + __in HRESULT /*hrStatus*/, + __inout BOOL* /*pfIgnoreError*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in DWORD64 /*dw64Version*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectCompatibleMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/, + __in DWORD64 /*dw64CompatiblePackageVersion*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzUpgradeCode*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOL /*fPerMachine*/, + __in DWORD64 /*dw64Version*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectTargetMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*state*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanBegin( + __in DWORD /*cPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/, + __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanCompatibleMsiPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, + __in BOOTSTRAPPER_ACTION_STATE /*execute*/, + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanTargetMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, + __in BOOTSTRAPPER_ACTION_STATE /*execute*/, + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyBegin( + __in DWORD /*dwPhaseCount*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnElevateBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnElevateComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnProgress( + __in DWORD /*dwProgressPercentage*/, + __in DWORD /*dwOverallProgressPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return IDNOACTION; + } + + virtual STDMETHODIMP OnError( + __in BOOTSTRAPPER_ERROR_TYPE /*errorType*/, + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*dwCode*/, + __in_z LPCWSTR /*wzError*/, + __in DWORD /*dwUIHint*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* /*pResult*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRegisterBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRegisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cCachePayloads*/, + __in DWORD64 /*dw64PackageCacheSize*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireBegin( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/, + __in_z LPCWSTR /*wzSource*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireProgress( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnResolveSource( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in_z LPCWSTR /*wzLocalSource*/, + __in_z_opt LPCWSTR /*wzDownloadSource*/, + __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireComplete( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteBegin( + __in DWORD /*cExecutingPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOL /*fExecute*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecutePatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzTargetProductCode*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteProgress( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*dwProgressPercentage*/, + __in DWORD /*dwOverallProgressPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteMsiMessage( + __in_z LPCWSTR /*wzPackageId*/, + __in INSTALLMESSAGE /*messageType*/, + __in DWORD /*dwUIHint*/, + __in_z LPCWSTR /*wzMessage*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* /*pResult*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteFilesInUse( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cFiles*/, + __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, + __in int /*nRecommendation*/, + __inout int* /*pResult*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyComplete( + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnLaunchApprovedExeBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnLaunchApprovedExeComplete( + __in HRESULT /*hrStatus*/, + __in DWORD /*dwProcessId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP_(HRESULT) BAProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __inout HRESULT* /*phr*/, + __in_opt LPVOID /*pvContext*/ + ) + { + } + +public: // IBAFunctions + virtual STDMETHODIMP OnPlan( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnThemeLoaded( + THEME* pTheme, + WIX_LOCALIZATION* pWixLoc + ) + { + HRESULT hr = S_OK; + + m_pTheme = pTheme; + m_pWixLoc = pWixLoc; + + return hr; + } + + virtual STDMETHODIMP WndProc( + __in THEME* pTheme, + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam, + __inout LRESULT* plRes + ) + { + HRESULT hr = S_OK; + + *plRes = ThemeDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); + + return hr; + } + + virtual STDMETHODIMP BAFunctionsProc( + __in BA_FUNCTIONS_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + +protected: + CBalBaseBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs + ) + { + 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; + } + + virtual ~CBalBaseBAFunctions() + { + ReleaseNullObject(m_pEngine); + } + +private: + long m_cReferences; + +protected: + IBootstrapperEngine* m_pEngine; + HMODULE m_hModule; + BA_FUNCTIONS_CREATE_ARGS m_bafCreateArgs; + BOOTSTRAPPER_CREATE_ARGS m_baCreateArgs; + BOOTSTRAPPER_COMMAND m_command; + THEME* m_pTheme; + WIX_LOCALIZATION* m_pWixLoc; +}; diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h new file mode 100644 index 00000000..da0a71f7 --- /dev/null +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -0,0 +1,114 @@ +#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->pTheme, pArgs->pWixLoc); +} + +static HRESULT BalBaseBAFunctionsProcWndProc( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_WNDPROC_ARGS* pArgs, + __inout BA_FUNCTIONS_WNDPROC_RESULTS* pResults + ) +{ + return pBAFunctions->WndProc(pArgs->pTheme, pArgs->hWnd, pArgs->uMsg, pArgs->wParam, pArgs->lParam, &pResults->lres); +} + +/******************************************************************* +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( + __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_ONSYSTEMSHUTDOWN: + 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_ONDETECTCOMPATIBLEMSIPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE: + case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE: + case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN: + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE: + 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_ONRESOLVESOURCE: + 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: + 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; + } + } + + return hr; +} diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h new file mode 100644 index 00000000..ac354e7b --- /dev/null +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -0,0 +1,900 @@ +// 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 "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +#include "balutil.h" +#include "balretry.h" + +class CBalBaseBootstrapperApplication : public IBootstrapperApplication +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = static_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBootstrapperApplication + virtual STDMETHODIMP OnStartup() + { + return S_OK; + } + + virtual STDMETHODIMP OnShutdown( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemShutdown( + __in DWORD dwEndSession, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + + // Allow requests to shut down when critical or not applying. + *pfCancel = !(ENDSESSION_CRITICAL & dwEndSession || !m_fApplying); + + return hr; + } + + virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fInstalled*/, + __in DWORD /*cPackages*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in DWORD64 /*dw64Version*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfIgnoreBundle*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateBegin( + __in_z LPCWSTR /*wzUpdateLocation*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfSkip*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdate( + __in_z LPCWSTR /*wzUpdateLocation*/, + __in DWORD64 /*dw64Size*/, + __in DWORD64 /*dw64Version*/, + __in_z LPCWSTR /*wzTitle*/, + __in_z LPCWSTR /*wzSummary*/, + __in_z LPCWSTR /*wzContentType*/, + __in_z LPCWSTR /*wzContent*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfStopProcessingUpdates*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateComplete( + __in HRESULT /*hrStatus*/, + __inout BOOL* /*pfIgnoreError*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in DWORD64 /*dw64Version*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectCompatibleMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/, + __in DWORD64 /*dw64CompatiblePackageVersion*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzUpgradeCode*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOL /*fPerMachine*/, + __in DWORD64 /*dw64Version*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectTargetMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*state*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanBegin( + __in DWORD /*cPackages*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/, + __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanCompatibleMsiPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, + __in BOOTSTRAPPER_ACTION_STATE /*execute*/, + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanTargetMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, + __in BOOTSTRAPPER_ACTION_STATE /*execute*/, + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyBegin( + __in DWORD /*dwPhaseCount*/, + __inout BOOL* pfCancel + ) + { + m_fApplying = TRUE; + + m_dwProgressPercentage = 0; + m_dwOverallProgressPercentage = 0; + + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnElevateBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnElevateComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnProgress( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + m_dwProgressPercentage = dwProgressPercentage; + m_dwOverallProgressPercentage = dwOverallProgressPercentage; + + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded overall progress."); + + if (IDERROR == nResult) + { + hr = E_FAIL; + } + else if (IDCANCEL == nResult) + { + *pfCancel = TRUE; + } + } + + LExit: + *pfCancel |= CheckCanceled(); + return hr; + } + + virtual STDMETHODIMP OnError( + __in BOOTSTRAPPER_ERROR_TYPE errorType, + __in_z LPCWSTR wzPackageId, + __in DWORD dwCode, + __in_z LPCWSTR /*wzError*/, + __in DWORD /*dwUIHint*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* pResult + ) + { + BalRetryErrorOccurred(wzPackageId, dwCode); + + if (CheckCanceled()) + { + *pResult = IDCANCEL; + } + else if (BOOTSTRAPPER_DISPLAY_FULL == m_display) + { + if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType) + { + *pResult = IDTRYAGAIN; + } + } + + return S_OK; + } + + virtual STDMETHODIMP OnRegisterBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnRegisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cCachePayloads*/, + __in DWORD64 /*dw64PackageCacheSize*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireBegin( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/, + __in_z LPCWSTR /*wzSource*/, + __inout BOOL* pfCancel + ) + { + BalRetryStartPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId); + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireProgress( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + // 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) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded cache progress."); + + if (IDERROR == nResult) + { + hr = E_FAIL; + } + else if (IDCANCEL == nResult) + { + *pfCancel = TRUE; + } + } + + LExit: + *pfCancel |= CheckCanceled(); + return hr; + } + + virtual STDMETHODIMP OnResolveSource( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in_z LPCWSTR /*wzLocalSource*/, + __in_z_opt LPCWSTR /*wzDownloadSource*/, + __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireComplete( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction + ) + { + HRESULT hr = S_OK; + BOOL fRetry = FALSE; + + if (CheckCanceled()) + { + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); + } + + hr = BalRetryEndPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); + ExitOnFailure(hr, "BalRetryEndPackage for cache failed"); + + if (fRetry) + { + *pAction = BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY; + } + + LExit: + return hr; + } + + virtual STDMETHODIMP OnCacheVerifyBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction + ) + { + if (CheckCanceled()) + { + *pAction = BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_NONE; + } + + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction + ) + { + if (CheckCanceled()) + { + *pAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE; + } + + return S_OK; + } + + virtual STDMETHODIMP OnCacheComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteBegin( + __in DWORD /*cExecutingPackages*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageBegin( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, + __inout BOOL* pfCancel + ) + { + // Only track retry on execution (not rollback). + if (fExecute) + { + BalRetryStartPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL); + } + + m_fRollingBack = !fExecute; + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnExecutePatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzTargetProductCode*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnExecuteProgress( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*dwProgressPercentage*/, + __in DWORD /*dwOverallProgressPercentage*/, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + // 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) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded execute progress."); + + if (IDERROR == nResult) + { + hr = E_FAIL; + } + else if (IDCANCEL == nResult) + { + *pfCancel = TRUE; + } + } + + LExit: + *pfCancel |= CheckCanceled(); + return hr; + } + + virtual STDMETHODIMP OnExecuteMsiMessage( + __in_z LPCWSTR /*wzPackageId*/, + __in INSTALLMESSAGE /*messageType*/, + __in DWORD /*dwUIHint*/, + __in_z LPCWSTR /*wzMessage*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* pResult + ) + { + if (CheckCanceled()) + { + *pResult = IDCANCEL; + } + + return S_OK; + } + + virtual STDMETHODIMP OnExecuteFilesInUse( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cFiles*/, + __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, + __in int /*nRecommendation*/, + __inout int* pResult + ) + { + if (CheckCanceled()) + { + *pResult = IDCANCEL; + } + + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageComplete( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction + ) + { + HRESULT hr = S_OK; + BOOL fRetry = FALSE; + + if (CheckCanceled()) + { + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); + } + + hr = BalRetryEndPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL, hrStatus, &fRetry); + ExitOnFailure(hr, "BalRetryEndPackage for execute failed"); + + if (fRetry) + { + *pAction = BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RETRY; + } + + LExit: + return hr; + } + + virtual STDMETHODIMP OnExecuteComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyComplete( + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_APPLY_RESTART restart, + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction + ) + { + HRESULT hr = S_OK; + BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart; + BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BOOTSTRAPPER_RESTART_PROMPT >= m_restart; + + if (fRestartRequired && !fShouldBlockRestart) + { + *pAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART; + } + + m_fApplying = FALSE; + + return hr; + } + + virtual STDMETHODIMP OnLaunchApprovedExeBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnLaunchApprovedExeComplete( + __in HRESULT /*hrStatus*/, + __in DWORD /*dwProcessId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP_(HRESULT) BAProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __inout HRESULT* /*phr*/, + __in_opt LPVOID /*pvContext*/ + ) + { + } + +protected: + // + // PromptCancel - prompts the user to close (if not forced). + // + virtual BOOL PromptCancel( + __in HWND hWnd, + __in BOOL fForceCancel, + __in_z_opt LPCWSTR wzMessage, + __in_z_opt LPCWSTR wzCaption + ) + { + ::EnterCriticalSection(&m_csCanceled); + + // Only prompt the user to close if we have not canceled already. + if (!m_fCanceled) + { + if (fForceCancel) + { + m_fCanceled = TRUE; + } + else + { + m_fCanceled = (IDYES == ::MessageBoxW(hWnd, wzMessage, wzCaption, MB_YESNO | MB_ICONEXCLAMATION)); + } + } + + ::LeaveCriticalSection(&m_csCanceled); + + return m_fCanceled; + } + + // + // CheckCanceled - waits if the cancel dialog is up and checks to see if the user canceled the operation. + // + BOOL CheckCanceled() + { + ::EnterCriticalSection(&m_csCanceled); + ::LeaveCriticalSection(&m_csCanceled); + return m_fRollingBack ? FALSE : m_fCanceled; + } + + BOOL IsRollingBack() + { + return m_fRollingBack; + } + + BOOL IsCanceled() + { + return m_fCanceled; + } + + CBalBaseBootstrapperApplication( + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __in DWORD dwRetryCount = 0, + __in DWORD dwRetryTimeout = 1000 + ) + { + m_cReferences = 1; + m_display = pArgs->pCommand->display; + m_restart = pArgs->pCommand->restart; + + pEngine->AddRef(); + m_pEngine = pEngine; + + ::InitializeCriticalSection(&m_csCanceled); + m_fCanceled = FALSE; + m_fApplying = FALSE; + m_fRollingBack = FALSE; + + BalRetryInitialize(dwRetryCount, dwRetryTimeout); + } + + virtual ~CBalBaseBootstrapperApplication() + { + BalRetryUninitialize(); + ::DeleteCriticalSection(&m_csCanceled); + + ReleaseNullObject(m_pEngine); + } + +protected: + CRITICAL_SECTION m_csCanceled; + BOOL m_fCanceled; + +private: + long m_cReferences; + BOOTSTRAPPER_DISPLAY m_display; + BOOTSTRAPPER_RESTART m_restart; + IBootstrapperEngine* m_pEngine; + + BOOL m_fApplying; + BOOL m_fRollingBack; + + DWORD m_dwProgressPercentage; + DWORD m_dwOverallProgressPercentage; +}; diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h new file mode 100644 index 00000000..4b8f4ca7 --- /dev/null +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -0,0 +1,698 @@ +#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->fInstalled, 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); +} + +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 BalBaseBAProcOnSystemShutdown( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMSHUTDOWN_ARGS* pArgs, + __inout BA_ONSYSTEMSHUTDOWN_RESULTS* pResults + ) +{ + return pBA->OnSystemShutdown(pArgs->dwEndSession, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( + __in IBootstrapperApplication* pBA, + __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, + __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults + ) +{ + return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, &pResults->fCancel, &pResults->fIgnoreBundle); +} + +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->dw64Version, 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->dw64Version, pArgs->operation, &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->dw64CompatiblePackageVersion, &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->dw64Version, pArgs->operation, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnDetectTargetMsiPackage( + __in IBootstrapperApplication* pBA, + __in BA_ONDETECTTARGETMSIPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTTARGETMSIPACKAGE_RESULTS* pResults + ) +{ + return pBA->OnDetectTargetMsiPackage(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); +} + +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 BalBaseBAProcOnPlanPackageBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONPLANPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults + ) +{ + return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->recommendedState, &pResults->requestedState, &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->dw64CompatiblePackageVersion, pArgs->recommendedState, &pResults->requestedState, &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->state, pArgs->requested, pArgs->execute, pArgs->rollback); +} + +static HRESULT BalBaseBAProcOnPlanTargetMsiPackage( + __in IBootstrapperApplication* pBA, + __in BA_ONPLANTARGETMSIPACKAGE_ARGS* pArgs, + __inout BA_ONPLANTARGETMSIPACKAGE_RESULTS* pResults + ) +{ + return pBA->OnPlanTargetMsiPackage(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->state, pArgs->requested, pArgs->execute, pArgs->rollback); +} + +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(&pResults->fCancel); +} + +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, &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->operation, pArgs->wzSource, &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 BalBaseBAProcOnResolveSource( + __in IBootstrapperApplication* pBA, + __in BA_ONRESOLVESOURCE_ARGS* pArgs, + __inout BA_ONRESOLVESOURCE_RESULTS* pResults + ) +{ + return pBA->OnResolveSource(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->recommendation, &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 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, &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, &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 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(&pResults->fCancel); +} + +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); +} + +/******************************************************************* +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_ONSYSTEMSHUTDOWN: + hr = BalBaseBAProcOnSystemShutdown(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: + hr = BalBaseBAProcOnDetectForwardCompatibleBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + 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_ONDETECTCOMPATIBLEMSIPACKAGE: + hr = BalBaseBAProcOnDetectCompatiblePackage(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_ONDETECTTARGETMSIPACKAGE: + hr = BalBaseBAProcOnDetectTargetMsiPackage(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_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_ONPLANTARGETMSIPACKAGE: + hr = BalBaseBAProcOnPlanTargetMsiPackage(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_ONRESOLVESOURCE: + hr = BalBaseBAProcOnResolveSource(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_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; + } + } + + pBA->BAProcFallback(message, pvArgs, pvResults, &hr, pvContext); + + return hr; +} diff --git a/src/balutil/inc/BalBootstrapperEngine.h b/src/balutil/inc/BalBootstrapperEngine.h new file mode 100644 index 00000000..45131d98 --- /dev/null +++ b/src/balutil/inc/BalBootstrapperEngine.h @@ -0,0 +1,17 @@ +// 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/balutil/inc/IBAFunctions.h b/src/balutil/inc/IBAFunctions.h new file mode 100644 index 00000000..7d8a07fa --- /dev/null +++ b/src/balutil/inc/IBAFunctions.h @@ -0,0 +1,34 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBAFunctions, IBootstrapperApplication, "0FB445ED-17BD-49C7-BE19-479776F8AE96") +{ + // OnThemeLoaded - Called after the BA finished loading all the controls for the theme. + // + STDMETHOD(OnThemeLoaded)( + THEME* pTheme, + WIX_LOCALIZATION* pWixLoc + ) = 0; + + // WndProc - Called if the BA hasn't handled the message. + // The implementation must either return E_NOTIMPL or call ThemeDefWindowProc for unhandled messages. + // + STDMETHOD(WndProc)( + __in THEME* pTheme, + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam, + __inout LRESULT* plRes + ) = 0; + + // BAFunctionsProc - The PFN_BA_FUNCTIONS_PROC can call this method to give the BAFunctions raw access to the callback from WixStdBA. + // This might be used to help the BAFunctions support more than one version of the engine/WixStdBA. + STDMETHOD(BAFunctionsProc)( + __in BA_FUNCTIONS_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; +}; diff --git a/src/balutil/inc/balcondition.h b/src/balutil/inc/balcondition.h new file mode 100644 index 00000000..677c593f --- /dev/null +++ b/src/balutil/inc/balcondition.h @@ -0,0 +1,58 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _BAL_CONDITION +{ + LPWSTR sczCondition; + LPWSTR sczMessage; +} BAL_CONDITION; + + +typedef struct _BAL_CONDITIONS +{ + BAL_CONDITION* rgConditions; + DWORD cConditions; +} BAL_CONDITIONS; + + +/******************************************************************* + BalConditionsParseFromXml - loads the conditions from the UX manifest. + +********************************************************************/ +DAPI_(HRESULT) BalConditionsParseFromXml( + __in BAL_CONDITIONS* pConditions, + __in IXMLDOMDocument* pixdManifest, + __in_opt WIX_LOCALIZATION* pWixLoc + ); + + +/******************************************************************* + BalConditionEvaluate - evaluates condition against the provided IBurnCore. + + NOTE: psczMessage is optional. +********************************************************************/ +DAPI_(HRESULT) BalConditionEvaluate( + __in BAL_CONDITION* pCondition, + __in IBootstrapperEngine* pEngine, + __out BOOL* pfResult, + __out_z_opt LPWSTR* psczMessage + ); + + +/******************************************************************* + BalConditionsUninitialize - uninitializes any conditions previously loaded. + +********************************************************************/ +DAPI_(void) BalConditionsUninitialize( + __in BAL_CONDITIONS* pConditions + ); + + +#ifdef __cplusplus +} +#endif diff --git a/src/balutil/inc/balinfo.h b/src/balutil/inc/balinfo.h new file mode 100644 index 00000000..be4b75d0 --- /dev/null +++ b/src/balutil/inc/balinfo.h @@ -0,0 +1,107 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum BAL_INFO_PACKAGE_TYPE +{ + BAL_INFO_PACKAGE_TYPE_UNKNOWN, + BAL_INFO_PACKAGE_TYPE_EXE, + BAL_INFO_PACKAGE_TYPE_MSI, + BAL_INFO_PACKAGE_TYPE_MSP, + BAL_INFO_PACKAGE_TYPE_MSU, + BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE, + BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON, + BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, +} BAL_INFO_PACKAGE_TYPE; + +typedef enum BAL_INFO_CACHE_TYPE +{ + BAL_INFO_CACHE_TYPE_NO, + BAL_INFO_CACHE_TYPE_YES, + BAL_INFO_CACHE_TYPE_ALWAYS, +} BAL_INFO_CACHE_TYPE; + + +typedef struct _BAL_INFO_PACKAGE +{ + LPWSTR sczId; + LPWSTR sczDisplayName; + LPWSTR sczDescription; + BAL_INFO_PACKAGE_TYPE type; + BOOL fPermanent; + BOOL fVital; + BOOL fDisplayInternalUI; + LPWSTR sczProductCode; + LPWSTR sczUpgradeCode; + LPWSTR sczVersion; + LPWSTR sczInstallCondition; + BAL_INFO_CACHE_TYPE cacheType; +} BAL_INFO_PACKAGE; + + +typedef struct _BAL_INFO_PACKAGES +{ + BAL_INFO_PACKAGE* rgPackages; + DWORD cPackages; +} BAL_INFO_PACKAGES; + + +typedef struct _BAL_INFO_BUNDLE +{ + BOOL fPerMachine; + LPWSTR sczName; + LPWSTR sczLogVariable; + BAL_INFO_PACKAGES packages; +} BAL_INFO_BUNDLE; + + +/******************************************************************* + BalInfoParseFromXml - loads the bundle and package info from the UX + manifest. + +********************************************************************/ +DAPI_(HRESULT) BalInfoParseFromXml( + __in BAL_INFO_BUNDLE* pBundle, + __in IXMLDOMDocument* pixdManifest + ); + + +/******************************************************************* + BalInfoAddRelatedBundleAsPackage - adds a related bundle as a package. + + ********************************************************************/ +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in BOOL fPerMachine + ); + + +/******************************************************************* + BalInfoFindPackageById - finds a package by its id. + + ********************************************************************/ +DAPI_(HRESULT) BalInfoFindPackageById( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __out BAL_INFO_PACKAGE** ppPackage + ); + + +/******************************************************************* + BalInfoUninitialize - uninitializes any info previously loaded. + +********************************************************************/ +DAPI_(void) BalInfoUninitialize( + __in BAL_INFO_BUNDLE* pBundle + ); + + +#ifdef __cplusplus +} +#endif diff --git a/src/balutil/inc/balretry.h b/src/balutil/inc/balretry.h new file mode 100644 index 00000000..040ab4ae --- /dev/null +++ b/src/balutil/inc/balretry.h @@ -0,0 +1,65 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum BALRETRY_TYPE +{ + BALRETRY_TYPE_CACHE, + BALRETRY_TYPE_EXECUTE, +} BALRETRY_TYPE; + +/******************************************************************* + BalRetryInitialize - initialize the retry count and timeout between + retries (in milliseconds). +********************************************************************/ +DAPI_(void) BalRetryInitialize( + __in DWORD dwMaxRetries, + __in DWORD dwTimeout + ); + +/******************************************************************* + BalRetryUninitialize - call to cleanup any memory allocated during + use of the retry utility. +********************************************************************/ +DAPI_(void) BalRetryUninitialize(); + +/******************************************************************* + BalRetryStartPackage - call when a package begins to be modified. If + the package is being retried, the function will + wait the specified timeout. +********************************************************************/ +DAPI_(void) BalRetryStartPackage( + __in BALRETRY_TYPE type, + __in_z_opt LPCWSTR wzPackageId, + __in_z_opt LPCWSTR wzPayloadId + ); + +/******************************************************************* + BalRetryErrorOccured - call when an error occurs for the retry utility + to consider. +********************************************************************/ +DAPI_(void) BalRetryErrorOccurred( + __in_z_opt LPCWSTR wzPackageId, + __in DWORD dwError + ); + +/******************************************************************* + BalRetryEndPackage - returns IDRETRY is a retry is recommended or + IDNOACTION if a retry is not recommended. +********************************************************************/ +DAPI_(HRESULT) BalRetryEndPackage( + __in BALRETRY_TYPE type, + __in_z_opt LPCWSTR wzPackageId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ); + + +#ifdef __cplusplus +} +#endif diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h new file mode 100644 index 00000000..0fbaab97 --- /dev/null +++ b/src/balutil/inc/balutil.h @@ -0,0 +1,165 @@ +#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 "dutil.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define BalExitOnFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnRootFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnNullWithLastError(p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } + +#define FACILITY_WIX 500 + +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); + + +/******************************************************************* + BalInitialize - remembers the engine interface to enable logging and + other functions. + +********************************************************************/ +DAPI_(void) BalInitialize( + __in IBootstrapperEngine* pEngine + ); + +/******************************************************************* + BalInitializeFromCreateArgs - convenience function to call BalBootstrapperEngineCreate + then pass it along to BalInitialize. + +********************************************************************/ +DAPI_(HRESULT) BalInitializeFromCreateArgs( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __out IBootstrapperEngine** ppEngine + ); + +/******************************************************************* + BalUninitialize - cleans up utility layer internals. + +********************************************************************/ +DAPI_(void) BalUninitialize(); + +/******************************************************************* + BalManifestLoad - loads the Application manifest into an XML document. + +********************************************************************/ +DAPI_(HRESULT) BalManifestLoad( + __in HMODULE hUXModule, + __out IXMLDOMDocument** ppixdManifest + ); + +/******************************************************************* +BalEvaluateCondition - evaluates a condition using variables in the engine. + +********************************************************************/ +DAPI_(HRESULT) BalEvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ); + +/******************************************************************* +BalFormatString - formats a string using variables in the engine. + + Note: Use StrFree() to release psczOut. +********************************************************************/ +DAPI_(HRESULT) BalFormatString( + __in_z LPCWSTR wzFormat, + __inout LPWSTR* psczOut + ); + +/******************************************************************* +BalGetNumericVariable - gets a number from a variable in the engine. + + Note: Returns E_NOTFOUND if variable does not exist. +********************************************************************/ +DAPI_(HRESULT) BalGetNumericVariable( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ); + +/******************************************************************* +BalSetNumericVariable - sets a numeric variable in the engine. + +********************************************************************/ +DAPI_(HRESULT) BalSetNumericVariable( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ); + +/******************************************************************* +BalStringVariableExists - checks if a string variable exists in the engine. + +********************************************************************/ +DAPI_(BOOL) BalStringVariableExists( + __in_z LPCWSTR wzVariable + ); + +/******************************************************************* +BalGetStringVariable - gets a string from a variable in the engine. + + Note: Use StrFree() to release psczValue. +********************************************************************/ +DAPI_(HRESULT) BalGetStringVariable( + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue + ); + +/******************************************************************* +BalSetStringVariable - sets a string variable in the engine. + +********************************************************************/ +DAPI_(HRESULT) BalSetStringVariable( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ); + +/******************************************************************* + BalLog - logs a message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BalLog( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* + BalLogError - logs an error message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BalLogError( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* +BalLogId - logs a message with the engine with a string embedded in a + MESSAGETABLE resource. + +********************************************************************/ +DAPIV_(HRESULT) BalLogId( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + ... + ); + +DAPI_(HRESULT) BalLogIdArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + __in va_list args + ); + +#ifdef __cplusplus +} +#endif diff --git a/src/balutil/precomp.h b/src/balutil/precomp.h new file mode 100644 index 00000000..89607416 --- /dev/null +++ b/src/balutil/precomp.h @@ -0,0 +1,31 @@ +#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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +#include "BAFunctions.h" +#include "IBAFunctions.h" + +#include "balutil.h" +#include "BalBootstrapperEngine.h" +#include "balcondition.h" +#include "balinfo.h" +#include "balretry.h" -- cgit v1.2.3-55-g6feb From 1dc08c5ec8e08f96e6e2d76a88bca1ed9d71a2d3 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 29 Dec 2018 22:26:48 -0600 Subject: Integrate into latest v4. --- .editorconfig | 37 +++++++++++ appveyor.cmd | 13 ++++ appveyor.yml | 35 ++++++++++ balutil.sln | 31 +++++++++ nuget.config | 8 +++ src/Cpp.Build.props | 100 +++++++++++++++++++++++++++++ src/Directory.Build.props | 26 ++++++++ src/Directory.Build.targets | 48 ++++++++++++++ src/NativeMultiTargeting.Build.props | 10 +++ src/balutil/balutil.nuspec | 22 +++++++ src/balutil/balutil.vcxproj | 94 +++++++++++++++++++++++++++ src/balutil/build/WixToolset.BalUtil.props | 23 +++++++ src/balutil/packages.config | 6 ++ src/balutil/precomp.cpp | 3 + version.json | 11 ++++ 15 files changed, 467 insertions(+) create mode 100644 .editorconfig create mode 100644 appveyor.cmd create mode 100644 appveyor.yml create mode 100644 balutil.sln create mode 100644 nuget.config create mode 100644 src/Cpp.Build.props create mode 100644 src/Directory.Build.props create mode 100644 src/Directory.Build.targets create mode 100644 src/NativeMultiTargeting.Build.props create mode 100644 src/balutil/balutil.nuspec create mode 100644 src/balutil/balutil.vcxproj create mode 100644 src/balutil/build/WixToolset.BalUtil.props create mode 100644 src/balutil/packages.config create mode 100644 src/balutil/precomp.cpp create mode 100644 version.json (limited to 'src') diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,37 @@ +# 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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/appveyor.cmd b/appveyor.cmd new file mode 100644 index 00000000..ee397c4a --- /dev/null +++ b/appveyor.cmd @@ -0,0 +1,13 @@ +@setlocal +@pushd %~dp0 + +nuget restore + +msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v140_xp + +msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v141_xp + +msbuild -p:Configuration=Release -t:Pack src\balutil\balutil.vcxproj + +@popd +@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..d55322da --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,35 @@ +# 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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +image: Visual Studio 2017 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/balutil.sln b/balutil.sln new file mode 100644 index 00000000..58f61391 --- /dev/null +++ b/balutil.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.12 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balutil.vcxproj", "{EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.ActiveCfg = Debug|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.Build.0 = Debug|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.ActiveCfg = Debug|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.Build.0 = Debug|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.ActiveCfg = Release|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.Build.0 = Release|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.ActiveCfg = Release|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8741FA43-6BD2-40F9-ABA5-A5BD466A6518} + EndGlobalSection +EndGlobal diff --git a/nuget.config b/nuget.config new file mode 100644 index 00000000..790be2b0 --- /dev/null +++ b/nuget.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props new file mode 100644 index 00000000..296b36ca --- /dev/null +++ b/src/Cpp.Build.props @@ -0,0 +1,100 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..e853e22d --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,26 @@ + + + + + + Debug + false + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + diff --git a/src/NativeMultiTargeting.Build.props b/src/NativeMultiTargeting.Build.props new file mode 100644 index 00000000..1ff46559 --- /dev/null +++ b/src/NativeMultiTargeting.Build.props @@ -0,0 +1,10 @@ + + + + + + + $(BaseIntermediateOutputPath)$(Configuration)\$(PlatformToolset)\$(PlatformTarget)\ + $(OutputPath)$(PlatformToolset)\$(PlatformTarget)\ + + diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec new file mode 100644 index 00000000..fb07def8 --- /dev/null +++ b/src/balutil/balutil.nuspec @@ -0,0 +1,22 @@ + + + + $id$ + $version$ + $authors$ + $authors$ + + https://licenses.nuget.org/MS-RL + https://github.com/wixtoolset/balutil + false + $description$ + $copyright$ + + + + + + + + + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj new file mode 100644 index 00000000..a8b97615 --- /dev/null +++ b/src/balutil/balutil.vcxproj @@ -0,0 +1,94 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} + StaticLibrary + balutil + v141 + MultiByte + WiX Toolset Bootstrapper Application Layer native utility library + + + + + + + + + + + + + + + $(ProjectDir)..\inc + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + diff --git a/src/balutil/build/WixToolset.BalUtil.props b/src/balutil/build/WixToolset.BalUtil.props new file mode 100644 index 00000000..6275e0e8 --- /dev/null +++ b/src/balutil/build/WixToolset.BalUtil.props @@ -0,0 +1,23 @@ + + + + + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + + + $(MSBuildThisFileDirectory)native\lib\v140\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + + + + $(MSBuildThisFileDirectory)native\lib\v141\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + + diff --git a/src/balutil/packages.config b/src/balutil/packages.config new file mode 100644 index 00000000..52c84cf0 --- /dev/null +++ b/src/balutil/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/balutil/precomp.cpp b/src/balutil/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/balutil/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/version.json b/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} -- cgit v1.2.3-55-g6feb From 4badef4fea21e91fb0b1558cf07260ee82131562 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 30 Dec 2018 20:40:11 -0600 Subject: Fix lib path in WixToolset.BalUtil.props and add dependencies in balutil.nuspec. --- src/balutil/balutil.nuspec | 4 ++++ src/balutil/build/WixToolset.BalUtil.props | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec index fb07def8..67ed9bde 100644 --- a/src/balutil/balutil.nuspec +++ b/src/balutil/balutil.nuspec @@ -11,6 +11,10 @@ false $description$ $copyright$ + + + + diff --git a/src/balutil/build/WixToolset.BalUtil.props b/src/balutil/build/WixToolset.BalUtil.props index 6275e0e8..0c92a3fb 100644 --- a/src/balutil/build/WixToolset.BalUtil.props +++ b/src/balutil/build/WixToolset.BalUtil.props @@ -12,12 +12,12 @@ - $(MSBuildThisFileDirectory)native\lib\v140\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + $(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) - $(MSBuildThisFileDirectory)native\lib\v141\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) -- cgit v1.2.3-55-g6feb From 9caf38b96e4b1955eed0f391cbcbf83064c23b31 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 13 Jan 2019 19:27:18 -0600 Subject: Update to latest Cpp.Build.props for locating latest Win10 SDK. --- src/Cpp.Build.props | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 296b36ca..0e00132b 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -8,6 +8,10 @@ $(OutputPath)$(Platform)\ + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + $(DisableSpecificCompilerWarnings) @@ -16,7 +20,7 @@ WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) Use precomp.h - StdCall + StdCall true false -YlprecompDefine -- cgit v1.2.3-55-g6feb From ca118d0123624e4e1523eeb7a54eb56364d5876e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 11 Dec 2019 11:25:32 +1100 Subject: Update to latest repo-template. --- src/Cpp.Build.props | 2 +- src/Directory.Build.props | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 0e00132b..44a042c7 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -8,7 +8,7 @@ $(OutputPath)$(Platform)\ - + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e853e22d..a22f4470 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,6 +8,7 @@ Debug false + MSB3246 $(MSBuildProjectName) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) @@ -21,6 +22,7 @@ WiX Toolset - + + -- cgit v1.2.3-55-g6feb From 62352fabd541aaa9d0a2c957c4bdd4b9c682df9c Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 11 Dec 2019 19:34:47 +1100 Subject: Import files from BootstrapperCore repo. --- .../BaseBootstrapperApplicationFactory.cs | 16 + src/WixToolset.Mba.Core/BootstrapperApplication.cs | 1591 ++++++++++++++++ .../BootstrapperApplicationData.cs | 63 + .../BootstrapperApplicationFactory.cs | 86 + .../BootstrapperApplicationFactoryAttribute.cs | 35 + src/WixToolset.Mba.Core/BootstrapperCommand.cs | 107 ++ .../BootstrapperSectionGroup.cs | 29 + src/WixToolset.Mba.Core/BundleInfo.cs | 67 + src/WixToolset.Mba.Core/Engine.cs | 516 ++++++ src/WixToolset.Mba.Core/EventArgs.cs | 1903 ++++++++++++++++++++ src/WixToolset.Mba.Core/Exceptions.cs | 145 ++ src/WixToolset.Mba.Core/HostSection.cs | 47 + .../IBootstrapperApplicationData.cs | 12 + .../IBootstrapperApplicationFactory.cs | 52 + src/WixToolset.Mba.Core/IBootstrapperCommand.cs | 63 + src/WixToolset.Mba.Core/IBundleInfo.cs | 16 + .../IDefaultBootstrapperApplication.cs | 65 + src/WixToolset.Mba.Core/IEngine.cs | 176 ++ src/WixToolset.Mba.Core/IPackageInfo.cs | 20 + src/WixToolset.Mba.Core/IVariables.cs | 27 + src/WixToolset.Mba.Core/NativeMethods.cs | 37 + src/WixToolset.Mba.Core/PackageInfo.cs | 181 ++ .../SupportedFrameworkElement.cs | 47 + .../SupportedFrameworkElementCollection.cs | 36 + .../WixToolset.BootstrapperCore.config | 26 + src/balutil/inc/IBootstrapperApplicationFactory.h | 14 + 26 files changed, 5377 insertions(+) create mode 100644 src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs create mode 100644 src/WixToolset.Mba.Core/BootstrapperApplication.cs create mode 100644 src/WixToolset.Mba.Core/BootstrapperApplicationData.cs create mode 100644 src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs create mode 100644 src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs create mode 100644 src/WixToolset.Mba.Core/BootstrapperCommand.cs create mode 100644 src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs create mode 100644 src/WixToolset.Mba.Core/BundleInfo.cs create mode 100644 src/WixToolset.Mba.Core/Engine.cs create mode 100644 src/WixToolset.Mba.Core/EventArgs.cs create mode 100644 src/WixToolset.Mba.Core/Exceptions.cs create mode 100644 src/WixToolset.Mba.Core/HostSection.cs create mode 100644 src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs create mode 100644 src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs create mode 100644 src/WixToolset.Mba.Core/IBootstrapperCommand.cs create mode 100644 src/WixToolset.Mba.Core/IBundleInfo.cs create mode 100644 src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs create mode 100644 src/WixToolset.Mba.Core/IEngine.cs create mode 100644 src/WixToolset.Mba.Core/IPackageInfo.cs create mode 100644 src/WixToolset.Mba.Core/IVariables.cs create mode 100644 src/WixToolset.Mba.Core/NativeMethods.cs create mode 100644 src/WixToolset.Mba.Core/PackageInfo.cs create mode 100644 src/WixToolset.Mba.Core/SupportedFrameworkElement.cs create mode 100644 src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs create mode 100644 src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config create mode 100644 src/balutil/inc/IBootstrapperApplicationFactory.h (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs new file mode 100644 index 00000000..e9b60929 --- /dev/null +++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -0,0 +1,16 @@ +// 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.BootstrapperCore +{ + public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory + { + public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) + { + IEngine engine = new Engine(pEngine); + IBootstrapperCommand bootstrapperCommand = command.GetBootstrapperCommand(); + return this.Create(engine, bootstrapperCommand); + } + + protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); + } +} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs new file mode 100644 index 00000000..c08a60c7 --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -0,0 +1,1591 @@ +// 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.BootstrapperCore +{ + using System; + using System.Runtime.InteropServices; + using System.Threading; + + /// + /// The default bootstrapper application. + /// + [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; + + private bool applying; + + /// + /// Creates a new instance of the class. + /// + protected BootstrapperApplication(IEngine engine) + { + this.engine = engine; + this.applying = false; + this.asyncExecution = true; + } + + /// + /// Fired when the engine is starting up the bootstrapper application. + /// + public event EventHandler Startup; + + /// + /// Fired when the engine is shutting down the bootstrapper application. + /// + public event EventHandler Shutdown; + + /// + /// Fired when the system is shutting down or user is logging off. + /// + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// By default setup will prevent shutting down or logging off between + /// and . + /// Derivatives can change this behavior by overriding + /// or handling . + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// This event may be fired on a different thread. + /// + public event EventHandler SystemShutdown; + + /// + /// Fired when the overall detection phase has begun. + /// + public event EventHandler DetectBegin; + + /// + /// Fired when a forward compatible bundle is detected. + /// + public event EventHandler DetectForwardCompatibleBundle; + + /// + /// Fired when the update detection phase has begun. + /// + public event EventHandler DetectUpdateBegin; + + /// + /// Fired when the update detection has found a potential update candidate. + /// + public event EventHandler DetectUpdate; + + /// + /// Fired when the update detection phase has completed. + /// + public event EventHandler DetectUpdateComplete; + + /// + /// Fired when a related bundle has been detected for a bundle. + /// + public event EventHandler DetectRelatedBundle; + + /// + /// Fired when the detection for a specific package has begun. + /// + public event EventHandler DetectPackageBegin; + + /// + /// Fired when a package was not detected but a package using the same provider key was. + /// + public event EventHandler DetectCompatibleMsiPackage; + + /// + /// Fired when a related MSI package has been detected for a package. + /// + public event EventHandler DetectRelatedMsiPackage; + + /// + /// Fired when an MSP package detects a target MSI has been detected. + /// + public event EventHandler DetectTargetMsiPackage; + + /// + /// Fired when a feature in an MSI package has been detected. + /// + public event EventHandler DetectMsiFeature; + + /// + /// Fired when the detection for a specific package has completed. + /// + public event EventHandler DetectPackageComplete; + + /// + /// Fired when the detection phase has completed. + /// + public event EventHandler DetectComplete; + + /// + /// Fired when the engine has begun planning the installation. + /// + public event EventHandler PlanBegin; + + /// + /// Fired when the engine has begun planning for a related bundle. + /// + public event EventHandler PlanRelatedBundle; + + /// + /// Fired when the engine has begun planning the installation of a specific package. + /// + public event EventHandler PlanPackageBegin; + + /// + /// Fired when the engine plans a new, compatible package using the same provider key. + /// + public event EventHandler PlanCompatibleMsiPackageBegin; + + /// + /// Fired when the engine has completed planning the installation of a specific package. + /// + public event EventHandler PlanCompatibleMsiPackageComplete; + + /// + /// Fired when the engine is about to plan the target MSI of a MSP package. + /// + public event EventHandler PlanTargetMsiPackage; + + /// + /// Fired when the engine is about to plan a feature in an MSI package. + /// + public event EventHandler PlanMsiFeature; + + /// + /// Fired when the engine has completed planning the installation of a specific package. + /// + public event EventHandler PlanPackageComplete; + + /// + /// Fired when the engine has completed planning the installation. + /// + public event EventHandler PlanComplete; + + /// + /// Fired when the engine has begun installing the bundle. + /// + public event EventHandler ApplyBegin; + + /// + /// Fired when the engine is about to start the elevated process. + /// + public event EventHandler ElevateBegin; + + /// + /// Fired when the engine has completed starting the elevated process. + /// + public event EventHandler ElevateComplete; + + /// + /// Fired when the engine has changed progress for the bundle installation. + /// + public event EventHandler Progress; + + /// + /// Fired when the engine has encountered an error. + /// + public event EventHandler Error; + + /// + /// Fired when the engine has begun registering the location and visibility of the bundle. + /// + public event EventHandler RegisterBegin; + + /// + /// Fired when the engine has completed registering the location and visibility of the bundle. + /// + public event EventHandler RegisterComplete; + + /// + /// Fired when the engine has begun removing the registration for the location and visibility of the bundle. + /// + public event EventHandler UnregisterBegin; + + /// + /// Fired when the engine has completed removing the registration for the location and visibility of the bundle. + /// + public event EventHandler UnregisterComplete; + + /// + /// Fired when the engine has begun caching the installation sources. + /// + public event EventHandler CacheBegin; + + /// + /// Fired when the engine has begun caching a specific package. + /// + public event EventHandler CachePackageBegin; + + /// + /// Fired when the engine has begun acquiring the installation sources. + /// + public event EventHandler CacheAcquireBegin; + + /// + /// Fired when the engine has progress acquiring the installation sources. + /// + public event EventHandler CacheAcquireProgress; + + /// + /// Fired by the engine to allow the BA to change the source + /// using or . + /// + public event EventHandler ResolveSource; + + /// + /// Fired when the engine has completed the acquisition of the installation sources. + /// + public event EventHandler CacheAcquireComplete; + + /// + /// Fired when the engine begins the verification of the acquired installation sources. + /// + public event EventHandler CacheVerifyBegin; + + /// + /// Fired when the engine complete the verification of the acquired installation sources. + /// + public event EventHandler CacheVerifyComplete; + + /// + /// Fired when the engine has completed caching a specific package. + /// + public event EventHandler CachePackageComplete; + + /// + /// Fired after the engine has cached the installation sources. + /// + public event EventHandler CacheComplete; + + /// + /// Fired when the engine has begun installing packages. + /// + public event EventHandler ExecuteBegin; + + /// + /// Fired when the engine has begun installing a specific package. + /// + public event EventHandler ExecutePackageBegin; + + /// + /// Fired when the engine executes one or more patches targeting a product. + /// + public event EventHandler ExecutePatchTarget; + + /// + /// Fired when Windows Installer sends an installation message. + /// + public event EventHandler ExecuteMsiMessage; + + /// + /// Fired when Windows Installer sends a files in use installation message. + /// + public event EventHandler ExecuteFilesInUse; + + /// + /// Fired when the engine has completed installing a specific package. + /// + public event EventHandler ExecutePackageComplete; + + /// + /// Fired when the engine has completed installing packages. + /// + public event EventHandler ExecuteComplete; + + /// + /// Fired when the engine has completed installing the bundle. + /// + public event EventHandler ApplyComplete; + + /// + /// Fired by the engine while executing on payload. + /// + public event EventHandler ExecuteProgress; + + /// + /// Fired when the engine is about to launch the preapproved executable. + /// + public event EventHandler LaunchApprovedExeBegin; + + /// + /// Fired when the engine has completed launching the preapproved executable. + /// + public event EventHandler LaunchApprovedExeComplete; + + /// + /// Entry point that is called when the bootstrapper application is ready to run. + /// + protected abstract void Run(); + + /// + /// Called by the engine on startup of the bootstrapper application. + /// + /// Additional arguments for this event. + protected virtual void OnStartup(StartupEventArgs args) + { + EventHandler handler = this.Startup; + if (null != handler) + { + handler(this, args); + } + + if (this.asyncExecution) + { + 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(); + } + else + { + this.engine.Log(LogLevel.Verbose, "Creating BA thread to run synchronously."); + this.Run(); + } + } + + /// + /// Called by the engine to uninitialize the BA. + /// + /// Additional arguments for this event. + protected virtual void OnShutdown(ShutdownEventArgs args) + { + EventHandler handler = this.Shutdown; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the system is shutting down or the user is logging off. + /// + /// Additional arguments for this event. + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// By default setup will prevent shutting down or logging off between + /// and . + /// Derivatives can change this behavior by overriding + /// or handling . + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// This method may be called on a different thread. + /// + protected virtual void OnSystemShutdown(SystemShutdownEventArgs args) + { + EventHandler handler = this.SystemShutdown; + if (null != handler) + { + handler(this, args); + } + else if (null != args) + { + // Allow requests to shut down when critical or not applying. + bool critical = EndSessionReasons.Critical == (EndSessionReasons.Critical & args.Reasons); + args.Cancel = !critical && this.applying; + } + } + + /// + /// Called when the overall detection phase has begun. + /// + /// Additional arguments for this event. + protected virtual void OnDetectBegin(DetectBeginEventArgs args) + { + EventHandler handler = this.DetectBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the update detection phase has begun. + /// + /// Additional arguments for this event. + protected virtual void OnDetectForwardCompatibleBundle(DetectForwardCompatibleBundleEventArgs args) + { + EventHandler handler = this.DetectForwardCompatibleBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the update detection phase has begun. + /// + /// Additional arguments for this event. + protected virtual void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) + { + EventHandler handler = this.DetectUpdateBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Fired when the update detection has found a potential update candidate. + /// + /// Additional arguments for this event. + protected virtual void OnDetectUpdate(DetectUpdateEventArgs args) + { + EventHandler handler = this.DetectUpdate; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the update detection phase has completed. + /// + /// Additional arguments for this event. + protected virtual void OnDetectUpdateComplete(DetectUpdateCompleteEventArgs args) + { + EventHandler handler = this.DetectUpdateComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when a related bundle has been detected for a bundle. + /// + /// Additional arguments for this event. + protected virtual void OnDetectRelatedBundle(DetectRelatedBundleEventArgs args) + { + EventHandler handler = this.DetectRelatedBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the detection for a specific package has begun. + /// + /// Additional arguments for this event. + protected virtual void OnDetectPackageBegin(DetectPackageBeginEventArgs args) + { + EventHandler handler = this.DetectPackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when a package was not detected but a package using the same provider key was. + /// + /// Additional arguments for this event. + protected virtual void OnDetectCompatibleMsiPackage(DetectCompatibleMsiPackageEventArgs args) + { + EventHandler handler = this.DetectCompatibleMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when a related MSI package has been detected for a package. + /// + /// Additional arguments for this event. + protected virtual void OnDetectRelatedMsiPackage(DetectRelatedMsiPackageEventArgs args) + { + EventHandler handler = this.DetectRelatedMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when an MSP package detects a target MSI has been detected. + /// + /// Additional arguments for this event. + protected virtual void OnDetectTargetMsiPackage(DetectTargetMsiPackageEventArgs args) + { + EventHandler handler = this.DetectTargetMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when an MSI feature has been detected for a package. + /// + /// Additional arguments for this event. + protected virtual void OnDetectMsiFeature(DetectMsiFeatureEventArgs args) + { + EventHandler handler = this.DetectMsiFeature; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the detection for a specific package has completed. + /// + /// Additional arguments for this event. + protected virtual void OnDetectPackageComplete(DetectPackageCompleteEventArgs args) + { + EventHandler handler = this.DetectPackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the detection phase has completed. + /// + /// Additional arguments for this event. + protected virtual void OnDetectComplete(DetectCompleteEventArgs args) + { + EventHandler handler = this.DetectComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun planning the installation. + /// + /// Additional arguments for this event. + protected virtual void OnPlanBegin(PlanBeginEventArgs args) + { + EventHandler handler = this.PlanBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun planning for a prior bundle. + /// + /// Additional arguments for this event. + protected virtual void OnPlanRelatedBundle(PlanRelatedBundleEventArgs args) + { + EventHandler handler = this.PlanRelatedBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun planning the installation of a specific package. + /// + /// Additional arguments for this event. + protected virtual void OnPlanPackageBegin(PlanPackageBeginEventArgs args) + { + EventHandler handler = this.PlanPackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine plans a new, compatible package using the same provider key. + /// + /// Additional arguments for this event. + protected virtual void OnPlanCompatibleMsiPackageBegin(PlanCompatibleMsiPackageBeginEventArgs args) + { + EventHandler handler = this.PlanCompatibleMsiPackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed planning the installation of a specific package. + /// + /// Additional arguments for this event. + protected virtual void OnPlanCompatibleMsiPackageComplete(PlanCompatibleMsiPackageCompleteEventArgs args) + { + EventHandler handler = this.PlanCompatibleMsiPackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine is about to plan the target MSI of a MSP package. + /// + /// Additional arguments for this event. + protected virtual void OnPlanTargetMsiPackage(PlanTargetMsiPackageEventArgs args) + { + EventHandler handler = this.PlanTargetMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine is about to plan an MSI feature of a specific package. + /// + /// Additional arguments for this event. + protected virtual void OnPlanMsiFeature(PlanMsiFeatureEventArgs args) + { + EventHandler handler = this.PlanMsiFeature; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when then engine has completed planning the installation of a specific package. + /// + /// Additional arguments for this event. + protected virtual void OnPlanPackageComplete(PlanPackageCompleteEventArgs args) + { + EventHandler handler = this.PlanPackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed planning the installation. + /// + /// Additional arguments for this event. + protected virtual void OnPlanComplete(PlanCompleteEventArgs args) + { + EventHandler handler = this.PlanComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun installing the bundle. + /// + /// Additional arguments for this event. + protected virtual void OnApplyBegin(ApplyBeginEventArgs args) + { + EventHandler handler = this.ApplyBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine is about to start the elevated process. + /// + /// Additional arguments for this event. + protected virtual void OnElevateBegin(ElevateBeginEventArgs args) + { + EventHandler handler = this.ElevateBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed starting the elevated process. + /// + /// Additional arguments for this event. + protected virtual void OnElevateComplete(ElevateCompleteEventArgs args) + { + EventHandler handler = this.ElevateComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has changed progress for the bundle installation. + /// + /// Additional arguments for this event. + protected virtual void OnProgress(ProgressEventArgs args) + { + EventHandler handler = this.Progress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has encountered an error. + /// + /// Additional arguments for this event. + protected virtual void OnError(ErrorEventArgs args) + { + EventHandler handler = this.Error; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun registering the location and visibility of the bundle. + /// + /// Additional arguments for this event. + protected virtual void OnRegisterBegin(RegisterBeginEventArgs args) + { + EventHandler handler = this.RegisterBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed registering the location and visilibity of the bundle. + /// + /// Additional arguments for this event. + protected virtual void OnRegisterComplete(RegisterCompleteEventArgs args) + { + EventHandler handler = this.RegisterComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun removing the registration for the location and visibility of the bundle. + /// + /// Additional arguments for this event. + protected virtual void OnUnregisterBegin(UnregisterBeginEventArgs args) + { + EventHandler handler = this.UnregisterBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed removing the registration for the location and visibility of the bundle. + /// + /// Additional arguments for this event. + protected virtual void OnUnregisterComplete(UnregisterCompleteEventArgs args) + { + EventHandler handler = this.UnregisterComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine begins to cache the installation sources. + /// + /// + protected virtual void OnCacheBegin(CacheBeginEventArgs args) + { + EventHandler handler = this.CacheBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine when it begins to cache a specific package. + /// + /// + protected virtual void OnCachePackageBegin(CachePackageBeginEventArgs args) + { + EventHandler handler = this.CachePackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine begins to cache the container or payload. + /// + /// + protected virtual void OnCacheAcquireBegin(CacheAcquireBeginEventArgs args) + { + EventHandler handler = this.CacheAcquireBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has progressed on caching the container or payload. + /// + /// + protected virtual void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args) + { + EventHandler handler = this.CacheAcquireProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine to allow the BA to change the source + /// using or . + /// + /// Additional arguments for this event. + protected virtual void OnResolveSource(ResolveSourceEventArgs args) + { + EventHandler handler = this.ResolveSource; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine completes caching of the container or payload. + /// + /// + protected virtual void OnCacheAcquireComplete(CacheAcquireCompleteEventArgs args) + { + EventHandler handler = this.CacheAcquireComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has started verify the payload. + /// + /// + protected virtual void OnCacheVerifyBegin(CacheVerifyBeginEventArgs args) + { + EventHandler handler = this.CacheVerifyBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine completes verification of the payload. + /// + /// + protected virtual void OnCacheVerifyComplete(CacheVerifyCompleteEventArgs args) + { + EventHandler handler = this.CacheVerifyComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine completes caching a specific package. + /// + /// + protected virtual void OnCachePackageComplete(CachePackageCompleteEventArgs args) + { + EventHandler handler = this.CachePackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called after the engine has cached the installation sources. + /// + /// Additional arguments for this event. + protected virtual void OnCacheComplete(CacheCompleteEventArgs args) + { + EventHandler handler = this.CacheComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun installing packages. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteBegin(ExecuteBeginEventArgs args) + { + EventHandler handler = this.ExecuteBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has begun installing a specific package. + /// + /// Additional arguments for this event. + protected virtual void OnExecutePackageBegin(ExecutePackageBeginEventArgs args) + { + EventHandler handler = this.ExecutePackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine executes one or more patches targeting a product. + /// + /// Additional arguments for this event. + protected virtual void OnExecutePatchTarget(ExecutePatchTargetEventArgs args) + { + EventHandler handler = this.ExecutePatchTarget; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when Windows Installer sends an installation message. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteMsiMessage(ExecuteMsiMessageEventArgs args) + { + EventHandler handler = this.ExecuteMsiMessage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when Windows Installer sends a file in use installation message. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) + { + EventHandler handler = this.ExecuteFilesInUse; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed installing a specific package. + /// + /// Additional arguments for this event. + protected virtual void OnExecutePackageComplete(ExecutePackageCompleteEventArgs args) + { + EventHandler handler = this.ExecutePackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed installing packages. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteComplete(ExecuteCompleteEventArgs args) + { + EventHandler handler = this.ExecuteComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called when the engine has completed installing the bundle. + /// + /// Additional arguments for this event. + protected virtual void OnApplyComplete(ApplyCompleteEventArgs args) + { + EventHandler handler = this.ApplyComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine while executing on payload. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteProgress(ExecuteProgressEventArgs args) + { + EventHandler handler = this.ExecuteProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine before trying to launch the preapproved executable. + /// + /// Additional arguments for this event. + protected virtual void OnLaunchApprovedExeBegin(LaunchApprovedExeBeginArgs args) + { + EventHandler handler = this.LaunchApprovedExeBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine after trying to launch the preapproved executable. + /// + /// Additional arguments for this event. + protected virtual void OnLaunchApprovedExeComplete(LaunchApprovedExeCompleteArgs args) + { + EventHandler handler = this.LaunchApprovedExeComplete; + if (null != handler) + { + handler(this, args); + } + } + + #region IBootstrapperApplication Members + + int IBootstrapperApplication.OnStartup() + { + StartupEventArgs args = new StartupEventArgs(); + this.OnStartup(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action) + { + ShutdownEventArgs args = new ShutdownEventArgs(action); + this.OnShutdown(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnSystemShutdown(EndSessionReasons dwEndSession, ref bool fCancel) + { + SystemShutdownEventArgs args = new SystemShutdownEventArgs(dwEndSession, fCancel); + this.OnSystemShutdown(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectBegin(bool fInstalled, int cPackages, ref bool fCancel) + { + DetectBeginEventArgs args = new DetectBeginEventArgs(fInstalled, cPackages, fCancel); + this.OnDetectBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, long version, ref bool fCancel, ref bool fIgnoreBundle) + { + DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, version, fCancel, fIgnoreBundle); + this.OnDetectForwardCompatibleBundle(args); + + fCancel = args.Cancel; + fIgnoreBundle = args.IgnoreBundle; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectUpdateBegin(string wzUpdateLocation, ref bool fCancel, ref bool fSkip) + { + DetectUpdateBeginEventArgs args = new DetectUpdateBeginEventArgs(wzUpdateLocation, fCancel, fSkip); + this.OnDetectUpdateBegin(args); + + fCancel = args.Cancel; + fSkip = args.Skip; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, long dw64Version, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) + { + DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, dw64Version, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); + this.OnDetectUpdate(args); + + fCancel = args.Cancel; + fStopProcessingUpdates = args.StopProcessingUpdates; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectUpdateComplete(int hrStatus, ref bool fIgnoreError) + { + DetectUpdateCompleteEventArgs args = new DetectUpdateCompleteEventArgs(hrStatus, fIgnoreError); + this.OnDetectUpdateComplete(args); + + fIgnoreError = args.IgnoreError; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, long version, RelatedOperation operation, ref bool fCancel) + { + DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, version, operation, fCancel); + this.OnDetectRelatedBundle(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectPackageBegin(string wzPackageId, ref bool fCancel) + { + DetectPackageBeginEventArgs args = new DetectPackageBeginEventArgs(wzPackageId, fCancel); + this.OnDetectPackageBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, long dw64CompatiblePackageVersion, ref bool fCancel) + { + DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, dw64CompatiblePackageVersion, fCancel); + this.OnDetectCompatibleMsiPackage(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, long version, RelatedOperation operation, ref bool fCancel) + { + DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, version, operation, fCancel); + this.OnDetectRelatedMsiPackage(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectTargetMsiPackage(string wzPackageId, string wzProductCode, PackageState patchState, ref bool fCancel) + { + DetectTargetMsiPackageEventArgs args = new DetectTargetMsiPackageEventArgs(wzPackageId, wzProductCode, patchState, fCancel); + this.OnDetectTargetMsiPackage(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectMsiFeature(string wzPackageId, string wzFeatureId, FeatureState state, ref bool fCancel) + { + DetectMsiFeatureEventArgs args = new DetectMsiFeatureEventArgs(wzPackageId, wzFeatureId, state, fCancel); + this.OnDetectMsiFeature(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectPackageComplete(string wzPackageId, int hrStatus, PackageState state) + { + DetectPackageCompleteEventArgs args = new DetectPackageCompleteEventArgs(wzPackageId, hrStatus, state); + this.OnDetectPackageComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnDetectComplete(int hrStatus) + { + DetectCompleteEventArgs args = new DetectCompleteEventArgs(hrStatus); + this.OnDetectComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlanBegin(int cPackages, ref bool fCancel) + { + PlanBeginEventArgs args = new PlanBeginEventArgs(cPackages, fCancel); + this.OnPlanBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + { + PlanRelatedBundleEventArgs args = new PlanRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel); + this.OnPlanRelatedBundle(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + { + PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, recommendedState, pRequestedState, fCancel); + this.OnPlanPackageBegin(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, long dw64CompatiblePackageVersion, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + { + PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, dw64CompatiblePackageVersion, recommendedState, pRequestedState, fCancel); + this.OnPlanCompatibleMsiPackageBegin(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanCompatibleMsiPackageComplete(string wzPackageId, string wzCompatiblePackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) + { + PlanCompatibleMsiPackageCompleteEventArgs args = new PlanCompatibleMsiPackageCompleteEventArgs(wzPackageId, wzCompatiblePackageId, hrStatus, state, requested, execute, rollback); + this.OnPlanCompatibleMsiPackageComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlanTargetMsiPackage(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + { + PlanTargetMsiPackageEventArgs args = new PlanTargetMsiPackageEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); + this.OnPlanTargetMsiPackage(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanMsiFeature(string wzPackageId, string wzFeatureId, FeatureState recommendedState, ref FeatureState pRequestedState, ref bool fCancel) + { + PlanMsiFeatureEventArgs args = new PlanMsiFeatureEventArgs(wzPackageId, wzFeatureId, recommendedState, pRequestedState, fCancel); + this.OnPlanMsiFeature(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanPackageComplete(string wzPackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) + { + var args = new PlanPackageCompleteEventArgs(wzPackageId, hrStatus, state, requested, execute, rollback); + this.OnPlanPackageComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlanComplete(int hrStatus) + { + PlanCompleteEventArgs args = new PlanCompleteEventArgs(hrStatus); + this.OnPlanComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnApplyBegin(int dwPhaseCount, ref bool fCancel) + { + this.applying = true; + + ApplyBeginEventArgs args = new ApplyBeginEventArgs(dwPhaseCount, fCancel); + this.OnApplyBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnElevateBegin(ref bool fCancel) + { + ElevateBeginEventArgs args = new ElevateBeginEventArgs(fCancel); + this.OnElevateBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnElevateComplete(int hrStatus) + { + ElevateCompleteEventArgs args = new ElevateCompleteEventArgs(hrStatus); + this.OnElevateComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnProgress(int dwProgressPercentage, int dwOverallPercentage, ref bool fCancel) + { + ProgressEventArgs args = new ProgressEventArgs(dwProgressPercentage, dwOverallPercentage, fCancel); + this.OnProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnError(ErrorType errorType, string wzPackageId, int dwCode, string wzError, int dwUIHint, int cData, string[] rgwzData, Result nRecommendation, ref Result pResult) + { + ErrorEventArgs args = new ErrorEventArgs(errorType, wzPackageId, dwCode, wzError, dwUIHint, rgwzData, nRecommendation, pResult); + this.OnError(args); + + pResult = args.Result; + return args.HResult; + } + + int IBootstrapperApplication.OnRegisterBegin(ref bool fCancel) + { + RegisterBeginEventArgs args = new RegisterBeginEventArgs(fCancel); + this.OnRegisterBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnRegisterComplete(int hrStatus) + { + RegisterCompleteEventArgs args = new RegisterCompleteEventArgs(hrStatus); + this.OnRegisterComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnCacheBegin(ref bool fCancel) + { + CacheBeginEventArgs args = new CacheBeginEventArgs(fCancel); + this.OnCacheBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePackageBegin(string wzPackageId, int cCachePayloads, long dw64PackageCacheSize, ref bool fCancel) + { + CachePackageBeginEventArgs args = new CachePackageBeginEventArgs(wzPackageId, cCachePayloads, dw64PackageCacheSize, fCancel); + this.OnCachePackageBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, CacheOperation operation, string wzSource, ref bool fCancel) + { + CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, operation, wzSource, fCancel); + this.OnCacheAcquireBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) + { + CacheAcquireProgressEventArgs args = new CacheAcquireProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); + this.OnCacheAcquireProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnResolveSource(string wzPackageOrContainerId, string wzPayloadId, string wzLocalSource, string wzDownloadSource, BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, ref BOOTSTRAPPER_RESOLVESOURCE_ACTION action, ref bool fCancel) + { + ResolveSourceEventArgs args = new ResolveSourceEventArgs(wzPackageOrContainerId, wzPayloadId, wzLocalSource, wzDownloadSource, action, recommendation, fCancel); + this.OnResolveSource(args); + + action = args.Action; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) + { + CacheAcquireCompleteEventArgs args = new CacheAcquireCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, action); + this.OnCacheAcquireComplete(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheVerifyBegin(string wzPackageId, string wzPayloadId, ref bool fCancel) + { + CacheVerifyBeginEventArgs args = new CacheVerifyBeginEventArgs(wzPackageId, wzPayloadId, fCancel); + this.OnCacheVerifyBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheVerifyComplete(string wzPackageId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) + { + CacheVerifyCompleteEventArgs args = new CacheVerifyCompleteEventArgs(wzPackageId, wzPayloadId, hrStatus, recommendation, action); + this.OnCacheVerifyComplete(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePackageComplete(string wzPackageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) + { + CachePackageCompleteEventArgs args = new CachePackageCompleteEventArgs(wzPackageId, hrStatus, recommendation, action); + this.OnCachePackageComplete(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheComplete(int hrStatus) + { + CacheCompleteEventArgs args = new CacheCompleteEventArgs(hrStatus); + this.OnCacheComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteBegin(int cExecutingPackages, ref bool fCancel) + { + ExecuteBeginEventArgs args = new ExecuteBeginEventArgs(cExecutingPackages, fCancel); + this.OnExecuteBegin(args); + + args.Cancel = fCancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ref bool fCancel) + { + ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, fCancel); + this.OnExecutePackageBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecutePatchTarget(string wzPackageId, string wzTargetProductCode, ref bool fCancel) + { + ExecutePatchTargetEventArgs args = new ExecutePatchTargetEventArgs(wzPackageId, wzTargetProductCode, fCancel); + this.OnExecutePatchTarget(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteProgress(string wzPackageId, int dwProgressPercentage, int dwOverallPercentage, ref bool fCancel) + { + ExecuteProgressEventArgs args = new ExecuteProgressEventArgs(wzPackageId, dwProgressPercentage, dwOverallPercentage, fCancel); + this.OnExecuteProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteMsiMessage(string wzPackageId, InstallMessage messageType, int dwUIHint, string wzMessage, int cData, string[] rgwzData, Result nRecommendation, ref Result pResult) + { + ExecuteMsiMessageEventArgs args = new ExecuteMsiMessageEventArgs(wzPackageId, messageType, dwUIHint, wzMessage, rgwzData, nRecommendation, pResult); + this.OnExecuteMsiMessage(args); + + pResult = args.Result; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteFilesInUse(string wzPackageId, int cFiles, string[] rgwzFiles, Result nRecommendation, ref Result pResult) + { + ExecuteFilesInUseEventArgs args = new ExecuteFilesInUseEventArgs(wzPackageId, rgwzFiles, nRecommendation, pResult); + this.OnExecuteFilesInUse(args); + + pResult = args.Result; + return args.HResult; + } + + int IBootstrapperApplication.OnExecutePackageComplete(string wzPackageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction) + { + ExecutePackageCompleteEventArgs args = new ExecutePackageCompleteEventArgs(wzPackageId, hrStatus, restart, recommendation, pAction); + this.OnExecutePackageComplete(args); + + pAction = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteComplete(int hrStatus) + { + ExecuteCompleteEventArgs args = new ExecuteCompleteEventArgs(hrStatus); + this.OnExecuteComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnUnregisterBegin(ref bool fCancel) + { + UnregisterBeginEventArgs args = new UnregisterBeginEventArgs(fCancel); + this.OnUnregisterBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnUnregisterComplete(int hrStatus) + { + UnregisterCompleteEventArgs args = new UnregisterCompleteEventArgs(hrStatus); + this.OnUnregisterComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnApplyComplete(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction) + { + ApplyCompleteEventArgs args = new ApplyCompleteEventArgs(hrStatus, restart, recommendation, pAction); + this.OnApplyComplete(args); + + this.applying = false; + + pAction = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnLaunchApprovedExeBegin(ref bool fCancel) + { + LaunchApprovedExeBeginArgs args = new LaunchApprovedExeBeginArgs(fCancel); + this.OnLaunchApprovedExeBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnLaunchApprovedExeComplete(int hrStatus, int processId) + { + LaunchApprovedExeCompleteArgs args = new LaunchApprovedExeCompleteArgs(hrStatus, processId); + this.OnLaunchApprovedExeComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + { + switch (message) + { + default: + return NativeMethods.E_NOTIMPL; + } + } + + void IBootstrapperApplication.BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + { + } + + #endregion + } +} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs new file mode 100644 index 00000000..a17f1a05 --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs @@ -0,0 +1,63 @@ +// 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.BootstrapperCore +{ + using System; + using System.IO; + using System.Xml.XPath; + + public class BootstrapperApplicationData : IBootstrapperApplicationData + { + public const string DefaultFileName = "BootstrapperApplicationData.xml"; + public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/2010/BootstrapperApplicationData"; + + public static readonly DirectoryInfo DefaultFolder; + public static readonly FileInfo DefaultFile; + + static BootstrapperApplicationData() + { + DefaultFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); + DefaultFile = new FileInfo(Path.Combine(DefaultFolder.FullName, DefaultFileName)); + } + + public FileInfo BADataFile { get; private set; } + + public IBundleInfo Bundle { get; private set; } + + public BootstrapperApplicationData() : this(DefaultFile) { } + + public BootstrapperApplicationData(FileInfo baDataFile) + { + this.BADataFile = baDataFile; + + using (FileStream fs = this.BADataFile.OpenRead()) + { + this.Bundle = BundleInfo.ParseBundleFromStream(fs); + } + } + + public static string GetAttribute(XPathNavigator node, string attributeName) + { + XPathNavigator attribute = node.SelectSingleNode("@" + attributeName); + + if (attribute == null) + { + return null; + } + + return attribute.Value; + } + + public static bool? GetYesNoAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + return attributeValue.Equals("yes", StringComparison.InvariantCulture); + } + } +} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs new file mode 100644 index 00000000..28430bb8 --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs @@ -0,0 +1,86 @@ +// 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.BootstrapperCore +{ + using System; + using System.Configuration; + using System.Reflection; + using System.Runtime.InteropServices; + + /// + /// Entry point for the MBA host to create and return the IBootstrapperApplication implementation to the engine. + /// + [ClassInterface(ClassInterfaceType.None)] + public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory + { + /// + /// Creates a new instance of the class. + /// + public BootstrapperApplicationFactory() + { + } + + /// + /// Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication. + /// + /// IBootstrapperEngine provided for the bootstrapper application. + /// Command line for the bootstrapper application. + /// Bootstrapper application via interface. + /// The bootstrapper application assembly + /// does not define the . + public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) + { + // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host. + var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection; + if (null == section) + { + throw new MissingAttributeException(); // TODO: throw a more specific exception than this. + } + + // Load the BA's IBootstrapperApplicationFactory. + var baFactoryType = BootstrapperApplicationFactory.GetBAFactoryTypeFromAssembly(section.AssemblyName); + var baFactory = (IBootstrapperApplicationFactory)Activator.CreateInstance(baFactoryType); + if (null == baFactory) + { + throw new InvalidBootstrapperApplicationFactoryException(); + } + + var ba = baFactory.Create(pEngine, ref command); + return ba; + } + + /// + /// Locates the and returns the specified type. + /// + /// The assembly that defines the IBootstrapperApplicationFactory implementation. + /// The bootstrapper application factory . + private static Type GetBAFactoryTypeFromAssembly(string assemblyName) + { + Type baFactoryType = null; + + // Load the requested assembly. + Assembly asm = AppDomain.CurrentDomain.Load(assemblyName); + + // If an assembly was loaded and is not the current assembly, check for the required attribute. + // This is done to avoid using the BootstrapperApplicationFactoryAttribute which we use at build time + // to specify the BootstrapperApplicationFactory assembly in the manifest. + if (!Assembly.GetExecutingAssembly().Equals(asm)) + { + // There must be one and only one BootstrapperApplicationFactoryAttribute. + // The attribute prevents multiple declarations already. + var attrs = (BootstrapperApplicationFactoryAttribute[])asm.GetCustomAttributes(typeof(BootstrapperApplicationFactoryAttribute), false); + if (null != attrs) + { + baFactoryType = attrs[0].BootstrapperApplicationFactoryType; + } + } + + if (null == baFactoryType) + { + throw new MissingAttributeException(); + } + + return baFactoryType; + } + } +} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs new file mode 100644 index 00000000..781d4ea1 --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs @@ -0,0 +1,35 @@ +// 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.BootstrapperCore +{ + using System; + + /// + /// Identifies the bootstrapper application factory class. + /// + /// + /// This required assembly attribute identifies the bootstrapper application factory class. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] + public sealed class BootstrapperApplicationFactoryAttribute : Attribute + { + private Type bootstrapperApplicationFactoryType; + + /// + /// Creates a new instance of the class. + /// + /// The of the BA factory. + public BootstrapperApplicationFactoryAttribute(Type bootstrapperApplicationFactoryType) + { + this.bootstrapperApplicationFactoryType = bootstrapperApplicationFactoryType; + } + + /// + /// Gets the type of the bootstrapper application factory class to create. + /// + public Type BootstrapperApplicationFactoryType + { + get { return this.bootstrapperApplicationFactoryType; } + } + } +} diff --git a/src/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/WixToolset.Mba.Core/BootstrapperCommand.cs new file mode 100644 index 00000000..bbd10e1d --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -0,0 +1,107 @@ +// 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.BootstrapperCore +{ + using System; + using System.ComponentModel; + using System.Runtime.InteropServices; + + public sealed class BootstrapperCommand : IBootstrapperCommand + { + private readonly string commandLine; + + public BootstrapperCommand( + LaunchAction action, + Display display, + Restart restart, + string commandLine, + int cmdShow, + ResumeType resume, + IntPtr splashScreen, + RelationType relation, + bool passthrough, + string layoutDirectory) + { + this.Action = action; + this.Display = display; + this.Restart = restart; + this.commandLine = commandLine; + this.CmdShow = cmdShow; + this.Resume = resume; + this.SplashScreen = splashScreen; + this.Relation = relation; + this.Passthrough = passthrough; + this.LayoutDirectory = layoutDirectory; + } + + public LaunchAction Action { get; } + + public Display Display { get; } + + public Restart Restart { get; } + + public string[] CommandLineArgs => GetCommandLineArgs(this.commandLine); + + public int CmdShow { get; } + + public ResumeType Resume { get; } + + public IntPtr SplashScreen { get; } + + public RelationType Relation { get; } + + public bool Passthrough { get; } + + public string LayoutDirectory { get; } + + /// + /// Gets the command line arguments as a string array. + /// + /// + /// Array of command line arguments. + /// + /// The command line could not be parsed into an array. + /// + /// This method uses the same parsing as the operating system which handles quotes and spaces correctly. + /// + public static string[] GetCommandLineArgs(string commandLine) + { + if (null == commandLine) + { + return new string[0]; + } + + // Parse the filtered command line arguments into a native array. + int argc = 0; + + // CommandLineToArgvW tries to treat the first argument as the path to the process, + // which fails pretty miserably if your first argument is something like + // FOO="C:\Program Files\My Company". So give it something harmless to play with. + IntPtr argv = NativeMethods.CommandLineToArgvW("ignored " + commandLine, out argc); + + if (IntPtr.Zero == argv) + { + // Throw an exception with the last error. + throw new Win32Exception(); + } + + // Marshal each native array pointer to a managed string. + try + { + // Skip "ignored" argument/hack. + string[] args = new string[argc - 1]; + for (int i = 1; i < argc; ++i) + { + IntPtr argvi = Marshal.ReadIntPtr(argv, i * IntPtr.Size); + args[i - 1] = Marshal.PtrToStringUni(argvi); + } + + return args; + } + finally + { + NativeMethods.LocalFree(argv); + } + } + } +} diff --git a/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs b/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs new file mode 100644 index 00000000..7721c027 --- /dev/null +++ b/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs @@ -0,0 +1,29 @@ +// 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.BootstrapperCore +{ + using System; + using System.Configuration; + + /// + /// Handler for the wix.bootstrapper configuration section group. + /// + public class BootstrapperSectionGroup : ConfigurationSectionGroup + { + /// + /// Creates a new instance of the class. + /// + public BootstrapperSectionGroup() + { + } + + /// + /// Gets the handler for the mba configuration section. + /// + [ConfigurationProperty("host")] + public HostSection Host + { + get { return (HostSection)base.Sections["host"]; } + } + } +} diff --git a/src/WixToolset.Mba.Core/BundleInfo.cs b/src/WixToolset.Mba.Core/BundleInfo.cs new file mode 100644 index 00000000..51c2d268 --- /dev/null +++ b/src/WixToolset.Mba.Core/BundleInfo.cs @@ -0,0 +1,67 @@ +// 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.BootstrapperCore +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; + using System.Xml.XPath; + + public class BundleInfo : IBundleInfo + { + public bool PerMachine { get; internal set; } + public string Name { get; internal set; } + public string LogVariable { get; internal set; } + public IDictionary Packages { get; internal set; } + + internal BundleInfo() + { + this.Packages = new Dictionary(); + } + + public void AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) + { + var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); + this.Packages.Add(package.Id, package); + } + + public static IBundleInfo ParseBundleFromStream(Stream stream) + { + XPathDocument manifest = new XPathDocument(stream); + XPathNavigator root = manifest.CreateNavigator(); + return ParseBundleFromXml(root); + } + + public static IBundleInfo ParseBundleFromXml(XPathNavigator root) + { + BundleInfo bundle = new BundleInfo(); + + XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); + namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); + XPathNavigator bundleNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:WixBundleProperties", namespaceManager); + + if (bundleNode == null) + { + throw new Exception("Failed to select bundle information."); + } + + bool? perMachine = BootstrapperApplicationData.GetYesNoAttribute(bundleNode, "PerMachine"); + if (perMachine.HasValue) + { + bundle.PerMachine = perMachine.Value; + } + + bundle.Name = BootstrapperApplicationData.GetAttribute(bundleNode, "DisplayName"); + + bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable"); + + foreach (var package in PackageInfo.ParsePackagesFromXml(root)) + { + bundle.Packages.Add(package.Id, package); + } + + return bundle; + } + } +} diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs new file mode 100644 index 00000000..ad62134f --- /dev/null +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -0,0 +1,516 @@ +// 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.BootstrapperCore +{ + using System; + using System.ComponentModel; + using System.Runtime.InteropServices; + using System.Security; + using System.Text; + + /// + /// Container class for the interface. + /// + public sealed class Engine : IEngine + { + // Burn errs on empty strings, so declare initial buffer size. + private const int InitialBufferSize = 80; + private static readonly string normalizeVersionFormatString = "{0} must be less than or equal to " + UInt16.MaxValue; + + private IBootstrapperEngine engine; + private Variables numericVariables; + private Variables secureStringVariables; + private Variables stringVariables; + private Variables versionVariables; + + /// + /// Creates a new instance of the container class. + /// + /// The to contain. + internal Engine(IBootstrapperEngine engine) + { + this.engine = engine; + + // Wrap the calls to get and set numeric variables. + this.numericVariables = new Variables( + delegate(string name) + { + long value; + int ret = this.engine.GetVariableNumeric(name, out value); + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return value; + }, + delegate(string name, long value) + { + this.engine.SetVariableNumeric(name, value); + }, + delegate(string name) + { + long value; + int ret = this.engine.GetVariableNumeric(name, out value); + + return NativeMethods.E_NOTFOUND != ret; + } + ); + + // Wrap the calls to get and set string variables using SecureStrings. + this.secureStringVariables = new Variables( + delegate(string name) + { + var pUniString = this.getStringVariable(name, out var length); + try + { + return this.convertToSecureString(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + }, + delegate(string name, SecureString value) + { + IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); + try + { + this.engine.SetVariableString(name, pValue); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + }, + delegate(string name) + { + return this.containsVariable(name); + } + ); + + // Wrap the calls to get and set string variables. + this.stringVariables = new Variables( + delegate(string name) + { + int length; + IntPtr pUniString = this.getStringVariable(name, out length); + try + { + return Marshal.PtrToStringUni(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + }, + delegate(string name, string value) + { + IntPtr pValue = Marshal.StringToCoTaskMemUni(value); + try + { + this.engine.SetVariableString(name, pValue); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + }, + delegate(string name) + { + return this.containsVariable(name); + } + ); + + // Wrap the calls to get and set version variables. + this.versionVariables = new Variables( + delegate(string name) + { + long value; + int ret = this.engine.GetVariableVersion(name, out value); + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return LongToVersion(value); + }, + delegate(string name, Version value) + { + long version = VersionToLong(value); + this.engine.SetVariableVersion(name, version); + }, + delegate(string name) + { + long value; + int ret = this.engine.GetVariableVersion(name, out value); + + return NativeMethods.E_NOTFOUND != ret; + } + ); + } + + public IVariables NumericVariables + { + get { return this.numericVariables; } + } + + public int PackageCount + { + get + { + int count; + this.engine.GetPackageCount(out count); + + return count; + } + } + + public IVariables SecureStringVariables + { + get { return this.secureStringVariables; } + } + + public IVariables StringVariables + { + get { return this.stringVariables; } + } + + public IVariables VersionVariables + { + get { return this.versionVariables; } + } + + public void Apply(IntPtr hwndParent) + { + this.engine.Apply(hwndParent); + } + + public void CloseSplashScreen() + { + this.engine.CloseSplashScreen(); + } + + public void Detect() + { + this.Detect(IntPtr.Zero); + } + + public void Detect(IntPtr hwndParent) + { + this.engine.Detect(hwndParent); + } + + public bool Elevate(IntPtr hwndParent) + { + int ret = this.engine.Elevate(hwndParent); + + if (NativeMethods.S_OK == ret || NativeMethods.E_ALREADYINITIALIZED == ret) + { + return true; + } + else if (NativeMethods.E_CANCELLED == ret) + { + return false; + } + else + { + throw new Win32Exception(ret); + } + } + + public string EscapeString(string input) + { + int capacity = InitialBufferSize; + StringBuilder sb = new StringBuilder(capacity); + + // Get the size of the buffer. + int ret = this.engine.EscapeString(input, sb, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + sb.Capacity = ++capacity; // Add one for the null terminator. + ret = this.engine.EscapeString(input, sb, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return sb.ToString(); + } + + public bool EvaluateCondition(string condition) + { + bool value; + this.engine.EvaluateCondition(condition, out value); + + return value; + } + + public string FormatString(string format) + { + int capacity = InitialBufferSize; + StringBuilder sb = new StringBuilder(capacity); + + // Get the size of the buffer. + int ret = this.engine.FormatString(format, sb, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + sb.Capacity = ++capacity; // Add one for the null terminator. + ret = this.engine.FormatString(format, sb, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return sb.ToString(); + } + + public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) + { + this.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, 0); + } + + public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout) + { + this.engine.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, waitForInputIdleTimeout); + } + + public void Log(LogLevel level, string message) + { + this.engine.Log(level, message); + } + + public void Plan(LaunchAction action) + { + this.engine.Plan(action); + } + + public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash) + { + this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); + } + + public void SetLocalSource(string packageOrContainerId, string payloadId, string path) + { + this.engine.SetLocalSource(packageOrContainerId, payloadId, path); + } + + public void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password) + { + this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); + } + + public int SendEmbeddedError(int errorCode, string message, int uiHint) + { + int result = 0; + this.engine.SendEmbeddedError(errorCode, message, uiHint, out result); + return result; + } + + public int SendEmbeddedProgress(int progressPercentage, int overallPercentage) + { + int result = 0; + this.engine.SendEmbeddedProgress(progressPercentage, overallPercentage, out result); + return result; + } + + public void Quit(int exitCode) + { + this.engine.Quit(exitCode); + } + + internal sealed class Variables : IVariables + { + // .NET 2.0 does not support Func or Action. + internal delegate T Getter(string name); + internal delegate void Setter(string name, T value); + + private Getter getter; + private Setter setter; + private Predicate contains; + + internal Variables(Getter getter, Setter setter, Predicate contains) + { + this.getter = getter; + this.setter = setter; + this.contains = contains; + } + + public T this[string name] + { + get { return this.getter(name); } + set { this.setter(name, value); } + } + + public bool Contains(string name) + { + return this.contains(name); + } + } + + /// + /// Gets whether the variable given by exists. + /// + /// The name of the variable to check. + /// True if the variable given by exists; otherwise, false. + internal bool containsVariable(string name) + { + int capacity = 0; + IntPtr pValue = IntPtr.Zero; + int ret = this.engine.GetVariableString(name, pValue, ref capacity); + + return NativeMethods.E_NOTFOUND != ret; + } + + /// + /// Gets the variable given by as a string. + /// + /// The name of the variable to get. + /// The length of the Unicode string. + /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. + /// An error occurred getting the variable. + internal IntPtr getStringVariable(string name, out int length) + { + int capacity = InitialBufferSize; + bool success = false; + IntPtr pValue = Marshal.AllocCoTaskMem(capacity * UnicodeEncoding.CharSize); + try + { + // Get the size of the buffer. + int ret = this.engine.GetVariableString(name, pValue, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + // Don't need to add 1 for the null terminator, the engine already includes that. + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity * UnicodeEncoding.CharSize); + ret = this.engine.GetVariableString(name, pValue, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw Marshal.GetExceptionForHR(ret); + } + + // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. + for (length = 0; length < capacity; ++length) + { + if(0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) + { + break; + } + } + + success = true; + return pValue; + } + finally + { + if (!success && IntPtr.Zero != pValue) + { + Marshal.FreeCoTaskMem(pValue); + } + } + } + + /// + /// Initialize a SecureString with the given Unicode string. + /// + /// Pointer to Unicode string. + /// The string's length. + internal SecureString convertToSecureString(IntPtr pUniString, int length) + { + if (IntPtr.Zero == pUniString) + { + return null; + } + + SecureString value = new SecureString(); + short s; + char c; + for (int charIndex = 0; charIndex < length; charIndex++) + { + s = Marshal.ReadInt16(pUniString, charIndex * UnicodeEncoding.CharSize); + c = (char)s; + value.AppendChar(c); + s = 0; + c = (char)0; + } + return value; + } + + public static long VersionToLong(Version version) + { + // In Windows, each version component has a max value of 65535, + // so we truncate the version before shifting it, which will overflow if invalid. + long major = (long)(ushort)version.Major << 48; + long minor = (long)(ushort)version.Minor << 32; + long build = (long)(ushort)version.Build << 16; + long revision = (long)(ushort)version.Revision; + + return major | minor | build | revision; + } + + public static Version LongToVersion(long version) + { + int major = (int)((version & ((long)0xffff << 48)) >> 48); + int minor = (int)((version & ((long)0xffff << 32)) >> 32); + int build = (int)((version & ((long)0xffff << 16)) >> 16); + int revision = (int)(version & 0xffff); + + return new Version(major, minor, build, revision); + } + + /// + /// Verifies that VersionVariables can pass on the given Version to the engine. + /// If the Build or Revision fields are undefined, they are set to zero. + /// + public static Version NormalizeVersion(Version version) + { + if (version == null) + { + throw new ArgumentNullException("version"); + } + + int major = version.Major; + int minor = version.Minor; + int build = version.Build; + int revision = version.Revision; + + if (major > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Major")); + } + if (minor > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Minor")); + } + if (build > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Build")); + } + if (build == -1) + { + build = 0; + } + if (revision > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Revision")); + } + if (revision == -1) + { + revision = 0; + } + + return new Version(major, minor, build, revision); + } + } +} diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs new file mode 100644 index 00000000..9e8e6ecc --- /dev/null +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -0,0 +1,1903 @@ +// 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.BootstrapperCore +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + + /// + /// Base class for BA classes. + /// + [Serializable] + public abstract class HResultEventArgs : EventArgs + { + /// + /// Creates a new instance of the class. + /// + public HResultEventArgs() + { + } + + /// + /// Gets or sets the of the operation. This is passed back to the engine. + /// + public int HResult { get; set; } + } + + /// + /// Base class for cancellable BA classes. + /// + [Serializable] + public abstract class CancellableHResultEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CancellableHResultEventArgs(bool cancelRecommendation) + { + this.Cancel = cancelRecommendation; + } + + /// + /// Gets or sets whether to cancel the operation. This is passed back to the engine. + /// + public bool Cancel { get; set; } + } + + /// + /// Base class for classes that must return a . + /// + [Serializable] + public abstract class ResultEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// Recommended result from engine. + /// The result to return to the engine. + public ResultEventArgs(Result recommendation, Result result) + { + this.Recommendation = recommendation; + this.Result = result; + } + + /// + /// Gets the recommended of the operation. + /// + public Result Recommendation { get; private set; } + + /// + /// Gets or sets the of the operation. This is passed back to the engine. + /// + public Result Result { get; set; } + } + + /// + /// Base class for classes that receive status from the engine. + /// + [Serializable] + public abstract class StatusEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public StatusEventArgs(int hrStatus) + { + this.Status = hrStatus; + } + + /// + /// Gets the return code of the operation. + /// + public int Status { get; private set; } + } + + /// + /// Base class for classes that receive status from the engine and return an action. + /// + public abstract class ActionEventArgs : StatusEventArgs + { + /// + /// + /// The return code of the operation. + /// Recommended action from engine. + /// The action to perform. + public ActionEventArgs(int hrStatus, T recommendation, T action) + : base(hrStatus) + { + this.Recommendation = recommendation; + this.Action = action; + } + + /// + /// Gets the recommended action from the engine. + /// + public T Recommendation { get; private set; } + + /// + /// Gets or sets the action to be performed. This is passed back to the engine. + /// + public T Action { get; set; } + } + + /// + /// Additional arguments used when startup has begun. + /// + [Serializable] + public class StartupEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public StartupEventArgs() + { + } + } + + /// + /// Additional arguments used when shutdown has begun. + /// + [Serializable] + public class ShutdownEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public ShutdownEventArgs(BOOTSTRAPPER_SHUTDOWN_ACTION action) + { + this.Action = action; + } + + /// + /// The action for OnShutdown. + /// + public BOOTSTRAPPER_SHUTDOWN_ACTION Action { get; set; } + } + + /// + /// Additional arguments used when the system is shutting down or the user is logging off. + /// + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// By default setup will prevent shutting down or logging off between + /// and . + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// + [Serializable] + public class SystemShutdownEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The reason the application is requested to close or being closed. + /// The recommendation from the engine. + public SystemShutdownEventArgs(EndSessionReasons reasons, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.Reasons = reasons; + } + + /// + /// Gets the reason the application is requested to close or being closed. + /// + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// + public EndSessionReasons Reasons { get; private set; } + } + + /// + /// Additional arguments used when the overall detection phase has begun. + /// + [Serializable] + public class DetectBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// Specifies whether the bundle is installed. + /// The number of packages to detect. + /// The recommendation from the engine. + public DetectBeginEventArgs(bool installed, int packageCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.Installed = installed; + this.PackageCount = packageCount; + } + + /// + /// Gets whether the bundle is installed. + /// + public bool Installed { get; private set; } + + /// + /// Gets the number of packages to detect. + /// + public int PackageCount { get; private set; } + } + + /// + /// Additional arguments used when detected a forward compatible bundle. + /// + [Serializable] + public class DetectForwardCompatibleBundleEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the forward compatible bundle. + /// Relationship type for this forward compatible bundle. + /// The tag of the forward compatible bundle. + /// Whether the detected forward compatible bundle is per machine. + /// The version of the forward compatible bundle detected. + /// The cancel recommendation from the engine. + /// The ignore recommendation from the engine. + public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, long version, bool cancelRecommendation, bool ignoreBundleRecommendation) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RelationType = relationType; + this.BundleTag = bundleTag; + this.PerMachine = perMachine; + this.Version = Engine.LongToVersion(version); + this.IgnoreBundle = ignoreBundleRecommendation; + } + + /// + /// Gets the identity of the forward compatible bundle detected. + /// + public string BundleId { get; private set; } + + /// + /// Gets the relationship type of the forward compatible bundle. + /// + public RelationType RelationType { get; private set; } + + /// + /// Gets the tag of the forward compatible bundle. + /// + public string BundleTag { get; private set; } + + /// + /// Gets whether the detected forward compatible bundle is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the forward compatible bundle detected. + /// + public Version Version { get; private set; } + + /// + /// Instructs the engine whether to use the forward compatible bundle. + /// + public bool IgnoreBundle { get; set; } + } + + /// + /// Additional arguments used when the detection for an update has begun. + /// + [Serializable] + public class DetectUpdateBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The location to check for an updated bundle. + /// The cancel recommendation from the engine. + /// The skip recommendation from the engine. + public DetectUpdateBeginEventArgs(string updateLocation, bool cancelRecommendation, bool skipRecommendation) + : base(cancelRecommendation) + { + this.UpdateLocation = updateLocation; + } + + /// + /// Gets the identity of the bundle to detect. + /// + public string UpdateLocation { get; private set; } + + /// + /// Whether to skip checking for bundle updates. + /// + public bool Skip { get; set; } + } + + /// + /// Additional arguments used when the detection for an update has begun. + /// + [Serializable] + public class DetectUpdateEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The location to check for an updated bundle. + /// The expected size of the updated bundle. + /// The expected version of the updated bundle. + /// The title of the updated bundle. + /// The summary of the updated bundle. + /// The content type of the content of the updated bundle. + /// The content of the updated bundle. + /// The recommendation from the engine. + /// The recommendation from the engine. + public DetectUpdateEventArgs(string updateLocation, long size, long version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) + : base(cancelRecommendation) + { + this.UpdateLocation = updateLocation; + this.Size = size; + this.Version = Engine.LongToVersion(version); + this.Title = title; + this.Summary = summary; + this.ContentType = contentType; + this.Content = content; + this.StopProcessingUpdates = stopRecommendation; + } + + /// + /// Gets the identity of the bundle to detect. + /// + public string UpdateLocation { get; private set; } + + /// + /// Gets the size of the updated bundle. + /// + public long Size { get; private set; } + + /// + /// Gets the version of the updated bundle. + /// + public Version Version { get; private set; } + + /// + /// Gets the title of the the updated bundle. + /// + public string Title { get; private set; } + + /// + /// Gets the summary of the updated bundle. + /// + public string Summary { get; private set; } + + /// + /// Gets the content type of the content of the updated bundle. + /// + public string ContentType { get; private set; } + + /// + /// Gets the content of the updated bundle. + /// + public string Content { get; private set; } + + /// + /// Tells the engine to stop giving the rest of the updates found in the feed. + /// + public bool StopProcessingUpdates { get; set; } + } + + /// + /// Additional arguments used when the detection for an update has completed. + /// + [Serializable] + public class DetectUpdateCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + /// The recommendation from the engine. + public DetectUpdateCompleteEventArgs(int hrStatus, bool ignoreRecommendation) + : base(hrStatus) + { + this.IgnoreError = ignoreRecommendation; + } + + /// + /// If Status is an error, then set this to true to ignore it and continue detecting. + /// + public bool IgnoreError { get; set; } + } + + /// + /// Additional arguments used when a related bundle has been detected for a bundle. + /// + [Serializable] + public class DetectRelatedBundleEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the related package bundle. + /// Relationship type for this related bundle. + /// The tag of the related package bundle. + /// Whether the detected bundle is per machine. + /// The version of the related bundle detected. + /// The operation that will be taken on the detected bundle. + /// The recommendation from the engine. + public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, long version, RelatedOperation operation, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.ProductCode = productCode; + this.RelationType = relationType; + this.BundleTag = bundleTag; + this.PerMachine = perMachine; + this.Version = Engine.LongToVersion(version); + this.Operation = operation; + } + + /// + /// Gets the identity of the related bundle detected. + /// + public string ProductCode { get; private set; } + + /// + /// Gets the relationship type of the related bundle. + /// + public RelationType RelationType { get; private set; } + + /// + /// Gets the tag of the related package bundle. + /// + public string BundleTag { get; private set; } + + /// + /// Gets whether the detected bundle is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the related bundle detected. + /// + public Version Version { get; private set; } + + /// + /// Gets the operation that will be taken on the detected bundle. + /// + public RelatedOperation Operation { get; private set; } + } + + /// + /// Additional arguments used when the detection for a specific package has begun. + /// + [Serializable] + public class DetectPackageBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package to detect. + /// The recommendation from the engine. + public DetectPackageBeginEventArgs(string packageId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + } + + /// + /// Gets the identity of the package to detect. + /// + public string PackageId { get; private set; } + } + + /// + /// Additional arguments used when a package was not found but a newer package using the same provider key was. + /// + [Serializable] + public class DetectCompatibleMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that was not detected. + /// The identity of the compatible package that was detected. + /// The version of the compatible package that was detected. + /// The recommendation from the engine. + public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, long compatiblePackageVersion, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.CompatiblePackageVersion = Engine.LongToVersion(compatiblePackageVersion); + } + + /// + /// Gets the identity of the package that was not detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package that was detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the version of the compatible package that was detected. + /// + public Version CompatiblePackageVersion { get; private set; } + } + + /// + /// Additional arguments used when a related MSI package has been detected for a package. + /// + [Serializable] + public class DetectRelatedMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package detecting. + /// The upgrade code of the related package detected. + /// The identity of the related package detected. + /// Whether the detected package is per machine. + /// The version of the related package detected. + /// The operation that will be taken on the detected package. + /// The recommendation from the engine. + public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, long version, RelatedOperation operation, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.UpgradeCode = upgradeCode; + this.ProductCode = productCode; + this.PerMachine = perMachine; + this.Version = Engine.LongToVersion(version); + this.Operation = operation; + } + + /// + /// Gets the identity of the product's package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the upgrade code of the related package detected. + /// + public string UpgradeCode { get; private set; } + + /// + /// Gets the identity of the related package detected. + /// + public string ProductCode { get; private set; } + + /// + /// Gets whether the detected package is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the related package detected. + /// + public Version Version { get; private set; } + + /// + /// Gets the operation that will be taken on the detected package. + /// + public RelatedOperation Operation { get; private set; } + } + + /// + /// Additional arguments used when a target MSI package has been detected. + /// + public class DetectTargetMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// Detected package identifier. + /// Detected product code. + /// Package state detected. + /// The recommendation from the engine. + public DetectTargetMsiPackageEventArgs(string packageId, string productCode, PackageState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ProductCode = productCode; + this.State = state; + } + + /// + /// Gets the identity of the target's package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the product code of the target MSI detected. + /// + public string ProductCode { get; private set; } + + /// + /// Gets the detected patch package state. + /// + public PackageState State { get; private set; } + } + + /// + /// Additional arguments used when a feature in an MSI package has been detected. + /// + public class DetectMsiFeatureEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// Detected package identifier. + /// Detected feature identifier. + /// Feature state detected. + /// The recommendation from the engine. + public DetectMsiFeatureEventArgs(string packageId, string featureId, FeatureState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.FeatureId = featureId; + this.State = state; + } + + /// + /// Gets the identity of the feature's package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the feature detected. + /// + public string FeatureId { get; private set; } + + /// + /// Gets the detected feature state. + /// + public FeatureState State { get; private set; } + } + + /// + /// Additional arguments used when the detection for a specific package has completed. + /// + [Serializable] + public class DetectPackageCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package detected. + /// The return code of the operation. + /// The state of the specified package. + public DetectPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state) + : base(hrStatus) + { + this.PackageId = packageId; + this.State = state; + } + + /// + /// Gets the identity of the package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the state of the specified package. + /// + public PackageState State { get; private set; } + } + + /// + /// Additional arguments used when the detection phase has completed. + /// + [Serializable] + public class DetectCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public DetectCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has begun planning the installation. + /// + [Serializable] + public class PlanBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The number of packages to plan for. + /// The recommendation from the engine. + public PlanBeginEventArgs(int packageCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageCount = packageCount; + } + + /// + /// Gets the number of packages to plan for. + /// + public int PackageCount { get; private set; } + } + + /// + /// Additional arguments used when the engine has begun planning for a related bundle. + /// + [Serializable] + public class PlanRelatedBundleEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the bundle to plan for. + /// The recommended requested state for the bundle. + /// The requested state for the bundle. + /// The recommendation from the engine. + public PlanRelatedBundleEventArgs(string bundleId, RequestState recommendedState, RequestState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the bundle to plan for. + /// + public string BundleId { get; private set; } + + /// + /// Gets the recommended requested state for the bundle. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// Gets or sets the requested state for the bundle. + /// + public RequestState State { get; set; } + } + + /// + /// Additional arguments used when the engine has begun planning the installation of a specific package. + /// + [Serializable] + public class PlanPackageBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package to plan for. + /// The recommended requested state for the package. + /// The requested state for the package. + /// The recommendation from the engine. + public PlanPackageBeginEventArgs(string packageId, RequestState recommendedState, RequestState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the package to plan for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the recommended requested state for the package. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// Gets or sets the requested state for the package. + /// + public RequestState State { get; set; } + } + + /// + /// Additional arguments used when the engine is about to plan a newer package using the same provider key. + /// + [Serializable] + public class PlanCompatibleMsiPackageBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that was not detected. + /// The identity of the compatible package that was detected. + /// The version of the compatible package that was detected. + /// The recommended request state for the compatible package. + /// The requested state for the compatible package. + /// The recommendation from the engine. + public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, long compatiblePackageVersion, RequestState recommendedState, RequestState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.CompatiblePackageVersion = Engine.LongToVersion(compatiblePackageVersion); + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the package that was not detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the version of the compatible package detected. + /// + public Version CompatiblePackageVersion { get; private set; } + + /// + /// Gets the recommended state to use for the compatible package for planning. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// Gets or sets the state to use for the compatible package for planning. + /// + public RequestState State { get; set; } + } + + /// + /// Additional arguments used when the engine has completed planning the installation of a specific package. + /// + [Serializable] + public class PlanCompatibleMsiPackageCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package planned for. + /// The identity of the compatible package that was detected. + /// The return code of the operation. + /// The current state of the package. + /// The requested state for the package + /// The execution action to take. + /// The rollback action to take. + public PlanCompatibleMsiPackageCompleteEventArgs(string packageId, string compatiblePackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) + : base(hrStatus) + { + this.PackageId = packageId; + this.CompatiblePackageId = compatiblePackageId; + this.State = state; + this.Requested = requested; + this.Execute = execute; + this.Rollback = rollback; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the compatible package detected. + /// + public string CompatiblePackageId { get; private set; } + + /// + /// Gets the current state of the package. + /// + public PackageState State { get; private set; } + + /// + /// Gets the requested state for the package. + /// + public RequestState Requested { get; private set; } + + /// + /// Gets the execution action to take. + /// + public ActionState Execute { get; private set; } + + /// + /// Gets the rollback action to take. + /// + public ActionState Rollback { get; private set; } + } + + /// + /// Additional arguments used when engine is about to plan a MSP applied to a target MSI package. + /// + [Serializable] + public class PlanTargetMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// Package identifier of the patch being planned. + /// Product code identifier being planned. + /// Recommended package state of the patch being planned. + /// Package state of the patch being planned. + /// The recommendation from the engine. + public PlanTargetMsiPackageEventArgs(string packageId, string productCode, RequestState recommendedState, RequestState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ProductCode = productCode; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the patch package to plan. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the patch's target MSI to plan. + /// + public string ProductCode { get; private set; } + + /// + /// Gets the recommended state of the patch to use by planning. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// Gets or sets the state of the patch to use by planning. + /// + public RequestState State { get; set; } + } + + /// + /// Additional arguments used when engine is about to plan a feature in an MSI package. + /// + [Serializable] + public class PlanMsiFeatureEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// Package identifier being planned. + /// Feature identifier being planned. + /// Recommended feature state being planned. + /// Feature state being planned. + /// The recommendation from the engine. + public PlanMsiFeatureEventArgs(string packageId, string featureId, FeatureState recommendedState, FeatureState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.FeatureId = featureId; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the feature's package to plan. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the feature to plan. + /// + public string FeatureId { get; private set; } + + /// + /// Gets the recommended feature state to use by planning. + /// + public FeatureState RecommendedState { get; private set; } + + /// + /// Gets or sets the feature state to use by planning. + /// + public FeatureState State { get; set; } + } + + /// + /// Additional arguments used when then engine has completed planning the installation of a specific package. + /// + [Serializable] + public class PlanPackageCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package planned for. + /// The return code of the operation. + /// The current state of the package. + /// The requested state for the package + /// The execution action to take. + /// The rollback action to take. + public PlanPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) + : base(hrStatus) + { + this.PackageId = packageId; + this.State = state; + this.Requested = requested; + this.Execute = execute; + this.Rollback = rollback; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the current state of the package. + /// + public PackageState State { get; private set; } + + /// + /// Gets the requested state for the package. + /// + public RequestState Requested { get; private set; } + + /// + /// Gets the execution action to take. + /// + public ActionState Execute { get; private set; } + + /// + /// Gets the rollback action to take. + /// + public ActionState Rollback { get; private set; } + } + + /// + /// Additional arguments used when the engine has completed planning the installation. + /// + [Serializable] + public class PlanCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public PlanCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has begun installing the bundle. + /// + [Serializable] + public class ApplyBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The number of phases during apply. + /// The recommendation from the engine. + public ApplyBeginEventArgs(int phaseCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PhaseCount = phaseCount; + } + + /// + /// Gets the number of phases that the engine will go through in apply. + /// There are currently two possible phases: cache and execute. + /// + public int PhaseCount { get; private set; } + } + + /// + /// Additional arguments used when the engine is about to start the elevated process. + /// + [Serializable] + public class ElevateBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The recommendation from the engine. + public ElevateBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments used when the engine has completed starting the elevated process. + /// + [Serializable] + public class ElevateCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public ElevateCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has changed progress for the bundle installation. + /// + [Serializable] + public class ProgressEventArgs : CancellableHResultEventArgs + { + /// + /// Creates an new instance of the class. + /// + /// The percentage from 0 to 100 completed for a package. + /// The percentage from 0 to 100 completed for the bundle. + /// The recommendation from the engine. + public ProgressEventArgs(int progressPercentage, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.ProgressPercentage = progressPercentage; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the percentage from 0 to 100 completed for a package. + /// + public int ProgressPercentage { get; private set; } + + /// + /// Gets the percentage from 0 to 100 completed for the bundle. + /// + public int OverallPercentage { get; private set; } + } + + /// + /// Additional arguments used when the engine has encountered an error. + /// + [Serializable] + public class ErrorEventArgs : ResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The error type. + /// The identity of the package that yielded the error. + /// The error code. + /// The error message. + /// Recommended display flags for an error dialog. + /// The exteded data for the error. + /// Recommended result from engine. + /// The result to return to the engine. + public ErrorEventArgs(ErrorType errorType, string packageId, int errorCode, string errorMessage, int dwUIHint, string[] data, Result recommendation, Result result) + : base(recommendation, result) + { + this.ErrorType = errorType; + this.PackageId = packageId; + this.ErrorCode = errorCode; + this.ErrorMessage = errorMessage; + this.UIHint = dwUIHint; + this.Data = new ReadOnlyCollection(data ?? new string[] { }); + } + + /// + /// Gets the type of error that occurred. + /// + public ErrorType ErrorType { get; private set; } + + /// + /// Gets the identity of the package that yielded the error. + /// + public string PackageId { get; private set; } + + /// + /// Gets the error code. + /// + public int ErrorCode { get; private set; } + + /// + /// Gets the error message. + /// + public string ErrorMessage { get; private set; } + + /// + /// Gets the recommended display flags for an error dialog. + /// + public int UIHint { get; private set; } + + /// + /// Gets the extended data for the error. + /// + public IList Data { get; private set; } + } + + /// + /// Additional arguments used when the engine has begun registering the location and visibility of the bundle. + /// + [Serializable] + public class RegisterBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The recommendation from the engine. + public RegisterBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments used when the engine has completed registering the location and visilibity of the bundle. + /// + [Serializable] + public class RegisterCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public RegisterCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has begun removing the registration for the location and visibility of the bundle. + /// + [Serializable] + public class UnregisterBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The recommendation from the engine. + public UnregisterBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments used when the engine has completed removing the registration for the location and visibility of the bundle. + /// + [Serializable] + public class UnregisterCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public UnregisterCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has begun caching the installation sources. + /// + [Serializable] + public class CacheBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The recommendation from the engine. + public CacheBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments used when the engine begins to acquire containers or payloads. + /// + [Serializable] + public class CacheAcquireBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, CacheOperation operation, string source, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.Operation = operation; + this.Source = source; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload (if acquiring a payload). + /// + public string PayloadId { get; private set; } + + /// + /// Gets the cache acquire operation. + /// + public CacheOperation Operation { get; private set; } + + /// + /// Gets the source of the container or payload. + /// + public string Source { get; private set; } + } + + /// + /// Additional arguments used when the engine acquires some part of a container or payload. + /// + [Serializable] + public class CacheAcquireProgressEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CacheAcquireProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.Progress = progress; + this.Total = total; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload (if acquiring a payload). + /// + public string PayloadId { get; private set; } + + /// + /// Gets the number of bytes cached thus far. + /// + public long Progress { get; private set; } + + /// + /// Gets the total bytes to cache. + /// + public long Total { get; private set; } + + /// + /// Gets the overall percentage of progress of caching. + /// + public int OverallPercentage { get; private set; } + } + + /// + /// Additional arguments used when the engine completes the acquisition of a container or payload. + /// + [Serializable] + public class CacheAcquireCompleteEventArgs : ActionEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CacheAcquireCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload (if acquiring a payload). + /// + public string PayloadId { get; private set; } + } + + /// + /// Additional arguments used when the engine starts the verification of a payload. + /// + [Serializable] + public class CacheVerifyBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CacheVerifyBeginEventArgs(string packageId, string payloadId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the package. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// Additional arguments used when the engine completes the verification of a payload. + /// + [Serializable] + public class CacheVerifyCompleteEventArgs : ActionEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CacheVerifyCompleteEventArgs(string packageId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageId = packageId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the package. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// Additional arguments used after the engine has cached the installation sources. + /// + [Serializable] + public class CacheCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public CacheCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has begun installing packages. + /// + [Serializable] + public class ExecuteBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The number of packages to act on. + /// The recommendation from the engine. + public ExecuteBeginEventArgs(int packageCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageCount = packageCount; + } + + /// + /// Gets the number of packages to act on. + /// + public int PackageCount { get; private set; } + } + + /// + /// Additional arguments used when the engine has begun installing a specific package. + /// + [Serializable] + public class ExecutePackageBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package to act on. + /// Whether the package should really be acted on. + /// The recommendation from the engine. + public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ShouldExecute = shouldExecute; + } + + /// + /// Gets the identity of the package to act on. + /// + public string PackageId { get; private set; } + + /// + /// Gets whether the package should really be acted on. + /// + public bool ShouldExecute { get; private set; } + } + + /// + /// Additional arguments used when the engine executes one or more patches targeting a product. + /// + [Serializable] + public class ExecutePatchTargetEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package to act on. + /// The product code of the target of the patch. + /// The recommendation from the engine. + public ExecutePatchTargetEventArgs(string packageId, string targetProductCode, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.TargetProductCode = targetProductCode; + } + + /// + /// Gets the identity of the package to act on. + /// + public string PackageId { get; private set; } + + /// + /// Gets the product code being targeted. + /// + public string TargetProductCode { get; private set; } + } + + /// + /// Additional arguments used when Windows Installer sends an installation message. + /// + [Serializable] + public class ExecuteMsiMessageEventArgs : ResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that yielded this message. + /// The type of this message. + /// Recommended display flags for this message. + /// The message. + /// The extended data for the message. + /// Recommended result from engine. + /// The result to return to the engine. + public ExecuteMsiMessageEventArgs(string packageId, InstallMessage messageType, int dwUIHint, string message, string[] data, Result recommendation, Result result) + : base(recommendation, result) + { + this.PackageId = packageId; + this.MessageType = messageType; + this.UIHint = dwUIHint; + this.Message = message; + this.Data = new ReadOnlyCollection(data ?? new string[] { }); + } + + /// + /// Gets the identity of the package that yielded this message. + /// + public string PackageId { get; private set; } + + /// + /// Gets the type of this message. + /// + public InstallMessage MessageType { get; private set; } + + /// + /// Gets the recommended display flags for this message. + /// + public int UIHint { get; private set; } + + /// + /// Gets the message. + /// + public string Message { get; private set; } + + /// + /// Gets the extended data for the message. + /// + public IList Data { get; private set; } + } + + /// + /// Additional arugments used for file in use installation messages. + /// + [Serializable] + public class ExecuteFilesInUseEventArgs : ResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that yielded the files in use message. + /// The list of files in use. + /// Recommended result from engine. + /// The result to return to the engine. + public ExecuteFilesInUseEventArgs(string packageId, string[] files, Result recommendation, Result result) + : base(recommendation, result) + { + this.PackageId = packageId; + this.Files = new ReadOnlyCollection(files ?? new string[] { }); + } + + /// + /// Gets the identity of the package that yielded the files in use message. + /// + public string PackageId { get; private set; } + + /// + /// Gets the list of files in use. + /// + public IList Files { get; private set; } + } + + /// + /// Additional arguments used when the engine has completed installing a specific package. + /// + [Serializable] + public class ExecutePackageCompleteEventArgs : ActionEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that was acted on. + /// The return code of the operation. + /// Whether a restart is required. + /// Recommended action from engine. + /// The action to perform. + public ExecutePackageCompleteEventArgs(string packageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageId = packageId; + this.Restart = restart; + } + + /// + /// Gets the identity of the package that was acted on. + /// + public string PackageId { get; private set; } + + /// + /// Gets the package restart state after being applied. + /// + public ApplyRestart Restart { get; private set; } + } + + /// + /// Additional arguments used when the engine has completed installing packages. + /// + [Serializable] + public class ExecuteCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public ExecuteCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments used when the engine has completed installing the bundle. + /// + [Serializable] + public class ApplyCompleteEventArgs : ActionEventArgs + { + /// + /// Creates a new instance of the clas. + /// + /// The return code of the operation. + /// Whether a restart is required. + /// Recommended action from engine. + /// The action to perform. + public ApplyCompleteEventArgs(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_APPLYCOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.Restart = restart; + } + + /// + /// Gets the apply restart state when complete. + /// + public ApplyRestart Restart { get; private set; } + } + + /// + /// Additional arguments used by the engine to allow the BA to change the source + /// using or . + /// + [Serializable] + public class ResolveSourceEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package or container that requires source. + /// The identity of the payload that requires source. + /// The current path used for source resolution. + /// Optional URL to download container or payload. + /// The recommended action from the engine. + /// The action to perform. + /// The recommendation from the engine. + public ResolveSourceEventArgs(string packageOrContainerId, string payloadId, string localSource, string downloadSource, BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, BOOTSTRAPPER_RESOLVESOURCE_ACTION action, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.LocalSource = localSource; + this.DownloadSource = downloadSource; + this.Recommendation = recommendation; + this.Action = action; + } + + /// + /// Gets the identity of the package or container that requires source. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identity of the payload that requires source. + /// + public string PayloadId { get; private set; } + + /// + /// Gets the current path used for source resolution. + /// + public string LocalSource { get; private set; } + + /// + /// Gets the optional URL to download container or payload. + /// + public string DownloadSource { get; private set; } + + /// + /// Gets the recommended action from the engine. + /// + public BOOTSTRAPPER_RESOLVESOURCE_ACTION Recommendation { get; private set; } + + /// + /// Gets or sets the action to perform. + /// + public BOOTSTRAPPER_RESOLVESOURCE_ACTION Action { get; set; } + } + + /// + /// Additional arguments used by the engine when it has begun caching a specific package. + /// + [Serializable] + public class CachePackageBeginEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that is being cached. + /// Number of payloads to be cached. + /// The size on disk required by the specific package. + /// The recommendation from the engine. + public CachePackageBeginEventArgs(string packageId, int cachePayloads, long packageCacheSize, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CachePayloads = cachePayloads; + this.PackageCacheSize = packageCacheSize; + } + + /// + /// Gets the identity of the package that is being cached. + /// + public string PackageId { get; private set; } + + /// + /// Gets number of payloads to be cached. + /// + public long CachePayloads { get; private set; } + + /// + /// Gets the size on disk required by the specific package. + /// + public long PackageCacheSize { get; private set; } + } + + /// + /// Additional arguments passed by the engine when it has completed caching a specific package. + /// + [Serializable] + public class CachePackageCompleteEventArgs : ActionEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package that was cached. + /// The return code of the operation. + /// Recommended action from engine. + /// The action to perform. + public CachePackageCompleteEventArgs(string packageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageId = packageId; + } + + /// + /// Gets the identity of the package that was cached. + /// + public string PackageId { get; private set; } + } + + /// + /// Additional arguments passed by the engine while executing on payload. + /// + [Serializable] + public class ExecuteProgressEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identifier of the package being executed. + /// The percentage from 0 to 100 of the execution progress for a single payload. + /// The percentage from 0 to 100 of the execution progress for all payload. + /// The recommendation from the engine. + public ExecuteProgressEventArgs(string packageId, int progressPercentage, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ProgressPercentage = progressPercentage; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the identity of the package that was executed. + /// + public string PackageId { get; private set; } + + /// + /// Gets the percentage from 0 to 100 of the execution progress for a single payload. + /// + public int ProgressPercentage { get; private set; } + + /// + /// Gets the percentage from 0 to 100 of the execution progress for all payloads. + /// + public int OverallPercentage { get; private set; } + } + + /// + /// Additional arguments passed by the engine before it tries to launch the preapproved executable. + /// + [Serializable] + public class LaunchApprovedExeBeginArgs : CancellableHResultEventArgs + { + public LaunchApprovedExeBeginArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments passed by the engine after it finished trying to launch the preapproved executable. + /// + [Serializable] + public class LaunchApprovedExeCompleteArgs : StatusEventArgs + { + private int processId; + + public LaunchApprovedExeCompleteArgs(int hrStatus, int processId) + : base(hrStatus) + { + this.processId = processId; + } + + /// + /// Gets the ProcessId of the process that was launched. + /// This is only valid if the status reports success. + /// + public int ProcessId + { + get { return this.processId; } + } + } +} diff --git a/src/WixToolset.Mba.Core/Exceptions.cs b/src/WixToolset.Mba.Core/Exceptions.cs new file mode 100644 index 00000000..360b360d --- /dev/null +++ b/src/WixToolset.Mba.Core/Exceptions.cs @@ -0,0 +1,145 @@ +// 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.BootstrapperCore +{ + using System; + using System.Runtime.Serialization; + + /// + /// Base class for exception returned to the bootstrapper application host. + /// + [Serializable] + public abstract class BootstrapperException : Exception + { + /// + /// Creates an instance of the base class with the given HRESULT. + /// + /// The HRESULT for the exception that is used by the bootstrapper application host. + public BootstrapperException(int hr) + { + this.HResult = hr; + } + + /// + /// Initializes a new instance of the class. + /// + /// Exception message. + public BootstrapperException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Exception message + /// Inner exception associated with this one + public BootstrapperException(string message, Exception innerException) + : base(message, innerException) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Serialization information for this exception + /// Streaming context to serialize to + protected BootstrapperException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } + + /// + /// The bootstrapper application assembly loaded by the host does not contain exactly one instance of the + /// class. + /// + /// + [Serializable] + public class MissingAttributeException : BootstrapperException + { + /// + /// Creates a new instance of the class. + /// + public MissingAttributeException() + : base(NativeMethods.E_NOTFOUND) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Exception message. + public MissingAttributeException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Exception message + /// Inner exception associated with this one + public MissingAttributeException(string message, Exception innerException) + : base(message, innerException) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Serialization information for this exception + /// Streaming context to serialize to + protected MissingAttributeException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } + + /// + /// The bootstrapper application factory specified by the + /// does not extend the base class. + /// + /// + /// + [Serializable] + public class InvalidBootstrapperApplicationFactoryException : BootstrapperException + { + /// + /// Creates a new instance of the class. + /// + public InvalidBootstrapperApplicationFactoryException() + : base(NativeMethods.E_UNEXPECTED) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Exception message. + public InvalidBootstrapperApplicationFactoryException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Exception message + /// Inner exception associated with this one + public InvalidBootstrapperApplicationFactoryException(string message, Exception innerException) + : base(message, innerException) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Serialization information for this exception + /// Streaming context to serialize to + protected InvalidBootstrapperApplicationFactoryException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/WixToolset.Mba.Core/HostSection.cs b/src/WixToolset.Mba.Core/HostSection.cs new file mode 100644 index 00000000..e5b7ea64 --- /dev/null +++ b/src/WixToolset.Mba.Core/HostSection.cs @@ -0,0 +1,47 @@ +// 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.BootstrapperCore +{ + using System; + using System.Configuration; + + /// + /// Handler for the Host configuration section. + /// + public sealed class HostSection : ConfigurationSection + { + private static readonly ConfigurationProperty assemblyNameProperty = new ConfigurationProperty("assemblyName", typeof(string), null, ConfigurationPropertyOptions.IsRequired); + private static readonly ConfigurationProperty supportedFrameworksProperty = new ConfigurationProperty("", typeof(SupportedFrameworkElementCollection), null, ConfigurationPropertyOptions.IsDefaultCollection); + + /// + /// Creates a new instance of the class. + /// + public HostSection() + { + } + + /// + /// Gets the name of the assembly that contians the child class. + /// + /// + /// The assembly specified by this name must contain the to identify + /// the type of the child class. + /// + [ConfigurationProperty("assemblyName", IsRequired = true)] + public string AssemblyName + { + get { return (string)base[assemblyNameProperty]; } + set { base[assemblyNameProperty] = value; } + } + + /// + /// Gets the of supported frameworks for the host configuration. + /// + [ConfigurationProperty("", IsDefaultCollection = true)] + [ConfigurationCollection(typeof(SupportedFrameworkElement))] + public SupportedFrameworkElementCollection SupportedFrameworks + { + get { return (SupportedFrameworkElementCollection)base[supportedFrameworksProperty]; } + } + } +} diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs new file mode 100644 index 00000000..c8c6e6e3 --- /dev/null +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs @@ -0,0 +1,12 @@ +// 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.BootstrapperCore +{ + using System.IO; + + public interface IBootstrapperApplicationData + { + FileInfo BADataFile { get; } + IBundleInfo Bundle { get; } + } +} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs new file mode 100644 index 00000000..414d28ed --- /dev/null +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -0,0 +1,52 @@ +// 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.BootstrapperCore +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.InteropServices; + + [ComVisible(true)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("2965A12F-AC7B-43A0-85DF-E4B2168478A4")] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public interface IBootstrapperApplicationFactory + { + IBootstrapperApplication Create( + [MarshalAs(UnmanagedType.Interface)] IBootstrapperEngine pEngine, + ref Command command + ); + } + + [Serializable] + [StructLayout(LayoutKind.Sequential)] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public struct Command + { + [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; + [MarshalAs(UnmanagedType.U4)] private readonly Display display; + [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; + [MarshalAs(UnmanagedType.LPWStr)] private readonly string 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; + [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzLayoutDirectory; + + public IBootstrapperCommand GetBootstrapperCommand() + { + return new BootstrapperCommand( + this.action, + this.display, + this.restart, + this.wzCommandLine, + this.nCmdShow, + this.resume, + this.hwndSplashScreen, + this.relation, + this.passthrough, + this.wzLayoutDirectory); + } + } +} diff --git a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs new file mode 100644 index 00000000..332b4c3b --- /dev/null +++ b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs @@ -0,0 +1,63 @@ +// 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.BootstrapperCore +{ + using System; + + /// + /// Command information passed from the engine for the BA to perform. + /// + public interface IBootstrapperCommand + { + /// + /// Gets the action for the BA to perform. + /// + LaunchAction Action { get; } + + /// + /// Gets the display level for the BA. + /// + Display Display { get; } + + /// + /// Gets the action to perform if a reboot is required. + /// + Restart Restart { get; } + + /// + /// Gets the command line arguments as a string array. + /// + /// + /// Array of command line arguments not handled by the engine. + /// + /// The command line could not be parsed into an array. + string[] CommandLineArgs { get; } + + int CmdShow { get; } + + /// + /// Gets the method of how the engine was resumed from a previous installation step. + /// + ResumeType Resume { get; } + + /// + /// Gets the handle to the splash screen window. If no splash screen was displayed this value will be IntPtr.Zero. + /// + IntPtr SplashScreen { get; } + + /// + /// If this was run from a related bundle, specifies the relation type. + /// + RelationType Relation { get; } + + /// + /// If this was run from a backward compatible bundle. + /// + bool Passthrough { get; } + + /// + /// Gets layout directory. + /// + string LayoutDirectory { get; } + } +} diff --git a/src/WixToolset.Mba.Core/IBundleInfo.cs b/src/WixToolset.Mba.Core/IBundleInfo.cs new file mode 100644 index 00000000..a5f4b9c7 --- /dev/null +++ b/src/WixToolset.Mba.Core/IBundleInfo.cs @@ -0,0 +1,16 @@ +// 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.BootstrapperCore +{ + using System.Collections.Generic; + + public interface IBundleInfo + { + string LogVariable { get; } + string Name { get; } + IDictionary Packages { get; } + bool PerMachine { get; } + + void AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); + } +} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs new file mode 100644 index 00000000..ccbe84db --- /dev/null +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -0,0 +1,65 @@ +// 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.BootstrapperCore +{ + using System; + + public interface IDefaultBootstrapperApplication : IBootstrapperApplication + { + event EventHandler ApplyBegin; + event EventHandler ApplyComplete; + event EventHandler CacheAcquireBegin; + event EventHandler CacheAcquireComplete; + event EventHandler CacheAcquireProgress; + event EventHandler CacheBegin; + event EventHandler CacheComplete; + event EventHandler CachePackageBegin; + event EventHandler CachePackageComplete; + event EventHandler CacheVerifyBegin; + event EventHandler CacheVerifyComplete; + event EventHandler DetectBegin; + event EventHandler DetectCompatibleMsiPackage; + event EventHandler DetectComplete; + event EventHandler DetectForwardCompatibleBundle; + event EventHandler DetectMsiFeature; + event EventHandler DetectPackageBegin; + event EventHandler DetectPackageComplete; + event EventHandler DetectRelatedBundle; + event EventHandler DetectRelatedMsiPackage; + event EventHandler DetectTargetMsiPackage; + event EventHandler DetectUpdate; + event EventHandler DetectUpdateBegin; + event EventHandler DetectUpdateComplete; + event EventHandler ElevateBegin; + event EventHandler ElevateComplete; + event EventHandler Error; + event EventHandler ExecuteBegin; + event EventHandler ExecuteComplete; + event EventHandler ExecuteFilesInUse; + event EventHandler ExecuteMsiMessage; + event EventHandler ExecutePackageBegin; + event EventHandler ExecutePackageComplete; + event EventHandler ExecutePatchTarget; + event EventHandler ExecuteProgress; + event EventHandler LaunchApprovedExeBegin; + event EventHandler LaunchApprovedExeComplete; + event EventHandler PlanBegin; + event EventHandler PlanCompatibleMsiPackageBegin; + event EventHandler PlanCompatibleMsiPackageComplete; + event EventHandler PlanComplete; + event EventHandler PlanMsiFeature; + event EventHandler PlanPackageBegin; + event EventHandler PlanPackageComplete; + event EventHandler PlanRelatedBundle; + event EventHandler PlanTargetMsiPackage; + event EventHandler Progress; + event EventHandler RegisterBegin; + event EventHandler RegisterComplete; + event EventHandler ResolveSource; + event EventHandler Shutdown; + event EventHandler Startup; + event EventHandler SystemShutdown; + event EventHandler UnregisterBegin; + event EventHandler UnregisterComplete; + } +} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs new file mode 100644 index 00000000..46b8158a --- /dev/null +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -0,0 +1,176 @@ +// 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.BootstrapperCore +{ + using System; + using System.ComponentModel; + using System.Security; + + public interface IEngine + { + /// + /// Gets or sets numeric variables for the engine. + /// + IVariables NumericVariables { get; } + + /// + /// Gets the number of packages in the bundle. + /// + int PackageCount { get; } + + /// + /// Gets or sets string variables for the engine using SecureStrings. + /// + IVariables SecureStringVariables { get; } + + /// + /// Gets or sets string variables for the engine. + /// + IVariables StringVariables { get; } + + /// + /// Gets or sets variables for the engine. + /// + /// The class can keep track of when the build and revision fields are undefined, but the engine can't. + /// Therefore, the build and revision fields must be defined when setting a variable. + /// Use the NormalizeVersion method to make sure the engine can accept the Version. + /// + /// To keep track of versions without build or revision fields, use StringVariables instead. + /// + /// The given was invalid. + IVariables VersionVariables { get; } + + /// + /// Install the packages. + /// + /// The parent window for the installation user interface. + void Apply(IntPtr hwndParent); + + /// + /// Close the splash screen if it is still open. Does nothing if the splash screen is not or + /// never was opened. + /// + void CloseSplashScreen(); + + /// + /// Determine if all installation conditions are fulfilled. + /// + void Detect(); + + /// + /// Determine if all installation conditions are fulfilled. + /// + /// The parent window for the installation user interface. + void Detect(IntPtr hwndParent); + + /// + /// Elevate the install. + /// + /// The parent window of the elevation dialog. + /// true if elevation succeeded; otherwise, false if the user cancelled. + /// A Win32 error occurred. + bool Elevate(IntPtr hwndParent); + + /// + /// Escapes the input string. + /// + /// The string to escape. + /// The escaped string. + /// A Win32 error occurred. + string EscapeString(string input); + + /// + /// Evaluates the string. + /// + /// The string representing the condition to evaluate. + /// Whether the condition evaluated to true or false. + bool EvaluateCondition(string condition); + + /// + /// Formats the input string. + /// + /// The string to format. + /// The formatted string. + /// A Win32 error occurred. + string FormatString(string format); + + /// + /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. + /// + /// The parent window of the elevation dialog (if the engine hasn't elevated yet). + /// Id of the ApprovedExeForElevation element specified when the bundle was authored. + /// Optional arguments. + void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments); + + /// + /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. + /// + /// The parent window of the elevation dialog (if the engine hasn't elevated yet). + /// Id of the ApprovedExeForElevation element specified when the bundle was authored. + /// Optional arguments. + /// Timeout in milliseconds. When set to something other than zero, the engine will call WaitForInputIdle for the new process with this timeout before calling OnLaunchApprovedExeComplete. + void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout); + + /// + /// Logs the . + /// + /// The logging level. + /// The message to log. + void Log(LogLevel level, string message); + + /// + /// Determine the installation sequencing and costing. + /// + /// The action to perform when planning. + void Plan(LaunchAction action); + + /// + /// Set the update information for a bundle. + /// + /// Optional local source path for the update. Default is "update\[OriginalNameOfBundle].exe". + /// Optional download source for the update. + /// 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, byte[] hash); + + /// + /// Set the local source for a package or container. + /// + /// The id that uniquely identifies the package or container. + /// The id that uniquely identifies the payload. + /// The new source path. + void SetLocalSource(string packageOrContainerId, string payloadId, string path); + + /// + /// Set the new download URL for a package or container. + /// + /// The id that uniquely identifies the package or container. + /// The id that uniquely identifies the payload. + /// The new url. + /// The user name for proxy authentication. + /// The password for proxy authentication. + void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password); + + /// + /// Sends error message when embedded. + /// + /// Error code. + /// Error message. + /// UI buttons to show on error dialog. + int SendEmbeddedError(int errorCode, string message, int uiHint); + + /// + /// Sends progress percentages when embedded. + /// + /// Percentage completed thus far. + /// Overall percentage completed. + int SendEmbeddedProgress(int progressPercentage, int overallPercentage); + + /// + /// Shuts down the engine. + /// + /// Exit code indicating reason for shut down. + void Quit(int exitCode); + } +} diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs new file mode 100644 index 00000000..f4c7c558 --- /dev/null +++ b/src/WixToolset.Mba.Core/IPackageInfo.cs @@ -0,0 +1,20 @@ +// 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.BootstrapperCore +{ + public interface IPackageInfo + { + CacheType CacheType { get; } + string Description { get; } + bool DisplayInternalUI { get; } + string DisplayName { get; } + string Id { get; } + string InstallCondition { get; } + bool Permanent { get; } + string ProductCode { get; } + PackageType Type { get; } + string UpgradeCode { get; } + string Version { get; } + bool Vital { get; } + } +} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IVariables.cs b/src/WixToolset.Mba.Core/IVariables.cs new file mode 100644 index 00000000..15da4c84 --- /dev/null +++ b/src/WixToolset.Mba.Core/IVariables.cs @@ -0,0 +1,27 @@ +// 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.BootstrapperCore +{ + using System; + + /// + /// An accessor for numeric, string, and version variables for the engine. + /// + public interface IVariables + { + /// + /// Gets or sets the variable given by . + /// + /// The name of the variable to get/set. + /// The value of the given variable. + /// An error occurred getting the variable. + T this[string name] { get; set; } + + /// + /// Gets whether the variable given by exists. + /// + /// The name of the variable to check. + /// True if the variable given by exists; otherwise, false. + bool Contains(string name); + } +} diff --git a/src/WixToolset.Mba.Core/NativeMethods.cs b/src/WixToolset.Mba.Core/NativeMethods.cs new file mode 100644 index 00000000..1964cb45 --- /dev/null +++ b/src/WixToolset.Mba.Core/NativeMethods.cs @@ -0,0 +1,37 @@ +// 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.BootstrapperCore +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Contains native constants, functions, and structures for this assembly. + /// + internal static class NativeMethods + { + #region Error Constants + internal const int S_OK = 0; + internal const int E_MOREDATA = unchecked((int)0x800700ea); + internal const int E_INSUFFICIENT_BUFFER = unchecked((int)0x8007007a); + internal const int E_CANCELLED = unchecked((int)0x800704c7); + internal const int E_ALREADYINITIALIZED = unchecked((int)0x800704df); + internal const int E_NOTFOUND = unchecked((int)0x80070490); + internal const int E_NOTIMPL = unchecked((int)0x80004001); + internal const int E_UNEXPECTED = unchecked((int)0x8000ffff); + #endregion + + #region Functions + [DllImport("shell32.dll", ExactSpelling = true, SetLastError = true)] + internal static extern IntPtr CommandLineToArgvW( + [MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine, + out int pNumArgs + ); + + [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)] + internal static extern IntPtr LocalFree( + IntPtr hMem + ); + #endregion + } +} diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs new file mode 100644 index 00000000..99ebb33a --- /dev/null +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -0,0 +1,181 @@ +// 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.BootstrapperCore +{ + using System; + using System.Collections.Generic; + using System.Xml; + using System.Xml.XPath; + + public enum CacheType + { + No, + Yes, + Always, + } + + public enum PackageType + { + Unknown, + Exe, + Msi, + Msp, + Msu, + UpgradeBundle, + AddonBundle, + PatchBundle, + } + + public class PackageInfo : IPackageInfo + { + public string Id { get; internal set; } + public string DisplayName { get; internal set; } + public string Description { get; internal set; } + public PackageType Type { get; internal set; } + public bool Permanent { get; internal set; } + public bool Vital { get; internal set; } + public bool DisplayInternalUI { get; internal set; } + public string ProductCode { get; internal set; } + public string UpgradeCode { get; internal set; } + public string Version { get; internal set; } + public string InstallCondition { get; internal set; } + public CacheType CacheType { get; internal set; } + + internal PackageInfo() { } + + public static IEnumerable ParsePackagesFromXml(XPathNavigator root) + { + XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); + namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); + XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); + + foreach (XPathNavigator node in nodes) + { + var package = new PackageInfo(); + + string id = BootstrapperApplicationData.GetAttribute(node, "Package"); + if (id == null) + { + throw new Exception("Failed to get package identifier for package."); + } + package.Id = id; + + package.DisplayName = BootstrapperApplicationData.GetAttribute(node, "DisplayName"); + + package.Description = BootstrapperApplicationData.GetAttribute(node, "Description"); + + PackageType? packageType = GetPackageTypeAttribute(node, "PackageType"); + if (!packageType.HasValue) + { + throw new Exception("Failed to get package type for package."); + } + package.Type = packageType.Value; + + bool? permanent = BootstrapperApplicationData.GetYesNoAttribute(node, "Permanent"); + if (!permanent.HasValue) + { + throw new Exception("Failed to get permanent settings for package."); + } + package.Permanent = permanent.Value; + + bool? vital = BootstrapperApplicationData.GetYesNoAttribute(node, "Vital"); + if (!vital.HasValue) + { + throw new Exception("Failed to get vital setting for package."); + } + package.Vital = vital.Value; + + bool? displayInternalUI = BootstrapperApplicationData.GetYesNoAttribute(node, "DisplayInternalUI"); + package.DisplayInternalUI = displayInternalUI.HasValue && displayInternalUI.Value; + + package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); + + package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); + + package.Version = BootstrapperApplicationData.GetAttribute(node, "Version"); + + package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); + + yield return package; + } + } + + public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + if (attributeValue.Equals("yes", StringComparison.InvariantCulture)) + { + return CacheType.Yes; + } + else if (attributeValue.Equals("always", StringComparison.InvariantCulture)) + { + return CacheType.Always; + } + else + { + return CacheType.No; + } + } + + public static PackageType? GetPackageTypeAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + if (attributeValue.Equals("Exe", StringComparison.InvariantCulture)) + { + return PackageType.Exe; + } + else if (attributeValue.Equals("Msi", StringComparison.InvariantCulture)) + { + return PackageType.Msi; + } + else if (attributeValue.Equals("Msp", StringComparison.InvariantCulture)) + { + return PackageType.Msp; + } + else if (attributeValue.Equals("Msu", StringComparison.InvariantCulture)) + { + return PackageType.Msu; + } + else + { + return PackageType.Unknown; + } + } + + public static PackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) + { + PackageInfo package = new PackageInfo(); + package.Id = id; + package.Version = version.ToString(); + + switch (relationType) + { + case RelationType.Addon: + package.Type = PackageType.AddonBundle; + break; + case RelationType.Patch: + package.Type = PackageType.PatchBundle; + break; + case RelationType.Upgrade: + package.Type = PackageType.UpgradeBundle; + break; + default: + throw new Exception(string.Format("Unknown related bundle type: {0}", relationType)); + } + + return package; + } + } +} diff --git a/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs b/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs new file mode 100644 index 00000000..37a31b69 --- /dev/null +++ b/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs @@ -0,0 +1,47 @@ +// 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.BootstrapperCore +{ + using System; + using System.Configuration; + + /// + /// Handler for the supportedFramework configuration section. + /// + public sealed class SupportedFrameworkElement : ConfigurationElement + { + private static readonly ConfigurationProperty versionProperty = new ConfigurationProperty("version", typeof(string), null, ConfigurationPropertyOptions.IsRequired); + private static readonly ConfigurationProperty runtimeVersionProperty = new ConfigurationProperty("runtimeVersion", typeof(string)); + + /// + /// Creates a new instance of the class. + /// + public SupportedFrameworkElement() + { + } + + /// + /// Gets the version of the supported framework. + /// + /// + /// The assembly specified by this name must contain a value matching the NETFX version registry key under + /// "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP". + /// + [ConfigurationProperty("version", IsRequired = true)] + public string Version + { + get { return (string)base[versionProperty]; } + set { base[versionProperty] = value; } + } + + /// + /// Gets the runtime version required by this supported framework. + /// + [ConfigurationProperty("runtimeVersion", IsRequired = false)] + public string RuntimeVersion + { + get { return (string)base[runtimeVersionProperty]; } + set { base[runtimeVersionProperty] = value; } + } + } +} diff --git a/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs b/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs new file mode 100644 index 00000000..1a5aa2de --- /dev/null +++ b/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs @@ -0,0 +1,36 @@ +// 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.BootstrapperCore +{ + using System; + using System.Configuration; + using System.Diagnostics.CodeAnalysis; + + /// + /// Handler for the supportedFramework collection. + /// + [SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")] + [ConfigurationCollection(typeof(SupportedFrameworkElement), AddItemName = "supportedFramework", CollectionType = ConfigurationElementCollectionType.BasicMap)] + public sealed class SupportedFrameworkElementCollection : ConfigurationElementCollection + { + public override ConfigurationElementCollectionType CollectionType + { + get { return ConfigurationElementCollectionType.BasicMap; } + } + + protected override string ElementName + { + get { return "supportedFramework"; } + } + + protected override ConfigurationElement CreateNewElement() + { + return new SupportedFrameworkElement(); + } + + protected override object GetElementKey(ConfigurationElement element) + { + return (element as SupportedFrameworkElement).Version; + } + } +} diff --git a/src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config b/src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config new file mode 100644 index 00000000..1e284001 --- /dev/null +++ b/src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config @@ -0,0 +1,26 @@ + + + + + + + +
+ + + + + + + + + + + + + + diff --git a/src/balutil/inc/IBootstrapperApplicationFactory.h b/src/balutil/inc/IBootstrapperApplicationFactory.h new file mode 100644 index 00000000..e29c23bc --- /dev/null +++ b/src/balutil/inc/IBootstrapperApplicationFactory.h @@ -0,0 +1,14 @@ +#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 IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_COMMAND *pCommand, + __out IBootstrapperApplication **ppApplication + ); +}; -- cgit v1.2.3-55-g6feb From 20bbfc8ad82e6246f5357d8bc183a5fc0ea3fac7 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 11 Dec 2019 20:15:08 +1100 Subject: Setup WixToolset.Mba.Core project and nuget package. --- appveyor.cmd | 1 + balutil.sln | 10 ++ src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs | 17 ++++ .../WixToolset.BootstrapperCore.config | 26 ----- src/WixToolset.Mba.Core/WixToolset.Mba.Core.config | 26 +++++ src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 111 +++++++++++++++++++++ src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 21 ++++ src/WixToolset.Mba.Core/packages.config | 5 + src/balutil/balutil.nuspec | 2 +- src/balutil/balutil.vcxproj | 9 +- src/balutil/packages.config | 4 +- 11 files changed, 199 insertions(+), 33 deletions(-) create mode 100644 src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs delete mode 100644 src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config create mode 100644 src/WixToolset.Mba.Core/WixToolset.Mba.Core.config create mode 100644 src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj create mode 100644 src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec create mode 100644 src/WixToolset.Mba.Core/packages.config (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index ee397c4a..1aceb3b0 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -8,6 +8,7 @@ msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v140_xp msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v141_xp msbuild -p:Configuration=Release -t:Pack src\balutil\balutil.vcxproj +msbuild -p:Configuration=Release -t:Pack src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj @popd @endlocal \ No newline at end of file diff --git a/balutil.sln b/balutil.sln index 58f61391..9ed8e3f5 100644 --- a/balutil.sln +++ b/balutil.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 15.0.26124.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balutil.vcxproj", "{EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -21,6 +23,14 @@ Global {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.Build.0 = Release|x64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.ActiveCfg = Release|Win32 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.Build.0 = Release|Win32 + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs b/src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..386748a8 --- /dev/null +++ b/src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,17 @@ +// 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. + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Managed Bootstrapper Application Core (WiX)")] +[assembly: AssemblyDescription("Managed Bootstrapper Application Core")] +[assembly: AssemblyProduct("WiX Toolset")] +[assembly: AssemblyCompany("WiX Toolset Team")] +[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and contributors. All rights reserved.")] + +// Types should not be visible to COM by default. +[assembly: ComVisible(false)] +[assembly: Guid("6f4e0cc9-8ad4-4b5a-a669-3aafff67a76f")] + +[assembly: CLSCompliantAttribute(true)] diff --git a/src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config b/src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config deleted file mode 100644 index 1e284001..00000000 --- a/src/WixToolset.Mba.Core/WixToolset.BootstrapperCore.config +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - -
- - - - - - - - - - - - - - diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config new file mode 100644 index 00000000..1e284001 --- /dev/null +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config @@ -0,0 +1,26 @@ + + + + + + + +
+ + + + + + + + + + + + + + diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj new file mode 100644 index 00000000..16d278b0 --- /dev/null +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -0,0 +1,111 @@ + + + + + + + {E7E1841E-A58E-4901-B9CA-4845B807D45F} + WixToolset.Mba.Core + Library + WixToolset.Mba.Core + 0693;1591 + v2.0 + Managed Bootstrapper Application entry point + + + true + false + $(DefineConstants);DEBUG;TRACE + + + true + true + $(DefineConstants);TRACE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + + + + + ..\..\packages\WixToolset.BootstrapperCore.4.0.8\lib\net20\WixToolset.BootstrapperCore.dll + + + + + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + $(OutputPath)\$(AssemblyName).xml + + \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec new file mode 100644 index 00000000..04eee9ec --- /dev/null +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -0,0 +1,21 @@ + + + + $id$ + $version$ + WiX Toolset Team + WiX Toolset Team + + https://licenses.nuget.org/MS-RL + https://github.com/wixtoolset/BootstrapperCore + false + $description$ + $copyright$ + + + + + + + + diff --git a/src/WixToolset.Mba.Core/packages.config b/src/WixToolset.Mba.Core/packages.config new file mode 100644 index 00000000..3702a604 --- /dev/null +++ b/src/WixToolset.Mba.Core/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec index 67ed9bde..0a26004a 100644 --- a/src/balutil/balutil.nuspec +++ b/src/balutil/balutil.nuspec @@ -12,7 +12,7 @@ $description$ $copyright$ - + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index a8b97615..42aa909e 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -70,6 +70,7 @@ + @@ -87,8 +88,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 52c84cf0..769c5a6e 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 46d46435592ba779d6c8d017859c27d90b092aa6 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 11 Dec 2019 20:27:17 +1100 Subject: Update the namespace in WixToolset.Mba.Core. --- balutil.sln | 2 +- src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs | 4 +++- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 3 ++- src/WixToolset.Mba.Core/BootstrapperApplicationData.cs | 2 +- src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs | 3 ++- .../BootstrapperApplicationFactoryAttribute.cs | 2 +- src/WixToolset.Mba.Core/BootstrapperCommand.cs | 3 ++- src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs | 2 +- src/WixToolset.Mba.Core/BundleInfo.cs | 2 +- src/WixToolset.Mba.Core/Engine.cs | 3 ++- src/WixToolset.Mba.Core/EventArgs.cs | 3 ++- src/WixToolset.Mba.Core/Exceptions.cs | 2 +- src/WixToolset.Mba.Core/HostSection.cs | 2 +- src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs | 2 +- src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs | 3 ++- src/WixToolset.Mba.Core/IBootstrapperCommand.cs | 3 ++- src/WixToolset.Mba.Core/IBundleInfo.cs | 2 +- src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs | 3 ++- src/WixToolset.Mba.Core/IEngine.cs | 3 ++- src/WixToolset.Mba.Core/IPackageInfo.cs | 2 +- src/WixToolset.Mba.Core/IVariables.cs | 2 +- src/WixToolset.Mba.Core/NativeMethods.cs | 2 +- src/WixToolset.Mba.Core/PackageInfo.cs | 3 ++- src/WixToolset.Mba.Core/SupportedFrameworkElement.cs | 2 +- src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs | 2 +- src/WixToolset.Mba.Core/WixToolset.Mba.Core.config | 8 ++++---- 26 files changed, 41 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/balutil.sln b/balutil.sln index 9ed8e3f5..7c170206 100644 --- a/balutil.sln +++ b/balutil.sln @@ -28,7 +28,7 @@ Global {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.ActiveCfg = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.Build.0 = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.ActiveCfg = Release|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.ActiveCfg = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index e9b60929..08d2c4d8 100644 --- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -1,7 +1,9 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { + using WixToolset.BootstrapperCore; + public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory { public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index c08a60c7..52667923 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1,10 +1,11 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Runtime.InteropServices; using System.Threading; + using WixToolset.BootstrapperCore; /// /// The default bootstrapper application. diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs index a17f1a05..d6d590ba 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.IO; diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs index 28430bb8..de12ca17 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs @@ -1,11 +1,12 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Configuration; using System.Reflection; using System.Runtime.InteropServices; + using WixToolset.BootstrapperCore; /// /// Entry point for the MBA host to create and return the IBootstrapperApplication implementation to the engine. diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs index 781d4ea1..95252cf3 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; diff --git a/src/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/WixToolset.Mba.Core/BootstrapperCommand.cs index bbd10e1d..1ca64924 100644 --- a/src/WixToolset.Mba.Core/BootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -1,10 +1,11 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.ComponentModel; using System.Runtime.InteropServices; + using WixToolset.BootstrapperCore; public sealed class BootstrapperCommand : IBootstrapperCommand { diff --git a/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs b/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs index 7721c027..f307e53e 100644 --- a/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs +++ b/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Configuration; diff --git a/src/WixToolset.Mba.Core/BundleInfo.cs b/src/WixToolset.Mba.Core/BundleInfo.cs index 51c2d268..e6d2f6e6 100644 --- a/src/WixToolset.Mba.Core/BundleInfo.cs +++ b/src/WixToolset.Mba.Core/BundleInfo.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Collections.Generic; diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index ad62134f..2e094bb9 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -1,12 +1,13 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.ComponentModel; using System.Runtime.InteropServices; using System.Security; using System.Text; + using WixToolset.BootstrapperCore; /// /// Container class for the interface. diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 9e8e6ecc..26a3b573 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -1,10 +1,11 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Collections.Generic; using System.Collections.ObjectModel; + using WixToolset.BootstrapperCore; /// /// Base class for BA classes. diff --git a/src/WixToolset.Mba.Core/Exceptions.cs b/src/WixToolset.Mba.Core/Exceptions.cs index 360b360d..72669a42 100644 --- a/src/WixToolset.Mba.Core/Exceptions.cs +++ b/src/WixToolset.Mba.Core/Exceptions.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Runtime.Serialization; diff --git a/src/WixToolset.Mba.Core/HostSection.cs b/src/WixToolset.Mba.Core/HostSection.cs index e5b7ea64..2586f565 100644 --- a/src/WixToolset.Mba.Core/HostSection.cs +++ b/src/WixToolset.Mba.Core/HostSection.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Configuration; diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs index c8c6e6e3..a19a34b5 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System.IO; diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index 414d28ed..6dd4af72 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -1,10 +1,11 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.CodeDom.Compiler; using System.Runtime.InteropServices; + using WixToolset.BootstrapperCore; [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] diff --git a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs index 332b4c3b..fc7d1fc2 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs @@ -1,8 +1,9 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; + using WixToolset.BootstrapperCore; /// /// Command information passed from the engine for the BA to perform. diff --git a/src/WixToolset.Mba.Core/IBundleInfo.cs b/src/WixToolset.Mba.Core/IBundleInfo.cs index a5f4b9c7..3d5b067e 100644 --- a/src/WixToolset.Mba.Core/IBundleInfo.cs +++ b/src/WixToolset.Mba.Core/IBundleInfo.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System.Collections.Generic; diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index ccbe84db..ee290865 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -1,8 +1,9 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; + using WixToolset.BootstrapperCore; public interface IDefaultBootstrapperApplication : IBootstrapperApplication { diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 46b8158a..6aef50b3 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -1,10 +1,11 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.ComponentModel; using System.Security; + using WixToolset.BootstrapperCore; public interface IEngine { diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs index f4c7c558..5afe4b38 100644 --- a/src/WixToolset.Mba.Core/IPackageInfo.cs +++ b/src/WixToolset.Mba.Core/IPackageInfo.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { public interface IPackageInfo { diff --git a/src/WixToolset.Mba.Core/IVariables.cs b/src/WixToolset.Mba.Core/IVariables.cs index 15da4c84..c7994f0b 100644 --- a/src/WixToolset.Mba.Core/IVariables.cs +++ b/src/WixToolset.Mba.Core/IVariables.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; diff --git a/src/WixToolset.Mba.Core/NativeMethods.cs b/src/WixToolset.Mba.Core/NativeMethods.cs index 1964cb45..adb2256e 100644 --- a/src/WixToolset.Mba.Core/NativeMethods.cs +++ b/src/WixToolset.Mba.Core/NativeMethods.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Runtime.InteropServices; diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index 99ebb33a..9bc21923 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -1,11 +1,12 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Collections.Generic; using System.Xml; using System.Xml.XPath; + using WixToolset.BootstrapperCore; public enum CacheType { diff --git a/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs b/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs index 37a31b69..7eae8bbf 100644 --- a/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs +++ b/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Configuration; diff --git a/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs b/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs index 1a5aa2de..88a9b4dd 100644 --- a/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs +++ b/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs @@ -1,6 +1,6 @@ // 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.BootstrapperCore +namespace WixToolset.Mba.Core { using System; using System.Configuration; diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config index 1e284001..81b49347 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config @@ -4,8 +4,8 @@ - -
+ +
@@ -20,7 +20,7 @@ --> - - + + -- cgit v1.2.3-55-g6feb From f3c383c2412e376353d64a8b744184fa1cee1c6e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 21 Dec 2019 11:23:03 +1100 Subject: Move IBootstrapperApplication and IBootstrapperEngine into balutil. --- .../BaseBootstrapperApplicationFactory.cs | 2 - src/WixToolset.Mba.Core/BootstrapperApplication.cs | 5 +- .../BootstrapperApplicationFactory.cs | 1 - src/WixToolset.Mba.Core/BootstrapperCommand.cs | 1 - src/WixToolset.Mba.Core/Engine.cs | 1 - src/WixToolset.Mba.Core/EventArgs.cs | 1 - .../IBootstrapperApplication.cs | 834 +++++++++++++++++++++ .../IBootstrapperApplicationFactory.cs | 1 - src/WixToolset.Mba.Core/IBootstrapperCommand.cs | 1 - src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 279 +++++++ .../IDefaultBootstrapperApplication.cs | 1 - src/WixToolset.Mba.Core/IEngine.cs | 1 - src/WixToolset.Mba.Core/PackageInfo.cs | 1 - src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 5 +- src/WixToolset.Mba.Core/packages.config | 1 - src/balutil/inc/IBootstrapperApplication.h | 525 +++++++++++++ src/balutil/inc/IBootstrapperEngine.h | 128 ++++ 17 files changed, 1770 insertions(+), 18 deletions(-) create mode 100644 src/WixToolset.Mba.Core/IBootstrapperApplication.cs create mode 100644 src/WixToolset.Mba.Core/IBootstrapperEngine.cs create mode 100644 src/balutil/inc/IBootstrapperApplication.h create mode 100644 src/balutil/inc/IBootstrapperEngine.h (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index 08d2c4d8..20151b71 100644 --- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -2,8 +2,6 @@ namespace WixToolset.Mba.Core { - using WixToolset.BootstrapperCore; - public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory { public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 52667923..f8ac2a1e 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -5,7 +5,6 @@ namespace WixToolset.Mba.Core using System; using System.Runtime.InteropServices; using System.Threading; - using WixToolset.BootstrapperCore; /// /// The default bootstrapper application. @@ -1574,7 +1573,7 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) { switch (message) { @@ -1583,7 +1582,7 @@ namespace WixToolset.Mba.Core } } - void IBootstrapperApplication.BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) { } diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs index de12ca17..968c6336 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs @@ -6,7 +6,6 @@ namespace WixToolset.Mba.Core using System.Configuration; using System.Reflection; using System.Runtime.InteropServices; - using WixToolset.BootstrapperCore; /// /// Entry point for the MBA host to create and return the IBootstrapperApplication implementation to the engine. diff --git a/src/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/WixToolset.Mba.Core/BootstrapperCommand.cs index 1ca64924..6854e9ae 100644 --- a/src/WixToolset.Mba.Core/BootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -5,7 +5,6 @@ namespace WixToolset.Mba.Core using System; using System.ComponentModel; using System.Runtime.InteropServices; - using WixToolset.BootstrapperCore; public sealed class BootstrapperCommand : IBootstrapperCommand { diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index 2e094bb9..f2cc3947 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -7,7 +7,6 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; using System.Security; using System.Text; - using WixToolset.BootstrapperCore; /// /// Container class for the interface. diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 26a3b573..83c0c96a 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -5,7 +5,6 @@ namespace WixToolset.Mba.Core using System; using System.Collections.Generic; using System.Collections.ObjectModel; - using WixToolset.BootstrapperCore; /// /// Base class for BA classes. diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs new file mode 100644 index 00000000..8e5d2aeb --- /dev/null +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -0,0 +1,834 @@ +// 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 +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.InteropServices; + + /// + /// Allows customization of the bootstrapper application. + /// + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("53C31D56-49C0-426B-AB06-099D717C67FE")] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public interface IBootstrapperApplication + { + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnStartup(); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnSystemShutdown( + [MarshalAs(UnmanagedType.U4)] EndSessionReasons dwEndSession, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectBegin( + [MarshalAs(UnmanagedType.Bool)] bool fInstalled, + [MarshalAs(UnmanagedType.U4)] int cPackages, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectForwardCompatibleBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelationType relationType, + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectUpdateBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fSkip + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectUpdate( + [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, + [MarshalAs(UnmanagedType.U8)] long dw64Size, + [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzTitle, + [MarshalAs(UnmanagedType.LPWStr)] string wzSummary, + [MarshalAs(UnmanagedType.LPWStr)] string wzContentType, + [MarshalAs(UnmanagedType.LPWStr)] string wzContent, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fStopProcessingUpdates + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectUpdateComplete( + int hrStatus, + [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreError + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectRelatedBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelationType relationType, + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectPackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectCompatibleMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + [MarshalAs(UnmanagedType.U8)] long dw64CompatiblePackageVersion, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectRelatedMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzUpgradeCode, + [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectTargetMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, + [MarshalAs(UnmanagedType.U4)] PackageState patchState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectMsiFeature( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzFeatureId, + [MarshalAs(UnmanagedType.U4)] FeatureState state, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectPackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] PackageState state + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanBegin( + [MarshalAs(UnmanagedType.U4)] int cPackages, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanRelatedBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanPackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanCompatibleMsiPackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + [MarshalAs(UnmanagedType.U8)] long dw64CompatiblePackageVersion, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanCompatibleMsiPackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] PackageState state, + [MarshalAs(UnmanagedType.U4)] RequestState requested, + [MarshalAs(UnmanagedType.U4)] ActionState execute, + [MarshalAs(UnmanagedType.U4)] ActionState rollback + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanTargetMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanMsiFeature( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzFeatureId, + [MarshalAs(UnmanagedType.U4)] FeatureState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref FeatureState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanPackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] PackageState state, + [MarshalAs(UnmanagedType.U4)] RequestState requested, + [MarshalAs(UnmanagedType.U4)] ActionState execute, + [MarshalAs(UnmanagedType.U4)] ActionState rollback + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnApplyBegin( + [MarshalAs(UnmanagedType.U4)] int dwPhaseCount, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnElevateBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnElevateComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnProgress( + [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnError( + [MarshalAs(UnmanagedType.U4)] ErrorType errorType, + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int dwCode, + [MarshalAs(UnmanagedType.LPWStr)] string wzError, + [MarshalAs(UnmanagedType.I4)] int dwUIHint, + [MarshalAs(UnmanagedType.U4)] int cData, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzData, + [MarshalAs(UnmanagedType.I4)] Result nRecommendation, + [MarshalAs(UnmanagedType.I4)] ref Result pResult + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRegisterBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRegisterComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int cCachePayloads, + [MarshalAs(UnmanagedType.U8)] long dw64PackageCacheSize, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U4)] CacheOperation operation, + [MarshalAs(UnmanagedType.LPWStr)] string wzSource, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnResolveSource( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, + BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, + ref BOOTSTRAPPER_RESOLVESOURCE_ACTION action, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus, + BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, + ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION pAction + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheVerifyBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheVerifyComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus, + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, + ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, + ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteBegin( + [MarshalAs(UnmanagedType.U4)] int cExecutingPackages, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecutePackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.Bool)] bool fExecute, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecutePatchTarget( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzTargetProductCode, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteMsiMessage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] InstallMessage messageType, + [MarshalAs(UnmanagedType.I4)] int dwUIHint, + [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, + [MarshalAs(UnmanagedType.U4)] int cData, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzData, + [MarshalAs(UnmanagedType.I4)] Result nRecommendation, + [MarshalAs(UnmanagedType.I4)] ref Result pResult + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteFilesInUse( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int cFiles, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzFiles, + [MarshalAs(UnmanagedType.I4)] Result nRecommendation, + [MarshalAs(UnmanagedType.I4)] ref Result pResult + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecutePackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] ApplyRestart restart, + [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, + [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnUnregisterBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnUnregisterComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnApplyComplete( + int hrStatus, + [MarshalAs(UnmanagedType.U4)] ApplyRestart restart, + [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, + [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnLaunchApprovedExeBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnLaunchApprovedExeComplete( + int hrStatus, + int processId + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int BAProc( + int message, + IntPtr pvArgs, + IntPtr pvResults, + IntPtr pvContext + ); + + void BAProcFallback( + int message, + IntPtr pvArgs, + IntPtr pvResults, + ref int phr, + IntPtr pvContext + ); + } + + /// + /// The display level for the BA. + /// + public enum Display + { + Unknown, + Embedded, + None, + Passive, + Full, + } + + /// + /// Messages from Windows Installer. + /// + public enum InstallMessage + { + FatalExit, + Error = 0x01000000, + Warning = 0x02000000, + User = 0x03000000, + Info = 0x04000000, + FilesInUse = 0x05000000, + ResolveSource = 0x06000000, + OutOfDiskSpace = 0x07000000, + ActionStart = 0x08000000, + ActionData = 0x09000000, + Progress = 0x0a000000, + CommonData = 0x0b000000, + Initialize = 0x0c000000, + Terminate = 0x0d000000, + ShowDialog = 0x0e000000, + RMFilesInUse = 0x19000000, + } + + /// + /// The action to perform when a reboot is necessary. + /// + public enum Restart + { + Unknown, + Never, + Prompt, + Automatic, + Always, + } + + /// + /// Result codes. + /// + public enum Result + { + Error = -1, + None, + Ok, + Cancel, + Abort, + Retry, + Ignore, + Yes, + No, + Close, + Help, + TryAgain, + Continue, + } + + /// + /// Describes why a bundle or packaged is being resumed. + /// + public enum ResumeType + { + None, + + /// + /// Resume information exists but is invalid. + /// + Invalid, + + /// + /// The bundle was re-launched after an unexpected interruption. + /// + Interrupted, + + /// + /// A reboot is pending. + /// + RebootPending, + + /// + /// The bundle was re-launched after a reboot. + /// + Reboot, + + /// + /// The bundle was re-launched after being suspended. + /// + Suspend, + + /// + /// The bundle was launched from Add/Remove Programs. + /// + Arp, + } + + /// + /// Indicates what caused the error. + /// + public enum ErrorType + { + /// + /// The error occurred trying to elevate. + /// + Elevate, + + /// + /// The error came from the Windows Installer. + /// + WindowsInstaller, + + /// + /// The error came from an EXE Package. + /// + ExePackage, + + /// + /// The error came while trying to authenticate with an HTTP server. + /// + HttpServerAuthentication, + + /// + /// The error came while trying to authenticate with an HTTP proxy. + /// + HttpProxyAuthentication, + + /// + /// The error occurred during apply. + /// + Apply, + }; + + public enum RelatedOperation + { + None, + + /// + /// The related bundle or package will be downgraded. + /// + Downgrade, + + /// + /// The related package will be upgraded as a minor revision. + /// + MinorUpdate, + + /// + /// The related bundle or package will be upgraded as a major revision. + /// + MajorUpgrade, + + /// + /// The related bundle will be removed. + /// + Remove, + + /// + /// The related bundle will be installed. + /// + Install, + + /// + /// The related bundle will be repaired. + /// + Repair, + }; + + /// + /// The cache operation used to acquire a container or payload. + /// + public enum CacheOperation + { + /// + /// Container or payload is being copied. + /// + Copy, + + /// + /// Container or payload is being downloaded. + /// + Download, + + /// + /// Container or payload is being extracted. + /// + Extract + } + + /// + /// The restart state after a package or all packages were applied. + /// + public enum ApplyRestart + { + /// + /// Package or chain does not require a restart. + /// + None, + + /// + /// Package or chain requires a restart but it has not been initiated yet. + /// + RestartRequired, + + /// + /// Package or chain has already initiated the restart. + /// + RestartInitiated + } + + /// + /// The relation type for related bundles. + /// + public enum RelationType + { + None, + Detect, + Upgrade, + Addon, + Patch, + Dependent, + Update, + } + + /// + /// One or more reasons why the application is requested to be closed or is being closed. + /// + [Flags] + public enum EndSessionReasons + { + /// + /// The system is shutting down or restarting (it is not possible to determine which event is occurring). + /// + Unknown, + + /// + /// The application is using a file that must be replaced, the system is being serviced, or system resources are exhausted. + /// + CloseApplication, + + /// + /// The application is forced to shut down. + /// + Critical = 0x40000000, + + /// + /// The user is logging off. + /// + Logoff = unchecked((int)0x80000000) + } + + /// + /// The available actions for OnApplyComplete. + /// + public enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION + { + None, + Restart, + } + + /// + /// The available actions for OnCacheAcquireComplete. + /// + public enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION + { + None, + Retry, + } + + /// + /// The available actions for OnCachePackageComplete. + /// + public enum BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION + { + None, + Ignore, + Retry, + } + + /// + /// The available actions for OnCacheVerifyComplete. + /// + public enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION + { + None, + RetryVerification, + RetryAcquisition, + } + + /// + /// The available actions for OnExecutePackageComplete. + /// + public enum BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION + { + None, + Ignore, + Retry, + Restart, + Suspend, + } + + /// + /// The available actions for OnResolveSource. + /// + public enum BOOTSTRAPPER_RESOLVESOURCE_ACTION + { + None, + Retry, + Download, + } + + /// + /// The available actions for OnShutdown. + /// + public enum BOOTSTRAPPER_SHUTDOWN_ACTION + { + None, + Restart, + ReloadBootstrapper, + } +} diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index 6dd4af72..f5d4c705 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -5,7 +5,6 @@ namespace WixToolset.Mba.Core using System; using System.CodeDom.Compiler; using System.Runtime.InteropServices; - using WixToolset.BootstrapperCore; [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] diff --git a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs index fc7d1fc2..675abdf9 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs @@ -3,7 +3,6 @@ namespace WixToolset.Mba.Core { using System; - using WixToolset.BootstrapperCore; /// /// Command information passed from the engine for the BA to perform. diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs new file mode 100644 index 00000000..d070998e --- /dev/null +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -0,0 +1,279 @@ +// 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 +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.InteropServices; + using System.Text; + + /// + /// Allows calls into the bootstrapper engine. + /// + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("6480D616-27A0-44D7-905B-81512C29C2FB")] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public interface IBootstrapperEngine + { + void GetPackageCount( + [MarshalAs(UnmanagedType.U4)] out int pcPackages + ); + + [PreserveSig] + int GetVariableNumeric( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + out long pllValue + ); + + [PreserveSig] + int GetVariableString( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + IntPtr wzValue, + [MarshalAs(UnmanagedType.U4)] ref int pcchValue + ); + + [PreserveSig] + int GetVariableVersion( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + [MarshalAs(UnmanagedType.U8)] out long pqwValue + ); + + [PreserveSig] + int FormatString( + [MarshalAs(UnmanagedType.LPWStr)] string wzIn, + [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, + [MarshalAs(UnmanagedType.U4)] ref int pcchOut + ); + + [PreserveSig] + int EscapeString( + [MarshalAs(UnmanagedType.LPWStr)] string wzIn, + [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, + [MarshalAs(UnmanagedType.U4)] ref int pcchOut + ); + + void EvaluateCondition( + [MarshalAs(UnmanagedType.LPWStr)] string wzCondition, + [MarshalAs(UnmanagedType.Bool)] out bool pf + ); + + void Log( + [MarshalAs(UnmanagedType.U4)] LogLevel level, + [MarshalAs(UnmanagedType.LPWStr)] string wzMessage + ); + + void SendEmbeddedError( + [MarshalAs(UnmanagedType.U4)] int dwErrorCode, + [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, + [MarshalAs(UnmanagedType.U4)] int dwUIHint, + [MarshalAs(UnmanagedType.I4)] out int pnResult + ); + + void SendEmbeddedProgress( + [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, + [MarshalAs(UnmanagedType.U4)] int dwOverallProgressPercentage, + [MarshalAs(UnmanagedType.I4)] out int pnResult + ); + + void SetUpdate( + [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, + [MarshalAs(UnmanagedType.U8)] long qwValue, + [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=4)] byte[] rgbHash, + [MarshalAs(UnmanagedType.U4)] int cbHash + ); + + void SetLocalSource( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPath + ); + + void SetDownloadSource( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPWStr)] string wzUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzUser, + [MarshalAs(UnmanagedType.LPWStr)] string wzPassword + ); + + void SetVariableNumeric( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + long llValue + ); + + void SetVariableString( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + IntPtr wzValue + ); + + void SetVariableVersion( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + [MarshalAs(UnmanagedType.U8)] long qwValue + ); + + void CloseSplashScreen(); + + void Detect( + IntPtr hwndParent + ); + + void Plan( + [MarshalAs(UnmanagedType.U4)] LaunchAction action + ); + + [PreserveSig] + int Elevate( + IntPtr hwndParent + ); + + void Apply( + IntPtr hwndParent + ); + + void Quit( + [MarshalAs(UnmanagedType.U4)] int dwExitCode + ); + + void LaunchApprovedExe( + IntPtr hwndParent, + [MarshalAs(UnmanagedType.LPWStr)] string wzApprovedExeForElevationId, + [MarshalAs(UnmanagedType.LPWStr)] string wzArguments, + [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout + ); + } + + /// + /// The installation action for the bundle or current package. + /// + public enum ActionState + { + None, + Uninstall, + Install, + AdminInstall, + Modify, + Repair, + MinorUpgrade, + MajorUpgrade, + Patch, + } + + /// + /// The action for the BA to perform. + /// + public enum LaunchAction + { + Unknown, + Help, + Layout, + Uninstall, + Cache, + Install, + Modify, + Repair, + UpdateReplace, + UpdateReplaceEmbedded, + } + + /// + /// The message log level. + /// + public enum LogLevel + { + /// + /// No logging level (generic). + /// + None, + + /// + /// User messages. + /// + Standard, + + /// + /// Verbose messages. + /// + Verbose, + + /// + /// Messages for debugging. + /// + Debug, + + /// + /// Error messages. + /// + Error, + } + + /// + /// Type of hash used for update bundle. + /// + public enum UpdateHashType + { + /// + /// No hash provided. + /// + None, + + /// + /// SHA-1 based hash provided. + /// + Sha1, + } + + /// + /// Describes the state of an installation package. + /// + public enum PackageState + { + Unknown, + Obsolete, + Absent, + Cached, + Present, + Superseded, + } + + /// + /// Indicates the state desired for an installation package. + /// + public enum RequestState + { + None, + ForceAbsent, + Absent, + Cache, + Present, + Repair, + } + + /// + /// Indicates the state of a feature. + /// + public enum FeatureState + { + Unknown, + Absent, + Advertised, + Local, + Source, + } + + /// + /// Indicates the action for a feature. + /// + public enum FeatureAction + { + None, + AddLocal, + AddSource, + AddDefault, + Reinstall, + Advertise, + Remove, + } +} diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index ee290865..9bea6418 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -3,7 +3,6 @@ namespace WixToolset.Mba.Core { using System; - using WixToolset.BootstrapperCore; public interface IDefaultBootstrapperApplication : IBootstrapperApplication { diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 6aef50b3..5ddc4176 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -5,7 +5,6 @@ namespace WixToolset.Mba.Core using System; using System.ComponentModel; using System.Security; - using WixToolset.BootstrapperCore; public interface IEngine { diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index 9bc21923..46894d2e 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -6,7 +6,6 @@ namespace WixToolset.Mba.Core using System.Collections.Generic; using System.Xml; using System.Xml.XPath; - using WixToolset.BootstrapperCore; public enum CacheType { diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 16d278b0..05d042c3 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -35,9 +35,11 @@ + + @@ -62,9 +64,6 @@ - - ..\..\packages\WixToolset.BootstrapperCore.4.0.8\lib\net20\WixToolset.BootstrapperCore.dll - diff --git a/src/WixToolset.Mba.Core/packages.config b/src/WixToolset.Mba.Core/packages.config index 3702a604..03e866cf 100644 --- a/src/WixToolset.Mba.Core/packages.config +++ b/src/WixToolset.Mba.Core/packages.config @@ -1,5 +1,4 @@  - \ No newline at end of file diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h new file mode 100644 index 00000000..6ab7ed20 --- /dev/null +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -0,0 +1,525 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-AB06-099D717C67FE") +{ + // OnStartup - called when the engine is ready for the bootstrapper application to start. + // + STDMETHOD(OnStartup)() = 0; + + // OnShutdown - called after the bootstrapper application quits the engine. + STDMETHOD(OnShutdown)( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction + ) = 0; + + // OnSystemShutdown - called when the operating system is instructed to shutdown the machine. + STDMETHOD(OnSystemShutdown)( + __in DWORD dwEndSession, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectBegin - called when the engine begins detection. + STDMETHOD(OnDetectBegin)( + __in BOOL fInstalled, + __in DWORD cPackages, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectForwardCompatibleBundle - called when the engine detects a forward compatible bundle. + STDMETHOD(OnDetectForwardCompatibleBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in_z LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in DWORD64 dw64Version, + __inout BOOL* pfCancel, + __inout BOOL* pfIgnoreBundle + ) = 0; + + // OnDetectUpdateBegin - called when the engine begins detection for bundle update. + STDMETHOD(OnDetectUpdateBegin)( + __in_z LPCWSTR wzUpdateLocation, + __inout BOOL* pfCancel, + __inout BOOL* pfSkip + ) = 0; + + // OnDetectUpdate - called when the engine has an update candidate for bundle update. + STDMETHOD(OnDetectUpdate)( + __in_z_opt LPCWSTR wzUpdateLocation, + __in DWORD64 dw64Size, + __in DWORD64 dw64Version, + __in_z_opt LPCWSTR wzTitle, + __in_z_opt LPCWSTR wzSummary, + __in_z_opt LPCWSTR wzContentType, + __in_z_opt LPCWSTR wzContent, + __inout BOOL* pfCancel, + __inout BOOL* pfStopProcessingUpdates + ) = 0; + + // OnDetectUpdateComplete - called when the engine completes detection for bundle update. + STDMETHOD(OnDetectUpdateComplete)( + __in HRESULT hrStatus, + __inout BOOL* pfIgnoreError + ) = 0; + + // OnDetectRelatedBundle - called when the engine detects a related bundle. + STDMETHOD(OnDetectRelatedBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in_z LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in DWORD64 dw64Version, + __in BOOTSTRAPPER_RELATED_OPERATION operation, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectPackageBegin - called when the engine begins detecting a package. + STDMETHOD(OnDetectPackageBegin)( + __in_z LPCWSTR wzPackageId, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectCompatibleMsiPackage - called when the engine detects that a package is not installed but a newer package using the same provider key is. + STDMETHOD(OnDetectCompatibleMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzCompatiblePackageId, + __in DWORD64 dw64CompatiblePackageVersion, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectRelatedMsiPackage - called when the engine begins detects a related package. + STDMETHOD(OnDetectRelatedMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzUpgradeCode, + __in_z LPCWSTR wzProductCode, + __in BOOL fPerMachine, + __in DWORD64 dw64Version, + __in BOOTSTRAPPER_RELATED_OPERATION operation, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectTargetMsiPackage - called when the engine detects a target MSI package for + // an MSP package. + STDMETHOD(OnDetectTargetMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzProductCode, + __in BOOTSTRAPPER_PACKAGE_STATE patchState, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectMsiFeature - called when the engine detects a feature in an MSI package. + STDMETHOD(OnDetectMsiFeature)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzFeatureId, + __in BOOTSTRAPPER_FEATURE_STATE state, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectPackageComplete - called after the engine detects a package. + // + STDMETHOD(OnDetectPackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_PACKAGE_STATE state + ) = 0; + + // OnDetectPackageComplete - called after the engine completes detection. + // + STDMETHOD(OnDetectComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnPlanBegin - called when the engine begins planning. + STDMETHOD(OnPlanBegin)( + __in DWORD cPackages, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanRelatedBundle - called when the engine begins planning a related bundle. + STDMETHOD(OnPlanRelatedBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanPackageBegin - called when the engine begins planning a package. + STDMETHOD(OnPlanPackageBegin)( + __in_z LPCWSTR wzPackageId, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanCompatibleMsiPackageBegin - called when the engine plans a newer, compatible package using the same provider key. + STDMETHOD(OnPlanCompatibleMsiPackageBegin)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzCompatiblePackageId, + __in DWORD64 dw64CompatiblePackageVersion, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanCompatibleMsiPackageComplete - called after the engine plans the package. + // + STDMETHOD(OnPlanCompatibleMsiPackageComplete)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzCompatiblePackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_PACKAGE_STATE state, + __in BOOTSTRAPPER_REQUEST_STATE requested, + __in BOOTSTRAPPER_ACTION_STATE execute, + __in BOOTSTRAPPER_ACTION_STATE rollback + ) = 0; + + // OnPlanTargetMsiPackage - called when the engine plans an MSP package + // to apply to an MSI package. + STDMETHOD(OnPlanTargetMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzProductCode, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanMsiFeature - called when the engine plans a feature in an + // MSI package. + STDMETHOD(OnPlanMsiFeature)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzFeatureId, + __in BOOTSTRAPPER_FEATURE_STATE recommendedState, + __inout BOOTSTRAPPER_FEATURE_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanPackageComplete - called after the engine plans a package. + // + STDMETHOD(OnPlanPackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_PACKAGE_STATE state, + __in BOOTSTRAPPER_REQUEST_STATE requested, + __in BOOTSTRAPPER_ACTION_STATE execute, + __in BOOTSTRAPPER_ACTION_STATE rollback + ) = 0; + + // OnPlanComplete - called when the engine completes planning. + // + STDMETHOD(OnPlanComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnApplyBegin - called when the engine begins applying the plan. + // + STDMETHOD(OnApplyBegin)( + __in DWORD dwPhaseCount, + __inout BOOL* pfCancel + ) = 0; + + // OnElevateBegin - called before the engine displays an elevation prompt. + // Will only happen once per execution of the engine, + // assuming the elevation was successful. + STDMETHOD(OnElevateBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnElevateComplete - called after the engine attempted to elevate. + // + STDMETHOD(OnElevateComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnProgress - called when the engine makes progress. + // + STDMETHOD(OnProgress)( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + // OnError - called when the engine encounters an error. + // + // nResult: + // uiFlags is a combination of valid ID* return values appropriate for + // the error. + // + // IDNOACTION instructs the engine to pass the error through to default + // handling which usually results in the apply failing. + STDMETHOD(OnError)( + __in BOOTSTRAPPER_ERROR_TYPE errorType, + __in_z_opt LPCWSTR wzPackageId, + __in DWORD dwCode, + __in_z_opt LPCWSTR wzError, + __in DWORD dwUIHint, + __in DWORD cData, + __in_ecount_z_opt(cData) LPCWSTR* rgwzData, + __in int nRecommendation, + __inout int* pResult + ) = 0; + + // OnRegisterBegin - called when the engine registers the bundle. + // + STDMETHOD(OnRegisterBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnRegisterComplete - called when the engine registration is + // complete. + // + STDMETHOD(OnRegisterComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnCacheBegin - called when the engine begins caching. + // + STDMETHOD(OnCacheBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnCachePackageBegin - called when the engine begins caching + // a package. + // + STDMETHOD(OnCachePackageBegin)( + __in_z LPCWSTR wzPackageId, + __in DWORD cCachePayloads, + __in DWORD64 dw64PackageCacheSize, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireBegin - called when the engine begins copying or + // downloading a payload to the working folder. + // + STDMETHOD(OnCacheAcquireBegin)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in BOOTSTRAPPER_CACHE_OPERATION operation, + __in_z LPCWSTR wzSource, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireProgress - called when the engine makes progresss copying + // or downloading a payload to the working folder. + // + STDMETHOD(OnCacheAcquireProgress)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + // OnResolveSource - called when a payload or container cannot be found locally. + // + // Parameters: + // wzPayloadId will be NULL when resolving a container. + // wzDownloadSource will be NULL if the container or payload does not provide a DownloadURL. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning BOOTSTRAPPER_RESOLVESOURCE_ACTION_RETRY or BOOTSTRAPPER_RESOLVESOURCE_ACTION_DOWNLOAD. + STDMETHOD(OnResolveSource)( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzLocalSource, + __in_z_opt LPCWSTR wzDownloadSource, + __in BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, + __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* pAction, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireComplete - called after the engine copied or downloaded + // a payload to the working folder. + // + STDMETHOD(OnCacheAcquireComplete)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction + ) = 0; + + // OnCacheVerifyBegin - called when the engine begins to verify then copy + // a payload or container to the package cache folder. + // + STDMETHOD(OnCacheVerifyBegin)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheVerifyComplete - called after the engine verifies and copies + // a payload or container to the package cache folder. + // + STDMETHOD(OnCacheVerifyComplete)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction + ) = 0; + + // OnCachePackageComplete - called after the engine attempts to copy or download all + // payloads of a package into the package cache folder. + // + STDMETHOD(OnCachePackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction + ) = 0; + + // OnCacheComplete - called when the engine caching is complete. + // + STDMETHOD(OnCacheComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnExecuteBegin - called when the engine begins executing the plan. + // + STDMETHOD(OnExecuteBegin)( + __in DWORD cExecutingPackages, + __inout BOOL* pfCancel + ) = 0; + + // OnExecuteBegin - called when the engine begins executing a package. + // + STDMETHOD(OnExecutePackageBegin)( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, + __inout BOOL* pfCancel + ) = 0; + + // OnExecutePatchTarget - called for each patch in an MspPackage targeting the product + // when the engine begins executing the MspPackage. + // + STDMETHOD(OnExecutePatchTarget)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzTargetProductCode, + __inout BOOL* pfCancel + ) = 0; + + // OnExecuteProgress - called when the engine makes progress executing a package. + // + STDMETHOD(OnExecuteProgress)( + __in_z LPCWSTR wzPackageId, + __in DWORD dwProgressPercentage, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + // OnExecuteMsiMessage - called when the engine receives an MSI package message. + // + // Return: + // uiFlags is a combination of valid ID* return values appropriate for + // the message. + // + // IDNOACTION instructs the engine to pass the message through to default + // handling which usually results in the execution continuing. + STDMETHOD(OnExecuteMsiMessage)( + __in_z LPCWSTR wzPackageId, + __in INSTALLMESSAGE messageType, + __in DWORD dwUIHint, + __in_z LPCWSTR wzMessage, + __in DWORD cData, + __in_ecount_z_opt(cData) LPCWSTR* rgwzData, + __in int nRecommendation, + __inout int* pResult + ) = 0; + + // OnExecuteFilesInUse - called when the engine encounters files in use while + // executing a package. + // + // Return: + // IDOK instructs the engine to let the Restart Manager attempt to close the + // applications to avoid a restart. + // + // IDCANCEL instructs the engine to abort the execution and start rollback. + // + // IDIGNORE instructs the engine to ignore the running applications. A restart will be + // required. + // + // IDRETRY instructs the engine to check if the applications are still running again. + // + // IDNOACTION is equivalent to ignoring the running applications. A restart will be + // required. + STDMETHOD(OnExecuteFilesInUse)( + __in_z LPCWSTR wzPackageId, + __in DWORD cFiles, + __in_ecount_z(cFiles) LPCWSTR* rgwzFiles, + __in int nRecommendation, + __inout int* pResult + ) = 0; + + // OnExecutePackageComplete - called when a package execution is complete. + // + STDMETHOD(OnExecutePackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_APPLY_RESTART restart, + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction + ) = 0; + + // OnExecuteComplete - called when the engine execution is complete. + // + STDMETHOD(OnExecuteComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnUnregisterBegin - called when the engine unregisters the bundle. + // + STDMETHOD(OnUnregisterBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnUnregisterComplete - called when the engine unregistration is complete. + // + STDMETHOD(OnUnregisterComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnApplyComplete - called after the plan has been applied. + // + STDMETHOD(OnApplyComplete)( + __in HRESULT hrStatus, + __in BOOTSTRAPPER_APPLY_RESTART restart, + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction + ) = 0; + + // OnLaunchApprovedExeBegin - called before trying to launch the preapproved executable. + // + STDMETHOD(OnLaunchApprovedExeBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnLaunchApprovedExeComplete - called after trying to launch the preapproved executable. + // + STDMETHOD(OnLaunchApprovedExeComplete)( + __in HRESULT hrStatus, + __in DWORD dwProcessId + ) = 0; + + // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. + // This might be used to help the BA support more than one version of the engine. + STDMETHOD(BAProc)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; + + // BAProcFallback - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method + // to give the BA the ability to use default behavior + // and then forward the message to extensions. + STDMETHOD_(void, BAProcFallback)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __inout HRESULT* phr, + __in_opt LPVOID pvContext + ) = 0; +}; diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h new file mode 100644 index 00000000..3fe3d401 --- /dev/null +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -0,0 +1,128 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-81512C29C2FB") +{ + STDMETHOD(GetPackageCount)( + __out DWORD* pcPackages + ) = 0; + + STDMETHOD(GetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) = 0; + + STDMETHOD(GetVariableString)( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue + ) = 0; + + STDMETHOD(GetVariableVersion)( + __in_z LPCWSTR wzVariable, + __out DWORD64* pqwValue + ) = 0; + + STDMETHOD(FormatString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD* pcchOut + ) = 0; + + STDMETHOD(EscapeString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD* pcchOut + ) = 0; + + STDMETHOD(EvaluateCondition)( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) = 0; + + STDMETHOD(Log)( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) = 0; + + STDMETHOD(SendEmbeddedError)( + __in DWORD dwErrorCode, + __in_z_opt LPCWSTR wzMessage, + __in DWORD dwUIHint, + __out int* pnResult + ) = 0; + + STDMETHOD(SendEmbeddedProgress)( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __out int* pnResult + ) = 0; + + STDMETHOD(SetUpdate)( + __in_z_opt LPCWSTR wzLocalSource, + __in_z_opt LPCWSTR wzDownloadSource, + __in DWORD64 qwSize, + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, + __in_bcount_opt(cbHash) BYTE* rgbHash, + __in DWORD cbHash + ) = 0; + + STDMETHOD(SetLocalSource)( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzPath + ) = 0; + + STDMETHOD(SetDownloadSource)( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzUrl, + __in_z_opt LPCWSTR wzUser, + __in_z_opt LPCWSTR wzPassword + ) = 0; + + STDMETHOD(SetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) = 0; + + STDMETHOD(SetVariableString)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) = 0; + + STDMETHOD(SetVariableVersion)( + __in_z LPCWSTR wzVariable, + __in DWORD64 qwValue + ) = 0; + + STDMETHOD(CloseSplashScreen)() = 0; + + STDMETHOD(Detect)( + __in_opt HWND hwndParent = NULL + ) = 0; + + STDMETHOD(Plan)( + __in BOOTSTRAPPER_ACTION action + ) = 0; + + STDMETHOD(Elevate)( + __in_opt HWND hwndParent + ) = 0; + + STDMETHOD(Apply)( + __in_opt HWND hwndParent + ) = 0; + + STDMETHOD(Quit)( + __in DWORD dwExitCode + ) = 0; + + STDMETHOD(LaunchApprovedExe)( + __in_opt HWND hwndParent, + __in_z LPCWSTR wzApprovedExeForElevationId, + __in_z_opt LPCWSTR wzArguments, + __in DWORD dwWaitForInputIdleTimeout + ) = 0; +}; -- cgit v1.2.3-55-g6feb From 24379873f589cff33965f1104041f61c0c4503e0 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 22 Dec 2019 10:31:33 +1100 Subject: Move the responsibility of wrapping the binary interfaces from mbahost to the new mbanative dll of WixToolset.Mba.Core. --- balutil.sln | 23 ++++- src/WixToolset.Mba.Core/BalUtil.cs | 22 ++++ .../BaseBootstrapperApplicationFactory.cs | 28 ++++- .../BootstrapperApplicationFactory.cs | 14 ++- .../IBootstrapperApplicationFactory.cs | 28 ++++- src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 1 + src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 4 +- .../build/net20/WixToolset.Mba.Core.props | 11 ++ src/balutil/balutil.vcxproj | 6 +- src/balutil/inc/IBootstrapperApplicationFactory.h | 5 +- src/balutil/packages.config | 2 +- src/mbanative/mbanative.cpp | 29 ++++++ src/mbanative/mbanative.def | 6 ++ src/mbanative/mbanative.vcxproj | 76 ++++++++++++++ src/mbanative/packages.config | 6 ++ src/mbanative/precomp.cpp | 3 + src/mbanative/precomp.h | 15 +++ .../BaseBootstrapperApplicationFactoryFixture.cs | 113 +++++++++++++++++++++ .../WixToolsetTest.Mba.Core.csproj | 29 ++++++ .../WixToolsetTest.Mba.Core.v3.ncrunchproject | 5 + 20 files changed, 402 insertions(+), 24 deletions(-) create mode 100644 src/WixToolset.Mba.Core/BalUtil.cs create mode 100644 src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props create mode 100644 src/mbanative/mbanative.cpp create mode 100644 src/mbanative/mbanative.def create mode 100644 src/mbanative/mbanative.vcxproj create mode 100644 src/mbanative/packages.config create mode 100644 src/mbanative/precomp.cpp create mode 100644 src/mbanative/precomp.h create mode 100644 src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs create mode 100644 src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj create mode 100644 src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject (limited to 'src') diff --git a/balutil.sln b/balutil.sln index 7c170206..37d391fc 100644 --- a/balutil.sln +++ b/balutil.sln @@ -1,12 +1,16 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.12 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29503.13 MinimumVisualStudioVersion = 15.0.26124.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balutil.vcxproj", "{EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbanative", "src\mbanative\mbanative.vcxproj", "{665E0441-17F9-4105-B202-EDF274657F6E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Mba.Core", "src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj", "{F54997F7-10D7-409B-B9F2-DB546490EDC0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -31,6 +35,21 @@ Global {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.ActiveCfg = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.Build.0 = Release|Any CPU + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.ActiveCfg = Debug|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.Build.0 = Debug|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.ActiveCfg = Debug|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.Build.0 = Debug|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.ActiveCfg = Release|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.ActiveCfg = Release|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.Build.0 = Release|Win32 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.ActiveCfg = Debug|x64 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.Build.0 = Debug|x64 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.ActiveCfg = Debug|x86 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.Build.0 = Debug|x86 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.Build.0 = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/WixToolset.Mba.Core/BalUtil.cs b/src/WixToolset.Mba.Core/BalUtil.cs new file mode 100644 index 00000000..f478eca4 --- /dev/null +++ b/src/WixToolset.Mba.Core/BalUtil.cs @@ -0,0 +1,22 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + internal static class BalUtil + { + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern IBootstrapperEngine InitializeFromCreateArgs( + IntPtr pArgs, + ref Command pCommand + ); + + [DllImport("mbanative.dll", ExactSpelling = true)] + internal static extern void StoreBAInCreateResults( + IntPtr pResults, + [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA + ); + } +} diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index 20151b71..264733ac 100644 --- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -2,15 +2,35 @@ namespace WixToolset.Mba.Core { + using System; + using System.Runtime.InteropServices; + public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory { - public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) + public void Create(IntPtr pArgs, IntPtr pResults) { - IEngine engine = new Engine(pEngine); - IBootstrapperCommand bootstrapperCommand = command.GetBootstrapperCommand(); - return this.Create(engine, bootstrapperCommand); + InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); + + var ba = this.Create(engine, bootstrapperCommand); + StoreBAInCreateResults(pResults, ba); } protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); + + public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) + { + Command pCommand = new Command + { + cbSize = Marshal.SizeOf(typeof(Command)) + }; + var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand); + engine = new Engine(pEngine); + bootstrapperCommand = pCommand.GetBootstrapperCommand(); + } + + public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) + { + BalUtil.StoreBAInCreateResults(pResults, ba); + } } } diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs index 968c6336..55f0e83b 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs @@ -8,7 +8,7 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; /// - /// Entry point for the MBA host to create and return the IBootstrapperApplication implementation to the engine. + /// Entry point for the MBA host to create and return the BA to the engine. /// [ClassInterface(ClassInterfaceType.None)] public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory @@ -21,14 +21,13 @@ namespace WixToolset.Mba.Core } /// - /// Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication. + /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method. /// - /// IBootstrapperEngine provided for the bootstrapper application. - /// Command line for the bootstrapper application. - /// Bootstrapper application via interface. + /// Pointer to BOOTSTRAPPER_CREATE_ARGS struct. + /// Pointer to BOOTSTRAPPER_CREATE_RESULTS struct. /// The bootstrapper application assembly /// does not define the . - public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) + public void Create(IntPtr pArgs, IntPtr pResults) { // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host. var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection; @@ -45,8 +44,7 @@ namespace WixToolset.Mba.Core throw new InvalidBootstrapperApplicationFactoryException(); } - var ba = baFactory.Create(pEngine, ref command); - return ba; + baFactory.Create(pArgs, pResults); } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index f5d4c705..700f0888 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -12,9 +12,9 @@ namespace WixToolset.Mba.Core [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] public interface IBootstrapperApplicationFactory { - IBootstrapperApplication Create( - [MarshalAs(UnmanagedType.Interface)] IBootstrapperEngine pEngine, - ref Command command + void Create( + IntPtr pArgs, + IntPtr pResults ); } @@ -23,6 +23,7 @@ namespace WixToolset.Mba.Core [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] public struct Command { + [MarshalAs(UnmanagedType.I4)] internal int cbSize; [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; [MarshalAs(UnmanagedType.U4)] private readonly Display display; [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; @@ -49,4 +50,25 @@ namespace WixToolset.Mba.Core this.wzLayoutDirectory); } } + + [Serializable] + [StructLayout(LayoutKind.Sequential)] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + 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; + } + } } diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 05d042c3..4b14a545 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -23,6 +23,7 @@ $(DefineConstants);TRACE + diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index 04eee9ec..bbac204f 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -7,7 +7,7 @@ WiX Toolset Team https://licenses.nuget.org/MS-RL - https://github.com/wixtoolset/BootstrapperCore + https://github.com/wixtoolset/balutil false $description$ $copyright$ @@ -15,6 +15,8 @@ + + diff --git a/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props new file mode 100644 index 00000000..c0018e0d --- /dev/null +++ b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)x86\mbanative.dll + + + + + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 42aa909e..9d7dc0a5 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -70,7 +70,9 @@ + + @@ -88,7 +90,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/IBootstrapperApplicationFactory.h b/src/balutil/inc/IBootstrapperApplicationFactory.h index e29c23bc..fd603e50 100644 --- a/src/balutil/inc/IBootstrapperApplicationFactory.h +++ b/src/balutil/inc/IBootstrapperApplicationFactory.h @@ -7,8 +7,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplicationFactory, IUnknown, "2965A12F-AC7B-43A0-85DF-E4B2168478A4") { STDMETHOD(Create)( - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_COMMAND *pCommand, - __out IBootstrapperApplication **ppApplication + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS *pResults ); }; diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 769c5a6e..d747d6a9 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.cpp b/src/mbanative/mbanative.cpp new file mode 100644 index 00000000..745b50e7 --- /dev/null +++ b/src/mbanative/mbanative.cpp @@ -0,0 +1,29 @@ +// 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, pArgs->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/mbanative/mbanative.def b/src/mbanative/mbanative.def new file mode 100644 index 00000000..bd366ac7 --- /dev/null +++ b/src/mbanative/mbanative.def @@ -0,0 +1,6 @@ +; 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. + + +EXPORTS + InitializeFromCreateArgs + StoreBAInCreateResults diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj new file mode 100644 index 00000000..5ec21f74 --- /dev/null +++ b/src/mbanative/mbanative.vcxproj @@ -0,0 +1,76 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {665E0441-17F9-4105-B202-EDF274657F6E} + DynamicLibrary + v141 + Unicode + mbanative + mbanative.def + + + + + + + + ..\balutil\inc + balutil.lib + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config new file mode 100644 index 00000000..d37b6def --- /dev/null +++ b/src/mbanative/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/mbanative/precomp.cpp b/src/mbanative/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/mbanative/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/mbanative/precomp.h b/src/mbanative/precomp.h new file mode 100644 index 00000000..54d8cb08 --- /dev/null +++ b/src/mbanative/precomp.h @@ -0,0 +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 +#include + +#include + +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +#include "balutil.h" diff --git a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs new file mode 100644 index 00000000..12483ddf --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs @@ -0,0 +1,113 @@ +// 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.Util +{ + using System; + using System.Runtime.InteropServices; + 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", + }; + 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); + Assert.Equal(baFactory.BA.Command.CommandLineArgs, new string[] { "this", "is a", "test" }); + } + 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; + public Restart restart; + [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 TestCreateResults + { + public int cbSize; + public IntPtr pBAProc; + [MarshalAs(UnmanagedType.Interface)] public IBootstrapperApplication pBA; + } + } +} diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj new file mode 100644 index 00000000..d401d877 --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -0,0 +1,29 @@ + + + + + + netcoreapp2.1 + false + AnyCPU;x86;x64 + + + + NU1701 + + + + + {665E0441-17F9-4105-B202-EDF274657F6E} + Content + Always + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 0c3a3b3a7d724a8eb0cb62de05354040d7d1a9f4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 22 Dec 2019 10:33:15 +1100 Subject: Move the entry point from Mba.Core to Mba.Host. --- .../BootstrapperApplicationFactory.cs | 84 ------------ .../BootstrapperSectionGroup.cs | 29 ----- src/WixToolset.Mba.Core/Exceptions.cs | 145 --------------------- src/WixToolset.Mba.Core/HostSection.cs | 47 ------- .../SupportedFrameworkElement.cs | 47 ------- .../SupportedFrameworkElementCollection.cs | 36 ----- src/WixToolset.Mba.Core/WixToolset.Mba.Core.config | 26 ---- src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 37 +----- src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 2 - 9 files changed, 1 insertion(+), 452 deletions(-) delete mode 100644 src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs delete mode 100644 src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs delete mode 100644 src/WixToolset.Mba.Core/Exceptions.cs delete mode 100644 src/WixToolset.Mba.Core/HostSection.cs delete mode 100644 src/WixToolset.Mba.Core/SupportedFrameworkElement.cs delete mode 100644 src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs delete mode 100644 src/WixToolset.Mba.Core/WixToolset.Mba.Core.config (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs deleted file mode 100644 index 55f0e83b..00000000 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs +++ /dev/null @@ -1,84 +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 WixToolset.Mba.Core -{ - using System; - using System.Configuration; - using System.Reflection; - using System.Runtime.InteropServices; - - /// - /// Entry point for the MBA host to create and return the BA to the engine. - /// - [ClassInterface(ClassInterfaceType.None)] - public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory - { - /// - /// Creates a new instance of the class. - /// - public BootstrapperApplicationFactory() - { - } - - /// - /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method. - /// - /// Pointer to BOOTSTRAPPER_CREATE_ARGS struct. - /// Pointer to BOOTSTRAPPER_CREATE_RESULTS struct. - /// The bootstrapper application assembly - /// does not define the . - public void Create(IntPtr pArgs, IntPtr pResults) - { - // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host. - var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection; - if (null == section) - { - throw new MissingAttributeException(); // TODO: throw a more specific exception than this. - } - - // Load the BA's IBootstrapperApplicationFactory. - var baFactoryType = BootstrapperApplicationFactory.GetBAFactoryTypeFromAssembly(section.AssemblyName); - var baFactory = (IBootstrapperApplicationFactory)Activator.CreateInstance(baFactoryType); - if (null == baFactory) - { - throw new InvalidBootstrapperApplicationFactoryException(); - } - - baFactory.Create(pArgs, pResults); - } - - /// - /// Locates the and returns the specified type. - /// - /// The assembly that defines the IBootstrapperApplicationFactory implementation. - /// The bootstrapper application factory . - private static Type GetBAFactoryTypeFromAssembly(string assemblyName) - { - Type baFactoryType = null; - - // Load the requested assembly. - Assembly asm = AppDomain.CurrentDomain.Load(assemblyName); - - // If an assembly was loaded and is not the current assembly, check for the required attribute. - // This is done to avoid using the BootstrapperApplicationFactoryAttribute which we use at build time - // to specify the BootstrapperApplicationFactory assembly in the manifest. - if (!Assembly.GetExecutingAssembly().Equals(asm)) - { - // There must be one and only one BootstrapperApplicationFactoryAttribute. - // The attribute prevents multiple declarations already. - var attrs = (BootstrapperApplicationFactoryAttribute[])asm.GetCustomAttributes(typeof(BootstrapperApplicationFactoryAttribute), false); - if (null != attrs) - { - baFactoryType = attrs[0].BootstrapperApplicationFactoryType; - } - } - - if (null == baFactoryType) - { - throw new MissingAttributeException(); - } - - return baFactoryType; - } - } -} diff --git a/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs b/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs deleted file mode 100644 index f307e53e..00000000 --- a/src/WixToolset.Mba.Core/BootstrapperSectionGroup.cs +++ /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. - -namespace WixToolset.Mba.Core -{ - using System; - using System.Configuration; - - /// - /// Handler for the wix.bootstrapper configuration section group. - /// - public class BootstrapperSectionGroup : ConfigurationSectionGroup - { - /// - /// Creates a new instance of the class. - /// - public BootstrapperSectionGroup() - { - } - - /// - /// Gets the handler for the mba configuration section. - /// - [ConfigurationProperty("host")] - public HostSection Host - { - get { return (HostSection)base.Sections["host"]; } - } - } -} diff --git a/src/WixToolset.Mba.Core/Exceptions.cs b/src/WixToolset.Mba.Core/Exceptions.cs deleted file mode 100644 index 72669a42..00000000 --- a/src/WixToolset.Mba.Core/Exceptions.cs +++ /dev/null @@ -1,145 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.Serialization; - - /// - /// Base class for exception returned to the bootstrapper application host. - /// - [Serializable] - public abstract class BootstrapperException : Exception - { - /// - /// Creates an instance of the base class with the given HRESULT. - /// - /// The HRESULT for the exception that is used by the bootstrapper application host. - public BootstrapperException(int hr) - { - this.HResult = hr; - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message. - public BootstrapperException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message - /// Inner exception associated with this one - public BootstrapperException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization information for this exception - /// Streaming context to serialize to - protected BootstrapperException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } - - /// - /// The bootstrapper application assembly loaded by the host does not contain exactly one instance of the - /// class. - /// - /// - [Serializable] - public class MissingAttributeException : BootstrapperException - { - /// - /// Creates a new instance of the class. - /// - public MissingAttributeException() - : base(NativeMethods.E_NOTFOUND) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message. - public MissingAttributeException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message - /// Inner exception associated with this one - public MissingAttributeException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization information for this exception - /// Streaming context to serialize to - protected MissingAttributeException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } - - /// - /// The bootstrapper application factory specified by the - /// does not extend the base class. - /// - /// - /// - [Serializable] - public class InvalidBootstrapperApplicationFactoryException : BootstrapperException - { - /// - /// Creates a new instance of the class. - /// - public InvalidBootstrapperApplicationFactoryException() - : base(NativeMethods.E_UNEXPECTED) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message. - public InvalidBootstrapperApplicationFactoryException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Exception message - /// Inner exception associated with this one - public InvalidBootstrapperApplicationFactoryException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Serialization information for this exception - /// Streaming context to serialize to - protected InvalidBootstrapperApplicationFactoryException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/src/WixToolset.Mba.Core/HostSection.cs b/src/WixToolset.Mba.Core/HostSection.cs deleted file mode 100644 index 2586f565..00000000 --- a/src/WixToolset.Mba.Core/HostSection.cs +++ /dev/null @@ -1,47 +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 WixToolset.Mba.Core -{ - using System; - using System.Configuration; - - /// - /// Handler for the Host configuration section. - /// - public sealed class HostSection : ConfigurationSection - { - private static readonly ConfigurationProperty assemblyNameProperty = new ConfigurationProperty("assemblyName", typeof(string), null, ConfigurationPropertyOptions.IsRequired); - private static readonly ConfigurationProperty supportedFrameworksProperty = new ConfigurationProperty("", typeof(SupportedFrameworkElementCollection), null, ConfigurationPropertyOptions.IsDefaultCollection); - - /// - /// Creates a new instance of the class. - /// - public HostSection() - { - } - - /// - /// Gets the name of the assembly that contians the child class. - /// - /// - /// The assembly specified by this name must contain the to identify - /// the type of the child class. - /// - [ConfigurationProperty("assemblyName", IsRequired = true)] - public string AssemblyName - { - get { return (string)base[assemblyNameProperty]; } - set { base[assemblyNameProperty] = value; } - } - - /// - /// Gets the of supported frameworks for the host configuration. - /// - [ConfigurationProperty("", IsDefaultCollection = true)] - [ConfigurationCollection(typeof(SupportedFrameworkElement))] - public SupportedFrameworkElementCollection SupportedFrameworks - { - get { return (SupportedFrameworkElementCollection)base[supportedFrameworksProperty]; } - } - } -} diff --git a/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs b/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs deleted file mode 100644 index 7eae8bbf..00000000 --- a/src/WixToolset.Mba.Core/SupportedFrameworkElement.cs +++ /dev/null @@ -1,47 +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 WixToolset.Mba.Core -{ - using System; - using System.Configuration; - - /// - /// Handler for the supportedFramework configuration section. - /// - public sealed class SupportedFrameworkElement : ConfigurationElement - { - private static readonly ConfigurationProperty versionProperty = new ConfigurationProperty("version", typeof(string), null, ConfigurationPropertyOptions.IsRequired); - private static readonly ConfigurationProperty runtimeVersionProperty = new ConfigurationProperty("runtimeVersion", typeof(string)); - - /// - /// Creates a new instance of the class. - /// - public SupportedFrameworkElement() - { - } - - /// - /// Gets the version of the supported framework. - /// - /// - /// The assembly specified by this name must contain a value matching the NETFX version registry key under - /// "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP". - /// - [ConfigurationProperty("version", IsRequired = true)] - public string Version - { - get { return (string)base[versionProperty]; } - set { base[versionProperty] = value; } - } - - /// - /// Gets the runtime version required by this supported framework. - /// - [ConfigurationProperty("runtimeVersion", IsRequired = false)] - public string RuntimeVersion - { - get { return (string)base[runtimeVersionProperty]; } - set { base[runtimeVersionProperty] = value; } - } - } -} diff --git a/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs b/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs deleted file mode 100644 index 88a9b4dd..00000000 --- a/src/WixToolset.Mba.Core/SupportedFrameworkElementCollection.cs +++ /dev/null @@ -1,36 +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 WixToolset.Mba.Core -{ - using System; - using System.Configuration; - using System.Diagnostics.CodeAnalysis; - - /// - /// Handler for the supportedFramework collection. - /// - [SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")] - [ConfigurationCollection(typeof(SupportedFrameworkElement), AddItemName = "supportedFramework", CollectionType = ConfigurationElementCollectionType.BasicMap)] - public sealed class SupportedFrameworkElementCollection : ConfigurationElementCollection - { - public override ConfigurationElementCollectionType CollectionType - { - get { return ConfigurationElementCollectionType.BasicMap; } - } - - protected override string ElementName - { - get { return "supportedFramework"; } - } - - protected override ConfigurationElement CreateNewElement() - { - return new SupportedFrameworkElement(); - } - - protected override object GetElementKey(ConfigurationElement element) - { - return (element as SupportedFrameworkElement).Version; - } - } -} diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config deleted file mode 100644 index 81b49347..00000000 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.config +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - -
- - - - - - - - - - - - - - diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 4b14a545..e88498ac 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -10,7 +10,7 @@ WixToolset.Mba.Core 0693;1591 v2.0 - Managed Bootstrapper Application entry point + Managed Bootstrapper Application Core true @@ -27,15 +27,11 @@ - - - - @@ -49,13 +45,6 @@ - - - - - - PreserveNewest - @@ -66,33 +55,9 @@ - - - False - - - - - - - - - - - - - - - - - - - - - diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index bbac204f..d773bcf9 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -14,10 +14,8 @@ - - -- cgit v1.2.3-55-g6feb From 0ee5b5a2f8c7fddbfbbf0011a89e4c8065a120bc Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 22 Dec 2019 14:12:24 +1100 Subject: Update WixToolset.BootstrapperCore.Native. --- src/balutil/balutil.vcxproj | 4 ++-- src/balutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 9d7dc0a5..5c934f65 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -90,7 +90,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index d747d6a9..f7638ec7 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 5ec21f74..a3c93e2a 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,7 +2,7 @@ - + @@ -69,7 +69,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index d37b6def..f7638ec7 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,6 +1,6 @@ - + - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 3c9eb7218686ffe40d841e7669d8fcf670f3c32b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 12 Mar 2020 16:22:44 +1100 Subject: Guard around defining FACILITY_WIX. --- src/balutil/balutil.vcxproj | 4 ++-- src/balutil/inc/balutil.h | 2 ++ src/balutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 5c934f65..134bc2f6 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -90,7 +90,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index 0fbaab97..d86b2728 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -13,7 +13,9 @@ extern "C" { #define BalExitOnRootFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } #define BalExitOnNullWithLastError(p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#ifndef FACILITY_WIX #define FACILITY_WIX 500 +#endif const LPCWSTR BAL_MANIFEST_FILENAME = L"BootstrapperApplicationData.xml"; diff --git a/src/balutil/packages.config b/src/balutil/packages.config index f7638ec7..01a9390c 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index a3c93e2a..4a9b91f6 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,7 +2,7 @@ - + @@ -69,7 +69,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index f7638ec7..01a9390c 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 83e4e5d759903e70a9bbf75d4d084bfda49e5877 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 30 Mar 2020 18:51:48 +1000 Subject: Upgrade to latest BootstrapperCore. --- src/WixToolset.Mba.Core/BootstrapperApplicationData.cs | 2 +- src/WixToolset.Mba.Core/BootstrapperCommand.cs | 10 +++++++++- src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs | 6 +++++- src/WixToolset.Mba.Core/IBootstrapperCommand.cs | 10 ++++++++++ src/balutil/balutil.vcxproj | 4 ++-- src/balutil/packages.config | 2 +- src/balutil/precomp.h | 5 +++-- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- src/mbanative/precomp.h | 10 +++++----- 10 files changed, 39 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs index d6d590ba..05672f1b 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs @@ -9,7 +9,7 @@ namespace WixToolset.Mba.Core public class BootstrapperApplicationData : IBootstrapperApplicationData { public const string DefaultFileName = "BootstrapperApplicationData.xml"; - public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/2010/BootstrapperApplicationData"; + public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/BootstrapperApplicationData"; public static readonly DirectoryInfo DefaultFolder; public static readonly FileInfo DefaultFile; diff --git a/src/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/WixToolset.Mba.Core/BootstrapperCommand.cs index 6854e9ae..42d19bf9 100644 --- a/src/WixToolset.Mba.Core/BootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -20,7 +20,9 @@ namespace WixToolset.Mba.Core IntPtr splashScreen, RelationType relation, bool passthrough, - string layoutDirectory) + string layoutDirectory, + string bootstrapperWorkingFolder, + string bootstrapperApplicationDataPath) { this.Action = action; this.Display = display; @@ -32,6 +34,8 @@ namespace WixToolset.Mba.Core this.Relation = relation; this.Passthrough = passthrough; this.LayoutDirectory = layoutDirectory; + this.BootstrapperWorkingFolder = bootstrapperWorkingFolder; + this.BootstrapperApplicationDataPath = bootstrapperApplicationDataPath; } public LaunchAction Action { get; } @@ -54,6 +58,10 @@ namespace WixToolset.Mba.Core public string LayoutDirectory { get; } + public string BootstrapperWorkingFolder { get; } + + public string BootstrapperApplicationDataPath { get; } + /// /// Gets the command line arguments as a string array. /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index 700f0888..d3087717 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -34,6 +34,8 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] private readonly RelationType relation; [MarshalAs(UnmanagedType.Bool)] private readonly bool passthrough; [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzLayoutDirectory; + [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzBootstrapperWorkingFolder; + [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzBootstrapperApplicationDataPath; public IBootstrapperCommand GetBootstrapperCommand() { @@ -47,7 +49,9 @@ namespace WixToolset.Mba.Core this.hwndSplashScreen, this.relation, this.passthrough, - this.wzLayoutDirectory); + this.wzLayoutDirectory, + this.wzBootstrapperWorkingFolder, + this.wzBootstrapperApplicationDataPath); } } diff --git a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs index 675abdf9..889db529 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs @@ -59,5 +59,15 @@ namespace WixToolset.Mba.Core /// Gets layout directory. ///
string LayoutDirectory { get; } + + /// + /// Gets bootstrapper working folder. + /// + string BootstrapperWorkingFolder { get; } + + /// + /// Gets path to BootstrapperApplicationData.xml. + /// + string BootstrapperApplicationDataPath { get; } } } diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 134bc2f6..ce109d36 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -90,7 +90,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 01a9390c..75a6476b 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/balutil/precomp.h b/src/balutil/precomp.h index 89607416..c500060a 100644 --- a/src/balutil/precomp.h +++ b/src/balutil/precomp.h @@ -16,8 +16,9 @@ #include #include -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" +#include +#include + #include "IBootstrapperEngine.h" #include "IBootstrapperApplication.h" diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 4a9b91f6..605cc535 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,7 +2,7 @@ - + @@ -69,7 +69,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 01a9390c..75a6476b 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/precomp.h b/src/mbanative/precomp.h index 54d8cb08..d19b4695 100644 --- a/src/mbanative/precomp.h +++ b/src/mbanative/precomp.h @@ -7,9 +7,9 @@ #include -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" +#include +#include -#include "balutil.h" +#include +#include +#include -- cgit v1.2.3-55-g6feb From 51af2090a7c911d0ae1b8232b11ca67613adf3ef Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 30 Mar 2020 18:52:22 +1000 Subject: Add bextutil. --- appveyor.cmd | 1 + balutil.sln | 10 + src/bextutil/BextBundleExtensionEngine.cpp | 331 +++++++++++++++++++++++++ src/bextutil/bextutil.cpp | 179 +++++++++++++ src/bextutil/bextutil.nuspec | 26 ++ src/bextutil/bextutil.vcxproj | 86 +++++++ src/bextutil/build/WixToolset.BextUtil.props | 23 ++ src/bextutil/inc/BextBaseBundleExtension.h | 120 +++++++++ src/bextutil/inc/BextBaseBundleExtensionProc.h | 48 ++++ src/bextutil/inc/BextBundleExtensionEngine.h | 17 ++ src/bextutil/inc/IBundleExtension.h | 20 ++ src/bextutil/inc/IBundleExtensionEngine.h | 64 +++++ src/bextutil/inc/bextutil.h | 76 ++++++ src/bextutil/packages.config | 6 + src/bextutil/precomp.cpp | 3 + src/bextutil/precomp.h | 22 ++ 16 files changed, 1032 insertions(+) create mode 100644 src/bextutil/BextBundleExtensionEngine.cpp create mode 100644 src/bextutil/bextutil.cpp create mode 100644 src/bextutil/bextutil.nuspec create mode 100644 src/bextutil/bextutil.vcxproj create mode 100644 src/bextutil/build/WixToolset.BextUtil.props create mode 100644 src/bextutil/inc/BextBaseBundleExtension.h create mode 100644 src/bextutil/inc/BextBaseBundleExtensionProc.h create mode 100644 src/bextutil/inc/BextBundleExtensionEngine.h create mode 100644 src/bextutil/inc/IBundleExtension.h create mode 100644 src/bextutil/inc/IBundleExtensionEngine.h create mode 100644 src/bextutil/inc/bextutil.h create mode 100644 src/bextutil/packages.config create mode 100644 src/bextutil/precomp.cpp create mode 100644 src/bextutil/precomp.h (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 1aceb3b0..8a7782de 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -8,6 +8,7 @@ msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v140_xp msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v141_xp msbuild -p:Configuration=Release -t:Pack src\balutil\balutil.vcxproj +msbuild -p:Configuration=Release -t:Pack src\bextutil\bextutil.vcxproj msbuild -p:Configuration=Release -t:Pack src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj @popd diff --git a/balutil.sln b/balutil.sln index 37d391fc..73df2292 100644 --- a/balutil.sln +++ b/balutil.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29503.13 MinimumVisualStudioVersion = 15.0.26124.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balutil.vcxproj", "{EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bextutil", "src\bextutil\bextutil.vcxproj", "{06027492-1CB9-48BC-B31E-C1F9356ED07E}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbanative", "src\mbanative\mbanative.vcxproj", "{665E0441-17F9-4105-B202-EDF274657F6E}" @@ -27,6 +29,14 @@ Global {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.Build.0 = Release|x64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.ActiveCfg = Release|Win32 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.Build.0 = Release|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.ActiveCfg = Debug|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.Build.0 = Debug|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.ActiveCfg = Debug|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.Build.0 = Debug|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.ActiveCfg = Release|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.Build.0 = Release|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.ActiveCfg = Release|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.Build.0 = Release|Win32 {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.ActiveCfg = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.Build.0 = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp new file mode 100644 index 00000000..02070a6f --- /dev/null +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -0,0 +1,331 @@ +// 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" + + +class CBextBundleExtensionEngine : public IBundleExtensionEngine +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBundleExtensionEngine), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = reinterpret_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBundleExtensionEngine + virtual STDMETHODIMP EscapeString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD* pcchOut + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP EvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS results = { }; + + ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); + + args.cbSize = sizeof(args); + args.wzCondition = wzCondition; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pf = results.f; + + LExit: + return hr; + } + + virtual STDMETHODIMP FormatString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD* pcchOut + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableNumeric( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS results = { }; + + ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pllValue = results.llValue; + + LExit: + SecureZeroMemory(&results, sizeof(results)); + return hr; + } + + virtual STDMETHODIMP GetVariableString( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS results = { }; + + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchValue = results.cchValue; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableVersion( + __in_z LPCWSTR wzVariable, + __out DWORD64* pqwValue + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS results = { }; + + ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pqwValue = results.qwValue; + + LExit: + SecureZeroMemory(&results, sizeof(results)); + return hr; + } + + virtual STDMETHODIMP Log( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) + { + BUNDLE_EXTENSION_ENGINE_LOG_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_LOG_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.level = level; + args.wzMessage = wzMessage; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableLiteralString( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLELITERALSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableNumeric( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.llValue = llValue; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableString( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableVersion( + __in_z LPCWSTR wzVariable, + __in DWORD64 qwValue + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.qwValue = qwValue; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); + } + +public: + CBextBundleExtensionEngine( + __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, + __in_opt LPVOID pvBundleExtensionEngineProcContext + ) + { + m_cReferences = 1; + m_pfnBundleExtensionEngineProc = pfnBundleExtensionEngineProc; + m_pvBundleExtensionEngineProcContext = pvBundleExtensionEngineProcContext; + } + +private: + long m_cReferences; + PFN_BUNDLE_EXTENSION_ENGINE_PROC m_pfnBundleExtensionEngineProc; + LPVOID m_pvBundleExtensionEngineProcContext; +}; + +HRESULT BextBundleExtensionEngineCreate( + __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, + __in_opt LPVOID pvBundleExtensionEngineProcContext, + __out IBundleExtensionEngine** ppEngineForExtension + ) +{ + HRESULT hr = S_OK; + CBextBundleExtensionEngine* pBundleExtensionEngine = NULL; + + pBundleExtensionEngine = new CBextBundleExtensionEngine(pfnBundleExtensionEngineProc, pvBundleExtensionEngineProcContext); + ExitOnNull(pBundleExtensionEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BextBundleExtensionEngine object."); + + hr = pBundleExtensionEngine->QueryInterface(IID_PPV_ARGS(ppEngineForExtension)); + ExitOnFailure(hr, "Failed to QI for IBundleExtensionEngine from BextBundleExtensionEngine object."); + +LExit: + ReleaseObject(pBundleExtensionEngine); + return hr; +} diff --git a/src/bextutil/bextutil.cpp b/src/bextutil/bextutil.cpp new file mode 100644 index 00000000..baf35591 --- /dev/null +++ b/src/bextutil/bextutil.cpp @@ -0,0 +1,179 @@ +// 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 IBundleExtensionEngine* vpEngine = NULL; + +// prototypes + +DAPI_(void) BextInitialize( + __in IBundleExtensionEngine* pEngine + ) +{ + pEngine->AddRef(); + + ReleaseObject(vpEngine); + vpEngine = pEngine; +} + +DAPI_(HRESULT) BextInitializeFromCreateArgs( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __out_opt IBundleExtensionEngine** ppEngine + ) +{ + HRESULT hr = S_OK; + IBundleExtensionEngine* pEngine = NULL; + + hr = BextBundleExtensionEngineCreate(pArgs->pfnBundleExtensionEngineProc, pArgs->pvBundleExtensionEngineProcContext, &pEngine); + ExitOnFailure(hr, "Failed to create BextBundleExtensionEngine."); + + BextInitialize(pEngine); + + if (ppEngine) + { + *ppEngine = pEngine; + } + pEngine = NULL; + +LExit: + ReleaseObject(pEngine); + + return hr; +} + + +DAPI_(void) BextUninitialize() +{ + ReleaseNullObject(vpEngine); +} + +DAPI_(HRESULT) BextGetBundleExtensionDataNode( + __in IXMLDOMDocument* pixdManifest, + __in LPCWSTR wzExtensionId, + __out IXMLDOMNode** ppixnBundleExtension + ) +{ + HRESULT hr = S_OK; + IXMLDOMElement* pixeBundleExtensionData = NULL; + IXMLDOMNodeList* pixnNodes = NULL; + IXMLDOMNode* pixnNode = NULL; + DWORD cNodes = 0; + LPWSTR sczId = NULL; + + // Get BundleExtensionData element. + hr = pixdManifest->get_documentElement(&pixeBundleExtensionData); + ExitOnFailure(hr, "Failed to get BundleExtensionData element."); + + // Select BundleExtension nodes. + hr = XmlSelectNodes(pixeBundleExtensionData, L"BundleExtension", &pixnNodes); + ExitOnFailure(hr, "Failed to select BundleExtension nodes."); + + // Get BundleExtension node count. + hr = pixnNodes->get_length((long*)&cNodes); + ExitOnFailure(hr, "Failed to get BundleExtension node count."); + + if (!cNodes) + { + ExitFunction(); + } + + // Find requested extension. + for (DWORD i = 0; i < cNodes; ++i) + { + hr = XmlNextElement(pixnNodes, &pixnNode, NULL); + ExitOnFailure(hr, "Failed to get next node."); + + // @Id + hr = XmlGetAttributeEx(pixnNode, L"Id", &sczId); + ExitOnFailure(hr, "Failed to get @Id."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczId, -1, wzExtensionId, -1)) + { + *ppixnBundleExtension = pixnNode; + pixnNode = NULL; + + ExitFunction1(hr = S_OK); + } + + // Prepare next iteration. + ReleaseNullObject(pixnNode); + } + + hr = E_NOTFOUND; + +LExit: + ReleaseStr(sczId); + ReleaseObject(pixnNode); + ReleaseObject(pixnNodes); + ReleaseObject(pixeBundleExtensionData); + + return hr; +} + + +DAPIV_(HRESULT) BextLog( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + va_end(args); + ExitOnFailure(hr, "Failed to format log string."); + + hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); + ExitOnFailure(hr, "Failed to convert log string to Unicode."); + + hr = vpEngine->Log(level, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} + + +DAPIV_(HRESULT) BextLogError( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + va_end(args); + ExitOnFailure(hr, "Failed to format error log string."); + + hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); + ExitOnFailure(hr, "Failed to prepend error number to error log string."); + + hr = vpEngine->Log(BUNDLE_EXTENSION_LOG_LEVEL_ERROR, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} diff --git a/src/bextutil/bextutil.nuspec b/src/bextutil/bextutil.nuspec new file mode 100644 index 00000000..30e0871d --- /dev/null +++ b/src/bextutil/bextutil.nuspec @@ -0,0 +1,26 @@ + + + + $id$ + $version$ + $authors$ + $authors$ + + https://licenses.nuget.org/MS-RL + https://github.com/wixtoolset/balutil + false + $description$ + $copyright$ + + + + + + + + + + + + + diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj new file mode 100644 index 00000000..3deb3317 --- /dev/null +++ b/src/bextutil/bextutil.vcxproj @@ -0,0 +1,86 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {06027492-1CB9-48BC-B31E-C1F9356ED07E} + StaticLibrary + bextutil + v141 + MultiByte + WiX Toolset Bundle Extension native utility library + + + + + + + + + + + + + + + $(ProjectDir)..\inc + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + diff --git a/src/bextutil/build/WixToolset.BextUtil.props b/src/bextutil/build/WixToolset.BextUtil.props new file mode 100644 index 00000000..3e2980ec --- /dev/null +++ b/src/bextutil/build/WixToolset.BextUtil.props @@ -0,0 +1,23 @@ + + + + + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + + + $(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + + + + $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + + diff --git a/src/bextutil/inc/BextBaseBundleExtension.h b/src/bextutil/inc/BextBaseBundleExtension.h new file mode 100644 index 00000000..69c338e4 --- /dev/null +++ b/src/bextutil/inc/BextBaseBundleExtension.h @@ -0,0 +1,120 @@ +// 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 "BundleExtensionEngine.h" +#include "BundleExtension.h" +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" + +#include "bextutil.h" + +class CBextBaseBundleExtension : public IBundleExtension +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBundleExtension), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = static_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBundleExtension + virtual STDMETHODIMP Search( + __in LPCWSTR /*wzId*/, + __in LPCWSTR /*wzVariable*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP BundleExtensionProc( + __in BUNDLE_EXTENSION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + +public: //CBextBaseBundleExtension + virtual STDMETHODIMP Initialize( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs + ) + { + HRESULT hr = S_OK; + + hr = StrAllocString(&m_sczBundleExtensionDataPath, pCreateArgs->wzBundleExtensionDataPath, 0); + ExitOnFailure(hr, "Failed to copy BundleExtensionDataPath."); + + LExit: + return hr; + } + +protected: + + CBextBaseBundleExtension( + __in IBundleExtensionEngine* pEngine + ) + { + m_cReferences = 1; + + pEngine->AddRef(); + m_pEngine = pEngine; + + m_sczBundleExtensionDataPath = NULL; + } + + virtual ~CBextBaseBundleExtension() + { + ReleaseNullObject(m_pEngine); + ReleaseStr(m_sczBundleExtensionDataPath); + } + +protected: + IBundleExtensionEngine* m_pEngine; + LPWSTR m_sczBundleExtensionDataPath; + +private: + long m_cReferences; +}; diff --git a/src/bextutil/inc/BextBaseBundleExtensionProc.h b/src/bextutil/inc/BextBaseBundleExtensionProc.h new file mode 100644 index 00000000..f71e3b92 --- /dev/null +++ b/src/bextutil/inc/BextBaseBundleExtensionProc.h @@ -0,0 +1,48 @@ +#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 "BundleExtensionEngine.h" +#include "BundleExtension.h" +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" + +static HRESULT BextBaseBEProcSearch( + __in IBundleExtension* pBE, + __in BUNDLE_EXTENSION_SEARCH_ARGS* pArgs, + __inout BUNDLE_EXTENSION_SEARCH_RESULTS* /*pResults*/ + ) +{ + return pBE->Search(pArgs->wzId, pArgs->wzVariable); +} + +/******************************************************************* +BextBaseBundleExtensionProc - requires pvContext to be of type IBundleExtension. + Provides a default mapping between the message based + BundleExtension interface and the COM-based BundleExtension interface. + +*******************************************************************/ +static HRESULT WINAPI BextBaseBundleExtensionProc( + __in BUNDLE_EXTENSION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) +{ + IBundleExtension* pBE = reinterpret_cast(pvContext); + HRESULT hr = pBE->BundleExtensionProc(message, pvArgs, pvResults, pvContext); + + if (E_NOTIMPL == hr) + { + switch (message) + { + case BUNDLE_EXTENSION_MESSAGE_SEARCH: + hr = BextBaseBEProcSearch(pBE, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + } + } + + return hr; +} diff --git a/src/bextutil/inc/BextBundleExtensionEngine.h b/src/bextutil/inc/BextBundleExtensionEngine.h new file mode 100644 index 00000000..9fdcb700 --- /dev/null +++ b/src/bextutil/inc/BextBundleExtensionEngine.h @@ -0,0 +1,17 @@ +// 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 BextBundleExtensionEngineCreate( + __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, + __in_opt LPVOID pvBundleExtensionEngineProcContext, + __out IBundleExtensionEngine** ppEngineForExtension + ); + +#ifdef __cplusplus +} +#endif diff --git a/src/bextutil/inc/IBundleExtension.h b/src/bextutil/inc/IBundleExtension.h new file mode 100644 index 00000000..7516c11b --- /dev/null +++ b/src/bextutil/inc/IBundleExtension.h @@ -0,0 +1,20 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBundleExtension, IUnknown, "93123C9D-796B-4FCD-A507-6EDEF9A925FD") +{ + STDMETHOD(Search)( + __in LPCWSTR wzId, + __in LPCWSTR wzVariable + ) = 0; + + // BundleExtensionProc - The PFN_BUNDLE_EXTENSION_PROC can call this method to give the BundleExtension raw access to the callback from the engine. + // This might be used to help the BundleExtension support more than one version of the engine. + STDMETHOD(BundleExtensionProc)( + __in BUNDLE_EXTENSION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; +}; diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h new file mode 100644 index 00000000..869c6695 --- /dev/null +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -0,0 +1,64 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-9737-C185089EB263") +{ + STDMETHOD(EscapeString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD * pcchOut + ) = 0; + + STDMETHOD(EvaluateCondition)( + __in_z LPCWSTR wzCondition, + __out BOOL * pf + ) = 0; + + STDMETHOD(FormatString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout DWORD * pcchOut + ) = 0; + + STDMETHOD(GetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) = 0; + + STDMETHOD(GetVariableString)( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue + ) = 0; + + STDMETHOD(GetVariableVersion)( + __in_z LPCWSTR wzVariable, + __out DWORD64* pqwValue + ) = 0; + + STDMETHOD(Log)( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) = 0; + + STDMETHOD(SetVariableLiteralString)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) = 0; + + STDMETHOD(SetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) = 0; + + STDMETHOD(SetVariableString)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) = 0; + + STDMETHOD(SetVariableVersion)( + __in_z LPCWSTR wzVariable, + __in DWORD64 qwValue + ) = 0; +}; diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h new file mode 100644 index 00000000..0472f854 --- /dev/null +++ b/src/bextutil/inc/bextutil.h @@ -0,0 +1,76 @@ +#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 "dutil.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define BextExitOnFailure(x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnRootFailure(x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnNullWithLastError(p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } + +const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml"; + + +/******************************************************************* + BextInitialize - remembers the engine interface to enable logging and + other functions. + +********************************************************************/ +DAPI_(void) BextInitialize( + __in IBundleExtensionEngine* pEngine + ); + +/******************************************************************* + BextInitializeFromCreateArgs - convenience function to call BextBundleExtensionEngineCreate + then pass it along to BextInitialize. + +********************************************************************/ +DAPI_(HRESULT) BextInitializeFromCreateArgs( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __out IBundleExtensionEngine** ppEngine + ); + +/******************************************************************* + BextUninitialize - cleans up utility layer internals. + +********************************************************************/ +DAPI_(void) BextUninitialize(); + +/******************************************************************* + BextGetBundleExtensionDataNode - gets the requested BundleExtension node. + +********************************************************************/ +DAPI_(HRESULT) BextGetBundleExtensionDataNode( + __in IXMLDOMDocument* pixdManifest, + __in LPCWSTR wzExtensionId, + __out IXMLDOMNode** ppixnBundleExtension + ); + +/******************************************************************* + BextLog - logs a message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BextLog( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* + BextLogError - logs an error message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BextLogError( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + ... + ); + +#ifdef __cplusplus +} +#endif diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config new file mode 100644 index 00000000..75a6476b --- /dev/null +++ b/src/bextutil/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/bextutil/precomp.cpp b/src/bextutil/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/bextutil/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/bextutil/precomp.h b/src/bextutil/precomp.h new file mode 100644 index 00000000..5d1dd20b --- /dev/null +++ b/src/bextutil/precomp.h @@ -0,0 +1,22 @@ +#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 + +#include +#include +#include +#include +#include + +#include +#include + +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" + +#include "bextutil.h" +#include "BextBundleExtensionEngine.h" -- cgit v1.2.3-55-g6feb From 523d933f7a325092e71b3862fd085791124cd36c Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 10 Apr 2020 16:14:13 +1000 Subject: Add E_DNCHOST_SCD_RUNTIME_FAILURE. --- src/balutil/inc/balutil.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index d86b2728..b2d50752 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -22,6 +22,7 @@ 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); /******************************************************************* -- cgit v1.2.3-55-g6feb From efbe40802d13867ab43f4d7808e1b91052b18ca2 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 21 Apr 2020 17:11:49 +1000 Subject: Add action to OnExecutePackageBegin. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 4 ++-- src/WixToolset.Mba.Core/EventArgs.cs | 13 ++++++++++--- src/WixToolset.Mba.Core/IBootstrapperApplication.cs | 1 + src/balutil/balutil.vcxproj | 4 ++-- src/balutil/inc/BalBaseBAFunctions.h | 1 + src/balutil/inc/BalBaseBootstrapperApplication.h | 1 + src/balutil/inc/BalBaseBootstrapperApplicationProc.h | 2 +- src/balutil/inc/IBootstrapperApplication.h | 3 ++- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 ++-- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- 13 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index f8ac2a1e..249c17c9 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1466,9 +1466,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ref bool fCancel) + int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ActionState action, ref bool fCancel) { - ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, fCancel); + ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, action, fCancel); this.OnExecutePackageBegin(args); fCancel = args.Cancel; diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 83c0c96a..ca0fa173 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -1501,13 +1501,15 @@ namespace WixToolset.Mba.Core /// Creates a new instance of the class. ///
/// The identity of the package to act on. - /// Whether the package should really be acted on. + /// Whether the package is being executed or rolled back. + /// The action about to be executed. /// The recommendation from the engine. - public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, bool cancelRecommendation) + public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, ActionState action, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.ShouldExecute = shouldExecute; + this.Action = action; } /// @@ -1516,9 +1518,14 @@ namespace WixToolset.Mba.Core public string PackageId { get; private set; } /// - /// Gets whether the package should really be acted on. + /// Gets whether the package is being executed or rolled back. /// public bool ShouldExecute { get; private set; } + + /// + /// Gets the action about to be executed. + /// + public ActionState Action { get; private set; } } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 8e5d2aeb..c4daaf32 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -392,6 +392,7 @@ namespace WixToolset.Mba.Core int OnExecutePackageBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.Bool)] bool fExecute, + [MarshalAs(UnmanagedType.U4)] ActionState action, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index ce109d36..b3a43d4c 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -90,7 +90,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index dd190ee9..411524fb 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -489,6 +489,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnExecutePackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in BOOL /*fExecute*/, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, __inout BOOL* /*pfCancel*/ ) { diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index ac354e7b..269777a6 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -603,6 +603,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnExecutePackageBegin( __in_z LPCWSTR wzPackageId, __in BOOL fExecute, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, __inout BOOL* pfCancel ) { diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 4b8f4ca7..35bc0a9e 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -402,7 +402,7 @@ static HRESULT BalBaseBAProcOnExecutePackageBegin( __inout BA_ONEXECUTEPACKAGEBEGIN_RESULTS* pResults ) { - return pBA->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, &pResults->fCancel); + return pBA->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, &pResults->fCancel); } static HRESULT BalBaseBAProcOnExecutePatchTarget( diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 6ab7ed20..30b456c7 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -388,7 +388,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // STDMETHOD(OnExecutePackageBegin)( __in_z LPCWSTR wzPackageId, - __in BOOL fExecute, + __in BOOL fExecute, // false means rollback. + __in BOOTSTRAPPER_ACTION_STATE action, __inout BOOL* pfCancel ) = 0; diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 75a6476b..38569fda 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 3deb3317..d0f045ed 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -79,7 +79,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 75a6476b..38569fda 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 605cc535..d2e2b90a 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,7 +2,7 @@ - + @@ -69,7 +69,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 75a6476b..38569fda 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 1e7800b811b658659c8487bf2ccb541fdd6bd1be Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 28 Apr 2020 11:17:29 +1000 Subject: Fix bugs around mbanative's InitializeFromCreateArgs. --- .../IBootstrapperApplicationFactory.cs | 17 +++++++++-------- src/balutil/balutil.vcxproj | 4 ++-- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 ++-- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.cpp | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- 8 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index d3087717..b9c62a99 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -23,19 +23,20 @@ namespace WixToolset.Mba.Core [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; [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; - [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzCommandLine; + 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; - [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzLayoutDirectory; - [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzBootstrapperWorkingFolder; - [MarshalAs(UnmanagedType.LPWStr)] private readonly string wzBootstrapperApplicationDataPath; + private readonly IntPtr wzLayoutDirectory; + private readonly IntPtr wzBootstrapperWorkingFolder; + private readonly IntPtr wzBootstrapperApplicationDataPath; public IBootstrapperCommand GetBootstrapperCommand() { @@ -43,15 +44,15 @@ namespace WixToolset.Mba.Core this.action, this.display, this.restart, - this.wzCommandLine, + Marshal.PtrToStringUni(this.wzCommandLine), this.nCmdShow, this.resume, this.hwndSplashScreen, this.relation, this.passthrough, - this.wzLayoutDirectory, - this.wzBootstrapperWorkingFolder, - this.wzBootstrapperApplicationDataPath); + Marshal.PtrToStringUni(this.wzLayoutDirectory), + Marshal.PtrToStringUni(this.wzBootstrapperWorkingFolder), + Marshal.PtrToStringUni(this.wzBootstrapperApplicationDataPath)); } } diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index b3a43d4c..8c96c002 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -90,7 +90,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 38569fda..e9b2d190 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index d0f045ed..eb552747 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -79,7 +79,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 38569fda..e9b2d190 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.cpp b/src/mbanative/mbanative.cpp index 745b50e7..98ea3c30 100644 --- a/src/mbanative/mbanative.cpp +++ b/src/mbanative/mbanative.cpp @@ -14,7 +14,7 @@ extern "C" HRESULT WINAPI InitializeFromCreateArgs( hr = BalInitializeFromCreateArgs(pArgs, ppEngine); ExitOnFailure(hr, "Failed to initialize Bal."); - memcpy_s(pCommand, pCommand->cbSize, pArgs->pCommand, pArgs->pCommand->cbSize); + memcpy_s(pCommand, pCommand->cbSize, pArgs->pCommand, min(pArgs->pCommand->cbSize, pCommand->cbSize)); LExit: return hr; } diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index d2e2b90a..0cba46b5 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,7 +2,7 @@ - + @@ -69,7 +69,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 38569fda..e9b2d190 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From b0b50f1d8512b6d7ebd087d19406629db0a5ef9b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 15 May 2020 13:48:12 +1000 Subject: Drop XP support. --- appveyor.cmd | 4 ++-- appveyor.yml | 2 +- src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 2 +- src/balutil/balutil.nuspec | 4 ++-- src/balutil/balutil.vcxproj | 8 ++++---- src/balutil/packages.config | 4 ++-- src/bextutil/bextutil.nuspec | 4 ++-- src/bextutil/bextutil.vcxproj | 8 ++++---- src/bextutil/packages.config | 4 ++-- src/mbanative/mbanative.vcxproj | 8 ++++---- src/mbanative/packages.config | 4 ++-- src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 8a7782de..ddad4dae 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -3,9 +3,9 @@ nuget restore -msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v140_xp +msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v140 -msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v141_xp +msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v141 msbuild -p:Configuration=Release -t:Pack src\balutil\balutil.vcxproj msbuild -p:Configuration=Release -t:Pack src\bextutil\bextutil.vcxproj diff --git a/appveyor.yml b/appveyor.yml index c1df03cc..7c686b04 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ branches: - master - develop -image: Visual Studio 2017 +image: Visual Studio 2019 version: 0.0.0.{build} configuration: Release diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index d773bcf9..c7f4a97d 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -15,7 +15,7 @@ - + diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec index 0a26004a..e82610e3 100644 --- a/src/balutil/balutil.nuspec +++ b/src/balutil/balutil.nuspec @@ -20,7 +20,7 @@ - - + + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 8c96c002..f37fde17 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -90,8 +90,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index e9b2d190..7fb53719 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.nuspec b/src/bextutil/bextutil.nuspec index 30e0871d..40488610 100644 --- a/src/bextutil/bextutil.nuspec +++ b/src/bextutil/bextutil.nuspec @@ -20,7 +20,7 @@ - - + + diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index eb552747..50c6c7d2 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -79,8 +79,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index e9b2d190..7fb53719 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 0cba46b5..5a998182 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -69,8 +69,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index e9b2d190..7fb53719 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj index d401d877..9959e261 100644 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -3,7 +3,7 @@ - netcoreapp2.1 + netcoreapp3.1 false AnyCPU;x86;x64 @@ -22,7 +22,7 @@ - + -- cgit v1.2.3-55-g6feb From 780cd25e41f2d2982807a0a2a24a734684d27fe6 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 15 May 2020 13:48:38 +1000 Subject: WIXFEAT:6164 Add OnPlanMsiPackage. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 34 ++++++- src/WixToolset.Mba.Core/EventArgs.cs | 74 +++++++++++++- .../IBootstrapperApplication.cs | 109 +++++++++++++++++++++ src/balutil/inc/BAFunctions.h | 1 + src/balutil/inc/BalBaseBAFunctions.h | 15 +++ src/balutil/inc/BalBaseBAFunctionsProc.h | 1 + src/balutil/inc/BalBaseBootstrapperApplication.h | 16 +++ .../inc/BalBaseBootstrapperApplicationProc.h | 14 ++- src/balutil/inc/IBootstrapperApplication.h | 14 +++ 9 files changed, 274 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 249c17c9..9ee909dc 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -161,6 +161,11 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanMsiFeature; + /// + /// Fired when the engine is planning an MSI or MSP package. + /// + public event EventHandler PlanMsiPackage; + /// /// Fired when the engine has completed planning the installation of a specific package. /// @@ -658,6 +663,19 @@ namespace WixToolset.Mba.Core } } + /// + /// Called when the engine is planning an MSI or MSP package. + /// + /// Additional arguments for this event. + protected virtual void OnPlanMsiPackage(PlanMsiPackageEventArgs args) + { + EventHandler handler = this.PlanMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called when then engine has completed planning the installation of a specific package. /// @@ -1288,6 +1306,18 @@ namespace WixToolset.Mba.Core return args.HResult; } + int IBootstrapperApplication.OnPlanMsiPackage(string wzPackageId, bool fExecute, ActionState action, ref bool fCancel, ref BURN_MSI_PROPERTY actionMsiProperty, ref INSTALLUILEVEL uiLevel, ref bool fDisableExternalUiHandler) + { + PlanMsiPackageEventArgs args = new PlanMsiPackageEventArgs(wzPackageId, fExecute, action, fCancel, actionMsiProperty, uiLevel, fDisableExternalUiHandler); + this.OnPlanMsiPackage(args); + + fCancel = args.Cancel; + actionMsiProperty = args.ActionMsiProperty; + uiLevel = args.UiLevel; + fDisableExternalUiHandler = args.DisableExternalUiHandler; + return args.HResult; + } + int IBootstrapperApplication.OnPlanPackageComplete(string wzPackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) { var args = new PlanPackageCompleteEventArgs(wzPackageId, hrStatus, state, requested, execute, rollback); @@ -1466,9 +1496,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ActionState action, ref bool fCancel) + int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ActionState action, INSTALLUILEVEL uiLevel, bool fDisableExternalUiHandler, ref bool fCancel) { - ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, action, fCancel); + ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, action, uiLevel, fDisableExternalUiHandler, fCancel); this.OnExecutePackageBegin(args); fCancel = args.Cancel; diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index ca0fa173..e739a853 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -995,6 +995,64 @@ namespace WixToolset.Mba.Core public FeatureState State { get; set; } } + /// + /// Additional arguments used when the engine is planning an MSI or MSP package. + /// + [Serializable] + public class PlanMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The identity of the package planned for. + /// Whether the package is planned to execute or roll back. + /// The action planned for the package. + /// The recommendation from the engine. + /// The requested MSI property to add. + /// The requested internal UI level. + /// Whether Burn is requested to set up an external UI handler. + public PlanMsiPackageEventArgs(string packageId, bool shouldExecute, ActionState action, bool cancelRecommendation, BURN_MSI_PROPERTY actionMsiProperty, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ShouldExecute = shouldExecute; + this.Action = action; + this.ActionMsiProperty = actionMsiProperty; + this.UiLevel = uiLevel; + this.DisableExternalUiHandler = disableExternalUiHandler; + } + + /// + /// Gets identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets whether the package is planned to execute or roll back. + /// + public bool ShouldExecute { get; private set; } + + /// + /// Gets the action planned for the package. + /// + public ActionState Action { get; private set; } + + /// + /// Gets or sets the requested MSI property to add. + /// + public BURN_MSI_PROPERTY ActionMsiProperty { get; set; } + + /// + /// Gets or sets the requested internal UI level. + /// + public INSTALLUILEVEL UiLevel { get; set; } + + /// + /// Gets or sets whether Burn is requested to set up an external UI handler. + /// + public bool DisableExternalUiHandler { get; set; } + } + /// /// Additional arguments used when then engine has completed planning the installation of a specific package. /// @@ -1503,13 +1561,17 @@ namespace WixToolset.Mba.Core /// The identity of the package to act on. /// Whether the package is being executed or rolled back. /// The action about to be executed. + /// The internal UI level (if this is an MSI or MSP package). + /// Whether Burn will set up an external UI handler (if this is an MSI or MSP package). /// The recommendation from the engine. - public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, ActionState action, bool cancelRecommendation) + public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, ActionState action, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.ShouldExecute = shouldExecute; this.Action = action; + this.UiLevel = uiLevel; + this.DisableExternalUiHandler = disableExternalUiHandler; } /// @@ -1526,6 +1588,16 @@ namespace WixToolset.Mba.Core /// Gets the action about to be executed. /// public ActionState Action { get; private set; } + + /// + /// Gets the internal UI level (if this is an MSI or MSP package). + /// + public INSTALLUILEVEL UiLevel { get; private set; } + + /// + /// Gets whether Burn will set up an external UI handler (if this is an MSI or MSP package). + /// + public bool DisableExternalUiHandler { get; private set; } } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index c4daaf32..fa655282 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -219,6 +219,18 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.Bool)] bool fExecute, + [MarshalAs(UnmanagedType.U4)] ActionState action, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.U4)] ref BURN_MSI_PROPERTY actionMsiProperty, + [MarshalAs(UnmanagedType.U4)] ref INSTALLUILEVEL uiLevel, + [MarshalAs(UnmanagedType.Bool)] ref bool fDisableExternalUiHandler + ); + [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanPackageComplete( @@ -393,6 +405,8 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.Bool)] bool fExecute, [MarshalAs(UnmanagedType.U4)] ActionState action, + [MarshalAs(UnmanagedType.U4)] INSTALLUILEVEL uiLevel, + [MarshalAs(UnmanagedType.Bool)] bool fDisableExternalUiHandler, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -832,4 +846,99 @@ namespace WixToolset.Mba.Core Restart, ReloadBootstrapper, } + + /// + /// The property Burn will add so the MSI can know the planned action for the package. + /// + public enum BURN_MSI_PROPERTY + { + /// + /// No property will be added. + /// + None, + + /// + /// Add BURNMSIINSTALL=1 + /// + Install, + + /// + /// Add BURNMSIMODFIY=1 + /// + Modify, + + /// + /// Add BURNMSIREPAIR=1 + /// + Repair, + + /// + /// Add BURNMSIUNINSTALL=1 + /// + Uninstall, + } + + /// + /// From msi.h + /// https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetinternalui + /// + [Flags] + public enum INSTALLUILEVEL + { + /// + /// UI level is unchanged + /// + NoChange = 0, + + /// + /// default UI is used + /// + Default = 1, + + /// + /// completely silent installation + /// + None = 2, + + /// + /// simple progress and error handling + /// + Basic = 3, + + /// + /// authored UI, wizard dialogs suppressed + /// + Reduced = 4, + + /// + /// authored UI with wizards, progress, errors + /// + Full = 5, + + /// + /// display success/failure dialog at end of install + /// + EndDialog = 0x80, + + /// + /// display only progress dialog + /// + ProgressOnly = 0x40, + + /// + /// do not display the cancel button in basic UI + /// + HideCancel = 0x20, + + /// + /// force display of source resolution even if quiet + /// + SourceResOnly = 0x100, + + /// + /// show UAC prompt even if quiet + /// Can only be used if on Windows Installer 5.0 or later + /// + UacOnly = 0x200, + } } diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 1338253d..8101afdb 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -64,6 +64,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 411524fb..4e095fb8 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -298,6 +298,19 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnPlanMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOL /*fExecute*/, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __inout BOOL* /*pfCancel*/, + __inout BURN_MSI_PROPERTY* /*pActionMsiProperty*/, + __inout INSTALLUILEVEL* /*pUiLevel*/, + __inout BOOL* /*pfDisableExternalUiHandler*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP OnPlanPackageComplete( __in_z LPCWSTR /*wzPackageId*/, __in HRESULT /*hrStatus*/, @@ -490,6 +503,8 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzPackageId*/, __in BOOL /*fExecute*/, __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __in INSTALLUILEVEL /*uiLevel*/, + __in BOOL /*fDisableExternalUiHandler*/, __inout BOOL* /*pfCancel*/ ) { diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index da0a71f7..f6ebd9f6 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -99,6 +99,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE: case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE: hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); break; case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 269777a6..1d014419 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -311,6 +311,20 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnPlanMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOL /*fExecute*/, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __inout BOOL* pfCancel, + __inout BURN_MSI_PROPERTY* /*pActionMsiProperty*/, + __inout INSTALLUILEVEL* /*pUiLevel*/, + __inout BOOL* /*pfDisableExternalUiHandler*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + virtual STDMETHODIMP OnPlanPackageComplete( __in_z LPCWSTR /*wzPackageId*/, __in HRESULT /*hrStatus*/, @@ -604,6 +618,8 @@ public: // IBootstrapperApplication __in_z LPCWSTR wzPackageId, __in BOOL fExecute, __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __in INSTALLUILEVEL /*uiLevel*/, + __in BOOL /*fDisableExternalUiHandler*/, __inout BOOL* pfCancel ) { diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 35bc0a9e..d25af1f7 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -402,7 +402,7 @@ static HRESULT BalBaseBAProcOnExecutePackageBegin( __inout BA_ONEXECUTEPACKAGEBEGIN_RESULTS* pResults ) { - return pBA->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, &pResults->fCancel); + return pBA->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, pArgs->uiLevel, pArgs->fDisableExternalUiHandler, &pResults->fCancel); } static HRESULT BalBaseBAProcOnExecutePatchTarget( @@ -504,6 +504,15 @@ static HRESULT BalBaseBAProcOnLaunchApprovedExeComplete( 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, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler); +} + /******************************************************************* BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. Provides a default mapping between the new message based BA interface and @@ -689,6 +698,9 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( 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; } } diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 30b456c7..e17d2589 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -194,6 +194,18 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; + // OnPlanMsiPackage - called when the engine plans an MSI or MSP package. + // + STDMETHOD(OnPlanMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, // false means rollback. + __in BOOTSTRAPPER_ACTION_STATE action, + __inout BOOL* pfCancel, + __inout BURN_MSI_PROPERTY* pActionMsiProperty, + __inout INSTALLUILEVEL* pUiLevel, + __inout BOOL* pfDisableExternalUiHandler + ) = 0; + // OnPlanPackageComplete - called after the engine plans a package. // STDMETHOD(OnPlanPackageComplete)( @@ -390,6 +402,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in_z LPCWSTR wzPackageId, __in BOOL fExecute, // false means rollback. __in BOOTSTRAPPER_ACTION_STATE action, + __in INSTALLUILEVEL uiLevel, + __in BOOL fDisableExternalUiHandler, __inout BOOL* pfCancel ) = 0; -- cgit v1.2.3-55-g6feb From 9010bd828e70e91523ed74733cc371eec09f58bb Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 15 May 2020 17:18:36 +1000 Subject: WIXFEAT:6164 Update BAL_INFO_PACKAGE with bal specific data. --- src/WixToolset.Mba.Core/BundleInfo.cs | 8 +-- src/WixToolset.Mba.Core/IBundleInfo.cs | 2 +- src/WixToolset.Mba.Core/IPackageInfo.cs | 6 +- src/WixToolset.Mba.Core/PackageInfo.cs | 64 ++++++++++++++++++--- src/balutil/balinfo.cpp | 99 ++++++++++++++++++++++++++++++--- src/balutil/balutil.vcxproj | 4 +- src/balutil/inc/balinfo.h | 9 ++- src/balutil/inc/balutil.h | 3 + src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 +- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 +- src/mbanative/packages.config | 2 +- 13 files changed, 177 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BundleInfo.cs b/src/WixToolset.Mba.Core/BundleInfo.cs index e6d2f6e6..e1a56878 100644 --- a/src/WixToolset.Mba.Core/BundleInfo.cs +++ b/src/WixToolset.Mba.Core/BundleInfo.cs @@ -20,10 +20,11 @@ namespace WixToolset.Mba.Core this.Packages = new Dictionary(); } - public void AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) + public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) { var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); this.Packages.Add(package.Id, package); + return package; } public static IBundleInfo ParseBundleFromStream(Stream stream) @@ -56,10 +57,7 @@ namespace WixToolset.Mba.Core bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable"); - foreach (var package in PackageInfo.ParsePackagesFromXml(root)) - { - bundle.Packages.Add(package.Id, package); - } + bundle.Packages = PackageInfo.ParsePackagesFromXml(root); return bundle; } diff --git a/src/WixToolset.Mba.Core/IBundleInfo.cs b/src/WixToolset.Mba.Core/IBundleInfo.cs index 3d5b067e..d471c677 100644 --- a/src/WixToolset.Mba.Core/IBundleInfo.cs +++ b/src/WixToolset.Mba.Core/IBundleInfo.cs @@ -11,6 +11,6 @@ namespace WixToolset.Mba.Core IDictionary Packages { get; } bool PerMachine { get; } - void AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); + IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); } } \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs index 5afe4b38..a82e81ea 100644 --- a/src/WixToolset.Mba.Core/IPackageInfo.cs +++ b/src/WixToolset.Mba.Core/IPackageInfo.cs @@ -5,12 +5,16 @@ namespace WixToolset.Mba.Core public interface IPackageInfo { CacheType CacheType { get; } + object CustomData { get; set; } string Description { get; } - bool DisplayInternalUI { get; } + string DisplayInternalUICondition { get; } string DisplayName { get; } string Id { get; } string InstallCondition { get; } bool Permanent { get; } + bool PrereqPackage { get; } + string PrereqLicenseFile { get; } + string PrereqLicenseUrl { get; } string ProductCode { get; } PackageType Type { get; } string UpgradeCode { get; } diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index 46894d2e..d3199c08 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -34,17 +34,22 @@ namespace WixToolset.Mba.Core public PackageType Type { get; internal set; } public bool Permanent { get; internal set; } public bool Vital { get; internal set; } - public bool DisplayInternalUI { get; internal set; } + public string DisplayInternalUICondition { get; internal set; } public string ProductCode { get; internal set; } public string UpgradeCode { get; internal set; } public string Version { get; internal set; } public string InstallCondition { get; internal set; } public CacheType CacheType { get; internal set; } + public bool PrereqPackage { get; internal set; } + public string PrereqLicenseFile { get; internal set; } + public string PrereqLicenseUrl { get; internal set; } + public object CustomData { get; set; } internal PackageInfo() { } - public static IEnumerable ParsePackagesFromXml(XPathNavigator root) + public static IDictionary ParsePackagesFromXml(XPathNavigator root) { + var packagesById = new Dictionary(); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); @@ -85,9 +90,6 @@ namespace WixToolset.Mba.Core } package.Vital = vital.Value; - bool? displayInternalUI = BootstrapperApplicationData.GetYesNoAttribute(node, "DisplayInternalUI"); - package.DisplayInternalUI = displayInternalUI.HasValue && displayInternalUI.Value; - package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); @@ -96,8 +98,11 @@ namespace WixToolset.Mba.Core package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); - yield return package; + packagesById.Add(package.Id, package); } + + ParseBalPackageInfoFromXml(root, namespaceManager, packagesById); + return packagesById; } public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) @@ -154,7 +159,7 @@ namespace WixToolset.Mba.Core } } - public static PackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) + public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) { PackageInfo package = new PackageInfo(); package.Id = id; @@ -177,5 +182,50 @@ namespace WixToolset.Mba.Core return package; } + + internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespaceManager namespaceManager, Dictionary packagesById) + { + XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixBalPackageInfo", namespaceManager); + + foreach (XPathNavigator node in nodes) + { + string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); + if (id == null) + { + throw new Exception("Failed to get package identifier for WixBalPackageInfo."); + } + + if (!packagesById.TryGetValue(id, out var ipackage)) + { + throw new Exception(string.Format("Failed to find package specified in WixBalPackageInfo: {0}", id)); + } + + var package = (PackageInfo)ipackage; + + package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); + } + + nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", 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."); + } + + if (!packagesById.TryGetValue(id, out var ipackage)) + { + throw new Exception(string.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); + } + + var package = (PackageInfo)ipackage; + + package.PrereqPackage = true; + package.PrereqLicenseFile = BootstrapperApplicationData.GetAttribute(node, "LicenseFile"); + package.PrereqLicenseUrl = BootstrapperApplicationData.GetAttribute(node, "LicenseUrl"); + } + } } } diff --git a/src/balutil/balinfo.cpp b/src/balutil/balinfo.cpp index b36e3741..492c8e08 100644 --- a/src/balutil/balinfo.cpp +++ b/src/balutil/balinfo.cpp @@ -7,6 +7,10 @@ static HRESULT ParsePackagesFromXml( __in BAL_INFO_PACKAGES* pPackages, __in IXMLDOMDocument* pixdManifest ); +static HRESULT ParseBalPackageInfoFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ); DAPI_(HRESULT) BalInfoParseFromXml( @@ -44,6 +48,9 @@ DAPI_(HRESULT) BalInfoParseFromXml( hr = ParsePackagesFromXml(&pBundle->packages, pixdManifest); BalExitOnFailure(hr, "Failed to parse package information from bootstrapper application data."); + hr = ParseBalPackageInfoFromXml(&pBundle->packages, pixdManifest); + BalExitOnFailure(hr, "Failed to parse bal package information from bootstrapper application data."); + LExit: ReleaseObject(pNode); @@ -55,7 +62,8 @@ DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( __in BAL_INFO_PACKAGES* pPackages, __in LPCWSTR wzId, __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in BOOL /*fPerMachine*/ + __in BOOL /*fPerMachine*/, + __out_opt BAL_INFO_PACKAGE** ppPackage ) { HRESULT hr = S_OK; @@ -104,6 +112,11 @@ DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( // TODO: try to look up the DisplayName and Description in Add/Remove Programs with the wzId. + if (ppPackage) + { + *ppPackage = pPackage; + } + LExit: return hr; } @@ -139,10 +152,13 @@ DAPI_(void) BalInfoUninitialize( ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayName); ReleaseStr(pBundle->packages.rgPackages[i].sczDescription); ReleaseStr(pBundle->packages.rgPackages[i].sczId); + ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayInternalUICondition); ReleaseStr(pBundle->packages.rgPackages[i].sczProductCode); ReleaseStr(pBundle->packages.rgPackages[i].sczUpgradeCode); ReleaseStr(pBundle->packages.rgPackages[i].sczVersion); ReleaseStr(pBundle->packages.rgPackages[i].sczInstallCondition); + ReleaseStr(pBundle->packages.rgPackages[i].sczPrereqLicenseFile); + ReleaseStr(pBundle->packages.rgPackages[i].sczPrereqLicenseUrl); } ReleaseMem(pBundle->packages.rgPackages); @@ -218,12 +234,6 @@ static HRESULT ParsePackagesFromXml( hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital); ExitOnFailure(hr, "Failed to get vital setting for package."); - hr = XmlGetYesNoAttribute(pNode, L"DisplayInternalUI", &prgPackages[iPackage].fDisplayInternalUI); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get DisplayInternalUI setting for package."); - } - hr = XmlGetAttributeEx(pNode, L"ProductCode", &prgPackages[iPackage].sczProductCode); if (E_NOTFOUND != hr) { @@ -286,3 +296,78 @@ LExit: return hr; } + + +static HRESULT ParseBalPackageInfoFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ) +{ + HRESULT hr = S_OK; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + LPWSTR scz = NULL; + BAL_INFO_PACKAGE* pPackage = NULL; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalPackageInfo", &pNodeList); + ExitOnFailure(hr, "Failed to select all packages."); + + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); + ExitOnFailure(hr, "Failed to get package identifier for WixBalPackageInfo."); + + hr = BalInfoFindPackageById(pPackages, scz, &pPackage); + ExitOnFailure(hr, "Failed to find package specified in WixBalPackageInfo: %ls", scz); + + hr = XmlGetAttributeEx(pNode, L"DisplayInternalUICondition", &pPackage->sczDisplayInternalUICondition); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get DisplayInternalUICondition setting for package."); + } + + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all WixBalPackageInfo elements."); + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixMbaPrereqInformation", &pNodeList); + ExitOnFailure(hr, "Failed to select all packages."); + + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); + ExitOnFailure(hr, "Failed to get package identifier for WixMbaPrereqInformation."); + + hr = BalInfoFindPackageById(pPackages, scz, &pPackage); + ExitOnFailure(hr, "Failed to find package specified in WixMbaPrereqInformation: %ls", scz); + + pPackage->fPrereqPackage = TRUE; + + hr = XmlGetAttributeEx(pNode, L"LicenseFile", &pPackage->sczPrereqLicenseFile); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get LicenseFile setting for prereq package."); + } + + hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &pPackage->sczPrereqLicenseUrl); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get LicenseUrl setting for prereq package."); + } + + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all WixMbaPrereqInformation elements."); + + if (S_FALSE == hr) + { + hr = S_OK; + } + +LExit: + ReleaseStr(scz); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + + return hr; +} diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index f37fde17..31f0a9f7 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -3,7 +3,7 @@ - + @@ -91,7 +91,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/balinfo.h b/src/balutil/inc/balinfo.h index be4b75d0..0d838ae3 100644 --- a/src/balutil/inc/balinfo.h +++ b/src/balutil/inc/balinfo.h @@ -34,12 +34,16 @@ typedef struct _BAL_INFO_PACKAGE BAL_INFO_PACKAGE_TYPE type; BOOL fPermanent; BOOL fVital; - BOOL fDisplayInternalUI; + LPWSTR sczDisplayInternalUICondition; LPWSTR sczProductCode; LPWSTR sczUpgradeCode; LPWSTR sczVersion; LPWSTR sczInstallCondition; BAL_INFO_CACHE_TYPE cacheType; + BOOL fPrereqPackage; + LPWSTR sczPrereqLicenseFile; + LPWSTR sczPrereqLicenseUrl; + LPVOID pvCustomData; } BAL_INFO_PACKAGE; @@ -78,7 +82,8 @@ DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( __in BAL_INFO_PACKAGES* pPackages, __in LPCWSTR wzId, __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in BOOL fPerMachine + __in BOOL fPerMachine, + __out_opt BAL_INFO_PACKAGE** ppPackage ); diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index b2d50752..bbfb16a2 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -11,7 +11,10 @@ extern "C" { #define BalExitOnFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } #define BalExitOnRootFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnLastError(x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } } +#define BalExitOnNull(p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } #define BalExitOnNullWithLastError(p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BalExitWithLastError(x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } #ifndef FACILITY_WIX #define FACILITY_WIX 500 diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 7fb53719..251df9d0 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 50c6c7d2..d6fa3816 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -3,7 +3,7 @@ - + @@ -80,7 +80,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 7fb53719..251df9d0 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 5a998182..f86c7fef 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -3,7 +3,7 @@ - + @@ -70,7 +70,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 7fb53719..251df9d0 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From b7ee8f1eaa4e67b3eeba426b4bc528b35042dbea Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 18 Jun 2020 18:03:33 +1000 Subject: Create netstandard version of Mba.Core and separate nupkg for mbanative. --- appveyor.cmd | 14 +++-- balutil.sln | 10 +-- src/WixToolset.Mba.Core/Engine.cs | 10 +-- src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs | 17 ----- src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 73 ++++------------------ src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 16 +++-- .../build/net20/WixToolset.Mba.Core.props | 11 ---- src/WixToolset.Mba.Core/packages.config | 4 -- src/mbanative/mbanative.vcxproj | 10 ++- .../runtime.win.WixToolset.Mba.Core.nuspec | 19 ++++++ .../WixToolsetTest.Mba.Core.csproj | 2 +- 11 files changed, 72 insertions(+), 114 deletions(-) delete mode 100644 src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs delete mode 100644 src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props delete mode 100644 src/WixToolset.Mba.Core/packages.config create mode 100644 src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index ddad4dae..1e1f118c 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -1,15 +1,19 @@ @setlocal @pushd %~dp0 +@set _C=Release nuget restore -msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v140 +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v140 -msbuild -p:Configuration=Release;Platform=x86;PlatformToolset=v141 +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 -msbuild -p:Configuration=Release -t:Pack src\balutil\balutil.vcxproj -msbuild -p:Configuration=Release -t:Pack src\bextutil\bextutil.vcxproj -msbuild -p:Configuration=Release -t:Pack src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj +@rem msbuild -t:VSTest -p:Configuration=%_C% src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj + +msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj +msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj +msbuild -t:Pack -p:Configuration=%_C% src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj +msbuild -t:Pack -p:Configuration=%_C% src\mbanative\mbanative.vcxproj @popd @endlocal \ No newline at end of file diff --git a/balutil.sln b/balutil.sln index 73df2292..e923cf15 100644 --- a/balutil.sln +++ b/balutil.sln @@ -7,7 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balu EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bextutil", "src\bextutil\bextutil.vcxproj", "{06027492-1CB9-48BC-B31E-C1F9356ED07E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbanative", "src\mbanative\mbanative.vcxproj", "{665E0441-17F9-4105-B202-EDF274657F6E}" EndProject @@ -52,10 +52,10 @@ Global {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.ActiveCfg = Release|Win32 {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.ActiveCfg = Release|Win32 {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.Build.0 = Release|Win32 - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.ActiveCfg = Debug|x64 - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.Build.0 = Debug|x64 - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.ActiveCfg = Debug|x86 - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.Build.0 = Debug|x86 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.Build.0 = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.Build.0 = Debug|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.ActiveCfg = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.Build.0 = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.ActiveCfg = Release|Any CPU diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index f2cc3947..408278ed 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -332,14 +332,14 @@ namespace WixToolset.Mba.Core internal sealed class Variables : IVariables { // .NET 2.0 does not support Func or Action. - internal delegate T Getter(string name); - internal delegate void Setter(string name, T value); + internal delegate T Getter(string name); + internal delegate void Setter(string name, T value); - private Getter getter; - private Setter setter; + private Getter getter; + private Setter setter; private Predicate contains; - internal Variables(Getter getter, Setter setter, Predicate contains) + internal Variables(Getter getter, Setter setter, Predicate contains) { this.getter = getter; this.setter = setter; diff --git a/src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs b/src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs deleted file mode 100644 index 386748a8..00000000 --- a/src/WixToolset.Mba.Core/Properties/AssemblyInfo.cs +++ /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. - -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Managed Bootstrapper Application Core (WiX)")] -[assembly: AssemblyDescription("Managed Bootstrapper Application Core")] -[assembly: AssemblyProduct("WiX Toolset")] -[assembly: AssemblyCompany("WiX Toolset Team")] -[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and contributors. All rights reserved.")] - -// Types should not be visible to COM by default. -[assembly: ComVisible(false)] -[assembly: Guid("6f4e0cc9-8ad4-4b5a-a669-3aafff67a76f")] - -[assembly: CLSCompliantAttribute(true)] diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index e88498ac..b05ea8b9 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -1,76 +1,29 @@  - - + - {E7E1841E-A58E-4901-B9CA-4845B807D45F} + netstandard2.0;net20 WixToolset.Mba.Core - Library WixToolset.Mba.Core - 0693;1591 - v2.0 + embedded Managed Bootstrapper Application Core + $(MSBuildThisFileName).nuspec - - true - false - $(DefineConstants);DEBUG;TRACE - - - true - true - $(DefineConstants);TRACE + + + $(OutputPath)\$(AssemblyName).xml + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + $(OutputPath) + Configuration=$(Configuration);Id=$(MSBuildThisFileName);Version=$(BuildVersionSimple);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description) - - - - $(OutputPath)\$(AssemblyName).xml - \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index c7f4a97d..4f3a2744 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -5,17 +5,23 @@ $version$ WiX Toolset Team WiX Toolset Team - - https://licenses.nuget.org/MS-RL + MS-RL https://github.com/wixtoolset/balutil false $description$ $copyright$ + + + + + + + + - - - + + diff --git a/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props deleted file mode 100644 index c0018e0d..00000000 --- a/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)x86\mbanative.dll - - - - - diff --git a/src/WixToolset.Mba.Core/packages.config b/src/WixToolset.Mba.Core/packages.config deleted file mode 100644 index 03e866cf..00000000 --- a/src/WixToolset.Mba.Core/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index f86c7fef..0a740a9f 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -31,12 +31,17 @@ Unicode mbanative mbanative.def + Native component of WixToolset.Mba.Core + + + + ..\balutil\inc balutil.lib @@ -63,8 +68,11 @@ + + + + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec b/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec new file mode 100644 index 00000000..a8546092 --- /dev/null +++ b/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec @@ -0,0 +1,19 @@ + + + + $id$ + $version$ + WiX Toolset Team + WiX Toolset Team + MS-RL + https://github.com/wixtoolset/balutil + false + $description$ + $copyright$ + + + + + + + diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj index 9959e261..8691f89f 100644 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 false - AnyCPU;x86;x64 + win-x86 -- cgit v1.2.3-55-g6feb From 1571b2e9a0dc0925e8d4bfacc19d7acd29068ff8 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 18 Jun 2020 21:58:51 +1000 Subject: Add v142, x64, ARM, and ARM64. --- appveyor.cmd | 9 +++++ balutil.sln | 47 +++++++++++++++++++++- src/balutil/balutil.nuspec | 8 ++++ src/balutil/balutil.vcxproj | 22 ++++++++-- src/balutil/build/WixToolset.BalUtil.props | 5 +++ src/balutil/packages.config | 2 +- src/bextutil/bextutil.nuspec | 8 ++++ src/bextutil/bextutil.vcxproj | 22 ++++++++-- src/bextutil/build/WixToolset.BextUtil.props | 5 +++ src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 22 ++++++++-- src/mbanative/packages.config | 2 +- .../runtime.win.WixToolset.Mba.Core.nuspec | 10 ++++- .../WixToolsetTest.Mba.Core.csproj | 4 -- 14 files changed, 149 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 1e1f118c..bb617d8f 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -5,8 +5,17 @@ nuget restore msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v140 +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v140 msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v141 +msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v141 +msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v141 + +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v142 +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 +msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v142 +msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 @rem msbuild -t:VSTest -p:Configuration=%_C% src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj diff --git a/balutil.sln b/balutil.sln index e923cf15..9bca316a 100644 --- a/balutil.sln +++ b/balutil.sln @@ -15,47 +15,92 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Mba.Core", " EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM.ActiveCfg = Debug|ARM + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM.Build.0 = Debug|ARM + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM64.Build.0 = Debug|ARM64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.ActiveCfg = Debug|x64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.Build.0 = Debug|x64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.ActiveCfg = Debug|Win32 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.Build.0 = Debug|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM.ActiveCfg = Release|ARM + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM.Build.0 = Release|ARM + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM64.ActiveCfg = Release|ARM64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM64.Build.0 = Release|ARM64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.ActiveCfg = Release|x64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.Build.0 = Release|x64 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.ActiveCfg = Release|Win32 {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.Build.0 = Release|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM.ActiveCfg = Debug|ARM + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM.Build.0 = Debug|ARM + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM64.Build.0 = Debug|ARM64 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.ActiveCfg = Debug|x64 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.Build.0 = Debug|x64 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.ActiveCfg = Debug|Win32 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.Build.0 = Debug|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM.ActiveCfg = Release|ARM + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM.Build.0 = Release|ARM + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM64.ActiveCfg = Release|ARM64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM64.Build.0 = Release|ARM64 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.ActiveCfg = Release|x64 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.Build.0 = Release|x64 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.ActiveCfg = Release|Win32 {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.Build.0 = Release|Win32 + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM64.Build.0 = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.ActiveCfg = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.Build.0 = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.ActiveCfg = Debug|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM.Build.0 = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM64.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM64.Build.0 = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.ActiveCfg = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.ActiveCfg = Release|Any CPU {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.Build.0 = Release|Any CPU + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM.ActiveCfg = Debug|ARM + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM.Build.0 = Debug|ARM + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM64.Build.0 = Debug|ARM64 {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.ActiveCfg = Debug|x64 {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.Build.0 = Debug|x64 {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.ActiveCfg = Debug|Win32 {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.Build.0 = Debug|Win32 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.ActiveCfg = Release|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM.ActiveCfg = Release|ARM + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM.Build.0 = Release|ARM + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM64.ActiveCfg = Release|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM64.Build.0 = Release|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.ActiveCfg = Release|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.Build.0 = Release|x64 {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.ActiveCfg = Release|Win32 {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.Build.0 = Release|Win32 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM.Build.0 = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM64.Build.0 = Debug|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.ActiveCfg = Debug|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.Build.0 = Debug|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.ActiveCfg = Debug|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.Build.0 = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM.Build.0 = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM64.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM64.Build.0 = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.ActiveCfg = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.Build.0 = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.ActiveCfg = Release|Any CPU diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec index e82610e3..b9d8d139 100644 --- a/src/balutil/balutil.nuspec +++ b/src/balutil/balutil.nuspec @@ -21,6 +21,14 @@ + + + + + + + + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 31f0a9f7..f4207910 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -3,13 +3,29 @@ - + + + Debug + ARM + + + Debug + ARM64 + Debug Win32 + + Release + ARM + + + Release + ARM64 + Release Win32 @@ -28,7 +44,7 @@ {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} StaticLibrary balutil - v141 + v142 MultiByte WiX Toolset Bootstrapper Application Layer native utility library @@ -91,7 +107,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/build/WixToolset.BalUtil.props b/src/balutil/build/WixToolset.BalUtil.props index 0c92a3fb..45b97f6a 100644 --- a/src/balutil/build/WixToolset.BalUtil.props +++ b/src/balutil/build/WixToolset.BalUtil.props @@ -20,4 +20,9 @@ $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + + $(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 251df9d0..be537005 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/bextutil/bextutil.nuspec b/src/bextutil/bextutil.nuspec index 40488610..a1276b6f 100644 --- a/src/bextutil/bextutil.nuspec +++ b/src/bextutil/bextutil.nuspec @@ -21,6 +21,14 @@ + + + + + + + + diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index d6fa3816..b4aee2c7 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -3,13 +3,29 @@ - + + + Debug + ARM + + + Debug + ARM64 + Debug Win32 + + Release + ARM + + + Release + ARM64 + Release Win32 @@ -28,7 +44,7 @@ {06027492-1CB9-48BC-B31E-C1F9356ED07E} StaticLibrary bextutil - v141 + v142 MultiByte WiX Toolset Bundle Extension native utility library @@ -80,7 +96,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/build/WixToolset.BextUtil.props b/src/bextutil/build/WixToolset.BextUtil.props index 3e2980ec..60a2db54 100644 --- a/src/bextutil/build/WixToolset.BextUtil.props +++ b/src/bextutil/build/WixToolset.BextUtil.props @@ -20,4 +20,9 @@ $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + + $(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 251df9d0..be537005 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 0a740a9f..29842a9b 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -3,13 +3,29 @@ - + + + Debug + ARM + + + Debug + ARM64 + Debug Win32 + + Release + ARM + + + Release + ARM64 + Release Win32 @@ -27,7 +43,7 @@ {665E0441-17F9-4105-B202-EDF274657F6E} DynamicLibrary - v141 + v142 Unicode mbanative mbanative.def @@ -78,7 +94,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 251df9d0..be537005 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec b/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec index a8546092..c95531da 100644 --- a/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec +++ b/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec @@ -13,7 +13,13 @@ - - + + + + + + + + diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj index 8691f89f..34a51a05 100644 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -8,10 +8,6 @@ win-x86 - - NU1701 - - {665E0441-17F9-4105-B202-EDF274657F6E} -- cgit v1.2.3-55-g6feb From 04c8a362c9b001811ef5406716667eb73163aa10 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 18 Jun 2020 22:02:10 +1000 Subject: Fail build on each command. --- appveyor.cmd | 32 ++++++++++++++++---------------- src/balutil/balutil.nuspec | 3 +-- src/bextutil/bextutil.nuspec | 3 +-- 3 files changed, 18 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index bb617d8f..75799bc1 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -2,27 +2,27 @@ @pushd %~dp0 @set _C=Release -nuget restore +nuget restore || exit /b -msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v140 -msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v140 +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v140 || exit /b +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v140 || exit /b -msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 -msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v141 -msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v141 -msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v141 +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 || exit /b +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v141 || exit /b +msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v141 || exit /b +msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v141 || exit /b -msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v142 -msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 -msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v142 -msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v142 || exit /b +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 || exit /b +msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v142 || exit /b +msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 || exit /b -@rem msbuild -t:VSTest -p:Configuration=%_C% src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj +@rem msbuild -t:VSTest -p:Configuration=%_C% src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b -msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj -msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj -msbuild -t:Pack -p:Configuration=%_C% src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj -msbuild -t:Pack -p:Configuration=%_C% src\mbanative\mbanative.vcxproj +msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b +msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b +msbuild -t:Pack -p:Configuration=%_C% src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b +msbuild -t:Pack -p:Configuration=%_C% src\mbanative\mbanative.vcxproj || exit /b @popd @endlocal \ No newline at end of file diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec index b9d8d139..60c32bb1 100644 --- a/src/balutil/balutil.nuspec +++ b/src/balutil/balutil.nuspec @@ -5,8 +5,7 @@ $version$ $authors$ $authors$ - - https://licenses.nuget.org/MS-RL + MS-RL https://github.com/wixtoolset/balutil false $description$ diff --git a/src/bextutil/bextutil.nuspec b/src/bextutil/bextutil.nuspec index a1276b6f..e8a08075 100644 --- a/src/bextutil/bextutil.nuspec +++ b/src/bextutil/bextutil.nuspec @@ -5,8 +5,7 @@ $version$ $authors$ $authors$ - - https://licenses.nuget.org/MS-RL + MS-RL https://github.com/wixtoolset/balutil false $description$ -- cgit v1.2.3-55-g6feb From d21aad3f7b694ece882f8bba48958625dd060dbd Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 22 Jun 2020 14:21:22 +1000 Subject: Fix WixToolset.Mba.Core.nuspec - group without framework is fallback not common --- src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index 4f3a2744..95d229b6 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -15,8 +15,6 @@ - - -- cgit v1.2.3-55-g6feb From 7af7a8d2b52bdb102cfbbd2523c6f4b417af1dcd Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 24 Jun 2020 11:05:21 +1000 Subject: Update to latest dutil. --- src/balutil/balutil.vcxproj | 4 ++-- src/balutil/inc/balutil.h | 19 +++++++++++++------ src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 ++-- src/bextutil/inc/bextutil.h | 16 +++++++++++++--- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- 8 files changed, 35 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index f4207910..d522a2e4 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -3,7 +3,7 @@ - + @@ -107,7 +107,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index bbfb16a2..68ef5a4d 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -9,12 +9,19 @@ extern "C" { #endif -#define BalExitOnFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } -#define BalExitOnRootFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } -#define BalExitOnLastError(x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } } -#define BalExitOnNull(p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } -#define BalExitOnNullWithLastError(p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } -#define BalExitWithLastError(x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } +#define BalExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } + +#define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitOnLastError(x, f, ...) BalExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) +#define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) +#define BalExitWithLastError(x, f, ...) BalExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) #ifndef FACILITY_WIX #define FACILITY_WIX 500 diff --git a/src/balutil/packages.config b/src/balutil/packages.config index be537005..52ccddb4 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index b4aee2c7..17679b6d 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -3,7 +3,7 @@ - + @@ -96,7 +96,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h index 0472f854..e80d3944 100644 --- a/src/bextutil/inc/bextutil.h +++ b/src/bextutil/inc/bextutil.h @@ -9,9 +9,19 @@ extern "C" { #endif -#define BextExitOnFailure(x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } -#define BextExitOnRootFailure(x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } -#define BextExitOnNullWithLastError(p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } +#define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } + +#define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitOnLastError(x, f, ...) BextExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) +#define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) +#define BextExitWithLastError(x, f, ...) BextExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml"; diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index be537005..52ccddb4 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 29842a9b..31f4907e 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -3,7 +3,7 @@ - + @@ -94,7 +94,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index be537005..52ccddb4 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 844c971ed5afa15f73032e1cc7d2ddce2c925cdc Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 24 Jun 2020 11:51:14 +1000 Subject: Add SourceLink to C++ projects. --- src/mbanative/mbanative.vcxproj | 17 +++++++++++++++-- src/mbanative/packages.config | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 31f4907e..737075e8 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,6 +2,9 @@ + + + @@ -48,6 +51,7 @@ mbanative mbanative.def Native component of WixToolset.Mba.Core + false @@ -55,6 +59,9 @@ + + + @@ -93,8 +100,14 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + - - + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 52ccddb4..8b533737 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -1,5 +1,8 @@  + + + -- cgit v1.2.3-55-g6feb From 69ed2c07285729b55a0a26adcf19ce684c437a44 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 24 Jun 2020 15:32:11 +1000 Subject: Turn tests off in appveyor.yml since they're run in appveyor.cmd --- appveyor.cmd | 2 +- appveyor.yml | 2 ++ src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 38 ++++++++++++++++++++++ .../WixToolsetTest.Mba.Core.csproj | 5 --- 4 files changed, 41 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 75799bc1..0ccdecc6 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -17,7 +17,7 @@ msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 || exit /b msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v142 || exit /b msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 || exit /b -@rem msbuild -t:VSTest -p:Configuration=%_C% src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b +dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b diff --git a/appveyor.yml b/appveyor.yml index 7c686b04..e4d25586 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,6 +21,8 @@ environment: build_script: - appveyor.cmd +test: off + pull_requests: do_not_increment_build_number: true diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index b05ea8b9..6c5f0050 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -20,6 +20,44 @@ + + $(MSBuildProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt + $(NCrunchOriginalProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt + + + + + + + + + + + + + + PreserveNewest + %(Filename)%(Extension) + + + + + + + + + + + + + + + + + + + + $(OutputPath) diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj index 34a51a05..9d9b9c2b 100644 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -9,11 +9,6 @@ - - {665E0441-17F9-4105-B202-EDF274657F6E} - Content - Always - -- cgit v1.2.3-55-g6feb From 57fc25f5bf81dcc5edbf1b1e7c331dde8fe4578f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 24 Jun 2020 16:18:36 +1000 Subject: Merge the native nupkg into the Mba.Core nupkg. Manually author the repository element in the nupkg for SourceLink. --- appveyor.cmd | 1 - src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 2 +- src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 24 ++++++++++++++------- src/mbanative/mbanative.vcxproj | 5 ----- .../runtime.win.WixToolset.Mba.Core.nuspec | 25 ---------------------- 5 files changed, 17 insertions(+), 40 deletions(-) delete mode 100644 src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 0ccdecc6..34f8beb0 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -22,7 +22,6 @@ dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.M msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b msbuild -t:Pack -p:Configuration=%_C% src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b -msbuild -t:Pack -p:Configuration=%_C% src\mbanative\mbanative.vcxproj || exit /b @popd @endlocal \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 6c5f0050..5ffd617a 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -61,7 +61,7 @@ $(OutputPath) - Configuration=$(Configuration);Id=$(MSBuildThisFileName);Version=$(BuildVersionSimple);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description) + Id=$(MSBuildThisFileName);Version=$(BuildVersionSimple);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl) \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index 95d229b6..3a9f05df 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -1,25 +1,33 @@ - - + + $id$ $version$ - WiX Toolset Team - WiX Toolset Team + $authors$ + $authors$ MS-RL https://github.com/wixtoolset/balutil false $description$ $copyright$ - + - - - + + + + + + + + + + + diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 737075e8..ef1616c3 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -50,7 +50,6 @@ Unicode mbanative mbanative.def - Native component of WixToolset.Mba.Core false @@ -91,10 +90,6 @@ - - - - diff --git a/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec b/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec deleted file mode 100644 index c95531da..00000000 --- a/src/mbanative/runtime.win.WixToolset.Mba.Core.nuspec +++ /dev/null @@ -1,25 +0,0 @@ - - - - $id$ - $version$ - WiX Toolset Team - WiX Toolset Team - MS-RL - https://github.com/wixtoolset/balutil - false - $description$ - $copyright$ - - - - - - - - - - - - - -- cgit v1.2.3-55-g6feb From fd385c79b4f00ebe897e864481669295d8fc112c Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 24 Jun 2020 16:19:06 +1000 Subject: Move native pdbs into symbols package. --- src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 5ffd617a..00fc8548 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -9,6 +9,7 @@ embedded Managed Bootstrapper Application Core $(MSBuildThisFileName).nuspec + true -- cgit v1.2.3-55-g6feb From 44355b6fa5c92a00f0d2fb33ba627a25f052664b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 1 Jul 2020 21:27:43 +1000 Subject: Add BalLogArgs and BalLogErrorArgs. --- src/balutil/balutil.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++---- src/balutil/inc/balutil.h | 20 +++++++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp index df254359..7567752c 100644 --- a/src/balutil/balutil.cpp +++ b/src/balutil/balutil.cpp @@ -251,6 +251,29 @@ DAPIV_(HRESULT) BalLog( { HRESULT hr = S_OK; va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BalLogArgs(level, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalLogArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; LPSTR sczFormattedAnsi = NULL; LPWSTR sczMessage = NULL; @@ -260,9 +283,7 @@ DAPIV_(HRESULT) BalLog( ExitOnRootFailure(hr, "BalInitialize() must be called first."); } - va_start(args, szFormat); hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - va_end(args); ExitOnFailure(hr, "Failed to format log string."); hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); @@ -285,6 +306,29 @@ DAPIV_(HRESULT) BalLogError( { HRESULT hr = S_OK; va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BalLogErrorArgs(hrError, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalLogErrorArgs( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; LPSTR sczFormattedAnsi = NULL; LPWSTR sczMessage = NULL; @@ -294,9 +338,7 @@ DAPIV_(HRESULT) BalLogError( ExitOnRootFailure(hr, "BalInitialize() must be called first."); } - va_start(args, szFormat); hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - va_end(args); ExitOnFailure(hr, "Failed to format error log string."); hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index 68ef5a4d..e0f5874c 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -144,6 +144,16 @@ DAPIV_(HRESULT) BalLog( ... ); +/******************************************************************* + BalLogArgs - logs a message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BalLogArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + /******************************************************************* BalLogError - logs an error message with the engine. @@ -154,6 +164,16 @@ DAPIV_(HRESULT) BalLogError( ... ); +/******************************************************************* + BalLogErrorArgs - logs an error message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BalLogErrorArgs( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + /******************************************************************* BalLogId - logs a message with the engine with a string embedded in a MESSAGETABLE resource. -- cgit v1.2.3-55-g6feb From 2ded319a01a9ec42b637a677813d394cd7eda6b9 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 19 Jul 2020 16:41:39 +1000 Subject: Update dependencies. --- nuget.config | 2 +- src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 2 +- src/balutil/balutil.vcxproj | 8 ++++---- src/balutil/packages.config | 4 ++-- src/bextutil/bextutil.vcxproj | 8 ++++---- src/bextutil/packages.config | 4 ++-- src/mbanative/mbanative.vcxproj | 8 ++++---- src/mbanative/packages.config | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/nuget.config b/nuget.config index b6266ac2..0a24a6a3 100644 --- a/nuget.config +++ b/nuget.config @@ -2,7 +2,7 @@ - + diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 00fc8548..64540de8 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index d522a2e4..72c23991 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -106,8 +106,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 52ccddb4..56f0cea3 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 17679b6d..78ff290d 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -95,8 +95,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 52ccddb4..56f0cea3 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index ef1616c3..23e38e49 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -102,7 +102,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 8b533737..9515379a 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From a37013d41f0702cbdf2aee6dce95d26dafc069b4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 1 Aug 2020 10:20:31 -0600 Subject: WIXFEAT:4763 Change "string" variable type to literal and add "formatted". --- src/WixToolset.Mba.Core/Engine.cs | 4 +-- src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 3 +- src/balutil/BalBootstrapperEngine.cpp | 4 ++- src/balutil/balutil.cpp | 5 +-- src/balutil/balutil.vcxproj | 8 ++--- src/balutil/inc/IBootstrapperEngine.h | 3 +- src/balutil/inc/balutil.h | 3 +- src/balutil/packages.config | 4 +-- src/bextutil/BextBundleExtensionEngine.cpp | 21 ++--------- src/bextutil/bextutil.cpp | 50 +++++++++++++++++++++++--- src/bextutil/bextutil.vcxproj | 8 ++--- src/bextutil/inc/IBundleExtensionEngine.h | 8 ++--- src/bextutil/inc/bextutil.h | 20 +++++++++++ src/bextutil/packages.config | 4 +-- src/mbanative/mbanative.vcxproj | 8 ++--- src/mbanative/packages.config | 4 +-- 16 files changed, 103 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index 408278ed..2c544f29 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -79,7 +79,7 @@ namespace WixToolset.Mba.Core IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); try { - this.engine.SetVariableString(name, pValue); + this.engine.SetVariableString(name, pValue, true); } finally { @@ -115,7 +115,7 @@ namespace WixToolset.Mba.Core IntPtr pValue = Marshal.StringToCoTaskMemUni(value); try { - this.engine.SetVariableString(name, pValue); + this.engine.SetVariableString(name, pValue, true); } finally { diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index d070998e..85ca8693 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -106,7 +106,8 @@ namespace WixToolset.Mba.Core void SetVariableString( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - IntPtr wzValue + IntPtr wzValue, + [MarshalAs(UnmanagedType.Bool)] bool fFormatted ); void SetVariableVersion( diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index 945940c5..6a0c66d6 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -391,7 +391,8 @@ public: // IBootstrapperEngine virtual STDMETHODIMP SetVariableString( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) { BAENGINE_SETVARIABLESTRING_ARGS args = { }; @@ -400,6 +401,7 @@ public: // IBootstrapperEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; args.wzValue = wzValue; + args.fFormatted = fFormatted; results.cbSize = sizeof(results); diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp index 7567752c..ebfaede4 100644 --- a/src/balutil/balutil.cpp +++ b/src/balutil/balutil.cpp @@ -225,7 +225,8 @@ LExit: DAPI_(HRESULT) BalSetStringVariable( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) { HRESULT hr = S_OK; @@ -236,7 +237,7 @@ DAPI_(HRESULT) BalSetStringVariable( ExitOnRootFailure(hr, "BalInitialize() must be called first."); } - hr = vpEngine->SetVariableString(wzVariable, wzValue); + hr = vpEngine->SetVariableString(wzVariable, wzValue, fFormatted); LExit: return hr; diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 72c23991..39be0bed 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -106,8 +106,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h index 3fe3d401..3b648df1 100644 --- a/src/balutil/inc/IBootstrapperEngine.h +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -89,7 +89,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(SetVariableString)( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) = 0; STDMETHOD(SetVariableVersion)( diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index e0f5874c..b718e48b 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -131,7 +131,8 @@ BalSetStringVariable - sets a string variable in the engine. ********************************************************************/ DAPI_(HRESULT) BalSetStringVariable( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ); /******************************************************************* diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 56f0cea3..e8417860 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp index 02070a6f..a78b3130 100644 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -225,23 +225,6 @@ public: // IBundleExtensionEngine return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); } - virtual STDMETHODIMP SetVariableLiteralString( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) - { - BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.wzValue = wzValue; - - results.cbSize = sizeof(results); - - return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLELITERALSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); - } - virtual STDMETHODIMP SetVariableNumeric( __in_z LPCWSTR wzVariable, __in LONGLONG llValue @@ -261,7 +244,8 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP SetVariableString( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) { BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; @@ -270,6 +254,7 @@ public: // IBundleExtensionEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; args.wzValue = wzValue; + args.fFormatted = fFormatted; results.cbSize = sizeof(results); diff --git a/src/bextutil/bextutil.cpp b/src/bextutil/bextutil.cpp index baf35591..4b22d502 100644 --- a/src/bextutil/bextutil.cpp +++ b/src/bextutil/bextutil.cpp @@ -119,6 +119,29 @@ DAPIV_(HRESULT) BextLog( { HRESULT hr = S_OK; va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BextLogArgs(level, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BextLogArgs( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; LPSTR sczFormattedAnsi = NULL; LPWSTR sczMessage = NULL; @@ -128,9 +151,7 @@ DAPIV_(HRESULT) BextLog( ExitOnRootFailure(hr, "BextInitialize() must be called first."); } - va_start(args, szFormat); hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - va_end(args); ExitOnFailure(hr, "Failed to format log string."); hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); @@ -153,6 +174,29 @@ DAPIV_(HRESULT) BextLogError( { HRESULT hr = S_OK; va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BextLogErrorArgs(hrError, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BextLogErrorArgs( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; LPSTR sczFormattedAnsi = NULL; LPWSTR sczMessage = NULL; @@ -162,9 +206,7 @@ DAPIV_(HRESULT) BextLogError( ExitOnRootFailure(hr, "BextInitialize() must be called first."); } - va_start(args, szFormat); hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - va_end(args); ExitOnFailure(hr, "Failed to format error log string."); hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 78ff290d..32518202 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -95,8 +95,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h index 869c6695..7772b016 100644 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -42,11 +42,6 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 __in_z LPCWSTR wzMessage ) = 0; - STDMETHOD(SetVariableLiteralString)( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) = 0; - STDMETHOD(SetVariableNumeric)( __in_z LPCWSTR wzVariable, __in LONGLONG llValue @@ -54,7 +49,8 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(SetVariableString)( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) = 0; STDMETHOD(SetVariableVersion)( diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h index e80d3944..ac9c0062 100644 --- a/src/bextutil/inc/bextutil.h +++ b/src/bextutil/inc/bextutil.h @@ -71,6 +71,16 @@ DAPIV_(HRESULT) BextLog( ... ); +/******************************************************************* + BextLogArgs - logs a message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BextLogArgs( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + /******************************************************************* BextLogError - logs an error message with the engine. @@ -81,6 +91,16 @@ DAPIV_(HRESULT) BextLogError( ... ); +/******************************************************************* + BextLogErrorArgs - logs an error message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BextLogErrorArgs( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + #ifdef __cplusplus } #endif diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 56f0cea3..e8417860 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 23e38e49..c2d0bded 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -102,7 +102,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 9515379a..c3c26daa 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 522458420df786eb653009d616127e1060b3ab9b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 1 Aug 2020 11:49:05 -0600 Subject: WIXFEAT:5319 Remove IVariables since they were a leaky abstraction. --- src/WixToolset.Mba.Core/Engine.cs | 290 ++++++++++++---------------------- src/WixToolset.Mba.Core/IEngine.cs | 95 +++++++---- src/WixToolset.Mba.Core/IVariables.cs | 27 ---- src/balutil/balutil.cpp | 4 +- src/balutil/inc/balutil.h | 4 +- 5 files changed, 171 insertions(+), 249 deletions(-) delete mode 100644 src/WixToolset.Mba.Core/IVariables.cs (limited to 'src') diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index 2c544f29..98427cfa 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -18,10 +18,6 @@ namespace WixToolset.Mba.Core private static readonly string normalizeVersionFormatString = "{0} must be less than or equal to " + UInt16.MaxValue; private IBootstrapperEngine engine; - private Variables numericVariables; - private Variables secureStringVariables; - private Variables stringVariables; - private Variables versionVariables; /// /// Creates a new instance of the container class. @@ -30,135 +26,6 @@ namespace WixToolset.Mba.Core internal Engine(IBootstrapperEngine engine) { this.engine = engine; - - // Wrap the calls to get and set numeric variables. - this.numericVariables = new Variables( - delegate(string name) - { - long value; - int ret = this.engine.GetVariableNumeric(name, out value); - if (NativeMethods.S_OK != ret) - { - throw new Win32Exception(ret); - } - - return value; - }, - delegate(string name, long value) - { - this.engine.SetVariableNumeric(name, value); - }, - delegate(string name) - { - long value; - int ret = this.engine.GetVariableNumeric(name, out value); - - return NativeMethods.E_NOTFOUND != ret; - } - ); - - // Wrap the calls to get and set string variables using SecureStrings. - this.secureStringVariables = new Variables( - delegate(string name) - { - var pUniString = this.getStringVariable(name, out var length); - try - { - return this.convertToSecureString(pUniString, length); - } - finally - { - if (IntPtr.Zero != pUniString) - { - Marshal.FreeCoTaskMem(pUniString); - } - } - }, - delegate(string name, SecureString value) - { - IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); - try - { - this.engine.SetVariableString(name, pValue, true); - } - finally - { - Marshal.FreeCoTaskMem(pValue); - } - }, - delegate(string name) - { - return this.containsVariable(name); - } - ); - - // Wrap the calls to get and set string variables. - this.stringVariables = new Variables( - delegate(string name) - { - int length; - IntPtr pUniString = this.getStringVariable(name, out length); - try - { - return Marshal.PtrToStringUni(pUniString, length); - } - finally - { - if (IntPtr.Zero != pUniString) - { - Marshal.FreeCoTaskMem(pUniString); - } - } - }, - delegate(string name, string value) - { - IntPtr pValue = Marshal.StringToCoTaskMemUni(value); - try - { - this.engine.SetVariableString(name, pValue, true); - } - finally - { - Marshal.FreeCoTaskMem(pValue); - } - }, - delegate(string name) - { - return this.containsVariable(name); - } - ); - - // Wrap the calls to get and set version variables. - this.versionVariables = new Variables( - delegate(string name) - { - long value; - int ret = this.engine.GetVariableVersion(name, out value); - if (NativeMethods.S_OK != ret) - { - throw new Win32Exception(ret); - } - - return LongToVersion(value); - }, - delegate(string name, Version value) - { - long version = VersionToLong(value); - this.engine.SetVariableVersion(name, version); - }, - delegate(string name) - { - long value; - int ret = this.engine.GetVariableVersion(name, out value); - - return NativeMethods.E_NOTFOUND != ret; - } - ); - } - - public IVariables NumericVariables - { - get { return this.numericVariables; } } public int PackageCount @@ -172,21 +39,6 @@ namespace WixToolset.Mba.Core } } - public IVariables SecureStringVariables - { - get { return this.secureStringVariables; } - } - - public IVariables StringVariables - { - get { return this.stringVariables; } - } - - public IVariables VersionVariables - { - get { return this.versionVariables; } - } - public void Apply(IntPtr hwndParent) { this.engine.Apply(hwndParent); @@ -197,6 +49,13 @@ namespace WixToolset.Mba.Core this.engine.CloseSplashScreen(); } + public bool ContainsVariable(string name) + { + int capacity = 0; + int ret = this.engine.GetVariableString(name, IntPtr.Zero, ref capacity); + return NativeMethods.E_NOTFOUND != ret; + } + public void Detect() { this.Detect(IntPtr.Zero); @@ -275,6 +134,61 @@ namespace WixToolset.Mba.Core return sb.ToString(); } + public long GetVariableNumeric(string name) + { + int ret = this.engine.GetVariableNumeric(name, out long value); + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return value; + } + + public SecureString GetVariableSecureString(string name) + { + var pUniString = this.getStringVariable(name, out var length); + try + { + return this.convertToSecureString(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + } + + public string GetVariableString(string name) + { + int length; + IntPtr pUniString = this.getStringVariable(name, out length); + try + { + return Marshal.PtrToStringUni(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + } + + public Version GetVariableVersion(string name) + { + int ret = this.engine.GetVariableVersion(name, out long value); + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return LongToVersion(value); + } + public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) { this.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, 0); @@ -310,6 +224,43 @@ namespace WixToolset.Mba.Core this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); } + public void SetVariable(string name, long value) + { + this.engine.SetVariableNumeric(name, value); + } + + public void SetVariable(string name, SecureString value, bool formatted) + { + IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); + try + { + this.engine.SetVariableString(name, pValue, formatted); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + } + + public void SetVariable(string name, string value, bool formatted) + { + IntPtr pValue = Marshal.StringToCoTaskMemUni(value); + try + { + this.engine.SetVariableString(name, pValue, formatted); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + } + + public void SetVariable(string name, Version value) + { + long version = VersionToLong(value); + this.engine.SetVariableVersion(name, version); + } + public int SendEmbeddedError(int errorCode, string message, int uiHint) { int result = 0; @@ -329,49 +280,6 @@ namespace WixToolset.Mba.Core this.engine.Quit(exitCode); } - internal sealed class Variables : IVariables - { - // .NET 2.0 does not support Func or Action. - internal delegate T Getter(string name); - internal delegate void Setter(string name, T value); - - private Getter getter; - private Setter setter; - private Predicate contains; - - internal Variables(Getter getter, Setter setter, Predicate contains) - { - this.getter = getter; - this.setter = setter; - this.contains = contains; - } - - public T this[string name] - { - get { return this.getter(name); } - set { this.setter(name, value); } - } - - public bool Contains(string name) - { - return this.contains(name); - } - } - - /// - /// Gets whether the variable given by exists. - /// - /// The name of the variable to check. - /// True if the variable given by exists; otherwise, false. - internal bool containsVariable(string name) - { - int capacity = 0; - IntPtr pValue = IntPtr.Zero; - int ret = this.engine.GetVariableString(name, pValue, ref capacity); - - return NativeMethods.E_NOTFOUND != ret; - } - /// /// Gets the variable given by as a string. /// diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 5ddc4176..84d93bb0 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -8,38 +8,11 @@ namespace WixToolset.Mba.Core public interface IEngine { - /// - /// Gets or sets numeric variables for the engine. - /// - IVariables NumericVariables { get; } - /// /// Gets the number of packages in the bundle. /// int PackageCount { get; } - /// - /// Gets or sets string variables for the engine using SecureStrings. - /// - IVariables SecureStringVariables { get; } - - /// - /// Gets or sets string variables for the engine. - /// - IVariables StringVariables { get; } - - /// - /// Gets or sets variables for the engine. - /// - /// The class can keep track of when the build and revision fields are undefined, but the engine can't. - /// Therefore, the build and revision fields must be defined when setting a variable. - /// Use the NormalizeVersion method to make sure the engine can accept the Version. - /// - /// To keep track of versions without build or revision fields, use StringVariables instead. - /// - /// The given was invalid. - IVariables VersionVariables { get; } - /// /// Install the packages. /// @@ -52,6 +25,13 @@ namespace WixToolset.Mba.Core /// void CloseSplashScreen(); + /// + /// Checks if a variable exists in the engine. + /// + /// The name of the variable. + /// Whether the variable exists. + bool ContainsVariable(string name); + /// /// Determine if all installation conditions are fulfilled. /// @@ -94,6 +74,30 @@ namespace WixToolset.Mba.Core /// A Win32 error occurred. string FormatString(string format); + /// + /// Gets numeric variables for the engine. + /// + /// The name of the variable. + long GetVariableNumeric(string name); + + /// + /// Gets string variables for the engine using SecureStrings. + /// + /// The name of the variable. + SecureString GetVariableSecureString(string name); + + /// + /// Gets string variables for the engine. + /// + /// The name of the variable. + string GetVariableString(string name); + + /// + /// Gets variables for the engine. + /// + /// The name of the variable. + Version GetVariableVersion(string name); + /// /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. /// @@ -152,6 +156,43 @@ namespace WixToolset.Mba.Core /// The password for proxy authentication. void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password); + /// + /// Sets numeric variables for the engine. + /// + /// The name of the variable. + /// The value to set. + void SetVariable(string name, long value); + + /// + /// Sets string variables for the engine using SecureStrings. + /// + /// The name of the variable. + /// The value to set. + /// False if the value is a literal string. + void SetVariable(string name, SecureString value, bool formatted); + + /// + /// Sets string variables for the engine. + /// + /// The name of the variable. + /// The value to set. + /// False if the value is a literal string. + void SetVariable(string name, string value, bool formatted); + + /// + /// Sets variables for the engine. + /// + /// The class can keep track of when the build and revision fields are undefined, but the engine can't. + /// Therefore, the build and revision fields must be defined when setting a variable. + /// Use the NormalizeVersion method to make sure the engine can accept the Version. + /// + /// To keep track of versions without build or revision fields, use StringVariables instead. + /// + /// The name of the variable. + /// The value to set. + /// The given was invalid. + void SetVariable(string name, Version value); + /// /// Sends error message when embedded. /// diff --git a/src/WixToolset.Mba.Core/IVariables.cs b/src/WixToolset.Mba.Core/IVariables.cs deleted file mode 100644 index c7994f0b..00000000 --- a/src/WixToolset.Mba.Core/IVariables.cs +++ /dev/null @@ -1,27 +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 WixToolset.Mba.Core -{ - using System; - - /// - /// An accessor for numeric, string, and version variables for the engine. - /// - public interface IVariables - { - /// - /// Gets or sets the variable given by . - /// - /// The name of the variable to get/set. - /// The value of the given variable. - /// An error occurred getting the variable. - T this[string name] { get; set; } - - /// - /// Gets whether the variable given by exists. - /// - /// The name of the variable to check. - /// True if the variable given by exists; otherwise, false. - bool Contains(string name); - } -} diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp index ebfaede4..faca70f5 100644 --- a/src/balutil/balutil.cpp +++ b/src/balutil/balutil.cpp @@ -167,7 +167,7 @@ LExit: } -DAPI_(BOOL) BalStringVariableExists( +DAPI_(BOOL) BalVariableExists( __in_z LPCWSTR wzVariable ) { @@ -183,7 +183,7 @@ DAPI_(BOOL) BalStringVariableExists( hr = vpEngine->GetVariableString(wzVariable, NULL, &cch); LExit: - return E_MOREDATA == hr; // string exists only if there are more than zero characters in the variable. + return E_NOTFOUND != hr; } diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index b718e48b..affa4925 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -108,10 +108,10 @@ DAPI_(HRESULT) BalSetNumericVariable( ); /******************************************************************* -BalStringVariableExists - checks if a string variable exists in the engine. +BalVariableExists - checks if a variable exists in the engine. ********************************************************************/ -DAPI_(BOOL) BalStringVariableExists( +DAPI_(BOOL) BalVariableExists( __in_z LPCWSTR wzVariable ); -- cgit v1.2.3-55-g6feb From dcf13e60f0b165a8942e7e7d98f5f0702f7d1e84 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 22 Sep 2020 21:58:43 -0400 Subject: Remove ARM32 --- appveyor.cmd | 2 -- src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 2 -- src/balutil/balutil.nuspec | 2 -- src/balutil/balutil.vcxproj | 20 ++++++-------------- src/balutil/packages.config | 2 +- src/bextutil/bextutil.nuspec | 2 -- src/bextutil/bextutil.vcxproj | 20 ++++++-------------- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 20 ++++++-------------- src/mbanative/packages.config | 2 +- 10 files changed, 21 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 34f8beb0..3b170ad4 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -9,12 +9,10 @@ msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v140 || exit /b msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 || exit /b msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v141 || exit /b -msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v141 || exit /b msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v141 || exit /b msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v142 || exit /b msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 || exit /b -msbuild -p:Configuration=%_C%;Platform=ARM;PlatformToolset=v142 || exit /b msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 || exit /b dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index 3a9f05df..cf7d014d 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -21,8 +21,6 @@ - - diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec index 60c32bb1..e38362ec 100644 --- a/src/balutil/balutil.nuspec +++ b/src/balutil/balutil.nuspec @@ -23,11 +23,9 @@ - - diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 39be0bed..8697b5ab 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -3,29 +3,21 @@ - + - - Debug - ARM - Debug ARM64 - - Debug - Win32 - - - Release - ARM - Release ARM64 + + Debug + Win32 + Release Win32 @@ -107,7 +99,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index e8417860..4db0b6a7 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/bextutil/bextutil.nuspec b/src/bextutil/bextutil.nuspec index e8a08075..752dbb97 100644 --- a/src/bextutil/bextutil.nuspec +++ b/src/bextutil/bextutil.nuspec @@ -23,11 +23,9 @@ - - diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 32518202..c27d8aee 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -3,29 +3,21 @@ - + - - Debug - ARM - Debug ARM64 - - Debug - Win32 - - - Release - ARM - Release ARM64 + + Debug + Win32 + Release Win32 @@ -96,7 +88,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index e8417860..4db0b6a7 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index c2d0bded..3fe9ef6b 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -6,29 +6,21 @@ - + - - Debug - ARM - Debug ARM64 - - Debug - Win32 - - - Release - ARM - Release ARM64 + + Debug + Win32 + Release Win32 @@ -103,6 +95,6 @@ - + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index c3c26daa..443e0094 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -5,5 +5,5 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From c9d14eb51e4b8458fd5e2738fcc7d1c1129ad22e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 18 Oct 2020 22:37:12 -0500 Subject: WIXFEAT:6210 Change data type of versions to strings. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 24 +++--- src/WixToolset.Mba.Core/Engine.cs | 86 +++++++++++++++++++--- src/WixToolset.Mba.Core/EventArgs.cs | 36 ++++----- .../IBootstrapperApplication.cs | 12 +-- src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 5 +- src/WixToolset.Mba.Core/IEngine.cs | 19 ++--- src/WixToolset.Mba.Core/PackageInfo.cs | 4 +- src/balutil/BalBootstrapperEngine.cpp | 14 ++-- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BalBaseBAFunctions.h | 12 +-- src/balutil/inc/BalBaseBootstrapperApplication.h | 12 +-- .../inc/BalBaseBootstrapperApplicationProc.h | 12 +-- src/balutil/inc/IBootstrapperApplication.h | 12 +-- src/balutil/inc/IBootstrapperEngine.h | 5 +- src/balutil/packages.config | 4 +- src/bextutil/BextBundleExtensionEngine.cpp | 14 ++-- src/bextutil/bextutil.vcxproj | 8 +- src/bextutil/inc/IBundleExtensionEngine.h | 5 +- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 8 +- src/mbanative/packages.config | 4 +- 21 files changed, 185 insertions(+), 123 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 9ee909dc..472c553a 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1130,9 +1130,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, long version, ref bool fCancel, ref bool fIgnoreBundle) + int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, ref bool fCancel, ref bool fIgnoreBundle) { - DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, version, fCancel, fIgnoreBundle); + DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fCancel, fIgnoreBundle); this.OnDetectForwardCompatibleBundle(args); fCancel = args.Cancel; @@ -1150,9 +1150,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, long dw64Version, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) + int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, string wzVersion, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) { - DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, dw64Version, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); + DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, wzVersion, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); this.OnDetectUpdate(args); fCancel = args.Cancel; @@ -1169,9 +1169,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, long version, RelatedOperation operation, ref bool fCancel) + int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) { - DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, version, operation, fCancel); + DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fCancel); this.OnDetectRelatedBundle(args); fCancel = args.Cancel; @@ -1187,18 +1187,18 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, long dw64CompatiblePackageVersion, ref bool fCancel) + int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, ref bool fCancel) { - DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, dw64CompatiblePackageVersion, fCancel); + DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, fCancel); this.OnDetectCompatibleMsiPackage(args); fCancel = args.Cancel; return args.HResult; } - int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, long version, RelatedOperation operation, ref bool fCancel) + int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) { - DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, version, operation, fCancel); + DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, wzVersion, operation, fCancel); this.OnDetectRelatedMsiPackage(args); fCancel = args.Cancel; @@ -1268,9 +1268,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, long dw64CompatiblePackageVersion, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { - PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, dw64CompatiblePackageVersion, recommendedState, pRequestedState, fCancel); + PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, recommendedState, pRequestedState, fCancel); this.OnPlanCompatibleMsiPackageBegin(args); pRequestedState = args.State; diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index 98427cfa..e3ad097a 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -178,15 +178,21 @@ namespace WixToolset.Mba.Core } } - public Version GetVariableVersion(string name) + public string GetVariableVersion(string name) { - int ret = this.engine.GetVariableVersion(name, out long value); - if (NativeMethods.S_OK != ret) + int length; + IntPtr pUniString = this.getVersionVariable(name, out length); + try { - throw new Win32Exception(ret); + return Marshal.PtrToStringUni(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } } - - return LongToVersion(value); } public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) @@ -224,12 +230,12 @@ namespace WixToolset.Mba.Core this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); } - public void SetVariable(string name, long value) + public void SetVariableNumeric(string name, long value) { this.engine.SetVariableNumeric(name, value); } - public void SetVariable(string name, SecureString value, bool formatted) + public void SetVariableString(string name, SecureString value, bool formatted) { IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); try @@ -242,7 +248,7 @@ namespace WixToolset.Mba.Core } } - public void SetVariable(string name, string value, bool formatted) + public void SetVariableString(string name, string value, bool formatted) { IntPtr pValue = Marshal.StringToCoTaskMemUni(value); try @@ -255,10 +261,17 @@ namespace WixToolset.Mba.Core } } - public void SetVariable(string name, Version value) + public void SetVariableVersion(string name, string value) { - long version = VersionToLong(value); - this.engine.SetVariableVersion(name, version); + IntPtr pValue = Marshal.StringToCoTaskMemUni(value); + try + { + this.engine.SetVariableVersion(name, pValue); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } } public int SendEmbeddedError(int errorCode, string message, int uiHint) @@ -329,6 +342,55 @@ namespace WixToolset.Mba.Core } } + /// + /// Gets the variable given by as a version string. + /// + /// The name of the variable to get. + /// The length of the Unicode string. + /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. + /// An error occurred getting the variable. + internal IntPtr getVersionVariable(string name, out int length) + { + int capacity = InitialBufferSize; + bool success = false; + IntPtr pValue = Marshal.AllocCoTaskMem(capacity * UnicodeEncoding.CharSize); + try + { + // Get the size of the buffer. + int ret = this.engine.GetVariableVersion(name, pValue, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + // Don't need to add 1 for the null terminator, the engine already includes that. + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity * UnicodeEncoding.CharSize); + ret = this.engine.GetVariableVersion(name, pValue, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw Marshal.GetExceptionForHR(ret); + } + + // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. + for (length = 0; length < capacity; ++length) + { + if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) + { + break; + } + } + + success = true; + return pValue; + } + finally + { + if (!success && IntPtr.Zero != pValue) + { + Marshal.FreeCoTaskMem(pValue); + } + } + } + /// /// Initialize a SecureString with the given Unicode string. /// diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index e739a853..71bd15e1 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -241,14 +241,14 @@ namespace WixToolset.Mba.Core /// The version of the forward compatible bundle detected. /// The cancel recommendation from the engine. /// The ignore recommendation from the engine. - public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, long version, bool cancelRecommendation, bool ignoreBundleRecommendation) + public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool cancelRecommendation, bool ignoreBundleRecommendation) : base(cancelRecommendation) { this.BundleId = bundleId; this.RelationType = relationType; this.BundleTag = bundleTag; this.PerMachine = perMachine; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.IgnoreBundle = ignoreBundleRecommendation; } @@ -275,7 +275,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the forward compatible bundle detected. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Instructs the engine whether to use the forward compatible bundle. @@ -330,12 +330,12 @@ namespace WixToolset.Mba.Core /// The content of the updated bundle. /// The recommendation from the engine. /// The recommendation from the engine. - public DetectUpdateEventArgs(string updateLocation, long size, long version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) + public DetectUpdateEventArgs(string updateLocation, long size, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) : base(cancelRecommendation) { this.UpdateLocation = updateLocation; this.Size = size; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.Title = title; this.Summary = summary; this.ContentType = contentType; @@ -356,7 +356,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the updated bundle. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Gets the title of the the updated bundle. @@ -423,14 +423,14 @@ namespace WixToolset.Mba.Core /// The version of the related bundle detected. /// The operation that will be taken on the detected bundle. /// The recommendation from the engine. - public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, long version, RelatedOperation operation, bool cancelRecommendation) + public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) : base(cancelRecommendation) { this.ProductCode = productCode; this.RelationType = relationType; this.BundleTag = bundleTag; this.PerMachine = perMachine; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.Operation = operation; } @@ -457,7 +457,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the related bundle detected. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Gets the operation that will be taken on the detected bundle. @@ -501,12 +501,12 @@ namespace WixToolset.Mba.Core /// The identity of the compatible package that was detected. /// The version of the compatible package that was detected. /// The recommendation from the engine. - public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, long compatiblePackageVersion, bool cancelRecommendation) + public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.CompatiblePackageId = compatiblePackageId; - this.CompatiblePackageVersion = Engine.LongToVersion(compatiblePackageVersion); + this.CompatiblePackageVersion = compatiblePackageVersion; } /// @@ -522,7 +522,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the compatible package that was detected. /// - public Version CompatiblePackageVersion { get; private set; } + public string CompatiblePackageVersion { get; private set; } } /// @@ -541,14 +541,14 @@ namespace WixToolset.Mba.Core /// The version of the related package detected. /// The operation that will be taken on the detected package. /// The recommendation from the engine. - public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, long version, RelatedOperation operation, bool cancelRecommendation) + public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.UpgradeCode = upgradeCode; this.ProductCode = productCode; this.PerMachine = perMachine; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.Operation = operation; } @@ -575,7 +575,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the related package detected. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Gets the operation that will be taken on the detected package. @@ -813,12 +813,12 @@ namespace WixToolset.Mba.Core /// The recommended request state for the compatible package. /// The requested state for the compatible package. /// The recommendation from the engine. - public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, long compatiblePackageVersion, RequestState recommendedState, RequestState state, bool cancelRecommendation) + public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, RequestState recommendedState, RequestState state, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.CompatiblePackageId = compatiblePackageId; - this.CompatiblePackageVersion = Engine.LongToVersion(compatiblePackageVersion); + this.CompatiblePackageVersion = compatiblePackageVersion; this.RecommendedState = recommendedState; this.State = state; } @@ -836,7 +836,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the compatible package detected. /// - public Version CompatiblePackageVersion { get; private set; } + public string CompatiblePackageVersion { get; private set; } /// /// Gets the recommended state to use for the compatible package for planning. diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index fa655282..0d79122d 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -45,7 +45,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] RelationType relationType, [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle ); @@ -63,7 +63,7 @@ namespace WixToolset.Mba.Core int OnDetectUpdate( [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, [MarshalAs(UnmanagedType.U8)] long dw64Size, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.LPWStr)] string wzTitle, [MarshalAs(UnmanagedType.LPWStr)] string wzSummary, [MarshalAs(UnmanagedType.LPWStr)] string wzContentType, @@ -86,7 +86,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] RelationType relationType, [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -103,7 +103,7 @@ namespace WixToolset.Mba.Core int OnDetectCompatibleMsiPackage( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - [MarshalAs(UnmanagedType.U8)] long dw64CompatiblePackageVersion, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -114,7 +114,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzUpgradeCode, [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -181,7 +181,7 @@ namespace WixToolset.Mba.Core int OnPlanCompatibleMsiPackageBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - [MarshalAs(UnmanagedType.U8)] long dw64CompatiblePackageVersion, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index 85ca8693..584e0f6d 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -36,7 +36,8 @@ namespace WixToolset.Mba.Core [PreserveSig] int GetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - [MarshalAs(UnmanagedType.U8)] out long pqwValue + IntPtr wzValue, + [MarshalAs(UnmanagedType.U4)] ref int pcchValue ); [PreserveSig] @@ -112,7 +113,7 @@ namespace WixToolset.Mba.Core void SetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - [MarshalAs(UnmanagedType.U8)] long qwValue + IntPtr wzValue ); void CloseSplashScreen(); diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 84d93bb0..b486e51d 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -96,7 +96,7 @@ namespace WixToolset.Mba.Core /// Gets variables for the engine. /// /// The name of the variable. - Version GetVariableVersion(string name); + string GetVariableVersion(string name); /// /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. @@ -161,7 +161,7 @@ namespace WixToolset.Mba.Core /// /// The name of the variable. /// The value to set. - void SetVariable(string name, long value); + void SetVariableNumeric(string name, long value); /// /// Sets string variables for the engine using SecureStrings. @@ -169,7 +169,7 @@ namespace WixToolset.Mba.Core /// The name of the variable. /// The value to set. /// False if the value is a literal string. - void SetVariable(string name, SecureString value, bool formatted); + void SetVariableString(string name, SecureString value, bool formatted); /// /// Sets string variables for the engine. @@ -177,21 +177,14 @@ namespace WixToolset.Mba.Core /// The name of the variable. /// The value to set. /// False if the value is a literal string. - void SetVariable(string name, string value, bool formatted); + void SetVariableString(string name, string value, bool formatted); /// - /// Sets variables for the engine. - /// - /// The class can keep track of when the build and revision fields are undefined, but the engine can't. - /// Therefore, the build and revision fields must be defined when setting a variable. - /// Use the NormalizeVersion method to make sure the engine can accept the Version. - /// - /// To keep track of versions without build or revision fields, use StringVariables instead. + /// Sets version variables for the engine. /// /// The name of the variable. /// The value to set. - /// The given was invalid. - void SetVariable(string name, Version value); + void SetVariableVersion(string name, string value); /// /// Sends error message when embedded. diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index d3199c08..d54438f5 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -159,11 +159,11 @@ namespace WixToolset.Mba.Core } } - public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) + public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, string version) { PackageInfo package = new PackageInfo(); package.Id = id; - package.Version = version.ToString(); + package.Version = version; switch (relationType) { diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index 6a0c66d6..b68ea7c2 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -133,26 +133,28 @@ public: // IBootstrapperEngine virtual STDMETHODIMP GetVariableVersion( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) { HRESULT hr = S_OK; BAENGINE_GETVARIABLEVERSION_ARGS args = { }; BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; - ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required"); + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); args.cbSize = sizeof(args); args.wzVariable = wzVariable; results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); - *pqwValue = results.qwValue; + *pcchValue = results.cchValue; LExit: - SecureZeroMemory(&results, sizeof(results)); return hr; } @@ -410,7 +412,7 @@ public: // IBootstrapperEngine virtual STDMETHODIMP SetVariableVersion( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) { BAENGINE_SETVARIABLEVERSION_ARGS args = { }; @@ -418,7 +420,7 @@ public: // IBootstrapperEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; - args.qwValue = qwValue; + args.wzValue = wzValue; results.cbSize = sizeof(results); diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 8697b5ab..7373040a 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 4e095fb8..72edadd5 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -103,7 +103,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __inout BOOL* /*pfCancel*/, __inout BOOL* /*pfIgnoreBundle*/ ) @@ -123,7 +123,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectUpdate( __in_z LPCWSTR /*wzUpdateLocation*/, __in DWORD64 /*dw64Size*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in_z LPCWSTR /*wzTitle*/, __in_z LPCWSTR /*wzSummary*/, __in_z LPCWSTR /*wzContentType*/, @@ -148,7 +148,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* /*pfCancel*/ ) @@ -167,7 +167,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectCompatibleMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __inout BOOL* /*pfCancel*/ ) { @@ -179,7 +179,7 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzUpgradeCode*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* /*pfCancel*/ ) @@ -254,7 +254,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, __inout BOOL* /*pfCancel*/ diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 1d014419..612faf54 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -101,7 +101,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __inout BOOL* pfCancel, __inout BOOL* /*pfIgnoreBundle*/ ) @@ -123,7 +123,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectUpdate( __in_z LPCWSTR /*wzUpdateLocation*/, __in DWORD64 /*dw64Size*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in_z LPCWSTR /*wzTitle*/, __in_z LPCWSTR /*wzSummary*/, __in_z LPCWSTR /*wzContentType*/, @@ -149,7 +149,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* pfCancel ) @@ -170,7 +170,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectCompatibleMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __inout BOOL* pfCancel ) { @@ -183,7 +183,7 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzUpgradeCode*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* pfCancel ) @@ -264,7 +264,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, __inout BOOL* pfCancel diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index d25af1f7..7d5de8e4 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -78,7 +78,7 @@ static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, &pResults->fCancel, &pResults->fIgnoreBundle); + return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, &pResults->fCancel, &pResults->fIgnoreBundle); } static HRESULT BalBaseBAProcOnDetectUpdateBegin( @@ -96,7 +96,7 @@ static HRESULT BalBaseBAProcOnDetectUpdate( __inout BA_ONDETECTUPDATE_RESULTS* pResults ) { - return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->dw64Version, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); + return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->wzVersion, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); } static HRESULT BalBaseBAProcOnDetectUpdateComplete( @@ -114,7 +114,7 @@ static HRESULT BalBaseBAProcOnDetectRelatedBundle( __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, pArgs->operation, &pResults->fCancel); + return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectPackageBegin( @@ -132,7 +132,7 @@ static HRESULT BalBaseBAProcOnDetectCompatiblePackage( __inout BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS* pResults ) { - return pBA->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->dw64CompatiblePackageVersion, &pResults->fCancel); + return pBA->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage( @@ -141,7 +141,7 @@ static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage( __inout BA_ONDETECTRELATEDMSIPACKAGE_RESULTS* pResults ) { - return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->dw64Version, pArgs->operation, &pResults->fCancel); + return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectTargetMsiPackage( @@ -195,7 +195,7 @@ static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageBegin( __inout BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS* pResults ) { - return pBA->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->dw64CompatiblePackageVersion, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); + return pBA->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); } static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageComplete( diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index e17d2589..9cc19120 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -32,7 +32,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in BOOTSTRAPPER_RELATION_TYPE relationType, __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __inout BOOL* pfCancel, __inout BOOL* pfIgnoreBundle ) = 0; @@ -48,7 +48,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnDetectUpdate)( __in_z_opt LPCWSTR wzUpdateLocation, __in DWORD64 dw64Size, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __in_z_opt LPCWSTR wzTitle, __in_z_opt LPCWSTR wzSummary, __in_z_opt LPCWSTR wzContentType, @@ -69,7 +69,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in BOOTSTRAPPER_RELATION_TYPE relationType, __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __in BOOTSTRAPPER_RELATED_OPERATION operation, __inout BOOL* pfCancel ) = 0; @@ -84,7 +84,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnDetectCompatibleMsiPackage)( __in_z LPCWSTR wzPackageId, __in_z LPCWSTR wzCompatiblePackageId, - __in DWORD64 dw64CompatiblePackageVersion, + __in_z LPCWSTR wzCompatiblePackageVersion, __inout BOOL* pfCancel ) = 0; @@ -94,7 +94,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in_z LPCWSTR wzUpgradeCode, __in_z LPCWSTR wzProductCode, __in BOOL fPerMachine, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __in BOOTSTRAPPER_RELATED_OPERATION operation, __inout BOOL* pfCancel ) = 0; @@ -156,7 +156,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnPlanCompatibleMsiPackageBegin)( __in_z LPCWSTR wzPackageId, __in_z LPCWSTR wzCompatiblePackageId, - __in DWORD64 dw64CompatiblePackageVersion, + __in_z LPCWSTR wzCompatiblePackageVersion, __in BOOTSTRAPPER_REQUEST_STATE recommendedState, __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, __inout BOOL* pfCancel diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h index 3b648df1..cf055102 100644 --- a/src/balutil/inc/IBootstrapperEngine.h +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -21,7 +21,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(GetVariableVersion)( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) = 0; STDMETHOD(FormatString)( @@ -95,7 +96,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(SetVariableVersion)( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) = 0; STDMETHOD(CloseSplashScreen)() = 0; diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 4db0b6a7..be1bf8e2 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp index a78b3130..983782a9 100644 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -185,26 +185,28 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP GetVariableVersion( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) { HRESULT hr = S_OK; BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS args = { }; BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS results = { }; - ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required"); + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); args.cbSize = sizeof(args); args.wzVariable = wzVariable; results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); - *pqwValue = results.qwValue; + *pcchValue = results.cchValue; LExit: - SecureZeroMemory(&results, sizeof(results)); return hr; } @@ -263,7 +265,7 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP SetVariableVersion( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) { BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS args = { }; @@ -271,7 +273,7 @@ public: // IBundleExtensionEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; - args.qwValue = qwValue; + args.wzValue = wzValue; results.cbSize = sizeof(results); diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index c27d8aee..00478a6e 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h index 7772b016..77ea2770 100644 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -34,7 +34,8 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(GetVariableVersion)( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) = 0; STDMETHOD(Log)( @@ -55,6 +56,6 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(SetVariableVersion)( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) = 0; }; diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 4db0b6a7..be1bf8e2 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 3fe9ef6b..3e1de28f 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -94,7 +94,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 443e0094..3faa75d5 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 1b6a4f9b4600079e829d5884f768563ed7dea5e5 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 18 Oct 2020 22:38:21 -0500 Subject: Add CompareVersions engine method and expose verutil in Mba.Core. --- src/WixToolset.Mba.Core/Engine.cs | 6 + src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 6 + src/WixToolset.Mba.Core/IEngine.cs | 3 + src/WixToolset.Mba.Core/VerUtil.cs | 126 +++++++++++++++++++++ src/WixToolset.Mba.Core/VerUtilVersion.cs | 63 +++++++++++ .../VerUtilVersionReleaseLabel.cs | 22 ++++ src/balutil/BalBootstrapperEngine.cpp | 26 +++++ src/balutil/inc/IBootstrapperApplication.h | 2 +- src/balutil/inc/IBootstrapperEngine.h | 6 + src/bextutil/BextBundleExtensionEngine.cpp | 26 +++++ src/bextutil/inc/IBundleExtensionEngine.h | 6 + src/mbanative/mbanative.def | 6 + src/mbanative/precomp.h | 1 + .../BaseBootstrapperApplicationFactoryFixture.cs | 2 +- src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs | 93 +++++++++++++++ 15 files changed, 392 insertions(+), 2 deletions(-) create mode 100644 src/WixToolset.Mba.Core/VerUtil.cs create mode 100644 src/WixToolset.Mba.Core/VerUtilVersion.cs create mode 100644 src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs create mode 100644 src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs (limited to 'src') diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index e3ad097a..c6570f9d 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -49,6 +49,12 @@ namespace WixToolset.Mba.Core this.engine.CloseSplashScreen(); } + public int CompareVersions(string version1, string version2) + { + this.engine.CompareVersions(version1, version2, out var result); + return result; + } + public bool ContainsVariable(string name) { int capacity = 0; diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index 584e0f6d..5cc42071 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -145,6 +145,12 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzArguments, [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout ); + + void CompareVersions( + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, + [MarshalAs(UnmanagedType.I4)] out int pnResult + ); } /// diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index b486e51d..8403352d 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -25,6 +25,9 @@ namespace WixToolset.Mba.Core /// void CloseSplashScreen(); + /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 + int CompareVersions(string version1, string version2); + /// /// Checks if a variable exists in the engine. /// diff --git a/src/WixToolset.Mba.Core/VerUtil.cs b/src/WixToolset.Mba.Core/VerUtil.cs new file mode 100644 index 00000000..dcc9dee2 --- /dev/null +++ b/src/WixToolset.Mba.Core/VerUtil.cs @@ -0,0 +1,126 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + using System.Text; + + public static class VerUtil + { + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern int VerCompareParsedVersions( + VersionHandle pVersion1, + VersionHandle pVersion2 + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern int VerCompareStringVersions( + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, + [MarshalAs(UnmanagedType.Bool)] bool fStrict + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern VersionHandle VerCopyVersion( + VersionHandle pSource + ); + + [DllImport("mbanative.dll", ExactSpelling = true)] + internal static extern void VerFreeVersion( + IntPtr pVersion + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern VersionHandle VerParseVersion( + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.U4)] uint cchValue, + [MarshalAs(UnmanagedType.Bool)] bool fStrict + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern VersionHandle VerVersionFromQword( + [MarshalAs(UnmanagedType.I8)] long qwVersion + ); + + [StructLayout(LayoutKind.Sequential)] + internal struct VersionReleaseLabelStruct + { + public bool fNumeric; + public uint dwValue; + public IntPtr cchLabelOffset; + public int cchLabel; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct VersionStruct + { + public IntPtr sczVersion; + public uint dwMajor; + public uint dwMinor; + public uint dwPatch; + public uint dwRevision; + public int cReleaseLabels; + public IntPtr rgReleaseLabels; + public IntPtr cchMetadataOffset; + public bool fInvalid; + } + + internal static string VersionStringFromOffset(IntPtr wzVersion, IntPtr cchOffset, int? cchLength = null) + { + var offset = cchOffset.ToInt64() * UnicodeEncoding.CharSize; + var wz = new IntPtr(wzVersion.ToInt64() + offset); + if (cchLength.HasValue) + { + return Marshal.PtrToStringUni(wz, (int)cchLength); + } + else + { + return Marshal.PtrToStringUni(wz); + } + } + + internal sealed class VersionHandle : SafeHandle + { + public VersionHandle() : base(IntPtr.Zero, true) { } + + public override bool IsInvalid => false; + + protected override bool ReleaseHandle() + { + VerFreeVersion(this.handle); + return true; + } + } + + /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 + public static int CompareParsedVersions(VerUtilVersion version1, VerUtilVersion version2) + { + return VerCompareParsedVersions(version1.GetHandle(), version2.GetHandle()); + } + + /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 + public static int CompareStringVersions(string version1, string version2, bool strict) + { + return VerCompareStringVersions(version1, version2, strict); + } + + public static VerUtilVersion CopyVersion(VerUtilVersion version) + { + var handle = VerCopyVersion(version.GetHandle()); + return new VerUtilVersion(handle); + } + + public static VerUtilVersion ParseVersion(string version, bool strict) + { + var handle = VerParseVersion(version, 0, strict); + return new VerUtilVersion(handle); + } + + public static VerUtilVersion VersionFromQword(long version) + { + var handle = VerVersionFromQword(version); + return new VerUtilVersion(handle); + } + } +} diff --git a/src/WixToolset.Mba.Core/VerUtilVersion.cs b/src/WixToolset.Mba.Core/VerUtilVersion.cs new file mode 100644 index 00000000..2b509a21 --- /dev/null +++ b/src/WixToolset.Mba.Core/VerUtilVersion.cs @@ -0,0 +1,63 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + public sealed class VerUtilVersion : IDisposable + { + internal VerUtilVersion(VerUtil.VersionHandle handle) + { + this.Handle = handle; + + var pVersion = handle.DangerousGetHandle(); + var version = (VerUtil.VersionStruct)Marshal.PtrToStructure(pVersion, typeof(VerUtil.VersionStruct)); + this.Version = Marshal.PtrToStringUni(version.sczVersion); + this.Major = version.dwMajor; + this.Minor = version.dwMinor; + this.Patch = version.dwPatch; + this.Revision = version.dwRevision; + this.ReleaseLabels = new VerUtilVersionReleaseLabel[version.cReleaseLabels]; + this.Metadata = VerUtil.VersionStringFromOffset(version.sczVersion, version.cchMetadataOffset); + this.IsInvalid = version.fInvalid; + + for (var i = 0; i < version.cReleaseLabels; ++i) + { + var offset = i * Marshal.SizeOf(typeof(VerUtil.VersionReleaseLabelStruct)); + var pReleaseLabel = new IntPtr(version.rgReleaseLabels.ToInt64() + offset); + this.ReleaseLabels[i] = new VerUtilVersionReleaseLabel(pReleaseLabel, version.sczVersion); + } + } + + public string Version { get; private set; } + public uint Major { get; private set; } + public uint Minor { get; private set; } + public uint Patch { get; private set; } + public uint Revision { get; private set; } + public VerUtilVersionReleaseLabel[] ReleaseLabels { get; private set; } + public string Metadata { get; private set; } + public bool IsInvalid { get; private set; } + + public void Dispose() + { + if (this.Handle != null) + { + this.Handle.Dispose(); + this.Handle = null; + } + } + + private VerUtil.VersionHandle Handle { get; set; } + + internal VerUtil.VersionHandle GetHandle() + { + if (this.Handle == null) + { + throw new ObjectDisposedException(this.Version); + } + + return this.Handle; + } + } +} diff --git a/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs b/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs new file mode 100644 index 00000000..84ff3b36 --- /dev/null +++ b/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs @@ -0,0 +1,22 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + public sealed class VerUtilVersionReleaseLabel + { + internal VerUtilVersionReleaseLabel(IntPtr pReleaseLabel, IntPtr wzVersion) + { + var releaseLabel = (VerUtil.VersionReleaseLabelStruct)Marshal.PtrToStructure(pReleaseLabel, typeof(VerUtil.VersionReleaseLabelStruct)); + this.IsNumeric = releaseLabel.fNumeric; + this.Value = releaseLabel.dwValue; + this.Label = VerUtil.VersionStringFromOffset(wzVersion, releaseLabel.cchLabelOffset, releaseLabel.cchLabel); + } + + public bool IsNumeric { get; private set; } + public uint Value { get; private set; } + public string Label { get; private set; } + } +} diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index b68ea7c2..8a78b127 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -535,6 +535,32 @@ public: // IBootstrapperEngine return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); } + virtual STDMETHODIMP CompareVersions( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BAENGINE_COMPAREVERSIONS_ARGS args = { }; + BAENGINE_COMPAREVERSIONS_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.wzVersion1 = wzVersion1; + args.wzVersion2 = wzVersion2; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBAEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + public: // IMarshal virtual STDMETHODIMP GetUnmarshalClass( __in REFIID /*riid*/, diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 9cc19120..75ea7bc9 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -396,7 +396,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnExecuteBegin - called when the engine begins executing a package. + // OnExecutePackageBegin - called when the engine begins executing a package. // STDMETHOD(OnExecutePackageBegin)( __in_z LPCWSTR wzPackageId, diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h index cf055102..cd89a9f0 100644 --- a/src/balutil/inc/IBootstrapperEngine.h +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -127,4 +127,10 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 __in_z_opt LPCWSTR wzArguments, __in DWORD dwWaitForInputIdleTimeout ) = 0; + + STDMETHOD(CompareVersions)( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) = 0; }; diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp index 983782a9..9906a7f5 100644 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -280,6 +280,32 @@ public: // IBundleExtensionEngine return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); } + virtual STDMETHODIMP CompareVersions( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.wzVersion1 = wzVersion1; + args.wzVersion2 = wzVersion2; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + public: CBextBundleExtensionEngine( __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h index 77ea2770..a96e3812 100644 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -58,4 +58,10 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 __in_z LPCWSTR wzVariable, __in_z_opt LPCWSTR wzValue ) = 0; + + STDMETHOD(CompareVersions)( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) = 0; }; diff --git a/src/mbanative/mbanative.def b/src/mbanative/mbanative.def index bd366ac7..28e923b6 100644 --- a/src/mbanative/mbanative.def +++ b/src/mbanative/mbanative.def @@ -4,3 +4,9 @@ EXPORTS InitializeFromCreateArgs StoreBAInCreateResults + VerCompareParsedVersions + VerCompareStringVersions + VerCopyVersion + VerFreeVersion + VerParseVersion + VerVersionFromQword diff --git a/src/mbanative/precomp.h b/src/mbanative/precomp.h index d19b4695..2e2f3ff8 100644 --- a/src/mbanative/precomp.h +++ b/src/mbanative/precomp.h @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs index 12483ddf..7fe0a405 100644 --- a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs +++ b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs @@ -1,6 +1,6 @@ // 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.Util +namespace WixToolsetTest.Mba.Core { using System; using System.Runtime.InteropServices; diff --git a/src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs b/src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs new file mode 100644 index 00000000..44142e3d --- /dev/null +++ b/src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs @@ -0,0 +1,93 @@ +// 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 WixToolset.Mba.Core; + using Xunit; + + public class VerUtilFixture + { + [Fact] + public void CanCompareStringVersions() + { + var version1 = "1.2.3.4+abcd"; + var version2 = "1.2.3.4+zyxw"; + + Assert.Equal(0, VerUtil.CompareStringVersions(version1, version2, strict: false)); + } + + [Fact] + public void CanCopyVersion() + { + var version = "1.2.3.4-5.6.7.8.9.0"; + + VerUtilVersion copiedVersion = null; + try + { + using (var parsedVersion = VerUtil.ParseVersion(version, strict: true)) + { + copiedVersion = VerUtil.CopyVersion(parsedVersion); + } + + using (var secondVersion = VerUtil.ParseVersion(version, strict: true)) + { + Assert.Equal(0, VerUtil.CompareParsedVersions(copiedVersion, secondVersion)); + } + } + finally + { + copiedVersion?.Dispose(); + } + } + + [Fact] + public void CanCreateFromQword() + { + var version = new Version(100, 200, 300, 400); + var qwVersion = Engine.VersionToLong(version); + + using var parsedVersion = VerUtil.VersionFromQword(qwVersion); + Assert.Equal("100.200.300.400", parsedVersion.Version); + Assert.Equal(100u, parsedVersion.Major); + Assert.Equal(200u, parsedVersion.Minor); + Assert.Equal(300u, parsedVersion.Patch); + Assert.Equal(400u, parsedVersion.Revision); + Assert.Empty(parsedVersion.ReleaseLabels); + Assert.Equal("", parsedVersion.Metadata); + Assert.False(parsedVersion.IsInvalid); + } + + [Fact] + public void CanParseVersion() + { + var version = "1.2.3.4-a.b.c.d.5.+abc123"; + + using var parsedVersion = VerUtil.ParseVersion(version, strict: false); + Assert.Equal(version, parsedVersion.Version); + Assert.Equal(1u, parsedVersion.Major); + Assert.Equal(2u, parsedVersion.Minor); + Assert.Equal(3u, parsedVersion.Patch); + Assert.Equal(4u, parsedVersion.Revision); + Assert.Equal(5, parsedVersion.ReleaseLabels.Length); + Assert.Equal("+abc123", parsedVersion.Metadata); + Assert.True(parsedVersion.IsInvalid); + + Assert.Equal("a", parsedVersion.ReleaseLabels[0].Label); + Assert.False(parsedVersion.ReleaseLabels[0].IsNumeric); + + Assert.Equal("b", parsedVersion.ReleaseLabels[1].Label); + Assert.False(parsedVersion.ReleaseLabels[1].IsNumeric); + + Assert.Equal("c", parsedVersion.ReleaseLabels[2].Label); + Assert.False(parsedVersion.ReleaseLabels[2].IsNumeric); + + Assert.Equal("d", parsedVersion.ReleaseLabels[3].Label); + Assert.False(parsedVersion.ReleaseLabels[3].IsNumeric); + + Assert.Equal("5", parsedVersion.ReleaseLabels[4].Label); + Assert.True(parsedVersion.ReleaseLabels[4].IsNumeric); + Assert.Equal(5u, parsedVersion.ReleaseLabels[4].Value); + } + } +} -- cgit v1.2.3-55-g6feb From 02fa915bdabd6a25ef2e66ffdabd91e6c271211b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 18 Oct 2020 22:38:42 -0500 Subject: Upgrade Nerdbank.GitVersioning. --- src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 3 ++- src/balutil/balutil.vcxproj | 4 ++-- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 ++-- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 64540de8..2ca3d2d9 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -10,6 +10,7 @@ Managed Bootstrapper Application Core $(MSBuildThisFileName).nuspec true + false @@ -18,7 +19,7 @@ - + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 7373040a..2d6d3c78 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -43,7 +43,7 @@ - + @@ -100,6 +100,6 @@ - + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index be1bf8e2..8eafbc78 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 00478a6e..76963e58 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -43,7 +43,7 @@ - + @@ -89,6 +89,6 @@ - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index be1bf8e2..8eafbc78 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 3e1de28f..a557e2f1 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -53,7 +53,7 @@ - + @@ -93,7 +93,7 @@ - + diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 3faa75d5..92e1126a 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -3,7 +3,7 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 00b7b3d04c8f4293411473c17dd464a37354b383 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 24 Oct 2020 20:12:54 -0500 Subject: Update dependencies. --- src/balutil/balutil.vcxproj | 4 ++-- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 ++-- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 2d6d3c78..d35a7a77 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -98,7 +98,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 8eafbc78..dbc4eb18 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 76963e58..def0dd59 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -87,7 +87,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 8eafbc78..dbc4eb18 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index a557e2f1..69309f8a 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,7 +5,7 @@ - + @@ -94,7 +94,7 @@ - + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 92e1126a..20047373 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From e08c0fc700edd3fe31d3a3778c26cac9f0304de4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 31 Oct 2020 19:21:19 -0500 Subject: Strong-name sign WiX assemblies. --- src/CSharp.Build.props | 11 +++++++++++ src/Directory.Build.props | 1 + src/wix.snk | Bin 0 -> 596 bytes 3 files changed, 12 insertions(+) create mode 100644 src/CSharp.Build.props create mode 100644 src/wix.snk (limited to 'src') diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a22f4470..f83cc154 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -22,6 +22,7 @@ WiX Toolset + diff --git a/src/wix.snk b/src/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/wix.snk differ -- cgit v1.2.3-55-g6feb From 27766738dc62ec95f89af347eebb1723a5943848 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 2 Dec 2020 20:11:21 -0600 Subject: Add test projects for balutil and bextutil. For now, they only have test implementations to check for compile errors in header only code. --- balutil.sln | 24 +++++++ nuget.config | 1 + src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 73 ++++++++++++++++++++++ .../BalUtilUnitTest.vcxproj.filters | 33 ++++++++++ src/test/BalUtilUnitTest/TestBAFunctions.cpp | 41 ++++++++++++ .../TestBootstrapperApplication.cpp | 39 ++++++++++++ src/test/BalUtilUnitTest/packages.config | 15 +++++ src/test/BalUtilUnitTest/precomp.cpp | 3 + src/test/BalUtilUnitTest/precomp.h | 23 +++++++ src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 72 +++++++++++++++++++++ .../BextUtilUnitTest.vcxproj.filters | 30 +++++++++ src/test/BextUtilUnitTest/TestBundleExtension.cpp | 42 +++++++++++++ src/test/BextUtilUnitTest/packages.config | 15 +++++ src/test/BextUtilUnitTest/precomp.cpp | 3 + src/test/BextUtilUnitTest/precomp.h | 19 ++++++ 15 files changed, 433 insertions(+) create mode 100644 src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj create mode 100644 src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters create mode 100644 src/test/BalUtilUnitTest/TestBAFunctions.cpp create mode 100644 src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp create mode 100644 src/test/BalUtilUnitTest/packages.config create mode 100644 src/test/BalUtilUnitTest/precomp.cpp create mode 100644 src/test/BalUtilUnitTest/precomp.h create mode 100644 src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj create mode 100644 src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters create mode 100644 src/test/BextUtilUnitTest/TestBundleExtension.cpp create mode 100644 src/test/BextUtilUnitTest/packages.config create mode 100644 src/test/BextUtilUnitTest/precomp.cpp create mode 100644 src/test/BextUtilUnitTest/precomp.h (limited to 'src') diff --git a/balutil.sln b/balutil.sln index 9bca316a..5d1923e1 100644 --- a/balutil.sln +++ b/balutil.sln @@ -13,6 +13,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbanative", "src\mbanative\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Mba.Core", "src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj", "{F54997F7-10D7-409B-B9F2-DB546490EDC0}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BalUtilUnitTest", "src\test\BalUtilUnitTest\BalUtilUnitTest.vcxproj", "{9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BextUtilUnitTest", "src\test\BextUtilUnitTest\BextUtilUnitTest.vcxproj", "{B69E6422-49B0-4E28-92F9-B8A7410A6ED9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -105,6 +109,26 @@ Global {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.Build.0 = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.ActiveCfg = Release|Any CPU {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.Build.0 = Release|Any CPU + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|ARM.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|ARM64.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x64.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x86.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x86.Build.0 = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|ARM.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|ARM64.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x64.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x86.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x86.Build.0 = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|ARM.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|ARM64.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x64.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x86.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x86.Build.0 = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|ARM.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|ARM64.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x64.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x86.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/nuget.config b/nuget.config index 0a24a6a3..2c6c5608 100644 --- a/nuget.config +++ b/nuget.config @@ -2,6 +2,7 @@ + diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj new file mode 100644 index 00000000..53d14cd7 --- /dev/null +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -0,0 +1,73 @@ + + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631} + UnitTest + ManagedCProj + DynamicLibrary + Unicode + true + + + + + ..\..\balutil\inc + comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib + + + + Create + + 4564;4691 + + + + + + + + + + + + + + + ..\..\..\packages\WixBuildTools.TestSupport.4.0.47\lib\net472\WixBuildTools.TestSupport.dll + + + ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.47\lib\net472\WixBuildTools.TestSupport.Native.dll + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters new file mode 100644 index 00000000..85f31076 --- /dev/null +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/TestBAFunctions.cpp b/src/test/BalUtilUnitTest/TestBAFunctions.cpp new file mode 100644 index 00000000..927a8d10 --- /dev/null +++ b/src/test/BalUtilUnitTest/TestBAFunctions.cpp @@ -0,0 +1,41 @@ +// 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 "BalBaseBAFunctions.h" +#include "BalBaseBAFunctionsProc.h" + +class CTestBAFunctions : public CBalBaseBAFunctions +{ +public: + CTestBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs + ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) + { + } +}; + +HRESULT CreateBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __in BA_FUNCTIONS_CREATE_RESULTS* pResults, + __out IBAFunctions** ppApplication + ) +{ + HRESULT hr = S_OK; + CTestBAFunctions* pApplication = NULL; + + pApplication = new CTestBAFunctions(hModule, pEngine, pArgs); + ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object."); + + pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; + pResults->pvBAFunctionsProcContext = pApplication; + *ppApplication = pApplication; + pApplication = NULL; + +LExit: + ReleaseObject(pApplication); + return hr; +} diff --git a/src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp b/src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp new file mode 100644 index 00000000..13d22e72 --- /dev/null +++ b/src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp @@ -0,0 +1,39 @@ +// 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 "BalBaseBootstrapperApplication.h" +#include "BalBaseBootstrapperApplicationProc.h" + +class CTestBootstrapperApplication : public CBalBaseBootstrapperApplication +{ +public: + CTestBootstrapperApplication( + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs + ) : CBalBaseBootstrapperApplication(pEngine, pArgs) + { + } +}; + +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, pArgs); + ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bootstrapper application object."); + + pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; + pResults->pvBootstrapperApplicationProcContext = pApplication; + *ppApplication = pApplication; + pApplication = NULL; + +LExit: + ReleaseObject(pApplication); + return hr; +} diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config new file mode 100644 index 00000000..b8423837 --- /dev/null +++ b/src/test/BalUtilUnitTest/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/precomp.cpp b/src/test/BalUtilUnitTest/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/test/BalUtilUnitTest/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/test/BalUtilUnitTest/precomp.h b/src/test/BalUtilUnitTest/precomp.h new file mode 100644 index 00000000..a84391f9 --- /dev/null +++ b/src/test/BalUtilUnitTest/precomp.h @@ -0,0 +1,23 @@ +#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 + +#include +#include +#include + +#include +#include + +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" +#include "balutil.h" +#include "balretry.h" +#include "BAFunctions.h" + +#pragma managed +#include diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj new file mode 100644 index 00000000..15a1f51d --- /dev/null +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -0,0 +1,72 @@ + + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9} + UnitTest + ManagedCProj + DynamicLibrary + Unicode + true + + + + + ..\..\bextutil\inc + + + + + Create + + 4564;4691 + + + + + + + + + + + + + + ..\..\..\packages\WixBuildTools.TestSupport.4.0.47\lib\net472\WixBuildTools.TestSupport.dll + + + ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.47\lib\net472\WixBuildTools.TestSupport.Native.dll + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters new file mode 100644 index 00000000..f1711f81 --- /dev/null +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/TestBundleExtension.cpp b/src/test/BextUtilUnitTest/TestBundleExtension.cpp new file mode 100644 index 00000000..921303bb --- /dev/null +++ b/src/test/BextUtilUnitTest/TestBundleExtension.cpp @@ -0,0 +1,42 @@ +// 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 "BextBaseBundleExtension.h" +#include "BextBaseBundleExtensionProc.h" + +class CTestBundleExtension : public CBextBaseBundleExtension +{ +public: + CTestBundleExtension( + __in IBundleExtensionEngine* pEngine + ) : CBextBaseBundleExtension(pEngine) + { + } +}; + +HRESULT TestBundleExtensionCreate( + __in IBundleExtensionEngine* pEngine, + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults, + __out IBundleExtension** ppBundleExtension + ) +{ + HRESULT hr = S_OK; + CTestBundleExtension* pExtension = NULL; + + pExtension = new CTestBundleExtension(pEngine); + ExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CTestBundleExtension."); + + hr = pExtension->Initialize(pArgs); + ExitOnFailure(hr, "CTestBundleExtension initialization failed"); + + pResults->pfnBundleExtensionProc = BextBaseBundleExtensionProc; + pResults->pvBundleExtensionProcContext = pExtension; + + *ppBundleExtension = pExtension; + pExtension = NULL; + +LExit: + ReleaseObject(pExtension); + return hr; +} diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config new file mode 100644 index 00000000..b8423837 --- /dev/null +++ b/src/test/BextUtilUnitTest/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/precomp.cpp b/src/test/BextUtilUnitTest/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/test/BextUtilUnitTest/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/test/BextUtilUnitTest/precomp.h b/src/test/BextUtilUnitTest/precomp.h new file mode 100644 index 00000000..a6586f70 --- /dev/null +++ b/src/test/BextUtilUnitTest/precomp.h @@ -0,0 +1,19 @@ +#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 +#include + +#include +#include + +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" +#include "bextutil.h" + +#pragma managed +#include -- cgit v1.2.3-55-g6feb From fa97c540035df80723a60e870f90bbeeab02bb3b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 2 Dec 2020 20:19:27 -0600 Subject: Ignore C26812 warning for C style enums. --- src/Cpp.Build.props | 8 ++++++++ src/CustomizedNativeRecommendedRules.ruleset | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/CustomizedNativeRecommendedRules.ruleset (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 44a042c7..4d2da36f 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -6,12 +6,20 @@ Win32 $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ $(OutputPath)$(Platform)\ + + + $(Company) + $(Copyright) $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + $(MSBuildThisFileDirectory)CustomizedNativeRecommendedRules.ruleset + + $(DisableSpecificCompilerWarnings) diff --git a/src/CustomizedNativeRecommendedRules.ruleset b/src/CustomizedNativeRecommendedRules.ruleset new file mode 100644 index 00000000..142b141c --- /dev/null +++ b/src/CustomizedNativeRecommendedRules.ruleset @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From ca5d60d267051b4b75e22763ad8eda06f0501451 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 2 Dec 2020 22:38:23 -0600 Subject: WIXFEAT:4626,5386 - Add more BA events. OnBeginMsiTransactionBegin, OnBeginMsiTransactionComplete, OnCommitMsiTransactionBegin, OnCommitMsiTransactionComplete, OnRollbackMsiTransactionBegin, OnRollbackMsiTransactionComplete, OnPauseAutomaticUpdatesBegin, OnPauseAutomaticUpdatesComplete, OnSystemRestorePointBegin, OnSystemRestorePointComplete --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 278 ++++++++++++++++++++- src/WixToolset.Mba.Core/EventArgs.cs | 191 +++++++++++++- .../IBootstrapperApplication.cs | 64 ++++- .../IDefaultBootstrapperApplication.cs | 15 +- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BAFunctions.h | 10 + src/balutil/inc/BalBaseBAFunctions.h | 73 ++++++ src/balutil/inc/BalBaseBAFunctionsProc.h | 10 + src/balutil/inc/BalBaseBootstrapperApplication.h | 75 ++++++ .../inc/BalBaseBootstrapperApplicationProc.h | 119 +++++++++ src/balutil/inc/IBootstrapperApplication.h | 43 ++++ src/balutil/packages.config | 4 +- src/bextutil/bextutil.vcxproj | 8 +- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 8 +- src/mbanative/packages.config | 4 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 8 +- src/test/BalUtilUnitTest/packages.config | 4 +- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 8 +- src/test/BextUtilUnitTest/packages.config | 4 +- 20 files changed, 893 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 472c553a..2d527427 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -320,12 +320,62 @@ namespace WixToolset.Mba.Core /// /// Fired when the engine is about to launch the preapproved executable. /// - public event EventHandler LaunchApprovedExeBegin; + public event EventHandler LaunchApprovedExeBegin; /// /// Fired when the engine has completed launching the preapproved executable. /// - public event EventHandler LaunchApprovedExeComplete; + public event EventHandler LaunchApprovedExeComplete; + + /// + /// Fired when the engine is about to begin an MSI transaction. + /// + public event EventHandler BeginMsiTransactionBegin; + + /// + /// Fired when the engine has completed beginning an MSI transaction. + /// + public event EventHandler BeginMsiTransactionComplete; + + /// + /// Fired when the engine is about to commit an MSI transaction. + /// + public event EventHandler CommitMsiTransactionBegin; + + /// + /// Fired when the engine has completed comitting an MSI transaction. + /// + public event EventHandler CommitMsiTransactionComplete; + + /// + /// Fired when the engine is about to rollback an MSI transaction. + /// + public event EventHandler RollbackMsiTransactionBegin; + + /// + /// Fired when the engine has completed rolling back an MSI transaction. + /// + public event EventHandler RollbackMsiTransactionComplete; + + /// + /// Fired when the engine is about to pause Windows automatic updates. + /// + public event EventHandler PauseAutomaticUpdatesBegin; + + /// + /// Fired when the engine has completed pausing Windows automatic updates. + /// + public event EventHandler PauseAutomaticUpdatesComplete; + + /// + /// Fired when the engine is about to take a system restore point. + /// + public event EventHandler SystemRestorePointBegin; + + /// + /// Fired when the engine has completed taking a system restore point. + /// + public event EventHandler SystemRestorePointComplete; /// /// Entry point that is called when the bootstrapper application is ready to run. @@ -1071,9 +1121,9 @@ namespace WixToolset.Mba.Core /// Called by the engine before trying to launch the preapproved executable. /// /// Additional arguments for this event. - protected virtual void OnLaunchApprovedExeBegin(LaunchApprovedExeBeginArgs args) + protected virtual void OnLaunchApprovedExeBegin(LaunchApprovedExeBeginEventArgs args) { - EventHandler handler = this.LaunchApprovedExeBegin; + EventHandler handler = this.LaunchApprovedExeBegin; if (null != handler) { handler(this, args); @@ -1084,9 +1134,139 @@ namespace WixToolset.Mba.Core /// Called by the engine after trying to launch the preapproved executable. /// /// Additional arguments for this event. - protected virtual void OnLaunchApprovedExeComplete(LaunchApprovedExeCompleteArgs args) + protected virtual void OnLaunchApprovedExeComplete(LaunchApprovedExeCompleteEventArgs args) + { + EventHandler handler = this.LaunchApprovedExeComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine before beginning an MSI transaction. + /// + /// Additional arguments for this event. + protected virtual void OnBeginMsiTransactionBegin(BeginMsiTransactionBeginEventArgs args) + { + EventHandler handler = this.BeginMsiTransactionBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine after beginning an MSI transaction. + /// + /// Additional arguments for this event. + protected virtual void OnBeginMsiTransactionComplete(BeginMsiTransactionCompleteEventArgs args) + { + EventHandler handler = this.BeginMsiTransactionComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine before committing an MSI transaction. + /// + /// Additional arguments for this event. + protected virtual void OnCommitMsiTransactionBegin(CommitMsiTransactionBeginEventArgs args) + { + EventHandler handler = this.CommitMsiTransactionBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine after committing an MSI transaction. + /// + /// Additional arguments for this event. + protected virtual void OnCommitMsiTransactionComplete(CommitMsiTransactionCompleteEventArgs args) + { + EventHandler handler = this.CommitMsiTransactionComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine before rolling back an MSI transaction. + /// + /// Additional arguments for this event. + protected virtual void OnRollbackMsiTransactionBegin(RollbackMsiTransactionBeginEventArgs args) + { + EventHandler handler = this.RollbackMsiTransactionBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine after rolling back an MSI transaction. + /// + /// Additional arguments for this event. + protected virtual void OnRollbackMsiTransactionComplete(RollbackMsiTransactionCompleteEventArgs args) + { + EventHandler handler = this.RollbackMsiTransactionComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine before pausing Windows automatic updates. + /// + /// Additional arguments for this event. + protected virtual void OnPauseAutomaticUpdatesBegin(PauseAutomaticUpdatesBeginEventArgs args) + { + EventHandler handler = this.PauseAutomaticUpdatesBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine after pausing Windows automatic updates. + /// + /// Additional arguments for this event. + protected virtual void OnPauseAutomaticUpdatesComplete(PauseAutomaticUpdatesCompleteEventArgs args) + { + EventHandler handler = this.PauseAutomaticUpdatesComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine before taking a system restore point. + /// + /// Additional arguments for this event. + protected virtual void OnSystemRestorePointBegin(SystemRestorePointBeginEventArgs args) { - EventHandler handler = this.LaunchApprovedExeComplete; + EventHandler handler = this.SystemRestorePointBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine after taking a system restore point. + /// + /// Additional arguments for this event. + protected virtual void OnSystemRestorePointComplete(SystemRestorePointCompleteEventArgs args) + { + EventHandler handler = this.SystemRestorePointComplete; if (null != handler) { handler(this, args); @@ -1588,7 +1768,7 @@ namespace WixToolset.Mba.Core int IBootstrapperApplication.OnLaunchApprovedExeBegin(ref bool fCancel) { - LaunchApprovedExeBeginArgs args = new LaunchApprovedExeBeginArgs(fCancel); + LaunchApprovedExeBeginEventArgs args = new LaunchApprovedExeBeginEventArgs(fCancel); this.OnLaunchApprovedExeBegin(args); fCancel = args.Cancel; @@ -1597,12 +1777,94 @@ namespace WixToolset.Mba.Core int IBootstrapperApplication.OnLaunchApprovedExeComplete(int hrStatus, int processId) { - LaunchApprovedExeCompleteArgs args = new LaunchApprovedExeCompleteArgs(hrStatus, processId); + LaunchApprovedExeCompleteEventArgs args = new LaunchApprovedExeCompleteEventArgs(hrStatus, processId); this.OnLaunchApprovedExeComplete(args); return args.HResult; } + int IBootstrapperApplication.OnBeginMsiTransactionBegin(string transactionId, ref bool fCancel) + { + BeginMsiTransactionBeginEventArgs args = new BeginMsiTransactionBeginEventArgs(transactionId, fCancel); + this.OnBeginMsiTransactionBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnBeginMsiTransactionComplete(string transactionId, int hrStatus) + { + BeginMsiTransactionCompleteEventArgs args = new BeginMsiTransactionCompleteEventArgs(transactionId, hrStatus); + this.OnBeginMsiTransactionComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnCommitMsiTransactionBegin(string transactionId, ref bool fCancel) + { + CommitMsiTransactionBeginEventArgs args = new CommitMsiTransactionBeginEventArgs(transactionId, fCancel); + this.OnCommitMsiTransactionBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCommitMsiTransactionComplete(string transactionId, int hrStatus) + { + CommitMsiTransactionCompleteEventArgs args = new CommitMsiTransactionCompleteEventArgs(transactionId, hrStatus); + this.OnCommitMsiTransactionComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnRollbackMsiTransactionBegin(string transactionId) + { + RollbackMsiTransactionBeginEventArgs args = new RollbackMsiTransactionBeginEventArgs(transactionId); + this.OnRollbackMsiTransactionBegin(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnRollbackMsiTransactionComplete(string transactionId, int hrStatus) + { + RollbackMsiTransactionCompleteEventArgs args = new RollbackMsiTransactionCompleteEventArgs(transactionId, hrStatus); + this.OnRollbackMsiTransactionComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPauseAutomaticUpdatesBegin() + { + PauseAutomaticUpdatesBeginEventArgs args = new PauseAutomaticUpdatesBeginEventArgs(); + this.OnPauseAutomaticUpdatesBegin(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPauseAutomaticUpdatesComplete(int hrStatus) + { + PauseAutomaticUpdatesCompleteEventArgs args = new PauseAutomaticUpdatesCompleteEventArgs(hrStatus); + this.OnPauseAutomaticUpdatesComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnSystemRestorePointBegin() + { + SystemRestorePointBeginEventArgs args = new SystemRestorePointBeginEventArgs(); + this.OnSystemRestorePointBegin(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnSystemRestorePointComplete(int hrStatus) + { + SystemRestorePointCompleteEventArgs args = new SystemRestorePointCompleteEventArgs(hrStatus); + this.OnSystemRestorePointComplete(args); + + return args.HResult; + } + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) { switch (message) diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 71bd15e1..b52b893a 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -1948,9 +1948,9 @@ namespace WixToolset.Mba.Core /// Additional arguments passed by the engine before it tries to launch the preapproved executable. /// [Serializable] - public class LaunchApprovedExeBeginArgs : CancellableHResultEventArgs + public class LaunchApprovedExeBeginEventArgs : CancellableHResultEventArgs { - public LaunchApprovedExeBeginArgs(bool cancelRecommendation) + public LaunchApprovedExeBeginEventArgs(bool cancelRecommendation) : base(cancelRecommendation) { } @@ -1960,11 +1960,11 @@ namespace WixToolset.Mba.Core /// Additional arguments passed by the engine after it finished trying to launch the preapproved executable. /// [Serializable] - public class LaunchApprovedExeCompleteArgs : StatusEventArgs + public class LaunchApprovedExeCompleteEventArgs : StatusEventArgs { private int processId; - public LaunchApprovedExeCompleteArgs(int hrStatus, int processId) + public LaunchApprovedExeCompleteEventArgs(int hrStatus, int processId) : base(hrStatus) { this.processId = processId; @@ -1979,4 +1979,187 @@ namespace WixToolset.Mba.Core get { return this.processId; } } } + + /// + /// Additional arguments passed by the engine before beginning an MSI transaction. + /// + [Serializable] + public class BeginMsiTransactionBeginEventArgs : CancellableHResultEventArgs + { + private string transactionId; + + public BeginMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine after beginning an MSI transaction. + /// + [Serializable] + public class BeginMsiTransactionCompleteEventArgs : StatusEventArgs + { + private string transactionId; + + public BeginMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) + : base(hrStatus) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine before committing an MSI transaction. + /// + [Serializable] + public class CommitMsiTransactionBeginEventArgs : CancellableHResultEventArgs + { + private string transactionId; + + public CommitMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine after committing an MSI transaction. + /// + [Serializable] + public class CommitMsiTransactionCompleteEventArgs : StatusEventArgs + { + private string transactionId; + + public CommitMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) + : base(hrStatus) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine before rolling back an MSI transaction. + /// + [Serializable] + public class RollbackMsiTransactionBeginEventArgs : HResultEventArgs + { + private string transactionId; + + public RollbackMsiTransactionBeginEventArgs(string transactionId) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine after rolling back an MSI transaction. + /// + [Serializable] + public class RollbackMsiTransactionCompleteEventArgs : StatusEventArgs + { + private string transactionId; + + public RollbackMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) + : base(hrStatus) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine before pausing Windows automatic updates. + /// + [Serializable] + public class PauseAutomaticUpdatesBeginEventArgs : HResultEventArgs + { + public PauseAutomaticUpdatesBeginEventArgs() + { + } + } + + /// + /// Additional arguments passed by the engine after pausing Windows automatic updates. + /// + [Serializable] + public class PauseAutomaticUpdatesCompleteEventArgs : StatusEventArgs + { + public PauseAutomaticUpdatesCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments passed by the engine before taking a system restore point. + /// + [Serializable] + public class SystemRestorePointBeginEventArgs : HResultEventArgs + { + public SystemRestorePointBeginEventArgs() + { + } + } + + /// + /// Additional arguments passed by the engine after taking a system restore point. + /// + [Serializable] + public class SystemRestorePointCompleteEventArgs : StatusEventArgs + { + public SystemRestorePointCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } } diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 0d79122d..f1a631a3 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -12,7 +12,6 @@ namespace WixToolset.Mba.Core [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("53C31D56-49C0-426B-AB06-099D717C67FE")] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] public interface IBootstrapperApplication { [PreserveSig] @@ -500,6 +499,69 @@ namespace WixToolset.Mba.Core int processId ); + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnBeginMsiTransactionBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnBeginMsiTransactionComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCommitMsiTransactionBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCommitMsiTransactionComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRollbackMsiTransactionBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRollbackMsiTransactionComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPauseAutomaticUpdatesBegin( + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPauseAutomaticUpdatesComplete( + int hrStatus + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnSystemRestorePointBegin( + ); + + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnSystemRestorePointComplete( + int hrStatus + ); + [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int BAProc( diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 9bea6418..4a30da7e 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -8,6 +8,8 @@ namespace WixToolset.Mba.Core { event EventHandler ApplyBegin; event EventHandler ApplyComplete; + event EventHandler BeginMsiTransactionBegin; + event EventHandler BeginMsiTransactionComplete; event EventHandler CacheAcquireBegin; event EventHandler CacheAcquireComplete; event EventHandler CacheAcquireProgress; @@ -17,6 +19,8 @@ namespace WixToolset.Mba.Core event EventHandler CachePackageComplete; event EventHandler CacheVerifyBegin; event EventHandler CacheVerifyComplete; + event EventHandler CommitMsiTransactionBegin; + event EventHandler CommitMsiTransactionComplete; event EventHandler DetectBegin; event EventHandler DetectCompatibleMsiPackage; event EventHandler DetectComplete; @@ -41,13 +45,16 @@ namespace WixToolset.Mba.Core event EventHandler ExecutePackageComplete; event EventHandler ExecutePatchTarget; event EventHandler ExecuteProgress; - event EventHandler LaunchApprovedExeBegin; - event EventHandler LaunchApprovedExeComplete; + event EventHandler LaunchApprovedExeBegin; + event EventHandler LaunchApprovedExeComplete; + event EventHandler PauseAutomaticUpdatesBegin; + event EventHandler PauseAutomaticUpdatesComplete; event EventHandler PlanBegin; event EventHandler PlanCompatibleMsiPackageBegin; event EventHandler PlanCompatibleMsiPackageComplete; event EventHandler PlanComplete; event EventHandler PlanMsiFeature; + event EventHandler PlanMsiPackage; event EventHandler PlanPackageBegin; event EventHandler PlanPackageComplete; event EventHandler PlanRelatedBundle; @@ -56,8 +63,12 @@ namespace WixToolset.Mba.Core event EventHandler RegisterBegin; event EventHandler RegisterComplete; event EventHandler ResolveSource; + event EventHandler RollbackMsiTransactionBegin; + event EventHandler RollbackMsiTransactionComplete; event EventHandler Shutdown; event EventHandler Startup; + event EventHandler SystemRestorePointBegin; + event EventHandler SystemRestorePointComplete; event EventHandler SystemShutdown; event EventHandler UnregisterBegin; event EventHandler UnregisterComplete; diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index d35a7a77..4793770a 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 8101afdb..a95b7a03 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -65,6 +65,16 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, + BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, + BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 72edadd5..39934128 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -612,6 +612,79 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnBeginMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index f6ebd9f6..69843301 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -100,6 +100,16 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + case BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + case BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + case BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); break; case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 612faf54..ad0c60e5 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -798,6 +798,81 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnBeginMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 7d5de8e4..648252b5 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -513,6 +513,96 @@ static HRESULT BalBaseBAProcOnPlanMsiPackage( return pBA->OnPlanMsiPackage(pArgs->wzPackageId, pArgs->fExecute, pArgs->action, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler); } +static HRESULT BalBaseBAProcOnBeginMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONBEGINMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBA->OnBeginMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnBeginMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnBeginMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnCommitMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBA->OnCommitMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnCommitMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnRollbackMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnRollbackMsiTransactionBegin(pArgs->wzTransactionId); +} + +static HRESULT BalBaseBAProcOnRollbackMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS* /*pArgs*/, + __inout BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnPauseAutomaticUpdatesBegin(); +} + +static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS* pArgs, + __inout BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnPauseAutomaticUpdatesComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnSystemRestorePointBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS* /*pArgs*/, + __inout BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnSystemRestorePointBegin(); +} + +static HRESULT BalBaseBAProcOnSystemRestorePointComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS* pArgs, + __inout BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnSystemRestorePointComplete(pArgs->hrStatus); +} + /******************************************************************* BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. Provides a default mapping between the new message based BA interface and @@ -701,6 +791,35 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE: hr = BalBaseBAProcOnPlanMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN: + hr = BalBaseBAProcOnBeginMsiTransactionBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE: + hr = BalBaseBAProcOnBeginMsiTransactionComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN: + hr = BalBaseBAProcOnCommitMsiTransactionBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE: + hr = BalBaseBAProcOnCommitMsiTransactionComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN: + hr = BalBaseBAProcOnRollbackMsiTransactionBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE: + hr = BalBaseBAProcOnRollbackMsiTransactionComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN: + hr = BalBaseBAProcOnPauseAutomaticUpdatesBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: + hr = BalBaseBAProcOnPauseAutomaticUpdatesComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: + hr = BalBaseBAProcOnSystemRestorePointBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: + hr = BalBaseBAProcOnSystemRestorePointComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; } } diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 75ea7bc9..dd8f8024 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -518,6 +518,49 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in DWORD dwProcessId ) = 0; + STDMETHOD(OnBeginMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnBeginMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnCommitMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCommitMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnRollbackMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId + ) = 0; + + STDMETHOD(OnRollbackMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnPauseAutomaticUpdatesBegin)( + ) = 0; + + STDMETHOD(OnPauseAutomaticUpdatesComplete)( + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnSystemRestorePointBegin)( + ) = 0; + + STDMETHOD(OnSystemRestorePointComplete)( + __in HRESULT hrStatus + ) = 0; + // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. // This might be used to help the BA support more than one version of the engine. STDMETHOD(BAProc)( diff --git a/src/balutil/packages.config b/src/balutil/packages.config index dbc4eb18..e6716363 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index def0dd59..2e248d2c 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index dbc4eb18..e6716363 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 69309f8a..be60f3a9 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -94,7 +94,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 20047373..46972411 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 53d14cd7..a57c6f01 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -67,7 +67,7 @@ - - + + diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index b8423837..e3b144e6 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index 15a1f51d..c1cf107c 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -66,7 +66,7 @@ - - + + diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index b8423837..e3b144e6 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 80df808461fca91b53e232b5b504a5c868029697 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 19 Dec 2020 19:15:11 -0600 Subject: Enable XML doc. --- src/CSharp.Build.props | 2 + src/Directory.Build.targets | 8 + .../BaseBootstrapperApplicationFactory.cs | 27 + src/WixToolset.Mba.Core/BootstrapperApplication.cs | 424 ++++------- .../BootstrapperApplicationData.cs | 38 + src/WixToolset.Mba.Core/BootstrapperCommand.cs | 30 + src/WixToolset.Mba.Core/BundleInfo.cs | 21 + src/WixToolset.Mba.Core/Engine.cs | 43 +- src/WixToolset.Mba.Core/EventArgs.cs | 54 +- .../IBootstrapperApplication.cs | 808 ++++++++++++++++++++- .../IBootstrapperApplicationData.cs | 10 + .../IBootstrapperApplicationFactory.cs | 31 +- src/WixToolset.Mba.Core/IBootstrapperCommand.cs | 3 + src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 303 ++++++++ src/WixToolset.Mba.Core/IBundleInfo.cs | 23 + .../IDefaultBootstrapperApplication.cs | 278 +++++++ src/WixToolset.Mba.Core/IEngine.cs | 3 + src/WixToolset.Mba.Core/IPackageInfo.cs | 66 ++ src/WixToolset.Mba.Core/PackageInfo.cs | 107 +++ src/WixToolset.Mba.Core/VerUtil.cs | 19 + src/WixToolset.Mba.Core/VerUtilVersion.cs | 36 + .../VerUtilVersionReleaseLabel.cs | 14 + src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 6 +- src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 2 + .../BaseBootstrapperApplicationFactoryFixture.cs | 19 + 25 files changed, 2045 insertions(+), 330 deletions(-) (limited to 'src') diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props index b12f4c6e..81d24ad1 100644 --- a/src/CSharp.Build.props +++ b/src/CSharp.Build.props @@ -5,7 +5,9 @@ --> + true true $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + false diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index dac7452a..cb988931 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -9,6 +9,11 @@ See the original here: https://github.com/dotnet/sdk/issues/1151#issuecomment-385133284 --> + + false + $(OutputPath)\$(AssemblyName).xml + + true $(SolutionPath) @@ -45,4 +50,7 @@ + + + diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs index 264733ac..ad8a5dc0 100644 --- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -5,8 +5,16 @@ namespace WixToolset.Mba.Core using System; using System.Runtime.InteropServices; + /// + /// Default implementation of . + /// public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory { + /// + /// Default implementation of + /// + /// + /// public void Create(IntPtr pArgs, IntPtr pResults) { InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); @@ -15,8 +23,21 @@ namespace WixToolset.Mba.Core StoreBAInCreateResults(pResults, ba); } + /// + /// Called by to get the . + /// + /// The bundle engine. + /// Command information passed from the engine for the BA to perform. + /// The for the bundle. protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); + /// + /// Initializes the native part of . + /// Most users should inherit from instead of calling this method. + /// + /// 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. public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) { Command pCommand = new Command @@ -28,6 +49,12 @@ namespace WixToolset.Mba.Core bootstrapperCommand = pCommand.GetBootstrapperCommand(); } + /// + /// 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. + /// + /// The results struct given by the engine when initially creating the BA + /// The . public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) { BalUtil.StoreBAInCreateResults(pResults, ba); diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 2d527427..759e76b1 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -34,347 +34,202 @@ namespace WixToolset.Mba.Core this.asyncExecution = true; } - /// - /// Fired when the engine is starting up the bootstrapper application. - /// + /// public event EventHandler Startup; - /// - /// Fired when the engine is shutting down the bootstrapper application. - /// + /// public event EventHandler Shutdown; - /// - /// Fired when the system is shutting down or user is logging off. - /// - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// By default setup will prevent shutting down or logging off between - /// and . - /// Derivatives can change this behavior by overriding - /// or handling . - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// This event may be fired on a different thread. - /// + /// public event EventHandler SystemShutdown; - /// - /// Fired when the overall detection phase has begun. - /// + /// public event EventHandler DetectBegin; - /// - /// Fired when a forward compatible bundle is detected. - /// + /// public event EventHandler DetectForwardCompatibleBundle; - /// - /// Fired when the update detection phase has begun. - /// + /// public event EventHandler DetectUpdateBegin; - /// - /// Fired when the update detection has found a potential update candidate. - /// + /// public event EventHandler DetectUpdate; - /// - /// Fired when the update detection phase has completed. - /// + /// public event EventHandler DetectUpdateComplete; - /// - /// Fired when a related bundle has been detected for a bundle. - /// + /// public event EventHandler DetectRelatedBundle; - /// - /// Fired when the detection for a specific package has begun. - /// + /// public event EventHandler DetectPackageBegin; - /// - /// Fired when a package was not detected but a package using the same provider key was. - /// + /// public event EventHandler DetectCompatibleMsiPackage; - - /// - /// Fired when a related MSI package has been detected for a package. - /// + + /// public event EventHandler DetectRelatedMsiPackage; - /// - /// Fired when an MSP package detects a target MSI has been detected. - /// + /// public event EventHandler DetectTargetMsiPackage; - /// - /// Fired when a feature in an MSI package has been detected. - /// + /// public event EventHandler DetectMsiFeature; - /// - /// Fired when the detection for a specific package has completed. - /// + /// public event EventHandler DetectPackageComplete; - /// - /// Fired when the detection phase has completed. - /// + /// public event EventHandler DetectComplete; - /// - /// Fired when the engine has begun planning the installation. - /// + /// public event EventHandler PlanBegin; - /// - /// Fired when the engine has begun planning for a related bundle. - /// + /// public event EventHandler PlanRelatedBundle; - /// - /// Fired when the engine has begun planning the installation of a specific package. - /// + /// public event EventHandler PlanPackageBegin; - /// - /// Fired when the engine plans a new, compatible package using the same provider key. - /// + /// public event EventHandler PlanCompatibleMsiPackageBegin; - /// - /// Fired when the engine has completed planning the installation of a specific package. - /// + /// public event EventHandler PlanCompatibleMsiPackageComplete; - /// - /// Fired when the engine is about to plan the target MSI of a MSP package. - /// + /// public event EventHandler PlanTargetMsiPackage; - /// - /// Fired when the engine is about to plan a feature in an MSI package. - /// + /// public event EventHandler PlanMsiFeature; - /// - /// Fired when the engine is planning an MSI or MSP package. - /// + /// public event EventHandler PlanMsiPackage; - /// - /// Fired when the engine has completed planning the installation of a specific package. - /// + /// public event EventHandler PlanPackageComplete; - /// - /// Fired when the engine has completed planning the installation. - /// + /// public event EventHandler PlanComplete; - /// - /// Fired when the engine has begun installing the bundle. - /// + /// public event EventHandler ApplyBegin; - /// - /// Fired when the engine is about to start the elevated process. - /// + /// public event EventHandler ElevateBegin; - /// - /// Fired when the engine has completed starting the elevated process. - /// + /// public event EventHandler ElevateComplete; - /// - /// Fired when the engine has changed progress for the bundle installation. - /// + /// public event EventHandler Progress; - /// - /// Fired when the engine has encountered an error. - /// + /// public event EventHandler Error; - /// - /// Fired when the engine has begun registering the location and visibility of the bundle. - /// + /// public event EventHandler RegisterBegin; - /// - /// Fired when the engine has completed registering the location and visibility of the bundle. - /// + /// public event EventHandler RegisterComplete; - /// - /// Fired when the engine has begun removing the registration for the location and visibility of the bundle. - /// + /// public event EventHandler UnregisterBegin; - /// - /// Fired when the engine has completed removing the registration for the location and visibility of the bundle. - /// + /// public event EventHandler UnregisterComplete; - /// - /// Fired when the engine has begun caching the installation sources. - /// + /// public event EventHandler CacheBegin; - /// - /// Fired when the engine has begun caching a specific package. - /// + /// public event EventHandler CachePackageBegin; - /// - /// Fired when the engine has begun acquiring the installation sources. - /// + /// public event EventHandler CacheAcquireBegin; - /// - /// Fired when the engine has progress acquiring the installation sources. - /// + /// public event EventHandler CacheAcquireProgress; - /// - /// Fired by the engine to allow the BA to change the source - /// using or . - /// + /// public event EventHandler ResolveSource; - /// - /// Fired when the engine has completed the acquisition of the installation sources. - /// + /// public event EventHandler CacheAcquireComplete; - /// - /// Fired when the engine begins the verification of the acquired installation sources. - /// + /// public event EventHandler CacheVerifyBegin; - /// - /// Fired when the engine complete the verification of the acquired installation sources. - /// + /// public event EventHandler CacheVerifyComplete; - /// - /// Fired when the engine has completed caching a specific package. - /// + /// public event EventHandler CachePackageComplete; - /// - /// Fired after the engine has cached the installation sources. - /// + /// public event EventHandler CacheComplete; - /// - /// Fired when the engine has begun installing packages. - /// + /// public event EventHandler ExecuteBegin; - /// - /// Fired when the engine has begun installing a specific package. - /// + /// public event EventHandler ExecutePackageBegin; - /// - /// Fired when the engine executes one or more patches targeting a product. - /// + /// public event EventHandler ExecutePatchTarget; - /// - /// Fired when Windows Installer sends an installation message. - /// + /// public event EventHandler ExecuteMsiMessage; - /// - /// Fired when Windows Installer sends a files in use installation message. - /// + /// public event EventHandler ExecuteFilesInUse; - /// - /// Fired when the engine has completed installing a specific package. - /// + /// public event EventHandler ExecutePackageComplete; - /// - /// Fired when the engine has completed installing packages. - /// + /// public event EventHandler ExecuteComplete; - /// - /// Fired when the engine has completed installing the bundle. - /// + /// public event EventHandler ApplyComplete; - /// - /// Fired by the engine while executing on payload. - /// + /// public event EventHandler ExecuteProgress; - /// - /// Fired when the engine is about to launch the preapproved executable. - /// + /// public event EventHandler LaunchApprovedExeBegin; - /// - /// Fired when the engine has completed launching the preapproved executable. - /// + /// public event EventHandler LaunchApprovedExeComplete; - /// - /// Fired when the engine is about to begin an MSI transaction. - /// + /// public event EventHandler BeginMsiTransactionBegin; - /// - /// Fired when the engine has completed beginning an MSI transaction. - /// + /// public event EventHandler BeginMsiTransactionComplete; - /// - /// Fired when the engine is about to commit an MSI transaction. - /// + /// public event EventHandler CommitMsiTransactionBegin; - /// - /// Fired when the engine has completed comitting an MSI transaction. - /// + /// public event EventHandler CommitMsiTransactionComplete; - /// - /// Fired when the engine is about to rollback an MSI transaction. - /// + /// public event EventHandler RollbackMsiTransactionBegin; - /// - /// Fired when the engine has completed rolling back an MSI transaction. - /// + /// public event EventHandler RollbackMsiTransactionComplete; - /// - /// Fired when the engine is about to pause Windows automatic updates. - /// + /// public event EventHandler PauseAutomaticUpdatesBegin; - /// - /// Fired when the engine has completed pausing Windows automatic updates. - /// + /// public event EventHandler PauseAutomaticUpdatesComplete; - /// - /// Fired when the engine is about to take a system restore point. - /// + /// public event EventHandler SystemRestorePointBegin; - /// - /// Fired when the engine has completed taking a system restore point. - /// + /// public event EventHandler SystemRestorePointComplete; /// @@ -383,7 +238,7 @@ namespace WixToolset.Mba.Core protected abstract void Run(); /// - /// Called by the engine on startup of the bootstrapper application. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnStartup(StartupEventArgs args) @@ -410,7 +265,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine to uninitialize the BA. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnShutdown(ShutdownEventArgs args) @@ -423,21 +278,9 @@ namespace WixToolset.Mba.Core } /// - /// Called when the system is shutting down or the user is logging off. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// By default setup will prevent shutting down or logging off between - /// and . - /// Derivatives can change this behavior by overriding - /// or handling . - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// This method may be called on a different thread. - /// protected virtual void OnSystemShutdown(SystemShutdownEventArgs args) { EventHandler handler = this.SystemShutdown; @@ -454,7 +297,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the overall detection phase has begun. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectBegin(DetectBeginEventArgs args) @@ -467,7 +310,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the update detection phase has begun. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectForwardCompatibleBundle(DetectForwardCompatibleBundleEventArgs args) @@ -480,7 +323,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the update detection phase has begun. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) @@ -493,7 +336,7 @@ namespace WixToolset.Mba.Core } /// - /// Fired when the update detection has found a potential update candidate. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectUpdate(DetectUpdateEventArgs args) @@ -506,7 +349,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the update detection phase has completed. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectUpdateComplete(DetectUpdateCompleteEventArgs args) @@ -519,7 +362,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when a related bundle has been detected for a bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectRelatedBundle(DetectRelatedBundleEventArgs args) @@ -532,7 +375,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the detection for a specific package has begun. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectPackageBegin(DetectPackageBeginEventArgs args) @@ -545,7 +388,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when a package was not detected but a package using the same provider key was. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectCompatibleMsiPackage(DetectCompatibleMsiPackageEventArgs args) @@ -558,7 +401,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when a related MSI package has been detected for a package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectRelatedMsiPackage(DetectRelatedMsiPackageEventArgs args) @@ -571,7 +414,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when an MSP package detects a target MSI has been detected. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectTargetMsiPackage(DetectTargetMsiPackageEventArgs args) @@ -584,7 +427,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when an MSI feature has been detected for a package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectMsiFeature(DetectMsiFeatureEventArgs args) @@ -597,7 +440,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the detection for a specific package has completed. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectPackageComplete(DetectPackageCompleteEventArgs args) @@ -610,7 +453,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the detection phase has completed. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnDetectComplete(DetectCompleteEventArgs args) @@ -623,7 +466,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun planning the installation. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanBegin(PlanBeginEventArgs args) @@ -636,7 +479,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun planning for a prior bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanRelatedBundle(PlanRelatedBundleEventArgs args) @@ -649,7 +492,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun planning the installation of a specific package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanPackageBegin(PlanPackageBeginEventArgs args) @@ -662,7 +505,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine plans a new, compatible package using the same provider key. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanCompatibleMsiPackageBegin(PlanCompatibleMsiPackageBeginEventArgs args) @@ -675,7 +518,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed planning the installation of a specific package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanCompatibleMsiPackageComplete(PlanCompatibleMsiPackageCompleteEventArgs args) @@ -688,7 +531,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine is about to plan the target MSI of a MSP package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanTargetMsiPackage(PlanTargetMsiPackageEventArgs args) @@ -701,7 +544,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine is about to plan an MSI feature of a specific package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanMsiFeature(PlanMsiFeatureEventArgs args) @@ -714,7 +557,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine is planning an MSI or MSP package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanMsiPackage(PlanMsiPackageEventArgs args) @@ -727,7 +570,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when then engine has completed planning the installation of a specific package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanPackageComplete(PlanPackageCompleteEventArgs args) @@ -740,7 +583,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed planning the installation. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPlanComplete(PlanCompleteEventArgs args) @@ -753,7 +596,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun installing the bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnApplyBegin(ApplyBeginEventArgs args) @@ -766,7 +609,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine is about to start the elevated process. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnElevateBegin(ElevateBeginEventArgs args) @@ -779,7 +622,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed starting the elevated process. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnElevateComplete(ElevateCompleteEventArgs args) @@ -792,7 +635,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has changed progress for the bundle installation. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnProgress(ProgressEventArgs args) @@ -805,7 +648,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has encountered an error. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnError(ErrorEventArgs args) @@ -818,7 +661,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun registering the location and visibility of the bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnRegisterBegin(RegisterBeginEventArgs args) @@ -831,7 +674,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed registering the location and visilibity of the bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnRegisterComplete(RegisterCompleteEventArgs args) @@ -844,7 +687,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun removing the registration for the location and visibility of the bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnUnregisterBegin(UnregisterBeginEventArgs args) @@ -857,7 +700,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed removing the registration for the location and visibility of the bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnUnregisterComplete(UnregisterCompleteEventArgs args) @@ -870,7 +713,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine begins to cache the installation sources. + /// Called by the engine, raises the event. /// /// protected virtual void OnCacheBegin(CacheBeginEventArgs args) @@ -883,7 +726,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine when it begins to cache a specific package. + /// Called by the engine, raises the event. /// /// protected virtual void OnCachePackageBegin(CachePackageBeginEventArgs args) @@ -896,7 +739,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine begins to cache the container or payload. + /// Called by the engine, raises the event. /// /// protected virtual void OnCacheAcquireBegin(CacheAcquireBeginEventArgs args) @@ -909,7 +752,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has progressed on caching the container or payload. + /// Called by the engine, raises the event. /// /// protected virtual void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args) @@ -922,8 +765,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine to allow the BA to change the source - /// using or . + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnResolveSource(ResolveSourceEventArgs args) @@ -936,7 +778,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine completes caching of the container or payload. + /// Called by the engine, raises the event. /// /// protected virtual void OnCacheAcquireComplete(CacheAcquireCompleteEventArgs args) @@ -949,7 +791,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has started verify the payload. + /// Called by the engine, raises the event. /// /// protected virtual void OnCacheVerifyBegin(CacheVerifyBeginEventArgs args) @@ -962,7 +804,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine completes verification of the payload. + /// Called by the engine, raises the event. /// /// protected virtual void OnCacheVerifyComplete(CacheVerifyCompleteEventArgs args) @@ -975,7 +817,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine completes caching a specific package. + /// Called by the engine, raises the event. /// /// protected virtual void OnCachePackageComplete(CachePackageCompleteEventArgs args) @@ -988,7 +830,7 @@ namespace WixToolset.Mba.Core } /// - /// Called after the engine has cached the installation sources. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnCacheComplete(CacheCompleteEventArgs args) @@ -1001,7 +843,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun installing packages. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecuteBegin(ExecuteBeginEventArgs args) @@ -1014,7 +856,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has begun installing a specific package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecutePackageBegin(ExecutePackageBeginEventArgs args) @@ -1027,7 +869,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine executes one or more patches targeting a product. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecutePatchTarget(ExecutePatchTargetEventArgs args) @@ -1040,7 +882,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when Windows Installer sends an installation message. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecuteMsiMessage(ExecuteMsiMessageEventArgs args) @@ -1053,7 +895,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when Windows Installer sends a file in use installation message. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) @@ -1066,7 +908,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed installing a specific package. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecutePackageComplete(ExecutePackageCompleteEventArgs args) @@ -1079,7 +921,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed installing packages. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecuteComplete(ExecuteCompleteEventArgs args) @@ -1092,7 +934,7 @@ namespace WixToolset.Mba.Core } /// - /// Called when the engine has completed installing the bundle. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnApplyComplete(ApplyCompleteEventArgs args) @@ -1105,7 +947,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine while executing on payload. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnExecuteProgress(ExecuteProgressEventArgs args) @@ -1118,7 +960,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine before trying to launch the preapproved executable. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnLaunchApprovedExeBegin(LaunchApprovedExeBeginEventArgs args) @@ -1131,7 +973,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine after trying to launch the preapproved executable. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnLaunchApprovedExeComplete(LaunchApprovedExeCompleteEventArgs args) @@ -1144,7 +986,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine before beginning an MSI transaction. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnBeginMsiTransactionBegin(BeginMsiTransactionBeginEventArgs args) @@ -1157,7 +999,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine after beginning an MSI transaction. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnBeginMsiTransactionComplete(BeginMsiTransactionCompleteEventArgs args) @@ -1170,7 +1012,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine before committing an MSI transaction. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnCommitMsiTransactionBegin(CommitMsiTransactionBeginEventArgs args) @@ -1183,7 +1025,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine after committing an MSI transaction. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnCommitMsiTransactionComplete(CommitMsiTransactionCompleteEventArgs args) @@ -1196,7 +1038,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine before rolling back an MSI transaction. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnRollbackMsiTransactionBegin(RollbackMsiTransactionBeginEventArgs args) @@ -1209,7 +1051,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine after rolling back an MSI transaction. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnRollbackMsiTransactionComplete(RollbackMsiTransactionCompleteEventArgs args) @@ -1222,7 +1064,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine before pausing Windows automatic updates. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPauseAutomaticUpdatesBegin(PauseAutomaticUpdatesBeginEventArgs args) @@ -1235,7 +1077,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine after pausing Windows automatic updates. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnPauseAutomaticUpdatesComplete(PauseAutomaticUpdatesCompleteEventArgs args) @@ -1248,7 +1090,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine before taking a system restore point. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnSystemRestorePointBegin(SystemRestorePointBeginEventArgs args) @@ -1261,7 +1103,7 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine after taking a system restore point. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. protected virtual void OnSystemRestorePointComplete(SystemRestorePointCompleteEventArgs args) diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs index 05672f1b..739a08bb 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs @@ -6,12 +6,29 @@ namespace WixToolset.Mba.Core using System.IO; using System.Xml.XPath; + /// + /// Utility class for reading BootstrapperApplicationData.xml. + /// public class BootstrapperApplicationData : IBootstrapperApplicationData { + /// + /// + /// public const string DefaultFileName = "BootstrapperApplicationData.xml"; + + /// + /// + /// public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/BootstrapperApplicationData"; + /// + /// The default path of where the BA was extracted to. + /// public static readonly DirectoryInfo DefaultFolder; + + /// + /// The default path to BootstrapperApplicationData.xml. + /// public static readonly FileInfo DefaultFile; static BootstrapperApplicationData() @@ -20,12 +37,21 @@ namespace WixToolset.Mba.Core DefaultFile = new FileInfo(Path.Combine(DefaultFolder.FullName, DefaultFileName)); } + /// public FileInfo BADataFile { get; private set; } + /// public IBundleInfo Bundle { get; private set; } + /// + /// Uses the default location for BootstrapperApplicationData.xml. + /// public BootstrapperApplicationData() : this(DefaultFile) { } + /// + /// Uses the given file for BootstrapperApplicationData.xml. + /// + /// public BootstrapperApplicationData(FileInfo baDataFile) { this.BADataFile = baDataFile; @@ -36,6 +62,12 @@ namespace WixToolset.Mba.Core } } + /// + /// Utility method for parsing BootstrapperApplicationData.xml. + /// + /// + /// + /// public static string GetAttribute(XPathNavigator node, string attributeName) { XPathNavigator attribute = node.SelectSingleNode("@" + attributeName); @@ -48,6 +80,12 @@ namespace WixToolset.Mba.Core return attribute.Value; } + /// + /// Utility method for parsing BootstrapperApplicationData.xml. + /// + /// + /// + /// public static bool? GetYesNoAttribute(XPathNavigator node, string attributeName) { string attributeValue = GetAttribute(node, attributeName); diff --git a/src/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/WixToolset.Mba.Core/BootstrapperCommand.cs index 42d19bf9..65dde0f4 100644 --- a/src/WixToolset.Mba.Core/BootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -6,10 +6,28 @@ namespace WixToolset.Mba.Core using System.ComponentModel; using System.Runtime.InteropServices; + /// + /// Default implementation of . + /// public sealed class BootstrapperCommand : IBootstrapperCommand { private readonly string commandLine; + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public BootstrapperCommand( LaunchAction action, Display display, @@ -38,28 +56,40 @@ namespace WixToolset.Mba.Core this.BootstrapperApplicationDataPath = bootstrapperApplicationDataPath; } + /// public LaunchAction Action { get; } + /// public Display Display { get; } + /// public Restart Restart { get; } + /// public string[] CommandLineArgs => GetCommandLineArgs(this.commandLine); + /// public int CmdShow { get; } + /// public ResumeType Resume { get; } + /// public IntPtr SplashScreen { get; } + /// public RelationType Relation { get; } + /// public bool Passthrough { get; } + /// public string LayoutDirectory { get; } + /// public string BootstrapperWorkingFolder { get; } + /// public string BootstrapperApplicationDataPath { get; } /// diff --git a/src/WixToolset.Mba.Core/BundleInfo.cs b/src/WixToolset.Mba.Core/BundleInfo.cs index e1a56878..3d5d535d 100644 --- a/src/WixToolset.Mba.Core/BundleInfo.cs +++ b/src/WixToolset.Mba.Core/BundleInfo.cs @@ -8,11 +8,21 @@ namespace WixToolset.Mba.Core using System.Xml; using System.Xml.XPath; + /// + /// Default implementation of . + /// public class BundleInfo : IBundleInfo { + /// public bool PerMachine { get; internal set; } + + /// public string Name { get; internal set; } + + /// public string LogVariable { get; internal set; } + + /// public IDictionary Packages { get; internal set; } internal BundleInfo() @@ -20,6 +30,7 @@ namespace WixToolset.Mba.Core this.Packages = new Dictionary(); } + /// public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) { var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); @@ -27,6 +38,11 @@ namespace WixToolset.Mba.Core return package; } + /// + /// Parses BA manifest from the given stream. + /// + /// + /// public static IBundleInfo ParseBundleFromStream(Stream stream) { XPathDocument manifest = new XPathDocument(stream); @@ -34,6 +50,11 @@ namespace WixToolset.Mba.Core return ParseBundleFromXml(root); } + /// + /// Parses BA manifest from the given . + /// + /// The root of the BA manifest. + /// public static IBundleInfo ParseBundleFromXml(XPathNavigator root) { BundleInfo bundle = new BundleInfo(); diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index c6570f9d..d5c43a53 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -9,7 +9,7 @@ namespace WixToolset.Mba.Core using System.Text; /// - /// Container class for the interface. + /// Default implementation of . /// public sealed class Engine : IEngine { @@ -28,6 +28,7 @@ namespace WixToolset.Mba.Core this.engine = engine; } + /// public int PackageCount { get @@ -39,22 +40,26 @@ namespace WixToolset.Mba.Core } } + /// public void Apply(IntPtr hwndParent) { this.engine.Apply(hwndParent); } + /// public void CloseSplashScreen() { this.engine.CloseSplashScreen(); } + /// public int CompareVersions(string version1, string version2) { this.engine.CompareVersions(version1, version2, out var result); return result; } + /// public bool ContainsVariable(string name) { int capacity = 0; @@ -62,16 +67,19 @@ namespace WixToolset.Mba.Core return NativeMethods.E_NOTFOUND != ret; } + /// public void Detect() { this.Detect(IntPtr.Zero); } + /// public void Detect(IntPtr hwndParent) { this.engine.Detect(hwndParent); } + /// public bool Elevate(IntPtr hwndParent) { int ret = this.engine.Elevate(hwndParent); @@ -90,6 +98,7 @@ namespace WixToolset.Mba.Core } } + /// public string EscapeString(string input) { int capacity = InitialBufferSize; @@ -111,6 +120,7 @@ namespace WixToolset.Mba.Core return sb.ToString(); } + /// public bool EvaluateCondition(string condition) { bool value; @@ -119,6 +129,7 @@ namespace WixToolset.Mba.Core return value; } + /// public string FormatString(string format) { int capacity = InitialBufferSize; @@ -140,6 +151,7 @@ namespace WixToolset.Mba.Core return sb.ToString(); } + /// public long GetVariableNumeric(string name) { int ret = this.engine.GetVariableNumeric(name, out long value); @@ -151,6 +163,7 @@ namespace WixToolset.Mba.Core return value; } + /// public SecureString GetVariableSecureString(string name) { var pUniString = this.getStringVariable(name, out var length); @@ -167,6 +180,7 @@ namespace WixToolset.Mba.Core } } + /// public string GetVariableString(string name) { int length; @@ -184,6 +198,7 @@ namespace WixToolset.Mba.Core } } + /// public string GetVariableVersion(string name) { int length; @@ -201,46 +216,55 @@ namespace WixToolset.Mba.Core } } + /// public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) { this.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, 0); } + /// public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout) { this.engine.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, waitForInputIdleTimeout); } + /// public void Log(LogLevel level, string message) { this.engine.Log(level, message); } + /// public void Plan(LaunchAction action) { this.engine.Plan(action); } + /// public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash) { this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); } + /// public void SetLocalSource(string packageOrContainerId, string payloadId, string path) { this.engine.SetLocalSource(packageOrContainerId, payloadId, path); } + /// public void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password) { this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); } + /// public void SetVariableNumeric(string name, long value) { this.engine.SetVariableNumeric(name, value); } + /// public void SetVariableString(string name, SecureString value, bool formatted) { IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); @@ -254,6 +278,7 @@ namespace WixToolset.Mba.Core } } + /// public void SetVariableString(string name, string value, bool formatted) { IntPtr pValue = Marshal.StringToCoTaskMemUni(value); @@ -267,6 +292,7 @@ namespace WixToolset.Mba.Core } } + /// public void SetVariableVersion(string name, string value) { IntPtr pValue = Marshal.StringToCoTaskMemUni(value); @@ -280,6 +306,7 @@ namespace WixToolset.Mba.Core } } + /// public int SendEmbeddedError(int errorCode, string message, int uiHint) { int result = 0; @@ -287,6 +314,7 @@ namespace WixToolset.Mba.Core return result; } + /// public int SendEmbeddedProgress(int progressPercentage, int overallPercentage) { int result = 0; @@ -294,6 +322,7 @@ namespace WixToolset.Mba.Core return result; } + /// public void Quit(int exitCode) { this.engine.Quit(exitCode); @@ -423,6 +452,11 @@ namespace WixToolset.Mba.Core return value; } + /// + /// Utility method for converting a into a . + /// + /// + /// public static long VersionToLong(Version version) { // In Windows, each version component has a max value of 65535, @@ -435,6 +469,11 @@ namespace WixToolset.Mba.Core return major | minor | build | revision; } + /// + /// Utility method for converting a into a . + /// + /// + /// public static Version LongToVersion(long version) { int major = (int)((version & ((long)0xffff << 48)) >> 48); @@ -446,7 +485,7 @@ namespace WixToolset.Mba.Core } /// - /// Verifies that VersionVariables can pass on the given Version to the engine. + /// Verifies that Version can be represented in a . /// If the Build or Revision fields are undefined, they are set to zero. /// public static Version NormalizeVersion(Version version) diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index b52b893a..4e59fd6f 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -163,7 +163,7 @@ namespace WixToolset.Mba.Core /// To prevent shutting down or logging off, set to /// true; otherwise, set it to false. /// By default setup will prevent shutting down or logging off between - /// and . + /// and . /// If contains /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other /// critical operations before being closed by the operating system. @@ -1950,6 +1950,10 @@ namespace WixToolset.Mba.Core [Serializable] public class LaunchApprovedExeBeginEventArgs : CancellableHResultEventArgs { + /// + /// + /// + /// public LaunchApprovedExeBeginEventArgs(bool cancelRecommendation) : base(cancelRecommendation) { @@ -1964,6 +1968,11 @@ namespace WixToolset.Mba.Core { private int processId; + /// + /// + /// + /// + /// public LaunchApprovedExeCompleteEventArgs(int hrStatus, int processId) : base(hrStatus) { @@ -1988,6 +1997,11 @@ namespace WixToolset.Mba.Core { private string transactionId; + /// + /// + /// + /// + /// public BeginMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) : base(cancelRecommendation) { @@ -2011,6 +2025,11 @@ namespace WixToolset.Mba.Core { private string transactionId; + /// + /// + /// + /// + /// public BeginMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) : base(hrStatus) { @@ -2034,6 +2053,11 @@ namespace WixToolset.Mba.Core { private string transactionId; + /// + /// + /// + /// + /// public CommitMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) : base(cancelRecommendation) { @@ -2057,6 +2081,11 @@ namespace WixToolset.Mba.Core { private string transactionId; + /// + /// + /// + /// + /// public CommitMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) : base(hrStatus) { @@ -2080,6 +2109,10 @@ namespace WixToolset.Mba.Core { private string transactionId; + /// + /// + /// + /// public RollbackMsiTransactionBeginEventArgs(string transactionId) { this.transactionId = transactionId; @@ -2102,6 +2135,11 @@ namespace WixToolset.Mba.Core { private string transactionId; + /// + /// + /// + /// + /// public RollbackMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) : base(hrStatus) { @@ -2123,6 +2161,9 @@ namespace WixToolset.Mba.Core [Serializable] public class PauseAutomaticUpdatesBeginEventArgs : HResultEventArgs { + /// + /// + /// public PauseAutomaticUpdatesBeginEventArgs() { } @@ -2134,6 +2175,10 @@ namespace WixToolset.Mba.Core [Serializable] public class PauseAutomaticUpdatesCompleteEventArgs : StatusEventArgs { + /// + /// + /// + /// public PauseAutomaticUpdatesCompleteEventArgs(int hrStatus) : base(hrStatus) { @@ -2146,6 +2191,9 @@ namespace WixToolset.Mba.Core [Serializable] public class SystemRestorePointBeginEventArgs : HResultEventArgs { + /// + /// + /// public SystemRestorePointBeginEventArgs() { } @@ -2157,6 +2205,10 @@ namespace WixToolset.Mba.Core [Serializable] public class SystemRestorePointCompleteEventArgs : StatusEventArgs { + /// + /// + /// + /// public SystemRestorePointCompleteEventArgs(int hrStatus) : base(hrStatus) { diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index f1a631a3..3c62370a 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -14,14 +14,26 @@ namespace WixToolset.Mba.Core [Guid("53C31D56-49C0-426B-AB06-099D717C67FE")] public interface IBootstrapperApplication { + /// + /// See . + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnStartup(); + /// + /// See . + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnSystemShutdown( @@ -29,6 +41,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectBegin( @@ -37,6 +56,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectForwardCompatibleBundle( @@ -49,6 +79,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectUpdateBegin( @@ -57,6 +94,19 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fSkip ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectUpdate( @@ -71,6 +121,12 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fStopProcessingUpdates ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectUpdateComplete( @@ -78,6 +134,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreError ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectRelatedBundle( @@ -90,6 +157,12 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectPackageBegin( @@ -97,6 +170,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectCompatibleMsiPackage( @@ -106,6 +187,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectRelatedMsiPackage( @@ -118,6 +210,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectTargetMsiPackage( @@ -127,6 +227,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectMsiFeature( @@ -136,6 +244,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectPackageComplete( @@ -144,12 +259,23 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] PackageState state ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectComplete( int hrStatus ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanBegin( @@ -157,6 +283,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanRelatedBundle( @@ -166,6 +300,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanPackageBegin( @@ -175,6 +317,16 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanCompatibleMsiPackageBegin( @@ -186,6 +338,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanCompatibleMsiPackageComplete( @@ -198,6 +361,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ActionState rollback ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanTargetMsiPackage( @@ -208,6 +380,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanMsiFeature( @@ -218,6 +399,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanMsiPackage( @@ -230,6 +422,16 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fDisableExternalUiHandler ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanPackageComplete( @@ -241,12 +443,23 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ActionState rollback ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanComplete( int hrStatus ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnApplyBegin( @@ -254,18 +467,35 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnElevateBegin( [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnElevateComplete( int hrStatus ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnProgress( @@ -274,6 +504,19 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnError( @@ -288,24 +531,47 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] ref Result pResult ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnRegisterBegin( [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnRegisterComplete( int hrStatus ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheBegin( [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCachePackageBegin( @@ -315,6 +581,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireBegin( @@ -325,6 +600,16 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireProgress( @@ -336,6 +621,17 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnResolveSource( @@ -348,6 +644,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireComplete( @@ -358,6 +663,13 @@ namespace WixToolset.Mba.Core ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION pAction ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheVerifyBegin( @@ -366,6 +678,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheVerifyComplete( @@ -376,6 +697,14 @@ namespace WixToolset.Mba.Core ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCachePackageComplete( @@ -385,12 +714,23 @@ namespace WixToolset.Mba.Core ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheComplete( int hrStatus ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecuteBegin( @@ -398,6 +738,16 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecutePackageBegin( @@ -409,6 +759,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecutePatchTarget( @@ -417,6 +774,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecuteProgress( @@ -426,6 +791,18 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecuteMsiMessage( @@ -439,6 +816,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] ref Result pResult ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecuteFilesInUse( @@ -449,6 +835,15 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] ref Result pResult ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecutePackageComplete( @@ -459,24 +854,47 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnExecuteComplete( int hrStatus ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnUnregisterBegin( [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnUnregisterComplete( int hrStatus ); + /// + /// See . + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnApplyComplete( @@ -486,12 +904,23 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnLaunchApprovedExeBegin( [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnLaunchApprovedExeComplete( @@ -499,6 +928,12 @@ namespace WixToolset.Mba.Core int processId ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnBeginMsiTransactionBegin( @@ -506,6 +941,12 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnBeginMsiTransactionComplete( @@ -513,6 +954,12 @@ namespace WixToolset.Mba.Core int hrStatus ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCommitMsiTransactionBegin( @@ -520,6 +967,12 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCommitMsiTransactionComplete( @@ -527,12 +980,23 @@ namespace WixToolset.Mba.Core int hrStatus ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnRollbackMsiTransactionBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnRollbackMsiTransactionComplete( @@ -540,28 +1004,54 @@ namespace WixToolset.Mba.Core int hrStatus ); + /// + /// See . + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPauseAutomaticUpdatesBegin( ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPauseAutomaticUpdatesComplete( int hrStatus ); + /// + /// See . + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnSystemRestorePointBegin( ); + /// + /// See . + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnSystemRestorePointComplete( int hrStatus ); + /// + /// Low level method that is called directly from the engine. + /// + /// + /// + /// + /// + /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int BAProc( @@ -571,6 +1061,14 @@ namespace WixToolset.Mba.Core IntPtr pvContext ); + /// + /// Low level method that is called directly from the engine. + /// + /// + /// + /// + /// + /// void BAProcFallback( int message, IntPtr pvArgs, @@ -585,34 +1083,131 @@ namespace WixToolset.Mba.Core /// public enum Display { + /// + /// + /// Unknown, + + /// + /// + /// Embedded, + + /// + /// + /// None, + + /// + /// + /// Passive, + + /// + /// + /// Full, } /// - /// Messages from Windows Installer. + /// Messages from Windows Installer (msi.h). /// public enum InstallMessage { + /// + /// premature termination, possibly fatal OOM + /// FatalExit, + + /// + /// formatted error message + /// Error = 0x01000000, + + /// + /// formatted warning message + /// Warning = 0x02000000, + + /// + /// user request message + /// User = 0x03000000, + + /// + /// informative message for log + /// Info = 0x04000000, + + /// + /// list of files in use that need to be replaced + /// FilesInUse = 0x05000000, + + /// + /// request to determine a valid source location + /// ResolveSource = 0x06000000, + + /// + /// insufficient disk space message + /// OutOfDiskSpace = 0x07000000, + + /// + /// start of action: action name & description + /// ActionStart = 0x08000000, + + /// + /// formatted data associated with individual action item + /// ActionData = 0x09000000, + + /// + /// progress gauge info: units so far, total + /// Progress = 0x0a000000, + + /// + /// product info for dialog: language Id, dialog caption + /// CommonData = 0x0b000000, + + /// + /// sent prior to UI initialization, no string data + /// Initialize = 0x0c000000, + + /// + /// sent after UI termination, no string data + /// Terminate = 0x0d000000, + + /// + /// sent prior to display or authored dialog or wizard + /// ShowDialog = 0x0e000000, + + /// + /// log only, to log performance number like action time + /// + Performance = 0x0f000000, + + /// + /// the list of apps that the user can request Restart Manager to shut down and restart + /// RMFilesInUse = 0x19000000, + + /// + /// sent prior to server-side install of a product + /// + InstallStart = 0x1a000000, + + /// + /// sent after server-side install + /// + InstallEnd = 0x1B000000, } /// @@ -620,30 +1215,100 @@ namespace WixToolset.Mba.Core /// public enum Restart { + /// + /// + /// Unknown, + + /// + /// + /// Never, + + /// + /// + /// Prompt, + + /// + /// + /// Automatic, + + /// + /// + /// Always, } /// - /// Result codes. + /// Result codes (based on Dialog Box Command IDs from WinUser.h). /// public enum Result { + /// + /// + /// Error = -1, + + /// + /// + /// None, + + /// + /// + /// Ok, + + /// + /// + /// Cancel, + + /// + /// + /// Abort, + + /// + /// + /// Retry, + + /// + /// + /// Ignore, + + /// + /// + /// Yes, + + /// + /// + /// No, + + /// + /// / + /// Close, + + /// + /// + /// Help, + + /// + /// + /// TryAgain, + + /// + /// + /// Continue, } @@ -652,6 +1317,9 @@ namespace WixToolset.Mba.Core /// public enum ResumeType { + /// + /// + /// None, /// @@ -721,8 +1389,14 @@ namespace WixToolset.Mba.Core Apply, }; + /// + /// The calculated operation for the related bundle. + /// public enum RelatedOperation { + /// + /// + /// None, /// @@ -803,12 +1477,39 @@ namespace WixToolset.Mba.Core /// public enum RelationType { + /// + /// + /// None, + + /// + /// + /// Detect, + + /// + /// + /// Upgrade, + + /// + /// + /// Addon, + + /// + /// + /// Patch, + + /// + /// + /// Dependent, + + /// + /// + /// Update, } @@ -840,72 +1541,161 @@ namespace WixToolset.Mba.Core } /// - /// The available actions for OnApplyComplete. + /// The available actions for . /// public enum 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 . + /// Restart, } /// - /// The available actions for OnCacheAcquireComplete. + /// The available actions for . /// public enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION { + /// + /// + /// None, + + /// + /// Instructs the engine to try the acquisition of the package again. + /// Ignored if hrStatus is a success. + /// Retry, } /// - /// The available actions for OnCachePackageComplete. + /// The available actions for . /// public enum 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. + /// Ignore, + + /// + /// Instructs the engine to try the acquisition and verification of the package again. + /// Ignored if hrStatus is a success. + /// Retry, } /// - /// The available actions for OnCacheVerifyComplete. + /// The available actions for . /// public enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION { + /// + /// + /// None, + + /// + /// Ignored if hrStatus is a success. + /// RetryVerification, + + /// + /// Ignored if hrStatus is a success. + /// RetryAcquisition, } /// - /// The available actions for OnExecutePackageComplete. + /// The available actions for . /// public enum 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. + /// Ignore, + + /// + /// Instructs the engine to try the execution of the package again. + /// Ignored if hrStatus is a success. + /// Retry, + + /// + /// Instructs the engine to stop processing the chain and restart. + /// The engine will launch again after the machine is restarted. + /// Restart, + + /// + /// Instructs the engine to stop processing the chain and suspend the current state. + /// Suspend, } /// - /// The available actions for OnResolveSource. + /// The available actions for . /// public enum BOOTSTRAPPER_RESOLVESOURCE_ACTION { + /// + /// Instructs the engine that the source can't be found. + /// None, + + /// + /// Instructs the engine to try the local source again. + /// Retry, + + /// + /// Instructs the engine to try the download source. + /// Download, } /// - /// The available actions for OnShutdown. + /// The available actions for . /// public enum 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 . + /// 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. + /// ReloadBootstrapper, } diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs index a19a34b5..23a1c8a3 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs @@ -4,9 +4,19 @@ namespace WixToolset.Mba.Core { using System.IO; + /// + /// Interface for BootstrapperApplicationData.xml. + /// public interface IBootstrapperApplicationData { + /// + /// The BootstrapperApplicationData.xml file. + /// FileInfo BADataFile { get; } + + /// + /// The BA manifest. + /// IBundleInfo Bundle { get; } } } \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs index b9c62a99..0f9193d0 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -6,12 +6,20 @@ namespace WixToolset.Mba.Core using System.CodeDom.Compiler; using System.Runtime.InteropServices; + /// + /// Interface used by WixToolset.Mba.Host to dynamically load the BA. + /// [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("2965A12F-AC7B-43A0-85DF-E4B2168478A4")] [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] public interface IBootstrapperApplicationFactory { + /// + /// Low level method called by the native host. + /// + /// + /// void Create( IntPtr pArgs, IntPtr pResults @@ -21,7 +29,7 @@ namespace WixToolset.Mba.Core [Serializable] [StructLayout(LayoutKind.Sequential)] [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] - public struct Command + internal struct Command { // Strings must be declared as pointers so that Marshaling doesn't free them. [MarshalAs(UnmanagedType.I4)] internal int cbSize; @@ -55,25 +63,4 @@ namespace WixToolset.Mba.Core Marshal.PtrToStringUni(this.wzBootstrapperApplicationDataPath)); } } - - [Serializable] - [StructLayout(LayoutKind.Sequential)] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] - 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; - } - } } diff --git a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs index 889db529..e861813f 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs @@ -33,6 +33,9 @@ namespace WixToolset.Mba.Core /// The command line could not be parsed into an array. string[] CommandLineArgs { get; } + /// + /// Hint for the initial visibility of the window. + /// int CmdShow { get; } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index 5cc42071..ddf223df 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -16,16 +16,33 @@ namespace WixToolset.Mba.Core [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] public interface IBootstrapperEngine { + /// + /// See . + /// + /// void GetPackageCount( [MarshalAs(UnmanagedType.U4)] out int pcPackages ); + /// + /// See . + /// + /// + /// + /// [PreserveSig] int GetVariableNumeric( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, out long pllValue ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] int GetVariableString( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, @@ -33,6 +50,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ref int pcchValue ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] int GetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, @@ -40,6 +64,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ref int pcchValue ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] int FormatString( [MarshalAs(UnmanagedType.LPWStr)] string wzIn, @@ -47,6 +78,13 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ref int pcchOut ); + /// + /// See . + /// + /// + /// + /// + /// [PreserveSig] int EscapeString( [MarshalAs(UnmanagedType.LPWStr)] string wzIn, @@ -54,16 +92,33 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ref int pcchOut ); + /// + /// See . + /// + /// + /// void EvaluateCondition( [MarshalAs(UnmanagedType.LPWStr)] string wzCondition, [MarshalAs(UnmanagedType.Bool)] out bool pf ); + /// + /// See . + /// + /// + /// void Log( [MarshalAs(UnmanagedType.U4)] LogLevel level, [MarshalAs(UnmanagedType.LPWStr)] string wzMessage ); + /// + /// See . + /// + /// + /// + /// + /// void SendEmbeddedError( [MarshalAs(UnmanagedType.U4)] int dwErrorCode, [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, @@ -71,12 +126,27 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.I4)] out int pnResult ); + /// + /// See . + /// + /// + /// + /// void SendEmbeddedProgress( [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, [MarshalAs(UnmanagedType.U4)] int dwOverallProgressPercentage, [MarshalAs(UnmanagedType.I4)] out int pnResult ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// void SetUpdate( [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, @@ -86,12 +156,26 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] int cbHash ); + /// + /// See . + /// + /// + /// + /// void SetLocalSource( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, [MarshalAs(UnmanagedType.LPWStr)] string wzPath ); + /// + /// See . + /// + /// + /// + /// + /// + /// void SetDownloadSource( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, @@ -100,45 +184,92 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzPassword ); + /// + /// See . + /// + /// + /// void SetVariableNumeric( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, long llValue ); + /// + /// See . + /// + /// + /// + /// void SetVariableString( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, IntPtr wzValue, [MarshalAs(UnmanagedType.Bool)] bool fFormatted ); + /// + /// See . + /// + /// + /// void SetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, IntPtr wzValue ); + /// + /// See . + /// void CloseSplashScreen(); + /// + /// See . + /// + /// void Detect( IntPtr hwndParent ); + /// + /// See . + /// + /// void Plan( [MarshalAs(UnmanagedType.U4)] LaunchAction action ); + /// + /// See . + /// + /// + /// [PreserveSig] int Elevate( IntPtr hwndParent ); + /// + /// See . + /// + /// void Apply( IntPtr hwndParent ); + /// + /// See . + /// + /// void Quit( [MarshalAs(UnmanagedType.U4)] int dwExitCode ); + /// + /// See . + /// + /// + /// + /// + /// void LaunchApprovedExe( IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string wzApprovedExeForElevationId, @@ -146,6 +277,12 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout ); + /// + /// See . + /// + /// + /// + /// void CompareVersions( [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, @@ -158,14 +295,49 @@ namespace WixToolset.Mba.Core /// public enum ActionState { + /// + /// + /// None, + + /// + /// + /// Uninstall, + + /// + /// + /// Install, + + /// + /// + /// AdminInstall, + + /// + /// + /// Modify, + + /// + /// + /// Repair, + + /// + /// + /// MinorUpgrade, + + /// + /// + /// MajorUpgrade, + + /// + /// + /// Patch, } @@ -174,15 +346,54 @@ namespace WixToolset.Mba.Core /// public enum LaunchAction { + /// + /// + /// Unknown, + + /// + /// + /// Help, + + /// + /// + /// Layout, + + /// + /// + /// Uninstall, + + /// + /// + /// Cache, + + /// + /// + /// Install, + + /// + /// + /// Modify, + + /// + /// + /// Repair, + + /// + /// + /// UpdateReplace, + + /// + /// + /// UpdateReplaceEmbedded, } @@ -238,11 +449,34 @@ namespace WixToolset.Mba.Core /// public enum PackageState { + /// + /// + /// Unknown, + + /// + /// + /// Obsolete, + + /// + /// + /// Absent, + + /// + /// + /// Cached, + + /// + /// + /// Present, + + /// + /// + /// Superseded, } @@ -251,11 +485,34 @@ namespace WixToolset.Mba.Core /// public enum RequestState { + /// + /// + /// None, + + /// + /// / + /// ForceAbsent, + + /// + /// + /// Absent, + + /// + /// + /// Cache, + + /// + /// + /// Present, + + /// + /// + /// Repair, } @@ -264,10 +521,29 @@ namespace WixToolset.Mba.Core /// public enum FeatureState { + /// + /// + /// Unknown, + + /// + /// + /// Absent, + + /// + /// + /// Advertised, + + /// + /// + /// Local, + + /// + /// + /// Source, } @@ -276,12 +552,39 @@ namespace WixToolset.Mba.Core /// public enum FeatureAction { + /// + /// + /// None, + + /// + /// + /// AddLocal, + + /// + /// + /// AddSource, + + /// + /// + /// AddDefault, + + /// + /// + /// Reinstall, + + /// + /// + /// Advertise, + + /// + /// + /// Remove, } } diff --git a/src/WixToolset.Mba.Core/IBundleInfo.cs b/src/WixToolset.Mba.Core/IBundleInfo.cs index d471c677..f4a82f36 100644 --- a/src/WixToolset.Mba.Core/IBundleInfo.cs +++ b/src/WixToolset.Mba.Core/IBundleInfo.cs @@ -4,13 +4,36 @@ namespace WixToolset.Mba.Core { using System.Collections.Generic; + /// + /// BA manifest data. + /// public interface IBundleInfo { + /// + /// + /// string LogVariable { get; } + + /// + /// + /// string Name { get; } + + /// + /// + /// IDictionary Packages { get; } + + /// + /// + /// bool PerMachine { get; } + /// + /// Adds a related bundle as a package. + /// + /// + /// The created . IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); } } \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 4a30da7e..b7e4759c 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -4,73 +4,351 @@ namespace WixToolset.Mba.Core { using System; + /// + /// Interface for built-in implementation of . + /// public interface IDefaultBootstrapperApplication : IBootstrapperApplication { + /// + /// Fired when the engine has begun installing the bundle. + /// event EventHandler ApplyBegin; + + /// + /// Fired when the engine has completed installing the bundle. + /// event EventHandler ApplyComplete; + + /// + /// Fired when the engine is about to begin an MSI transaction. + /// event EventHandler BeginMsiTransactionBegin; + + /// + /// Fired when the engine has completed beginning an MSI transaction. + /// event EventHandler BeginMsiTransactionComplete; + + /// + /// Fired when the engine has begun acquiring the installation sources. + /// event EventHandler CacheAcquireBegin; + + /// + /// Fired when the engine has completed the acquisition of the installation sources. + /// event EventHandler CacheAcquireComplete; + + /// + /// Fired when the engine has progress acquiring the installation sources. + /// event EventHandler CacheAcquireProgress; + + /// + /// Fired when the engine has begun caching the installation sources. + /// event EventHandler CacheBegin; + + /// + /// Fired after the engine has cached the installation sources. + /// event EventHandler CacheComplete; + + /// + /// Fired when the engine has begun caching a specific package. + /// event EventHandler CachePackageBegin; + + /// + /// Fired when the engine has completed caching a specific package. + /// event EventHandler CachePackageComplete; + + /// + /// Fired when the engine begins the verification of the acquired installation sources. + /// event EventHandler CacheVerifyBegin; + + /// + /// Fired when the engine complete the verification of the acquired installation sources. + /// event EventHandler CacheVerifyComplete; + + /// + /// Fired when the engine is about to commit an MSI transaction. + /// event EventHandler CommitMsiTransactionBegin; + + /// + /// Fired when the engine has completed comitting an MSI transaction. + /// event EventHandler CommitMsiTransactionComplete; + + /// + /// Fired when the overall detection phase has begun. + /// event EventHandler DetectBegin; + + /// + /// Fired when a package was not detected but a package using the same provider key was. + /// event EventHandler DetectCompatibleMsiPackage; + + /// + /// Fired when the detection phase has completed. + /// event EventHandler DetectComplete; + + /// + /// Fired when a forward compatible bundle is detected. + /// event EventHandler DetectForwardCompatibleBundle; + + /// + /// Fired when a feature in an MSI package has been detected. + /// event EventHandler DetectMsiFeature; + + /// + /// Fired when the detection for a specific package has begun. + /// event EventHandler DetectPackageBegin; + + /// + /// Fired when the detection for a specific package has completed. + /// event EventHandler DetectPackageComplete; + + /// + /// Fired when a related bundle has been detected for a bundle. + /// event EventHandler DetectRelatedBundle; + + /// + /// Fired when a related MSI package has been detected for a package. + /// event EventHandler DetectRelatedMsiPackage; + + /// + /// Fired when an MSP package detects a target MSI has been detected. + /// event EventHandler DetectTargetMsiPackage; + + /// + /// Fired when the update detection has found a potential update candidate. + /// event EventHandler DetectUpdate; + + /// + /// Fired when the update detection phase has begun. + /// event EventHandler DetectUpdateBegin; + + /// + /// Fired when the update detection phase has completed. + /// event EventHandler DetectUpdateComplete; + + /// + /// Fired when the engine is about to start the elevated process. + /// event EventHandler ElevateBegin; + + /// + /// Fired when the engine has completed starting the elevated process. + /// event EventHandler ElevateComplete; + + /// + /// Fired when the engine has encountered an error. + /// event EventHandler Error; + + /// + /// Fired when the engine has begun installing packages. + /// event EventHandler ExecuteBegin; + + /// + /// Fired when the engine has completed installing packages. + /// event EventHandler ExecuteComplete; + + /// + /// Fired when Windows Installer sends a files in use installation message. + /// event EventHandler ExecuteFilesInUse; + + /// + /// Fired when Windows Installer sends an installation message. + /// event EventHandler ExecuteMsiMessage; + + /// + /// Fired when the engine has begun installing a specific package. + /// event EventHandler ExecutePackageBegin; + + /// + /// Fired when the engine has completed installing a specific package. + /// event EventHandler ExecutePackageComplete; + + /// + /// Fired when the engine executes one or more patches targeting a product. + /// event EventHandler ExecutePatchTarget; + + /// + /// Fired by the engine while executing on payload. + /// event EventHandler ExecuteProgress; + + /// + /// Fired when the engine is about to launch the preapproved executable. + /// event EventHandler LaunchApprovedExeBegin; + + /// + /// Fired when the engine has completed launching the preapproved executable. + /// event EventHandler LaunchApprovedExeComplete; + + /// + /// Fired when the engine is about to pause Windows automatic updates. + /// event EventHandler PauseAutomaticUpdatesBegin; + + /// + /// Fired when the engine has completed pausing Windows automatic updates. + /// event EventHandler PauseAutomaticUpdatesComplete; + + /// + /// Fired when the engine has begun planning the installation. + /// event EventHandler PlanBegin; + + /// + /// Fired when the engine plans a new, compatible package using the same provider key. + /// event EventHandler PlanCompatibleMsiPackageBegin; + + /// + /// Fired when the engine has completed planning the installation of a specific package. + /// event EventHandler PlanCompatibleMsiPackageComplete; + + /// + /// Fired when the engine has completed planning the installation. + /// event EventHandler PlanComplete; + + /// + /// Fired when the engine is about to plan a feature in an MSI package. + /// event EventHandler PlanMsiFeature; + + /// + /// Fired when the engine is planning an MSI or MSP package. + /// event EventHandler PlanMsiPackage; + + /// + /// Fired when the engine has begun planning the installation of a specific package. + /// event EventHandler PlanPackageBegin; + + /// + /// Fired when the engine has completed planning the installation of a specific package. + /// event EventHandler PlanPackageComplete; + + /// + /// Fired when the engine has begun planning for a related bundle. + /// event EventHandler PlanRelatedBundle; + + /// + /// Fired when the engine is about to plan the target MSI of a MSP package. + /// event EventHandler PlanTargetMsiPackage; + + /// + /// Fired when the engine has changed progress for the bundle installation. + /// event EventHandler Progress; + + /// + /// Fired when the engine has begun registering the location and visibility of the bundle. + /// event EventHandler RegisterBegin; + + /// + /// Fired when the engine has completed registering the location and visibility of the bundle. + /// event EventHandler RegisterComplete; + + /// + /// Fired by the engine to allow the BA to change the source + /// using or . + /// event EventHandler ResolveSource; + + /// + /// Fired when the engine is about to rollback an MSI transaction. + /// event EventHandler RollbackMsiTransactionBegin; + + /// + /// Fired when the engine has completed rolling back an MSI transaction. + /// event EventHandler RollbackMsiTransactionComplete; + + /// + /// Fired when the engine is shutting down the bootstrapper application. + /// event EventHandler Shutdown; + + /// + /// Fired when the engine is starting up the bootstrapper application. + /// event EventHandler Startup; + + /// + /// Fired when the engine is about to take a system restore point. + /// event EventHandler SystemRestorePointBegin; + + /// + /// Fired when the engine has completed taking a system restore point. + /// event EventHandler SystemRestorePointComplete; + + /// + /// Fired when the system is shutting down or user is logging off. + /// + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// By default setup will prevent shutting down or logging off between + /// and . + /// Derivatives can change this behavior by handling . + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// This event may be fired on a different thread. + /// event EventHandler SystemShutdown; + + /// + /// Fired when the engine has begun removing the registration for the location and visibility of the bundle. + /// event EventHandler UnregisterBegin; + + /// + /// Fired when the engine has completed removing the registration for the location and visibility of the bundle. + /// event EventHandler UnregisterComplete; } } \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 8403352d..0899ec43 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -6,6 +6,9 @@ namespace WixToolset.Mba.Core using System.ComponentModel; using System.Security; + /// + /// High level abstraction over the interface. + /// public interface IEngine { /// diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs index a82e81ea..0d7e549e 100644 --- a/src/WixToolset.Mba.Core/IPackageInfo.cs +++ b/src/WixToolset.Mba.Core/IPackageInfo.cs @@ -2,23 +2,89 @@ namespace WixToolset.Mba.Core { + /// + /// Package information from the BA manifest. + /// public interface IPackageInfo { + /// + /// + /// CacheType CacheType { get; } + + /// + /// Place for the BA to store it's own custom data for this package. + /// object CustomData { get; set; } + + /// + /// + /// string Description { get; } + + /// + /// + /// string DisplayInternalUICondition { get; } + + /// + /// + /// string DisplayName { get; } + + /// + /// + /// string Id { get; } + + /// + /// + /// string InstallCondition { get; } + + /// + /// + /// bool Permanent { get; } + + /// + /// + /// bool PrereqPackage { get; } + + /// + /// + /// string PrereqLicenseFile { get; } + + /// + /// + /// string PrereqLicenseUrl { get; } + + /// + /// + /// string ProductCode { get; } + + /// + /// + /// PackageType Type { get; } + + /// + /// + /// string UpgradeCode { get; } + + /// + /// + /// string Version { get; } + + /// + /// + /// bool Vital { get; } } } \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index d54438f5..75a0fd53 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -7,46 +7,133 @@ namespace WixToolset.Mba.Core using System.Xml; using System.Xml.XPath; + /// + /// + /// public enum CacheType { + /// + /// + /// No, + + /// + /// + /// Yes, + + /// + /// + /// Always, } + /// + /// + /// public enum PackageType { + /// + /// + /// Unknown, + + /// + /// + /// Exe, + + /// + /// + /// Msi, + + /// + /// + /// Msp, + + /// + /// + /// Msu, + + /// + /// + /// UpgradeBundle, + + /// + /// + /// AddonBundle, + + /// + /// + /// PatchBundle, } + /// + /// Default implementation of . + /// public class PackageInfo : IPackageInfo { + /// public string Id { get; internal set; } + + /// public string DisplayName { get; internal set; } + + /// public string Description { get; internal set; } + + /// public PackageType Type { get; internal set; } + + /// public bool Permanent { get; internal set; } + + /// public bool Vital { get; internal set; } + + /// public string DisplayInternalUICondition { get; internal set; } + + /// public string ProductCode { get; internal set; } + + /// public string UpgradeCode { get; internal set; } + + /// public string Version { get; internal set; } + + /// public string InstallCondition { get; internal set; } + + /// public CacheType CacheType { get; internal set; } + + /// public bool PrereqPackage { get; internal set; } + + /// public string PrereqLicenseFile { get; internal set; } + + /// public string PrereqLicenseUrl { get; internal set; } + + /// public object CustomData { get; set; } internal PackageInfo() { } + /// + /// + /// + /// + /// public static IDictionary ParsePackagesFromXml(XPathNavigator root) { var packagesById = new Dictionary(); @@ -105,6 +192,12 @@ namespace WixToolset.Mba.Core return packagesById; } + /// + /// + /// + /// + /// + /// public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) { string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); @@ -128,6 +221,12 @@ namespace WixToolset.Mba.Core } } + /// + /// + /// + /// + /// + /// public static PackageType? GetPackageTypeAttribute(XPathNavigator node, string attributeName) { string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); @@ -159,6 +258,14 @@ namespace WixToolset.Mba.Core } } + /// + /// + /// + /// + /// + /// + /// + /// public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, string version) { PackageInfo package = new PackageInfo(); diff --git a/src/WixToolset.Mba.Core/VerUtil.cs b/src/WixToolset.Mba.Core/VerUtil.cs index dcc9dee2..81c5b716 100644 --- a/src/WixToolset.Mba.Core/VerUtil.cs +++ b/src/WixToolset.Mba.Core/VerUtil.cs @@ -6,6 +6,9 @@ namespace WixToolset.Mba.Core using System.Runtime.InteropServices; using System.Text; + /// + /// Managed wrapper for verutil. + /// public static class VerUtil { [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] @@ -105,18 +108,34 @@ namespace WixToolset.Mba.Core return VerCompareStringVersions(version1, version2, strict); } + /// + /// + /// + /// + /// public static VerUtilVersion CopyVersion(VerUtilVersion version) { var handle = VerCopyVersion(version.GetHandle()); return new VerUtilVersion(handle); } + /// + /// + /// + /// + /// Whether to throw exception on invalid version. + /// public static VerUtilVersion ParseVersion(string version, bool strict) { var handle = VerParseVersion(version, 0, strict); return new VerUtilVersion(handle); } + /// + /// + /// + /// + /// public static VerUtilVersion VersionFromQword(long version) { var handle = VerVersionFromQword(version); diff --git a/src/WixToolset.Mba.Core/VerUtilVersion.cs b/src/WixToolset.Mba.Core/VerUtilVersion.cs index 2b509a21..7408c26f 100644 --- a/src/WixToolset.Mba.Core/VerUtilVersion.cs +++ b/src/WixToolset.Mba.Core/VerUtilVersion.cs @@ -5,6 +5,9 @@ namespace WixToolset.Mba.Core using System; using System.Runtime.InteropServices; + /// + /// An enhanced implementation of SemVer 2.0. + /// public sealed class VerUtilVersion : IDisposable { internal VerUtilVersion(VerUtil.VersionHandle handle) @@ -30,15 +33,48 @@ namespace WixToolset.Mba.Core } } + /// + /// String version, which would have stripped the leading 'v'. + /// public string Version { get; private set; } + + /// + /// For version A.B.C.D, Major is A. It is 0 if not specified. + /// public uint Major { get; private set; } + + /// + /// For version A.B.C.D, Minor is B. It is 0 if not specified. + /// public uint Minor { get; private set; } + + /// + /// For version A.B.C.D, Patch is C. It is 0 if not specified. + /// public uint Patch { get; private set; } + + /// + /// For version A.B.C.D, Revision is D. It is 0 if not specified. + /// public uint Revision { get; private set; } + + /// + /// For version X.Y.Z-releaselabels+metadata, ReleaseLabels is the parsed information for releaselabels. + /// public VerUtilVersionReleaseLabel[] ReleaseLabels { get; private set; } + + /// + /// For version X.Y.Z-releaselabels+metadata, Metadata is the rest of the string after +. + /// For invalid versions, it is all of the string after the point where it was an invalid string. + /// public string Metadata { get; private set; } + + /// + /// Whether the version conformed to the spec. + /// public bool IsInvalid { get; private set; } + /// public void Dispose() { if (this.Handle != null) diff --git a/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs b/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs index 84ff3b36..97e8190d 100644 --- a/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs +++ b/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs @@ -5,6 +5,9 @@ namespace WixToolset.Mba.Core using System; using System.Runtime.InteropServices; + /// + /// A release label from a . + /// public sealed class VerUtilVersionReleaseLabel { internal VerUtilVersionReleaseLabel(IntPtr pReleaseLabel, IntPtr wzVersion) @@ -15,8 +18,19 @@ namespace WixToolset.Mba.Core this.Label = VerUtil.VersionStringFromOffset(wzVersion, releaseLabel.cchLabelOffset, releaseLabel.cchLabel); } + /// + /// Whether the label was parsed as a number. + /// public bool IsNumeric { get; private set; } + + /// + /// If then the value that was parsed. + /// public uint Value { get; private set; } + + /// + /// The string version of the label. + /// public string Label { get; private set; } } } diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 2ca3d2d9..1cfc8c11 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -10,11 +10,7 @@ Managed Bootstrapper Application Core $(MSBuildThisFileName).nuspec true - false - - - - $(OutputPath)\$(AssemblyName).xml + true diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec index cf7d014d..a5e09ea9 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -19,7 +19,9 @@ + + diff --git a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs index 7fe0a405..aaf5ee29 100644 --- a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs +++ b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs @@ -102,6 +102,25 @@ namespace WixToolsetTest.Mba.Core [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 { -- cgit v1.2.3-55-g6feb From 9bcf076a845acfa1f97c40f8cc5c988d4c70af05 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 19 Jan 2021 16:53:10 -0600 Subject: Update dependencies. --- src/balutil/balutil.vcxproj | 8 ++++---- src/balutil/packages.config | 4 ++-- src/bextutil/bextutil.vcxproj | 8 ++++---- src/bextutil/packages.config | 4 ++-- src/mbanative/mbanative.vcxproj | 8 ++++---- src/mbanative/packages.config | 4 ++-- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 8 ++++---- src/test/BalUtilUnitTest/packages.config | 4 ++-- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 8 ++++---- src/test/BextUtilUnitTest/packages.config | 4 ++-- 10 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 4793770a..2a6f4053 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/packages.config b/src/balutil/packages.config index e6716363..15e2e31f 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 2e248d2c..140652c6 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index e6716363..15e2e31f 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index be60f3a9..a8eda0b0 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -94,7 +94,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 46972411..9f0405eb 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index a57c6f01..4e14691e 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -67,7 +67,7 @@ - - + + diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index e3b144e6..cdbde0c8 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index c1cf107c..0c170c02 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -66,7 +66,7 @@ - - + + diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index e3b144e6..cdbde0c8 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From ae1f24b7bbb9c47fb773ecbd7b12632782bd1618 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 19 Jan 2021 17:20:19 -0600 Subject: Remove enums that were removed in the native headers. --- src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 56 -------------------------- 1 file changed, 56 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index ddf223df..e03271ca 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -310,11 +310,6 @@ namespace WixToolset.Mba.Core /// Install, - /// - /// - /// - AdminInstall, - /// /// /// @@ -329,16 +324,6 @@ namespace WixToolset.Mba.Core /// /// MinorUpgrade, - - /// - /// - /// - MajorUpgrade, - - /// - /// - /// - Patch, } /// @@ -546,45 +531,4 @@ namespace WixToolset.Mba.Core /// Source, } - - /// - /// Indicates the action for a feature. - /// - public enum FeatureAction - { - /// - /// - /// - None, - - /// - /// - /// - AddLocal, - - /// - /// - /// - AddSource, - - /// - /// - /// - AddDefault, - - /// - /// - /// - Reinstall, - - /// - /// - /// - Advertise, - - /// - /// - /// - Remove, - } } -- cgit v1.2.3-55-g6feb From e619546617d6266645561428fbbe7a05d257eeba Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 4 Feb 2021 21:19:55 -0600 Subject: Update to latest Burn headers. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 79 +---------- src/WixToolset.Mba.Core/EventArgs.cs | 155 ++------------------- .../IBootstrapperApplication.cs | 70 ++-------- .../IDefaultBootstrapperApplication.cs | 15 -- src/balutil/balutil.vcxproj | 4 +- src/balutil/inc/BAFunctions.h | 3 - src/balutil/inc/BalBaseBAFunctions.h | 38 +---- src/balutil/inc/BalBaseBAFunctionsProc.h | 3 - src/balutil/inc/BalBaseBootstrapperApplication.h | 40 +----- .../inc/BalBaseBootstrapperApplicationProc.h | 38 +---- src/balutil/inc/IBootstrapperApplication.h | 33 +---- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 +- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 +- src/mbanative/packages.config | 2 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 4 +- src/test/BalUtilUnitTest/packages.config | 2 +- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 4 +- src/test/BextUtilUnitTest/packages.config | 2 +- 20 files changed, 40 insertions(+), 464 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 759e76b1..9f4f6330 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -63,9 +63,6 @@ namespace WixToolset.Mba.Core /// public event EventHandler DetectPackageBegin; - - /// - public event EventHandler DetectCompatibleMsiPackage; /// public event EventHandler DetectRelatedMsiPackage; @@ -91,12 +88,6 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanPackageBegin; - /// - public event EventHandler PlanCompatibleMsiPackageBegin; - - /// - public event EventHandler PlanCompatibleMsiPackageComplete; - /// public event EventHandler PlanTargetMsiPackage; @@ -387,19 +378,6 @@ namespace WixToolset.Mba.Core } } - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectCompatibleMsiPackage(DetectCompatibleMsiPackageEventArgs args) - { - EventHandler handler = this.DetectCompatibleMsiPackage; - if (null != handler) - { - handler(this, args); - } - } - /// /// Called by the engine, raises the event. /// @@ -504,32 +482,6 @@ namespace WixToolset.Mba.Core } } - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanCompatibleMsiPackageBegin(PlanCompatibleMsiPackageBeginEventArgs args) - { - EventHandler handler = this.PlanCompatibleMsiPackageBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanCompatibleMsiPackageComplete(PlanCompatibleMsiPackageCompleteEventArgs args) - { - EventHandler handler = this.PlanCompatibleMsiPackageComplete; - if (null != handler) - { - handler(this, args); - } - } - /// /// Called by the engine, raises the event. /// @@ -1209,15 +1161,6 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, ref bool fCancel) - { - DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, fCancel); - this.OnDetectCompatibleMsiPackage(args); - - fCancel = args.Cancel; - return args.HResult; - } - int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) { DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, wzVersion, operation, fCancel); @@ -1253,9 +1196,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectComplete(int hrStatus) + int IBootstrapperApplication.OnDetectComplete(int hrStatus, bool fEligibleForCleanup) { - DetectCompleteEventArgs args = new DetectCompleteEventArgs(hrStatus); + DetectCompleteEventArgs args = new DetectCompleteEventArgs(hrStatus, fEligibleForCleanup); this.OnDetectComplete(args); return args.HResult; @@ -1290,24 +1233,6 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) - { - PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, recommendedState, pRequestedState, fCancel); - this.OnPlanCompatibleMsiPackageBegin(args); - - pRequestedState = args.State; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanCompatibleMsiPackageComplete(string wzPackageId, string wzCompatiblePackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) - { - PlanCompatibleMsiPackageCompleteEventArgs args = new PlanCompatibleMsiPackageCompleteEventArgs(wzPackageId, wzCompatiblePackageId, hrStatus, state, requested, execute, rollback); - this.OnPlanCompatibleMsiPackageComplete(args); - - return args.HResult; - } - int IBootstrapperApplication.OnPlanTargetMsiPackage(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { PlanTargetMsiPackageEventArgs args = new PlanTargetMsiPackageEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 4e59fd6f..2f21b50e 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -488,43 +488,6 @@ namespace WixToolset.Mba.Core public string PackageId { get; private set; } } - /// - /// Additional arguments used when a package was not found but a newer package using the same provider key was. - /// - [Serializable] - public class DetectCompatibleMsiPackageEventArgs : CancellableHResultEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that was not detected. - /// The identity of the compatible package that was detected. - /// The version of the compatible package that was detected. - /// The recommendation from the engine. - public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.CompatiblePackageId = compatiblePackageId; - this.CompatiblePackageVersion = compatiblePackageVersion; - } - - /// - /// Gets the identity of the package that was not detected. - /// - public string PackageId { get; private set; } - - /// - /// Gets the identity of the compatible package that was detected. - /// - public string CompatiblePackageId { get; private set; } - - /// - /// Gets the version of the compatible package that was detected. - /// - public string CompatiblePackageVersion { get; private set; } - } - /// /// Additional arguments used when a related MSI package has been detected for a package. /// @@ -695,10 +658,17 @@ namespace WixToolset.Mba.Core /// Creates a new instance of the class. /// /// The return code of the operation. - public DetectCompleteEventArgs(int hrStatus) + /// + public DetectCompleteEventArgs(int hrStatus, bool eligibleForCleanup) : base(hrStatus) { + this.EligibleForCleanup = eligibleForCleanup; } + + /// + /// Indicates whether the engine will uninstall the bundle if shutdown without running Apply. + /// + public bool EligibleForCleanup { get; private set; } } /// @@ -798,115 +768,6 @@ namespace WixToolset.Mba.Core public RequestState State { get; set; } } - /// - /// Additional arguments used when the engine is about to plan a newer package using the same provider key. - /// - [Serializable] - public class PlanCompatibleMsiPackageBeginEventArgs : CancellableHResultEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that was not detected. - /// The identity of the compatible package that was detected. - /// The version of the compatible package that was detected. - /// The recommended request state for the compatible package. - /// The requested state for the compatible package. - /// The recommendation from the engine. - public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, RequestState recommendedState, RequestState state, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.CompatiblePackageId = compatiblePackageId; - this.CompatiblePackageVersion = compatiblePackageVersion; - this.RecommendedState = recommendedState; - this.State = state; - } - - /// - /// Gets the identity of the package that was not detected. - /// - public string PackageId { get; private set; } - - /// - /// Gets the identity of the compatible package detected. - /// - public string CompatiblePackageId { get; private set; } - - /// - /// Gets the version of the compatible package detected. - /// - public string CompatiblePackageVersion { get; private set; } - - /// - /// Gets the recommended state to use for the compatible package for planning. - /// - public RequestState RecommendedState { get; private set; } - - /// - /// Gets or sets the state to use for the compatible package for planning. - /// - public RequestState State { get; set; } - } - - /// - /// Additional arguments used when the engine has completed planning the installation of a specific package. - /// - [Serializable] - public class PlanCompatibleMsiPackageCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package planned for. - /// The identity of the compatible package that was detected. - /// The return code of the operation. - /// The current state of the package. - /// The requested state for the package - /// The execution action to take. - /// The rollback action to take. - public PlanCompatibleMsiPackageCompleteEventArgs(string packageId, string compatiblePackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) - : base(hrStatus) - { - this.PackageId = packageId; - this.CompatiblePackageId = compatiblePackageId; - this.State = state; - this.Requested = requested; - this.Execute = execute; - this.Rollback = rollback; - } - - /// - /// Gets the identity of the package planned for. - /// - public string PackageId { get; private set; } - - /// - /// Gets the identity of the compatible package detected. - /// - public string CompatiblePackageId { get; private set; } - - /// - /// Gets the current state of the package. - /// - public PackageState State { get; private set; } - - /// - /// Gets the requested state for the package. - /// - public RequestState Requested { get; private set; } - - /// - /// Gets the execution action to take. - /// - public ActionState Execute { get; private set; } - - /// - /// Gets the rollback action to take. - /// - public ActionState Rollback { get; private set; } - } - /// /// Additional arguments used when engine is about to plan a MSP applied to a target MSI package. /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 3c62370a..c1a32ed4 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -170,23 +170,6 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectCompatibleMsiPackage( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - /// /// See . /// @@ -263,11 +246,13 @@ namespace WixToolset.Mba.Core /// See . /// /// + /// /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectComplete( - int hrStatus + int hrStatus, + [MarshalAs(UnmanagedType.Bool)] bool fEligibleForCleanup ); /// @@ -317,50 +302,6 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanCompatibleMsiPackageBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, - [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, - [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanCompatibleMsiPackageComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - int hrStatus, - [MarshalAs(UnmanagedType.U4)] PackageState state, - [MarshalAs(UnmanagedType.U4)] RequestState requested, - [MarshalAs(UnmanagedType.U4)] ActionState execute, - [MarshalAs(UnmanagedType.U4)] ActionState rollback - ); - /// /// See . /// @@ -1697,6 +1638,11 @@ namespace WixToolset.Mba.Core /// Typically used to switch from a native bootstrapper application to a managed one. /// ReloadBootstrapper, + + /// + /// Opts out of the engine behavior of trying to uninstall itself when no non-permanent packages are installed. + /// + SkipCleanup, } /// diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index b7e4759c..9970dc3e 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -89,11 +89,6 @@ namespace WixToolset.Mba.Core /// event EventHandler DetectBegin; - /// - /// Fired when a package was not detected but a package using the same provider key was. - /// - event EventHandler DetectCompatibleMsiPackage; - /// /// Fired when the detection phase has completed. /// @@ -229,16 +224,6 @@ namespace WixToolset.Mba.Core /// event EventHandler PlanBegin; - /// - /// Fired when the engine plans a new, compatible package using the same provider key. - /// - event EventHandler PlanCompatibleMsiPackageBegin; - - /// - /// Fired when the engine has completed planning the installation of a specific package. - /// - event EventHandler PlanCompatibleMsiPackageComplete; - /// /// Fired when the engine has completed planning the installation. /// diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 2a6f4053..702a25c0 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -98,7 +98,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index a95b7a03..eb6d96d8 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -22,15 +22,12 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE, BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE, BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 39934128..10334a18 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -164,16 +164,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnDetectCompatibleMsiPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in LPCWSTR /*wzCompatiblePackageVersion*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - virtual STDMETHODIMP OnDetectRelatedMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzUpgradeCode*/, @@ -217,7 +207,8 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnDetectComplete( - __in HRESULT /*hrStatus*/ + __in HRESULT /*hrStatus*/, + __in BOOL /*fEligibleForCleanup*/ ) { return S_OK; @@ -251,31 +242,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in LPCWSTR /*wzCompatiblePackageVersion*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanCompatibleMsiPackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, - __in BOOTSTRAPPER_ACTION_STATE /*execute*/, - __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ - ) - { - return S_OK; - } - virtual STDMETHODIMP OnPlanTargetMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index 69843301..4f0906d2 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -57,15 +57,12 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE: case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE: case BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE: case BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE: case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE: case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: - case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE: case BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE: case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index ad0c60e5..1b0230de 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -167,17 +167,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnDetectCompatibleMsiPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in LPCWSTR /*wzCompatiblePackageVersion*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - virtual STDMETHODIMP OnDetectRelatedMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzUpgradeCode*/, @@ -224,7 +213,8 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnDetectComplete( - __in HRESULT /*hrStatus*/ + __in HRESULT /*hrStatus*/, + __in BOOL /*fEligibleForCleanup*/ ) { return S_OK; @@ -261,32 +251,6 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in LPCWSTR /*wzCompatiblePackageVersion*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanCompatibleMsiPackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, - __in BOOTSTRAPPER_ACTION_STATE /*execute*/, - __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ - ) - { - return S_OK; - } - virtual STDMETHODIMP OnPlanTargetMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 648252b5..e16640e5 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -24,7 +24,7 @@ static HRESULT BalBaseBAProcOnDetectComplete( __inout BA_ONDETECTCOMPLETE_RESULTS* /*pResults*/ ) { - return pBA->OnDetectComplete(pArgs->hrStatus); + return pBA->OnDetectComplete(pArgs->hrStatus, pArgs->fEligibleForCleanup); } static HRESULT BalBaseBAProcOnPlanBegin( @@ -126,15 +126,6 @@ static HRESULT BalBaseBAProcOnDetectPackageBegin( 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, @@ -189,24 +180,6 @@ static HRESULT BalBaseBAProcOnPlanPackageBegin( return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->recommendedState, &pResults->requestedState, &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->recommendedState, &pResults->requestedState, &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->state, pArgs->requested, pArgs->execute, pArgs->rollback); -} - static HRESULT BalBaseBAProcOnPlanTargetMsiPackage( __in IBootstrapperApplication* pBA, __in BA_ONPLANTARGETMSIPACKAGE_ARGS* pArgs, @@ -662,9 +635,6 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN: hr = BalBaseBAProcOnDetectPackageBegin(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_ONDETECTRELATEDMSIPACKAGE: hr = BalBaseBAProcOnDetectRelatedMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; @@ -683,12 +653,6 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: hr = BalBaseBAProcOnPlanPackageBegin(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_ONPLANTARGETMSIPACKAGE: hr = BalBaseBAProcOnPlanTargetMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index dd8f8024..4569cdab 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -80,14 +80,6 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnDetectCompatibleMsiPackage - called when the engine detects that a package is not installed but a newer package using the same provider key is. - STDMETHOD(OnDetectCompatibleMsiPackage)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzCompatiblePackageId, - __in_z LPCWSTR wzCompatiblePackageVersion, - __inout BOOL* pfCancel - ) = 0; - // OnDetectRelatedMsiPackage - called when the engine begins detects a related package. STDMETHOD(OnDetectRelatedMsiPackage)( __in_z LPCWSTR wzPackageId, @@ -127,7 +119,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // OnDetectPackageComplete - called after the engine completes detection. // STDMETHOD(OnDetectComplete)( - __in HRESULT hrStatus + __in HRESULT hrStatus, + __in BOOL fEligibleForCleanup ) = 0; // OnPlanBegin - called when the engine begins planning. @@ -152,28 +145,6 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnPlanCompatibleMsiPackageBegin - called when the engine plans a newer, compatible package using the same provider key. - STDMETHOD(OnPlanCompatibleMsiPackageBegin)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzCompatiblePackageId, - __in_z LPCWSTR wzCompatiblePackageVersion, - __in BOOTSTRAPPER_REQUEST_STATE recommendedState, - __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, - __inout BOOL* pfCancel - ) = 0; - - // OnPlanCompatibleMsiPackageComplete - called after the engine plans the package. - // - STDMETHOD(OnPlanCompatibleMsiPackageComplete)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzCompatiblePackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_PACKAGE_STATE state, - __in BOOTSTRAPPER_REQUEST_STATE requested, - __in BOOTSTRAPPER_ACTION_STATE execute, - __in BOOTSTRAPPER_ACTION_STATE rollback - ) = 0; - // OnPlanTargetMsiPackage - called when the engine plans an MSP package // to apply to an MSI package. STDMETHOD(OnPlanTargetMsiPackage)( diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 15e2e31f..9a928742 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 140652c6..f81ce469 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -87,7 +87,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 15e2e31f..9a928742 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index a8eda0b0..7132cf1a 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,7 +5,7 @@ - + @@ -94,7 +94,7 @@ - + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 9f0405eb..b60fbb82 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 4e14691e..5f250d39 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -4,7 +4,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index cdbde0c8..273ae5d9 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index 0c170c02..c648b86b 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -4,7 +4,7 @@ - + @@ -66,7 +66,7 @@ - + diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index cdbde0c8..273ae5d9 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 022beff26b46c7808eefacfebccfc1fcb5aa5256 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 22 Feb 2021 20:25:55 -0600 Subject: Integrate patch related changes in Burn headers. --- appveyor.cmd | 2 +- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 60 +++++++--- src/WixToolset.Mba.Core/EventArgs.cs | 126 +++++++++++++-------- .../IBootstrapperApplication.cs | 31 +++-- .../IDefaultBootstrapperApplication.cs | 27 +++-- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BAFunctions.h | 5 +- src/balutil/inc/BalBaseBAFunctions.h | 16 ++- src/balutil/inc/BalBaseBAFunctionsProc.h | 5 +- src/balutil/inc/BalBaseBootstrapperApplication.h | 16 ++- .../inc/BalBaseBootstrapperApplicationProc.h | 40 ++++--- src/balutil/inc/IBootstrapperApplication.h | 29 +++-- src/balutil/packages.config | 4 +- src/bextutil/bextutil.vcxproj | 8 +- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 12 +- src/mbanative/packages.config | 4 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 12 +- src/test/BalUtilUnitTest/packages.config | 4 +- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 12 +- src/test/BextUtilUnitTest/packages.config | 4 +- 21 files changed, 271 insertions(+), 158 deletions(-) (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 3b170ad4..19c2d49f 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -19,7 +19,7 @@ dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.M msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b -msbuild -t:Pack -p:Configuration=%_C% src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b +msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b @popd @endlocal \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 9f4f6330..43e69e81 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -68,7 +68,7 @@ namespace WixToolset.Mba.Core public event EventHandler DetectRelatedMsiPackage; /// - public event EventHandler DetectTargetMsiPackage; + public event EventHandler DetectPatchTarget; /// public event EventHandler DetectMsiFeature; @@ -89,7 +89,7 @@ namespace WixToolset.Mba.Core public event EventHandler PlanPackageBegin; /// - public event EventHandler PlanTargetMsiPackage; + public event EventHandler PlanPatchTarget; /// public event EventHandler PlanMsiFeature; @@ -100,6 +100,9 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanPackageComplete; + /// + public event EventHandler PlannedPackage; + /// public event EventHandler PlanComplete; @@ -392,12 +395,12 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine, raises the event. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - protected virtual void OnDetectTargetMsiPackage(DetectTargetMsiPackageEventArgs args) + protected virtual void OnDetectPatchTarget(DetectPatchTargetEventArgs args) { - EventHandler handler = this.DetectTargetMsiPackage; + EventHandler handler = this.DetectPatchTarget; if (null != handler) { handler(this, args); @@ -483,12 +486,12 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine, raises the event. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - protected virtual void OnPlanTargetMsiPackage(PlanTargetMsiPackageEventArgs args) + protected virtual void OnPlanPatchTarget(PlanPatchTargetEventArgs args) { - EventHandler handler = this.PlanTargetMsiPackage; + EventHandler handler = this.PlanPatchTarget; if (null != handler) { handler(this, args); @@ -534,6 +537,19 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlannedPackage(PlannedPackageEventArgs args) + { + EventHandler handler = this.PlannedPackage; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called by the engine, raises the event. /// @@ -1170,10 +1186,10 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectTargetMsiPackage(string wzPackageId, string wzProductCode, PackageState patchState, ref bool fCancel) + int IBootstrapperApplication.OnDetectPatchTarget(string wzPackageId, string wzProductCode, PackageState patchState, ref bool fCancel) { - DetectTargetMsiPackageEventArgs args = new DetectTargetMsiPackageEventArgs(wzPackageId, wzProductCode, patchState, fCancel); - this.OnDetectTargetMsiPackage(args); + DetectPatchTargetEventArgs args = new DetectPatchTargetEventArgs(wzPackageId, wzProductCode, patchState, fCancel); + this.OnDetectPatchTarget(args); fCancel = args.Cancel; return args.HResult; @@ -1223,9 +1239,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, PackageState state, bool fInstallCondition, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { - PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, recommendedState, pRequestedState, fCancel); + PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, state, fInstallCondition, recommendedState, pRequestedState, fCancel); this.OnPlanPackageBegin(args); pRequestedState = args.State; @@ -1233,10 +1249,10 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanTargetMsiPackage(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + int IBootstrapperApplication.OnPlanPatchTarget(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { - PlanTargetMsiPackageEventArgs args = new PlanTargetMsiPackageEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); - this.OnPlanTargetMsiPackage(args); + PlanPatchTargetEventArgs args = new PlanPatchTargetEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); + this.OnPlanPatchTarget(args); pRequestedState = args.State; fCancel = args.Cancel; @@ -1265,14 +1281,22 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanPackageComplete(string wzPackageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) + int IBootstrapperApplication.OnPlanPackageComplete(string wzPackageId, int hrStatus, RequestState requested) { - var args = new PlanPackageCompleteEventArgs(wzPackageId, hrStatus, state, requested, execute, rollback); + var args = new PlanPackageCompleteEventArgs(wzPackageId, hrStatus, requested); this.OnPlanPackageComplete(args); return args.HResult; } + int IBootstrapperApplication.OnPlannedPackage(string wzPackageId, ActionState execute, ActionState rollback) + { + var args = new PlannedPackageEventArgs(wzPackageId, execute, rollback); + this.OnPlannedPackage(args); + + return args.HResult; + } + int IBootstrapperApplication.OnPlanComplete(int hrStatus) { PlanCompleteEventArgs args = new PlanCompleteEventArgs(hrStatus); diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 2f21b50e..953e31ee 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -547,18 +547,18 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when a target MSI package has been detected. + /// Event arguments for /// - public class DetectTargetMsiPackageEventArgs : CancellableHResultEventArgs + public class DetectPatchTargetEventArgs : CancellableHResultEventArgs { /// - /// Creates a new instance of the class. + /// /// - /// Detected package identifier. - /// Detected product code. - /// Package state detected. - /// The recommendation from the engine. - public DetectTargetMsiPackageEventArgs(string packageId, string productCode, PackageState state, bool cancelRecommendation) + /// + /// + /// + /// + public DetectPatchTargetEventArgs(string packageId, string productCode, PackageState state, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; @@ -567,17 +567,17 @@ namespace WixToolset.Mba.Core } /// - /// Gets the identity of the target's package detected. + /// Gets the identity of the patch's package. /// public string PackageId { get; private set; } /// - /// Gets the product code of the target MSI detected. + /// Gets the product code of the target. /// public string ProductCode { get; private set; } /// - /// Gets the detected patch package state. + /// Gets the detected patch state for the target. /// public PackageState State { get; private set; } } @@ -732,22 +732,26 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun planning the installation of a specific package. + /// Event arguments for /// [Serializable] public class PlanPackageBeginEventArgs : CancellableHResultEventArgs { /// - /// Creates a new instance of the class. + /// /// - /// The identity of the package to plan for. - /// The recommended requested state for the package. - /// The requested state for the package. - /// The recommendation from the engine. - public PlanPackageBeginEventArgs(string packageId, RequestState recommendedState, RequestState state, bool cancelRecommendation) + /// + /// + /// + /// + /// + /// + public PlanPackageBeginEventArgs(string packageId, PackageState currentState, bool installCondition, RequestState recommendedState, RequestState state, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; + this.CurrentState = currentState; + this.InstallCondition = installCondition; this.RecommendedState = recommendedState; this.State = state; } @@ -757,6 +761,16 @@ namespace WixToolset.Mba.Core /// public string PackageId { get; private set; } + /// + /// Gets the current state of the package. + /// + public PackageState CurrentState { get; private set; } + + /// + /// Gets the evaluated result of the package's install condition. + /// + public bool InstallCondition { get; private set; } + /// /// Gets the recommended requested state for the package. /// @@ -769,20 +783,20 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when engine is about to plan a MSP applied to a target MSI package. + /// Event arguments for /// [Serializable] - public class PlanTargetMsiPackageEventArgs : CancellableHResultEventArgs + public class PlanPatchTargetEventArgs : CancellableHResultEventArgs { /// - /// Creates a new instance of the class. + /// /// - /// Package identifier of the patch being planned. - /// Product code identifier being planned. - /// Recommended package state of the patch being planned. - /// Package state of the patch being planned. - /// The recommendation from the engine. - public PlanTargetMsiPackageEventArgs(string packageId, string productCode, RequestState recommendedState, RequestState state, bool cancelRecommendation) + /// + /// + /// + /// + /// + public PlanPatchTargetEventArgs(string packageId, string productCode, RequestState recommendedState, RequestState state, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; @@ -792,22 +806,22 @@ namespace WixToolset.Mba.Core } /// - /// Gets the identity of the patch package to plan. + /// Gets the identity of the patch's package. /// public string PackageId { get; private set; } /// - /// Gets the identity of the patch's target MSI to plan. + /// Gets the product code of the target. /// public string ProductCode { get; private set; } /// - /// Gets the recommended state of the patch to use by planning. + /// Gets the recommended state of the patch to use by planning for the target. /// public RequestState RecommendedState { get; private set; } /// - /// Gets or sets the state of the patch to use by planning. + /// Gets or sets the state of the patch to use by planning for the target. /// public RequestState State { get; set; } } @@ -915,28 +929,22 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when then engine has completed planning the installation of a specific package. + /// Event arguments for /// [Serializable] public class PlanPackageCompleteEventArgs : StatusEventArgs { /// - /// Creates a new instance of the class. + /// /// - /// The identity of the package planned for. - /// The return code of the operation. - /// The current state of the package. - /// The requested state for the package - /// The execution action to take. - /// The rollback action to take. - public PlanPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state, RequestState requested, ActionState execute, ActionState rollback) + /// + /// + /// + public PlanPackageCompleteEventArgs(string packageId, int hrStatus, RequestState requested) : base(hrStatus) { this.PackageId = packageId; - this.State = state; this.Requested = requested; - this.Execute = execute; - this.Rollback = rollback; } /// @@ -945,22 +953,42 @@ namespace WixToolset.Mba.Core public string PackageId { get; private set; } /// - /// Gets the current state of the package. + /// Gets the requested state for the package. /// - public PackageState State { get; private set; } + public RequestState Requested { get; private set; } + } + /// + /// Event arguments for + /// + [Serializable] + public class PlannedPackageEventArgs : HResultEventArgs + { /// - /// Gets the requested state for the package. + /// /// - public RequestState Requested { get; private set; } + /// + /// + /// + public PlannedPackageEventArgs(string packageId, ActionState execute, ActionState rollback) + { + this.PackageId = packageId; + this.Execute = execute; + this.Rollback = rollback; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } /// - /// Gets the execution action to take. + /// Gets the planned execution action. /// public ActionState Execute { get; private set; } /// - /// Gets the rollback action to take. + /// Gets the planned rollback action. /// public ActionState Rollback { get; private set; } } diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index c1a32ed4..7ff243d2 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -194,7 +194,7 @@ namespace WixToolset.Mba.Core ); /// - /// See . + /// See . /// /// /// @@ -203,7 +203,7 @@ namespace WixToolset.Mba.Core /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] - int OnDetectTargetMsiPackage( + int OnDetectPatchTarget( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, [MarshalAs(UnmanagedType.U4)] PackageState patchState, @@ -289,6 +289,8 @@ namespace WixToolset.Mba.Core /// See . /// /// + /// + /// /// /// /// @@ -297,13 +299,15 @@ namespace WixToolset.Mba.Core [return: MarshalAs(UnmanagedType.I4)] int OnPlanPackageBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] PackageState state, + [MarshalAs(UnmanagedType.Bool)] bool fInstallCondition, [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// - /// See . + /// See . /// /// /// @@ -313,7 +317,7 @@ namespace WixToolset.Mba.Core /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] - int OnPlanTargetMsiPackage( + int OnPlanPatchTarget( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, @@ -368,18 +372,27 @@ namespace WixToolset.Mba.Core ///
/// /// - /// /// - /// - /// /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanPackageComplete( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, int hrStatus, - [MarshalAs(UnmanagedType.U4)] PackageState state, - [MarshalAs(UnmanagedType.U4)] RequestState requested, + [MarshalAs(UnmanagedType.U4)] RequestState requested + ); + + /// + /// See . + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlannedPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.U4)] ActionState execute, [MarshalAs(UnmanagedType.U4)] ActionState rollback ); diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 9970dc3e..d0518049 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -114,6 +114,11 @@ namespace WixToolset.Mba.Core ///
event EventHandler DetectPackageComplete; + /// + /// Fired when the engine detects a target product for an MSP package. + /// + event EventHandler DetectPatchTarget; + /// /// Fired when a related bundle has been detected for a bundle. /// @@ -124,11 +129,6 @@ namespace WixToolset.Mba.Core ///
event EventHandler DetectRelatedMsiPackage; - /// - /// Fired when an MSP package detects a target MSI has been detected. - /// - event EventHandler DetectTargetMsiPackage; - /// /// Fired when the update detection has found a potential update candidate. /// @@ -229,6 +229,11 @@ namespace WixToolset.Mba.Core ///
event EventHandler PlanComplete; + /// + /// Fired when the engine has completed planning a package. + /// + event EventHandler PlannedPackage; + /// /// Fired when the engine is about to plan a feature in an MSI package. /// @@ -240,24 +245,24 @@ namespace WixToolset.Mba.Core event EventHandler PlanMsiPackage; /// - /// Fired when the engine has begun planning the installation of a specific package. + /// Fired when the engine has begun getting the BA's input for planning a package. /// event EventHandler PlanPackageBegin; /// - /// Fired when the engine has completed planning the installation of a specific package. + /// Fired when the engine has completed getting the BA's input for planning a package. /// event EventHandler PlanPackageComplete; /// - /// Fired when the engine has begun planning for a related bundle. + /// Fired when the engine is about to plan a target of an MSP package. /// - event EventHandler PlanRelatedBundle; + event EventHandler PlanPatchTarget; /// - /// Fired when the engine is about to plan the target MSI of a MSP package. + /// Fired when the engine has begun planning for a related bundle. /// - event EventHandler PlanTargetMsiPackage; + event EventHandler PlanRelatedBundle; /// /// Fired when the engine has changed progress for the bundle installation. diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 702a25c0..578586e8 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index eb6d96d8..6d36ad8c 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -23,12 +23,12 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, - BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONDETECTPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONPLANPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, @@ -72,6 +72,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 10334a18..7699b8ff 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -177,7 +177,7 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnDetectTargetMsiPackage( + virtual STDMETHODIMP OnDetectPatchTarget( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, @@ -234,6 +234,8 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanPackageBegin( __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fInstallCondition*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, __inout BOOL* /*pfCancel*/ @@ -242,7 +244,7 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnPlanTargetMsiPackage( + virtual STDMETHODIMP OnPlanPatchTarget( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, @@ -280,8 +282,14 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanPackageComplete( __in_z LPCWSTR /*wzPackageId*/, __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlannedPackage( + __in_z LPCWSTR /*wzPackageId*/, __in BOOTSTRAPPER_ACTION_STATE /*execute*/, __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ ) diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index 4f0906d2..1b11c300 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -58,12 +58,12 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE: case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN: case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE: - case BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE: + 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_ONPLANTARGETMSIPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONPLANPATCHTARGET: case BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE: case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN: @@ -107,6 +107,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE: case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: + case BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE: hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); break; case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 1b0230de..59e57de1 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -181,7 +181,7 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnDetectTargetMsiPackage( + virtual STDMETHODIMP OnDetectPatchTarget( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, @@ -242,6 +242,8 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanPackageBegin( __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fInstallCondition*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, __inout BOOL* pfCancel @@ -251,7 +253,7 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnPlanTargetMsiPackage( + virtual STDMETHODIMP OnPlanPatchTarget( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, @@ -292,8 +294,14 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanPackageComplete( __in_z LPCWSTR /*wzPackageId*/, __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOTSTRAPPER_REQUEST_STATE /*requested*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlannedPackage( + __in_z LPCWSTR /*wzPackageId*/, __in BOOTSTRAPPER_ACTION_STATE /*execute*/, __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ ) diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index e16640e5..6ce8710d 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -135,13 +135,13 @@ static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage( return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); } -static HRESULT BalBaseBAProcOnDetectTargetMsiPackage( +static HRESULT BalBaseBAProcOnDetectPatchTarget( __in IBootstrapperApplication* pBA, - __in BA_ONDETECTTARGETMSIPACKAGE_ARGS* pArgs, - __inout BA_ONDETECTTARGETMSIPACKAGE_RESULTS* pResults + __in BA_ONDETECTPATCHTARGET_ARGS* pArgs, + __inout BA_ONDETECTPATCHTARGET_RESULTS* pResults ) { - return pBA->OnDetectTargetMsiPackage(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->patchState, &pResults->fCancel); + return pBA->OnDetectPatchTarget(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->patchState, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectMsiFeature( @@ -177,16 +177,16 @@ static HRESULT BalBaseBAProcOnPlanPackageBegin( __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults ) { - return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); + return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->state, pArgs->fInstallCondition, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); } -static HRESULT BalBaseBAProcOnPlanTargetMsiPackage( +static HRESULT BalBaseBAProcOnPlanPatchTarget( __in IBootstrapperApplication* pBA, - __in BA_ONPLANTARGETMSIPACKAGE_ARGS* pArgs, - __inout BA_ONPLANTARGETMSIPACKAGE_RESULTS* pResults + __in BA_ONPLANPATCHTARGET_ARGS* pArgs, + __inout BA_ONPLANPATCHTARGET_RESULTS* pResults ) { - return pBA->OnPlanTargetMsiPackage(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); + return pBA->OnPlanPatchTarget(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); } static HRESULT BalBaseBAProcOnPlanMsiFeature( @@ -204,7 +204,16 @@ static HRESULT BalBaseBAProcOnPlanPackageComplete( __inout BA_ONPLANPACKAGECOMPLETE_RESULTS* /*pResults*/ ) { - return pBA->OnPlanPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state, pArgs->requested, pArgs->execute, pArgs->rollback); + return pBA->OnPlanPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->requested); +} + +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); } static HRESULT BalBaseBAProcOnApplyBegin( @@ -638,8 +647,8 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE: hr = BalBaseBAProcOnDetectRelatedMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE: - hr = BalBaseBAProcOnDetectTargetMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + 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)); @@ -653,8 +662,8 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: hr = BalBaseBAProcOnPlanPackageBegin(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE: - hr = BalBaseBAProcOnPlanTargetMsiPackage(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + 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)); @@ -784,6 +793,9 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( 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; } } diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 4569cdab..7d710b26 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -91,9 +91,9 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnDetectTargetMsiPackage - called when the engine detects a target MSI package for - // an MSP package. - STDMETHOD(OnDetectTargetMsiPackage)( + // OnDetectPatchTarget - called when the engine detects a target product + // for an MSP package. + STDMETHOD(OnDetectPatchTarget)( __in_z LPCWSTR wzPackageId, __in_z LPCWSTR wzProductCode, __in BOOTSTRAPPER_PACKAGE_STATE patchState, @@ -137,17 +137,20 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnPlanPackageBegin - called when the engine begins planning a package. + // OnPlanPackageBegin - called when the engine has begun getting the BA's input + // for planning a package. STDMETHOD(OnPlanPackageBegin)( __in_z LPCWSTR wzPackageId, + __in BOOTSTRAPPER_PACKAGE_STATE state, + __in BOOL fInstallCondition, __in BOOTSTRAPPER_REQUEST_STATE recommendedState, __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, __inout BOOL* pfCancel ) = 0; - // OnPlanTargetMsiPackage - called when the engine plans an MSP package - // to apply to an MSI package. - STDMETHOD(OnPlanTargetMsiPackage)( + // OnPlanPatchTarget - called when the engine is about to plan a target + // of an MSP package. + STDMETHOD(OnPlanPatchTarget)( __in_z LPCWSTR wzPackageId, __in_z LPCWSTR wzProductCode, __in BOOTSTRAPPER_REQUEST_STATE recommendedState, @@ -177,13 +180,17 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfDisableExternalUiHandler ) = 0; - // OnPlanPackageComplete - called after the engine plans a package. - // + // OnPlanPackageComplete - called after the engine has completed getting the BA's input + // for planning a package. STDMETHOD(OnPlanPackageComplete)( __in_z LPCWSTR wzPackageId, __in HRESULT hrStatus, - __in BOOTSTRAPPER_PACKAGE_STATE state, - __in BOOTSTRAPPER_REQUEST_STATE requested, + __in BOOTSTRAPPER_REQUEST_STATE requested + ) = 0; + + // OnPlannedPackage - called after the engine has completed planning a package. + STDMETHOD(OnPlannedPackage)( + __in_z LPCWSTR wzPackageId, __in BOOTSTRAPPER_ACTION_STATE execute, __in BOOTSTRAPPER_ACTION_STATE rollback ) = 0; diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 9a928742..68970a7e 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index f81ce469..44393f94 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 9a928742..68970a7e 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 7132cf1a..eaf95157 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -79,7 +79,9 @@ - + + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} + @@ -94,7 +96,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index b60fbb82..e9fcafcd 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 5f250d39..aad361c1 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -57,7 +57,9 @@ - + + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} + @@ -67,7 +69,7 @@ - - + + diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index 273ae5d9..9e1a6a0e 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index c648b86b..566a2abd 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -56,7 +56,9 @@ - + + {06027492-1CB9-48BC-B31E-C1F9356ED07E} + @@ -66,7 +68,7 @@ - - + + diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index 273ae5d9..9e1a6a0e 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 5f4829e678c9c5cd5e581b0075cfa4a6b263c66e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 2 Mar 2021 15:11:58 -0600 Subject: Integrate OnUnregisterBegin changes in Burn headers. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 6 ++--- src/WixToolset.Mba.Core/EventArgs.cs | 28 +++++++++++++++------- .../IBootstrapperApplication.cs | 6 +++-- .../IDefaultBootstrapperApplication.cs | 4 ++-- src/balutil/balutil.vcxproj | 8 +++---- src/balutil/inc/BalBaseBAFunctions.h | 3 ++- src/balutil/inc/BalBaseBootstrapperApplication.h | 4 ++-- .../inc/BalBaseBootstrapperApplicationProc.h | 4 ++-- src/balutil/inc/IBootstrapperApplication.h | 3 ++- src/balutil/packages.config | 4 ++-- src/bextutil/bextutil.vcxproj | 8 +++---- src/bextutil/packages.config | 4 ++-- src/mbanative/mbanative.vcxproj | 8 +++---- src/mbanative/packages.config | 4 ++-- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 8 +++---- src/test/BalUtilUnitTest/packages.config | 4 ++-- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 8 +++---- src/test/BextUtilUnitTest/packages.config | 4 ++-- 18 files changed, 66 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 43e69e81..1812c80b 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1529,12 +1529,12 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnUnregisterBegin(ref bool fCancel) + int IBootstrapperApplication.OnUnregisterBegin(bool fKeepRegistration, ref bool fForceKeepRegistration) { - UnregisterBeginEventArgs args = new UnregisterBeginEventArgs(fCancel); + UnregisterBeginEventArgs args = new UnregisterBeginEventArgs(fKeepRegistration, fForceKeepRegistration); this.OnUnregisterBegin(args); - fCancel = args.Cancel; + fForceKeepRegistration = args.ForceKeepRegistration; return args.HResult; } diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 953e31ee..56705769 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -1187,31 +1187,41 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun removing the registration for the location and visibility of the bundle. + /// Event arguments for /// [Serializable] - public class UnregisterBeginEventArgs : CancellableHResultEventArgs + public class UnregisterBeginEventArgs : HResultEventArgs { /// - /// Creates a new instance of the class. + /// /// - /// The recommendation from the engine. - public UnregisterBeginEventArgs(bool cancelRecommendation) - : base(cancelRecommendation) + /// + /// + public UnregisterBeginEventArgs(bool keepRegistration, bool forceKeepRegistration) { } + + /// + /// Indicates whether the engine will uninstall the bundle. + /// + public bool ForceKeepRegistration { get; set; } + + /// + /// If is FALSE, then this can be set to TRUE to make the engine keep the bundle installed. + /// + public bool KeepRegistration { get; private set; } } /// - /// Additional arguments used when the engine has completed removing the registration for the location and visibility of the bundle. + /// Event arguments for /// [Serializable] public class UnregisterCompleteEventArgs : StatusEventArgs { /// - /// Creates a new instance of the class. + /// /// - /// The return code of the operation. + /// public UnregisterCompleteEventArgs(int hrStatus) : base(hrStatus) { diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 7ff243d2..4812c038 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -822,12 +822,14 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// + /// + /// /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnUnregisterBegin( - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + [MarshalAs(UnmanagedType.Bool)] bool fKeepRegistration, + [MarshalAs(UnmanagedType.Bool)] ref bool fForceKeepRegistration ); /// diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index d0518049..5803a26a 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -332,12 +332,12 @@ namespace WixToolset.Mba.Core event EventHandler SystemShutdown; /// - /// Fired when the engine has begun removing the registration for the location and visibility of the bundle. + /// Fired when the engine unregisters the bundle. /// event EventHandler UnregisterBegin; /// - /// Fired when the engine has completed removing the registration for the location and visibility of the bundle. + /// Fired when the engine unregistration is complete. /// event EventHandler UnregisterComplete; } diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 578586e8..1c9a2372 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 7699b8ff..55ed8cbe 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -548,7 +548,8 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnUnregisterBegin( - __inout BOOL* /*pfCancel*/ + __in BOOL /*fKeepRegistration*/, + __inout BOOL* /*pfForceKeepRegistration*/ ) { return S_OK; diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 59e57de1..ff1d07fd 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -719,10 +719,10 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnUnregisterBegin( - __inout BOOL* pfCancel + __in BOOL /*fKeepRegistration*/, + __inout BOOL* /*pfForceKeepRegistration*/ ) { - *pfCancel |= CheckCanceled(); return S_OK; } diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 6ce8710d..d971a2eb 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -443,11 +443,11 @@ static HRESULT BalBaseBAProcOnExecuteComplete( static HRESULT BalBaseBAProcOnUnregisterBegin( __in IBootstrapperApplication* pBA, - __in BA_ONUNREGISTERBEGIN_ARGS* /*pArgs*/, + __in BA_ONUNREGISTERBEGIN_ARGS* pArgs, __inout BA_ONUNREGISTERBEGIN_RESULTS* pResults ) { - return pBA->OnUnregisterBegin(&pResults->fCancel); + return pBA->OnUnregisterBegin(pArgs->fKeepRegistration, &pResults->fForceKeepRegistration); } static HRESULT BalBaseBAProcOnUnregisterComplete( diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 7d710b26..01d0bb8a 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -465,7 +465,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // OnUnregisterBegin - called when the engine unregisters the bundle. // STDMETHOD(OnUnregisterBegin)( - __inout BOOL* pfCancel + __in BOOL fKeepRegistration, + __inout BOOL* pfForceKeepRegistration ) = 0; // OnUnregisterComplete - called when the engine unregistration is complete. diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 68970a7e..1ac5d2ac 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 44393f94..99edfaae 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 68970a7e..1ac5d2ac 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index eaf95157..0c67b548 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -96,7 +96,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index e9fcafcd..52a8333b 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index aad361c1..a901712e 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -69,7 +69,7 @@ - - + + diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index 9e1a6a0e..768cc4cc 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index 566a2abd..22e84e9a 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -4,8 +4,8 @@ - - + + Debug @@ -68,7 +68,7 @@ - - + + diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index 9e1a6a0e..768cc4cc 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 4bdf4846de8c96a1c2ad5e9ea791b575e3b0e37d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 3 Mar 2021 22:12:55 -0600 Subject: Rely on the free-threaded marshaler for IBootstrapperEngine marshalling It is the supported way to provide the direct pointer when marshalling, just like we were doing before. #4386 --- src/balutil/BalBootstrapperEngine.cpp | 166 +++------------------------------- 1 file changed, 15 insertions(+), 151 deletions(-) (limited to 'src') diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index 8a78b127..8e40f7ae 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -3,7 +3,7 @@ #include "precomp.h" -class CBalBootstrapperEngine : public IBootstrapperEngine, public IMarshal +class CBalBootstrapperEngine : public IBootstrapperEngine { public: // IUnknown virtual STDMETHODIMP QueryInterface( @@ -24,7 +24,7 @@ public: // IUnknown } else if (::IsEqualIID(IID_IMarshal, riid)) { - *ppvObject = static_cast(this); + return m_pFreeThreadedMarshaler->QueryInterface(riid, ppvObject); } else if (::IsEqualIID(IID_IUnknown, riid)) { @@ -561,158 +561,12 @@ public: // IBootstrapperEngine return hr; } -public: // IMarshal - virtual STDMETHODIMP GetUnmarshalClass( - __in REFIID /*riid*/, - __in_opt LPVOID /*pv*/, - __in DWORD /*dwDestContext*/, - __reserved LPVOID /*pvDestContext*/, - __in DWORD /*mshlflags*/, - __out LPCLSID /*pCid*/ - ) - { - return E_NOTIMPL; - } - - virtual STDMETHODIMP GetMarshalSizeMax( - __in REFIID riid, - __in_opt LPVOID /*pv*/, - __in DWORD dwDestContext, - __reserved LPVOID /*pvDestContext*/, - __in DWORD /*mshlflags*/, - __out DWORD *pSize - ) - { - HRESULT hr = S_OK; - - // We only support marshaling the IBootstrapperEngine interface in-proc. - if (__uuidof(IBootstrapperEngine) != riid) - { - // Skip logging the following message since it appears way too often in the log. - // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface." - ExitFunction1(hr = E_NOINTERFACE); - } - else if (0 == (MSHCTX_INPROC & dwDestContext)) - { - hr = E_FAIL; - ExitOnRootFailure(hr, "Cannot marshal IBootstrapperEngine interface out of proc."); - } - - // E_FAIL is used because E_INVALIDARG is not a supported return value. - ExitOnNull(pSize, hr, E_FAIL, "Invalid size output parameter is NULL."); - - // Specify enough size to marshal just the interface pointer across threads. - *pSize = sizeof(LPVOID); - - LExit: - return hr; - } - - virtual STDMETHODIMP MarshalInterface( - __in IStream* pStm, - __in REFIID riid, - __in_opt LPVOID pv, - __in DWORD dwDestContext, - __reserved LPVOID /*pvDestContext*/, - __in DWORD /*mshlflags*/ - ) - { - HRESULT hr = S_OK; - IBootstrapperEngine *pThis = NULL; - ULONG ulWritten = 0; - - // We only support marshaling the IBootstrapperEngine interface in-proc. - if (__uuidof(IBootstrapperEngine) != riid) - { - // Skip logging the following message since it appears way too often in the log. - // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface." - ExitFunction1(hr = E_NOINTERFACE); - } - else if (0 == (MSHCTX_INPROC & dwDestContext)) - { - hr = E_FAIL; - ExitOnRootFailure(hr, "Cannot marshal IBootstrapperEngine interface out of proc."); - } - - // "pv" may not be set, so we should us "this" otherwise. - if (pv) - { - pThis = reinterpret_cast(pv); - } - else - { - pThis = static_cast(this); - } - - // E_INVALIDARG is not a supported return value. - ExitOnNull(pStm, hr, E_FAIL, "The marshaling stream parameter is NULL."); - - // Marshal the interface pointer in-proc as is. - hr = pStm->Write(pThis, sizeof(pThis), &ulWritten); - if (STG_E_MEDIUMFULL == hr) - { - ExitOnFailure(hr, "Failed to write the stream because the stream is full."); - } - else if (FAILED(hr)) - { - // All other STG error must be converted into E_FAIL based on IMarshal documentation. - hr = E_FAIL; - ExitOnFailure(hr, "Failed to write the IBootstrapperEngine interface pointer to the marshaling stream."); - } - - LExit: - return hr; - } - - virtual STDMETHODIMP UnmarshalInterface( - __in IStream* pStm, - __in REFIID riid, - __deref_out LPVOID* ppv - ) - { - HRESULT hr = S_OK; - ULONG ulRead = 0; - - // We only support marshaling the engine in-proc. - if (__uuidof(IBootstrapperEngine) != riid) - { - // Skip logging the following message since it appears way too often in the log. - // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface." - ExitFunction1(hr = E_NOINTERFACE); - } - - // E_FAIL is used because E_INVALIDARG is not a supported return value. - ExitOnNull(pStm, hr, E_FAIL, "The marshaling stream parameter is NULL."); - ExitOnNull(ppv, hr, E_FAIL, "The interface output parameter is NULL."); - - // Unmarshal the interface pointer in-proc as is. - hr = pStm->Read(*ppv, sizeof(LPVOID), &ulRead); - if (FAILED(hr)) - { - // All STG errors must be converted into E_FAIL based on IMarshal documentation. - hr = E_FAIL; - ExitOnFailure(hr, "Failed to read the IBootstrapperEngine interface pointer from the marshaling stream."); - } - - LExit: - return hr; - } - - virtual STDMETHODIMP ReleaseMarshalData( - __in IStream* /*pStm*/ - ) - { - return E_NOTIMPL; - } - - virtual STDMETHODIMP DisconnectObject( - __in DWORD /*dwReserved*/ - ) +public: + HRESULT Init() { - return E_NOTIMPL; + return ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); } -public: CBalBootstrapperEngine( __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, __in_opt LPVOID pvBAEngineProcContext @@ -721,12 +575,19 @@ public: m_cReferences = 1; m_pfnBAEngineProc = pfnBAEngineProc; m_pvBAEngineProcContext = pvBAEngineProcContext; + m_pFreeThreadedMarshaler = NULL; + } + + ~CBalBootstrapperEngine() + { + ReleaseObject(m_pFreeThreadedMarshaler); } private: long m_cReferences; PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc; LPVOID m_pvBAEngineProcContext; + IUnknown* m_pFreeThreadedMarshaler; }; HRESULT BalBootstrapperEngineCreate( @@ -741,6 +602,9 @@ HRESULT BalBootstrapperEngineCreate( pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext); ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); + hr = pBootstrapperEngine->Init(); + ExitOnFailure(hr, "Failed to initialize CBalBootstrapperEngine."); + hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); -- cgit v1.2.3-55-g6feb From b036b878a6b477158a22e508ee3a9e8f569f5bf4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 11 Mar 2021 19:57:12 -0600 Subject: Integrate ForwardCompatible and RelatedBundle changes in Burn headers. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 34 ++++++-- src/WixToolset.Mba.Core/EventArgs.cs | 97 ++++++++++++++++------ .../IBootstrapperApplication.cs | 33 +++++++- .../IDefaultBootstrapperApplication.cs | 5 ++ src/balutil/balutil.vcxproj | 4 +- src/balutil/inc/BAFunctions.h | 1 + src/balutil/inc/BalBaseBAFunctions.h | 19 ++++- src/balutil/inc/BalBaseBAFunctionsProc.h | 1 + src/balutil/inc/BalBaseBootstrapperApplication.h | 20 ++++- .../inc/BalBaseBootstrapperApplicationProc.h | 16 +++- src/balutil/inc/IBootstrapperApplication.h | 16 +++- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 4 +- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 +- src/mbanative/packages.config | 2 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 4 +- src/test/BalUtilUnitTest/packages.config | 2 +- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 4 +- src/test/BextUtilUnitTest/packages.config | 2 +- 20 files changed, 214 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 1812c80b..b6c0dd0d 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -226,6 +226,9 @@ namespace WixToolset.Mba.Core /// public event EventHandler SystemRestorePointComplete; + /// + public event EventHandler PlanForwardCompatibleBundle; + /// /// Entry point that is called when the bootstrapper application is ready to run. /// @@ -1083,6 +1086,18 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + protected virtual void OnPlanForwardCompatibleBundle(PlanForwardCompatibleBundleEventArgs args) + { + EventHandler handler = this.PlanForwardCompatibleBundle; + if (null != handler) + { + handler(this, args); + } + } + #region IBootstrapperApplication Members int IBootstrapperApplication.OnStartup() @@ -1120,13 +1135,12 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, ref bool fCancel, ref bool fIgnoreBundle) + int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fMissingFromCache, ref bool fCancel) { - DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fCancel, fIgnoreBundle); + DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, fCancel); this.OnDetectForwardCompatibleBundle(args); fCancel = args.Cancel; - fIgnoreBundle = args.IgnoreBundle; return args.HResult; } @@ -1159,9 +1173,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) + int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, bool fMissingFromCache, ref bool fCancel) { - DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fCancel); + DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fMissingFromCache, fCancel); this.OnDetectRelatedBundle(args); fCancel = args.Cancel; @@ -1656,6 +1670,16 @@ namespace WixToolset.Mba.Core return args.HResult; } + int IBootstrapperApplication.OnPlanForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fRecommendedIgnoreBundle, ref bool fCancel, ref bool fIgnoreBundle) + { + PlanForwardCompatibleBundleEventArgs args = new PlanForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fRecommendedIgnoreBundle, fCancel, fIgnoreBundle); + this.OnPlanForwardCompatibleBundle(args); + + fCancel = args.Cancel; + fIgnoreBundle = args.IgnoreBundle; + return args.HResult; + } + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) { switch (message) diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 56705769..7e7cbd11 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -226,22 +226,13 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when detected a forward compatible bundle. + /// Event arguments for /// [Serializable] public class DetectForwardCompatibleBundleEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the forward compatible bundle. - /// Relationship type for this forward compatible bundle. - /// The tag of the forward compatible bundle. - /// Whether the detected forward compatible bundle is per machine. - /// The version of the forward compatible bundle detected. - /// The cancel recommendation from the engine. - /// The ignore recommendation from the engine. - public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool cancelRecommendation, bool ignoreBundleRecommendation) + /// + public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool missingFromCache, bool cancelRecommendation) : base(cancelRecommendation) { this.BundleId = bundleId; @@ -249,7 +240,7 @@ namespace WixToolset.Mba.Core this.BundleTag = bundleTag; this.PerMachine = perMachine; this.Version = version; - this.IgnoreBundle = ignoreBundleRecommendation; + this.MissingFromCache = missingFromCache; } /// @@ -278,9 +269,9 @@ namespace WixToolset.Mba.Core public string Version { get; private set; } /// - /// Instructs the engine whether to use the forward compatible bundle. + /// Whether the forward compatible bundle is missing from the package cache. /// - public bool IgnoreBundle { get; set; } + public bool MissingFromCache { get; set; } } /// @@ -408,22 +399,13 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when a related bundle has been detected for a bundle. + /// Event arguments for /// [Serializable] public class DetectRelatedBundleEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the related package bundle. - /// Relationship type for this related bundle. - /// The tag of the related package bundle. - /// Whether the detected bundle is per machine. - /// The version of the related bundle detected. - /// The operation that will be taken on the detected bundle. - /// The recommendation from the engine. - public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) + /// + public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool missingFromCache, bool cancelRecommendation) : base(cancelRecommendation) { this.ProductCode = productCode; @@ -432,6 +414,7 @@ namespace WixToolset.Mba.Core this.PerMachine = perMachine; this.Version = version; this.Operation = operation; + this.MissingFromCache = missingFromCache; } /// @@ -463,6 +446,11 @@ namespace WixToolset.Mba.Core /// Gets the operation that will be taken on the detected bundle. /// public RelatedOperation Operation { get; private set; } + + /// + /// Whether the related bundle is missing from the package cache. + /// + public bool MissingFromCache { get; set; } } /// @@ -1009,6 +997,61 @@ namespace WixToolset.Mba.Core } } + /// + /// Event arguments for + /// + [Serializable] + public class PlanForwardCompatibleBundleEventArgs : CancellableHResultEventArgs + { + /// + public PlanForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool recommendedIgnoreBundle, bool cancelRecommendation, bool ignoreBundle) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RelationType = relationType; + this.BundleTag = bundleTag; + this.PerMachine = perMachine; + this.Version = version; + this.RecommendedIgnoreBundle = recommendedIgnoreBundle; + this.IgnoreBundle = ignoreBundle; + } + + /// + /// Gets the identity of the forward compatible bundle detected. + /// + public string BundleId { get; private set; } + + /// + /// Gets the relationship type of the forward compatible bundle. + /// + public RelationType RelationType { get; private set; } + + /// + /// Gets the tag of the forward compatible bundle. + /// + public string BundleTag { get; private set; } + + /// + /// Gets whether the forward compatible bundle is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the forward compatible bundle. + /// + public string Version { get; private set; } + + /// + /// Gets the recommendation of whether the engine should use the forward compatible bundle. + /// + public bool RecommendedIgnoreBundle { get; set; } + + /// + /// Gets or sets whether the engine will use the forward compatible bundle. + /// + public bool IgnoreBundle { get; set; } + } + /// /// Additional arguments used when the engine has begun installing the bundle. /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 4812c038..14cb8fd5 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -64,8 +64,8 @@ namespace WixToolset.Mba.Core /// /// /// + /// /// - /// /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] @@ -75,8 +75,8 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, - [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle + [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// @@ -143,6 +143,7 @@ namespace WixToolset.Mba.Core /// /// /// + /// /// /// [PreserveSig] @@ -154,6 +155,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, + [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -1000,6 +1002,31 @@ namespace WixToolset.Mba.Core int hrStatus ); + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanForwardCompatibleBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelationType relationType, + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.Bool)] bool fRecommendedIgnoreBundle, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle + ); + /// /// Low level method that is called directly from the engine. /// diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 5803a26a..269d4955 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -229,6 +229,11 @@ namespace WixToolset.Mba.Core /// event EventHandler PlanComplete; + /// + /// Fired when the engine is about to plan a forward compatible bundle. + /// + event EventHandler PlanForwardCompatibleBundle; + /// /// Fired when the engine has completed planning a package. /// diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 1c9a2372..2510b966 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -98,7 +98,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 6d36ad8c..66852efa 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -73,6 +73,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, + BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 55ed8cbe..0164269c 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -104,8 +104,8 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, __in LPCWSTR /*wzVersion*/, - __inout BOOL* /*pfCancel*/, - __inout BOOL* /*pfIgnoreBundle*/ + __in BOOL /*fMissingFromCache*/, + __inout BOOL* /*pfCancel*/ ) { return S_OK; @@ -150,6 +150,7 @@ public: // IBootstrapperApplication __in BOOL /*fPerMachine*/, __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __in BOOL /*fMissingFromCache*/, __inout BOOL* /*pfCancel*/ ) { @@ -660,6 +661,20 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnPlanForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOL /*fRecommendedIgnoreBundle*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfIgnoreBundle*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index 1b11c300..e1de800a 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -108,6 +108,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN: case BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE: case BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE: + case BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE: hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); break; case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index ff1d07fd..c9211e0f 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -102,8 +102,8 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, __in LPCWSTR /*wzVersion*/, - __inout BOOL* pfCancel, - __inout BOOL* /*pfIgnoreBundle*/ + __in BOOL /*fMissingFromCache*/, + __inout BOOL* pfCancel ) { *pfCancel |= CheckCanceled(); @@ -151,6 +151,7 @@ public: // IBootstrapperApplication __in BOOL /*fPerMachine*/, __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __in BOOL /*fMissingFromCache*/, __inout BOOL* pfCancel ) { @@ -845,6 +846,21 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnPlanForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOL /*fRecommendedIgnoreBundle*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfIgnoreBundle*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + virtual STDMETHODIMP_(HRESULT) BAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, __in const LPVOID /*pvArgs*/, diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index d971a2eb..d8a6590b 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -78,7 +78,7 @@ static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, &pResults->fCancel, &pResults->fIgnoreBundle); + return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->fMissingFromCache, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectUpdateBegin( @@ -114,7 +114,7 @@ static HRESULT BalBaseBAProcOnDetectRelatedBundle( __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); + return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, pArgs->fMissingFromCache, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectPackageBegin( @@ -585,6 +585,15 @@ static HRESULT BalBaseBAProcOnSystemRestorePointComplete( 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); +} + /******************************************************************* BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. Provides a default mapping between the new message based BA interface and @@ -796,6 +805,9 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( 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; } } diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 01d0bb8a..ed70d8fe 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -33,8 +33,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, __in_z LPCWSTR wzVersion, - __inout BOOL* pfCancel, - __inout BOOL* pfIgnoreBundle + __in BOOL fMissingFromCache, + __inout BOOL* pfCancel ) = 0; // OnDetectUpdateBegin - called when the engine begins detection for bundle update. @@ -71,6 +71,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in BOOL fPerMachine, __in_z LPCWSTR wzVersion, __in BOOTSTRAPPER_RELATED_OPERATION operation, + __in BOOL fMissingFromCache, __inout BOOL* pfCancel ) = 0; @@ -540,6 +541,17 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in HRESULT hrStatus ) = 0; + STDMETHOD(OnPlanForwardCompatibleBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in_z LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in_z LPCWSTR wzVersion, + __in BOOL fRecommendedIgnoreBundle, + __inout BOOL* pfCancel, + __inout BOOL* pfIgnoreBundle + ) = 0; + // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. // This might be used to help the BA support more than one version of the engine. STDMETHOD(BAProc)( diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 1ac5d2ac..76baf58e 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 99edfaae..6008128f 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -87,7 +87,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 1ac5d2ac..76baf58e 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 0c67b548..cea2cddc 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,7 +5,7 @@ - + @@ -96,7 +96,7 @@ - + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 52a8333b..b9f93c69 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index a901712e..47bf1285 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -4,7 +4,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index 768cc4cc..456f4a1f 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index 22e84e9a..3e30a74e 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -4,7 +4,7 @@ - + @@ -68,7 +68,7 @@ - + diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index 768cc4cc..456f4a1f 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -10,6 +10,6 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 732e719b6888895ac01aa02c2a86d0beb37ec74d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 13 Apr 2021 11:18:18 -0700 Subject: Add MEND request state to repair any missing files in MSI packages --- src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 10 ++++++++++ src/balutil/balutil.vcxproj | 6 +++--- src/balutil/packages.config | 2 +- src/bextutil/bextutil.vcxproj | 6 +++--- src/bextutil/packages.config | 2 +- src/mbanative/mbanative.vcxproj | 4 ++-- src/mbanative/packages.config | 2 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 6 +++--- src/test/BalUtilUnitTest/packages.config | 8 ++++---- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 6 +++--- src/test/BextUtilUnitTest/packages.config | 8 ++++---- 11 files changed, 35 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index e03271ca..af3101dc 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -315,6 +315,11 @@ namespace WixToolset.Mba.Core /// Modify, + /// + /// + /// + Mend, + /// /// /// @@ -495,6 +500,11 @@ namespace WixToolset.Mba.Core /// Present, + /// + /// + /// + Mend, + /// /// /// diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 2510b966..6d31f9ba 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 76baf58e..0a0e5748 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 6008128f..5007afb8 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,7 +2,7 @@ - + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 76baf58e..0a0e5748 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index cea2cddc..0f2e6ee0 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,10 +2,10 @@ + - @@ -96,7 +96,7 @@ - + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index b9f93c69..a6397667 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 47bf1285..7fe93b60 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -3,8 +3,8 @@ + - @@ -69,7 +69,7 @@ - + - + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index 456f4a1f..b8befee3 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -1,6 +1,10 @@  + + + + @@ -8,8 +12,4 @@ - - - - \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index 3e30a74e..ee676f28 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -3,8 +3,8 @@ + - @@ -68,7 +68,7 @@ - + - + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index 456f4a1f..b8befee3 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -1,6 +1,10 @@  + + + + @@ -8,8 +12,4 @@ - - - - \ No newline at end of file -- cgit v1.2.3-55-g6feb From 6c740c1070475a8a894393a186cdcdd8a8a81112 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 14 Apr 2021 12:18:39 -0700 Subject: Allow BA to update feed source Fixes wixtoolset/issues#5568 --- src/WixToolset.Mba.Core/Engine.cs | 6 ++++++ src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 8 ++++++++ src/WixToolset.Mba.Core/IEngine.cs | 6 ++++++ src/balutil/BalBootstrapperEngine.cpp | 15 +++++++++++++++ src/balutil/inc/IBootstrapperEngine.h | 4 ++++ 5 files changed, 39 insertions(+) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index d5c43a53..e07ecd8b 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -246,6 +246,12 @@ namespace WixToolset.Mba.Core this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); } + /// + public void SetUpdateSource(string url) + { + this.engine.SetUpdateSource(url); + } + /// public void SetLocalSource(string packageOrContainerId, string payloadId, string path) { diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index af3101dc..78753a42 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -277,6 +277,14 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout ); + /// + /// Sets the URL to the update feed. + /// + /// URL of the update feed. + void SetUpdateSource( + [MarshalAs(UnmanagedType.LPWStr)] string url + ); + /// /// See . /// diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 0899ec43..3e636961 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -144,6 +144,12 @@ namespace WixToolset.Mba.Core /// Optional hash expected for the update. void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash); + /// + /// Sets the URL to the update feed. + /// + /// URL of the update feed. + void SetUpdateSource(string url); + /// /// Set the local source for a package or container. /// diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index 8e40f7ae..dda98cb9 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -535,6 +535,21 @@ public: // IBootstrapperEngine return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); } + virtual STDMETHODIMP SetUpdateSource( + __in_z LPCWSTR wzUrl + ) + { + BAENGINE_SETUPDATESOURCE_ARGS args = { }; + BAENGINE_SETUPDATESOURCE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzUrl = wzUrl; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &args, &results, m_pvBAEngineProcContext); + } + virtual STDMETHODIMP CompareVersions( __in_z LPCWSTR wzVersion1, __in_z LPCWSTR wzVersion2, diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h index cd89a9f0..af6379f4 100644 --- a/src/balutil/inc/IBootstrapperEngine.h +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -128,6 +128,10 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 __in DWORD dwWaitForInputIdleTimeout ) = 0; + STDMETHOD(SetUpdateSource)( + __in_z LPCWSTR wzUrl + ) = 0; + STDMETHOD(CompareVersions)( __in_z LPCWSTR wzVersion1, __in_z LPCWSTR wzVersion2, -- cgit v1.2.3-55-g6feb From 62b32cd6f21292c73dae8d5cfcd3a1cb13a1fd7d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 19 Apr 2021 17:32:32 -0500 Subject: Replace OnResolveSource with OnCacheAcquireResolving. Update balretry to have a separate type for container vs payload. #3640 --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 24 ++- src/WixToolset.Mba.Core/EventArgs.cs | 143 +++++++------ .../IBootstrapperApplication.cs | 100 +++++---- .../IDefaultBootstrapperApplication.cs | 19 +- src/balutil/balretry.cpp | 223 +++++++++++++-------- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BAFunctions.h | 2 +- src/balutil/inc/BalBaseBAFunctions.h | 23 ++- src/balutil/inc/BalBaseBAFunctionsProc.h | 2 +- src/balutil/inc/BalBaseBootstrapperApplication.h | 36 ++-- .../inc/BalBaseBootstrapperApplicationProc.h | 16 +- src/balutil/inc/IBootstrapperApplication.h | 50 +++-- src/balutil/inc/balretry.h | 37 ++-- src/balutil/packages.config | 4 +- src/bextutil/bextutil.vcxproj | 8 +- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 8 +- src/mbanative/packages.config | 4 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 8 +- src/test/BalUtilUnitTest/packages.config | 4 +- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 8 +- src/test/BextUtilUnitTest/packages.config | 4 +- 22 files changed, 444 insertions(+), 291 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index b6c0dd0d..79cbfa86 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -146,7 +146,7 @@ namespace WixToolset.Mba.Core public event EventHandler CacheAcquireProgress; /// - public event EventHandler ResolveSource; + public event EventHandler CacheAcquireResolving; /// public event EventHandler CacheAcquireComplete; @@ -736,12 +736,12 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine, raises the event. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - protected virtual void OnResolveSource(ResolveSourceEventArgs args) + protected virtual void OnCacheAcquireResolving(CacheAcquireResolvingEventArgs args) { - EventHandler handler = this.ResolveSource; + EventHandler handler = this.CacheAcquireResolving; if (null != handler) { handler(this, args); @@ -1126,9 +1126,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectBegin(bool fInstalled, int cPackages, ref bool fCancel) + int IBootstrapperApplication.OnDetectBegin(bool fCached, bool fInstalled, int cPackages, ref bool fCancel) { - DetectBeginEventArgs args = new DetectBeginEventArgs(fInstalled, cPackages, fCancel); + DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, fInstalled, cPackages, fCancel); this.OnDetectBegin(args); fCancel = args.Cancel; @@ -1400,11 +1400,12 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, CacheOperation operation, string wzSource, ref bool fCancel) + int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, string wzSource, string wzDownloadUrl, string wzPayloadContainerId, CacheOperation recommendation, ref CacheOperation action, ref bool fCancel) { - CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, operation, wzSource, fCancel); + CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, wzSource, wzDownloadUrl, wzPayloadContainerId, recommendation, action, fCancel); this.OnCacheAcquireBegin(args); + action = args.Action; fCancel = args.Cancel; return args.HResult; } @@ -1418,11 +1419,12 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnResolveSource(string wzPackageOrContainerId, string wzPayloadId, string wzLocalSource, string wzDownloadSource, BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, ref BOOTSTRAPPER_RESOLVESOURCE_ACTION action, ref bool fCancel) + int IBootstrapperApplication.OnCacheAcquireResolving(string wzPackageOrContainerId, string wzPayloadId, string[] searchPaths, int cSearchPaths, bool fFoundLocal, int dwRecommendedSearchPath, string wzDownloadUrl, string wzPayloadContainerId, CacheResolveOperation recommendation, ref int dwChosenSearchPath, ref CacheResolveOperation action, ref bool fCancel) { - ResolveSourceEventArgs args = new ResolveSourceEventArgs(wzPackageOrContainerId, wzPayloadId, wzLocalSource, wzDownloadSource, action, recommendation, fCancel); - this.OnResolveSource(args); + CacheAcquireResolvingEventArgs args = new CacheAcquireResolvingEventArgs(wzPackageOrContainerId, wzPayloadId, searchPaths, fFoundLocal, dwRecommendedSearchPath, wzDownloadUrl, wzPayloadContainerId, recommendation, dwChosenSearchPath, action, fCancel); + this.OnCacheAcquireResolving(args); + dwChosenSearchPath = args.ChosenSearchPath; action = args.Action; fCancel = args.Cancel; return args.HResult; diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 7e7cbd11..ee89b583 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -122,6 +122,31 @@ namespace WixToolset.Mba.Core public T Action { get; set; } } + /// + /// Base class for cancellable action BA classes. + /// + [Serializable] + public abstract class CancellableActionEventArgs : CancellableHResultEventArgs + { + /// + public CancellableActionEventArgs(bool cancelRecommendation, T recommendation, T action) + : base(cancelRecommendation) + { + this.Recommendation = recommendation; + this.Action = action; + } + + /// + /// Gets the recommended action from the engine. + /// + public T Recommendation { get; private set; } + + /// + /// Gets or sets the action to be performed. This is passed back to the engine. + /// + public T Action { get; set; } + } + /// /// Additional arguments used when startup has begun. /// @@ -196,24 +221,25 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the overall detection phase has begun. + /// Event arguments for /// [Serializable] public class DetectBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// Specifies whether the bundle is installed. - /// The number of packages to detect. - /// The recommendation from the engine. - public DetectBeginEventArgs(bool installed, int packageCount, bool cancelRecommendation) + /// + public DetectBeginEventArgs(bool cached, bool installed, int packageCount, bool cancelRecommendation) : base(cancelRecommendation) { + this.Cached = cached; this.Installed = installed; this.PackageCount = packageCount; } + /// + /// Gets whether the bundle is cached. + /// + public bool Cached { get; private set; } + /// /// Gets whether the bundle is installed. /// @@ -290,6 +316,7 @@ namespace WixToolset.Mba.Core : base(cancelRecommendation) { this.UpdateLocation = updateLocation; + this.Skip = skipRecommendation; } /// @@ -1242,6 +1269,8 @@ namespace WixToolset.Mba.Core /// public UnregisterBeginEventArgs(bool keepRegistration, bool forceKeepRegistration) { + this.KeepRegistration = keepRegistration; + this.ForceKeepRegistration = forceKeepRegistration; } /// @@ -1288,21 +1317,20 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine begins to acquire containers or payloads. + /// EventArgs for . /// [Serializable] - public class CacheAcquireBeginEventArgs : CancellableHResultEventArgs + public class CacheAcquireBeginEventArgs : CancellableActionEventArgs { - /// - /// Creates a new instance of the class. - /// - public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, CacheOperation operation, string source, bool cancelRecommendation) - : base(cancelRecommendation) + /// + public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, string source, string downloadUrl, string payloadContainerId, CacheOperation recommendation, CacheOperation action, bool cancelRecommendation) + : base(cancelRecommendation, recommendation, action) { this.PackageOrContainerId = packageOrContainerId; this.PayloadId = payloadId; - this.Operation = operation; this.Source = source; + this.DownloadUrl = downloadUrl; + this.PayloadContainerId = payloadContainerId; } /// @@ -1316,25 +1344,28 @@ namespace WixToolset.Mba.Core public string PayloadId { get; private set; } /// - /// Gets the cache acquire operation. + /// Gets the source of the container or payload. /// - public CacheOperation Operation { get; private set; } + public string Source { get; private set; } /// - /// Gets the source of the container or payload. + /// Gets the optional URL to download container or payload. /// - public string Source { get; private set; } + public string DownloadUrl { get; private set; } + + /// + /// Gets the optional identity of the container that contains the payload being acquired. + /// + public string PayloadContainerId { get; private set; } } /// - /// Additional arguments used when the engine acquires some part of a container or payload. + /// EventArgs for . /// [Serializable] public class CacheAcquireProgressEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// + /// public CacheAcquireProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1372,14 +1403,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine completes the acquisition of a container or payload. + /// EventArgs for . /// [Serializable] public class CacheAcquireCompleteEventArgs : ActionEventArgs { - /// - /// Creates a new instance of the class. - /// + /// public CacheAcquireCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) : base(hrStatus, recommendation, action) { @@ -1729,62 +1758,64 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used by the engine to allow the BA to change the source - /// using or . + /// EventArgs for . /// [Serializable] - public class ResolveSourceEventArgs : CancellableHResultEventArgs + public class CacheAcquireResolvingEventArgs : CancellableActionEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package or container that requires source. - /// The identity of the payload that requires source. - /// The current path used for source resolution. - /// Optional URL to download container or payload. - /// The recommended action from the engine. - /// The action to perform. - /// The recommendation from the engine. - public ResolveSourceEventArgs(string packageOrContainerId, string payloadId, string localSource, string downloadSource, BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, BOOTSTRAPPER_RESOLVESOURCE_ACTION action, bool cancelRecommendation) - : base(cancelRecommendation) + /// + public CacheAcquireResolvingEventArgs(string packageOrContainerId, string payloadId, string[] searchPaths, bool foundLocal, int recommendedSearchPath, string downloadUrl, string payloadContainerId, CacheResolveOperation recommendation, int chosenSearchPath, CacheResolveOperation action, bool cancel) + : base(cancel, recommendation, action) { this.PackageOrContainerId = packageOrContainerId; this.PayloadId = payloadId; - this.LocalSource = localSource; - this.DownloadSource = downloadSource; - this.Recommendation = recommendation; - this.Action = action; + this.SearchPaths = searchPaths; + this.FoundLocal = foundLocal; + this.RecommendedSearchPath = recommendedSearchPath; + this.DownloadUrl = downloadUrl; + this.PayloadContainerId = payloadContainerId; + this.ChosenSearchPath = chosenSearchPath; } /// - /// Gets the identity of the package or container that requires source. + /// Gets the identity of the package or container that is being acquired. /// public string PackageOrContainerId { get; private set; } /// - /// Gets the identity of the payload that requires source. + /// Gets the identity of the payload that is being acquired. /// public string PayloadId { get; private set; } /// - /// Gets the current path used for source resolution. + /// Gets the search paths used for source resolution. /// - public string LocalSource { get; private set; } + public string[] SearchPaths { get; private set; } + + /// + /// Gets whether indicates that a file was found at that search path. + /// + public bool FoundLocal { get; private set; } + + /// + /// When is true, the index to for the recommended local file. + /// + public int RecommendedSearchPath { get; private set; } /// /// Gets the optional URL to download container or payload. /// - public string DownloadSource { get; private set; } + public string DownloadUrl { get; private set; } /// - /// Gets the recommended action from the engine. + /// Gets the optional identity of the container that contains the payload being acquired. /// - public BOOTSTRAPPER_RESOLVESOURCE_ACTION Recommendation { get; private set; } + public string PayloadContainerId { get; private set; } /// - /// Gets or sets the action to perform. + /// Gets or sets the index to to use when is set to . /// - public BOOTSTRAPPER_RESOLVESOURCE_ACTION Action { get; set; } + public int ChosenSearchPath { get; set; } } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 14cb8fd5..88c65674 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -44,13 +44,10 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectBegin( + [MarshalAs(UnmanagedType.Bool)] bool fCached, [MarshalAs(UnmanagedType.Bool)] bool fInstalled, [MarshalAs(UnmanagedType.U4)] int cPackages, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel @@ -540,32 +537,22 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.U4)] CacheOperation operation, [MarshalAs(UnmanagedType.LPWStr)] string wzSource, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, + [MarshalAs(UnmanagedType.U4)] CacheOperation recommendation, + [MarshalAs(UnmanagedType.I4)] ref CacheOperation action, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// /// See . /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireProgress( @@ -578,37 +565,28 @@ namespace WixToolset.Mba.Core ); /// - /// See . + /// See . /// - /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] - int OnResolveSource( + int OnCacheAcquireResolving( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, - [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, - BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, - ref BOOTSTRAPPER_RESOLVESOURCE_ACTION action, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3, ArraySubType = UnmanagedType.LPWStr), In] string[] searchPaths, + [MarshalAs(UnmanagedType.U4)] int cSearchPaths, + [MarshalAs(UnmanagedType.Bool)] bool fFoundLocal, + [MarshalAs(UnmanagedType.U4)] int dwRecommendedSearchPath, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, + [MarshalAs(UnmanagedType.I4)] CacheResolveOperation recommendation, + [MarshalAs(UnmanagedType.U4)] ref int dwChosenSearchPath, + [MarshalAs(UnmanagedType.I4)] ref CacheResolveOperation action, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// /// See . /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireComplete( @@ -1419,19 +1397,55 @@ namespace WixToolset.Mba.Core public enum CacheOperation { /// - /// Container or payload is being copied. + /// There is no source available. + /// + None, + + /// + /// Copy the payload or container from the chosen local source. /// Copy, /// - /// Container or payload is being downloaded. + /// Download the payload or container using the download URL. /// Download, /// - /// Container or payload is being extracted. + /// Extract the payload from the container. + /// + Extract, + } + + /// + /// The source to be used to acquire a container or payload. + /// + public enum CacheResolveOperation + { + /// + /// There is no source available. + /// + None, + + /// + /// Copy the payload or container from the chosen local source. /// - Extract + Local, + + /// + /// Download the payload or container from the download URL. + /// + Download, + + /// + /// Extract the payload from the container. + /// + Container, + + /// + /// Look again for the payload or container locally. + /// + Retry, } /// @@ -1637,7 +1651,7 @@ namespace WixToolset.Mba.Core } /// - /// The available actions for . + /// The available actions for . /// public enum BOOTSTRAPPER_RESOLVESOURCE_ACTION { diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 269d4955..03f94d37 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -30,12 +30,16 @@ namespace WixToolset.Mba.Core event EventHandler BeginMsiTransactionComplete; /// - /// Fired when the engine has begun acquiring the installation sources. + /// Fired when the engine has begun acquiring the payload or container. + /// The BA can change the source using + /// or . /// event EventHandler CacheAcquireBegin; /// - /// Fired when the engine has completed the acquisition of the installation sources. + /// Fired when the engine has completed the acquisition of the payload or container. + /// The BA can change the source using + /// or . /// event EventHandler CacheAcquireComplete; @@ -44,6 +48,11 @@ namespace WixToolset.Mba.Core /// event EventHandler CacheAcquireProgress; + /// + /// Fired by the engine to allow the BA to override the acquisition action. + /// + event EventHandler CacheAcquireResolving; + /// /// Fired when the engine has begun caching the installation sources. /// @@ -284,12 +293,6 @@ namespace WixToolset.Mba.Core /// event EventHandler RegisterComplete; - /// - /// Fired by the engine to allow the BA to change the source - /// using or . - /// - event EventHandler ResolveSource; - /// /// Fired when the engine is about to rollback an MSI transaction. /// diff --git a/src/balutil/balretry.cpp b/src/balutil/balretry.cpp index d95d86b2..9d8abd6d 100644 --- a/src/balutil/balretry.cpp +++ b/src/balutil/balretry.cpp @@ -2,23 +2,33 @@ #include "precomp.h" +typedef enum BALRETRY_TYPE +{ + BALRETRY_TYPE_CACHE_CONTAINER, + BALRETRY_TYPE_CACHE_PAYLOAD, + BALRETRY_TYPE_EXECUTE, +} BALRETRY_TYPE; + struct BALRETRY_INFO { - LPWSTR sczId; // package or container id. - LPWSTR sczPayloadId; // optional payload id. + LPWSTR sczId; DWORD cRetries; DWORD dwLastError; }; static DWORD vdwMaxRetries = 0; static DWORD vdwTimeout = 0; -static BALRETRY_INFO vrgRetryInfo[2]; +static BALRETRY_INFO vrgRetryInfo[3]; // prototypes static BOOL IsActiveRetryEntry( __in BALRETRY_TYPE type, - __in_z LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId + __in_z LPCWSTR sczId + ); + +static HRESULT StartActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId ); @@ -39,7 +49,6 @@ DAPI_(void) BalRetryUninitialize() for (DWORD i = 0; i < countof(vrgRetryInfo); ++i) { ReleaseStr(vrgRetryInfo[i].sczId); - ReleaseStr(vrgRetryInfo[i].sczPayloadId); memset(vrgRetryInfo + i, 0, sizeof(BALRETRY_INFO)); } @@ -48,34 +57,32 @@ DAPI_(void) BalRetryUninitialize() } -DAPI_(void) BalRetryStartPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, +DAPI_(void) BalRetryStartContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, __in_z_opt LPCWSTR wzPayloadId ) { - if (!wzPackageId || !*wzPackageId) + if (!wzContainerOrPackageId && !wzPayloadId) { - ReleaseNullStr(vrgRetryInfo[type].sczId); - ReleaseNullStr(vrgRetryInfo[type].sczPayloadId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); } - else if (IsActiveRetryEntry(type, wzPackageId, wzPayloadId)) + else if (wzPayloadId) { - ++vrgRetryInfo[type].cRetries; - ::Sleep(vdwTimeout); + StartActiveRetryEntry(BALRETRY_TYPE_CACHE_PAYLOAD, wzPayloadId); } else { - StrAllocString(&vrgRetryInfo[type].sczId, wzPackageId, 0); - if (wzPayloadId) - { - StrAllocString(&vrgRetryInfo[type].sczPayloadId, wzPayloadId, 0); - } - - vrgRetryInfo[type].cRetries = 0; + StartActiveRetryEntry(BALRETRY_TYPE_CACHE_CONTAINER, wzContainerOrPackageId); } +} - vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; + +DAPI_(void) BalRetryStartPackage( + __in_z LPCWSTR wzPackageId + ) +{ + StartActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId); } @@ -84,87 +91,112 @@ DAPI_(void) BalRetryErrorOccurred( __in DWORD dwError ) { - if (IsActiveRetryEntry(BALRETRY_TYPE_CACHE, wzPackageId, NULL)) + if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId)) { - vrgRetryInfo[BALRETRY_TYPE_CACHE].dwLastError = dwError; + vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; } - else if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL)) +} + + +DAPI_(HRESULT) BalRetryEndContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ) +{ + HRESULT hr = S_OK; + BALRETRY_TYPE type = BALRETRY_TYPE_CACHE_PAYLOAD; + LPCWSTR wzId = NULL; + + if (!wzContainerOrPackageId && !wzPayloadId) { - vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); + ExitFunction(); + } + else if (wzPayloadId) + { + type = BALRETRY_TYPE_CACHE_PAYLOAD; + wzId = wzPayloadId; + } + else + { + type = BALRETRY_TYPE_CACHE_CONTAINER; + wzId = wzContainerOrPackageId; } + + if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzId)) + { + // Retry on all errors except the following. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && + BG_E_NETWORK_DISCONNECTED != hrError && + HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && + HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) + { + *pfRetry = TRUE; + } + } + +LExit: + return hr; } DAPI_(HRESULT) BalRetryEndPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzPackageId, __in HRESULT hrError, __inout BOOL* pfRetry ) { HRESULT hr = S_OK; + BALRETRY_TYPE type = BALRETRY_TYPE_EXECUTE; if (!wzPackageId || !*wzPackageId) { ReleaseNullStr(vrgRetryInfo[type].sczId); - ReleaseNullStr(vrgRetryInfo[type].sczPayloadId); } - else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId, wzPayloadId)) + else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId)) { - if (BALRETRY_TYPE_CACHE == type) + // If the service is out of whack, just try again. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) { - // Retry on all errors except the following. - if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && - BG_E_NETWORK_DISCONNECTED != hrError && - HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && - HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) - { - *pfRetry = TRUE; - } + *pfRetry = TRUE; } - else if (BALRETRY_TYPE_EXECUTE == type) + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) { - // If the service is out of whack, just try again. - if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) - { - *pfRetry = TRUE; - } - else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) - { - DWORD dwError = vrgRetryInfo[type].dwLastError; - - // If we failed with one of these specific error codes, then retry since - // we've seen these have a high success of succeeding on retry. - if (1303 == dwError || - 1304 == dwError || - 1306 == dwError || - 1307 == dwError || - 1309 == dwError || - 1310 == dwError || - 1311 == dwError || - 1312 == dwError || - 1316 == dwError || - 1317 == dwError || - 1321 == dwError || - 1335 == dwError || - 1402 == dwError || - 1406 == dwError || - 1606 == dwError || - 1706 == dwError || - 1719 == dwError || - 1723 == dwError || - 1923 == dwError || - 1931 == dwError) - { - *pfRetry = TRUE; - } - } - else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) + DWORD dwError = vrgRetryInfo[type].dwLastError; + + // If we failed with one of these specific error codes, then retry since + // we've seen these have a high success of succeeding on retry. + if (1303 == dwError || + 1304 == dwError || + 1306 == dwError || + 1307 == dwError || + 1309 == dwError || + 1310 == dwError || + 1311 == dwError || + 1312 == dwError || + 1316 == dwError || + 1317 == dwError || + 1321 == dwError || + 1335 == dwError || + 1402 == dwError || + 1406 == dwError || + 1606 == dwError || + 1706 == dwError || + 1719 == dwError || + 1723 == dwError || + 1923 == dwError || + 1931 == dwError) { *pfRetry = TRUE; } } + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) + { + *pfRetry = TRUE; + } } return hr; @@ -175,17 +207,40 @@ DAPI_(HRESULT) BalRetryEndPackage( static BOOL IsActiveRetryEntry( __in BALRETRY_TYPE type, - __in_z LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId + __in_z LPCWSTR sczId ) { BOOL fActive = FALSE; - fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, vrgRetryInfo[type].sczId, -1); - if (fActive && wzPayloadId) // if a payload id was provided ensure it matches. + fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, sczId, -1, vrgRetryInfo[type].sczId, -1); + + return fActive; +} + +static HRESULT StartActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId + ) +{ + HRESULT hr = S_OK; + + if (!sczId || !*sczId) { - fActive = vrgRetryInfo[type].sczPayloadId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPayloadId, -1, vrgRetryInfo[type].sczPayloadId, -1); + ReleaseNullStr(vrgRetryInfo[type].sczId); } + else if (IsActiveRetryEntry(type, sczId)) + { + ++vrgRetryInfo[type].cRetries; + ::Sleep(vdwTimeout); + } + else + { + hr = StrAllocString(&vrgRetryInfo[type].sczId, sczId, 0); - return fActive; + vrgRetryInfo[type].cRetries = 0; + } + + vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; + + return hr; } diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 6d31f9ba..a47e994f 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 66852efa..07f7a750 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -42,7 +42,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, - BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 0164269c..ca727f49 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -90,6 +90,7 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, __in BOOL /*fInstalled*/, __in DWORD /*cPackages*/, __inout BOOL* /*pfCancel*/ @@ -385,8 +386,11 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnCacheAcquireBegin( __in_z LPCWSTR /*wzPackageOrContainerId*/, __in_z_opt LPCWSTR /*wzPayloadId*/, - __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/, __in_z LPCWSTR /*wzSource*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, + __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, __inout BOOL* /*pfCancel*/ ) { @@ -405,13 +409,18 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnResolveSource( - __in_z LPCWSTR /*wzPackageOrContainerId*/, + virtual STDMETHODIMP OnCacheAcquireResolving( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR /*wzLocalSource*/, - __in_z_opt LPCWSTR /*wzDownloadSource*/, - __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/, + __in_z LPCWSTR* /*rgSearchPaths*/, + __in DWORD /*cSearchPaths*/, + __in BOOL /*fFoundLocal*/, + __in DWORD /*dwRecommendedSearchPath*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, + __inout DWORD* /*pdwChosenSearchPath*/, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, __inout BOOL* /*pfCancel*/ ) { diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index e1de800a..7e89fe83 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -77,7 +77,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN: case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN: case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE: + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING: case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN: case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index c9211e0f..3d3e4ffa 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -87,6 +87,7 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, __in BOOL /*fInstalled*/, __in DWORD /*cPackages*/, __inout BOOL* pfCancel @@ -442,14 +443,17 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnCacheAcquireBegin( - __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPackageOrContainerId, __in_z_opt LPCWSTR wzPayloadId, - __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/, __in_z LPCWSTR /*wzSource*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, + __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, __inout BOOL* pfCancel ) { - BalRetryStartPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId); + BalRetryStartContainerOrPayload(wzPackageOrContainerId, wzPayloadId); *pfCancel |= CheckCanceled(); return S_OK; } @@ -488,13 +492,18 @@ public: // IBootstrapperApplication return hr; } - virtual STDMETHODIMP OnResolveSource( - __in_z LPCWSTR /*wzPackageOrContainerId*/, + virtual STDMETHODIMP OnCacheAcquireResolving( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR /*wzLocalSource*/, - __in_z_opt LPCWSTR /*wzDownloadSource*/, - __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/, + __in_z LPCWSTR* /*rgSearchPaths*/, + __in DWORD /*cSearchPaths*/, + __in BOOL /*fFoundLocal*/, + __in DWORD /*dwRecommendedSearchPath*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, + __inout DWORD* /*pdwChosenSearchPath*/, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, __inout BOOL* pfCancel ) { @@ -518,7 +527,7 @@ public: // IBootstrapperApplication ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); } - hr = BalRetryEndPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); + hr = BalRetryEndContainerOrPayload(wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); ExitOnFailure(hr, "BalRetryEndPackage for cache failed"); if (fRetry) @@ -599,7 +608,7 @@ public: // IBootstrapperApplication // Only track retry on execution (not rollback). if (fExecute) { - BalRetryStartPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL); + BalRetryStartPackage(wzPackageId); } m_fRollingBack = !fExecute; @@ -700,7 +709,7 @@ public: // IBootstrapperApplication ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); } - hr = BalRetryEndPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL, hrStatus, &fRetry); + hr = BalRetryEndPackage(wzPackageId, hrStatus, &fRetry); ExitOnFailure(hr, "BalRetryEndPackage for execute failed"); if (fRetry) @@ -951,6 +960,9 @@ protected: m_fApplying = FALSE; m_fRollingBack = FALSE; + m_dwProgressPercentage = 0; + m_dwOverallProgressPercentage = 0; + BalRetryInitialize(dwRetryCount, dwRetryTimeout); } diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index d8a6590b..42ffeb79 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -15,7 +15,7 @@ static HRESULT BalBaseBAProcOnDetectBegin( __inout BA_ONDETECTBEGIN_RESULTS* pResults ) { - return pBA->OnDetectBegin(pArgs->fInstalled, pArgs->cPackages, &pResults->fCancel); + return pBA->OnDetectBegin(pArgs->fCached, pArgs->fInstalled, pArgs->cPackages, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectComplete( @@ -303,7 +303,7 @@ static HRESULT BalBaseBAProcOnCacheAcquireBegin( __inout BA_ONCACHEACQUIREBEGIN_RESULTS* pResults ) { - return pBA->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->operation, pArgs->wzSource, &pResults->fCancel); + return pBA->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzSource, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->action, &pResults->fCancel); } static HRESULT BalBaseBAProcOnCacheAcquireProgress( @@ -315,13 +315,13 @@ static HRESULT BalBaseBAProcOnCacheAcquireProgress( return pBA->OnCacheAcquireProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); } -static HRESULT BalBaseBAProcOnResolveSource( +static HRESULT BalBaseBAProcOnCacheAcquireResolving( __in IBootstrapperApplication* pBA, - __in BA_ONRESOLVESOURCE_ARGS* pArgs, - __inout BA_ONRESOLVESOURCE_RESULTS* pResults + __in BA_ONCACHEACQUIRERESOLVING_ARGS* pArgs, + __inout BA_ONCACHEACQUIRERESOLVING_RESULTS* pResults ) { - return pBA->OnResolveSource(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->recommendation, &pResults->action, &pResults->fCancel); + 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( @@ -713,8 +713,8 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: hr = BalBaseBAProcOnCacheAcquireProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE: - hr = BalBaseBAProcOnResolveSource(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + 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)); diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index ed70d8fe..8fcdd318 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -21,6 +21,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // OnDetectBegin - called when the engine begins detection. STDMETHOD(OnDetectBegin)( + __in BOOL fCached, __in BOOL fInstalled, __in DWORD cPackages, __inout BOOL* pfCancel @@ -279,14 +280,20 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnCacheAcquireBegin - called when the engine begins copying or - // downloading a payload to the working folder. + // OnCacheAcquireBegin - called when the engine begins acquiring a payload or container. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning. // STDMETHOD(OnCacheAcquireBegin)( __in_z_opt LPCWSTR wzPackageOrContainerId, __in_z_opt LPCWSTR wzPayloadId, - __in BOOTSTRAPPER_CACHE_OPERATION operation, __in_z LPCWSTR wzSource, + __in_z_opt LPCWSTR wzDownloadUrl, + __in_z_opt LPCWSTR wzPayloadContainerId, + __in BOOTSTRAPPER_CACHE_OPERATION recommendation, + __inout BOOTSTRAPPER_CACHE_OPERATION* pAction, __inout BOOL* pfCancel ) = 0; @@ -302,27 +309,38 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnResolveSource - called when a payload or container cannot be found locally. + // OnCacheAcquireResolving - called to allow the BA to override the acquisition action for the payload or container. // // Parameters: + // wzPackageOrContainerId will be NULL when resolving a layout-only payload. // wzPayloadId will be NULL when resolving a container. - // wzDownloadSource will be NULL if the container or payload does not provide a DownloadURL. + // wzDownloadUrl will be NULL if the container or payload does not provide a DownloadURL. + // wzPayloadContainerId will not be NULL if acquiring a payload that is in a container. // - // Notes: - // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() - // to update the source location before returning BOOTSTRAPPER_RESOLVESOURCE_ACTION_RETRY or BOOTSTRAPPER_RESOLVESOURCE_ACTION_DOWNLOAD. - STDMETHOD(OnResolveSource)( - __in_z LPCWSTR wzPackageOrContainerId, + // rgSearchPaths are the search paths used for source resolution. + // fFoundLocal is TRUE when dwRecommendedSearchPath indicates that the file was found. + // dwRecommendedSearchPath is the index into rgSearchPaths for the recommended local file. + // + STDMETHOD(OnCacheAcquireResolving)( + __in_z_opt LPCWSTR wzPackageOrContainerId, __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzLocalSource, - __in_z_opt LPCWSTR wzDownloadSource, - __in BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, - __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* pAction, + __in_z LPCWSTR* rgSearchPaths, + __in DWORD cSearchPaths, + __in BOOL fFoundLocal, + __in DWORD dwRecommendedSearchPath, + __in_z_opt LPCWSTR wzDownloadUrl, + __in_z_opt LPCWSTR wzPayloadContainerId, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION recommendation, + __inout DWORD* pdwChosenSearchPath, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* pAction, __inout BOOL* pfCancel ) = 0; - // OnCacheAcquireComplete - called after the engine copied or downloaded - // a payload to the working folder. + // OnCacheAcquireComplete - called after the engine acquired the payload or container. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY. // STDMETHOD(OnCacheAcquireComplete)( __in_z_opt LPCWSTR wzPackageOrContainerId, diff --git a/src/balutil/inc/balretry.h b/src/balutil/inc/balretry.h index 040ab4ae..35282a7e 100644 --- a/src/balutil/inc/balretry.h +++ b/src/balutil/inc/balretry.h @@ -6,12 +6,6 @@ extern "C" { #endif -typedef enum BALRETRY_TYPE -{ - BALRETRY_TYPE_CACHE, - BALRETRY_TYPE_EXECUTE, -} BALRETRY_TYPE; - /******************************************************************* BalRetryInitialize - initialize the retry count and timeout between retries (in milliseconds). @@ -33,9 +27,7 @@ DAPI_(void) BalRetryUninitialize(); wait the specified timeout. ********************************************************************/ DAPI_(void) BalRetryStartPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId + __in_z LPCWSTR wzPackageId ); /******************************************************************* @@ -43,17 +35,34 @@ DAPI_(void) BalRetryStartPackage( to consider. ********************************************************************/ DAPI_(void) BalRetryErrorOccurred( - __in_z_opt LPCWSTR wzPackageId, + __in_z LPCWSTR wzPackageId, __in DWORD dwError ); /******************************************************************* - BalRetryEndPackage - returns IDRETRY is a retry is recommended or - IDNOACTION if a retry is not recommended. + BalRetryEndPackage - returns TRUE if a retry is recommended. ********************************************************************/ DAPI_(HRESULT) BalRetryEndPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, + __in_z LPCWSTR wzPackageId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ); + +/******************************************************************* + BalRetryStartContainerOrPayload - call when a container or payload + begins to be acquired. If the target is being retried, + the function will wait the specified timeout. +********************************************************************/ +DAPI_(void) BalRetryStartContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId + ); + +/******************************************************************* + BalRetryEndContainerOrPayload - returns TRUE if a retry is recommended. +********************************************************************/ +DAPI_(HRESULT) BalRetryEndContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, __in_z_opt LPCWSTR wzPayloadId, __in HRESULT hrError, __inout BOOL* pfRetry diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 0a0e5748..de70fed1 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 5007afb8..c8671f3b 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 0a0e5748..de70fed1 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 0f2e6ee0..729d5df2 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,11 +2,11 @@ - + - + @@ -96,7 +96,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index a6397667..b5ba712e 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 7fe93b60..95d7ed5f 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -3,9 +3,9 @@ - + - + Debug @@ -69,7 +69,7 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index b8befee3..49b76211 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -3,8 +3,8 @@ - - + + diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index ee676f28..886e3c2c 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -3,9 +3,9 @@ - + - + Debug @@ -68,7 +68,7 @@ - - + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index b8befee3..49b76211 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -3,8 +3,8 @@ - - + + -- cgit v1.2.3-55-g6feb From 11fe2c881d182f9caff28bd9ff08c2e4fe513989 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 19 Apr 2021 17:35:44 -0500 Subject: Add new caching BA events. #3640 --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 195 +++++++- src/WixToolset.Mba.Core/EventArgs.cs | 536 ++++++++++----------- .../IBootstrapperApplication.cs | 160 ++++-- .../IDefaultBootstrapperApplication.cs | 45 +- src/balutil/inc/BAFunctions.h | 7 + src/balutil/inc/BalBaseBAFunctions.h | 101 +++- src/balutil/inc/BalBaseBootstrapperApplication.h | 106 +++- .../inc/BalBaseBootstrapperApplicationProc.h | 84 ++++ src/balutil/inc/IBootstrapperApplication.h | 87 +++- 9 files changed, 943 insertions(+), 378 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 79cbfa86..0a8f3af8 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -154,6 +154,9 @@ namespace WixToolset.Mba.Core /// public event EventHandler CacheVerifyBegin; + /// + public event EventHandler CacheVerifyProgress; + /// public event EventHandler CacheVerifyComplete; @@ -229,6 +232,24 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanForwardCompatibleBundle; + /// + public event EventHandler CacheContainerOrPayloadVerifyBegin; + + /// + public event EventHandler CacheContainerOrPayloadVerifyProgress; + + /// + public event EventHandler CacheContainerOrPayloadVerifyComplete; + + /// + public event EventHandler CachePayloadExtractBegin; + + /// + public event EventHandler CachePayloadExtractProgress; + + /// + public event EventHandler CachePayloadExtractComplete; + /// /// Entry point that is called when the bootstrapper application is ready to run. /// @@ -774,6 +795,19 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheVerifyProgress(CacheVerifyProgressEventArgs args) + { + EventHandler handler = this.CacheVerifyProgress; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called by the engine, raises the event. /// @@ -1098,8 +1132,99 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheContainerOrPayloadVerifyBegin(CacheContainerOrPayloadVerifyBeginEventArgs args) + { + EventHandler handler = this.CacheContainerOrPayloadVerifyBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheContainerOrPayloadVerifyProgress(CacheContainerOrPayloadVerifyProgressEventArgs args) + { + EventHandler handler = this.CacheContainerOrPayloadVerifyProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheContainerOrPayloadVerifyComplete(CacheContainerOrPayloadVerifyCompleteEventArgs args) + { + EventHandler handler = this.CacheContainerOrPayloadVerifyComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePayloadExtractBegin(CachePayloadExtractBeginEventArgs args) + { + EventHandler handler = this.CachePayloadExtractBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePayloadExtractProgress(CachePayloadExtractProgressEventArgs args) + { + EventHandler handler = this.CachePayloadExtractProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePayloadExtractComplete(CachePayloadExtractCompleteEventArgs args) + { + EventHandler handler = this.CachePayloadExtractComplete; + if (null != handler) + { + handler(this, args); + } + } + #region IBootstrapperApplication Members + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + { + switch (message) + { + default: + return NativeMethods.E_NOTIMPL; + } + } + + void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + { + } + int IBootstrapperApplication.OnStartup() { StartupEventArgs args = new StartupEventArgs(); @@ -1439,18 +1564,27 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnCacheVerifyBegin(string wzPackageId, string wzPayloadId, ref bool fCancel) + int IBootstrapperApplication.OnCacheVerifyBegin(string wzPackageOrContainerId, string wzPayloadId, ref bool fCancel) { - CacheVerifyBeginEventArgs args = new CacheVerifyBeginEventArgs(wzPackageId, wzPayloadId, fCancel); + CacheVerifyBeginEventArgs args = new CacheVerifyBeginEventArgs(wzPackageOrContainerId, wzPayloadId, fCancel); this.OnCacheVerifyBegin(args); fCancel = args.Cancel; return args.HResult; } - int IBootstrapperApplication.OnCacheVerifyComplete(string wzPackageId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) + int IBootstrapperApplication.OnCacheVerifyProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, CacheVerifyStep verifyStep, ref bool fCancel) + { + CacheVerifyProgressEventArgs args = new CacheVerifyProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, verifyStep, fCancel); + this.OnCacheVerifyProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheVerifyComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) { - CacheVerifyCompleteEventArgs args = new CacheVerifyCompleteEventArgs(wzPackageId, wzPayloadId, hrStatus, recommendation, action); + CacheVerifyCompleteEventArgs args = new CacheVerifyCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, action); this.OnCacheVerifyComplete(args); action = args.Action; @@ -1682,17 +1816,56 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyBegin(string wzPackageOrContainerId, string wzPayloadId, ref bool fCancel) { - switch (message) - { - default: - return NativeMethods.E_NOTIMPL; - } + CacheContainerOrPayloadVerifyBeginEventArgs args = new CacheContainerOrPayloadVerifyBeginEventArgs(wzPackageOrContainerId, wzPayloadId, fCancel); + this.OnCacheContainerOrPayloadVerifyBegin(args); + + fCancel = args.Cancel; + return args.HResult; } - void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) + { + CacheContainerOrPayloadVerifyProgressEventArgs args = new CacheContainerOrPayloadVerifyProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); + this.OnCacheContainerOrPayloadVerifyProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus) + { + CacheContainerOrPayloadVerifyCompleteEventArgs args = new CacheContainerOrPayloadVerifyCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus); + this.OnCacheContainerOrPayloadVerifyComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnCachePayloadExtractBegin(string wzContainerId, string wzPayloadId, ref bool fCancel) + { + CachePayloadExtractBeginEventArgs args = new CachePayloadExtractBeginEventArgs(wzContainerId, wzPayloadId, fCancel); + this.OnCachePayloadExtractBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePayloadExtractProgress(string wzContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) { + CachePayloadExtractProgressEventArgs args = new CachePayloadExtractProgressEventArgs(wzContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); + this.OnCachePayloadExtractProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePayloadExtractComplete(string wzContainerId, string wzPayloadId, int hrStatus) + { + CachePayloadExtractCompleteEventArgs args = new CachePayloadExtractCompleteEventArgs(wzContainerId, wzPayloadId, hrStatus); + this.OnCachePayloadExtractComplete(args); + + return args.HResult; } #endregion diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index ee89b583..e64f6d2c 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -51,11 +51,7 @@ namespace WixToolset.Mba.Core [Serializable] public abstract class ResultEventArgs : HResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// Recommended result from engine. - /// The result to return to the engine. + /// public ResultEventArgs(Result recommendation, Result result) { this.Recommendation = recommendation; @@ -99,11 +95,7 @@ namespace WixToolset.Mba.Core /// public abstract class ActionEventArgs : StatusEventArgs { - /// - /// - /// The return code of the operation. - /// Recommended action from engine. - /// The action to perform. + /// public ActionEventArgs(int hrStatus, T recommendation, T action) : base(hrStatus) { @@ -147,6 +139,49 @@ namespace WixToolset.Mba.Core public T Action { get; set; } } + /// + /// Base class for cache progress events. + /// + [Serializable] + public abstract class CacheProgressBaseEventArgs : CancellableHResultEventArgs + { + /// + public CacheProgressBaseEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.Progress = progress; + this.Total = total; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + + /// + /// Gets the number of bytes cached thus far. + /// + public long Progress { get; private set; } + + /// + /// Gets the total bytes to cache. + /// + public long Total { get; private set; } + + /// + /// Gets the overall percentage of progress of caching. + /// + public int OverallPercentage { get; private set; } + } + /// /// Additional arguments used when startup has begun. /// @@ -182,25 +217,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the system is shutting down or the user is logging off. + /// Event arguments for /// - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// By default setup will prevent shutting down or logging off between - /// and . - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// [Serializable] public class SystemShutdownEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The reason the application is requested to close or being closed. - /// The recommendation from the engine. + /// public SystemShutdownEventArgs(EndSessionReasons reasons, bool cancelRecommendation) : base(cancelRecommendation) { @@ -301,17 +323,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the detection for an update has begun. + /// Event arguments for /// [Serializable] public class DetectUpdateBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The location to check for an updated bundle. - /// The cancel recommendation from the engine. - /// The skip recommendation from the engine. + /// public DetectUpdateBeginEventArgs(string updateLocation, bool cancelRecommendation, bool skipRecommendation) : base(cancelRecommendation) { @@ -331,23 +348,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the detection for an update has begun. + /// Event arguments for /// [Serializable] public class DetectUpdateEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The location to check for an updated bundle. - /// The expected size of the updated bundle. - /// The expected version of the updated bundle. - /// The title of the updated bundle. - /// The summary of the updated bundle. - /// The content type of the content of the updated bundle. - /// The content of the updated bundle. - /// The recommendation from the engine. - /// The recommendation from the engine. + /// public DetectUpdateEventArgs(string updateLocation, long size, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) : base(cancelRecommendation) { @@ -403,16 +409,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the detection for an update has completed. + /// Event arguments for /// [Serializable] public class DetectUpdateCompleteEventArgs : StatusEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - /// The recommendation from the engine. + /// public DetectUpdateCompleteEventArgs(int hrStatus, bool ignoreRecommendation) : base(hrStatus) { @@ -481,16 +483,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the detection for a specific package has begun. + /// Event arguments for /// [Serializable] public class DetectPackageBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package to detect. - /// The recommendation from the engine. + /// public DetectPackageBeginEventArgs(string packageId, bool cancelRecommendation) : base(cancelRecommendation) { @@ -504,21 +502,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when a related MSI package has been detected for a package. + /// Event arguments for /// [Serializable] public class DetectRelatedMsiPackageEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package detecting. - /// The upgrade code of the related package detected. - /// The identity of the related package detected. - /// Whether the detected package is per machine. - /// The version of the related package detected. - /// The operation that will be taken on the detected package. - /// The recommendation from the engine. + /// public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) : base(cancelRecommendation) { @@ -598,17 +587,11 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when a feature in an MSI package has been detected. + /// Event arguments for /// public class DetectMsiFeatureEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// Detected package identifier. - /// Detected feature identifier. - /// Feature state detected. - /// The recommendation from the engine. + /// public DetectMsiFeatureEventArgs(string packageId, string featureId, FeatureState state, bool cancelRecommendation) : base(cancelRecommendation) { @@ -687,16 +670,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun planning the installation. + /// Event arguments for /// [Serializable] public class PlanBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The number of packages to plan for. - /// The recommendation from the engine. + /// public PlanBeginEventArgs(int packageCount, bool cancelRecommendation) : base(cancelRecommendation) { @@ -710,18 +689,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun planning for a related bundle. + /// Event arguments for /// [Serializable] public class PlanRelatedBundleEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the bundle to plan for. - /// The recommended requested state for the bundle. - /// The requested state for the bundle. - /// The recommendation from the engine. + /// public PlanRelatedBundleEventArgs(string bundleId, RequestState recommendedState, RequestState state, bool cancelRecommendation) : base(cancelRecommendation) { @@ -842,19 +815,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when engine is about to plan a feature in an MSI package. + /// Event arguments for /// [Serializable] public class PlanMsiFeatureEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// Package identifier being planned. - /// Feature identifier being planned. - /// Recommended feature state being planned. - /// Feature state being planned. - /// The recommendation from the engine. + /// public PlanMsiFeatureEventArgs(string packageId, string featureId, FeatureState recommendedState, FeatureState state, bool cancelRecommendation) : base(cancelRecommendation) { @@ -886,21 +852,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine is planning an MSI or MSP package. + /// Event arguments for /// [Serializable] public class PlanMsiPackageEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package planned for. - /// Whether the package is planned to execute or roll back. - /// The action planned for the package. - /// The recommendation from the engine. - /// The requested MSI property to add. - /// The requested internal UI level. - /// Whether Burn is requested to set up an external UI handler. + /// public PlanMsiPackageEventArgs(string packageId, bool shouldExecute, ActionState action, bool cancelRecommendation, BURN_MSI_PROPERTY actionMsiProperty, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler) : base(cancelRecommendation) { @@ -1080,16 +1037,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun installing the bundle. + /// Event arguments for /// [Serializable] public class ApplyBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The number of phases during apply. - /// The recommendation from the engine. + /// public ApplyBeginEventArgs(int phaseCount, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1104,15 +1057,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine is about to start the elevated process. + /// Event arguments for /// [Serializable] public class ElevateBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The recommendation from the engine. + /// public ElevateBeginEventArgs(bool cancelRecommendation) : base(cancelRecommendation) { @@ -1136,17 +1086,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has changed progress for the bundle installation. + /// Event arguments for /// [Serializable] public class ProgressEventArgs : CancellableHResultEventArgs { - /// - /// Creates an new instance of the class. - /// - /// The percentage from 0 to 100 completed for a package. - /// The percentage from 0 to 100 completed for the bundle. - /// The recommendation from the engine. + /// public ProgressEventArgs(int progressPercentage, int overallPercentage, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1166,22 +1111,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has encountered an error. + /// Event arguments for /// [Serializable] public class ErrorEventArgs : ResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The error type. - /// The identity of the package that yielded the error. - /// The error code. - /// The error message. - /// Recommended display flags for an error dialog. - /// The exteded data for the error. - /// Recommended result from engine. - /// The result to return to the engine. + /// public ErrorEventArgs(ErrorType errorType, string packageId, int errorCode, string errorMessage, int dwUIHint, string[] data, Result recommendation, Result result) : base(recommendation, result) { @@ -1225,15 +1160,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun registering the location and visibility of the bundle. + /// Event arguments for /// [Serializable] public class RegisterBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The recommendation from the engine. + /// public RegisterBeginEventArgs(bool cancelRecommendation) : base(cancelRecommendation) { @@ -1301,15 +1233,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun caching the installation sources. + /// Event arguments for /// [Serializable] public class CacheBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The recommendation from the engine. + /// public CacheBeginEventArgs(bool cancelRecommendation) : base(cancelRecommendation) { @@ -1363,43 +1292,13 @@ namespace WixToolset.Mba.Core /// EventArgs for . /// [Serializable] - public class CacheAcquireProgressEventArgs : CancellableHResultEventArgs + public class CacheAcquireProgressEventArgs : CacheProgressBaseEventArgs { /// public CacheAcquireProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) - : base(cancelRecommendation) + : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - this.Progress = progress; - this.Total = total; - this.OverallPercentage = overallPercentage; } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload (if acquiring a payload). - /// - public string PayloadId { get; private set; } - - /// - /// Gets the number of bytes cached thus far. - /// - public long Progress { get; private set; } - - /// - /// Gets the total bytes to cache. - /// - public long Total { get; private set; } - - /// - /// Gets the overall percentage of progress of caching. - /// - public int OverallPercentage { get; private set; } } /// @@ -1428,25 +1327,23 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine starts the verification of a payload. + /// EventArgs for . /// [Serializable] public class CacheVerifyBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - public CacheVerifyBeginEventArgs(string packageId, string payloadId, bool cancelRecommendation) + /// + public CacheVerifyBeginEventArgs(string packageOrContainerId, string payloadId, bool cancelRecommendation) : base(cancelRecommendation) { - this.PackageId = packageId; + this.PackageOrContainerId = packageOrContainerId; this.PayloadId = payloadId; } /// - /// Gets the identifier of the package. + /// Gets the identifier of the container or package. /// - public string PackageId { get; private set; } + public string PackageOrContainerId { get; private set; } /// /// Gets the identifier of the payload. @@ -1455,25 +1352,42 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine completes the verification of a payload. + /// EventArgs for . /// [Serializable] - public class CacheVerifyCompleteEventArgs : ActionEventArgs + public class CacheVerifyProgressEventArgs : CacheProgressBaseEventArgs { + /// + public CacheVerifyProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, CacheVerifyStep verifyStep, bool cancelRecommendation) + : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + this.Step = verifyStep; + } + /// - /// Creates a new instance of the class. + /// Gets the current verification step. /// - public CacheVerifyCompleteEventArgs(string packageId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) + public CacheVerifyStep Step { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CacheVerifyCompleteEventArgs : ActionEventArgs + { + /// + public CacheVerifyCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) : base(hrStatus, recommendation, action) { - this.PackageId = packageId; + this.PackageOrContainerId = packageOrContainerId; this.PayloadId = payloadId; } /// - /// Gets the identifier of the package. + /// Gets the identifier of the container or package. /// - public string PackageId { get; private set; } + public string PackageOrContainerId { get; private set; } /// /// Gets the identifier of the payload. @@ -1498,16 +1412,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun installing packages. + /// Event arguments for /// [Serializable] public class ExecuteBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The number of packages to act on. - /// The recommendation from the engine. + /// public ExecuteBeginEventArgs(int packageCount, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1521,20 +1431,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has begun installing a specific package. + /// Event arguments for /// [Serializable] public class ExecutePackageBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package to act on. - /// Whether the package is being executed or rolled back. - /// The action about to be executed. - /// The internal UI level (if this is an MSI or MSP package). - /// Whether Burn will set up an external UI handler (if this is an MSI or MSP package). - /// The recommendation from the engine. + /// public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, ActionState action, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1572,17 +1474,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine executes one or more patches targeting a product. + /// Event arguments for /// [Serializable] public class ExecutePatchTargetEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package to act on. - /// The product code of the target of the patch. - /// The recommendation from the engine. + /// public ExecutePatchTargetEventArgs(string packageId, string targetProductCode, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1602,21 +1499,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when Windows Installer sends an installation message. + /// Event arguments for /// [Serializable] public class ExecuteMsiMessageEventArgs : ResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that yielded this message. - /// The type of this message. - /// Recommended display flags for this message. - /// The message. - /// The extended data for the message. - /// Recommended result from engine. - /// The result to return to the engine. + /// public ExecuteMsiMessageEventArgs(string packageId, InstallMessage messageType, int dwUIHint, string message, string[] data, Result recommendation, Result result) : base(recommendation, result) { @@ -1654,18 +1542,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arugments used for file in use installation messages. + /// Event arguments for /// [Serializable] public class ExecuteFilesInUseEventArgs : ResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that yielded the files in use message. - /// The list of files in use. - /// Recommended result from engine. - /// The result to return to the engine. + /// public ExecuteFilesInUseEventArgs(string packageId, string[] files, Result recommendation, Result result) : base(recommendation, result) { @@ -1685,19 +1567,13 @@ namespace WixToolset.Mba.Core } /// + /// Event arguments for /// Additional arguments used when the engine has completed installing a specific package. /// [Serializable] public class ExecutePackageCompleteEventArgs : ActionEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that was acted on. - /// The return code of the operation. - /// Whether a restart is required. - /// Recommended action from engine. - /// The action to perform. + /// public ExecutePackageCompleteEventArgs(string packageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION action) : base(hrStatus, recommendation, action) { @@ -1733,18 +1609,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine has completed installing the bundle. + /// Event arguments for /// [Serializable] public class ApplyCompleteEventArgs : ActionEventArgs { - /// - /// Creates a new instance of the clas. - /// - /// The return code of the operation. - /// Whether a restart is required. - /// Recommended action from engine. - /// The action to perform. + /// public ApplyCompleteEventArgs(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_APPLYCOMPLETE_ACTION action) : base(hrStatus, recommendation, action) { @@ -1819,18 +1689,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used by the engine when it has begun caching a specific package. + /// Event arguments for /// [Serializable] public class CachePackageBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that is being cached. - /// Number of payloads to be cached. - /// The size on disk required by the specific package. - /// The recommendation from the engine. + /// public CachePackageBeginEventArgs(string packageId, int cachePayloads, long packageCacheSize, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1856,18 +1720,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments passed by the engine when it has completed caching a specific package. + /// Event arguments for /// [Serializable] public class CachePackageCompleteEventArgs : ActionEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package that was cached. - /// The return code of the operation. - /// Recommended action from engine. - /// The action to perform. + /// public CachePackageCompleteEventArgs(string packageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) : base(hrStatus, recommendation, action) { @@ -1881,18 +1739,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments passed by the engine while executing on payload. + /// Event arguments for /// [Serializable] public class ExecuteProgressEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identifier of the package being executed. - /// The percentage from 0 to 100 of the execution progress for a single payload. - /// The percentage from 0 to 100 of the execution progress for all payload. - /// The recommendation from the engine. + /// public ExecuteProgressEventArgs(string packageId, int progressPercentage, int overallPercentage, bool cancelRecommendation) : base(cancelRecommendation) { @@ -2187,4 +2039,130 @@ namespace WixToolset.Mba.Core { } } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheContainerOrPayloadVerifyBeginEventArgs : CancellableHResultEventArgs + { + /// + public CacheContainerOrPayloadVerifyBeginEventArgs(string packageOrContainerId, string payloadId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheContainerOrPayloadVerifyProgressEventArgs : CacheProgressBaseEventArgs + { + /// + public CacheContainerOrPayloadVerifyProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CacheContainerOrPayloadVerifyCompleteEventArgs : StatusEventArgs + { + /// + public CacheContainerOrPayloadVerifyCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus) + : base(hrStatus) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CachePayloadExtractBeginEventArgs : CancellableHResultEventArgs + { + /// + public CachePayloadExtractBeginEventArgs(string containerId, string payloadId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.ContainerId = containerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container. + /// + public string ContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CachePayloadExtractProgressEventArgs : CacheProgressBaseEventArgs + { + /// + public CachePayloadExtractProgressEventArgs(string containerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(containerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CachePayloadExtractCompleteEventArgs : StatusEventArgs + { + /// + public CachePayloadExtractCompleteEventArgs(string containerId, string payloadId, int hrStatus) + : base(hrStatus) + { + this.ContainerId = containerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container. + /// + public string ContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } } diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 88c65674..2195fd4b 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -3,7 +3,6 @@ namespace WixToolset.Mba.Core { using System; - using System.CodeDom.Compiler; using System.Runtime.InteropServices; /// @@ -14,6 +13,29 @@ namespace WixToolset.Mba.Core [Guid("53C31D56-49C0-426B-AB06-099D717C67FE")] public interface IBootstrapperApplication { + /// + /// Low level method that is called directly from the engine. + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int BAProc( + int message, + IntPtr pvArgs, + IntPtr pvResults, + IntPtr pvContext + ); + + /// + /// Low level method that is called directly from the engine. + /// + void BAProcFallback( + int message, + IntPtr pvArgs, + IntPtr pvResults, + ref int phr, + IntPtr pvContext + ); + /// /// See . /// @@ -600,31 +622,36 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheVerifyBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheVerifyProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.I4)] CacheVerifyStep verifyStep, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + /// /// See . /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheVerifyComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, @@ -1006,36 +1033,75 @@ namespace WixToolset.Mba.Core ); /// - /// Low level method that is called directly from the engine. + /// See . /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] - int BAProc( - int message, - IntPtr pvArgs, - IntPtr pvResults, - IntPtr pvContext + int OnCacheContainerOrPayloadVerifyBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// - /// Low level method that is called directly from the engine. + /// See . /// - /// - /// - /// - /// - /// - void BAProcFallback( - int message, - IntPtr pvArgs, - IntPtr pvResults, - ref int phr, - IntPtr pvContext + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheContainerOrPayloadVerifyProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheContainerOrPayloadVerifyComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePayloadExtractBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePayloadExtractProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePayloadExtractComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus ); } @@ -1448,6 +1514,26 @@ namespace WixToolset.Mba.Core Retry, } + /// + /// The current step when verifying a container or payload. + /// + public enum CacheVerifyStep + { + /// + /// Copying or moving the file from the working path to the unverified path. + /// Not used during Layout. + /// + Stage, + /// + /// Hashing the file. + /// + Hash, + /// + /// Copying or moving the file to the final location. + /// + Finalize, + } + /// /// The restart state after a package or all packages were applied. /// @@ -1566,7 +1652,7 @@ namespace WixToolset.Mba.Core None, /// - /// Instructs the engine to try the acquisition of the package again. + /// Instructs the engine to try the acquisition of the payload again. /// Ignored if hrStatus is a success. /// Retry, diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 03f94d37..a295f6c0 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -44,7 +44,7 @@ namespace WixToolset.Mba.Core event EventHandler CacheAcquireComplete; /// - /// Fired when the engine has progress acquiring the installation sources. + /// Fired when the engine has progress acquiring the payload or container. /// event EventHandler CacheAcquireProgress; @@ -63,6 +63,21 @@ namespace WixToolset.Mba.Core /// event EventHandler CacheComplete; + /// + /// Fired when the engine begins the verification of the payload or container that was already in the package cache. + /// + event EventHandler CacheContainerOrPayloadVerifyBegin; + + /// + /// Fired when the engine has completed the verification of the payload or container that was already in the package cache. + /// + event EventHandler CacheContainerOrPayloadVerifyComplete; + + /// + /// Fired when the engine has progress verifying the payload or container that was already in the package cache. + /// + event EventHandler CacheContainerOrPayloadVerifyProgress; + /// /// Fired when the engine has begun caching a specific package. /// @@ -74,15 +89,35 @@ namespace WixToolset.Mba.Core event EventHandler CachePackageComplete; /// - /// Fired when the engine begins the verification of the acquired installation sources. + /// Fired when the engine begins the extraction of the payload from the container. + /// + event EventHandler CachePayloadExtractBegin; + + /// + /// Fired when the engine has completed the extraction of the payload from the container. + /// + event EventHandler CachePayloadExtractComplete; + + /// + /// Fired when the engine has progress extracting the payload from the container. + /// + event EventHandler CachePayloadExtractProgress; + + /// + /// Fired when the engine begins the verification of the acquired payload or container. /// event EventHandler CacheVerifyBegin; /// - /// Fired when the engine complete the verification of the acquired installation sources. + /// Fired when the engine has completed the verification of the acquired payload or container. /// event EventHandler CacheVerifyComplete; + /// + /// Fired when the engine has progress verifying the payload or container. + /// + event EventHandler CacheVerifyProgress; + /// /// Fired when the engine is about to commit an MSI transaction. /// @@ -179,7 +214,7 @@ namespace WixToolset.Mba.Core event EventHandler ExecuteComplete; /// - /// Fired when Windows Installer sends a files in use installation message. + /// Fired when a package sends a files in use installation message. /// event EventHandler ExecuteFilesInUse; @@ -204,7 +239,7 @@ namespace WixToolset.Mba.Core event EventHandler ExecutePatchTarget; /// - /// Fired by the engine while executing on payload. + /// Fired by the engine while executing a package. /// event EventHandler ExecuteProgress; diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 07f7a750..2970478f 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -74,6 +74,13 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, + BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, + BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index ca727f49..054bfb26 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -69,6 +69,26 @@ public: // IUnknown } public: // IBootstrapperApplication + virtual STDMETHODIMP_(HRESULT) BAProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __inout HRESULT* /*phr*/, + __in_opt LPVOID /*pvContext*/ + ) + { + } + virtual STDMETHODIMP OnStartup() { return S_OK; @@ -439,7 +459,7 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnCacheVerifyBegin( - __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPackageOrContainerId*/, __in_z LPCWSTR /*wzPayloadId*/, __inout BOOL* /*pfCancel*/ ) @@ -447,8 +467,21 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnCacheVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __in BOOTSTRAPPER_CACHE_VERIFY_STEP /*verifyStep*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + virtual STDMETHODIMP OnCacheVerifyComplete( - __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPackageOrContainerId*/, __in_z LPCWSTR /*wzPayloadId*/, __in HRESULT /*hrStatus*/, __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, @@ -684,24 +717,64 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP_(HRESULT) BAProc( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* /*pfCancel*/ ) { - return E_NOTIMPL; + return S_OK; } - virtual STDMETHODIMP_(void) BAProcFallback( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __inout HRESULT* /*phr*/, - __in_opt LPVOID /*pvContext*/ + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* /*pfCancel*/ ) { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; } public: // IBAFunctions diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 3d3e4ffa..812025eb 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -61,6 +61,26 @@ public: // IUnknown } public: // IBootstrapperApplication + virtual STDMETHODIMP_(HRESULT) BAProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __inout HRESULT* /*phr*/, + __in_opt LPVOID /*pvContext*/ + ) + { + } + virtual STDMETHODIMP OnStartup() { return S_OK; @@ -540,7 +560,7 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnCacheVerifyBegin( - __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPackageOrContainerId*/, __in_z LPCWSTR /*wzPayloadId*/, __inout BOOL* pfCancel ) @@ -549,8 +569,22 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnCacheVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __in BOOTSTRAPPER_CACHE_VERIFY_STEP /*verifyStep*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + virtual STDMETHODIMP OnCacheVerifyComplete( - __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzPackageOrContainerId*/, __in_z LPCWSTR /*wzPayloadId*/, __in HRESULT /*hrStatus*/, __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, @@ -870,24 +904,68 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP_(HRESULT) BAProc( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* pfCancel ) { - return E_NOTIMPL; + *pfCancel |= CheckCanceled(); + return S_OK; } - virtual STDMETHODIMP_(void) BAProcFallback( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __inout HRESULT* /*phr*/, - __in_opt LPVOID /*pvContext*/ + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* pfCancel ) { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; } protected: diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 42ffeb79..10769529 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -342,6 +342,15 @@ static HRESULT BalBaseBAProcOnCacheVerifyBegin( 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, @@ -594,6 +603,60 @@ static HRESULT BalBaseBAProcOnPlanForwardCompatibleBundle( 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); +} + /******************************************************************* BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. Provides a default mapping between the new message based BA interface and @@ -722,6 +785,9 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( 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; @@ -808,6 +874,24 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( 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; } } diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 8fcdd318..7d6a7164 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -4,6 +4,26 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-AB06-099D717C67FE") { + // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. + // This might be used to help the BA support more than one version of the engine. + STDMETHOD(BAProc)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; + + // BAProcFallback - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method + // to give the BA the ability to use default behavior + // and then forward the message to extensions. + STDMETHOD_(void, BAProcFallback)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __inout HRESULT* phr, + __in_opt LPVOID pvContext + ) = 0; + // OnStartup - called when the engine is ready for the bootstrapper application to start. // STDMETHOD(OnStartup)() = 0; @@ -297,8 +317,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnCacheAcquireProgress - called when the engine makes progresss copying - // or downloading a payload to the working folder. + // OnCacheAcquireProgress - called when the engine makes progress acquiring the payload or container. // STDMETHOD(OnCacheAcquireProgress)( __in_z_opt LPCWSTR wzPackageOrContainerId, @@ -359,6 +378,16 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; + STDMETHOD(OnCacheVerifyProgress)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __in BOOTSTRAPPER_CACHE_VERIFY_STEP verifyStep, + __inout BOOL* pfCancel + ) = 0; + // OnCacheVerifyComplete - called after the engine verifies and copies // a payload or container to the package cache folder. // @@ -570,23 +599,45 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfIgnoreBundle ) = 0; - // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. - // This might be used to help the BA support more than one version of the engine. - STDMETHOD(BAProc)( - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext + STDMETHOD(OnCacheContainerOrPayloadVerifyBegin)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __inout BOOL* pfCancel ) = 0; - // BAProcFallback - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method - // to give the BA the ability to use default behavior - // and then forward the message to extensions. - STDMETHOD_(void, BAProcFallback)( - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __inout HRESULT* phr, - __in_opt LPVOID pvContext + STDMETHOD(OnCacheContainerOrPayloadVerifyProgress)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCacheContainerOrPayloadVerifyComplete)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnCachePayloadExtractBegin)( + __in_z_opt LPCWSTR wzContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCachePayloadExtractProgress)( + __in_z_opt LPCWSTR wzContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCachePayloadExtractComplete)( + __in_z_opt LPCWSTR wzContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus ) = 0; }; -- cgit v1.2.3-55-g6feb From 8deeffb615244c62a0c94ea99d01ece88b1caf09 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 27 Apr 2021 22:26:16 -0500 Subject: Integrate size_t and OnPlanPackageBegin changes in Burn headers. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 12 ++-- src/WixToolset.Mba.Core/Engine.cs | 36 ++++++----- src/WixToolset.Mba.Core/EventArgs.cs | 70 ++++++++++++++-------- .../IBootstrapperApplication.cs | 69 +++++++++++++++------ src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 24 ++------ src/WixToolset.Mba.Core/IPackageInfo.cs | 2 +- src/WixToolset.Mba.Core/PackageInfo.cs | 35 +++-------- src/balutil/BalBootstrapperEngine.cpp | 10 ++-- src/balutil/balcondition.cpp | 6 +- src/balutil/balinfo.cpp | 12 ++-- src/balutil/balutil.cpp | 10 ++-- src/balutil/balutil.vcxproj | 8 +-- src/balutil/inc/BalBaseBAFunctions.h | 12 +++- src/balutil/inc/BalBaseBootstrapperApplication.h | 12 +++- .../inc/BalBaseBootstrapperApplicationProc.h | 6 +- src/balutil/inc/IBootstrapperApplication.h | 12 +++- src/balutil/inc/IBootstrapperEngine.h | 10 ++-- src/balutil/inc/balinfo.h | 9 +-- src/balutil/inc/balutil.h | 2 +- src/balutil/packages.config | 4 +- src/bextutil/BextBundleExtensionEngine.cpp | 8 +-- src/bextutil/bextutil.vcxproj | 8 +-- src/bextutil/inc/IBundleExtensionEngine.h | 10 ++-- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 8 +-- src/mbanative/packages.config | 4 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 20 +++---- src/test/BalUtilUnitTest/packages.config | 8 +-- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 20 +++---- src/test/BextUtilUnitTest/packages.config | 8 +-- 30 files changed, 244 insertions(+), 215 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 0a8f3af8..072d3ef0 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1343,9 +1343,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectPackageComplete(string wzPackageId, int hrStatus, PackageState state) + int IBootstrapperApplication.OnDetectPackageComplete(string wzPackageId, int hrStatus, PackageState state, bool fCached) { - DetectPackageCompleteEventArgs args = new DetectPackageCompleteEventArgs(wzPackageId, hrStatus, state); + DetectPackageCompleteEventArgs args = new DetectPackageCompleteEventArgs(wzPackageId, hrStatus, state, fCached); this.OnDetectPackageComplete(args); return args.HResult; @@ -1378,9 +1378,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, PackageState state, bool fInstallCondition, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, PackageState state, bool fCached, BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, RequestState recommendedState, BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, ref RequestState pRequestedState, ref BOOTSTRAPPER_CACHE_TYPE pRequestedCacheType, ref bool fCancel) { - PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, state, fInstallCondition, recommendedState, pRequestedState, fCancel); + PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, state, fCached, installCondition, recommendedState, recommendedCacheType, pRequestedState, pRequestedCacheType, fCancel); this.OnPlanPackageBegin(args); pRequestedState = args.State; @@ -1428,9 +1428,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlannedPackage(string wzPackageId, ActionState execute, ActionState rollback) + int IBootstrapperApplication.OnPlannedPackage(string wzPackageId, ActionState execute, ActionState rollback, bool fPlannedCache, bool fPlannedUncache) { - var args = new PlannedPackageEventArgs(wzPackageId, execute, rollback); + var args = new PlannedPackageEventArgs(wzPackageId, execute, rollback, fPlannedCache, fPlannedUncache); this.OnPlannedPackage(args); return args.HResult; diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index e07ecd8b..aed420d5 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -62,7 +62,7 @@ namespace WixToolset.Mba.Core /// public bool ContainsVariable(string name) { - int capacity = 0; + IntPtr capacity = new IntPtr(0); int ret = this.engine.GetVariableString(name, IntPtr.Zero, ref capacity); return NativeMethods.E_NOTFOUND != ret; } @@ -101,14 +101,15 @@ namespace WixToolset.Mba.Core /// public string EscapeString(string input) { - int capacity = InitialBufferSize; - StringBuilder sb = new StringBuilder(capacity); + IntPtr capacity = new IntPtr(InitialBufferSize); + StringBuilder sb = new StringBuilder(capacity.ToInt32()); // Get the size of the buffer. int ret = this.engine.EscapeString(input, sb, ref capacity); if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) { - sb.Capacity = ++capacity; // Add one for the null terminator. + capacity = new IntPtr(capacity.ToInt32() + 1); // Add one for the null terminator. + sb.Capacity = capacity.ToInt32(); ret = this.engine.EscapeString(input, sb, ref capacity); } @@ -132,14 +133,15 @@ namespace WixToolset.Mba.Core /// public string FormatString(string format) { - int capacity = InitialBufferSize; - StringBuilder sb = new StringBuilder(capacity); + IntPtr capacity = new IntPtr(InitialBufferSize); + StringBuilder sb = new StringBuilder(capacity.ToInt32()); // Get the size of the buffer. int ret = this.engine.FormatString(format, sb, ref capacity); if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) { - sb.Capacity = ++capacity; // Add one for the null terminator. + capacity = new IntPtr(capacity.ToInt32() + 1); // Add one for the null terminator. + sb.Capacity = capacity.ToInt32(); ret = this.engine.FormatString(format, sb, ref capacity); } @@ -343,9 +345,9 @@ namespace WixToolset.Mba.Core /// An error occurred getting the variable. internal IntPtr getStringVariable(string name, out int length) { - int capacity = InitialBufferSize; + IntPtr capacity = new IntPtr(InitialBufferSize); bool success = false; - IntPtr pValue = Marshal.AllocCoTaskMem(capacity * UnicodeEncoding.CharSize); + IntPtr pValue = Marshal.AllocCoTaskMem(capacity.ToInt32() * UnicodeEncoding.CharSize); try { // Get the size of the buffer. @@ -353,7 +355,7 @@ namespace WixToolset.Mba.Core if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) { // Don't need to add 1 for the null terminator, the engine already includes that. - pValue = Marshal.ReAllocCoTaskMem(pValue, capacity * UnicodeEncoding.CharSize); + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity.ToInt32() * UnicodeEncoding.CharSize); ret = this.engine.GetVariableString(name, pValue, ref capacity); } @@ -363,9 +365,10 @@ namespace WixToolset.Mba.Core } // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. - for (length = 0; length < capacity; ++length) + int maxLength = capacity.ToInt32(); + for (length = 0; length < maxLength; ++length) { - if(0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) + if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) { break; } @@ -392,9 +395,9 @@ namespace WixToolset.Mba.Core /// An error occurred getting the variable. internal IntPtr getVersionVariable(string name, out int length) { - int capacity = InitialBufferSize; + IntPtr capacity = new IntPtr(InitialBufferSize); bool success = false; - IntPtr pValue = Marshal.AllocCoTaskMem(capacity * UnicodeEncoding.CharSize); + IntPtr pValue = Marshal.AllocCoTaskMem(capacity.ToInt32() * UnicodeEncoding.CharSize); try { // Get the size of the buffer. @@ -402,7 +405,7 @@ namespace WixToolset.Mba.Core if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) { // Don't need to add 1 for the null terminator, the engine already includes that. - pValue = Marshal.ReAllocCoTaskMem(pValue, capacity * UnicodeEncoding.CharSize); + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity.ToInt32() * UnicodeEncoding.CharSize); ret = this.engine.GetVariableVersion(name, pValue, ref capacity); } @@ -412,7 +415,8 @@ namespace WixToolset.Mba.Core } // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. - for (length = 0; length < capacity; ++length) + int maxLength = capacity.ToInt32(); + for (length = 0; length < maxLength; ++length) { if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) { diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index e64f6d2c..8ef8af14 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -617,22 +617,18 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the detection for a specific package has completed. + /// Additional arguments for . /// [Serializable] public class DetectPackageCompleteEventArgs : StatusEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package detected. - /// The return code of the operation. - /// The state of the specified package. - public DetectPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state) + /// + public DetectPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state, bool cached) : base(hrStatus) { this.PackageId = packageId; this.State = state; + this.Cached = cached; } /// @@ -644,6 +640,11 @@ namespace WixToolset.Mba.Core /// Gets the state of the specified package. /// public PackageState State { get; private set; } + + /// + /// Gets whether any part of the package is cached. + /// + public bool Cached { get; private set; } } /// @@ -725,23 +726,18 @@ namespace WixToolset.Mba.Core [Serializable] public class PlanPackageBeginEventArgs : CancellableHResultEventArgs { - /// - /// - /// - /// - /// - /// - /// - /// - /// - public PlanPackageBeginEventArgs(string packageId, PackageState currentState, bool installCondition, RequestState recommendedState, RequestState state, bool cancelRecommendation) + /// + public PlanPackageBeginEventArgs(string packageId, PackageState currentState, bool cached, BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, RequestState recommendedState, BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, RequestState state, BOOTSTRAPPER_CACHE_TYPE cacheType, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.CurrentState = currentState; + this.Cached = cached; this.InstallCondition = installCondition; this.RecommendedState = recommendedState; + this.RecommendedCacheType = recommendedCacheType; this.State = state; + this.CacheType = cacheType; } /// @@ -754,20 +750,35 @@ namespace WixToolset.Mba.Core /// public PackageState CurrentState { get; private set; } + /// + /// Gets whether any part of the package is cached. + /// + public bool Cached { get; private set; } + /// /// Gets the evaluated result of the package's install condition. /// - public bool InstallCondition { get; private set; } + public BOOTSTRAPPER_PACKAGE_CONDITION_RESULT InstallCondition { get; private set; } /// /// Gets the recommended requested state for the package. /// public RequestState RecommendedState { get; private set; } + /// + /// The authored cache type of the package. + /// + public BOOTSTRAPPER_CACHE_TYPE RecommendedCacheType { get; private set; } + /// /// Gets or sets the requested state for the package. /// public RequestState State { get; set; } + + /// + /// Gets or sets the requested cache type for the package. + /// + public BOOTSTRAPPER_CACHE_TYPE CacheType { get; set; } } /// @@ -936,17 +947,14 @@ namespace WixToolset.Mba.Core [Serializable] public class PlannedPackageEventArgs : HResultEventArgs { - /// - /// - /// - /// - /// - /// - public PlannedPackageEventArgs(string packageId, ActionState execute, ActionState rollback) + /// + public PlannedPackageEventArgs(string packageId, ActionState execute, ActionState rollback, bool cache, bool uncache) { this.PackageId = packageId; this.Execute = execute; this.Rollback = rollback; + this.Cache = cache; + this.Uncache = uncache; } /// @@ -963,6 +971,16 @@ namespace WixToolset.Mba.Core /// Gets the planned rollback action. /// public ActionState Rollback { get; private set; } + + /// + /// Gets whether the package will be cached. + /// + public bool Cache { get; private set; } + + /// + /// Gets whether the package will be removed from the package cache. + /// + public bool Uncache { get; private set; } } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 2195fd4b..530fb1a9 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -251,16 +251,13 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectPackageComplete( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, int hrStatus, - [MarshalAs(UnmanagedType.U4)] PackageState state + [MarshalAs(UnmanagedType.U4)] PackageState state, + [MarshalAs(UnmanagedType.Bool)] bool fCached ); /// @@ -309,21 +306,17 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlanPackageBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.U4)] PackageState state, - [MarshalAs(UnmanagedType.Bool)] bool fInstallCondition, + [MarshalAs(UnmanagedType.Bool)] bool fCached, + [MarshalAs(UnmanagedType.U4)] BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.U4)] ref BOOTSTRAPPER_CACHE_TYPE pRequestedCacheType, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -406,16 +399,14 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnPlannedPackage( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.U4)] ActionState execute, - [MarshalAs(UnmanagedType.U4)] ActionState rollback + [MarshalAs(UnmanagedType.U4)] ActionState rollback, + [MarshalAs(UnmanagedType.Bool)] bool fPlannedCache, + [MarshalAs(UnmanagedType.Bool)] bool fPlannedUncache ); /// @@ -1641,6 +1632,27 @@ namespace WixToolset.Mba.Core Restart, } + /// + /// The cache strategy to be used for the package. + /// + public enum BOOTSTRAPPER_CACHE_TYPE + { + /// + /// The package will be cached in order to securely run the package, but will always be cleaned from the cache at the end. + /// + Remove, + + /// + /// The package will be cached in order to run the package, and then kept in the cache until the package is uninstalled. + /// + Keep, + + /// + /// The package will always be cached and stay in the cache, unless the package and bundle are both being uninstalled. + /// + Force, + } + /// /// The available actions for . /// @@ -1736,6 +1748,27 @@ namespace WixToolset.Mba.Core Suspend, } + /// + /// The result of evaluating a condition from a package. + /// + public enum BOOTSTRAPPER_PACKAGE_CONDITION_RESULT + { + /// + /// No condition was authored. + /// + Default, + + /// + /// Evaluated to false. + /// + False, + + /// + /// Evaluated to true. + /// + True, + } + /// /// The available actions for . /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index 78753a42..4e19bf0f 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -39,57 +39,41 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// [PreserveSig] int GetVariableString( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, IntPtr wzValue, - [MarshalAs(UnmanagedType.U4)] ref int pcchValue + ref IntPtr pcchValue ); /// /// See . /// - /// - /// - /// - /// [PreserveSig] int GetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, IntPtr wzValue, - [MarshalAs(UnmanagedType.U4)] ref int pcchValue + ref IntPtr pcchValue ); /// /// See . /// - /// - /// - /// - /// [PreserveSig] int FormatString( [MarshalAs(UnmanagedType.LPWStr)] string wzIn, [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, - [MarshalAs(UnmanagedType.U4)] ref int pcchOut + ref IntPtr pcchOut ); /// /// See . /// - /// - /// - /// - /// [PreserveSig] int EscapeString( [MarshalAs(UnmanagedType.LPWStr)] string wzIn, [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, - [MarshalAs(UnmanagedType.U4)] ref int pcchOut + ref IntPtr pcchOut ); /// diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs index 0d7e549e..a1d99b10 100644 --- a/src/WixToolset.Mba.Core/IPackageInfo.cs +++ b/src/WixToolset.Mba.Core/IPackageInfo.cs @@ -10,7 +10,7 @@ namespace WixToolset.Mba.Core /// /// /// - CacheType CacheType { get; } + BOOTSTRAPPER_CACHE_TYPE CacheType { get; } /// /// Place for the BA to store it's own custom data for this package. diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index 75a0fd53..567a7cdd 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -7,27 +7,6 @@ namespace WixToolset.Mba.Core using System.Xml; using System.Xml.XPath; - /// - /// - /// - public enum CacheType - { - /// - /// - /// - No, - - /// - /// - /// - Yes, - - /// - /// - /// - Always, - } - /// /// /// @@ -113,7 +92,7 @@ namespace WixToolset.Mba.Core public string InstallCondition { get; internal set; } /// - public CacheType CacheType { get; internal set; } + public BOOTSTRAPPER_CACHE_TYPE CacheType { get; internal set; } /// public bool PrereqPackage { get; internal set; } @@ -198,7 +177,7 @@ namespace WixToolset.Mba.Core /// /// /// - public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) + public static BOOTSTRAPPER_CACHE_TYPE? GetCacheTypeAttribute(XPathNavigator node, string attributeName) { string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); @@ -207,17 +186,17 @@ namespace WixToolset.Mba.Core return null; } - if (attributeValue.Equals("yes", StringComparison.InvariantCulture)) + if (attributeValue.Equals("keep", StringComparison.InvariantCulture)) { - return CacheType.Yes; + return BOOTSTRAPPER_CACHE_TYPE.Keep; } - else if (attributeValue.Equals("always", StringComparison.InvariantCulture)) + else if (attributeValue.Equals("force", StringComparison.InvariantCulture)) { - return CacheType.Always; + return BOOTSTRAPPER_CACHE_TYPE.Force; } else { - return CacheType.No; + return BOOTSTRAPPER_CACHE_TYPE.Remove; } } diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index dda98cb9..301b88a5 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -107,7 +107,7 @@ public: // IBootstrapperEngine virtual STDMETHODIMP GetVariableString( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) { HRESULT hr = S_OK; @@ -134,7 +134,7 @@ public: // IBootstrapperEngine virtual STDMETHODIMP GetVariableVersion( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) { HRESULT hr = S_OK; @@ -161,7 +161,7 @@ public: // IBootstrapperEngine virtual STDMETHODIMP FormatString( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD* pcchOut + __inout SIZE_T* pcchOut ) { HRESULT hr = S_OK; @@ -188,7 +188,7 @@ public: // IBootstrapperEngine virtual STDMETHODIMP EscapeString( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD* pcchOut + __inout SIZE_T* pcchOut ) { HRESULT hr = S_OK; @@ -485,7 +485,7 @@ public: // IBootstrapperEngine } virtual STDMETHODIMP Apply( - __in_opt HWND hwndParent + __in HWND hwndParent ) { BAENGINE_APPLY_ARGS args = { }; diff --git a/src/balutil/balcondition.cpp b/src/balutil/balcondition.cpp index 11d3e218..8b05508f 100644 --- a/src/balutil/balcondition.cpp +++ b/src/balutil/balcondition.cpp @@ -78,7 +78,7 @@ DAPI_(HRESULT) BalConditionEvaluate( ) { HRESULT hr = S_OK; - DWORD_PTR cchMessage = 0; + SIZE_T cchMessage = 0; hr = pEngine->EvaluateCondition(pCondition->sczCondition, pfResult); ExitOnFailure(hr, "Failed to evaluate condition with bootstrapper engine."); @@ -91,7 +91,7 @@ DAPI_(HRESULT) BalConditionEvaluate( ExitOnFailure(hr, "Failed to get length of message."); } - hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, reinterpret_cast(&cchMessage)); + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, &cchMessage); if (E_MOREDATA == hr) { ++cchMessage; @@ -99,7 +99,7 @@ DAPI_(HRESULT) BalConditionEvaluate( hr = StrAllocSecure(psczMessage, cchMessage); ExitOnFailure(hr, "Failed to allocate string for condition's formatted message."); - hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, reinterpret_cast(&cchMessage)); + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, &cchMessage); } ExitOnFailure(hr, "Failed to format condition's message."); } diff --git a/src/balutil/balinfo.cpp b/src/balutil/balinfo.cpp index 492c8e08..3abb9286 100644 --- a/src/balutil/balinfo.cpp +++ b/src/balutil/balinfo.cpp @@ -261,17 +261,17 @@ static HRESULT ParsePackagesFromXml( hr = XmlGetAttributeEx(pNode, L"Cache", &scz); ExitOnFailure(hr, "Failed to get cache type for package."); - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"no", -1)) + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"remove", -1)) { - prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_NO; + prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_REMOVE; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"yes", -1)) + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"keep", -1)) { - prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_YES; + prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_KEEP; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"always", -1)) + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"force", -1)) { - prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_ALWAYS; + prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_FORCE; } ++iPackage; diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp index faca70f5..7a638219 100644 --- a/src/balutil/balutil.cpp +++ b/src/balutil/balutil.cpp @@ -96,7 +96,7 @@ DAPI_(HRESULT) BalFormatString( ) { HRESULT hr = S_OK; - DWORD cch = 0; + SIZE_T cch = 0; if (!vpEngine) { @@ -106,7 +106,7 @@ DAPI_(HRESULT) BalFormatString( if (*psczOut) { - hr = StrMaxLength(*psczOut, reinterpret_cast(&cch)); + hr = StrMaxLength(*psczOut, &cch); ExitOnFailure(hr, "Failed to determine length of value."); } @@ -172,7 +172,7 @@ DAPI_(BOOL) BalVariableExists( ) { HRESULT hr = S_OK; - DWORD cch = 0; + SIZE_T cch = 0; if (!vpEngine) { @@ -194,7 +194,7 @@ DAPI_(HRESULT) BalGetStringVariable( ) { HRESULT hr = S_OK; - DWORD cch = 0; + SIZE_T cch = 0; if (!vpEngine) { @@ -204,7 +204,7 @@ DAPI_(HRESULT) BalGetStringVariable( if (*psczValue) { - hr = StrMaxLength(*psczValue, reinterpret_cast(&cch)); + hr = StrMaxLength(*psczValue, &cch); ExitOnFailure(hr, "Failed to determine length of value."); } diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index a47e994f..73153d5e 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 054bfb26..ee2e452f 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -222,7 +222,8 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectPackageComplete( __in_z LPCWSTR /*wzPackageId*/, __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/ + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fCached*/ ) { return S_OK; @@ -257,9 +258,12 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanPackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOL /*fInstallCondition*/, + __in BOOL /*fCached*/, + __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT /*installCondition*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __in BOOTSTRAPPER_CACHE_TYPE /*recommendedCacheType*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, + __inout BOOTSTRAPPER_CACHE_TYPE* /*pRequestedCacheType*/, __inout BOOL* /*pfCancel*/ ) { @@ -313,7 +317,9 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlannedPackage( __in_z LPCWSTR /*wzPackageId*/, __in BOOTSTRAPPER_ACTION_STATE /*execute*/, - __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/, + __in BOOL /*fPlannedCache*/, + __in BOOL /*fPlannedUncache*/ ) { return S_OK; diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 812025eb..bf21c4a5 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -228,7 +228,8 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectPackageComplete( __in_z LPCWSTR /*wzPackageId*/, __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/ + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fCached*/ ) { return S_OK; @@ -265,9 +266,12 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanPackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOL /*fInstallCondition*/, + __in BOOL /*fCached*/, + __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT /*installCondition*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __in BOOTSTRAPPER_CACHE_TYPE /*recommendedCacheType*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, + __inout BOOTSTRAPPER_CACHE_TYPE* /*pRequestedCacheType*/, __inout BOOL* pfCancel ) { @@ -325,7 +329,9 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlannedPackage( __in_z LPCWSTR /*wzPackageId*/, __in BOOTSTRAPPER_ACTION_STATE /*execute*/, - __in BOOTSTRAPPER_ACTION_STATE /*rollback*/ + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/, + __in BOOL /*fPlannedCache*/, + __in BOOL /*fPlannedUncache*/ ) { return S_OK; diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index 10769529..7fe3ffd8 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -159,7 +159,7 @@ static HRESULT BalBaseBAProcOnDetectPackageComplete( __inout BA_ONDETECTPACKAGECOMPLETE_RESULTS* /*pResults*/ ) { - return pBA->OnDetectPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state); + return pBA->OnDetectPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state, pArgs->fCached); } static HRESULT BalBaseBAProcOnPlanRelatedBundle( @@ -177,7 +177,7 @@ static HRESULT BalBaseBAProcOnPlanPackageBegin( __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults ) { - return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->state, pArgs->fInstallCondition, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); + return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->state, pArgs->fCached, pArgs->installCondition, pArgs->recommendedState, pArgs->recommendedCacheType, &pResults->requestedState, &pResults->requestedCacheType, &pResults->fCancel); } static HRESULT BalBaseBAProcOnPlanPatchTarget( @@ -213,7 +213,7 @@ static HRESULT BalBaseBAProcOnPlannedPackage( __inout BA_ONPLANNEDPACKAGE_RESULTS* /*pResults*/ ) { - return pBA->OnPlannedPackage(pArgs->wzPackageId, pArgs->execute, pArgs->rollback); + return pBA->OnPlannedPackage(pArgs->wzPackageId, pArgs->execute, pArgs->rollback, pArgs->fPlannedCache, pArgs->fPlannedUncache); } static HRESULT BalBaseBAProcOnApplyBegin( diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index 7d6a7164..c284cb49 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -135,7 +135,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnDetectPackageComplete)( __in_z LPCWSTR wzPackageId, __in HRESULT hrStatus, - __in BOOTSTRAPPER_PACKAGE_STATE state + __in BOOTSTRAPPER_PACKAGE_STATE state, + __in BOOL fCached ) = 0; // OnDetectPackageComplete - called after the engine completes detection. @@ -164,9 +165,12 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnPlanPackageBegin)( __in_z LPCWSTR wzPackageId, __in BOOTSTRAPPER_PACKAGE_STATE state, - __in BOOL fInstallCondition, + __in BOOL fCached, + __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __in BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOTSTRAPPER_CACHE_TYPE* pRequestedCacheType, __inout BOOL* pfCancel ) = 0; @@ -214,7 +218,9 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnPlannedPackage)( __in_z LPCWSTR wzPackageId, __in BOOTSTRAPPER_ACTION_STATE execute, - __in BOOTSTRAPPER_ACTION_STATE rollback + __in BOOTSTRAPPER_ACTION_STATE rollback, + __in BOOL fPlannedCache, + __in BOOL fPlannedUncache ) = 0; // OnPlanComplete - called when the engine completes planning. diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h index af6379f4..ccb07f4f 100644 --- a/src/balutil/inc/IBootstrapperEngine.h +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -16,25 +16,25 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(GetVariableString)( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) = 0; STDMETHOD(GetVariableVersion)( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T * pcchValue ) = 0; STDMETHOD(FormatString)( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD* pcchOut + __inout SIZE_T * pcchOut ) = 0; STDMETHOD(EscapeString)( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD* pcchOut + __inout SIZE_T * pcchOut ) = 0; STDMETHOD(EvaluateCondition)( @@ -114,7 +114,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 ) = 0; STDMETHOD(Apply)( - __in_opt HWND hwndParent + __in HWND hwndParent ) = 0; STDMETHOD(Quit)( diff --git a/src/balutil/inc/balinfo.h b/src/balutil/inc/balinfo.h index 0d838ae3..8c2155e9 100644 --- a/src/balutil/inc/balinfo.h +++ b/src/balutil/inc/balinfo.h @@ -18,13 +18,6 @@ typedef enum BAL_INFO_PACKAGE_TYPE BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, } BAL_INFO_PACKAGE_TYPE; -typedef enum BAL_INFO_CACHE_TYPE -{ - BAL_INFO_CACHE_TYPE_NO, - BAL_INFO_CACHE_TYPE_YES, - BAL_INFO_CACHE_TYPE_ALWAYS, -} BAL_INFO_CACHE_TYPE; - typedef struct _BAL_INFO_PACKAGE { @@ -39,7 +32,7 @@ typedef struct _BAL_INFO_PACKAGE LPWSTR sczUpgradeCode; LPWSTR sczVersion; LPWSTR sczInstallCondition; - BAL_INFO_CACHE_TYPE cacheType; + BOOTSTRAPPER_CACHE_TYPE cacheType; BOOL fPrereqPackage; LPWSTR sczPrereqLicenseFile; LPWSTR sczPrereqLicenseUrl; diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index affa4925..fad8a471 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h @@ -51,7 +51,7 @@ DAPI_(void) BalInitialize( ********************************************************************/ DAPI_(HRESULT) BalInitializeFromCreateArgs( __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __out IBootstrapperEngine** ppEngine + __out_opt IBootstrapperEngine** ppEngine ); /******************************************************************* diff --git a/src/balutil/packages.config b/src/balutil/packages.config index de70fed1..08ea3364 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp index 9906a7f5..6043e2db 100644 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -56,7 +56,7 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP EscapeString( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD* pcchOut + __inout SIZE_T* pcchOut ) { HRESULT hr = S_OK; @@ -107,7 +107,7 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP FormatString( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD* pcchOut + __inout SIZE_T* pcchOut ) { HRESULT hr = S_OK; @@ -159,7 +159,7 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP GetVariableString( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) { HRESULT hr = S_OK; @@ -186,7 +186,7 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP GetVariableVersion( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) { HRESULT hr = S_OK; diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index c8671f3b..b3ce96ba 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h index a96e3812..63dadb06 100644 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -7,18 +7,18 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(EscapeString)( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD * pcchOut + __inout SIZE_T* pcchOut ) = 0; STDMETHOD(EvaluateCondition)( __in_z LPCWSTR wzCondition, - __out BOOL * pf + __out BOOL* pf ) = 0; STDMETHOD(FormatString)( __in_z LPCWSTR wzIn, __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout DWORD * pcchOut + __inout SIZE_T* pcchOut ) = 0; STDMETHOD(GetVariableNumeric)( @@ -29,13 +29,13 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(GetVariableString)( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) = 0; STDMETHOD(GetVariableVersion)( __in_z LPCWSTR wzVariable, __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout DWORD* pcchValue + __inout SIZE_T* pcchValue ) = 0; STDMETHOD(Log)( diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index de70fed1..08ea3364 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 729d5df2..f91fe3be 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,11 +2,11 @@ - + - + @@ -96,7 +96,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index b5ba712e..745fcae9 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 95d7ed5f..b7bbd77d 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -3,9 +3,9 @@ - - - + + + Debug @@ -50,10 +50,10 @@ - ..\..\..\packages\WixBuildTools.TestSupport.4.0.47\lib\net472\WixBuildTools.TestSupport.dll + ..\..\..\packages\WixBuildTools.TestSupport.4.0.50\lib\net472\WixBuildTools.TestSupport.dll - ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.47\lib\net472\WixBuildTools.TestSupport.Native.dll + ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.50\lib\net472\WixBuildTools.TestSupport.Native.dll @@ -62,14 +62,14 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index 49b76211..6d381fbe 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -1,10 +1,10 @@  - - - - + + + + diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index 886e3c2c..f45b9b83 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -3,9 +3,9 @@ - - - + + + Debug @@ -49,10 +49,10 @@ - ..\..\..\packages\WixBuildTools.TestSupport.4.0.47\lib\net472\WixBuildTools.TestSupport.dll + ..\..\..\packages\WixBuildTools.TestSupport.4.0.50\lib\net472\WixBuildTools.TestSupport.dll - ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.47\lib\net472\WixBuildTools.TestSupport.Native.dll + ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.50\lib\net472\WixBuildTools.TestSupport.Native.dll @@ -61,14 +61,14 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index 49b76211..6d381fbe 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -1,10 +1,10 @@  - - - - + + + + -- cgit v1.2.3-55-g6feb From d2f27517dffc02b7c50e386793c7ad89762c6b64 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 21 Apr 2021 11:01:10 -0700 Subject: Integrate new build scripts with signing support --- .gitignore | 43 ++++++-- appveyor.cmd | 5 +- signing.json | 13 +++ src/CSharp.Build.props | 13 --- src/Cpp.Build.props | 112 -------------------- src/Directory.Build.props | 5 +- src/Directory.Build.targets | 85 +++++++++------ src/Directory.csproj.props | 13 +++ src/Directory.vcxproj.props | 115 +++++++++++++++++++++ src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 12 +-- src/balutil/balutil.vcxproj | 6 +- src/bextutil/bextutil.vcxproj | 6 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 1 + src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 1 + .../WixToolsetTest.Mba.Core.csproj | 1 + 15 files changed, 236 insertions(+), 195 deletions(-) create mode 100644 signing.json delete mode 100644 src/CSharp.Build.props delete mode 100644 src/Cpp.Build.props create mode 100644 src/Directory.csproj.props create mode 100644 src/Directory.vcxproj.props (limited to 'src') diff --git a/.gitignore b/.gitignore index 3e8a1553..3a8542dc 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -20,12 +23,14 @@ [Rr]eleases/ x64/ x86/ +[Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +[Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ @@ -39,9 +44,10 @@ Generated\ Files/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -# NUNIT +# NUnit *.VisualState.xml TestResult.xml +nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ @@ -56,6 +62,9 @@ project.lock.json project.fragment.lock.json artifacts/ +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + # StyleCop StyleCopReport.xml @@ -122,9 +131,6 @@ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -# JustCode is a .NET coding add-in -.JustCode - # TeamCity is a build add-in _TeamCity* @@ -135,6 +141,11 @@ _TeamCity* .axoCover/* !.axoCover/settings.json +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + # Visual Studio code coverage results *.coverage *.coveragexml @@ -182,6 +193,8 @@ PublishScripts/ # NuGet Packages *.nupkg +# NuGet Symbol Packages +*.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. @@ -206,6 +219,8 @@ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx +*.appxbundle +*.appxupload # Visual Studio cache files # files ending in .cache can be ignored @@ -231,8 +246,6 @@ orleans.codegen.cs # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ -# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true -**/wwwroot/lib/ # RIA/Silverlight projects Generated_Code/ @@ -257,6 +270,9 @@ ServiceFabricBackup/ *.bim.layout *.bim_*.settings *.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ @@ -292,10 +308,6 @@ paket-files/ # FAKE - F# Make .fake/ -# JetBrains Rider -.idea/ -*.sln.iml - # CodeRush personal settings .cr/personal @@ -337,5 +349,14 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ -# BeatPulse healthcheck temp database +# BeatPulse healthcheck temp database healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/appveyor.cmd b/appveyor.cmd index 19c2d49f..d765e3ea 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -1,6 +1,7 @@ @setlocal @pushd %~dp0 @set _C=Release +@if /i "%1"=="debug" set _C=Debug nuget restore || exit /b @@ -17,8 +18,8 @@ msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 || exit /b dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b -msbuild -t:Pack -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b -msbuild -t:Pack -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b +msbuild -t:PackNative -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b +msbuild -t:PackNative -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b @popd diff --git a/signing.json b/signing.json new file mode 100644 index 00000000..fe1c8c9b --- /dev/null +++ b/signing.json @@ -0,0 +1,13 @@ +{ + "SignClient": { + "AzureAd": { + "AADInstance": "https://login.microsoftonline.com/", + "ClientId": "c248d68a-ba6f-4aa9-8a68-71fe872063f8", + "TenantId": "16076fdc-fcc1-4a15-b1ca-32c9a255900e" + }, + "Service": { + "Url": "https://codesign.dotnetfoundation.org/", + "ResourceId": "https://SignService/3c30251f-36f3-490b-a955-520addb85001" + } + } +} diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props deleted file mode 100644 index 81d24ad1..00000000 --- a/src/CSharp.Build.props +++ /dev/null @@ -1,13 +0,0 @@ - - - - - true - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - false - - diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props deleted file mode 100644 index 4d2da36f..00000000 --- a/src/Cpp.Build.props +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - Win32 - $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ - $(OutputPath)$(Platform)\ - - - $(Company) - $(Copyright) - - - - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - $(MSBuildThisFileDirectory)CustomizedNativeRecommendedRules.ruleset - - - - - $(DisableSpecificCompilerWarnings) - Level4 - $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - Use - precomp.h - StdCall - true - false - -YlprecompDefine - /Zc:threadSafeInit- %(AdditionalOptions) - true - - - $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) - $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) - - - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) - - - $(ProjectSubSystem) - $(ProjectModuleDefinitionFile) - $(ResourceOnlyDll) - true - $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) - /IGNORE:4099 %(AdditionalOptions) - - - - - - NoExtensions - - - - - CDecl - - - - - OldStyle - true - true - - - - - Disabled - EnableFastChecks - _DEBUG;DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - - MultiThreadedDebugDll - - - - - MinSpace - NDEBUG;%(PreprocessorDefinitions) - true - true - MultiThreaded - - - true - true - - - - - - MultiThreadedDll - - - - - $(LinkKeyFile) - $(LinkDelaySign) - - - diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f83cc154..fb34d54e 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,7 +8,6 @@ Debug false - MSB3246 $(MSBuildProjectName) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) @@ -22,8 +21,6 @@ WiX Toolset - - - + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index cb988931..44701fb6 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -4,53 +4,70 @@ Do NOT modify this file. Update the canonical version in Home\repo-template\src\Directory.Build.targets then update all of the repos. --> - - false - $(OutputPath)\$(AssemblyName).xml + $(BaseOutputPath)obj\.tools + $(SigningToolFolder)\SignClient.exe + $(SigningToolFolder)\empty-filelist.txt + $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), signing.json))\signing.json - true - $(SolutionPath) - $(NCrunchOriginalSolutionPath) + false + $(OutputPath)\$(AssemblyName).xml - - + + + $(PrivateRepositoryUrl.Replace('.git','')) + + $(MSBuildProjectName).nuspec + $(MSBuildProjectDirectory) + $(NuspecProperties);Id=$(PackageId);Authors="$(Authors)";Configuration=$(Configuration);Copyright="$(Copyright)";Description="$(Description)";Title="$(Title)" + $(NuspecProperties);Version=$(NPMPackageVersion);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl) + true + snupkg + + + + + + + + + + + + + - - $([System.IO.File]::ReadAllText($(TheSolutionPath))) - $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) - (?<="[PackageName]", ")(.*)(?=", ") - + - - - - %(Identity) - $(SolutionFileContent.Contains('\%(Identity).csproj')) - + + - - - $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) - $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) - + - + + - - - + + + + - - + + - + diff --git a/src/Directory.csproj.props b/src/Directory.csproj.props new file mode 100644 index 00000000..81d24ad1 --- /dev/null +++ b/src/Directory.csproj.props @@ -0,0 +1,13 @@ + + + + + true + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + false + + diff --git a/src/Directory.vcxproj.props b/src/Directory.vcxproj.props new file mode 100644 index 00000000..9ea7071b --- /dev/null +++ b/src/Directory.vcxproj.props @@ -0,0 +1,115 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + $(Company) + $(Copyright) + + win-x86;win-x64;win-arm64 + native,Version=v0.0 + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + $(MSBuildThisFileDirectory)CustomizedNativeRecommendedRules.ruleset + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj index 1cfc8c11..2bd7ca80 100644 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -19,6 +19,7 @@ + $(OutputPath) $(MSBuildProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt $(NCrunchOriginalProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt @@ -27,7 +28,7 @@ - + @@ -55,11 +56,4 @@ - - - - $(OutputPath) - Id=$(MSBuildThisFileName);Version=$(BuildVersionSimple);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl) - - - \ No newline at end of file + diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 73153d5e..ab33f159 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -39,6 +39,7 @@ v142 MultiByte WiX Toolset Bootstrapper Application Layer native utility library + WixToolset.BalUtil @@ -88,11 +89,6 @@ - - - - diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index b3ce96ba..b9334cf3 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -39,6 +39,7 @@ v142 MultiByte WiX Toolset Bundle Extension native utility library + WixToolset.BextUtil @@ -77,11 +78,6 @@ - - - - diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index b7bbd77d..d3a81e2a 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -24,6 +24,7 @@ DynamicLibrary Unicode true + false diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index f45b9b83..a9937894 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -24,6 +24,7 @@ DynamicLibrary Unicode true + false diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj index 9d9b9c2b..53d82f7e 100644 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj +++ b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -6,6 +6,7 @@ netcoreapp3.1 false win-x86 + false -- cgit v1.2.3-55-g6feb From 8eb98efd2175d9ece2e4639d43081667af9a4990 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 21 Apr 2021 11:01:33 -0700 Subject: Migrate Burn API headers from burn repository --- appveyor.cmd | 1 + .../WixToolset.BootstrapperCore.Native.nuspec | 19 + .../WixToolset.BootstrapperCore.Native.proj | 19 + .../build/WixToolset.BootstrapperCore.Native.props | 13 + .../inc/BootstrapperApplication.h | 1318 ++++++++++++++++++++ .../inc/BootstrapperEngine.h | 442 +++++++ .../inc/BundleExtension.h | 60 + .../inc/BundleExtensionEngine.h | 184 +++ 8 files changed, 2056 insertions(+) create mode 100644 src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec create mode 100644 src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj create mode 100644 src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props create mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h create mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h create mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h create mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index d765e3ea..26f75243 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -20,6 +20,7 @@ dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.M msbuild -t:PackNative -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b msbuild -t:PackNative -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b +msbuild -t:PackNative -p:Configuration=%_C% src\WixToolset.BootstrapperCore.Native\WixToolset.BootstrapperCore.Native.proj || exit /b msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b @popd diff --git a/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec b/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec new file mode 100644 index 00000000..b10b75d2 --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec @@ -0,0 +1,19 @@ + + + + $id$ + $version$ + WiX Toolset Team + WiX Toolset Team + MS-RL + https://github.com/wixtoolset/BootstrapperCore + false + $description$ + $copyright$ + + + + + + + diff --git a/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj b/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj new file mode 100644 index 00000000..0899bdcf --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj @@ -0,0 +1,19 @@ + + + + + + + WixToolset.BootstrapperCore.Native + WiX Bootstrapper native interfaces + + + + + + + + + + + diff --git a/src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props b/src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props new file mode 100644 index 00000000..82f81163 --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props @@ -0,0 +1,13 @@ + + + + + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h new file mode 100644 index 00000000..2a6d5c8a --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h @@ -0,0 +1,1318 @@ +#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_RESTART +{ + BOOTSTRAPPER_RESTART_UNKNOWN, + BOOTSTRAPPER_RESTART_NEVER, + BOOTSTRAPPER_RESTART_PROMPT, + BOOTSTRAPPER_RESTART_AUTOMATIC, + BOOTSTRAPPER_RESTART_ALWAYS, +}; + +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_PENDING, // reboot has not taken place yet + 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_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, + BOOTSTRAPPER_RELATION_UPDATE, +}; + +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_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_ONSYSTEMSHUTDOWN, + 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, +}; + +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_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_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; + BOOTSTRAPPER_RESTART restart; + + 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_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; +}; + +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_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; +}; + +struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD cbSize; +}; + +struct BA_ONDETECTBEGIN_ARGS +{ + DWORD cbSize; + BOOL fInstalled; + DWORD cPackages; + BOOL fCached; +}; + +struct BA_ONDETECTBEGIN_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; + BOOTSTRAPPER_RELATED_OPERATION operation; + BOOL fMissingFromCache; +}; + +struct BA_ONDETECTRELATEDBUNDLE_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 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; +}; + +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_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_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; +}; + +struct BA_ONPLANMSIPACKAGE_RESULTS +{ + DWORD cbSize; + BOOL fCancel; + BURN_MSI_PROPERTY actionMsiProperty; + INSTALLUILEVEL uiLevel; + BOOL fDisableExternalUiHandler; +}; + +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; +}; + +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_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; +}; + +struct BA_ONREGISTERBEGIN_RESULTS +{ + DWORD cbSize; + BOOL fCancel; +}; + +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; +}; + +struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_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_ONSYSTEMSHUTDOWN_ARGS +{ + DWORD cbSize; + DWORD dwEndSession; +}; + +struct BA_ONSYSTEMSHUTDOWN_RESULTS +{ + DWORD cbSize; + BOOL fCancel; +}; + +struct BA_ONUNREGISTERBEGIN_ARGS +{ + DWORD cbSize; + BOOL fKeepRegistration; +}; + +struct BA_ONUNREGISTERBEGIN_RESULTS +{ + DWORD cbSize; + BOOL fForceKeepRegistration; +}; + +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 + ); + +extern "C" typedef void (WINAPI *PFN_BOOTSTRAPPER_APPLICATION_DESTROY)(); + + + +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; + BOOL fDisableUnloading; // indicates the BA dll must not be unloaded after BootstrapperApplicationDestroy. +}; + +extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_APPLICATION_CREATE)( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ); diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h new file mode 100644 index 00000000..9c9b38a5 --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h @@ -0,0 +1,442 @@ +#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); + +// Note that ordering of the enumeration values is important. +// Some code paths use < or > comparisions and simply reording values will break those comparisons. +enum BOOTSTRAPPER_ACTION +{ + BOOTSTRAPPER_ACTION_UNKNOWN, + BOOTSTRAPPER_ACTION_HELP, + BOOTSTRAPPER_ACTION_LAYOUT, + 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_MEND, + 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_MEND, + 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, +}; + +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; + BYTE* rgbHash; + DWORD cbHash; +} 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; + + +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/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h new file mode 100644 index 00000000..be76a1a5 --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h @@ -0,0 +1,60 @@ +#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 + +enum BUNDLE_EXTENSION_MESSAGE +{ + BUNDLE_EXTENSION_MESSAGE_SEARCH, +}; + +typedef struct _BUNDLE_EXTENSION_SEARCH_ARGS +{ + DWORD cbSize; + LPCWSTR wzId; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_SEARCH_ARGS; + +typedef struct _BUNDLE_EXTENSION_SEARCH_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_SEARCH_RESULTS; + +extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_PROC)( + __in BUNDLE_EXTENSION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + +typedef struct _BUNDLE_EXTENSION_CREATE_ARGS +{ + DWORD cbSize; + DWORD64 qwEngineAPIVersion; + PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc; + LPVOID pvBundleExtensionEngineProcContext; + LPCWSTR wzBootstrapperWorkingFolder; + LPCWSTR wzBundleExtensionDataPath; + LPCWSTR wzExtensionId; +} BUNDLE_EXTENSION_CREATE_ARGS; + +typedef struct _BUNDLE_EXTENSION_CREATE_RESULTS +{ + DWORD cbSize; + PFN_BUNDLE_EXTENSION_PROC pfnBundleExtensionProc; + LPVOID pvBundleExtensionProcContext; +} BUNDLE_EXTENSION_CREATE_RESULTS; + +extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_CREATE)( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults + ); + +extern "C" typedef void (WINAPI *PFN_BUNDLE_EXTENSION_DESTROY)(); + +#if defined(__cplusplus) +} +#endif diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h new file mode 100644 index 00000000..b397ec16 --- /dev/null +++ b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h @@ -0,0 +1,184 @@ +#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 + +enum BUNDLE_EXTENSION_LOG_LEVEL +{ + BUNDLE_EXTENSION_LOG_LEVEL_NONE, // turns off report (only valid for XXXSetLevel()) + BUNDLE_EXTENSION_LOG_LEVEL_STANDARD, // written if reporting is on + BUNDLE_EXTENSION_LOG_LEVEL_VERBOSE, // written only if verbose reporting is on + BUNDLE_EXTENSION_LOG_LEVEL_DEBUG, // reporting useful when debugging code + BUNDLE_EXTENSION_LOG_LEVEL_ERROR, // always gets reported, but can never be specified +}; + +enum BUNDLE_EXTENSION_ENGINE_MESSAGE +{ + BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, + BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, + BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, + BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, +}; + +typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS +{ + DWORD cbSize; + LPCWSTR wzVersion1; + LPCWSTR wzVersion2; +} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS +{ + DWORD cbSize; + int nResult; +} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzIn; +} BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS +{ + DWORD cbSize; + LPWSTR wzOut; + // Should be initialized to the size of wzOut. + SIZE_T cchOut; +} BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS +{ + DWORD cbSize; + LPCWSTR wzCondition; +} BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS +{ + DWORD cbSize; + BOOL f; +} BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzIn; +} BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS +{ + DWORD cbSize; + LPWSTR wzOut; + // Should be initialized to the size of wzOut. + SIZE_T cchOut; +} BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS +{ + DWORD cbSize; + LONGLONG llValue; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS +{ + DWORD cbSize; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + SIZE_T cchValue; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS +{ + DWORD cbSize; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + SIZE_T cchValue; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_LOG_ARGS +{ + DWORD cbSize; + BUNDLE_EXTENSION_LOG_LEVEL level; + LPCWSTR wzMessage; +} BUNDLE_EXTENSION_ENGINE_LOG_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_LOG_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_LOG_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; + LONGLONG llValue; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; + LPCWSTR wzValue; + BOOL fFormatted; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; + LPCWSTR wzValue; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS; + +extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_ENGINE_PROC)( + __in BUNDLE_EXTENSION_ENGINE_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + +#if defined(__cplusplus) +} +#endif -- cgit v1.2.3-55-g6feb From c00516901e6b67e398396b14fe7682d0376f8643 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 05:46:03 -0700 Subject: Move balutil into API/burn --- .editorconfig | 37 - README.md | 2 - appveyor.cmd | 27 - appveyor.yml | 42 - balutil.sln | 113 - nuget.config | 10 - signing.json | 13 - src/.editorconfig | 37 + src/CustomizedNativeRecommendedRules.ruleset | 8 - src/Directory.Build.props | 26 - src/Directory.Build.targets | 73 - src/Directory.csproj.props | 13 - src/Directory.vcxproj.props | 115 - src/NativeMultiTargeting.Build.props | 10 - .../WixToolset.BootstrapperCore.Native.nuspec | 19 - .../WixToolset.BootstrapperCore.Native.proj | 19 - .../build/WixToolset.BootstrapperCore.Native.props | 13 - .../inc/BootstrapperApplication.h | 1318 ------------ .../inc/BootstrapperEngine.h | 442 ---- .../inc/BundleExtension.h | 60 - .../inc/BundleExtensionEngine.h | 184 -- src/WixToolset.Mba.Core/BalUtil.cs | 22 - .../BaseBootstrapperApplicationFactory.cs | 63 - src/WixToolset.Mba.Core/BootstrapperApplication.cs | 1873 ----------------- .../BootstrapperApplicationData.cs | 101 - .../BootstrapperApplicationFactoryAttribute.cs | 35 - src/WixToolset.Mba.Core/BootstrapperCommand.cs | 145 -- src/WixToolset.Mba.Core/BundleInfo.cs | 86 - src/WixToolset.Mba.Core/Engine.cs | 541 ----- src/WixToolset.Mba.Core/EventArgs.cs | 2186 -------------------- .../IBootstrapperApplication.cs | 1917 ----------------- .../IBootstrapperApplicationData.cs | 22 - .../IBootstrapperApplicationFactory.cs | 66 - src/WixToolset.Mba.Core/IBootstrapperCommand.cs | 76 - src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 536 ----- src/WixToolset.Mba.Core/IBundleInfo.cs | 39 - .../IDefaultBootstrapperApplication.cs | 387 ---- src/WixToolset.Mba.Core/IEngine.cs | 222 -- src/WixToolset.Mba.Core/IPackageInfo.cs | 90 - src/WixToolset.Mba.Core/NativeMethods.cs | 37 - src/WixToolset.Mba.Core/PackageInfo.cs | 317 --- src/WixToolset.Mba.Core/VerUtil.cs | 145 -- src/WixToolset.Mba.Core/VerUtilVersion.cs | 99 - .../VerUtilVersionReleaseLabel.cs | 36 - src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 59 - src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 33 - .../burn/CustomizedNativeRecommendedRules.ruleset | 8 + src/api/burn/Directory.Build.props | 26 + src/api/burn/Directory.Build.targets | 73 + src/api/burn/Directory.csproj.props | 13 + src/api/burn/Directory.vcxproj.props | 115 + src/api/burn/NativeMultiTargeting.Build.props | 10 + src/api/burn/README.md | 2 + .../WixToolset.BootstrapperCore.Native.nuspec | 19 + .../WixToolset.BootstrapperCore.Native.proj | 19 + .../build/WixToolset.BootstrapperCore.Native.props | 13 + .../inc/BootstrapperApplication.h | 1318 ++++++++++++ .../inc/BootstrapperEngine.h | 442 ++++ .../inc/BundleExtension.h | 60 + .../inc/BundleExtensionEngine.h | 184 ++ src/api/burn/WixToolset.Mba.Core/BalUtil.cs | 22 + .../BaseBootstrapperApplicationFactory.cs | 63 + .../WixToolset.Mba.Core/BootstrapperApplication.cs | 1873 +++++++++++++++++ .../BootstrapperApplicationData.cs | 101 + .../BootstrapperApplicationFactoryAttribute.cs | 35 + .../WixToolset.Mba.Core/BootstrapperCommand.cs | 145 ++ src/api/burn/WixToolset.Mba.Core/BundleInfo.cs | 86 + src/api/burn/WixToolset.Mba.Core/Engine.cs | 541 +++++ src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 2186 ++++++++++++++++++++ .../IBootstrapperApplication.cs | 1917 +++++++++++++++++ .../IBootstrapperApplicationData.cs | 22 + .../IBootstrapperApplicationFactory.cs | 66 + .../WixToolset.Mba.Core/IBootstrapperCommand.cs | 76 + .../WixToolset.Mba.Core/IBootstrapperEngine.cs | 536 +++++ src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs | 39 + .../IDefaultBootstrapperApplication.cs | 387 ++++ src/api/burn/WixToolset.Mba.Core/IEngine.cs | 222 ++ src/api/burn/WixToolset.Mba.Core/IPackageInfo.cs | 90 + src/api/burn/WixToolset.Mba.Core/NativeMethods.cs | 37 + src/api/burn/WixToolset.Mba.Core/PackageInfo.cs | 317 +++ src/api/burn/WixToolset.Mba.Core/VerUtil.cs | 145 ++ src/api/burn/WixToolset.Mba.Core/VerUtilVersion.cs | 99 + .../VerUtilVersionReleaseLabel.cs | 36 + .../WixToolset.Mba.Core/WixToolset.Mba.Core.csproj | 59 + .../WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec | 33 + src/api/burn/appveyor.cmd | 27 + src/api/burn/appveyor.yml | 42 + src/api/burn/balutil.sln | 113 + src/api/burn/balutil/BalBootstrapperEngine.cpp | 629 ++++++ src/api/burn/balutil/balcondition.cpp | 124 ++ src/api/burn/balutil/balinfo.cpp | 373 ++++ src/api/burn/balutil/balretry.cpp | 246 +++ src/api/burn/balutil/balutil.cpp | 425 ++++ src/api/burn/balutil/balutil.nuspec | 31 + src/api/burn/balutil/balutil.vcxproj | 101 + .../burn/balutil/build/WixToolset.BalUtil.props | 28 + src/api/burn/balutil/inc/BAFunctions.h | 147 ++ src/api/burn/balutil/inc/BalBaseBAFunctions.h | 867 ++++++++ src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h | 124 ++ .../balutil/inc/BalBaseBootstrapperApplication.h | 1076 ++++++++++ .../inc/BalBaseBootstrapperApplicationProc.h | 901 ++++++++ src/api/burn/balutil/inc/BalBootstrapperEngine.h | 17 + src/api/burn/balutil/inc/IBAFunctions.h | 34 + .../burn/balutil/inc/IBootstrapperApplication.h | 649 ++++++ .../balutil/inc/IBootstrapperApplicationFactory.h | 13 + src/api/burn/balutil/inc/IBootstrapperEngine.h | 140 ++ src/api/burn/balutil/inc/balcondition.h | 58 + src/api/burn/balutil/inc/balinfo.h | 105 + src/api/burn/balutil/inc/balretry.h | 74 + src/api/burn/balutil/inc/balutil.h | 199 ++ src/api/burn/balutil/packages.config | 6 + src/api/burn/balutil/precomp.cpp | 3 + src/api/burn/balutil/precomp.h | 32 + .../burn/bextutil/BextBundleExtensionEngine.cpp | 344 +++ src/api/burn/bextutil/bextutil.cpp | 221 ++ src/api/burn/bextutil/bextutil.nuspec | 31 + src/api/burn/bextutil/bextutil.vcxproj | 90 + .../burn/bextutil/build/WixToolset.BextUtil.props | 28 + .../burn/bextutil/inc/BextBaseBundleExtension.h | 120 ++ .../bextutil/inc/BextBaseBundleExtensionProc.h | 48 + .../burn/bextutil/inc/BextBundleExtensionEngine.h | 17 + src/api/burn/bextutil/inc/IBundleExtension.h | 20 + src/api/burn/bextutil/inc/IBundleExtensionEngine.h | 67 + src/api/burn/bextutil/inc/bextutil.h | 106 + src/api/burn/bextutil/packages.config | 6 + src/api/burn/bextutil/precomp.cpp | 3 + src/api/burn/bextutil/precomp.h | 22 + src/api/burn/mbanative/mbanative.cpp | 29 + src/api/burn/mbanative/mbanative.def | 12 + src/api/burn/mbanative/mbanative.vcxproj | 102 + src/api/burn/mbanative/packages.config | 9 + src/api/burn/mbanative/precomp.cpp | 3 + src/api/burn/mbanative/precomp.h | 16 + src/api/burn/nuget.config | 10 + .../test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 76 + .../BalUtilUnitTest.vcxproj.filters | 33 + .../burn/test/BalUtilUnitTest/TestBAFunctions.cpp | 41 + .../TestBootstrapperApplication.cpp | 39 + src/api/burn/test/BalUtilUnitTest/packages.config | 15 + src/api/burn/test/BalUtilUnitTest/precomp.cpp | 3 + src/api/burn/test/BalUtilUnitTest/precomp.h | 23 + .../test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 75 + .../BextUtilUnitTest.vcxproj.filters | 30 + .../test/BextUtilUnitTest/TestBundleExtension.cpp | 42 + src/api/burn/test/BextUtilUnitTest/packages.config | 15 + src/api/burn/test/BextUtilUnitTest/precomp.cpp | 3 + src/api/burn/test/BextUtilUnitTest/precomp.h | 19 + .../BaseBootstrapperApplicationFactoryFixture.cs | 132 ++ .../test/WixToolsetTest.Mba.Core/VerUtilFixture.cs | 93 + .../WixToolsetTest.Mba.Core.csproj | 21 + .../WixToolsetTest.Mba.Core.v3.ncrunchproject | 5 + src/balutil/BalBootstrapperEngine.cpp | 629 ------ src/balutil/balcondition.cpp | 124 -- src/balutil/balinfo.cpp | 373 ---- src/balutil/balretry.cpp | 246 --- src/balutil/balutil.cpp | 425 ---- src/balutil/balutil.nuspec | 31 - src/balutil/balutil.vcxproj | 101 - src/balutil/build/WixToolset.BalUtil.props | 28 - src/balutil/inc/BAFunctions.h | 147 -- src/balutil/inc/BalBaseBAFunctions.h | 867 -------- src/balutil/inc/BalBaseBAFunctionsProc.h | 124 -- src/balutil/inc/BalBaseBootstrapperApplication.h | 1076 ---------- .../inc/BalBaseBootstrapperApplicationProc.h | 901 -------- src/balutil/inc/BalBootstrapperEngine.h | 17 - src/balutil/inc/IBAFunctions.h | 34 - src/balutil/inc/IBootstrapperApplication.h | 649 ------ src/balutil/inc/IBootstrapperApplicationFactory.h | 13 - src/balutil/inc/IBootstrapperEngine.h | 140 -- src/balutil/inc/balcondition.h | 58 - src/balutil/inc/balinfo.h | 105 - src/balutil/inc/balretry.h | 74 - src/balutil/inc/balutil.h | 199 -- src/balutil/packages.config | 6 - src/balutil/precomp.cpp | 3 - src/balutil/precomp.h | 32 - src/bextutil/BextBundleExtensionEngine.cpp | 344 --- src/bextutil/bextutil.cpp | 221 -- src/bextutil/bextutil.nuspec | 31 - src/bextutil/bextutil.vcxproj | 90 - src/bextutil/build/WixToolset.BextUtil.props | 28 - src/bextutil/inc/BextBaseBundleExtension.h | 120 -- src/bextutil/inc/BextBaseBundleExtensionProc.h | 48 - src/bextutil/inc/BextBundleExtensionEngine.h | 17 - src/bextutil/inc/IBundleExtension.h | 20 - src/bextutil/inc/IBundleExtensionEngine.h | 67 - src/bextutil/inc/bextutil.h | 106 - src/bextutil/packages.config | 6 - src/bextutil/precomp.cpp | 3 - src/bextutil/precomp.h | 22 - src/mbanative/mbanative.cpp | 29 - src/mbanative/mbanative.def | 12 - src/mbanative/mbanative.vcxproj | 102 - src/mbanative/packages.config | 9 - src/mbanative/precomp.cpp | 3 - src/mbanative/precomp.h | 16 - src/signing.json | 13 + src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 76 - .../BalUtilUnitTest.vcxproj.filters | 33 - src/test/BalUtilUnitTest/TestBAFunctions.cpp | 41 - .../TestBootstrapperApplication.cpp | 39 - src/test/BalUtilUnitTest/packages.config | 15 - src/test/BalUtilUnitTest/precomp.cpp | 3 - src/test/BalUtilUnitTest/precomp.h | 23 - src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 75 - .../BextUtilUnitTest.vcxproj.filters | 30 - src/test/BextUtilUnitTest/TestBundleExtension.cpp | 42 - src/test/BextUtilUnitTest/packages.config | 15 - src/test/BextUtilUnitTest/precomp.cpp | 3 - src/test/BextUtilUnitTest/precomp.h | 19 - .../BaseBootstrapperApplicationFactoryFixture.cs | 132 -- src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs | 93 - .../WixToolsetTest.Mba.Core.csproj | 21 - .../WixToolsetTest.Mba.Core.v3.ncrunchproject | 5 - src/version.json | 11 + version.json | 11 - 216 files changed, 20049 insertions(+), 20049 deletions(-) delete mode 100644 .editorconfig delete mode 100644 README.md delete mode 100644 appveyor.cmd delete mode 100644 appveyor.yml delete mode 100644 balutil.sln delete mode 100644 nuget.config delete mode 100644 signing.json create mode 100644 src/.editorconfig delete mode 100644 src/CustomizedNativeRecommendedRules.ruleset delete mode 100644 src/Directory.Build.props delete mode 100644 src/Directory.Build.targets delete mode 100644 src/Directory.csproj.props delete mode 100644 src/Directory.vcxproj.props delete mode 100644 src/NativeMultiTargeting.Build.props delete mode 100644 src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec delete mode 100644 src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj delete mode 100644 src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props delete mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h delete mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h delete mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h delete mode 100644 src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h delete mode 100644 src/WixToolset.Mba.Core/BalUtil.cs delete mode 100644 src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs delete mode 100644 src/WixToolset.Mba.Core/BootstrapperApplication.cs delete mode 100644 src/WixToolset.Mba.Core/BootstrapperApplicationData.cs delete mode 100644 src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs delete mode 100644 src/WixToolset.Mba.Core/BootstrapperCommand.cs delete mode 100644 src/WixToolset.Mba.Core/BundleInfo.cs delete mode 100644 src/WixToolset.Mba.Core/Engine.cs delete mode 100644 src/WixToolset.Mba.Core/EventArgs.cs delete mode 100644 src/WixToolset.Mba.Core/IBootstrapperApplication.cs delete mode 100644 src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs delete mode 100644 src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs delete mode 100644 src/WixToolset.Mba.Core/IBootstrapperCommand.cs delete mode 100644 src/WixToolset.Mba.Core/IBootstrapperEngine.cs delete mode 100644 src/WixToolset.Mba.Core/IBundleInfo.cs delete mode 100644 src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs delete mode 100644 src/WixToolset.Mba.Core/IEngine.cs delete mode 100644 src/WixToolset.Mba.Core/IPackageInfo.cs delete mode 100644 src/WixToolset.Mba.Core/NativeMethods.cs delete mode 100644 src/WixToolset.Mba.Core/PackageInfo.cs delete mode 100644 src/WixToolset.Mba.Core/VerUtil.cs delete mode 100644 src/WixToolset.Mba.Core/VerUtilVersion.cs delete mode 100644 src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs delete mode 100644 src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj delete mode 100644 src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec create mode 100644 src/api/burn/CustomizedNativeRecommendedRules.ruleset create mode 100644 src/api/burn/Directory.Build.props create mode 100644 src/api/burn/Directory.Build.targets create mode 100644 src/api/burn/Directory.csproj.props create mode 100644 src/api/burn/Directory.vcxproj.props create mode 100644 src/api/burn/NativeMultiTargeting.Build.props create mode 100644 src/api/burn/README.md create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h create mode 100644 src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h create mode 100644 src/api/burn/WixToolset.Mba.Core/BalUtil.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationData.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/BundleInfo.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/Engine.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/EventArgs.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationData.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IBootstrapperCommand.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IEngine.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/IPackageInfo.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/NativeMethods.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/PackageInfo.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/VerUtil.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/VerUtilVersion.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs create mode 100644 src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj create mode 100644 src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec create mode 100644 src/api/burn/appveyor.cmd create mode 100644 src/api/burn/appveyor.yml create mode 100644 src/api/burn/balutil.sln create mode 100644 src/api/burn/balutil/BalBootstrapperEngine.cpp create mode 100644 src/api/burn/balutil/balcondition.cpp create mode 100644 src/api/burn/balutil/balinfo.cpp create mode 100644 src/api/burn/balutil/balretry.cpp create mode 100644 src/api/burn/balutil/balutil.cpp create mode 100644 src/api/burn/balutil/balutil.nuspec create mode 100644 src/api/burn/balutil/balutil.vcxproj create mode 100644 src/api/burn/balutil/build/WixToolset.BalUtil.props create mode 100644 src/api/burn/balutil/inc/BAFunctions.h create mode 100644 src/api/burn/balutil/inc/BalBaseBAFunctions.h create mode 100644 src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h create mode 100644 src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h create mode 100644 src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h create mode 100644 src/api/burn/balutil/inc/BalBootstrapperEngine.h create mode 100644 src/api/burn/balutil/inc/IBAFunctions.h create mode 100644 src/api/burn/balutil/inc/IBootstrapperApplication.h create mode 100644 src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h create mode 100644 src/api/burn/balutil/inc/IBootstrapperEngine.h create mode 100644 src/api/burn/balutil/inc/balcondition.h create mode 100644 src/api/burn/balutil/inc/balinfo.h create mode 100644 src/api/burn/balutil/inc/balretry.h create mode 100644 src/api/burn/balutil/inc/balutil.h create mode 100644 src/api/burn/balutil/packages.config create mode 100644 src/api/burn/balutil/precomp.cpp create mode 100644 src/api/burn/balutil/precomp.h create mode 100644 src/api/burn/bextutil/BextBundleExtensionEngine.cpp create mode 100644 src/api/burn/bextutil/bextutil.cpp create mode 100644 src/api/burn/bextutil/bextutil.nuspec create mode 100644 src/api/burn/bextutil/bextutil.vcxproj create mode 100644 src/api/burn/bextutil/build/WixToolset.BextUtil.props create mode 100644 src/api/burn/bextutil/inc/BextBaseBundleExtension.h create mode 100644 src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h create mode 100644 src/api/burn/bextutil/inc/BextBundleExtensionEngine.h create mode 100644 src/api/burn/bextutil/inc/IBundleExtension.h create mode 100644 src/api/burn/bextutil/inc/IBundleExtensionEngine.h create mode 100644 src/api/burn/bextutil/inc/bextutil.h create mode 100644 src/api/burn/bextutil/packages.config create mode 100644 src/api/burn/bextutil/precomp.cpp create mode 100644 src/api/burn/bextutil/precomp.h create mode 100644 src/api/burn/mbanative/mbanative.cpp create mode 100644 src/api/burn/mbanative/mbanative.def create mode 100644 src/api/burn/mbanative/mbanative.vcxproj create mode 100644 src/api/burn/mbanative/packages.config create mode 100644 src/api/burn/mbanative/precomp.cpp create mode 100644 src/api/burn/mbanative/precomp.h create mode 100644 src/api/burn/nuget.config create mode 100644 src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj create mode 100644 src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters create mode 100644 src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp create mode 100644 src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp create mode 100644 src/api/burn/test/BalUtilUnitTest/packages.config create mode 100644 src/api/burn/test/BalUtilUnitTest/precomp.cpp create mode 100644 src/api/burn/test/BalUtilUnitTest/precomp.h create mode 100644 src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj create mode 100644 src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters create mode 100644 src/api/burn/test/BextUtilUnitTest/TestBundleExtension.cpp create mode 100644 src/api/burn/test/BextUtilUnitTest/packages.config create mode 100644 src/api/burn/test/BextUtilUnitTest/precomp.cpp create mode 100644 src/api/burn/test/BextUtilUnitTest/precomp.h create mode 100644 src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs create mode 100644 src/api/burn/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs create mode 100644 src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj create mode 100644 src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject delete mode 100644 src/balutil/BalBootstrapperEngine.cpp delete mode 100644 src/balutil/balcondition.cpp delete mode 100644 src/balutil/balinfo.cpp delete mode 100644 src/balutil/balretry.cpp delete mode 100644 src/balutil/balutil.cpp delete mode 100644 src/balutil/balutil.nuspec delete mode 100644 src/balutil/balutil.vcxproj delete mode 100644 src/balutil/build/WixToolset.BalUtil.props delete mode 100644 src/balutil/inc/BAFunctions.h delete mode 100644 src/balutil/inc/BalBaseBAFunctions.h delete mode 100644 src/balutil/inc/BalBaseBAFunctionsProc.h delete mode 100644 src/balutil/inc/BalBaseBootstrapperApplication.h delete mode 100644 src/balutil/inc/BalBaseBootstrapperApplicationProc.h delete mode 100644 src/balutil/inc/BalBootstrapperEngine.h delete mode 100644 src/balutil/inc/IBAFunctions.h delete mode 100644 src/balutil/inc/IBootstrapperApplication.h delete mode 100644 src/balutil/inc/IBootstrapperApplicationFactory.h delete mode 100644 src/balutil/inc/IBootstrapperEngine.h delete mode 100644 src/balutil/inc/balcondition.h delete mode 100644 src/balutil/inc/balinfo.h delete mode 100644 src/balutil/inc/balretry.h delete mode 100644 src/balutil/inc/balutil.h delete mode 100644 src/balutil/packages.config delete mode 100644 src/balutil/precomp.cpp delete mode 100644 src/balutil/precomp.h delete mode 100644 src/bextutil/BextBundleExtensionEngine.cpp delete mode 100644 src/bextutil/bextutil.cpp delete mode 100644 src/bextutil/bextutil.nuspec delete mode 100644 src/bextutil/bextutil.vcxproj delete mode 100644 src/bextutil/build/WixToolset.BextUtil.props delete mode 100644 src/bextutil/inc/BextBaseBundleExtension.h delete mode 100644 src/bextutil/inc/BextBaseBundleExtensionProc.h delete mode 100644 src/bextutil/inc/BextBundleExtensionEngine.h delete mode 100644 src/bextutil/inc/IBundleExtension.h delete mode 100644 src/bextutil/inc/IBundleExtensionEngine.h delete mode 100644 src/bextutil/inc/bextutil.h delete mode 100644 src/bextutil/packages.config delete mode 100644 src/bextutil/precomp.cpp delete mode 100644 src/bextutil/precomp.h delete mode 100644 src/mbanative/mbanative.cpp delete mode 100644 src/mbanative/mbanative.def delete mode 100644 src/mbanative/mbanative.vcxproj delete mode 100644 src/mbanative/packages.config delete mode 100644 src/mbanative/precomp.cpp delete mode 100644 src/mbanative/precomp.h create mode 100644 src/signing.json delete mode 100644 src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj delete mode 100644 src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters delete mode 100644 src/test/BalUtilUnitTest/TestBAFunctions.cpp delete mode 100644 src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp delete mode 100644 src/test/BalUtilUnitTest/packages.config delete mode 100644 src/test/BalUtilUnitTest/precomp.cpp delete mode 100644 src/test/BalUtilUnitTest/precomp.h delete mode 100644 src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj delete mode 100644 src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters delete mode 100644 src/test/BextUtilUnitTest/TestBundleExtension.cpp delete mode 100644 src/test/BextUtilUnitTest/packages.config delete mode 100644 src/test/BextUtilUnitTest/precomp.cpp delete mode 100644 src/test/BextUtilUnitTest/precomp.h delete mode 100644 src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs delete mode 100644 src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs delete mode 100644 src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj delete mode 100644 src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject create mode 100644 src/version.json delete mode 100644 version.json (limited to 'src') diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1d72e683..00000000 --- a/.editorconfig +++ /dev/null @@ -1,37 +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. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig -# then update all of the repos. - -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true - -[*.{cs,vb}] -dotnet_sort_system_directives_first = true - -[*.cs] -csharp_indent_case_contents = true : error -csharp_indent_switch_labels = true : error -csharp_new_line_before_open_brace = all -csharp_prefer_braces = true : error -csharp_style_expression_bodied_methods = when_on_single_line : suggestion -csharp_style_expression_bodied_constructors = when_on_single_line : suggestion -csharp_style_expression_bodied_operators = when_on_single_line : suggestion -csharp_style_expression_bodied_properties = when_on_single_line : suggestion -csharp_style_expression_bodied_indexers = when_on_single_line : suggestion -csharp_style_expression_bodied_accessors = when_on_single_line : suggestion -csharp_style_var_elsewhere = true : suggestion -csharp_style_var_for_built_in_types = true : suggestion -csharp_style_var_when_type_is_apparent = true : suggestion -dotnet_style_qualification_for_event = true : error -dotnet_style_qualification_for_field = true : error -dotnet_style_qualification_for_method = true : error -dotnet_style_qualification_for_property = true : error - -[*.targets] -indent_size = 2 diff --git a/README.md b/README.md deleted file mode 100644 index 380bbda3..00000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# balutil -balutil.lib - WiX Toolset Bootstrapper Application Layer native utility library diff --git a/appveyor.cmd b/appveyor.cmd deleted file mode 100644 index 26f75243..00000000 --- a/appveyor.cmd +++ /dev/null @@ -1,27 +0,0 @@ -@setlocal -@pushd %~dp0 -@set _C=Release -@if /i "%1"=="debug" set _C=Debug - -nuget restore || exit /b - -msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v140 || exit /b -msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v140 || exit /b - -msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 || exit /b -msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v141 || exit /b -msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v141 || exit /b - -msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v142 || exit /b -msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 || exit /b -msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 || exit /b - -dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b - -msbuild -t:PackNative -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b -msbuild -t:PackNative -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b -msbuild -t:PackNative -p:Configuration=%_C% src\WixToolset.BootstrapperCore.Native\WixToolset.BootstrapperCore.Native.proj || exit /b -msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b - -@popd -@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e4d25586..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,42 +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. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml -# then update all of the repos. - -branches: - only: - - master - - develop - -image: Visual Studio 2019 - -version: 0.0.0.{build} -configuration: Release - -environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - NUGET_XMLDOC_MODE: skip - -build_script: - - appveyor.cmd - -test: off - -pull_requests: - do_not_increment_build_number: true - -nuget: - disable_publish_on_pr: true - -skip_branch_with_pr: true -skip_tags: true - -artifacts: -- path: build\Release\**\*.nupkg - name: nuget - -notifications: -- provider: Slack - incoming_webhook: - secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/balutil.sln b/balutil.sln deleted file mode 100644 index cae580f3..00000000 --- a/balutil.sln +++ /dev/null @@ -1,113 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balutil.vcxproj", "{EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bextutil", "src\bextutil\bextutil.vcxproj", "{06027492-1CB9-48BC-B31E-C1F9356ED07E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbanative", "src\mbanative\mbanative.vcxproj", "{665E0441-17F9-4105-B202-EDF274657F6E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Mba.Core", "src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj", "{F54997F7-10D7-409B-B9F2-DB546490EDC0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BalUtilUnitTest", "src\test\BalUtilUnitTest\BalUtilUnitTest.vcxproj", "{9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BextUtilUnitTest", "src\test\BextUtilUnitTest\BextUtilUnitTest.vcxproj", "{B69E6422-49B0-4E28-92F9-B8A7410A6ED9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM64.Build.0 = Debug|ARM64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.ActiveCfg = Debug|x64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.Build.0 = Debug|x64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.ActiveCfg = Debug|Win32 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.Build.0 = Debug|Win32 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM64.ActiveCfg = Release|ARM64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM64.Build.0 = Release|ARM64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.ActiveCfg = Release|x64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.Build.0 = Release|x64 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.ActiveCfg = Release|Win32 - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.Build.0 = Release|Win32 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM64.Build.0 = Debug|ARM64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.ActiveCfg = Debug|x64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.Build.0 = Debug|x64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.ActiveCfg = Debug|Win32 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.Build.0 = Debug|Win32 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM64.ActiveCfg = Release|ARM64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM64.Build.0 = Release|ARM64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.ActiveCfg = Release|x64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.Build.0 = Release|x64 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.ActiveCfg = Release|Win32 - {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.Build.0 = Release|Win32 - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM64.Build.0 = Debug|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.ActiveCfg = Debug|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.Build.0 = Debug|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.ActiveCfg = Debug|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.Build.0 = Debug|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM64.ActiveCfg = Release|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM64.Build.0 = Release|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.ActiveCfg = Release|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.ActiveCfg = Release|Any CPU - {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.Build.0 = Release|Any CPU - {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM64.Build.0 = Debug|ARM64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.ActiveCfg = Debug|x64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.Build.0 = Debug|x64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.ActiveCfg = Debug|Win32 - {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.Build.0 = Debug|Win32 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM64.ActiveCfg = Release|ARM64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM64.Build.0 = Release|ARM64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.ActiveCfg = Release|x64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.Build.0 = Release|x64 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.ActiveCfg = Release|Win32 - {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.Build.0 = Release|Win32 - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM64.Build.0 = Debug|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.ActiveCfg = Debug|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.Build.0 = Debug|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.ActiveCfg = Debug|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.Build.0 = Debug|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM64.ActiveCfg = Release|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM64.Build.0 = Release|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.ActiveCfg = Release|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.Build.0 = Release|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.ActiveCfg = Release|Any CPU - {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.Build.0 = Release|Any CPU - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|ARM64.ActiveCfg = Debug|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x64.ActiveCfg = Debug|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x86.ActiveCfg = Debug|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x86.Build.0 = Debug|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|ARM64.ActiveCfg = Release|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x64.ActiveCfg = Release|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x86.ActiveCfg = Release|Win32 - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x86.Build.0 = Release|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|ARM64.ActiveCfg = Debug|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x64.ActiveCfg = Debug|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x86.ActiveCfg = Debug|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x86.Build.0 = Debug|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|ARM64.ActiveCfg = Release|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x64.ActiveCfg = Release|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x86.ActiveCfg = Release|Win32 - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8741FA43-6BD2-40F9-ABA5-A5BD466A6518} - EndGlobalSection -EndGlobal diff --git a/nuget.config b/nuget.config deleted file mode 100644 index 2c6c5608..00000000 --- a/nuget.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/signing.json b/signing.json deleted file mode 100644 index fe1c8c9b..00000000 --- a/signing.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "SignClient": { - "AzureAd": { - "AADInstance": "https://login.microsoftonline.com/", - "ClientId": "c248d68a-ba6f-4aa9-8a68-71fe872063f8", - "TenantId": "16076fdc-fcc1-4a15-b1ca-32c9a255900e" - }, - "Service": { - "Url": "https://codesign.dotnetfoundation.org/", - "ResourceId": "https://SignService/3c30251f-36f3-490b-a955-520addb85001" - } - } -} diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,37 @@ +# 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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/src/CustomizedNativeRecommendedRules.ruleset b/src/CustomizedNativeRecommendedRules.ruleset deleted file mode 100644 index 142b141c..00000000 --- a/src/CustomizedNativeRecommendedRules.ruleset +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index fb34d54e..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - Debug - false - - $(MSBuildProjectName) - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) - $(BaseOutputPath)obj\$(ProjectName)\ - $(BaseOutputPath)$(Configuration)\ - - WiX Toolset Team - WiX Toolset - Copyright (c) .NET Foundation and contributors. All rights reserved. - MS-RL - WiX Toolset - - - - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index 44701fb6..00000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - $(BaseOutputPath)obj\.tools - $(SigningToolFolder)\SignClient.exe - $(SigningToolFolder)\empty-filelist.txt - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), signing.json))\signing.json - - - - false - $(OutputPath)\$(AssemblyName).xml - - - - - $(PrivateRepositoryUrl.Replace('.git','')) - - $(MSBuildProjectName).nuspec - $(MSBuildProjectDirectory) - $(NuspecProperties);Id=$(PackageId);Authors="$(Authors)";Configuration=$(Configuration);Copyright="$(Copyright)";Description="$(Description)";Title="$(Title)" - $(NuspecProperties);Version=$(NPMPackageVersion);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl) - true - snupkg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Directory.csproj.props b/src/Directory.csproj.props deleted file mode 100644 index 81d24ad1..00000000 --- a/src/Directory.csproj.props +++ /dev/null @@ -1,13 +0,0 @@ - - - - - true - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - false - - diff --git a/src/Directory.vcxproj.props b/src/Directory.vcxproj.props deleted file mode 100644 index 9ea7071b..00000000 --- a/src/Directory.vcxproj.props +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - Win32 - $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ - $(OutputPath)$(Platform)\ - - - $(Company) - $(Copyright) - - win-x86;win-x64;win-arm64 - native,Version=v0.0 - - - - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - $(MSBuildThisFileDirectory)CustomizedNativeRecommendedRules.ruleset - - - - - $(DisableSpecificCompilerWarnings) - Level4 - $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - Use - precomp.h - StdCall - true - false - -YlprecompDefine - /Zc:threadSafeInit- %(AdditionalOptions) - true - - - $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) - $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) - - - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) - - - $(ProjectSubSystem) - $(ProjectModuleDefinitionFile) - $(ResourceOnlyDll) - true - $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) - /IGNORE:4099 %(AdditionalOptions) - - - - - - NoExtensions - - - - - CDecl - - - - - OldStyle - true - true - - - - - Disabled - EnableFastChecks - _DEBUG;DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - - MultiThreadedDebugDll - - - - - MinSpace - NDEBUG;%(PreprocessorDefinitions) - true - true - MultiThreaded - - - true - true - - - - - - MultiThreadedDll - - - - - $(LinkKeyFile) - $(LinkDelaySign) - - - diff --git a/src/NativeMultiTargeting.Build.props b/src/NativeMultiTargeting.Build.props deleted file mode 100644 index 1ff46559..00000000 --- a/src/NativeMultiTargeting.Build.props +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - $(BaseIntermediateOutputPath)$(Configuration)\$(PlatformToolset)\$(PlatformTarget)\ - $(OutputPath)$(PlatformToolset)\$(PlatformTarget)\ - - diff --git a/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec b/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec deleted file mode 100644 index b10b75d2..00000000 --- a/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec +++ /dev/null @@ -1,19 +0,0 @@ - - - - $id$ - $version$ - WiX Toolset Team - WiX Toolset Team - MS-RL - https://github.com/wixtoolset/BootstrapperCore - false - $description$ - $copyright$ - - - - - - - diff --git a/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj b/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj deleted file mode 100644 index 0899bdcf..00000000 --- a/src/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - WixToolset.BootstrapperCore.Native - WiX Bootstrapper native interfaces - - - - - - - - - - - diff --git a/src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props b/src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props deleted file mode 100644 index 82f81163..00000000 --- a/src/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) - - - $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) - - - diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h deleted file mode 100644 index 2a6d5c8a..00000000 --- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h +++ /dev/null @@ -1,1318 +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_RESTART -{ - BOOTSTRAPPER_RESTART_UNKNOWN, - BOOTSTRAPPER_RESTART_NEVER, - BOOTSTRAPPER_RESTART_PROMPT, - BOOTSTRAPPER_RESTART_AUTOMATIC, - BOOTSTRAPPER_RESTART_ALWAYS, -}; - -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_PENDING, // reboot has not taken place yet - 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_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, - BOOTSTRAPPER_RELATION_UPDATE, -}; - -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_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_ONSYSTEMSHUTDOWN, - 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, -}; - -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_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_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; - BOOTSTRAPPER_RESTART restart; - - 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_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; -}; - -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_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; -}; - -struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS -{ - DWORD cbSize; -}; - -struct BA_ONDETECTBEGIN_ARGS -{ - DWORD cbSize; - BOOL fInstalled; - DWORD cPackages; - BOOL fCached; -}; - -struct BA_ONDETECTBEGIN_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; - BOOTSTRAPPER_RELATED_OPERATION operation; - BOOL fMissingFromCache; -}; - -struct BA_ONDETECTRELATEDBUNDLE_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 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; -}; - -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_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_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; -}; - -struct BA_ONPLANMSIPACKAGE_RESULTS -{ - DWORD cbSize; - BOOL fCancel; - BURN_MSI_PROPERTY actionMsiProperty; - INSTALLUILEVEL uiLevel; - BOOL fDisableExternalUiHandler; -}; - -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; -}; - -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_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; -}; - -struct BA_ONREGISTERBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -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; -}; - -struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_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_ONSYSTEMSHUTDOWN_ARGS -{ - DWORD cbSize; - DWORD dwEndSession; -}; - -struct BA_ONSYSTEMSHUTDOWN_RESULTS -{ - DWORD cbSize; - BOOL fCancel; -}; - -struct BA_ONUNREGISTERBEGIN_ARGS -{ - DWORD cbSize; - BOOL fKeepRegistration; -}; - -struct BA_ONUNREGISTERBEGIN_RESULTS -{ - DWORD cbSize; - BOOL fForceKeepRegistration; -}; - -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 - ); - -extern "C" typedef void (WINAPI *PFN_BOOTSTRAPPER_APPLICATION_DESTROY)(); - - - -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; - BOOL fDisableUnloading; // indicates the BA dll must not be unloaded after BootstrapperApplicationDestroy. -}; - -extern "C" typedef HRESULT(WINAPI *PFN_BOOTSTRAPPER_APPLICATION_CREATE)( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __inout BOOTSTRAPPER_CREATE_RESULTS* pResults - ); diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h deleted file mode 100644 index 9c9b38a5..00000000 --- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h +++ /dev/null @@ -1,442 +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); - -// Note that ordering of the enumeration values is important. -// Some code paths use < or > comparisions and simply reording values will break those comparisons. -enum BOOTSTRAPPER_ACTION -{ - BOOTSTRAPPER_ACTION_UNKNOWN, - BOOTSTRAPPER_ACTION_HELP, - BOOTSTRAPPER_ACTION_LAYOUT, - 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_MEND, - 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_MEND, - 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, -}; - -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; - BYTE* rgbHash; - DWORD cbHash; -} 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; - - -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/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h deleted file mode 100644 index be76a1a5..00000000 --- a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h +++ /dev/null @@ -1,60 +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 - -enum BUNDLE_EXTENSION_MESSAGE -{ - BUNDLE_EXTENSION_MESSAGE_SEARCH, -}; - -typedef struct _BUNDLE_EXTENSION_SEARCH_ARGS -{ - DWORD cbSize; - LPCWSTR wzId; - LPCWSTR wzVariable; -} BUNDLE_EXTENSION_SEARCH_ARGS; - -typedef struct _BUNDLE_EXTENSION_SEARCH_RESULTS -{ - DWORD cbSize; -} BUNDLE_EXTENSION_SEARCH_RESULTS; - -extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_PROC)( - __in BUNDLE_EXTENSION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ); - -typedef struct _BUNDLE_EXTENSION_CREATE_ARGS -{ - DWORD cbSize; - DWORD64 qwEngineAPIVersion; - PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc; - LPVOID pvBundleExtensionEngineProcContext; - LPCWSTR wzBootstrapperWorkingFolder; - LPCWSTR wzBundleExtensionDataPath; - LPCWSTR wzExtensionId; -} BUNDLE_EXTENSION_CREATE_ARGS; - -typedef struct _BUNDLE_EXTENSION_CREATE_RESULTS -{ - DWORD cbSize; - PFN_BUNDLE_EXTENSION_PROC pfnBundleExtensionProc; - LPVOID pvBundleExtensionProcContext; -} BUNDLE_EXTENSION_CREATE_RESULTS; - -extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_CREATE)( - __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, - __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults - ); - -extern "C" typedef void (WINAPI *PFN_BUNDLE_EXTENSION_DESTROY)(); - -#if defined(__cplusplus) -} -#endif diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h deleted file mode 100644 index b397ec16..00000000 --- a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h +++ /dev/null @@ -1,184 +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 - -enum BUNDLE_EXTENSION_LOG_LEVEL -{ - BUNDLE_EXTENSION_LOG_LEVEL_NONE, // turns off report (only valid for XXXSetLevel()) - BUNDLE_EXTENSION_LOG_LEVEL_STANDARD, // written if reporting is on - BUNDLE_EXTENSION_LOG_LEVEL_VERBOSE, // written only if verbose reporting is on - BUNDLE_EXTENSION_LOG_LEVEL_DEBUG, // reporting useful when debugging code - BUNDLE_EXTENSION_LOG_LEVEL_ERROR, // always gets reported, but can never be specified -}; - -enum BUNDLE_EXTENSION_ENGINE_MESSAGE -{ - BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, - BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, - BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, - BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, - BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, - BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, - BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, - BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, - BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, - BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, - BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, -}; - -typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS -{ - DWORD cbSize; - LPCWSTR wzVersion1; - LPCWSTR wzVersion2; -} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS -{ - DWORD cbSize; - int nResult; -} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzIn; -} BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS -{ - DWORD cbSize; - LPWSTR wzOut; - // Should be initialized to the size of wzOut. - SIZE_T cchOut; -} BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS -{ - DWORD cbSize; - LPCWSTR wzCondition; -} BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS -{ - DWORD cbSize; - BOOL f; -} BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzIn; -} BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS -{ - DWORD cbSize; - LPWSTR wzOut; - // Should be initialized to the size of wzOut. - SIZE_T cchOut; -} BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; -} BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS -{ - DWORD cbSize; - LONGLONG llValue; -} BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; -} BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS -{ - DWORD cbSize; - LPWSTR wzValue; - // Should be initialized to the size of wzValue. - SIZE_T cchValue; -} BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; -} BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS -{ - DWORD cbSize; - LPWSTR wzValue; - // Should be initialized to the size of wzValue. - SIZE_T cchValue; -} BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_LOG_ARGS -{ - DWORD cbSize; - BUNDLE_EXTENSION_LOG_LEVEL level; - LPCWSTR wzMessage; -} BUNDLE_EXTENSION_ENGINE_LOG_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_LOG_RESULTS -{ - DWORD cbSize; -} BUNDLE_EXTENSION_ENGINE_LOG_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; - LONGLONG llValue; -} BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS -{ - DWORD cbSize; -} BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; - LPCWSTR wzValue; - BOOL fFormatted; -} BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS -{ - DWORD cbSize; -} BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS -{ - DWORD cbSize; - LPCWSTR wzVariable; - LPCWSTR wzValue; -} BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS; - -typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS -{ - DWORD cbSize; -} BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS; - -extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_ENGINE_PROC)( - __in BUNDLE_EXTENSION_ENGINE_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ); - -#if defined(__cplusplus) -} -#endif diff --git a/src/WixToolset.Mba.Core/BalUtil.cs b/src/WixToolset.Mba.Core/BalUtil.cs deleted file mode 100644 index f478eca4..00000000 --- a/src/WixToolset.Mba.Core/BalUtil.cs +++ /dev/null @@ -1,22 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - - internal static class BalUtil - { - [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern IBootstrapperEngine InitializeFromCreateArgs( - IntPtr pArgs, - ref Command pCommand - ); - - [DllImport("mbanative.dll", ExactSpelling = true)] - internal static extern void StoreBAInCreateResults( - IntPtr pResults, - [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA - ); - } -} diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs deleted file mode 100644 index ad8a5dc0..00000000 --- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs +++ /dev/null @@ -1,63 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - - /// - /// Default implementation of . - /// - public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory - { - /// - /// Default implementation of - /// - /// - /// - public void Create(IntPtr pArgs, IntPtr pResults) - { - InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); - - var ba = this.Create(engine, bootstrapperCommand); - StoreBAInCreateResults(pResults, ba); - } - - /// - /// Called by to get the . - /// - /// The bundle engine. - /// Command information passed from the engine for the BA to perform. - /// The for the bundle. - protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); - - /// - /// Initializes the native part of . - /// Most users should inherit from instead of calling this method. - /// - /// 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. - public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) - { - Command pCommand = new Command - { - cbSize = Marshal.SizeOf(typeof(Command)) - }; - var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand); - engine = new Engine(pEngine); - bootstrapperCommand = pCommand.GetBootstrapperCommand(); - } - - /// - /// 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. - /// - /// The results struct given by the engine when initially creating the BA - /// The . - public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) - { - BalUtil.StoreBAInCreateResults(pResults, ba); - } - } -} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs deleted file mode 100644 index 072d3ef0..00000000 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ /dev/null @@ -1,1873 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - using System.Threading; - - /// - /// The default bootstrapper application. - /// - [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; - - private bool applying; - - /// - /// Creates a new instance of the class. - /// - protected BootstrapperApplication(IEngine engine) - { - this.engine = engine; - this.applying = false; - this.asyncExecution = true; - } - - /// - public event EventHandler Startup; - - /// - public event EventHandler Shutdown; - - /// - public event EventHandler SystemShutdown; - - /// - public event EventHandler DetectBegin; - - /// - public event EventHandler DetectForwardCompatibleBundle; - - /// - public event EventHandler DetectUpdateBegin; - - /// - public event EventHandler DetectUpdate; - - /// - public event EventHandler DetectUpdateComplete; - - /// - public event EventHandler DetectRelatedBundle; - - /// - public event EventHandler DetectPackageBegin; - - /// - public event EventHandler DetectRelatedMsiPackage; - - /// - public event EventHandler DetectPatchTarget; - - /// - public event EventHandler DetectMsiFeature; - - /// - public event EventHandler DetectPackageComplete; - - /// - public event EventHandler DetectComplete; - - /// - public event EventHandler PlanBegin; - - /// - public event EventHandler PlanRelatedBundle; - - /// - public event EventHandler PlanPackageBegin; - - /// - public event EventHandler PlanPatchTarget; - - /// - public event EventHandler PlanMsiFeature; - - /// - public event EventHandler PlanMsiPackage; - - /// - public event EventHandler PlanPackageComplete; - - /// - public event EventHandler PlannedPackage; - - /// - public event EventHandler PlanComplete; - - /// - public event EventHandler ApplyBegin; - - /// - public event EventHandler ElevateBegin; - - /// - public event EventHandler ElevateComplete; - - /// - public event EventHandler Progress; - - /// - public event EventHandler Error; - - /// - public event EventHandler RegisterBegin; - - /// - public event EventHandler RegisterComplete; - - /// - public event EventHandler UnregisterBegin; - - /// - public event EventHandler UnregisterComplete; - - /// - public event EventHandler CacheBegin; - - /// - public event EventHandler CachePackageBegin; - - /// - public event EventHandler CacheAcquireBegin; - - /// - public event EventHandler CacheAcquireProgress; - - /// - public event EventHandler CacheAcquireResolving; - - /// - public event EventHandler CacheAcquireComplete; - - /// - public event EventHandler CacheVerifyBegin; - - /// - public event EventHandler CacheVerifyProgress; - - /// - public event EventHandler CacheVerifyComplete; - - /// - public event EventHandler CachePackageComplete; - - /// - public event EventHandler CacheComplete; - - /// - public event EventHandler ExecuteBegin; - - /// - public event EventHandler ExecutePackageBegin; - - /// - public event EventHandler ExecutePatchTarget; - - /// - public event EventHandler ExecuteMsiMessage; - - /// - public event EventHandler ExecuteFilesInUse; - - /// - public event EventHandler ExecutePackageComplete; - - /// - public event EventHandler ExecuteComplete; - - /// - public event EventHandler ApplyComplete; - - /// - public event EventHandler ExecuteProgress; - - /// - public event EventHandler LaunchApprovedExeBegin; - - /// - public event EventHandler LaunchApprovedExeComplete; - - /// - public event EventHandler BeginMsiTransactionBegin; - - /// - public event EventHandler BeginMsiTransactionComplete; - - /// - public event EventHandler CommitMsiTransactionBegin; - - /// - public event EventHandler CommitMsiTransactionComplete; - - /// - public event EventHandler RollbackMsiTransactionBegin; - - /// - public event EventHandler RollbackMsiTransactionComplete; - - /// - public event EventHandler PauseAutomaticUpdatesBegin; - - /// - public event EventHandler PauseAutomaticUpdatesComplete; - - /// - public event EventHandler SystemRestorePointBegin; - - /// - public event EventHandler SystemRestorePointComplete; - - /// - public event EventHandler PlanForwardCompatibleBundle; - - /// - public event EventHandler CacheContainerOrPayloadVerifyBegin; - - /// - public event EventHandler CacheContainerOrPayloadVerifyProgress; - - /// - public event EventHandler CacheContainerOrPayloadVerifyComplete; - - /// - public event EventHandler CachePayloadExtractBegin; - - /// - public event EventHandler CachePayloadExtractProgress; - - /// - public event EventHandler CachePayloadExtractComplete; - - /// - /// Entry point that is called when the bootstrapper application is ready to run. - /// - protected abstract void Run(); - - /// - /// 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) - { - handler(this, args); - } - - if (this.asyncExecution) - { - 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(); - } - else - { - this.engine.Log(LogLevel.Verbose, "Creating BA thread to run synchronously."); - this.Run(); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnShutdown(ShutdownEventArgs args) - { - EventHandler handler = this.Shutdown; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSystemShutdown(SystemShutdownEventArgs args) - { - EventHandler handler = this.SystemShutdown; - if (null != handler) - { - handler(this, args); - } - else if (null != args) - { - // Allow requests to shut down when critical or not applying. - bool critical = EndSessionReasons.Critical == (EndSessionReasons.Critical & args.Reasons); - args.Cancel = !critical && this.applying; - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectBegin(DetectBeginEventArgs args) - { - EventHandler handler = this.DetectBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectForwardCompatibleBundle(DetectForwardCompatibleBundleEventArgs args) - { - EventHandler handler = this.DetectForwardCompatibleBundle; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) - { - EventHandler handler = this.DetectUpdateBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectUpdate(DetectUpdateEventArgs args) - { - EventHandler handler = this.DetectUpdate; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectUpdateComplete(DetectUpdateCompleteEventArgs args) - { - EventHandler handler = this.DetectUpdateComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectRelatedBundle(DetectRelatedBundleEventArgs args) - { - EventHandler handler = this.DetectRelatedBundle; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectPackageBegin(DetectPackageBeginEventArgs args) - { - EventHandler handler = this.DetectPackageBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectRelatedMsiPackage(DetectRelatedMsiPackageEventArgs args) - { - EventHandler handler = this.DetectRelatedMsiPackage; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectPatchTarget(DetectPatchTargetEventArgs args) - { - EventHandler handler = this.DetectPatchTarget; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectMsiFeature(DetectMsiFeatureEventArgs args) - { - EventHandler handler = this.DetectMsiFeature; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectPackageComplete(DetectPackageCompleteEventArgs args) - { - EventHandler handler = this.DetectPackageComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnDetectComplete(DetectCompleteEventArgs args) - { - EventHandler handler = this.DetectComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanBegin(PlanBeginEventArgs args) - { - EventHandler handler = this.PlanBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanRelatedBundle(PlanRelatedBundleEventArgs args) - { - EventHandler handler = this.PlanRelatedBundle; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanPackageBegin(PlanPackageBeginEventArgs args) - { - EventHandler handler = this.PlanPackageBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanPatchTarget(PlanPatchTargetEventArgs args) - { - EventHandler handler = this.PlanPatchTarget; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanMsiFeature(PlanMsiFeatureEventArgs args) - { - EventHandler handler = this.PlanMsiFeature; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanMsiPackage(PlanMsiPackageEventArgs args) - { - EventHandler handler = this.PlanMsiPackage; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanPackageComplete(PlanPackageCompleteEventArgs args) - { - EventHandler handler = this.PlanPackageComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlannedPackage(PlannedPackageEventArgs args) - { - EventHandler handler = this.PlannedPackage; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPlanComplete(PlanCompleteEventArgs args) - { - EventHandler handler = this.PlanComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnApplyBegin(ApplyBeginEventArgs args) - { - EventHandler handler = this.ApplyBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnElevateBegin(ElevateBeginEventArgs args) - { - EventHandler handler = this.ElevateBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnElevateComplete(ElevateCompleteEventArgs args) - { - EventHandler handler = this.ElevateComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnProgress(ProgressEventArgs args) - { - EventHandler handler = this.Progress; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnError(ErrorEventArgs args) - { - EventHandler handler = this.Error; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnRegisterBegin(RegisterBeginEventArgs args) - { - EventHandler handler = this.RegisterBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnRegisterComplete(RegisterCompleteEventArgs args) - { - EventHandler handler = this.RegisterComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnUnregisterBegin(UnregisterBeginEventArgs args) - { - EventHandler handler = this.UnregisterBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnUnregisterComplete(UnregisterCompleteEventArgs args) - { - EventHandler handler = this.UnregisterComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheBegin(CacheBeginEventArgs args) - { - EventHandler handler = this.CacheBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCachePackageBegin(CachePackageBeginEventArgs args) - { - EventHandler handler = this.CachePackageBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheAcquireBegin(CacheAcquireBeginEventArgs args) - { - EventHandler handler = this.CacheAcquireBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args) - { - EventHandler handler = this.CacheAcquireProgress; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnCacheAcquireResolving(CacheAcquireResolvingEventArgs args) - { - EventHandler handler = this.CacheAcquireResolving; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheAcquireComplete(CacheAcquireCompleteEventArgs args) - { - EventHandler handler = this.CacheAcquireComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheVerifyBegin(CacheVerifyBeginEventArgs args) - { - EventHandler handler = this.CacheVerifyBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheVerifyProgress(CacheVerifyProgressEventArgs args) - { - EventHandler handler = this.CacheVerifyProgress; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheVerifyComplete(CacheVerifyCompleteEventArgs args) - { - EventHandler handler = this.CacheVerifyComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCachePackageComplete(CachePackageCompleteEventArgs args) - { - EventHandler handler = this.CachePackageComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnCacheComplete(CacheCompleteEventArgs args) - { - EventHandler handler = this.CacheComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecuteBegin(ExecuteBeginEventArgs args) - { - EventHandler handler = this.ExecuteBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecutePackageBegin(ExecutePackageBeginEventArgs args) - { - EventHandler handler = this.ExecutePackageBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecutePatchTarget(ExecutePatchTargetEventArgs args) - { - EventHandler handler = this.ExecutePatchTarget; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecuteMsiMessage(ExecuteMsiMessageEventArgs args) - { - EventHandler handler = this.ExecuteMsiMessage; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) - { - EventHandler handler = this.ExecuteFilesInUse; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecutePackageComplete(ExecutePackageCompleteEventArgs args) - { - EventHandler handler = this.ExecutePackageComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecuteComplete(ExecuteCompleteEventArgs args) - { - EventHandler handler = this.ExecuteComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnApplyComplete(ApplyCompleteEventArgs args) - { - EventHandler handler = this.ApplyComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnExecuteProgress(ExecuteProgressEventArgs args) - { - EventHandler handler = this.ExecuteProgress; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnLaunchApprovedExeBegin(LaunchApprovedExeBeginEventArgs args) - { - EventHandler handler = this.LaunchApprovedExeBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnLaunchApprovedExeComplete(LaunchApprovedExeCompleteEventArgs args) - { - EventHandler handler = this.LaunchApprovedExeComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnBeginMsiTransactionBegin(BeginMsiTransactionBeginEventArgs args) - { - EventHandler handler = this.BeginMsiTransactionBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnBeginMsiTransactionComplete(BeginMsiTransactionCompleteEventArgs args) - { - EventHandler handler = this.BeginMsiTransactionComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnCommitMsiTransactionBegin(CommitMsiTransactionBeginEventArgs args) - { - EventHandler handler = this.CommitMsiTransactionBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnCommitMsiTransactionComplete(CommitMsiTransactionCompleteEventArgs args) - { - EventHandler handler = this.CommitMsiTransactionComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnRollbackMsiTransactionBegin(RollbackMsiTransactionBeginEventArgs args) - { - EventHandler handler = this.RollbackMsiTransactionBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnRollbackMsiTransactionComplete(RollbackMsiTransactionCompleteEventArgs args) - { - EventHandler handler = this.RollbackMsiTransactionComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPauseAutomaticUpdatesBegin(PauseAutomaticUpdatesBeginEventArgs args) - { - EventHandler handler = this.PauseAutomaticUpdatesBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnPauseAutomaticUpdatesComplete(PauseAutomaticUpdatesCompleteEventArgs args) - { - EventHandler handler = this.PauseAutomaticUpdatesComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSystemRestorePointBegin(SystemRestorePointBeginEventArgs args) - { - EventHandler handler = this.SystemRestorePointBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// Additional arguments for this event. - protected virtual void OnSystemRestorePointComplete(SystemRestorePointCompleteEventArgs args) - { - EventHandler handler = this.SystemRestorePointComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - protected virtual void OnPlanForwardCompatibleBundle(PlanForwardCompatibleBundleEventArgs args) - { - EventHandler handler = this.PlanForwardCompatibleBundle; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheContainerOrPayloadVerifyBegin(CacheContainerOrPayloadVerifyBeginEventArgs args) - { - EventHandler handler = this.CacheContainerOrPayloadVerifyBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheContainerOrPayloadVerifyProgress(CacheContainerOrPayloadVerifyProgressEventArgs args) - { - EventHandler handler = this.CacheContainerOrPayloadVerifyProgress; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCacheContainerOrPayloadVerifyComplete(CacheContainerOrPayloadVerifyCompleteEventArgs args) - { - EventHandler handler = this.CacheContainerOrPayloadVerifyComplete; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCachePayloadExtractBegin(CachePayloadExtractBeginEventArgs args) - { - EventHandler handler = this.CachePayloadExtractBegin; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCachePayloadExtractProgress(CachePayloadExtractProgressEventArgs args) - { - EventHandler handler = this.CachePayloadExtractProgress; - if (null != handler) - { - handler(this, args); - } - } - - /// - /// Called by the engine, raises the event. - /// - /// - protected virtual void OnCachePayloadExtractComplete(CachePayloadExtractCompleteEventArgs args) - { - EventHandler handler = this.CachePayloadExtractComplete; - if (null != handler) - { - handler(this, args); - } - } - - #region IBootstrapperApplication Members - - int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) - { - switch (message) - { - default: - return NativeMethods.E_NOTIMPL; - } - } - - void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) - { - } - - int IBootstrapperApplication.OnStartup() - { - StartupEventArgs args = new StartupEventArgs(); - this.OnStartup(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action) - { - ShutdownEventArgs args = new ShutdownEventArgs(action); - this.OnShutdown(args); - - action = args.Action; - return args.HResult; - } - - int IBootstrapperApplication.OnSystemShutdown(EndSessionReasons dwEndSession, ref bool fCancel) - { - SystemShutdownEventArgs args = new SystemShutdownEventArgs(dwEndSession, fCancel); - this.OnSystemShutdown(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectBegin(bool fCached, bool fInstalled, int cPackages, ref bool fCancel) - { - DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, fInstalled, cPackages, fCancel); - this.OnDetectBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fMissingFromCache, ref bool fCancel) - { - DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, fCancel); - this.OnDetectForwardCompatibleBundle(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectUpdateBegin(string wzUpdateLocation, ref bool fCancel, ref bool fSkip) - { - DetectUpdateBeginEventArgs args = new DetectUpdateBeginEventArgs(wzUpdateLocation, fCancel, fSkip); - this.OnDetectUpdateBegin(args); - - fCancel = args.Cancel; - fSkip = args.Skip; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, string wzVersion, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) - { - DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, wzVersion, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); - this.OnDetectUpdate(args); - - fCancel = args.Cancel; - fStopProcessingUpdates = args.StopProcessingUpdates; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectUpdateComplete(int hrStatus, ref bool fIgnoreError) - { - DetectUpdateCompleteEventArgs args = new DetectUpdateCompleteEventArgs(hrStatus, fIgnoreError); - this.OnDetectUpdateComplete(args); - - fIgnoreError = args.IgnoreError; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, bool fMissingFromCache, ref bool fCancel) - { - DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fMissingFromCache, fCancel); - this.OnDetectRelatedBundle(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectPackageBegin(string wzPackageId, ref bool fCancel) - { - DetectPackageBeginEventArgs args = new DetectPackageBeginEventArgs(wzPackageId, fCancel); - this.OnDetectPackageBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) - { - DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, wzVersion, operation, fCancel); - this.OnDetectRelatedMsiPackage(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectPatchTarget(string wzPackageId, string wzProductCode, PackageState patchState, ref bool fCancel) - { - DetectPatchTargetEventArgs args = new DetectPatchTargetEventArgs(wzPackageId, wzProductCode, patchState, fCancel); - this.OnDetectPatchTarget(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectMsiFeature(string wzPackageId, string wzFeatureId, FeatureState state, ref bool fCancel) - { - DetectMsiFeatureEventArgs args = new DetectMsiFeatureEventArgs(wzPackageId, wzFeatureId, state, fCancel); - this.OnDetectMsiFeature(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnDetectPackageComplete(string wzPackageId, int hrStatus, PackageState state, bool fCached) - { - DetectPackageCompleteEventArgs args = new DetectPackageCompleteEventArgs(wzPackageId, hrStatus, state, fCached); - this.OnDetectPackageComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnDetectComplete(int hrStatus, bool fEligibleForCleanup) - { - DetectCompleteEventArgs args = new DetectCompleteEventArgs(hrStatus, fEligibleForCleanup); - this.OnDetectComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnPlanBegin(int cPackages, ref bool fCancel) - { - PlanBeginEventArgs args = new PlanBeginEventArgs(cPackages, fCancel); - this.OnPlanBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) - { - PlanRelatedBundleEventArgs args = new PlanRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel); - this.OnPlanRelatedBundle(args); - - pRequestedState = args.State; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, PackageState state, bool fCached, BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, RequestState recommendedState, BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, ref RequestState pRequestedState, ref BOOTSTRAPPER_CACHE_TYPE pRequestedCacheType, ref bool fCancel) - { - PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, state, fCached, installCondition, recommendedState, recommendedCacheType, pRequestedState, pRequestedCacheType, fCancel); - this.OnPlanPackageBegin(args); - - pRequestedState = args.State; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanPatchTarget(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) - { - PlanPatchTargetEventArgs args = new PlanPatchTargetEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); - this.OnPlanPatchTarget(args); - - pRequestedState = args.State; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanMsiFeature(string wzPackageId, string wzFeatureId, FeatureState recommendedState, ref FeatureState pRequestedState, ref bool fCancel) - { - PlanMsiFeatureEventArgs args = new PlanMsiFeatureEventArgs(wzPackageId, wzFeatureId, recommendedState, pRequestedState, fCancel); - this.OnPlanMsiFeature(args); - - pRequestedState = args.State; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanMsiPackage(string wzPackageId, bool fExecute, ActionState action, ref bool fCancel, ref BURN_MSI_PROPERTY actionMsiProperty, ref INSTALLUILEVEL uiLevel, ref bool fDisableExternalUiHandler) - { - PlanMsiPackageEventArgs args = new PlanMsiPackageEventArgs(wzPackageId, fExecute, action, fCancel, actionMsiProperty, uiLevel, fDisableExternalUiHandler); - this.OnPlanMsiPackage(args); - - fCancel = args.Cancel; - actionMsiProperty = args.ActionMsiProperty; - uiLevel = args.UiLevel; - fDisableExternalUiHandler = args.DisableExternalUiHandler; - return args.HResult; - } - - int IBootstrapperApplication.OnPlanPackageComplete(string wzPackageId, int hrStatus, RequestState requested) - { - var args = new PlanPackageCompleteEventArgs(wzPackageId, hrStatus, requested); - this.OnPlanPackageComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnPlannedPackage(string wzPackageId, ActionState execute, ActionState rollback, bool fPlannedCache, bool fPlannedUncache) - { - var args = new PlannedPackageEventArgs(wzPackageId, execute, rollback, fPlannedCache, fPlannedUncache); - this.OnPlannedPackage(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnPlanComplete(int hrStatus) - { - PlanCompleteEventArgs args = new PlanCompleteEventArgs(hrStatus); - this.OnPlanComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnApplyBegin(int dwPhaseCount, ref bool fCancel) - { - this.applying = true; - - ApplyBeginEventArgs args = new ApplyBeginEventArgs(dwPhaseCount, fCancel); - this.OnApplyBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnElevateBegin(ref bool fCancel) - { - ElevateBeginEventArgs args = new ElevateBeginEventArgs(fCancel); - this.OnElevateBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnElevateComplete(int hrStatus) - { - ElevateCompleteEventArgs args = new ElevateCompleteEventArgs(hrStatus); - this.OnElevateComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnProgress(int dwProgressPercentage, int dwOverallPercentage, ref bool fCancel) - { - ProgressEventArgs args = new ProgressEventArgs(dwProgressPercentage, dwOverallPercentage, fCancel); - this.OnProgress(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnError(ErrorType errorType, string wzPackageId, int dwCode, string wzError, int dwUIHint, int cData, string[] rgwzData, Result nRecommendation, ref Result pResult) - { - ErrorEventArgs args = new ErrorEventArgs(errorType, wzPackageId, dwCode, wzError, dwUIHint, rgwzData, nRecommendation, pResult); - this.OnError(args); - - pResult = args.Result; - return args.HResult; - } - - int IBootstrapperApplication.OnRegisterBegin(ref bool fCancel) - { - RegisterBeginEventArgs args = new RegisterBeginEventArgs(fCancel); - this.OnRegisterBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnRegisterComplete(int hrStatus) - { - RegisterCompleteEventArgs args = new RegisterCompleteEventArgs(hrStatus); - this.OnRegisterComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnCacheBegin(ref bool fCancel) - { - CacheBeginEventArgs args = new CacheBeginEventArgs(fCancel); - this.OnCacheBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCachePackageBegin(string wzPackageId, int cCachePayloads, long dw64PackageCacheSize, ref bool fCancel) - { - CachePackageBeginEventArgs args = new CachePackageBeginEventArgs(wzPackageId, cCachePayloads, dw64PackageCacheSize, fCancel); - this.OnCachePackageBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, string wzSource, string wzDownloadUrl, string wzPayloadContainerId, CacheOperation recommendation, ref CacheOperation action, ref bool fCancel) - { - CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, wzSource, wzDownloadUrl, wzPayloadContainerId, recommendation, action, fCancel); - this.OnCacheAcquireBegin(args); - - action = args.Action; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheAcquireProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) - { - CacheAcquireProgressEventArgs args = new CacheAcquireProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); - this.OnCacheAcquireProgress(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheAcquireResolving(string wzPackageOrContainerId, string wzPayloadId, string[] searchPaths, int cSearchPaths, bool fFoundLocal, int dwRecommendedSearchPath, string wzDownloadUrl, string wzPayloadContainerId, CacheResolveOperation recommendation, ref int dwChosenSearchPath, ref CacheResolveOperation action, ref bool fCancel) - { - CacheAcquireResolvingEventArgs args = new CacheAcquireResolvingEventArgs(wzPackageOrContainerId, wzPayloadId, searchPaths, fFoundLocal, dwRecommendedSearchPath, wzDownloadUrl, wzPayloadContainerId, recommendation, dwChosenSearchPath, action, fCancel); - this.OnCacheAcquireResolving(args); - - dwChosenSearchPath = args.ChosenSearchPath; - action = args.Action; - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheAcquireComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) - { - CacheAcquireCompleteEventArgs args = new CacheAcquireCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, action); - this.OnCacheAcquireComplete(args); - - action = args.Action; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheVerifyBegin(string wzPackageOrContainerId, string wzPayloadId, ref bool fCancel) - { - CacheVerifyBeginEventArgs args = new CacheVerifyBeginEventArgs(wzPackageOrContainerId, wzPayloadId, fCancel); - this.OnCacheVerifyBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheVerifyProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, CacheVerifyStep verifyStep, ref bool fCancel) - { - CacheVerifyProgressEventArgs args = new CacheVerifyProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, verifyStep, fCancel); - this.OnCacheVerifyProgress(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheVerifyComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) - { - CacheVerifyCompleteEventArgs args = new CacheVerifyCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, action); - this.OnCacheVerifyComplete(args); - - action = args.Action; - return args.HResult; - } - - int IBootstrapperApplication.OnCachePackageComplete(string wzPackageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) - { - CachePackageCompleteEventArgs args = new CachePackageCompleteEventArgs(wzPackageId, hrStatus, recommendation, action); - this.OnCachePackageComplete(args); - - action = args.Action; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheComplete(int hrStatus) - { - CacheCompleteEventArgs args = new CacheCompleteEventArgs(hrStatus); - this.OnCacheComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnExecuteBegin(int cExecutingPackages, ref bool fCancel) - { - ExecuteBeginEventArgs args = new ExecuteBeginEventArgs(cExecutingPackages, fCancel); - this.OnExecuteBegin(args); - - args.Cancel = fCancel; - return args.HResult; - } - - int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ActionState action, INSTALLUILEVEL uiLevel, bool fDisableExternalUiHandler, ref bool fCancel) - { - ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, action, uiLevel, fDisableExternalUiHandler, fCancel); - this.OnExecutePackageBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnExecutePatchTarget(string wzPackageId, string wzTargetProductCode, ref bool fCancel) - { - ExecutePatchTargetEventArgs args = new ExecutePatchTargetEventArgs(wzPackageId, wzTargetProductCode, fCancel); - this.OnExecutePatchTarget(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnExecuteProgress(string wzPackageId, int dwProgressPercentage, int dwOverallPercentage, ref bool fCancel) - { - ExecuteProgressEventArgs args = new ExecuteProgressEventArgs(wzPackageId, dwProgressPercentage, dwOverallPercentage, fCancel); - this.OnExecuteProgress(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnExecuteMsiMessage(string wzPackageId, InstallMessage messageType, int dwUIHint, string wzMessage, int cData, string[] rgwzData, Result nRecommendation, ref Result pResult) - { - ExecuteMsiMessageEventArgs args = new ExecuteMsiMessageEventArgs(wzPackageId, messageType, dwUIHint, wzMessage, rgwzData, nRecommendation, pResult); - this.OnExecuteMsiMessage(args); - - pResult = args.Result; - return args.HResult; - } - - int IBootstrapperApplication.OnExecuteFilesInUse(string wzPackageId, int cFiles, string[] rgwzFiles, Result nRecommendation, ref Result pResult) - { - ExecuteFilesInUseEventArgs args = new ExecuteFilesInUseEventArgs(wzPackageId, rgwzFiles, nRecommendation, pResult); - this.OnExecuteFilesInUse(args); - - pResult = args.Result; - return args.HResult; - } - - int IBootstrapperApplication.OnExecutePackageComplete(string wzPackageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction) - { - ExecutePackageCompleteEventArgs args = new ExecutePackageCompleteEventArgs(wzPackageId, hrStatus, restart, recommendation, pAction); - this.OnExecutePackageComplete(args); - - pAction = args.Action; - return args.HResult; - } - - int IBootstrapperApplication.OnExecuteComplete(int hrStatus) - { - ExecuteCompleteEventArgs args = new ExecuteCompleteEventArgs(hrStatus); - this.OnExecuteComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnUnregisterBegin(bool fKeepRegistration, ref bool fForceKeepRegistration) - { - UnregisterBeginEventArgs args = new UnregisterBeginEventArgs(fKeepRegistration, fForceKeepRegistration); - this.OnUnregisterBegin(args); - - fForceKeepRegistration = args.ForceKeepRegistration; - return args.HResult; - } - - int IBootstrapperApplication.OnUnregisterComplete(int hrStatus) - { - UnregisterCompleteEventArgs args = new UnregisterCompleteEventArgs(hrStatus); - this.OnUnregisterComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnApplyComplete(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction) - { - ApplyCompleteEventArgs args = new ApplyCompleteEventArgs(hrStatus, restart, recommendation, pAction); - this.OnApplyComplete(args); - - this.applying = false; - - pAction = args.Action; - return args.HResult; - } - - int IBootstrapperApplication.OnLaunchApprovedExeBegin(ref bool fCancel) - { - LaunchApprovedExeBeginEventArgs args = new LaunchApprovedExeBeginEventArgs(fCancel); - this.OnLaunchApprovedExeBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnLaunchApprovedExeComplete(int hrStatus, int processId) - { - LaunchApprovedExeCompleteEventArgs args = new LaunchApprovedExeCompleteEventArgs(hrStatus, processId); - this.OnLaunchApprovedExeComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnBeginMsiTransactionBegin(string transactionId, ref bool fCancel) - { - BeginMsiTransactionBeginEventArgs args = new BeginMsiTransactionBeginEventArgs(transactionId, fCancel); - this.OnBeginMsiTransactionBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnBeginMsiTransactionComplete(string transactionId, int hrStatus) - { - BeginMsiTransactionCompleteEventArgs args = new BeginMsiTransactionCompleteEventArgs(transactionId, hrStatus); - this.OnBeginMsiTransactionComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnCommitMsiTransactionBegin(string transactionId, ref bool fCancel) - { - CommitMsiTransactionBeginEventArgs args = new CommitMsiTransactionBeginEventArgs(transactionId, fCancel); - this.OnCommitMsiTransactionBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCommitMsiTransactionComplete(string transactionId, int hrStatus) - { - CommitMsiTransactionCompleteEventArgs args = new CommitMsiTransactionCompleteEventArgs(transactionId, hrStatus); - this.OnCommitMsiTransactionComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnRollbackMsiTransactionBegin(string transactionId) - { - RollbackMsiTransactionBeginEventArgs args = new RollbackMsiTransactionBeginEventArgs(transactionId); - this.OnRollbackMsiTransactionBegin(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnRollbackMsiTransactionComplete(string transactionId, int hrStatus) - { - RollbackMsiTransactionCompleteEventArgs args = new RollbackMsiTransactionCompleteEventArgs(transactionId, hrStatus); - this.OnRollbackMsiTransactionComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnPauseAutomaticUpdatesBegin() - { - PauseAutomaticUpdatesBeginEventArgs args = new PauseAutomaticUpdatesBeginEventArgs(); - this.OnPauseAutomaticUpdatesBegin(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnPauseAutomaticUpdatesComplete(int hrStatus) - { - PauseAutomaticUpdatesCompleteEventArgs args = new PauseAutomaticUpdatesCompleteEventArgs(hrStatus); - this.OnPauseAutomaticUpdatesComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnSystemRestorePointBegin() - { - SystemRestorePointBeginEventArgs args = new SystemRestorePointBeginEventArgs(); - this.OnSystemRestorePointBegin(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnSystemRestorePointComplete(int hrStatus) - { - SystemRestorePointCompleteEventArgs args = new SystemRestorePointCompleteEventArgs(hrStatus); - this.OnSystemRestorePointComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnPlanForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fRecommendedIgnoreBundle, ref bool fCancel, ref bool fIgnoreBundle) - { - PlanForwardCompatibleBundleEventArgs args = new PlanForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fRecommendedIgnoreBundle, fCancel, fIgnoreBundle); - this.OnPlanForwardCompatibleBundle(args); - - fCancel = args.Cancel; - fIgnoreBundle = args.IgnoreBundle; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyBegin(string wzPackageOrContainerId, string wzPayloadId, ref bool fCancel) - { - CacheContainerOrPayloadVerifyBeginEventArgs args = new CacheContainerOrPayloadVerifyBeginEventArgs(wzPackageOrContainerId, wzPayloadId, fCancel); - this.OnCacheContainerOrPayloadVerifyBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) - { - CacheContainerOrPayloadVerifyProgressEventArgs args = new CacheContainerOrPayloadVerifyProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); - this.OnCacheContainerOrPayloadVerifyProgress(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus) - { - CacheContainerOrPayloadVerifyCompleteEventArgs args = new CacheContainerOrPayloadVerifyCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus); - this.OnCacheContainerOrPayloadVerifyComplete(args); - - return args.HResult; - } - - int IBootstrapperApplication.OnCachePayloadExtractBegin(string wzContainerId, string wzPayloadId, ref bool fCancel) - { - CachePayloadExtractBeginEventArgs args = new CachePayloadExtractBeginEventArgs(wzContainerId, wzPayloadId, fCancel); - this.OnCachePayloadExtractBegin(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCachePayloadExtractProgress(string wzContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) - { - CachePayloadExtractProgressEventArgs args = new CachePayloadExtractProgressEventArgs(wzContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); - this.OnCachePayloadExtractProgress(args); - - fCancel = args.Cancel; - return args.HResult; - } - - int IBootstrapperApplication.OnCachePayloadExtractComplete(string wzContainerId, string wzPayloadId, int hrStatus) - { - CachePayloadExtractCompleteEventArgs args = new CachePayloadExtractCompleteEventArgs(wzContainerId, wzPayloadId, hrStatus); - this.OnCachePayloadExtractComplete(args); - - return args.HResult; - } - - #endregion - } -} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs deleted file mode 100644 index 739a08bb..00000000 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationData.cs +++ /dev/null @@ -1,101 +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 WixToolset.Mba.Core -{ - using System; - using System.IO; - using System.Xml.XPath; - - /// - /// Utility class for reading BootstrapperApplicationData.xml. - /// - public class BootstrapperApplicationData : IBootstrapperApplicationData - { - /// - /// - /// - public const string DefaultFileName = "BootstrapperApplicationData.xml"; - - /// - /// - /// - public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/BootstrapperApplicationData"; - - /// - /// The default path of where the BA was extracted to. - /// - public static readonly DirectoryInfo DefaultFolder; - - /// - /// The default path to BootstrapperApplicationData.xml. - /// - public static readonly FileInfo DefaultFile; - - static BootstrapperApplicationData() - { - DefaultFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); - DefaultFile = new FileInfo(Path.Combine(DefaultFolder.FullName, DefaultFileName)); - } - - /// - public FileInfo BADataFile { get; private set; } - - /// - public IBundleInfo Bundle { get; private set; } - - /// - /// Uses the default location for BootstrapperApplicationData.xml. - /// - public BootstrapperApplicationData() : this(DefaultFile) { } - - /// - /// Uses the given file for BootstrapperApplicationData.xml. - /// - /// - public BootstrapperApplicationData(FileInfo baDataFile) - { - this.BADataFile = baDataFile; - - using (FileStream fs = this.BADataFile.OpenRead()) - { - this.Bundle = BundleInfo.ParseBundleFromStream(fs); - } - } - - /// - /// Utility method for parsing BootstrapperApplicationData.xml. - /// - /// - /// - /// - public static string GetAttribute(XPathNavigator node, string attributeName) - { - XPathNavigator attribute = node.SelectSingleNode("@" + attributeName); - - if (attribute == null) - { - return null; - } - - return attribute.Value; - } - - /// - /// Utility method for parsing BootstrapperApplicationData.xml. - /// - /// - /// - /// - public static bool? GetYesNoAttribute(XPathNavigator node, string attributeName) - { - string attributeValue = GetAttribute(node, attributeName); - - if (attributeValue == null) - { - return null; - } - - return attributeValue.Equals("yes", StringComparison.InvariantCulture); - } - } -} diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs deleted file mode 100644 index 95252cf3..00000000 --- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs +++ /dev/null @@ -1,35 +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 WixToolset.Mba.Core -{ - using System; - - /// - /// Identifies the bootstrapper application factory class. - /// - /// - /// This required assembly attribute identifies the bootstrapper application factory class. - /// - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] - public sealed class BootstrapperApplicationFactoryAttribute : Attribute - { - private Type bootstrapperApplicationFactoryType; - - /// - /// Creates a new instance of the class. - /// - /// The of the BA factory. - public BootstrapperApplicationFactoryAttribute(Type bootstrapperApplicationFactoryType) - { - this.bootstrapperApplicationFactoryType = bootstrapperApplicationFactoryType; - } - - /// - /// Gets the type of the bootstrapper application factory class to create. - /// - public Type BootstrapperApplicationFactoryType - { - get { return this.bootstrapperApplicationFactoryType; } - } - } -} diff --git a/src/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/WixToolset.Mba.Core/BootstrapperCommand.cs deleted file mode 100644 index 65dde0f4..00000000 --- a/src/WixToolset.Mba.Core/BootstrapperCommand.cs +++ /dev/null @@ -1,145 +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 WixToolset.Mba.Core -{ - using System; - using System.ComponentModel; - using System.Runtime.InteropServices; - - /// - /// Default implementation of . - /// - public sealed class BootstrapperCommand : IBootstrapperCommand - { - private readonly string commandLine; - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public BootstrapperCommand( - LaunchAction action, - Display display, - Restart restart, - string commandLine, - int cmdShow, - ResumeType resume, - IntPtr splashScreen, - RelationType relation, - bool passthrough, - string layoutDirectory, - string bootstrapperWorkingFolder, - string bootstrapperApplicationDataPath) - { - this.Action = action; - this.Display = display; - this.Restart = restart; - this.commandLine = commandLine; - this.CmdShow = cmdShow; - this.Resume = resume; - this.SplashScreen = splashScreen; - this.Relation = relation; - this.Passthrough = passthrough; - this.LayoutDirectory = layoutDirectory; - this.BootstrapperWorkingFolder = bootstrapperWorkingFolder; - this.BootstrapperApplicationDataPath = bootstrapperApplicationDataPath; - } - - /// - public LaunchAction Action { get; } - - /// - public Display Display { get; } - - /// - public Restart Restart { get; } - - /// - public string[] CommandLineArgs => GetCommandLineArgs(this.commandLine); - - /// - public int CmdShow { get; } - - /// - public ResumeType Resume { get; } - - /// - public IntPtr SplashScreen { get; } - - /// - public RelationType Relation { get; } - - /// - public bool Passthrough { get; } - - /// - public string LayoutDirectory { get; } - - /// - public string BootstrapperWorkingFolder { get; } - - /// - public string BootstrapperApplicationDataPath { get; } - - /// - /// Gets the command line arguments as a string array. - /// - /// - /// Array of command line arguments. - /// - /// The command line could not be parsed into an array. - /// - /// This method uses the same parsing as the operating system which handles quotes and spaces correctly. - /// - public static string[] GetCommandLineArgs(string commandLine) - { - if (null == commandLine) - { - return new string[0]; - } - - // Parse the filtered command line arguments into a native array. - int argc = 0; - - // CommandLineToArgvW tries to treat the first argument as the path to the process, - // which fails pretty miserably if your first argument is something like - // FOO="C:\Program Files\My Company". So give it something harmless to play with. - IntPtr argv = NativeMethods.CommandLineToArgvW("ignored " + commandLine, out argc); - - if (IntPtr.Zero == argv) - { - // Throw an exception with the last error. - throw new Win32Exception(); - } - - // Marshal each native array pointer to a managed string. - try - { - // Skip "ignored" argument/hack. - string[] args = new string[argc - 1]; - for (int i = 1; i < argc; ++i) - { - IntPtr argvi = Marshal.ReadIntPtr(argv, i * IntPtr.Size); - args[i - 1] = Marshal.PtrToStringUni(argvi); - } - - return args; - } - finally - { - NativeMethods.LocalFree(argv); - } - } - } -} diff --git a/src/WixToolset.Mba.Core/BundleInfo.cs b/src/WixToolset.Mba.Core/BundleInfo.cs deleted file mode 100644 index 3d5d535d..00000000 --- a/src/WixToolset.Mba.Core/BundleInfo.cs +++ /dev/null @@ -1,86 +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 WixToolset.Mba.Core -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Xml; - using System.Xml.XPath; - - /// - /// Default implementation of . - /// - public class BundleInfo : IBundleInfo - { - /// - public bool PerMachine { get; internal set; } - - /// - public string Name { get; internal set; } - - /// - public string LogVariable { get; internal set; } - - /// - public IDictionary Packages { get; internal set; } - - internal BundleInfo() - { - this.Packages = new Dictionary(); - } - - /// - public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) - { - var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); - this.Packages.Add(package.Id, package); - return package; - } - - /// - /// Parses BA manifest from the given stream. - /// - /// - /// - public static IBundleInfo ParseBundleFromStream(Stream stream) - { - XPathDocument manifest = new XPathDocument(stream); - XPathNavigator root = manifest.CreateNavigator(); - return ParseBundleFromXml(root); - } - - /// - /// Parses BA manifest from the given . - /// - /// The root of the BA manifest. - /// - public static IBundleInfo ParseBundleFromXml(XPathNavigator root) - { - BundleInfo bundle = new BundleInfo(); - - XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); - namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); - XPathNavigator bundleNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:WixBundleProperties", namespaceManager); - - if (bundleNode == null) - { - throw new Exception("Failed to select bundle information."); - } - - bool? perMachine = BootstrapperApplicationData.GetYesNoAttribute(bundleNode, "PerMachine"); - if (perMachine.HasValue) - { - bundle.PerMachine = perMachine.Value; - } - - bundle.Name = BootstrapperApplicationData.GetAttribute(bundleNode, "DisplayName"); - - bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable"); - - bundle.Packages = PackageInfo.ParsePackagesFromXml(root); - - return bundle; - } - } -} diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs deleted file mode 100644 index aed420d5..00000000 --- a/src/WixToolset.Mba.Core/Engine.cs +++ /dev/null @@ -1,541 +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 WixToolset.Mba.Core -{ - using System; - using System.ComponentModel; - using System.Runtime.InteropServices; - using System.Security; - using System.Text; - - /// - /// Default implementation of . - /// - public sealed class Engine : IEngine - { - // Burn errs on empty strings, so declare initial buffer size. - private const int InitialBufferSize = 80; - private static readonly string normalizeVersionFormatString = "{0} must be less than or equal to " + UInt16.MaxValue; - - private IBootstrapperEngine engine; - - /// - /// Creates a new instance of the container class. - /// - /// The to contain. - internal Engine(IBootstrapperEngine engine) - { - this.engine = engine; - } - - /// - public int PackageCount - { - get - { - int count; - this.engine.GetPackageCount(out count); - - return count; - } - } - - /// - public void Apply(IntPtr hwndParent) - { - this.engine.Apply(hwndParent); - } - - /// - public void CloseSplashScreen() - { - this.engine.CloseSplashScreen(); - } - - /// - public int CompareVersions(string version1, string version2) - { - this.engine.CompareVersions(version1, version2, out var result); - return result; - } - - /// - public bool ContainsVariable(string name) - { - IntPtr capacity = new IntPtr(0); - int ret = this.engine.GetVariableString(name, IntPtr.Zero, ref capacity); - return NativeMethods.E_NOTFOUND != ret; - } - - /// - public void Detect() - { - this.Detect(IntPtr.Zero); - } - - /// - public void Detect(IntPtr hwndParent) - { - this.engine.Detect(hwndParent); - } - - /// - public bool Elevate(IntPtr hwndParent) - { - int ret = this.engine.Elevate(hwndParent); - - if (NativeMethods.S_OK == ret || NativeMethods.E_ALREADYINITIALIZED == ret) - { - return true; - } - else if (NativeMethods.E_CANCELLED == ret) - { - return false; - } - else - { - throw new Win32Exception(ret); - } - } - - /// - public string EscapeString(string input) - { - IntPtr capacity = new IntPtr(InitialBufferSize); - StringBuilder sb = new StringBuilder(capacity.ToInt32()); - - // Get the size of the buffer. - int ret = this.engine.EscapeString(input, sb, ref capacity); - if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) - { - capacity = new IntPtr(capacity.ToInt32() + 1); // Add one for the null terminator. - sb.Capacity = capacity.ToInt32(); - ret = this.engine.EscapeString(input, sb, ref capacity); - } - - if (NativeMethods.S_OK != ret) - { - throw new Win32Exception(ret); - } - - return sb.ToString(); - } - - /// - public bool EvaluateCondition(string condition) - { - bool value; - this.engine.EvaluateCondition(condition, out value); - - return value; - } - - /// - public string FormatString(string format) - { - IntPtr capacity = new IntPtr(InitialBufferSize); - StringBuilder sb = new StringBuilder(capacity.ToInt32()); - - // Get the size of the buffer. - int ret = this.engine.FormatString(format, sb, ref capacity); - if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) - { - capacity = new IntPtr(capacity.ToInt32() + 1); // Add one for the null terminator. - sb.Capacity = capacity.ToInt32(); - ret = this.engine.FormatString(format, sb, ref capacity); - } - - if (NativeMethods.S_OK != ret) - { - throw new Win32Exception(ret); - } - - return sb.ToString(); - } - - /// - public long GetVariableNumeric(string name) - { - int ret = this.engine.GetVariableNumeric(name, out long value); - if (NativeMethods.S_OK != ret) - { - throw new Win32Exception(ret); - } - - return value; - } - - /// - public SecureString GetVariableSecureString(string name) - { - var pUniString = this.getStringVariable(name, out var length); - try - { - return this.convertToSecureString(pUniString, length); - } - finally - { - if (IntPtr.Zero != pUniString) - { - Marshal.FreeCoTaskMem(pUniString); - } - } - } - - /// - public string GetVariableString(string name) - { - int length; - IntPtr pUniString = this.getStringVariable(name, out length); - try - { - return Marshal.PtrToStringUni(pUniString, length); - } - finally - { - if (IntPtr.Zero != pUniString) - { - Marshal.FreeCoTaskMem(pUniString); - } - } - } - - /// - public string GetVariableVersion(string name) - { - int length; - IntPtr pUniString = this.getVersionVariable(name, out length); - try - { - return Marshal.PtrToStringUni(pUniString, length); - } - finally - { - if (IntPtr.Zero != pUniString) - { - Marshal.FreeCoTaskMem(pUniString); - } - } - } - - /// - public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) - { - this.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, 0); - } - - /// - public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout) - { - this.engine.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, waitForInputIdleTimeout); - } - /// - - public void Log(LogLevel level, string message) - { - this.engine.Log(level, message); - } - - /// - public void Plan(LaunchAction action) - { - this.engine.Plan(action); - } - - /// - public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash) - { - this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); - } - - /// - public void SetUpdateSource(string url) - { - this.engine.SetUpdateSource(url); - } - - /// - public void SetLocalSource(string packageOrContainerId, string payloadId, string path) - { - this.engine.SetLocalSource(packageOrContainerId, payloadId, path); - } - - /// - public void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password) - { - this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); - } - - /// - public void SetVariableNumeric(string name, long value) - { - this.engine.SetVariableNumeric(name, value); - } - - /// - public void SetVariableString(string name, SecureString value, bool formatted) - { - IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); - try - { - this.engine.SetVariableString(name, pValue, formatted); - } - finally - { - Marshal.FreeCoTaskMem(pValue); - } - } - - /// - public void SetVariableString(string name, string value, bool formatted) - { - IntPtr pValue = Marshal.StringToCoTaskMemUni(value); - try - { - this.engine.SetVariableString(name, pValue, formatted); - } - finally - { - Marshal.FreeCoTaskMem(pValue); - } - } - - /// - public void SetVariableVersion(string name, string value) - { - IntPtr pValue = Marshal.StringToCoTaskMemUni(value); - try - { - this.engine.SetVariableVersion(name, pValue); - } - finally - { - Marshal.FreeCoTaskMem(pValue); - } - } - - /// - public int SendEmbeddedError(int errorCode, string message, int uiHint) - { - int result = 0; - this.engine.SendEmbeddedError(errorCode, message, uiHint, out result); - return result; - } - - /// - public int SendEmbeddedProgress(int progressPercentage, int overallPercentage) - { - int result = 0; - this.engine.SendEmbeddedProgress(progressPercentage, overallPercentage, out result); - return result; - } - - /// - public void Quit(int exitCode) - { - this.engine.Quit(exitCode); - } - - /// - /// Gets the variable given by as a string. - /// - /// The name of the variable to get. - /// The length of the Unicode string. - /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. - /// An error occurred getting the variable. - internal IntPtr getStringVariable(string name, out int length) - { - IntPtr capacity = new IntPtr(InitialBufferSize); - bool success = false; - IntPtr pValue = Marshal.AllocCoTaskMem(capacity.ToInt32() * UnicodeEncoding.CharSize); - try - { - // Get the size of the buffer. - int ret = this.engine.GetVariableString(name, pValue, ref capacity); - if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) - { - // Don't need to add 1 for the null terminator, the engine already includes that. - pValue = Marshal.ReAllocCoTaskMem(pValue, capacity.ToInt32() * UnicodeEncoding.CharSize); - ret = this.engine.GetVariableString(name, pValue, ref capacity); - } - - if (NativeMethods.S_OK != ret) - { - throw Marshal.GetExceptionForHR(ret); - } - - // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. - int maxLength = capacity.ToInt32(); - for (length = 0; length < maxLength; ++length) - { - if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) - { - break; - } - } - - success = true; - return pValue; - } - finally - { - if (!success && IntPtr.Zero != pValue) - { - Marshal.FreeCoTaskMem(pValue); - } - } - } - - /// - /// Gets the variable given by as a version string. - /// - /// The name of the variable to get. - /// The length of the Unicode string. - /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. - /// An error occurred getting the variable. - internal IntPtr getVersionVariable(string name, out int length) - { - IntPtr capacity = new IntPtr(InitialBufferSize); - bool success = false; - IntPtr pValue = Marshal.AllocCoTaskMem(capacity.ToInt32() * UnicodeEncoding.CharSize); - try - { - // Get the size of the buffer. - int ret = this.engine.GetVariableVersion(name, pValue, ref capacity); - if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) - { - // Don't need to add 1 for the null terminator, the engine already includes that. - pValue = Marshal.ReAllocCoTaskMem(pValue, capacity.ToInt32() * UnicodeEncoding.CharSize); - ret = this.engine.GetVariableVersion(name, pValue, ref capacity); - } - - if (NativeMethods.S_OK != ret) - { - throw Marshal.GetExceptionForHR(ret); - } - - // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. - int maxLength = capacity.ToInt32(); - for (length = 0; length < maxLength; ++length) - { - if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) - { - break; - } - } - - success = true; - return pValue; - } - finally - { - if (!success && IntPtr.Zero != pValue) - { - Marshal.FreeCoTaskMem(pValue); - } - } - } - - /// - /// Initialize a SecureString with the given Unicode string. - /// - /// Pointer to Unicode string. - /// The string's length. - internal SecureString convertToSecureString(IntPtr pUniString, int length) - { - if (IntPtr.Zero == pUniString) - { - return null; - } - - SecureString value = new SecureString(); - short s; - char c; - for (int charIndex = 0; charIndex < length; charIndex++) - { - s = Marshal.ReadInt16(pUniString, charIndex * UnicodeEncoding.CharSize); - c = (char)s; - value.AppendChar(c); - s = 0; - c = (char)0; - } - return value; - } - - /// - /// Utility method for converting a into a . - /// - /// - /// - public static long VersionToLong(Version version) - { - // In Windows, each version component has a max value of 65535, - // so we truncate the version before shifting it, which will overflow if invalid. - long major = (long)(ushort)version.Major << 48; - long minor = (long)(ushort)version.Minor << 32; - long build = (long)(ushort)version.Build << 16; - long revision = (long)(ushort)version.Revision; - - return major | minor | build | revision; - } - - /// - /// Utility method for converting a into a . - /// - /// - /// - public static Version LongToVersion(long version) - { - int major = (int)((version & ((long)0xffff << 48)) >> 48); - int minor = (int)((version & ((long)0xffff << 32)) >> 32); - int build = (int)((version & ((long)0xffff << 16)) >> 16); - int revision = (int)(version & 0xffff); - - return new Version(major, minor, build, revision); - } - - /// - /// Verifies that Version can be represented in a . - /// If the Build or Revision fields are undefined, they are set to zero. - /// - public static Version NormalizeVersion(Version version) - { - if (version == null) - { - throw new ArgumentNullException("version"); - } - - int major = version.Major; - int minor = version.Minor; - int build = version.Build; - int revision = version.Revision; - - if (major > UInt16.MaxValue) - { - throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Major")); - } - if (minor > UInt16.MaxValue) - { - throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Minor")); - } - if (build > UInt16.MaxValue) - { - throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Build")); - } - if (build == -1) - { - build = 0; - } - if (revision > UInt16.MaxValue) - { - throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Revision")); - } - if (revision == -1) - { - revision = 0; - } - - return new Version(major, minor, build, revision); - } - } -} diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs deleted file mode 100644 index 8ef8af14..00000000 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ /dev/null @@ -1,2186 +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 WixToolset.Mba.Core -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - - /// - /// Base class for BA classes. - /// - [Serializable] - public abstract class HResultEventArgs : EventArgs - { - /// - /// Creates a new instance of the class. - /// - public HResultEventArgs() - { - } - - /// - /// Gets or sets the of the operation. This is passed back to the engine. - /// - public int HResult { get; set; } - } - - /// - /// Base class for cancellable BA classes. - /// - [Serializable] - public abstract class CancellableHResultEventArgs : HResultEventArgs - { - /// - /// Creates a new instance of the class. - /// - public CancellableHResultEventArgs(bool cancelRecommendation) - { - this.Cancel = cancelRecommendation; - } - - /// - /// Gets or sets whether to cancel the operation. This is passed back to the engine. - /// - public bool Cancel { get; set; } - } - - /// - /// Base class for classes that must return a . - /// - [Serializable] - public abstract class ResultEventArgs : HResultEventArgs - { - /// - public ResultEventArgs(Result recommendation, Result result) - { - this.Recommendation = recommendation; - this.Result = result; - } - - /// - /// Gets the recommended of the operation. - /// - public Result Recommendation { get; private set; } - - /// - /// Gets or sets the of the operation. This is passed back to the engine. - /// - public Result Result { get; set; } - } - - /// - /// Base class for classes that receive status from the engine. - /// - [Serializable] - public abstract class StatusEventArgs : HResultEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - public StatusEventArgs(int hrStatus) - { - this.Status = hrStatus; - } - - /// - /// Gets the return code of the operation. - /// - public int Status { get; private set; } - } - - /// - /// Base class for classes that receive status from the engine and return an action. - /// - public abstract class ActionEventArgs : StatusEventArgs - { - /// - public ActionEventArgs(int hrStatus, T recommendation, T action) - : base(hrStatus) - { - this.Recommendation = recommendation; - this.Action = action; - } - - /// - /// Gets the recommended action from the engine. - /// - public T Recommendation { get; private set; } - - /// - /// Gets or sets the action to be performed. This is passed back to the engine. - /// - public T Action { get; set; } - } - - /// - /// Base class for cancellable action BA classes. - /// - [Serializable] - public abstract class CancellableActionEventArgs : CancellableHResultEventArgs - { - /// - public CancellableActionEventArgs(bool cancelRecommendation, T recommendation, T action) - : base(cancelRecommendation) - { - this.Recommendation = recommendation; - this.Action = action; - } - - /// - /// Gets the recommended action from the engine. - /// - public T Recommendation { get; private set; } - - /// - /// Gets or sets the action to be performed. This is passed back to the engine. - /// - public T Action { get; set; } - } - - /// - /// Base class for cache progress events. - /// - [Serializable] - public abstract class CacheProgressBaseEventArgs : CancellableHResultEventArgs - { - /// - public CacheProgressBaseEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - this.Progress = progress; - this.Total = total; - this.OverallPercentage = overallPercentage; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - - /// - /// Gets the number of bytes cached thus far. - /// - public long Progress { get; private set; } - - /// - /// Gets the total bytes to cache. - /// - public long Total { get; private set; } - - /// - /// Gets the overall percentage of progress of caching. - /// - public int OverallPercentage { get; private set; } - } - - /// - /// Additional arguments used when startup has begun. - /// - [Serializable] - public class StartupEventArgs : HResultEventArgs - { - /// - /// Creates a new instance of the class. - /// - public StartupEventArgs() - { - } - } - - /// - /// Additional arguments used when shutdown has begun. - /// - [Serializable] - public class ShutdownEventArgs : HResultEventArgs - { - /// - /// Creates a new instance of the class. - /// - public ShutdownEventArgs(BOOTSTRAPPER_SHUTDOWN_ACTION action) - { - this.Action = action; - } - - /// - /// The action for OnShutdown. - /// - public BOOTSTRAPPER_SHUTDOWN_ACTION Action { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class SystemShutdownEventArgs : CancellableHResultEventArgs - { - /// - public SystemShutdownEventArgs(EndSessionReasons reasons, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.Reasons = reasons; - } - - /// - /// Gets the reason the application is requested to close or being closed. - /// - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// - public EndSessionReasons Reasons { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectBeginEventArgs : CancellableHResultEventArgs - { - /// - public DetectBeginEventArgs(bool cached, bool installed, int packageCount, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.Cached = cached; - this.Installed = installed; - this.PackageCount = packageCount; - } - - /// - /// Gets whether the bundle is cached. - /// - public bool Cached { get; private set; } - - /// - /// Gets whether the bundle is installed. - /// - public bool Installed { get; private set; } - - /// - /// Gets the number of packages to detect. - /// - public int PackageCount { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectForwardCompatibleBundleEventArgs : CancellableHResultEventArgs - { - /// - public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool missingFromCache, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.BundleId = bundleId; - this.RelationType = relationType; - this.BundleTag = bundleTag; - this.PerMachine = perMachine; - this.Version = version; - this.MissingFromCache = missingFromCache; - } - - /// - /// Gets the identity of the forward compatible bundle detected. - /// - public string BundleId { get; private set; } - - /// - /// Gets the relationship type of the forward compatible bundle. - /// - public RelationType RelationType { get; private set; } - - /// - /// Gets the tag of the forward compatible bundle. - /// - public string BundleTag { get; private set; } - - /// - /// Gets whether the detected forward compatible bundle is per machine. - /// - public bool PerMachine { get; private set; } - - /// - /// Gets the version of the forward compatible bundle detected. - /// - public string Version { get; private set; } - - /// - /// Whether the forward compatible bundle is missing from the package cache. - /// - public bool MissingFromCache { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectUpdateBeginEventArgs : CancellableHResultEventArgs - { - /// - public DetectUpdateBeginEventArgs(string updateLocation, bool cancelRecommendation, bool skipRecommendation) - : base(cancelRecommendation) - { - this.UpdateLocation = updateLocation; - this.Skip = skipRecommendation; - } - - /// - /// Gets the identity of the bundle to detect. - /// - public string UpdateLocation { get; private set; } - - /// - /// Whether to skip checking for bundle updates. - /// - public bool Skip { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectUpdateEventArgs : CancellableHResultEventArgs - { - /// - public DetectUpdateEventArgs(string updateLocation, long size, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) - : base(cancelRecommendation) - { - this.UpdateLocation = updateLocation; - this.Size = size; - this.Version = version; - this.Title = title; - this.Summary = summary; - this.ContentType = contentType; - this.Content = content; - this.StopProcessingUpdates = stopRecommendation; - } - - /// - /// Gets the identity of the bundle to detect. - /// - public string UpdateLocation { get; private set; } - - /// - /// Gets the size of the updated bundle. - /// - public long Size { get; private set; } - - /// - /// Gets the version of the updated bundle. - /// - public string Version { get; private set; } - - /// - /// Gets the title of the the updated bundle. - /// - public string Title { get; private set; } - - /// - /// Gets the summary of the updated bundle. - /// - public string Summary { get; private set; } - - /// - /// Gets the content type of the content of the updated bundle. - /// - public string ContentType { get; private set; } - - /// - /// Gets the content of the updated bundle. - /// - public string Content { get; private set; } - - /// - /// Tells the engine to stop giving the rest of the updates found in the feed. - /// - public bool StopProcessingUpdates { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectUpdateCompleteEventArgs : StatusEventArgs - { - /// - public DetectUpdateCompleteEventArgs(int hrStatus, bool ignoreRecommendation) - : base(hrStatus) - { - this.IgnoreError = ignoreRecommendation; - } - - /// - /// If Status is an error, then set this to true to ignore it and continue detecting. - /// - public bool IgnoreError { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectRelatedBundleEventArgs : CancellableHResultEventArgs - { - /// - public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool missingFromCache, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.ProductCode = productCode; - this.RelationType = relationType; - this.BundleTag = bundleTag; - this.PerMachine = perMachine; - this.Version = version; - this.Operation = operation; - this.MissingFromCache = missingFromCache; - } - - /// - /// Gets the identity of the related bundle detected. - /// - public string ProductCode { get; private set; } - - /// - /// Gets the relationship type of the related bundle. - /// - public RelationType RelationType { get; private set; } - - /// - /// Gets the tag of the related package bundle. - /// - public string BundleTag { get; private set; } - - /// - /// Gets whether the detected bundle is per machine. - /// - public bool PerMachine { get; private set; } - - /// - /// Gets the version of the related bundle detected. - /// - public string Version { get; private set; } - - /// - /// Gets the operation that will be taken on the detected bundle. - /// - public RelatedOperation Operation { get; private set; } - - /// - /// Whether the related bundle is missing from the package cache. - /// - public bool MissingFromCache { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectPackageBeginEventArgs : CancellableHResultEventArgs - { - /// - public DetectPackageBeginEventArgs(string packageId, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - } - - /// - /// Gets the identity of the package to detect. - /// - public string PackageId { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class DetectRelatedMsiPackageEventArgs : CancellableHResultEventArgs - { - /// - public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.UpgradeCode = upgradeCode; - this.ProductCode = productCode; - this.PerMachine = perMachine; - this.Version = version; - this.Operation = operation; - } - - /// - /// Gets the identity of the product's package detected. - /// - public string PackageId { get; private set; } - - /// - /// Gets the upgrade code of the related package detected. - /// - public string UpgradeCode { get; private set; } - - /// - /// Gets the identity of the related package detected. - /// - public string ProductCode { get; private set; } - - /// - /// Gets whether the detected package is per machine. - /// - public bool PerMachine { get; private set; } - - /// - /// Gets the version of the related package detected. - /// - public string Version { get; private set; } - - /// - /// Gets the operation that will be taken on the detected package. - /// - public RelatedOperation Operation { get; private set; } - } - - /// - /// Event arguments for - /// - public class DetectPatchTargetEventArgs : CancellableHResultEventArgs - { - /// - /// - /// - /// - /// - /// - /// - public DetectPatchTargetEventArgs(string packageId, string productCode, PackageState state, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.ProductCode = productCode; - this.State = state; - } - - /// - /// Gets the identity of the patch's package. - /// - public string PackageId { get; private set; } - - /// - /// Gets the product code of the target. - /// - public string ProductCode { get; private set; } - - /// - /// Gets the detected patch state for the target. - /// - public PackageState State { get; private set; } - } - - /// - /// Event arguments for - /// - public class DetectMsiFeatureEventArgs : CancellableHResultEventArgs - { - /// - public DetectMsiFeatureEventArgs(string packageId, string featureId, FeatureState state, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.FeatureId = featureId; - this.State = state; - } - - /// - /// Gets the identity of the feature's package detected. - /// - public string PackageId { get; private set; } - - /// - /// Gets the identity of the feature detected. - /// - public string FeatureId { get; private set; } - - /// - /// Gets the detected feature state. - /// - public FeatureState State { get; private set; } - } - - /// - /// Additional arguments for . - /// - [Serializable] - public class DetectPackageCompleteEventArgs : StatusEventArgs - { - /// - public DetectPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state, bool cached) - : base(hrStatus) - { - this.PackageId = packageId; - this.State = state; - this.Cached = cached; - } - - /// - /// Gets the identity of the package detected. - /// - public string PackageId { get; private set; } - - /// - /// Gets the state of the specified package. - /// - public PackageState State { get; private set; } - - /// - /// Gets whether any part of the package is cached. - /// - public bool Cached { get; private set; } - } - - /// - /// Additional arguments used when the detection phase has completed. - /// - [Serializable] - public class DetectCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - /// - public DetectCompleteEventArgs(int hrStatus, bool eligibleForCleanup) - : base(hrStatus) - { - this.EligibleForCleanup = eligibleForCleanup; - } - - /// - /// Indicates whether the engine will uninstall the bundle if shutdown without running Apply. - /// - public bool EligibleForCleanup { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanBeginEventArgs : CancellableHResultEventArgs - { - /// - public PlanBeginEventArgs(int packageCount, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageCount = packageCount; - } - - /// - /// Gets the number of packages to plan for. - /// - public int PackageCount { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanRelatedBundleEventArgs : CancellableHResultEventArgs - { - /// - public PlanRelatedBundleEventArgs(string bundleId, RequestState recommendedState, RequestState state, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.BundleId = bundleId; - this.RecommendedState = recommendedState; - this.State = state; - } - - /// - /// Gets the identity of the bundle to plan for. - /// - public string BundleId { get; private set; } - - /// - /// Gets the recommended requested state for the bundle. - /// - public RequestState RecommendedState { get; private set; } - - /// - /// Gets or sets the requested state for the bundle. - /// - public RequestState State { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanPackageBeginEventArgs : CancellableHResultEventArgs - { - /// - public PlanPackageBeginEventArgs(string packageId, PackageState currentState, bool cached, BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, RequestState recommendedState, BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, RequestState state, BOOTSTRAPPER_CACHE_TYPE cacheType, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.CurrentState = currentState; - this.Cached = cached; - this.InstallCondition = installCondition; - this.RecommendedState = recommendedState; - this.RecommendedCacheType = recommendedCacheType; - this.State = state; - this.CacheType = cacheType; - } - - /// - /// Gets the identity of the package to plan for. - /// - public string PackageId { get; private set; } - - /// - /// Gets the current state of the package. - /// - public PackageState CurrentState { get; private set; } - - /// - /// Gets whether any part of the package is cached. - /// - public bool Cached { get; private set; } - - /// - /// Gets the evaluated result of the package's install condition. - /// - public BOOTSTRAPPER_PACKAGE_CONDITION_RESULT InstallCondition { get; private set; } - - /// - /// Gets the recommended requested state for the package. - /// - public RequestState RecommendedState { get; private set; } - - /// - /// The authored cache type of the package. - /// - public BOOTSTRAPPER_CACHE_TYPE RecommendedCacheType { get; private set; } - - /// - /// Gets or sets the requested state for the package. - /// - public RequestState State { get; set; } - - /// - /// Gets or sets the requested cache type for the package. - /// - public BOOTSTRAPPER_CACHE_TYPE CacheType { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanPatchTargetEventArgs : CancellableHResultEventArgs - { - /// - /// - /// - /// - /// - /// - /// - /// - public PlanPatchTargetEventArgs(string packageId, string productCode, RequestState recommendedState, RequestState state, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.ProductCode = productCode; - this.RecommendedState = recommendedState; - this.State = state; - } - - /// - /// Gets the identity of the patch's package. - /// - public string PackageId { get; private set; } - - /// - /// Gets the product code of the target. - /// - public string ProductCode { get; private set; } - - /// - /// Gets the recommended state of the patch to use by planning for the target. - /// - public RequestState RecommendedState { get; private set; } - - /// - /// Gets or sets the state of the patch to use by planning for the target. - /// - public RequestState State { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanMsiFeatureEventArgs : CancellableHResultEventArgs - { - /// - public PlanMsiFeatureEventArgs(string packageId, string featureId, FeatureState recommendedState, FeatureState state, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.FeatureId = featureId; - this.RecommendedState = recommendedState; - this.State = state; - } - - /// - /// Gets the identity of the feature's package to plan. - /// - public string PackageId { get; private set; } - - /// - /// Gets the identity of the feature to plan. - /// - public string FeatureId { get; private set; } - - /// - /// Gets the recommended feature state to use by planning. - /// - public FeatureState RecommendedState { get; private set; } - - /// - /// Gets or sets the feature state to use by planning. - /// - public FeatureState State { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanMsiPackageEventArgs : CancellableHResultEventArgs - { - /// - public PlanMsiPackageEventArgs(string packageId, bool shouldExecute, ActionState action, bool cancelRecommendation, BURN_MSI_PROPERTY actionMsiProperty, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.ShouldExecute = shouldExecute; - this.Action = action; - this.ActionMsiProperty = actionMsiProperty; - this.UiLevel = uiLevel; - this.DisableExternalUiHandler = disableExternalUiHandler; - } - - /// - /// Gets identity of the package planned for. - /// - public string PackageId { get; private set; } - - /// - /// Gets whether the package is planned to execute or roll back. - /// - public bool ShouldExecute { get; private set; } - - /// - /// Gets the action planned for the package. - /// - public ActionState Action { get; private set; } - - /// - /// Gets or sets the requested MSI property to add. - /// - public BURN_MSI_PROPERTY ActionMsiProperty { get; set; } - - /// - /// Gets or sets the requested internal UI level. - /// - public INSTALLUILEVEL UiLevel { get; set; } - - /// - /// Gets or sets whether Burn is requested to set up an external UI handler. - /// - public bool DisableExternalUiHandler { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanPackageCompleteEventArgs : StatusEventArgs - { - /// - /// - /// - /// - /// - /// - public PlanPackageCompleteEventArgs(string packageId, int hrStatus, RequestState requested) - : base(hrStatus) - { - this.PackageId = packageId; - this.Requested = requested; - } - - /// - /// Gets the identity of the package planned for. - /// - public string PackageId { get; private set; } - - /// - /// Gets the requested state for the package. - /// - public RequestState Requested { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlannedPackageEventArgs : HResultEventArgs - { - /// - public PlannedPackageEventArgs(string packageId, ActionState execute, ActionState rollback, bool cache, bool uncache) - { - this.PackageId = packageId; - this.Execute = execute; - this.Rollback = rollback; - this.Cache = cache; - this.Uncache = uncache; - } - - /// - /// Gets the identity of the package planned for. - /// - public string PackageId { get; private set; } - - /// - /// Gets the planned execution action. - /// - public ActionState Execute { get; private set; } - - /// - /// Gets the planned rollback action. - /// - public ActionState Rollback { get; private set; } - - /// - /// Gets whether the package will be cached. - /// - public bool Cache { get; private set; } - - /// - /// Gets whether the package will be removed from the package cache. - /// - public bool Uncache { get; private set; } - } - - /// - /// Additional arguments used when the engine has completed planning the installation. - /// - [Serializable] - public class PlanCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - public PlanCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class PlanForwardCompatibleBundleEventArgs : CancellableHResultEventArgs - { - /// - public PlanForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool recommendedIgnoreBundle, bool cancelRecommendation, bool ignoreBundle) - : base(cancelRecommendation) - { - this.BundleId = bundleId; - this.RelationType = relationType; - this.BundleTag = bundleTag; - this.PerMachine = perMachine; - this.Version = version; - this.RecommendedIgnoreBundle = recommendedIgnoreBundle; - this.IgnoreBundle = ignoreBundle; - } - - /// - /// Gets the identity of the forward compatible bundle detected. - /// - public string BundleId { get; private set; } - - /// - /// Gets the relationship type of the forward compatible bundle. - /// - public RelationType RelationType { get; private set; } - - /// - /// Gets the tag of the forward compatible bundle. - /// - public string BundleTag { get; private set; } - - /// - /// Gets whether the forward compatible bundle is per machine. - /// - public bool PerMachine { get; private set; } - - /// - /// Gets the version of the forward compatible bundle. - /// - public string Version { get; private set; } - - /// - /// Gets the recommendation of whether the engine should use the forward compatible bundle. - /// - public bool RecommendedIgnoreBundle { get; set; } - - /// - /// Gets or sets whether the engine will use the forward compatible bundle. - /// - public bool IgnoreBundle { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ApplyBeginEventArgs : CancellableHResultEventArgs - { - /// - public ApplyBeginEventArgs(int phaseCount, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PhaseCount = phaseCount; - } - - /// - /// Gets the number of phases that the engine will go through in apply. - /// There are currently two possible phases: cache and execute. - /// - public int PhaseCount { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ElevateBeginEventArgs : CancellableHResultEventArgs - { - /// - public ElevateBeginEventArgs(bool cancelRecommendation) - : base(cancelRecommendation) - { - } - } - - /// - /// Additional arguments used when the engine has completed starting the elevated process. - /// - [Serializable] - public class ElevateCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - public ElevateCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ProgressEventArgs : CancellableHResultEventArgs - { - /// - public ProgressEventArgs(int progressPercentage, int overallPercentage, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.ProgressPercentage = progressPercentage; - this.OverallPercentage = overallPercentage; - } - - /// - /// Gets the percentage from 0 to 100 completed for a package. - /// - public int ProgressPercentage { get; private set; } - - /// - /// Gets the percentage from 0 to 100 completed for the bundle. - /// - public int OverallPercentage { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ErrorEventArgs : ResultEventArgs - { - /// - public ErrorEventArgs(ErrorType errorType, string packageId, int errorCode, string errorMessage, int dwUIHint, string[] data, Result recommendation, Result result) - : base(recommendation, result) - { - this.ErrorType = errorType; - this.PackageId = packageId; - this.ErrorCode = errorCode; - this.ErrorMessage = errorMessage; - this.UIHint = dwUIHint; - this.Data = new ReadOnlyCollection(data ?? new string[] { }); - } - - /// - /// Gets the type of error that occurred. - /// - public ErrorType ErrorType { get; private set; } - - /// - /// Gets the identity of the package that yielded the error. - /// - public string PackageId { get; private set; } - - /// - /// Gets the error code. - /// - public int ErrorCode { get; private set; } - - /// - /// Gets the error message. - /// - public string ErrorMessage { get; private set; } - - /// - /// Gets the recommended display flags for an error dialog. - /// - public int UIHint { get; private set; } - - /// - /// Gets the extended data for the error. - /// - public IList Data { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class RegisterBeginEventArgs : CancellableHResultEventArgs - { - /// - public RegisterBeginEventArgs(bool cancelRecommendation) - : base(cancelRecommendation) - { - } - } - - /// - /// Additional arguments used when the engine has completed registering the location and visilibity of the bundle. - /// - [Serializable] - public class RegisterCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - public RegisterCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class UnregisterBeginEventArgs : HResultEventArgs - { - /// - /// - /// - /// - /// - public UnregisterBeginEventArgs(bool keepRegistration, bool forceKeepRegistration) - { - this.KeepRegistration = keepRegistration; - this.ForceKeepRegistration = forceKeepRegistration; - } - - /// - /// Indicates whether the engine will uninstall the bundle. - /// - public bool ForceKeepRegistration { get; set; } - - /// - /// If is FALSE, then this can be set to TRUE to make the engine keep the bundle installed. - /// - public bool KeepRegistration { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class UnregisterCompleteEventArgs : StatusEventArgs - { - /// - /// - /// - /// - public UnregisterCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class CacheBeginEventArgs : CancellableHResultEventArgs - { - /// - public CacheBeginEventArgs(bool cancelRecommendation) - : base(cancelRecommendation) - { - } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheAcquireBeginEventArgs : CancellableActionEventArgs - { - /// - public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, string source, string downloadUrl, string payloadContainerId, CacheOperation recommendation, CacheOperation action, bool cancelRecommendation) - : base(cancelRecommendation, recommendation, action) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - this.Source = source; - this.DownloadUrl = downloadUrl; - this.PayloadContainerId = payloadContainerId; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload (if acquiring a payload). - /// - public string PayloadId { get; private set; } - - /// - /// Gets the source of the container or payload. - /// - public string Source { get; private set; } - - /// - /// Gets the optional URL to download container or payload. - /// - public string DownloadUrl { get; private set; } - - /// - /// Gets the optional identity of the container that contains the payload being acquired. - /// - public string PayloadContainerId { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheAcquireProgressEventArgs : CacheProgressBaseEventArgs - { - /// - public CacheAcquireProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) - : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) - { - } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheAcquireCompleteEventArgs : ActionEventArgs - { - /// - public CacheAcquireCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) - : base(hrStatus, recommendation, action) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload (if acquiring a payload). - /// - public string PayloadId { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheVerifyBeginEventArgs : CancellableHResultEventArgs - { - /// - public CacheVerifyBeginEventArgs(string packageOrContainerId, string payloadId, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheVerifyProgressEventArgs : CacheProgressBaseEventArgs - { - /// - public CacheVerifyProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, CacheVerifyStep verifyStep, bool cancelRecommendation) - : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) - { - this.Step = verifyStep; - } - - /// - /// Gets the current verification step. - /// - public CacheVerifyStep Step { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class CacheVerifyCompleteEventArgs : ActionEventArgs - { - /// - public CacheVerifyCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) - : base(hrStatus, recommendation, action) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - } - - /// - /// Additional arguments used after the engine has cached the installation sources. - /// - [Serializable] - public class CacheCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - public CacheCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ExecuteBeginEventArgs : CancellableHResultEventArgs - { - /// - public ExecuteBeginEventArgs(int packageCount, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageCount = packageCount; - } - - /// - /// Gets the number of packages to act on. - /// - public int PackageCount { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ExecutePackageBeginEventArgs : CancellableHResultEventArgs - { - /// - public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, ActionState action, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.ShouldExecute = shouldExecute; - this.Action = action; - this.UiLevel = uiLevel; - this.DisableExternalUiHandler = disableExternalUiHandler; - } - - /// - /// Gets the identity of the package to act on. - /// - public string PackageId { get; private set; } - - /// - /// Gets whether the package is being executed or rolled back. - /// - public bool ShouldExecute { get; private set; } - - /// - /// Gets the action about to be executed. - /// - public ActionState Action { get; private set; } - - /// - /// Gets the internal UI level (if this is an MSI or MSP package). - /// - public INSTALLUILEVEL UiLevel { get; private set; } - - /// - /// Gets whether Burn will set up an external UI handler (if this is an MSI or MSP package). - /// - public bool DisableExternalUiHandler { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ExecutePatchTargetEventArgs : CancellableHResultEventArgs - { - /// - public ExecutePatchTargetEventArgs(string packageId, string targetProductCode, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.TargetProductCode = targetProductCode; - } - - /// - /// Gets the identity of the package to act on. - /// - public string PackageId { get; private set; } - - /// - /// Gets the product code being targeted. - /// - public string TargetProductCode { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ExecuteMsiMessageEventArgs : ResultEventArgs - { - /// - public ExecuteMsiMessageEventArgs(string packageId, InstallMessage messageType, int dwUIHint, string message, string[] data, Result recommendation, Result result) - : base(recommendation, result) - { - this.PackageId = packageId; - this.MessageType = messageType; - this.UIHint = dwUIHint; - this.Message = message; - this.Data = new ReadOnlyCollection(data ?? new string[] { }); - } - - /// - /// Gets the identity of the package that yielded this message. - /// - public string PackageId { get; private set; } - - /// - /// Gets the type of this message. - /// - public InstallMessage MessageType { get; private set; } - - /// - /// Gets the recommended display flags for this message. - /// - public int UIHint { get; private set; } - - /// - /// Gets the message. - /// - public string Message { get; private set; } - - /// - /// Gets the extended data for the message. - /// - public IList Data { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ExecuteFilesInUseEventArgs : ResultEventArgs - { - /// - public ExecuteFilesInUseEventArgs(string packageId, string[] files, Result recommendation, Result result) - : base(recommendation, result) - { - this.PackageId = packageId; - this.Files = new ReadOnlyCollection(files ?? new string[] { }); - } - - /// - /// Gets the identity of the package that yielded the files in use message. - /// - public string PackageId { get; private set; } - - /// - /// Gets the list of files in use. - /// - public IList Files { get; private set; } - } - - /// - /// Event arguments for - /// Additional arguments used when the engine has completed installing a specific package. - /// - [Serializable] - public class ExecutePackageCompleteEventArgs : ActionEventArgs - { - /// - public ExecutePackageCompleteEventArgs(string packageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION action) - : base(hrStatus, recommendation, action) - { - this.PackageId = packageId; - this.Restart = restart; - } - - /// - /// Gets the identity of the package that was acted on. - /// - public string PackageId { get; private set; } - - /// - /// Gets the package restart state after being applied. - /// - public ApplyRestart Restart { get; private set; } - } - - /// - /// Additional arguments used when the engine has completed installing packages. - /// - [Serializable] - public class ExecuteCompleteEventArgs : StatusEventArgs - { - /// - /// Creates a new instance of the class. - /// - /// The return code of the operation. - public ExecuteCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ApplyCompleteEventArgs : ActionEventArgs - { - /// - public ApplyCompleteEventArgs(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_APPLYCOMPLETE_ACTION action) - : base(hrStatus, recommendation, action) - { - this.Restart = restart; - } - - /// - /// Gets the apply restart state when complete. - /// - public ApplyRestart Restart { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheAcquireResolvingEventArgs : CancellableActionEventArgs - { - /// - public CacheAcquireResolvingEventArgs(string packageOrContainerId, string payloadId, string[] searchPaths, bool foundLocal, int recommendedSearchPath, string downloadUrl, string payloadContainerId, CacheResolveOperation recommendation, int chosenSearchPath, CacheResolveOperation action, bool cancel) - : base(cancel, recommendation, action) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - this.SearchPaths = searchPaths; - this.FoundLocal = foundLocal; - this.RecommendedSearchPath = recommendedSearchPath; - this.DownloadUrl = downloadUrl; - this.PayloadContainerId = payloadContainerId; - this.ChosenSearchPath = chosenSearchPath; - } - - /// - /// Gets the identity of the package or container that is being acquired. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identity of the payload that is being acquired. - /// - public string PayloadId { get; private set; } - - /// - /// Gets the search paths used for source resolution. - /// - public string[] SearchPaths { get; private set; } - - /// - /// Gets whether indicates that a file was found at that search path. - /// - public bool FoundLocal { get; private set; } - - /// - /// When is true, the index to for the recommended local file. - /// - public int RecommendedSearchPath { get; private set; } - - /// - /// Gets the optional URL to download container or payload. - /// - public string DownloadUrl { get; private set; } - - /// - /// Gets the optional identity of the container that contains the payload being acquired. - /// - public string PayloadContainerId { get; private set; } - - /// - /// Gets or sets the index to to use when is set to . - /// - public int ChosenSearchPath { get; set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class CachePackageBeginEventArgs : CancellableHResultEventArgs - { - /// - public CachePackageBeginEventArgs(string packageId, int cachePayloads, long packageCacheSize, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.CachePayloads = cachePayloads; - this.PackageCacheSize = packageCacheSize; - } - - /// - /// Gets the identity of the package that is being cached. - /// - public string PackageId { get; private set; } - - /// - /// Gets number of payloads to be cached. - /// - public long CachePayloads { get; private set; } - - /// - /// Gets the size on disk required by the specific package. - /// - public long PackageCacheSize { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class CachePackageCompleteEventArgs : ActionEventArgs - { - /// - public CachePackageCompleteEventArgs(string packageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) - : base(hrStatus, recommendation, action) - { - this.PackageId = packageId; - } - - /// - /// Gets the identity of the package that was cached. - /// - public string PackageId { get; private set; } - } - - /// - /// Event arguments for - /// - [Serializable] - public class ExecuteProgressEventArgs : CancellableHResultEventArgs - { - /// - public ExecuteProgressEventArgs(string packageId, int progressPercentage, int overallPercentage, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageId = packageId; - this.ProgressPercentage = progressPercentage; - this.OverallPercentage = overallPercentage; - } - - /// - /// Gets the identity of the package that was executed. - /// - public string PackageId { get; private set; } - - /// - /// Gets the percentage from 0 to 100 of the execution progress for a single payload. - /// - public int ProgressPercentage { get; private set; } - - /// - /// Gets the percentage from 0 to 100 of the execution progress for all payloads. - /// - public int OverallPercentage { get; private set; } - } - - /// - /// Additional arguments passed by the engine before it tries to launch the preapproved executable. - /// - [Serializable] - public class LaunchApprovedExeBeginEventArgs : CancellableHResultEventArgs - { - /// - /// - /// - /// - public LaunchApprovedExeBeginEventArgs(bool cancelRecommendation) - : base(cancelRecommendation) - { - } - } - - /// - /// Additional arguments passed by the engine after it finished trying to launch the preapproved executable. - /// - [Serializable] - public class LaunchApprovedExeCompleteEventArgs : StatusEventArgs - { - private int processId; - - /// - /// - /// - /// - /// - public LaunchApprovedExeCompleteEventArgs(int hrStatus, int processId) - : base(hrStatus) - { - this.processId = processId; - } - - /// - /// Gets the ProcessId of the process that was launched. - /// This is only valid if the status reports success. - /// - public int ProcessId - { - get { return this.processId; } - } - } - - /// - /// Additional arguments passed by the engine before beginning an MSI transaction. - /// - [Serializable] - public class BeginMsiTransactionBeginEventArgs : CancellableHResultEventArgs - { - private string transactionId; - - /// - /// - /// - /// - /// - public BeginMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.transactionId = transactionId; - } - - /// - /// Gets the MSI transaction Id. - /// - public string TransactionId - { - get { return this.transactionId; } - } - } - - /// - /// Additional arguments passed by the engine after beginning an MSI transaction. - /// - [Serializable] - public class BeginMsiTransactionCompleteEventArgs : StatusEventArgs - { - private string transactionId; - - /// - /// - /// - /// - /// - public BeginMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) - : base(hrStatus) - { - this.transactionId = transactionId; - } - - /// - /// Gets the MSI transaction Id. - /// - public string TransactionId - { - get { return this.transactionId; } - } - } - - /// - /// Additional arguments passed by the engine before committing an MSI transaction. - /// - [Serializable] - public class CommitMsiTransactionBeginEventArgs : CancellableHResultEventArgs - { - private string transactionId; - - /// - /// - /// - /// - /// - public CommitMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.transactionId = transactionId; - } - - /// - /// Gets the MSI transaction Id. - /// - public string TransactionId - { - get { return this.transactionId; } - } - } - - /// - /// Additional arguments passed by the engine after committing an MSI transaction. - /// - [Serializable] - public class CommitMsiTransactionCompleteEventArgs : StatusEventArgs - { - private string transactionId; - - /// - /// - /// - /// - /// - public CommitMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) - : base(hrStatus) - { - this.transactionId = transactionId; - } - - /// - /// Gets the MSI transaction Id. - /// - public string TransactionId - { - get { return this.transactionId; } - } - } - - /// - /// Additional arguments passed by the engine before rolling back an MSI transaction. - /// - [Serializable] - public class RollbackMsiTransactionBeginEventArgs : HResultEventArgs - { - private string transactionId; - - /// - /// - /// - /// - public RollbackMsiTransactionBeginEventArgs(string transactionId) - { - this.transactionId = transactionId; - } - - /// - /// Gets the MSI transaction Id. - /// - public string TransactionId - { - get { return this.transactionId; } - } - } - - /// - /// Additional arguments passed by the engine after rolling back an MSI transaction. - /// - [Serializable] - public class RollbackMsiTransactionCompleteEventArgs : StatusEventArgs - { - private string transactionId; - - /// - /// - /// - /// - /// - public RollbackMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) - : base(hrStatus) - { - this.transactionId = transactionId; - } - - /// - /// Gets the MSI transaction Id. - /// - public string TransactionId - { - get { return this.transactionId; } - } - } - - /// - /// Additional arguments passed by the engine before pausing Windows automatic updates. - /// - [Serializable] - public class PauseAutomaticUpdatesBeginEventArgs : HResultEventArgs - { - /// - /// - /// - public PauseAutomaticUpdatesBeginEventArgs() - { - } - } - - /// - /// Additional arguments passed by the engine after pausing Windows automatic updates. - /// - [Serializable] - public class PauseAutomaticUpdatesCompleteEventArgs : StatusEventArgs - { - /// - /// - /// - /// - public PauseAutomaticUpdatesCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// Additional arguments passed by the engine before taking a system restore point. - /// - [Serializable] - public class SystemRestorePointBeginEventArgs : HResultEventArgs - { - /// - /// - /// - public SystemRestorePointBeginEventArgs() - { - } - } - - /// - /// Additional arguments passed by the engine after taking a system restore point. - /// - [Serializable] - public class SystemRestorePointCompleteEventArgs : StatusEventArgs - { - /// - /// - /// - /// - public SystemRestorePointCompleteEventArgs(int hrStatus) - : base(hrStatus) - { - } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheContainerOrPayloadVerifyBeginEventArgs : CancellableHResultEventArgs - { - /// - public CacheContainerOrPayloadVerifyBeginEventArgs(string packageOrContainerId, string payloadId, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CacheContainerOrPayloadVerifyProgressEventArgs : CacheProgressBaseEventArgs - { - /// - public CacheContainerOrPayloadVerifyProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) - : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class CacheContainerOrPayloadVerifyCompleteEventArgs : StatusEventArgs - { - /// - public CacheContainerOrPayloadVerifyCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus) - : base(hrStatus) - { - this.PackageOrContainerId = packageOrContainerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container or package. - /// - public string PackageOrContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CachePayloadExtractBeginEventArgs : CancellableHResultEventArgs - { - /// - public CachePayloadExtractBeginEventArgs(string containerId, string payloadId, bool cancelRecommendation) - : base(cancelRecommendation) - { - this.ContainerId = containerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container. - /// - public string ContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - } - - /// - /// EventArgs for . - /// - [Serializable] - public class CachePayloadExtractProgressEventArgs : CacheProgressBaseEventArgs - { - /// - public CachePayloadExtractProgressEventArgs(string containerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) - : base(containerId, payloadId, progress, total, overallPercentage, cancelRecommendation) - { - } - } - - /// - /// Event arguments for - /// - [Serializable] - public class CachePayloadExtractCompleteEventArgs : StatusEventArgs - { - /// - public CachePayloadExtractCompleteEventArgs(string containerId, string payloadId, int hrStatus) - : base(hrStatus) - { - this.ContainerId = containerId; - this.PayloadId = payloadId; - } - - /// - /// Gets the identifier of the container. - /// - public string ContainerId { get; private set; } - - /// - /// Gets the identifier of the payload. - /// - public string PayloadId { get; private set; } - } -} diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs deleted file mode 100644 index 530fb1a9..00000000 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ /dev/null @@ -1,1917 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - - /// - /// Allows customization of the bootstrapper application. - /// - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("53C31D56-49C0-426B-AB06-099D717C67FE")] - public interface IBootstrapperApplication - { - /// - /// Low level method that is called directly from the engine. - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int BAProc( - int message, - IntPtr pvArgs, - IntPtr pvResults, - IntPtr pvContext - ); - - /// - /// Low level method that is called directly from the engine. - /// - void BAProcFallback( - int message, - IntPtr pvArgs, - IntPtr pvResults, - ref int phr, - IntPtr pvContext - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnStartup(); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSystemShutdown( - [MarshalAs(UnmanagedType.U4)] EndSessionReasons dwEndSession, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectBegin( - [MarshalAs(UnmanagedType.Bool)] bool fCached, - [MarshalAs(UnmanagedType.Bool)] bool fInstalled, - [MarshalAs(UnmanagedType.U4)] int cPackages, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectForwardCompatibleBundle( - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, - [MarshalAs(UnmanagedType.U4)] RelationType relationType, - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, - [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectUpdateBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, - [MarshalAs(UnmanagedType.Bool)] ref bool fSkip - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectUpdate( - [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, - [MarshalAs(UnmanagedType.U8)] long dw64Size, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.LPWStr)] string wzTitle, - [MarshalAs(UnmanagedType.LPWStr)] string wzSummary, - [MarshalAs(UnmanagedType.LPWStr)] string wzContentType, - [MarshalAs(UnmanagedType.LPWStr)] string wzContent, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, - [MarshalAs(UnmanagedType.Bool)] ref bool fStopProcessingUpdates - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectUpdateComplete( - int hrStatus, - [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreError - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectRelatedBundle( - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, - [MarshalAs(UnmanagedType.U4)] RelationType relationType, - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, - [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, - [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectPackageBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectRelatedMsiPackage( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzUpgradeCode, - [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, - [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectPatchTarget( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, - [MarshalAs(UnmanagedType.U4)] PackageState patchState, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectMsiFeature( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzFeatureId, - [MarshalAs(UnmanagedType.U4)] FeatureState state, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectPackageComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - int hrStatus, - [MarshalAs(UnmanagedType.U4)] PackageState state, - [MarshalAs(UnmanagedType.Bool)] bool fCached - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnDetectComplete( - int hrStatus, - [MarshalAs(UnmanagedType.Bool)] bool fEligibleForCleanup - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanBegin( - [MarshalAs(UnmanagedType.U4)] int cPackages, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanRelatedBundle( - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, - [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, - [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanPackageBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] PackageState state, - [MarshalAs(UnmanagedType.Bool)] bool fCached, - [MarshalAs(UnmanagedType.U4)] BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, - [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, - [MarshalAs(UnmanagedType.U4)] BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, - [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, - [MarshalAs(UnmanagedType.U4)] ref BOOTSTRAPPER_CACHE_TYPE pRequestedCacheType, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanPatchTarget( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, - [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, - [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanMsiFeature( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzFeatureId, - [MarshalAs(UnmanagedType.U4)] FeatureState recommendedState, - [MarshalAs(UnmanagedType.U4)] ref FeatureState pRequestedState, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanMsiPackage( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.Bool)] bool fExecute, - [MarshalAs(UnmanagedType.U4)] ActionState action, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, - [MarshalAs(UnmanagedType.U4)] ref BURN_MSI_PROPERTY actionMsiProperty, - [MarshalAs(UnmanagedType.U4)] ref INSTALLUILEVEL uiLevel, - [MarshalAs(UnmanagedType.Bool)] ref bool fDisableExternalUiHandler - ); - - /// - /// See . - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanPackageComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - int hrStatus, - [MarshalAs(UnmanagedType.U4)] RequestState requested - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlannedPackage( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] ActionState execute, - [MarshalAs(UnmanagedType.U4)] ActionState rollback, - [MarshalAs(UnmanagedType.Bool)] bool fPlannedCache, - [MarshalAs(UnmanagedType.Bool)] bool fPlannedUncache - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnApplyBegin( - [MarshalAs(UnmanagedType.U4)] int dwPhaseCount, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnElevateBegin( - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnElevateComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnProgress( - [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, - [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnError( - [MarshalAs(UnmanagedType.U4)] ErrorType errorType, - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] int dwCode, - [MarshalAs(UnmanagedType.LPWStr)] string wzError, - [MarshalAs(UnmanagedType.I4)] int dwUIHint, - [MarshalAs(UnmanagedType.U4)] int cData, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzData, - [MarshalAs(UnmanagedType.I4)] Result nRecommendation, - [MarshalAs(UnmanagedType.I4)] ref Result pResult - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnRegisterBegin( - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnRegisterComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheBegin( - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCachePackageBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] int cCachePayloads, - [MarshalAs(UnmanagedType.U8)] long dw64PackageCacheSize, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheAcquireBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.LPWStr)] string wzSource, - [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, - [MarshalAs(UnmanagedType.U4)] CacheOperation recommendation, - [MarshalAs(UnmanagedType.I4)] ref CacheOperation action, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheAcquireProgress( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.U8)] long dw64Progress, - [MarshalAs(UnmanagedType.U8)] long dw64Total, - [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheAcquireResolving( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3, ArraySubType = UnmanagedType.LPWStr), In] string[] searchPaths, - [MarshalAs(UnmanagedType.U4)] int cSearchPaths, - [MarshalAs(UnmanagedType.Bool)] bool fFoundLocal, - [MarshalAs(UnmanagedType.U4)] int dwRecommendedSearchPath, - [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, - [MarshalAs(UnmanagedType.I4)] CacheResolveOperation recommendation, - [MarshalAs(UnmanagedType.U4)] ref int dwChosenSearchPath, - [MarshalAs(UnmanagedType.I4)] ref CacheResolveOperation action, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheAcquireComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - int hrStatus, - BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, - ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION pAction - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheVerifyBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheVerifyProgress( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.U8)] long dw64Progress, - [MarshalAs(UnmanagedType.U8)] long dw64Total, - [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, - [MarshalAs(UnmanagedType.I4)] CacheVerifyStep verifyStep, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheVerifyComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - int hrStatus, - BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, - ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCachePackageComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - int hrStatus, - BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, - ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecuteBegin( - [MarshalAs(UnmanagedType.U4)] int cExecutingPackages, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecutePackageBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.Bool)] bool fExecute, - [MarshalAs(UnmanagedType.U4)] ActionState action, - [MarshalAs(UnmanagedType.U4)] INSTALLUILEVEL uiLevel, - [MarshalAs(UnmanagedType.Bool)] bool fDisableExternalUiHandler, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecutePatchTarget( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzTargetProductCode, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecuteProgress( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, - [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecuteMsiMessage( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] InstallMessage messageType, - [MarshalAs(UnmanagedType.I4)] int dwUIHint, - [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, - [MarshalAs(UnmanagedType.U4)] int cData, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzData, - [MarshalAs(UnmanagedType.I4)] Result nRecommendation, - [MarshalAs(UnmanagedType.I4)] ref Result pResult - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecuteFilesInUse( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.U4)] int cFiles, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzFiles, - [MarshalAs(UnmanagedType.I4)] Result nRecommendation, - [MarshalAs(UnmanagedType.I4)] ref Result pResult - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecutePackageComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - int hrStatus, - [MarshalAs(UnmanagedType.U4)] ApplyRestart restart, - [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, - [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnExecuteComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnUnregisterBegin( - [MarshalAs(UnmanagedType.Bool)] bool fKeepRegistration, - [MarshalAs(UnmanagedType.Bool)] ref bool fForceKeepRegistration - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnUnregisterComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnApplyComplete( - int hrStatus, - [MarshalAs(UnmanagedType.U4)] ApplyRestart restart, - [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, - [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnLaunchApprovedExeBegin( - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnLaunchApprovedExeComplete( - int hrStatus, - int processId - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnBeginMsiTransactionBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnBeginMsiTransactionComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCommitMsiTransactionBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCommitMsiTransactionComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, - int hrStatus - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnRollbackMsiTransactionBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnRollbackMsiTransactionComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, - int hrStatus - ); - - /// - /// See . - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPauseAutomaticUpdatesBegin( - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPauseAutomaticUpdatesComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSystemRestorePointBegin( - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnSystemRestorePointComplete( - int hrStatus - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnPlanForwardCompatibleBundle( - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, - [MarshalAs(UnmanagedType.U4)] RelationType relationType, - [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, - [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.Bool)] bool fRecommendedIgnoreBundle, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, - [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheContainerOrPayloadVerifyBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheContainerOrPayloadVerifyProgress( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.U8)] long dw64Progress, - [MarshalAs(UnmanagedType.U8)] long dw64Total, - [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCacheContainerOrPayloadVerifyComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - int hrStatus - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCachePayloadExtractBegin( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCachePayloadExtractProgress( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.U8)] long dw64Progress, - [MarshalAs(UnmanagedType.U8)] long dw64Total, - [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, - [MarshalAs(UnmanagedType.Bool)] ref bool fCancel - ); - - /// - /// See . - /// - [PreserveSig] - [return: MarshalAs(UnmanagedType.I4)] - int OnCachePayloadExtractComplete( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - int hrStatus - ); - } - - /// - /// The display level for the BA. - /// - public enum Display - { - /// - /// - /// - Unknown, - - /// - /// - /// - Embedded, - - /// - /// - /// - None, - - /// - /// - /// - Passive, - - /// - /// - /// - Full, - } - - /// - /// Messages from Windows Installer (msi.h). - /// - public enum InstallMessage - { - /// - /// premature termination, possibly fatal OOM - /// - FatalExit, - - /// - /// formatted error message - /// - Error = 0x01000000, - - /// - /// formatted warning message - /// - Warning = 0x02000000, - - /// - /// user request message - /// - User = 0x03000000, - - /// - /// informative message for log - /// - Info = 0x04000000, - - /// - /// list of files in use that need to be replaced - /// - FilesInUse = 0x05000000, - - /// - /// request to determine a valid source location - /// - ResolveSource = 0x06000000, - - /// - /// insufficient disk space message - /// - OutOfDiskSpace = 0x07000000, - - /// - /// start of action: action name & description - /// - ActionStart = 0x08000000, - - /// - /// formatted data associated with individual action item - /// - ActionData = 0x09000000, - - /// - /// progress gauge info: units so far, total - /// - Progress = 0x0a000000, - - /// - /// product info for dialog: language Id, dialog caption - /// - CommonData = 0x0b000000, - - /// - /// sent prior to UI initialization, no string data - /// - Initialize = 0x0c000000, - - /// - /// sent after UI termination, no string data - /// - Terminate = 0x0d000000, - - /// - /// sent prior to display or authored dialog or wizard - /// - ShowDialog = 0x0e000000, - - /// - /// log only, to log performance number like action time - /// - Performance = 0x0f000000, - - /// - /// the list of apps that the user can request Restart Manager to shut down and restart - /// - RMFilesInUse = 0x19000000, - - /// - /// sent prior to server-side install of a product - /// - InstallStart = 0x1a000000, - - /// - /// sent after server-side install - /// - InstallEnd = 0x1B000000, - } - - /// - /// The action to perform when a reboot is necessary. - /// - public enum Restart - { - /// - /// - /// - Unknown, - - /// - /// - /// - Never, - - /// - /// - /// - Prompt, - - /// - /// - /// - Automatic, - - /// - /// - /// - Always, - } - - /// - /// Result codes (based on Dialog Box Command IDs from WinUser.h). - /// - public enum Result - { - /// - /// - /// - Error = -1, - - /// - /// - /// - None, - - /// - /// - /// - Ok, - - /// - /// - /// - Cancel, - - /// - /// - /// - Abort, - - /// - /// - /// - Retry, - - /// - /// - /// - Ignore, - - /// - /// - /// - Yes, - - /// - /// - /// - No, - - /// - /// / - /// - Close, - - /// - /// - /// - Help, - - /// - /// - /// - TryAgain, - - /// - /// - /// - Continue, - } - - /// - /// Describes why a bundle or packaged is being resumed. - /// - public enum ResumeType - { - /// - /// - /// - None, - - /// - /// Resume information exists but is invalid. - /// - Invalid, - - /// - /// The bundle was re-launched after an unexpected interruption. - /// - Interrupted, - - /// - /// A reboot is pending. - /// - RebootPending, - - /// - /// The bundle was re-launched after a reboot. - /// - Reboot, - - /// - /// The bundle was re-launched after being suspended. - /// - Suspend, - - /// - /// The bundle was launched from Add/Remove Programs. - /// - Arp, - } - - /// - /// Indicates what caused the error. - /// - public enum ErrorType - { - /// - /// The error occurred trying to elevate. - /// - Elevate, - - /// - /// The error came from the Windows Installer. - /// - WindowsInstaller, - - /// - /// The error came from an EXE Package. - /// - ExePackage, - - /// - /// The error came while trying to authenticate with an HTTP server. - /// - HttpServerAuthentication, - - /// - /// The error came while trying to authenticate with an HTTP proxy. - /// - HttpProxyAuthentication, - - /// - /// The error occurred during apply. - /// - Apply, - }; - - /// - /// The calculated operation for the related bundle. - /// - public enum RelatedOperation - { - /// - /// - /// - None, - - /// - /// The related bundle or package will be downgraded. - /// - Downgrade, - - /// - /// The related package will be upgraded as a minor revision. - /// - MinorUpdate, - - /// - /// The related bundle or package will be upgraded as a major revision. - /// - MajorUpgrade, - - /// - /// The related bundle will be removed. - /// - Remove, - - /// - /// The related bundle will be installed. - /// - Install, - - /// - /// The related bundle will be repaired. - /// - Repair, - }; - - /// - /// The cache operation used to acquire a container or payload. - /// - public enum CacheOperation - { - /// - /// There is no source available. - /// - None, - - /// - /// Copy the payload or container from the chosen local source. - /// - Copy, - - /// - /// Download the payload or container using the download URL. - /// - Download, - - /// - /// Extract the payload from the container. - /// - Extract, - } - - /// - /// The source to be used to acquire a container or payload. - /// - public enum CacheResolveOperation - { - /// - /// There is no source available. - /// - None, - - /// - /// Copy the payload or container from the chosen local source. - /// - Local, - - /// - /// Download the payload or container from the download URL. - /// - Download, - - /// - /// Extract the payload from the container. - /// - Container, - - /// - /// Look again for the payload or container locally. - /// - Retry, - } - - /// - /// The current step when verifying a container or payload. - /// - public enum CacheVerifyStep - { - /// - /// Copying or moving the file from the working path to the unverified path. - /// Not used during Layout. - /// - Stage, - /// - /// Hashing the file. - /// - Hash, - /// - /// Copying or moving the file to the final location. - /// - Finalize, - } - - /// - /// The restart state after a package or all packages were applied. - /// - public enum ApplyRestart - { - /// - /// Package or chain does not require a restart. - /// - None, - - /// - /// Package or chain requires a restart but it has not been initiated yet. - /// - RestartRequired, - - /// - /// Package or chain has already initiated the restart. - /// - RestartInitiated - } - - /// - /// The relation type for related bundles. - /// - public enum RelationType - { - /// - /// - /// - None, - - /// - /// - /// - Detect, - - /// - /// - /// - Upgrade, - - /// - /// - /// - Addon, - - /// - /// - /// - Patch, - - /// - /// - /// - Dependent, - - /// - /// - /// - Update, - } - - /// - /// One or more reasons why the application is requested to be closed or is being closed. - /// - [Flags] - public enum EndSessionReasons - { - /// - /// The system is shutting down or restarting (it is not possible to determine which event is occurring). - /// - Unknown, - - /// - /// The application is using a file that must be replaced, the system is being serviced, or system resources are exhausted. - /// - CloseApplication, - - /// - /// The application is forced to shut down. - /// - Critical = 0x40000000, - - /// - /// The user is logging off. - /// - Logoff = unchecked((int)0x80000000) - } - - /// - /// The available actions for . - /// - public enum 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 . - /// - Restart, - } - - /// - /// The cache strategy to be used for the package. - /// - public enum BOOTSTRAPPER_CACHE_TYPE - { - /// - /// The package will be cached in order to securely run the package, but will always be cleaned from the cache at the end. - /// - Remove, - - /// - /// The package will be cached in order to run the package, and then kept in the cache until the package is uninstalled. - /// - Keep, - - /// - /// The package will always be cached and stay in the cache, unless the package and bundle are both being uninstalled. - /// - Force, - } - - /// - /// The available actions for . - /// - public enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION - { - /// - /// - /// - None, - - /// - /// Instructs the engine to try the acquisition of the payload again. - /// Ignored if hrStatus is a success. - /// - Retry, - } - - /// - /// The available actions for . - /// - public enum 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. - /// - Ignore, - - /// - /// Instructs the engine to try the acquisition and verification of the package again. - /// Ignored if hrStatus is a success. - /// - Retry, - } - - /// - /// The available actions for . - /// - public enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION - { - /// - /// - /// - None, - - /// - /// Ignored if hrStatus is a success. - /// - RetryVerification, - - /// - /// Ignored if hrStatus is a success. - /// - RetryAcquisition, - } - - /// - /// The available actions for . - /// - public enum 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. - /// - Ignore, - - /// - /// Instructs the engine to try the execution of the package again. - /// Ignored if hrStatus is a success. - /// - Retry, - - /// - /// Instructs the engine to stop processing the chain and restart. - /// The engine will launch again after the machine is restarted. - /// - Restart, - - /// - /// Instructs the engine to stop processing the chain and suspend the current state. - /// - Suspend, - } - - /// - /// The result of evaluating a condition from a package. - /// - public enum BOOTSTRAPPER_PACKAGE_CONDITION_RESULT - { - /// - /// No condition was authored. - /// - Default, - - /// - /// Evaluated to false. - /// - False, - - /// - /// Evaluated to true. - /// - True, - } - - /// - /// The available actions for . - /// - public enum BOOTSTRAPPER_RESOLVESOURCE_ACTION - { - /// - /// Instructs the engine that the source can't be found. - /// - None, - - /// - /// Instructs the engine to try the local source again. - /// - Retry, - - /// - /// Instructs the engine to try the download source. - /// - Download, - } - - /// - /// The available actions for . - /// - public enum 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 . - /// - 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. - /// - ReloadBootstrapper, - - /// - /// Opts out of the engine behavior of trying to uninstall itself when no non-permanent packages are installed. - /// - SkipCleanup, - } - - /// - /// The property Burn will add so the MSI can know the planned action for the package. - /// - public enum BURN_MSI_PROPERTY - { - /// - /// No property will be added. - /// - None, - - /// - /// Add BURNMSIINSTALL=1 - /// - Install, - - /// - /// Add BURNMSIMODFIY=1 - /// - Modify, - - /// - /// Add BURNMSIREPAIR=1 - /// - Repair, - - /// - /// Add BURNMSIUNINSTALL=1 - /// - Uninstall, - } - - /// - /// From msi.h - /// https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetinternalui - /// - [Flags] - public enum INSTALLUILEVEL - { - /// - /// UI level is unchanged - /// - NoChange = 0, - - /// - /// default UI is used - /// - Default = 1, - - /// - /// completely silent installation - /// - None = 2, - - /// - /// simple progress and error handling - /// - Basic = 3, - - /// - /// authored UI, wizard dialogs suppressed - /// - Reduced = 4, - - /// - /// authored UI with wizards, progress, errors - /// - Full = 5, - - /// - /// display success/failure dialog at end of install - /// - EndDialog = 0x80, - - /// - /// display only progress dialog - /// - ProgressOnly = 0x40, - - /// - /// do not display the cancel button in basic UI - /// - HideCancel = 0x20, - - /// - /// force display of source resolution even if quiet - /// - SourceResOnly = 0x100, - - /// - /// show UAC prompt even if quiet - /// Can only be used if on Windows Installer 5.0 or later - /// - UacOnly = 0x200, - } -} diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs deleted file mode 100644 index 23a1c8a3..00000000 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationData.cs +++ /dev/null @@ -1,22 +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 WixToolset.Mba.Core -{ - using System.IO; - - /// - /// Interface for BootstrapperApplicationData.xml. - /// - public interface IBootstrapperApplicationData - { - /// - /// The BootstrapperApplicationData.xml file. - /// - FileInfo BADataFile { get; } - - /// - /// The BA manifest. - /// - IBundleInfo Bundle { get; } - } -} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs deleted file mode 100644 index 0f9193d0..00000000 --- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs +++ /dev/null @@ -1,66 +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 WixToolset.Mba.Core -{ - using System; - using System.CodeDom.Compiler; - using System.Runtime.InteropServices; - - /// - /// Interface used by WixToolset.Mba.Host to dynamically load the BA. - /// - [ComVisible(true)] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("2965A12F-AC7B-43A0-85DF-E4B2168478A4")] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] - public interface IBootstrapperApplicationFactory - { - /// - /// Low level method called by the native host. - /// - /// - /// - 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; - [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; - 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, - this.restart, - 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)); - } - } -} diff --git a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/WixToolset.Mba.Core/IBootstrapperCommand.cs deleted file mode 100644 index e861813f..00000000 --- a/src/WixToolset.Mba.Core/IBootstrapperCommand.cs +++ /dev/null @@ -1,76 +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 WixToolset.Mba.Core -{ - using System; - - /// - /// Command information passed from the engine for the BA to perform. - /// - public interface IBootstrapperCommand - { - /// - /// Gets the action for the BA to perform. - /// - LaunchAction Action { get; } - - /// - /// Gets the display level for the BA. - /// - Display Display { get; } - - /// - /// Gets the action to perform if a reboot is required. - /// - Restart Restart { get; } - - /// - /// Gets the command line arguments as a string array. - /// - /// - /// Array of command line arguments not handled by the engine. - /// - /// The command line could not be parsed into an array. - string[] CommandLineArgs { get; } - - /// - /// Hint for the initial visibility of the window. - /// - int CmdShow { get; } - - /// - /// Gets the method of how the engine was resumed from a previous installation step. - /// - ResumeType Resume { get; } - - /// - /// Gets the handle to the splash screen window. If no splash screen was displayed this value will be IntPtr.Zero. - /// - IntPtr SplashScreen { get; } - - /// - /// If this was run from a related bundle, specifies the relation type. - /// - RelationType Relation { get; } - - /// - /// If this was run from a backward compatible bundle. - /// - bool Passthrough { get; } - - /// - /// Gets layout directory. - /// - string LayoutDirectory { get; } - - /// - /// Gets bootstrapper working folder. - /// - string BootstrapperWorkingFolder { get; } - - /// - /// Gets path to BootstrapperApplicationData.xml. - /// - string BootstrapperApplicationDataPath { get; } - } -} diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs deleted file mode 100644 index 4e19bf0f..00000000 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ /dev/null @@ -1,536 +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 WixToolset.Mba.Core -{ - using System; - using System.CodeDom.Compiler; - using System.Runtime.InteropServices; - using System.Text; - - /// - /// Allows calls into the bootstrapper engine. - /// - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("6480D616-27A0-44D7-905B-81512C29C2FB")] - [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] - public interface IBootstrapperEngine - { - /// - /// See . - /// - /// - void GetPackageCount( - [MarshalAs(UnmanagedType.U4)] out int pcPackages - ); - - /// - /// See . - /// - /// - /// - /// - [PreserveSig] - int GetVariableNumeric( - [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - out long pllValue - ); - - /// - /// See . - /// - [PreserveSig] - int GetVariableString( - [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - IntPtr wzValue, - ref IntPtr pcchValue - ); - - /// - /// See . - /// - [PreserveSig] - int GetVariableVersion( - [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - IntPtr wzValue, - ref IntPtr pcchValue - ); - - /// - /// See . - /// - [PreserveSig] - int FormatString( - [MarshalAs(UnmanagedType.LPWStr)] string wzIn, - [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, - ref IntPtr pcchOut - ); - - /// - /// See . - /// - [PreserveSig] - int EscapeString( - [MarshalAs(UnmanagedType.LPWStr)] string wzIn, - [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, - ref IntPtr pcchOut - ); - - /// - /// See . - /// - /// - /// - void EvaluateCondition( - [MarshalAs(UnmanagedType.LPWStr)] string wzCondition, - [MarshalAs(UnmanagedType.Bool)] out bool pf - ); - - /// - /// See . - /// - /// - /// - void Log( - [MarshalAs(UnmanagedType.U4)] LogLevel level, - [MarshalAs(UnmanagedType.LPWStr)] string wzMessage - ); - - /// - /// See . - /// - /// - /// - /// - /// - void SendEmbeddedError( - [MarshalAs(UnmanagedType.U4)] int dwErrorCode, - [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, - [MarshalAs(UnmanagedType.U4)] int dwUIHint, - [MarshalAs(UnmanagedType.I4)] out int pnResult - ); - - /// - /// See . - /// - /// - /// - /// - void SendEmbeddedProgress( - [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, - [MarshalAs(UnmanagedType.U4)] int dwOverallProgressPercentage, - [MarshalAs(UnmanagedType.I4)] out int pnResult - ); - - /// - /// 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.LPArray, SizeParamIndex=4)] byte[] rgbHash, - [MarshalAs(UnmanagedType.U4)] int cbHash - ); - - /// - /// See . - /// - /// - /// - /// - void SetLocalSource( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPath - ); - - /// - /// See . - /// - /// - /// - /// - /// - /// - void SetDownloadSource( - [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, - [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.LPWStr)] string wzUrl, - [MarshalAs(UnmanagedType.LPWStr)] string wzUser, - [MarshalAs(UnmanagedType.LPWStr)] string wzPassword - ); - - /// - /// See . - /// - /// - /// - void SetVariableNumeric( - [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - long llValue - ); - - /// - /// See . - /// - /// - /// - /// - void SetVariableString( - [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - IntPtr wzValue, - [MarshalAs(UnmanagedType.Bool)] bool fFormatted - ); - - /// - /// See . - /// - /// - /// - void SetVariableVersion( - [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - IntPtr wzValue - ); - - /// - /// See . - /// - void CloseSplashScreen(); - - /// - /// See . - /// - /// - void Detect( - IntPtr hwndParent - ); - - /// - /// See . - /// - /// - void Plan( - [MarshalAs(UnmanagedType.U4)] LaunchAction action - ); - - /// - /// See . - /// - /// - /// - [PreserveSig] - int Elevate( - IntPtr hwndParent - ); - - /// - /// See . - /// - /// - void Apply( - IntPtr hwndParent - ); - - /// - /// See . - /// - /// - void Quit( - [MarshalAs(UnmanagedType.U4)] int dwExitCode - ); - - /// - /// See . - /// - /// - /// - /// - /// - void LaunchApprovedExe( - IntPtr hwndParent, - [MarshalAs(UnmanagedType.LPWStr)] string wzApprovedExeForElevationId, - [MarshalAs(UnmanagedType.LPWStr)] string wzArguments, - [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout - ); - - /// - /// Sets the URL to the update feed. - /// - /// URL of the update feed. - void SetUpdateSource( - [MarshalAs(UnmanagedType.LPWStr)] string url - ); - - /// - /// See . - /// - /// - /// - /// - void CompareVersions( - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, - [MarshalAs(UnmanagedType.I4)] out int pnResult - ); - } - - /// - /// The installation action for the bundle or current package. - /// - public enum ActionState - { - /// - /// - /// - None, - - /// - /// - /// - Uninstall, - - /// - /// - /// - Install, - - /// - /// - /// - Modify, - - /// - /// - /// - Mend, - - /// - /// - /// - Repair, - - /// - /// - /// - MinorUpgrade, - } - - /// - /// The action for the BA to perform. - /// - public enum LaunchAction - { - /// - /// - /// - Unknown, - - /// - /// - /// - Help, - - /// - /// - /// - Layout, - - /// - /// - /// - Uninstall, - - /// - /// - /// - Cache, - - /// - /// - /// - Install, - - /// - /// - /// - Modify, - - /// - /// - /// - Repair, - - /// - /// - /// - UpdateReplace, - - /// - /// - /// - UpdateReplaceEmbedded, - } - - /// - /// The message log level. - /// - public enum LogLevel - { - /// - /// No logging level (generic). - /// - None, - - /// - /// User messages. - /// - Standard, - - /// - /// Verbose messages. - /// - Verbose, - - /// - /// Messages for debugging. - /// - Debug, - - /// - /// Error messages. - /// - Error, - } - - /// - /// Type of hash used for update bundle. - /// - public enum UpdateHashType - { - /// - /// No hash provided. - /// - None, - - /// - /// SHA-1 based hash provided. - /// - Sha1, - } - - /// - /// Describes the state of an installation package. - /// - public enum PackageState - { - /// - /// - /// - Unknown, - - /// - /// - /// - Obsolete, - - /// - /// - /// - Absent, - - /// - /// - /// - Cached, - - /// - /// - /// - Present, - - /// - /// - /// - Superseded, - } - - /// - /// Indicates the state desired for an installation package. - /// - public enum RequestState - { - /// - /// - /// - None, - - /// - /// / - /// - ForceAbsent, - - /// - /// - /// - Absent, - - /// - /// - /// - Cache, - - /// - /// - /// - Present, - - /// - /// - /// - Mend, - - /// - /// - /// - Repair, - } - - /// - /// Indicates the state of a feature. - /// - public enum FeatureState - { - /// - /// - /// - Unknown, - - /// - /// - /// - Absent, - - /// - /// - /// - Advertised, - - /// - /// - /// - Local, - - /// - /// - /// - Source, - } -} diff --git a/src/WixToolset.Mba.Core/IBundleInfo.cs b/src/WixToolset.Mba.Core/IBundleInfo.cs deleted file mode 100644 index f4a82f36..00000000 --- a/src/WixToolset.Mba.Core/IBundleInfo.cs +++ /dev/null @@ -1,39 +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 WixToolset.Mba.Core -{ - using System.Collections.Generic; - - /// - /// BA manifest data. - /// - public interface IBundleInfo - { - /// - /// - /// - string LogVariable { get; } - - /// - /// - /// - string Name { get; } - - /// - /// - /// - IDictionary Packages { get; } - - /// - /// - /// - bool PerMachine { get; } - - /// - /// Adds a related bundle as a package. - /// - /// - /// The created . - IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); - } -} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs deleted file mode 100644 index a295f6c0..00000000 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ /dev/null @@ -1,387 +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 WixToolset.Mba.Core -{ - using System; - - /// - /// Interface for built-in implementation of . - /// - public interface IDefaultBootstrapperApplication : IBootstrapperApplication - { - /// - /// Fired when the engine has begun installing the bundle. - /// - event EventHandler ApplyBegin; - - /// - /// Fired when the engine has completed installing the bundle. - /// - event EventHandler ApplyComplete; - - /// - /// Fired when the engine is about to begin an MSI transaction. - /// - event EventHandler BeginMsiTransactionBegin; - - /// - /// Fired when the engine has completed beginning an MSI transaction. - /// - event EventHandler BeginMsiTransactionComplete; - - /// - /// Fired when the engine has begun acquiring the payload or container. - /// The BA can change the source using - /// or . - /// - event EventHandler CacheAcquireBegin; - - /// - /// Fired when the engine has completed the acquisition of the payload or container. - /// The BA can change the source using - /// or . - /// - event EventHandler CacheAcquireComplete; - - /// - /// Fired when the engine has progress acquiring the payload or container. - /// - event EventHandler CacheAcquireProgress; - - /// - /// Fired by the engine to allow the BA to override the acquisition action. - /// - event EventHandler CacheAcquireResolving; - - /// - /// Fired when the engine has begun caching the installation sources. - /// - event EventHandler CacheBegin; - - /// - /// Fired after the engine has cached the installation sources. - /// - event EventHandler CacheComplete; - - /// - /// Fired when the engine begins the verification of the payload or container that was already in the package cache. - /// - event EventHandler CacheContainerOrPayloadVerifyBegin; - - /// - /// Fired when the engine has completed the verification of the payload or container that was already in the package cache. - /// - event EventHandler CacheContainerOrPayloadVerifyComplete; - - /// - /// Fired when the engine has progress verifying the payload or container that was already in the package cache. - /// - event EventHandler CacheContainerOrPayloadVerifyProgress; - - /// - /// Fired when the engine has begun caching a specific package. - /// - event EventHandler CachePackageBegin; - - /// - /// Fired when the engine has completed caching a specific package. - /// - event EventHandler CachePackageComplete; - - /// - /// Fired when the engine begins the extraction of the payload from the container. - /// - event EventHandler CachePayloadExtractBegin; - - /// - /// Fired when the engine has completed the extraction of the payload from the container. - /// - event EventHandler CachePayloadExtractComplete; - - /// - /// Fired when the engine has progress extracting the payload from the container. - /// - event EventHandler CachePayloadExtractProgress; - - /// - /// Fired when the engine begins the verification of the acquired payload or container. - /// - event EventHandler CacheVerifyBegin; - - /// - /// Fired when the engine has completed the verification of the acquired payload or container. - /// - event EventHandler CacheVerifyComplete; - - /// - /// Fired when the engine has progress verifying the payload or container. - /// - event EventHandler CacheVerifyProgress; - - /// - /// Fired when the engine is about to commit an MSI transaction. - /// - event EventHandler CommitMsiTransactionBegin; - - /// - /// Fired when the engine has completed comitting an MSI transaction. - /// - event EventHandler CommitMsiTransactionComplete; - - /// - /// Fired when the overall detection phase has begun. - /// - event EventHandler DetectBegin; - - /// - /// Fired when the detection phase has completed. - /// - event EventHandler DetectComplete; - - /// - /// Fired when a forward compatible bundle is detected. - /// - event EventHandler DetectForwardCompatibleBundle; - - /// - /// Fired when a feature in an MSI package has been detected. - /// - event EventHandler DetectMsiFeature; - - /// - /// Fired when the detection for a specific package has begun. - /// - event EventHandler DetectPackageBegin; - - /// - /// Fired when the detection for a specific package has completed. - /// - event EventHandler DetectPackageComplete; - - /// - /// Fired when the engine detects a target product for an MSP package. - /// - event EventHandler DetectPatchTarget; - - /// - /// Fired when a related bundle has been detected for a bundle. - /// - event EventHandler DetectRelatedBundle; - - /// - /// Fired when a related MSI package has been detected for a package. - /// - event EventHandler DetectRelatedMsiPackage; - - /// - /// Fired when the update detection has found a potential update candidate. - /// - event EventHandler DetectUpdate; - - /// - /// Fired when the update detection phase has begun. - /// - event EventHandler DetectUpdateBegin; - - /// - /// Fired when the update detection phase has completed. - /// - event EventHandler DetectUpdateComplete; - - /// - /// Fired when the engine is about to start the elevated process. - /// - event EventHandler ElevateBegin; - - /// - /// Fired when the engine has completed starting the elevated process. - /// - event EventHandler ElevateComplete; - - /// - /// Fired when the engine has encountered an error. - /// - event EventHandler Error; - - /// - /// Fired when the engine has begun installing packages. - /// - event EventHandler ExecuteBegin; - - /// - /// Fired when the engine has completed installing packages. - /// - event EventHandler ExecuteComplete; - - /// - /// Fired when a package sends a files in use installation message. - /// - event EventHandler ExecuteFilesInUse; - - /// - /// Fired when Windows Installer sends an installation message. - /// - event EventHandler ExecuteMsiMessage; - - /// - /// Fired when the engine has begun installing a specific package. - /// - event EventHandler ExecutePackageBegin; - - /// - /// Fired when the engine has completed installing a specific package. - /// - event EventHandler ExecutePackageComplete; - - /// - /// Fired when the engine executes one or more patches targeting a product. - /// - event EventHandler ExecutePatchTarget; - - /// - /// Fired by the engine while executing a package. - /// - event EventHandler ExecuteProgress; - - /// - /// Fired when the engine is about to launch the preapproved executable. - /// - event EventHandler LaunchApprovedExeBegin; - - /// - /// Fired when the engine has completed launching the preapproved executable. - /// - event EventHandler LaunchApprovedExeComplete; - - /// - /// Fired when the engine is about to pause Windows automatic updates. - /// - event EventHandler PauseAutomaticUpdatesBegin; - - /// - /// Fired when the engine has completed pausing Windows automatic updates. - /// - event EventHandler PauseAutomaticUpdatesComplete; - - /// - /// Fired when the engine has begun planning the installation. - /// - event EventHandler PlanBegin; - - /// - /// Fired when the engine has completed planning the installation. - /// - event EventHandler PlanComplete; - - /// - /// Fired when the engine is about to plan a forward compatible bundle. - /// - event EventHandler PlanForwardCompatibleBundle; - - /// - /// Fired when the engine has completed planning a package. - /// - event EventHandler PlannedPackage; - - /// - /// Fired when the engine is about to plan a feature in an MSI package. - /// - event EventHandler PlanMsiFeature; - - /// - /// Fired when the engine is planning an MSI or MSP package. - /// - event EventHandler PlanMsiPackage; - - /// - /// Fired when the engine has begun getting the BA's input for planning a package. - /// - event EventHandler PlanPackageBegin; - - /// - /// Fired when the engine has completed getting the BA's input for planning a package. - /// - event EventHandler PlanPackageComplete; - - /// - /// Fired when the engine is about to plan a target of an MSP package. - /// - event EventHandler PlanPatchTarget; - - /// - /// Fired when the engine has begun planning for a related bundle. - /// - event EventHandler PlanRelatedBundle; - - /// - /// Fired when the engine has changed progress for the bundle installation. - /// - event EventHandler Progress; - - /// - /// Fired when the engine has begun registering the location and visibility of the bundle. - /// - event EventHandler RegisterBegin; - - /// - /// Fired when the engine has completed registering the location and visibility of the bundle. - /// - event EventHandler RegisterComplete; - - /// - /// Fired when the engine is about to rollback an MSI transaction. - /// - event EventHandler RollbackMsiTransactionBegin; - - /// - /// Fired when the engine has completed rolling back an MSI transaction. - /// - event EventHandler RollbackMsiTransactionComplete; - - /// - /// Fired when the engine is shutting down the bootstrapper application. - /// - event EventHandler Shutdown; - - /// - /// Fired when the engine is starting up the bootstrapper application. - /// - event EventHandler Startup; - - /// - /// Fired when the engine is about to take a system restore point. - /// - event EventHandler SystemRestorePointBegin; - - /// - /// Fired when the engine has completed taking a system restore point. - /// - event EventHandler SystemRestorePointComplete; - - /// - /// Fired when the system is shutting down or user is logging off. - /// - /// - /// To prevent shutting down or logging off, set to - /// true; otherwise, set it to false. - /// By default setup will prevent shutting down or logging off between - /// and . - /// Derivatives can change this behavior by handling . - /// If contains - /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other - /// critical operations before being closed by the operating system. - /// This event may be fired on a different thread. - /// - event EventHandler SystemShutdown; - - /// - /// Fired when the engine unregisters the bundle. - /// - event EventHandler UnregisterBegin; - - /// - /// Fired when the engine unregistration is complete. - /// - event EventHandler UnregisterComplete; - } -} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs deleted file mode 100644 index 3e636961..00000000 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ /dev/null @@ -1,222 +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 WixToolset.Mba.Core -{ - using System; - using System.ComponentModel; - using System.Security; - - /// - /// High level abstraction over the interface. - /// - public interface IEngine - { - /// - /// Gets the number of packages in the bundle. - /// - int PackageCount { get; } - - /// - /// Install the packages. - /// - /// The parent window for the installation user interface. - void Apply(IntPtr hwndParent); - - /// - /// Close the splash screen if it is still open. Does nothing if the splash screen is not or - /// never was opened. - /// - void CloseSplashScreen(); - - /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 - int CompareVersions(string version1, string version2); - - /// - /// Checks if a variable exists in the engine. - /// - /// The name of the variable. - /// Whether the variable exists. - bool ContainsVariable(string name); - - /// - /// Determine if all installation conditions are fulfilled. - /// - void Detect(); - - /// - /// Determine if all installation conditions are fulfilled. - /// - /// The parent window for the installation user interface. - void Detect(IntPtr hwndParent); - - /// - /// Elevate the install. - /// - /// The parent window of the elevation dialog. - /// true if elevation succeeded; otherwise, false if the user cancelled. - /// A Win32 error occurred. - bool Elevate(IntPtr hwndParent); - - /// - /// Escapes the input string. - /// - /// The string to escape. - /// The escaped string. - /// A Win32 error occurred. - string EscapeString(string input); - - /// - /// Evaluates the string. - /// - /// The string representing the condition to evaluate. - /// Whether the condition evaluated to true or false. - bool EvaluateCondition(string condition); - - /// - /// Formats the input string. - /// - /// The string to format. - /// The formatted string. - /// A Win32 error occurred. - string FormatString(string format); - - /// - /// Gets numeric variables for the engine. - /// - /// The name of the variable. - long GetVariableNumeric(string name); - - /// - /// Gets string variables for the engine using SecureStrings. - /// - /// The name of the variable. - SecureString GetVariableSecureString(string name); - - /// - /// Gets string variables for the engine. - /// - /// The name of the variable. - string GetVariableString(string name); - - /// - /// Gets variables for the engine. - /// - /// The name of the variable. - string GetVariableVersion(string name); - - /// - /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. - /// - /// The parent window of the elevation dialog (if the engine hasn't elevated yet). - /// Id of the ApprovedExeForElevation element specified when the bundle was authored. - /// Optional arguments. - void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments); - - /// - /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. - /// - /// The parent window of the elevation dialog (if the engine hasn't elevated yet). - /// Id of the ApprovedExeForElevation element specified when the bundle was authored. - /// Optional arguments. - /// Timeout in milliseconds. When set to something other than zero, the engine will call WaitForInputIdle for the new process with this timeout before calling OnLaunchApprovedExeComplete. - void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout); - - /// - /// Logs the . - /// - /// The logging level. - /// The message to log. - void Log(LogLevel level, string message); - - /// - /// Determine the installation sequencing and costing. - /// - /// The action to perform when planning. - void Plan(LaunchAction action); - - /// - /// Set the update information for a bundle. - /// - /// Optional local source path for the update. Default is "update\[OriginalNameOfBundle].exe". - /// Optional download source for the update. - /// 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, byte[] hash); - - /// - /// Sets the URL to the update feed. - /// - /// URL of the update feed. - void SetUpdateSource(string url); - - /// - /// Set the local source for a package or container. - /// - /// The id that uniquely identifies the package or container. - /// The id that uniquely identifies the payload. - /// The new source path. - void SetLocalSource(string packageOrContainerId, string payloadId, string path); - - /// - /// Set the new download URL for a package or container. - /// - /// The id that uniquely identifies the package or container. - /// The id that uniquely identifies the payload. - /// The new url. - /// The user name for proxy authentication. - /// The password for proxy authentication. - void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password); - - /// - /// Sets numeric variables for the engine. - /// - /// The name of the variable. - /// The value to set. - void SetVariableNumeric(string name, long value); - - /// - /// Sets string variables for the engine using SecureStrings. - /// - /// The name of the variable. - /// The value to set. - /// False if the value is a literal string. - void SetVariableString(string name, SecureString value, bool formatted); - - /// - /// Sets string variables for the engine. - /// - /// The name of the variable. - /// The value to set. - /// False if the value is a literal string. - void SetVariableString(string name, string value, bool formatted); - - /// - /// Sets version variables for the engine. - /// - /// The name of the variable. - /// The value to set. - void SetVariableVersion(string name, string value); - - /// - /// Sends error message when embedded. - /// - /// Error code. - /// Error message. - /// UI buttons to show on error dialog. - int SendEmbeddedError(int errorCode, string message, int uiHint); - - /// - /// Sends progress percentages when embedded. - /// - /// Percentage completed thus far. - /// Overall percentage completed. - int SendEmbeddedProgress(int progressPercentage, int overallPercentage); - - /// - /// Shuts down the engine. - /// - /// Exit code indicating reason for shut down. - void Quit(int exitCode); - } -} diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs deleted file mode 100644 index a1d99b10..00000000 --- a/src/WixToolset.Mba.Core/IPackageInfo.cs +++ /dev/null @@ -1,90 +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 WixToolset.Mba.Core -{ - /// - /// Package information from the BA manifest. - /// - public interface IPackageInfo - { - /// - /// - /// - BOOTSTRAPPER_CACHE_TYPE CacheType { get; } - - /// - /// Place for the BA to store it's own custom data for this package. - /// - object CustomData { get; set; } - - /// - /// - /// - string Description { get; } - - /// - /// - /// - string DisplayInternalUICondition { get; } - - /// - /// - /// - string DisplayName { get; } - - /// - /// - /// - string Id { get; } - - /// - /// - /// - string InstallCondition { get; } - - /// - /// - /// - bool Permanent { get; } - - /// - /// - /// - bool PrereqPackage { get; } - - /// - /// - /// - string PrereqLicenseFile { get; } - - /// - /// - /// - string PrereqLicenseUrl { get; } - - /// - /// - /// - string ProductCode { get; } - - /// - /// - /// - PackageType Type { get; } - - /// - /// - /// - string UpgradeCode { get; } - - /// - /// - /// - string Version { get; } - - /// - /// - /// - bool Vital { get; } - } -} \ No newline at end of file diff --git a/src/WixToolset.Mba.Core/NativeMethods.cs b/src/WixToolset.Mba.Core/NativeMethods.cs deleted file mode 100644 index adb2256e..00000000 --- a/src/WixToolset.Mba.Core/NativeMethods.cs +++ /dev/null @@ -1,37 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - - /// - /// Contains native constants, functions, and structures for this assembly. - /// - internal static class NativeMethods - { - #region Error Constants - internal const int S_OK = 0; - internal const int E_MOREDATA = unchecked((int)0x800700ea); - internal const int E_INSUFFICIENT_BUFFER = unchecked((int)0x8007007a); - internal const int E_CANCELLED = unchecked((int)0x800704c7); - internal const int E_ALREADYINITIALIZED = unchecked((int)0x800704df); - internal const int E_NOTFOUND = unchecked((int)0x80070490); - internal const int E_NOTIMPL = unchecked((int)0x80004001); - internal const int E_UNEXPECTED = unchecked((int)0x8000ffff); - #endregion - - #region Functions - [DllImport("shell32.dll", ExactSpelling = true, SetLastError = true)] - internal static extern IntPtr CommandLineToArgvW( - [MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine, - out int pNumArgs - ); - - [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)] - internal static extern IntPtr LocalFree( - IntPtr hMem - ); - #endregion - } -} diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs deleted file mode 100644 index 567a7cdd..00000000 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ /dev/null @@ -1,317 +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 WixToolset.Mba.Core -{ - using System; - using System.Collections.Generic; - using System.Xml; - using System.Xml.XPath; - - /// - /// - /// - public enum PackageType - { - /// - /// - /// - Unknown, - - /// - /// - /// - Exe, - - /// - /// - /// - Msi, - - /// - /// - /// - Msp, - - /// - /// - /// - Msu, - - /// - /// - /// - UpgradeBundle, - - /// - /// - /// - AddonBundle, - - /// - /// - /// - PatchBundle, - } - - /// - /// Default implementation of . - /// - public class PackageInfo : IPackageInfo - { - /// - public string Id { get; internal set; } - - /// - public string DisplayName { get; internal set; } - - /// - public string Description { get; internal set; } - - /// - public PackageType Type { get; internal set; } - - /// - public bool Permanent { get; internal set; } - - /// - public bool Vital { get; internal set; } - - /// - public string DisplayInternalUICondition { get; internal set; } - - /// - public string ProductCode { get; internal set; } - - /// - public string UpgradeCode { get; internal set; } - - /// - public string Version { get; internal set; } - - /// - public string InstallCondition { get; internal set; } - - /// - public BOOTSTRAPPER_CACHE_TYPE CacheType { get; internal set; } - - /// - public bool PrereqPackage { get; internal set; } - - /// - public string PrereqLicenseFile { get; internal set; } - - /// - public string PrereqLicenseUrl { get; internal set; } - - /// - public object CustomData { get; set; } - - internal PackageInfo() { } - - /// - /// - /// - /// - /// - public static IDictionary ParsePackagesFromXml(XPathNavigator root) - { - var packagesById = new Dictionary(); - XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); - namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); - XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); - - foreach (XPathNavigator node in nodes) - { - var package = new PackageInfo(); - - string id = BootstrapperApplicationData.GetAttribute(node, "Package"); - if (id == null) - { - throw new Exception("Failed to get package identifier for package."); - } - package.Id = id; - - package.DisplayName = BootstrapperApplicationData.GetAttribute(node, "DisplayName"); - - package.Description = BootstrapperApplicationData.GetAttribute(node, "Description"); - - PackageType? packageType = GetPackageTypeAttribute(node, "PackageType"); - if (!packageType.HasValue) - { - throw new Exception("Failed to get package type for package."); - } - package.Type = packageType.Value; - - bool? permanent = BootstrapperApplicationData.GetYesNoAttribute(node, "Permanent"); - if (!permanent.HasValue) - { - throw new Exception("Failed to get permanent settings for package."); - } - package.Permanent = permanent.Value; - - bool? vital = BootstrapperApplicationData.GetYesNoAttribute(node, "Vital"); - if (!vital.HasValue) - { - throw new Exception("Failed to get vital setting for package."); - } - package.Vital = vital.Value; - - package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); - - package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); - - package.Version = BootstrapperApplicationData.GetAttribute(node, "Version"); - - package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); - - packagesById.Add(package.Id, package); - } - - ParseBalPackageInfoFromXml(root, namespaceManager, packagesById); - return packagesById; - } - - /// - /// - /// - /// - /// - /// - public static BOOTSTRAPPER_CACHE_TYPE? GetCacheTypeAttribute(XPathNavigator node, string attributeName) - { - string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); - - if (attributeValue == null) - { - return null; - } - - if (attributeValue.Equals("keep", StringComparison.InvariantCulture)) - { - return BOOTSTRAPPER_CACHE_TYPE.Keep; - } - else if (attributeValue.Equals("force", StringComparison.InvariantCulture)) - { - return BOOTSTRAPPER_CACHE_TYPE.Force; - } - else - { - return BOOTSTRAPPER_CACHE_TYPE.Remove; - } - } - - /// - /// - /// - /// - /// - /// - public static PackageType? GetPackageTypeAttribute(XPathNavigator node, string attributeName) - { - string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); - - if (attributeValue == null) - { - return null; - } - - if (attributeValue.Equals("Exe", StringComparison.InvariantCulture)) - { - return PackageType.Exe; - } - else if (attributeValue.Equals("Msi", StringComparison.InvariantCulture)) - { - return PackageType.Msi; - } - else if (attributeValue.Equals("Msp", StringComparison.InvariantCulture)) - { - return PackageType.Msp; - } - else if (attributeValue.Equals("Msu", StringComparison.InvariantCulture)) - { - return PackageType.Msu; - } - else - { - return PackageType.Unknown; - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, string version) - { - PackageInfo package = new PackageInfo(); - package.Id = id; - package.Version = version; - - switch (relationType) - { - case RelationType.Addon: - package.Type = PackageType.AddonBundle; - break; - case RelationType.Patch: - package.Type = PackageType.PatchBundle; - break; - case RelationType.Upgrade: - package.Type = PackageType.UpgradeBundle; - break; - default: - throw new Exception(string.Format("Unknown related bundle type: {0}", relationType)); - } - - return package; - } - - internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespaceManager namespaceManager, Dictionary packagesById) - { - XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixBalPackageInfo", namespaceManager); - - foreach (XPathNavigator node in nodes) - { - string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); - if (id == null) - { - throw new Exception("Failed to get package identifier for WixBalPackageInfo."); - } - - if (!packagesById.TryGetValue(id, out var ipackage)) - { - throw new Exception(string.Format("Failed to find package specified in WixBalPackageInfo: {0}", id)); - } - - var package = (PackageInfo)ipackage; - - package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); - } - - nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", 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."); - } - - if (!packagesById.TryGetValue(id, out var ipackage)) - { - throw new Exception(string.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); - } - - var package = (PackageInfo)ipackage; - - package.PrereqPackage = true; - package.PrereqLicenseFile = BootstrapperApplicationData.GetAttribute(node, "LicenseFile"); - package.PrereqLicenseUrl = BootstrapperApplicationData.GetAttribute(node, "LicenseUrl"); - } - } - } -} diff --git a/src/WixToolset.Mba.Core/VerUtil.cs b/src/WixToolset.Mba.Core/VerUtil.cs deleted file mode 100644 index 81c5b716..00000000 --- a/src/WixToolset.Mba.Core/VerUtil.cs +++ /dev/null @@ -1,145 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - using System.Text; - - /// - /// Managed wrapper for verutil. - /// - public static class VerUtil - { - [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern int VerCompareParsedVersions( - VersionHandle pVersion1, - VersionHandle pVersion2 - ); - - [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern int VerCompareStringVersions( - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, - [MarshalAs(UnmanagedType.Bool)] bool fStrict - ); - - [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern VersionHandle VerCopyVersion( - VersionHandle pSource - ); - - [DllImport("mbanative.dll", ExactSpelling = true)] - internal static extern void VerFreeVersion( - IntPtr pVersion - ); - - [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern VersionHandle VerParseVersion( - [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, - [MarshalAs(UnmanagedType.U4)] uint cchValue, - [MarshalAs(UnmanagedType.Bool)] bool fStrict - ); - - [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] - internal static extern VersionHandle VerVersionFromQword( - [MarshalAs(UnmanagedType.I8)] long qwVersion - ); - - [StructLayout(LayoutKind.Sequential)] - internal struct VersionReleaseLabelStruct - { - public bool fNumeric; - public uint dwValue; - public IntPtr cchLabelOffset; - public int cchLabel; - } - - [StructLayout(LayoutKind.Sequential)] - internal struct VersionStruct - { - public IntPtr sczVersion; - public uint dwMajor; - public uint dwMinor; - public uint dwPatch; - public uint dwRevision; - public int cReleaseLabels; - public IntPtr rgReleaseLabels; - public IntPtr cchMetadataOffset; - public bool fInvalid; - } - - internal static string VersionStringFromOffset(IntPtr wzVersion, IntPtr cchOffset, int? cchLength = null) - { - var offset = cchOffset.ToInt64() * UnicodeEncoding.CharSize; - var wz = new IntPtr(wzVersion.ToInt64() + offset); - if (cchLength.HasValue) - { - return Marshal.PtrToStringUni(wz, (int)cchLength); - } - else - { - return Marshal.PtrToStringUni(wz); - } - } - - internal sealed class VersionHandle : SafeHandle - { - public VersionHandle() : base(IntPtr.Zero, true) { } - - public override bool IsInvalid => false; - - protected override bool ReleaseHandle() - { - VerFreeVersion(this.handle); - return true; - } - } - - /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 - public static int CompareParsedVersions(VerUtilVersion version1, VerUtilVersion version2) - { - return VerCompareParsedVersions(version1.GetHandle(), version2.GetHandle()); - } - - /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 - public static int CompareStringVersions(string version1, string version2, bool strict) - { - return VerCompareStringVersions(version1, version2, strict); - } - - /// - /// - /// - /// - /// - public static VerUtilVersion CopyVersion(VerUtilVersion version) - { - var handle = VerCopyVersion(version.GetHandle()); - return new VerUtilVersion(handle); - } - - /// - /// - /// - /// - /// Whether to throw exception on invalid version. - /// - public static VerUtilVersion ParseVersion(string version, bool strict) - { - var handle = VerParseVersion(version, 0, strict); - return new VerUtilVersion(handle); - } - - /// - /// - /// - /// - /// - public static VerUtilVersion VersionFromQword(long version) - { - var handle = VerVersionFromQword(version); - return new VerUtilVersion(handle); - } - } -} diff --git a/src/WixToolset.Mba.Core/VerUtilVersion.cs b/src/WixToolset.Mba.Core/VerUtilVersion.cs deleted file mode 100644 index 7408c26f..00000000 --- a/src/WixToolset.Mba.Core/VerUtilVersion.cs +++ /dev/null @@ -1,99 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - - /// - /// An enhanced implementation of SemVer 2.0. - /// - public sealed class VerUtilVersion : IDisposable - { - internal VerUtilVersion(VerUtil.VersionHandle handle) - { - this.Handle = handle; - - var pVersion = handle.DangerousGetHandle(); - var version = (VerUtil.VersionStruct)Marshal.PtrToStructure(pVersion, typeof(VerUtil.VersionStruct)); - this.Version = Marshal.PtrToStringUni(version.sczVersion); - this.Major = version.dwMajor; - this.Minor = version.dwMinor; - this.Patch = version.dwPatch; - this.Revision = version.dwRevision; - this.ReleaseLabels = new VerUtilVersionReleaseLabel[version.cReleaseLabels]; - this.Metadata = VerUtil.VersionStringFromOffset(version.sczVersion, version.cchMetadataOffset); - this.IsInvalid = version.fInvalid; - - for (var i = 0; i < version.cReleaseLabels; ++i) - { - var offset = i * Marshal.SizeOf(typeof(VerUtil.VersionReleaseLabelStruct)); - var pReleaseLabel = new IntPtr(version.rgReleaseLabels.ToInt64() + offset); - this.ReleaseLabels[i] = new VerUtilVersionReleaseLabel(pReleaseLabel, version.sczVersion); - } - } - - /// - /// String version, which would have stripped the leading 'v'. - /// - public string Version { get; private set; } - - /// - /// For version A.B.C.D, Major is A. It is 0 if not specified. - /// - public uint Major { get; private set; } - - /// - /// For version A.B.C.D, Minor is B. It is 0 if not specified. - /// - public uint Minor { get; private set; } - - /// - /// For version A.B.C.D, Patch is C. It is 0 if not specified. - /// - public uint Patch { get; private set; } - - /// - /// For version A.B.C.D, Revision is D. It is 0 if not specified. - /// - public uint Revision { get; private set; } - - /// - /// For version X.Y.Z-releaselabels+metadata, ReleaseLabels is the parsed information for releaselabels. - /// - public VerUtilVersionReleaseLabel[] ReleaseLabels { get; private set; } - - /// - /// For version X.Y.Z-releaselabels+metadata, Metadata is the rest of the string after +. - /// For invalid versions, it is all of the string after the point where it was an invalid string. - /// - public string Metadata { get; private set; } - - /// - /// Whether the version conformed to the spec. - /// - public bool IsInvalid { get; private set; } - - /// - public void Dispose() - { - if (this.Handle != null) - { - this.Handle.Dispose(); - this.Handle = null; - } - } - - private VerUtil.VersionHandle Handle { get; set; } - - internal VerUtil.VersionHandle GetHandle() - { - if (this.Handle == null) - { - throw new ObjectDisposedException(this.Version); - } - - return this.Handle; - } - } -} diff --git a/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs b/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs deleted file mode 100644 index 97e8190d..00000000 --- a/src/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs +++ /dev/null @@ -1,36 +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 WixToolset.Mba.Core -{ - using System; - using System.Runtime.InteropServices; - - /// - /// A release label from a . - /// - public sealed class VerUtilVersionReleaseLabel - { - internal VerUtilVersionReleaseLabel(IntPtr pReleaseLabel, IntPtr wzVersion) - { - var releaseLabel = (VerUtil.VersionReleaseLabelStruct)Marshal.PtrToStructure(pReleaseLabel, typeof(VerUtil.VersionReleaseLabelStruct)); - this.IsNumeric = releaseLabel.fNumeric; - this.Value = releaseLabel.dwValue; - this.Label = VerUtil.VersionStringFromOffset(wzVersion, releaseLabel.cchLabelOffset, releaseLabel.cchLabel); - } - - /// - /// Whether the label was parsed as a number. - /// - public bool IsNumeric { get; private set; } - - /// - /// If then the value that was parsed. - /// - public uint Value { get; private set; } - - /// - /// The string version of the label. - /// - public string Label { get; private set; } - } -} diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj deleted file mode 100644 index 2bd7ca80..00000000 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - netstandard2.0;net20 - WixToolset.Mba.Core - WixToolset.Mba.Core - embedded - Managed Bootstrapper Application Core - $(MSBuildThisFileName).nuspec - true - true - - - - - - - - - $(OutputPath) - $(MSBuildProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt - $(NCrunchOriginalProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt - - - - - - - - - - - - - - PreserveNewest - %(Filename)%(Extension) - - - - - - - - - - - - - - - - - - - - diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec deleted file mode 100644 index a5e09ea9..00000000 --- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec +++ /dev/null @@ -1,33 +0,0 @@ - - - - $id$ - $version$ - $authors$ - $authors$ - MS-RL - https://github.com/wixtoolset/balutil - false - $description$ - $copyright$ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/api/burn/CustomizedNativeRecommendedRules.ruleset b/src/api/burn/CustomizedNativeRecommendedRules.ruleset new file mode 100644 index 00000000..142b141c --- /dev/null +++ b/src/api/burn/CustomizedNativeRecommendedRules.ruleset @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/api/burn/Directory.Build.props b/src/api/burn/Directory.Build.props new file mode 100644 index 00000000..fb34d54e --- /dev/null +++ b/src/api/burn/Directory.Build.props @@ -0,0 +1,26 @@ + + + + + + Debug + false + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + diff --git a/src/api/burn/Directory.Build.targets b/src/api/burn/Directory.Build.targets new file mode 100644 index 00000000..44701fb6 --- /dev/null +++ b/src/api/burn/Directory.Build.targets @@ -0,0 +1,73 @@ + + + + + + $(BaseOutputPath)obj\.tools + $(SigningToolFolder)\SignClient.exe + $(SigningToolFolder)\empty-filelist.txt + $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), signing.json))\signing.json + + + + false + $(OutputPath)\$(AssemblyName).xml + + + + + $(PrivateRepositoryUrl.Replace('.git','')) + + $(MSBuildProjectName).nuspec + $(MSBuildProjectDirectory) + $(NuspecProperties);Id=$(PackageId);Authors="$(Authors)";Configuration=$(Configuration);Copyright="$(Copyright)";Description="$(Description)";Title="$(Title)" + $(NuspecProperties);Version=$(NPMPackageVersion);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl) + true + snupkg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/api/burn/Directory.csproj.props b/src/api/burn/Directory.csproj.props new file mode 100644 index 00000000..81d24ad1 --- /dev/null +++ b/src/api/burn/Directory.csproj.props @@ -0,0 +1,13 @@ + + + + + true + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + false + + diff --git a/src/api/burn/Directory.vcxproj.props b/src/api/burn/Directory.vcxproj.props new file mode 100644 index 00000000..9ea7071b --- /dev/null +++ b/src/api/burn/Directory.vcxproj.props @@ -0,0 +1,115 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + $(Company) + $(Copyright) + + win-x86;win-x64;win-arm64 + native,Version=v0.0 + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + $(MSBuildThisFileDirectory)CustomizedNativeRecommendedRules.ruleset + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/api/burn/NativeMultiTargeting.Build.props b/src/api/burn/NativeMultiTargeting.Build.props new file mode 100644 index 00000000..1ff46559 --- /dev/null +++ b/src/api/burn/NativeMultiTargeting.Build.props @@ -0,0 +1,10 @@ + + + + + + + $(BaseIntermediateOutputPath)$(Configuration)\$(PlatformToolset)\$(PlatformTarget)\ + $(OutputPath)$(PlatformToolset)\$(PlatformTarget)\ + + diff --git a/src/api/burn/README.md b/src/api/burn/README.md new file mode 100644 index 00000000..380bbda3 --- /dev/null +++ b/src/api/burn/README.md @@ -0,0 +1,2 @@ +# balutil +balutil.lib - WiX Toolset Bootstrapper Application Layer native utility library diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec b/src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec new file mode 100644 index 00000000..b10b75d2 --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.nuspec @@ -0,0 +1,19 @@ + + + + $id$ + $version$ + WiX Toolset Team + WiX Toolset Team + MS-RL + https://github.com/wixtoolset/BootstrapperCore + false + $description$ + $copyright$ + + + + + + + diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj b/src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj new file mode 100644 index 00000000..0899bdcf --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/WixToolset.BootstrapperCore.Native.proj @@ -0,0 +1,19 @@ + + + + + + + WixToolset.BootstrapperCore.Native + WiX Bootstrapper native interfaces + + + + + + + + + + + diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props b/src/api/burn/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props new file mode 100644 index 00000000..82f81163 --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/build/WixToolset.BootstrapperCore.Native.props @@ -0,0 +1,13 @@ + + + + + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h new file mode 100644 index 00000000..2a6d5c8a --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h @@ -0,0 +1,1318 @@ +#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_RESTART +{ + BOOTSTRAPPER_RESTART_UNKNOWN, + BOOTSTRAPPER_RESTART_NEVER, + BOOTSTRAPPER_RESTART_PROMPT, + BOOTSTRAPPER_RESTART_AUTOMATIC, + BOOTSTRAPPER_RESTART_ALWAYS, +}; + +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_PENDING, // reboot has not taken place yet + 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_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, + BOOTSTRAPPER_RELATION_UPDATE, +}; + +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_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_ONSYSTEMSHUTDOWN, + 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, +}; + +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_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_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; + BOOTSTRAPPER_RESTART restart; + + 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_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; +}; + +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_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; +}; + +struct BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS +{ + DWORD cbSize; +}; + +struct BA_ONDETECTBEGIN_ARGS +{ + DWORD cbSize; + BOOL fInstalled; + DWORD cPackages; + BOOL fCached; +}; + +struct BA_ONDETECTBEGIN_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; + BOOTSTRAPPER_RELATED_OPERATION operation; + BOOL fMissingFromCache; +}; + +struct BA_ONDETECTRELATEDBUNDLE_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 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; +}; + +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_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_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; +}; + +struct BA_ONPLANMSIPACKAGE_RESULTS +{ + DWORD cbSize; + BOOL fCancel; + BURN_MSI_PROPERTY actionMsiProperty; + INSTALLUILEVEL uiLevel; + BOOL fDisableExternalUiHandler; +}; + +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; +}; + +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_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; +}; + +struct BA_ONREGISTERBEGIN_RESULTS +{ + DWORD cbSize; + BOOL fCancel; +}; + +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; +}; + +struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_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_ONSYSTEMSHUTDOWN_ARGS +{ + DWORD cbSize; + DWORD dwEndSession; +}; + +struct BA_ONSYSTEMSHUTDOWN_RESULTS +{ + DWORD cbSize; + BOOL fCancel; +}; + +struct BA_ONUNREGISTERBEGIN_ARGS +{ + DWORD cbSize; + BOOL fKeepRegistration; +}; + +struct BA_ONUNREGISTERBEGIN_RESULTS +{ + DWORD cbSize; + BOOL fForceKeepRegistration; +}; + +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 + ); + +extern "C" typedef void (WINAPI *PFN_BOOTSTRAPPER_APPLICATION_DESTROY)(); + + + +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; + BOOL fDisableUnloading; // indicates the BA dll must not be unloaded after BootstrapperApplicationDestroy. +}; + +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 new file mode 100644 index 00000000..9c9b38a5 --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h @@ -0,0 +1,442 @@ +#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); + +// Note that ordering of the enumeration values is important. +// Some code paths use < or > comparisions and simply reording values will break those comparisons. +enum BOOTSTRAPPER_ACTION +{ + BOOTSTRAPPER_ACTION_UNKNOWN, + BOOTSTRAPPER_ACTION_HELP, + BOOTSTRAPPER_ACTION_LAYOUT, + 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_MEND, + 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_MEND, + 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, +}; + +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; + BYTE* rgbHash; + DWORD cbHash; +} 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; + + +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/BundleExtension.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h new file mode 100644 index 00000000..be76a1a5 --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h @@ -0,0 +1,60 @@ +#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 + +enum BUNDLE_EXTENSION_MESSAGE +{ + BUNDLE_EXTENSION_MESSAGE_SEARCH, +}; + +typedef struct _BUNDLE_EXTENSION_SEARCH_ARGS +{ + DWORD cbSize; + LPCWSTR wzId; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_SEARCH_ARGS; + +typedef struct _BUNDLE_EXTENSION_SEARCH_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_SEARCH_RESULTS; + +extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_PROC)( + __in BUNDLE_EXTENSION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + +typedef struct _BUNDLE_EXTENSION_CREATE_ARGS +{ + DWORD cbSize; + DWORD64 qwEngineAPIVersion; + PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc; + LPVOID pvBundleExtensionEngineProcContext; + LPCWSTR wzBootstrapperWorkingFolder; + LPCWSTR wzBundleExtensionDataPath; + LPCWSTR wzExtensionId; +} BUNDLE_EXTENSION_CREATE_ARGS; + +typedef struct _BUNDLE_EXTENSION_CREATE_RESULTS +{ + DWORD cbSize; + PFN_BUNDLE_EXTENSION_PROC pfnBundleExtensionProc; + LPVOID pvBundleExtensionProcContext; +} BUNDLE_EXTENSION_CREATE_RESULTS; + +extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_CREATE)( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults + ); + +extern "C" typedef void (WINAPI *PFN_BUNDLE_EXTENSION_DESTROY)(); + +#if defined(__cplusplus) +} +#endif diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h new file mode 100644 index 00000000..b397ec16 --- /dev/null +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h @@ -0,0 +1,184 @@ +#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 + +enum BUNDLE_EXTENSION_LOG_LEVEL +{ + BUNDLE_EXTENSION_LOG_LEVEL_NONE, // turns off report (only valid for XXXSetLevel()) + BUNDLE_EXTENSION_LOG_LEVEL_STANDARD, // written if reporting is on + BUNDLE_EXTENSION_LOG_LEVEL_VERBOSE, // written only if verbose reporting is on + BUNDLE_EXTENSION_LOG_LEVEL_DEBUG, // reporting useful when debugging code + BUNDLE_EXTENSION_LOG_LEVEL_ERROR, // always gets reported, but can never be specified +}; + +enum BUNDLE_EXTENSION_ENGINE_MESSAGE +{ + BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, + BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, + BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, + BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, + BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, +}; + +typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS +{ + DWORD cbSize; + LPCWSTR wzVersion1; + LPCWSTR wzVersion2; +} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS +{ + DWORD cbSize; + int nResult; +} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzIn; +} BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS +{ + DWORD cbSize; + LPWSTR wzOut; + // Should be initialized to the size of wzOut. + SIZE_T cchOut; +} BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS +{ + DWORD cbSize; + LPCWSTR wzCondition; +} BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS +{ + DWORD cbSize; + BOOL f; +} BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzIn; +} BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS +{ + DWORD cbSize; + LPWSTR wzOut; + // Should be initialized to the size of wzOut. + SIZE_T cchOut; +} BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS +{ + DWORD cbSize; + LONGLONG llValue; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS +{ + DWORD cbSize; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + SIZE_T cchValue; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS +{ + DWORD cbSize; + LPWSTR wzValue; + // Should be initialized to the size of wzValue. + SIZE_T cchValue; +} BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_LOG_ARGS +{ + DWORD cbSize; + BUNDLE_EXTENSION_LOG_LEVEL level; + LPCWSTR wzMessage; +} BUNDLE_EXTENSION_ENGINE_LOG_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_LOG_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_LOG_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; + LONGLONG llValue; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; + LPCWSTR wzValue; + BOOL fFormatted; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS +{ + DWORD cbSize; + LPCWSTR wzVariable; + LPCWSTR wzValue; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS +{ + DWORD cbSize; +} BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS; + +extern "C" typedef HRESULT(WINAPI *PFN_BUNDLE_EXTENSION_ENGINE_PROC)( + __in BUNDLE_EXTENSION_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.Mba.Core/BalUtil.cs b/src/api/burn/WixToolset.Mba.Core/BalUtil.cs new file mode 100644 index 00000000..f478eca4 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BalUtil.cs @@ -0,0 +1,22 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + internal static class BalUtil + { + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern IBootstrapperEngine InitializeFromCreateArgs( + IntPtr pArgs, + ref Command pCommand + ); + + [DllImport("mbanative.dll", ExactSpelling = true)] + internal static extern void StoreBAInCreateResults( + IntPtr pResults, + [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA + ); + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs new file mode 100644 index 00000000..ad8a5dc0 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs @@ -0,0 +1,63 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Default implementation of . + /// + public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory + { + /// + /// Default implementation of + /// + /// + /// + public void Create(IntPtr pArgs, IntPtr pResults) + { + InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand); + + var ba = this.Create(engine, bootstrapperCommand); + StoreBAInCreateResults(pResults, ba); + } + + /// + /// Called by to get the . + /// + /// The bundle engine. + /// Command information passed from the engine for the BA to perform. + /// The for the bundle. + protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); + + /// + /// Initializes the native part of . + /// Most users should inherit from instead of calling this method. + /// + /// 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. + public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand) + { + Command pCommand = new Command + { + cbSize = Marshal.SizeOf(typeof(Command)) + }; + var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand); + engine = new Engine(pEngine); + bootstrapperCommand = pCommand.GetBootstrapperCommand(); + } + + /// + /// 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. + /// + /// The results struct given by the engine when initially creating the BA + /// The . + public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba) + { + BalUtil.StoreBAInCreateResults(pResults, ba); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs new file mode 100644 index 00000000..072d3ef0 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -0,0 +1,1873 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + using System.Threading; + + /// + /// The default bootstrapper application. + /// + [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; + + private bool applying; + + /// + /// Creates a new instance of the class. + /// + protected BootstrapperApplication(IEngine engine) + { + this.engine = engine; + this.applying = false; + this.asyncExecution = true; + } + + /// + public event EventHandler Startup; + + /// + public event EventHandler Shutdown; + + /// + public event EventHandler SystemShutdown; + + /// + public event EventHandler DetectBegin; + + /// + public event EventHandler DetectForwardCompatibleBundle; + + /// + public event EventHandler DetectUpdateBegin; + + /// + public event EventHandler DetectUpdate; + + /// + public event EventHandler DetectUpdateComplete; + + /// + public event EventHandler DetectRelatedBundle; + + /// + public event EventHandler DetectPackageBegin; + + /// + public event EventHandler DetectRelatedMsiPackage; + + /// + public event EventHandler DetectPatchTarget; + + /// + public event EventHandler DetectMsiFeature; + + /// + public event EventHandler DetectPackageComplete; + + /// + public event EventHandler DetectComplete; + + /// + public event EventHandler PlanBegin; + + /// + public event EventHandler PlanRelatedBundle; + + /// + public event EventHandler PlanPackageBegin; + + /// + public event EventHandler PlanPatchTarget; + + /// + public event EventHandler PlanMsiFeature; + + /// + public event EventHandler PlanMsiPackage; + + /// + public event EventHandler PlanPackageComplete; + + /// + public event EventHandler PlannedPackage; + + /// + public event EventHandler PlanComplete; + + /// + public event EventHandler ApplyBegin; + + /// + public event EventHandler ElevateBegin; + + /// + public event EventHandler ElevateComplete; + + /// + public event EventHandler Progress; + + /// + public event EventHandler Error; + + /// + public event EventHandler RegisterBegin; + + /// + public event EventHandler RegisterComplete; + + /// + public event EventHandler UnregisterBegin; + + /// + public event EventHandler UnregisterComplete; + + /// + public event EventHandler CacheBegin; + + /// + public event EventHandler CachePackageBegin; + + /// + public event EventHandler CacheAcquireBegin; + + /// + public event EventHandler CacheAcquireProgress; + + /// + public event EventHandler CacheAcquireResolving; + + /// + public event EventHandler CacheAcquireComplete; + + /// + public event EventHandler CacheVerifyBegin; + + /// + public event EventHandler CacheVerifyProgress; + + /// + public event EventHandler CacheVerifyComplete; + + /// + public event EventHandler CachePackageComplete; + + /// + public event EventHandler CacheComplete; + + /// + public event EventHandler ExecuteBegin; + + /// + public event EventHandler ExecutePackageBegin; + + /// + public event EventHandler ExecutePatchTarget; + + /// + public event EventHandler ExecuteMsiMessage; + + /// + public event EventHandler ExecuteFilesInUse; + + /// + public event EventHandler ExecutePackageComplete; + + /// + public event EventHandler ExecuteComplete; + + /// + public event EventHandler ApplyComplete; + + /// + public event EventHandler ExecuteProgress; + + /// + public event EventHandler LaunchApprovedExeBegin; + + /// + public event EventHandler LaunchApprovedExeComplete; + + /// + public event EventHandler BeginMsiTransactionBegin; + + /// + public event EventHandler BeginMsiTransactionComplete; + + /// + public event EventHandler CommitMsiTransactionBegin; + + /// + public event EventHandler CommitMsiTransactionComplete; + + /// + public event EventHandler RollbackMsiTransactionBegin; + + /// + public event EventHandler RollbackMsiTransactionComplete; + + /// + public event EventHandler PauseAutomaticUpdatesBegin; + + /// + public event EventHandler PauseAutomaticUpdatesComplete; + + /// + public event EventHandler SystemRestorePointBegin; + + /// + public event EventHandler SystemRestorePointComplete; + + /// + public event EventHandler PlanForwardCompatibleBundle; + + /// + public event EventHandler CacheContainerOrPayloadVerifyBegin; + + /// + public event EventHandler CacheContainerOrPayloadVerifyProgress; + + /// + public event EventHandler CacheContainerOrPayloadVerifyComplete; + + /// + public event EventHandler CachePayloadExtractBegin; + + /// + public event EventHandler CachePayloadExtractProgress; + + /// + public event EventHandler CachePayloadExtractComplete; + + /// + /// Entry point that is called when the bootstrapper application is ready to run. + /// + protected abstract void Run(); + + /// + /// 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) + { + handler(this, args); + } + + if (this.asyncExecution) + { + 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(); + } + else + { + this.engine.Log(LogLevel.Verbose, "Creating BA thread to run synchronously."); + this.Run(); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnShutdown(ShutdownEventArgs args) + { + EventHandler handler = this.Shutdown; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnSystemShutdown(SystemShutdownEventArgs args) + { + EventHandler handler = this.SystemShutdown; + if (null != handler) + { + handler(this, args); + } + else if (null != args) + { + // Allow requests to shut down when critical or not applying. + bool critical = EndSessionReasons.Critical == (EndSessionReasons.Critical & args.Reasons); + args.Cancel = !critical && this.applying; + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectBegin(DetectBeginEventArgs args) + { + EventHandler handler = this.DetectBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectForwardCompatibleBundle(DetectForwardCompatibleBundleEventArgs args) + { + EventHandler handler = this.DetectForwardCompatibleBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) + { + EventHandler handler = this.DetectUpdateBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectUpdate(DetectUpdateEventArgs args) + { + EventHandler handler = this.DetectUpdate; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectUpdateComplete(DetectUpdateCompleteEventArgs args) + { + EventHandler handler = this.DetectUpdateComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectRelatedBundle(DetectRelatedBundleEventArgs args) + { + EventHandler handler = this.DetectRelatedBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectPackageBegin(DetectPackageBeginEventArgs args) + { + EventHandler handler = this.DetectPackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectRelatedMsiPackage(DetectRelatedMsiPackageEventArgs args) + { + EventHandler handler = this.DetectRelatedMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectPatchTarget(DetectPatchTargetEventArgs args) + { + EventHandler handler = this.DetectPatchTarget; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectMsiFeature(DetectMsiFeatureEventArgs args) + { + EventHandler handler = this.DetectMsiFeature; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectPackageComplete(DetectPackageCompleteEventArgs args) + { + EventHandler handler = this.DetectPackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnDetectComplete(DetectCompleteEventArgs args) + { + EventHandler handler = this.DetectComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanBegin(PlanBeginEventArgs args) + { + EventHandler handler = this.PlanBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanRelatedBundle(PlanRelatedBundleEventArgs args) + { + EventHandler handler = this.PlanRelatedBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanPackageBegin(PlanPackageBeginEventArgs args) + { + EventHandler handler = this.PlanPackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanPatchTarget(PlanPatchTargetEventArgs args) + { + EventHandler handler = this.PlanPatchTarget; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanMsiFeature(PlanMsiFeatureEventArgs args) + { + EventHandler handler = this.PlanMsiFeature; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanMsiPackage(PlanMsiPackageEventArgs args) + { + EventHandler handler = this.PlanMsiPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanPackageComplete(PlanPackageCompleteEventArgs args) + { + EventHandler handler = this.PlanPackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlannedPackage(PlannedPackageEventArgs args) + { + EventHandler handler = this.PlannedPackage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanComplete(PlanCompleteEventArgs args) + { + EventHandler handler = this.PlanComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnApplyBegin(ApplyBeginEventArgs args) + { + EventHandler handler = this.ApplyBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnElevateBegin(ElevateBeginEventArgs args) + { + EventHandler handler = this.ElevateBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnElevateComplete(ElevateCompleteEventArgs args) + { + EventHandler handler = this.ElevateComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnProgress(ProgressEventArgs args) + { + EventHandler handler = this.Progress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnError(ErrorEventArgs args) + { + EventHandler handler = this.Error; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnRegisterBegin(RegisterBeginEventArgs args) + { + EventHandler handler = this.RegisterBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnRegisterComplete(RegisterCompleteEventArgs args) + { + EventHandler handler = this.RegisterComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnUnregisterBegin(UnregisterBeginEventArgs args) + { + EventHandler handler = this.UnregisterBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnUnregisterComplete(UnregisterCompleteEventArgs args) + { + EventHandler handler = this.UnregisterComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheBegin(CacheBeginEventArgs args) + { + EventHandler handler = this.CacheBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePackageBegin(CachePackageBeginEventArgs args) + { + EventHandler handler = this.CachePackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheAcquireBegin(CacheAcquireBeginEventArgs args) + { + EventHandler handler = this.CacheAcquireBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args) + { + EventHandler handler = this.CacheAcquireProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnCacheAcquireResolving(CacheAcquireResolvingEventArgs args) + { + EventHandler handler = this.CacheAcquireResolving; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheAcquireComplete(CacheAcquireCompleteEventArgs args) + { + EventHandler handler = this.CacheAcquireComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheVerifyBegin(CacheVerifyBeginEventArgs args) + { + EventHandler handler = this.CacheVerifyBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheVerifyProgress(CacheVerifyProgressEventArgs args) + { + EventHandler handler = this.CacheVerifyProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheVerifyComplete(CacheVerifyCompleteEventArgs args) + { + EventHandler handler = this.CacheVerifyComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePackageComplete(CachePackageCompleteEventArgs args) + { + EventHandler handler = this.CachePackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnCacheComplete(CacheCompleteEventArgs args) + { + EventHandler handler = this.CacheComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteBegin(ExecuteBeginEventArgs args) + { + EventHandler handler = this.ExecuteBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecutePackageBegin(ExecutePackageBeginEventArgs args) + { + EventHandler handler = this.ExecutePackageBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecutePatchTarget(ExecutePatchTargetEventArgs args) + { + EventHandler handler = this.ExecutePatchTarget; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteMsiMessage(ExecuteMsiMessageEventArgs args) + { + EventHandler handler = this.ExecuteMsiMessage; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) + { + EventHandler handler = this.ExecuteFilesInUse; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecutePackageComplete(ExecutePackageCompleteEventArgs args) + { + EventHandler handler = this.ExecutePackageComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteComplete(ExecuteCompleteEventArgs args) + { + EventHandler handler = this.ExecuteComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnApplyComplete(ApplyCompleteEventArgs args) + { + EventHandler handler = this.ApplyComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnExecuteProgress(ExecuteProgressEventArgs args) + { + EventHandler handler = this.ExecuteProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnLaunchApprovedExeBegin(LaunchApprovedExeBeginEventArgs args) + { + EventHandler handler = this.LaunchApprovedExeBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnLaunchApprovedExeComplete(LaunchApprovedExeCompleteEventArgs args) + { + EventHandler handler = this.LaunchApprovedExeComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnBeginMsiTransactionBegin(BeginMsiTransactionBeginEventArgs args) + { + EventHandler handler = this.BeginMsiTransactionBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnBeginMsiTransactionComplete(BeginMsiTransactionCompleteEventArgs args) + { + EventHandler handler = this.BeginMsiTransactionComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnCommitMsiTransactionBegin(CommitMsiTransactionBeginEventArgs args) + { + EventHandler handler = this.CommitMsiTransactionBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnCommitMsiTransactionComplete(CommitMsiTransactionCompleteEventArgs args) + { + EventHandler handler = this.CommitMsiTransactionComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnRollbackMsiTransactionBegin(RollbackMsiTransactionBeginEventArgs args) + { + EventHandler handler = this.RollbackMsiTransactionBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnRollbackMsiTransactionComplete(RollbackMsiTransactionCompleteEventArgs args) + { + EventHandler handler = this.RollbackMsiTransactionComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPauseAutomaticUpdatesBegin(PauseAutomaticUpdatesBeginEventArgs args) + { + EventHandler handler = this.PauseAutomaticUpdatesBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPauseAutomaticUpdatesComplete(PauseAutomaticUpdatesCompleteEventArgs args) + { + EventHandler handler = this.PauseAutomaticUpdatesComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnSystemRestorePointBegin(SystemRestorePointBeginEventArgs args) + { + EventHandler handler = this.SystemRestorePointBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnSystemRestorePointComplete(SystemRestorePointCompleteEventArgs args) + { + EventHandler handler = this.SystemRestorePointComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + protected virtual void OnPlanForwardCompatibleBundle(PlanForwardCompatibleBundleEventArgs args) + { + EventHandler handler = this.PlanForwardCompatibleBundle; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheContainerOrPayloadVerifyBegin(CacheContainerOrPayloadVerifyBeginEventArgs args) + { + EventHandler handler = this.CacheContainerOrPayloadVerifyBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheContainerOrPayloadVerifyProgress(CacheContainerOrPayloadVerifyProgressEventArgs args) + { + EventHandler handler = this.CacheContainerOrPayloadVerifyProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCacheContainerOrPayloadVerifyComplete(CacheContainerOrPayloadVerifyCompleteEventArgs args) + { + EventHandler handler = this.CacheContainerOrPayloadVerifyComplete; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePayloadExtractBegin(CachePayloadExtractBeginEventArgs args) + { + EventHandler handler = this.CachePayloadExtractBegin; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePayloadExtractProgress(CachePayloadExtractProgressEventArgs args) + { + EventHandler handler = this.CachePayloadExtractProgress; + if (null != handler) + { + handler(this, args); + } + } + + /// + /// Called by the engine, raises the event. + /// + /// + protected virtual void OnCachePayloadExtractComplete(CachePayloadExtractCompleteEventArgs args) + { + EventHandler handler = this.CachePayloadExtractComplete; + if (null != handler) + { + handler(this, args); + } + } + + #region IBootstrapperApplication Members + + int IBootstrapperApplication.BAProc(int message, IntPtr pvArgs, IntPtr pvResults, IntPtr pvContext) + { + switch (message) + { + default: + return NativeMethods.E_NOTIMPL; + } + } + + void IBootstrapperApplication.BAProcFallback(int message, IntPtr pvArgs, IntPtr pvResults, ref int phr, IntPtr pvContext) + { + } + + int IBootstrapperApplication.OnStartup() + { + StartupEventArgs args = new StartupEventArgs(); + this.OnStartup(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action) + { + ShutdownEventArgs args = new ShutdownEventArgs(action); + this.OnShutdown(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnSystemShutdown(EndSessionReasons dwEndSession, ref bool fCancel) + { + SystemShutdownEventArgs args = new SystemShutdownEventArgs(dwEndSession, fCancel); + this.OnSystemShutdown(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectBegin(bool fCached, bool fInstalled, int cPackages, ref bool fCancel) + { + DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, fInstalled, cPackages, fCancel); + this.OnDetectBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fMissingFromCache, ref bool fCancel) + { + DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, fCancel); + this.OnDetectForwardCompatibleBundle(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectUpdateBegin(string wzUpdateLocation, ref bool fCancel, ref bool fSkip) + { + DetectUpdateBeginEventArgs args = new DetectUpdateBeginEventArgs(wzUpdateLocation, fCancel, fSkip); + this.OnDetectUpdateBegin(args); + + fCancel = args.Cancel; + fSkip = args.Skip; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, string wzVersion, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) + { + DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, wzVersion, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); + this.OnDetectUpdate(args); + + fCancel = args.Cancel; + fStopProcessingUpdates = args.StopProcessingUpdates; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectUpdateComplete(int hrStatus, ref bool fIgnoreError) + { + DetectUpdateCompleteEventArgs args = new DetectUpdateCompleteEventArgs(hrStatus, fIgnoreError); + this.OnDetectUpdateComplete(args); + + fIgnoreError = args.IgnoreError; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, bool fMissingFromCache, ref bool fCancel) + { + DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fMissingFromCache, fCancel); + this.OnDetectRelatedBundle(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectPackageBegin(string wzPackageId, ref bool fCancel) + { + DetectPackageBeginEventArgs args = new DetectPackageBeginEventArgs(wzPackageId, fCancel); + this.OnDetectPackageBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) + { + DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, wzVersion, operation, fCancel); + this.OnDetectRelatedMsiPackage(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectPatchTarget(string wzPackageId, string wzProductCode, PackageState patchState, ref bool fCancel) + { + DetectPatchTargetEventArgs args = new DetectPatchTargetEventArgs(wzPackageId, wzProductCode, patchState, fCancel); + this.OnDetectPatchTarget(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectMsiFeature(string wzPackageId, string wzFeatureId, FeatureState state, ref bool fCancel) + { + DetectMsiFeatureEventArgs args = new DetectMsiFeatureEventArgs(wzPackageId, wzFeatureId, state, fCancel); + this.OnDetectMsiFeature(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnDetectPackageComplete(string wzPackageId, int hrStatus, PackageState state, bool fCached) + { + DetectPackageCompleteEventArgs args = new DetectPackageCompleteEventArgs(wzPackageId, hrStatus, state, fCached); + this.OnDetectPackageComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnDetectComplete(int hrStatus, bool fEligibleForCleanup) + { + DetectCompleteEventArgs args = new DetectCompleteEventArgs(hrStatus, fEligibleForCleanup); + this.OnDetectComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlanBegin(int cPackages, ref bool fCancel) + { + PlanBeginEventArgs args = new PlanBeginEventArgs(cPackages, fCancel); + this.OnPlanBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + { + PlanRelatedBundleEventArgs args = new PlanRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel); + this.OnPlanRelatedBundle(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanPackageBegin(string wzPackageId, PackageState state, bool fCached, BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, RequestState recommendedState, BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, ref RequestState pRequestedState, ref BOOTSTRAPPER_CACHE_TYPE pRequestedCacheType, ref bool fCancel) + { + PlanPackageBeginEventArgs args = new PlanPackageBeginEventArgs(wzPackageId, state, fCached, installCondition, recommendedState, recommendedCacheType, pRequestedState, pRequestedCacheType, fCancel); + this.OnPlanPackageBegin(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanPatchTarget(string wzPackageId, string wzProductCode, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + { + PlanPatchTargetEventArgs args = new PlanPatchTargetEventArgs(wzPackageId, wzProductCode, recommendedState, pRequestedState, fCancel); + this.OnPlanPatchTarget(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanMsiFeature(string wzPackageId, string wzFeatureId, FeatureState recommendedState, ref FeatureState pRequestedState, ref bool fCancel) + { + PlanMsiFeatureEventArgs args = new PlanMsiFeatureEventArgs(wzPackageId, wzFeatureId, recommendedState, pRequestedState, fCancel); + this.OnPlanMsiFeature(args); + + pRequestedState = args.State; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanMsiPackage(string wzPackageId, bool fExecute, ActionState action, ref bool fCancel, ref BURN_MSI_PROPERTY actionMsiProperty, ref INSTALLUILEVEL uiLevel, ref bool fDisableExternalUiHandler) + { + PlanMsiPackageEventArgs args = new PlanMsiPackageEventArgs(wzPackageId, fExecute, action, fCancel, actionMsiProperty, uiLevel, fDisableExternalUiHandler); + this.OnPlanMsiPackage(args); + + fCancel = args.Cancel; + actionMsiProperty = args.ActionMsiProperty; + uiLevel = args.UiLevel; + fDisableExternalUiHandler = args.DisableExternalUiHandler; + return args.HResult; + } + + int IBootstrapperApplication.OnPlanPackageComplete(string wzPackageId, int hrStatus, RequestState requested) + { + var args = new PlanPackageCompleteEventArgs(wzPackageId, hrStatus, requested); + this.OnPlanPackageComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlannedPackage(string wzPackageId, ActionState execute, ActionState rollback, bool fPlannedCache, bool fPlannedUncache) + { + var args = new PlannedPackageEventArgs(wzPackageId, execute, rollback, fPlannedCache, fPlannedUncache); + this.OnPlannedPackage(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlanComplete(int hrStatus) + { + PlanCompleteEventArgs args = new PlanCompleteEventArgs(hrStatus); + this.OnPlanComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnApplyBegin(int dwPhaseCount, ref bool fCancel) + { + this.applying = true; + + ApplyBeginEventArgs args = new ApplyBeginEventArgs(dwPhaseCount, fCancel); + this.OnApplyBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnElevateBegin(ref bool fCancel) + { + ElevateBeginEventArgs args = new ElevateBeginEventArgs(fCancel); + this.OnElevateBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnElevateComplete(int hrStatus) + { + ElevateCompleteEventArgs args = new ElevateCompleteEventArgs(hrStatus); + this.OnElevateComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnProgress(int dwProgressPercentage, int dwOverallPercentage, ref bool fCancel) + { + ProgressEventArgs args = new ProgressEventArgs(dwProgressPercentage, dwOverallPercentage, fCancel); + this.OnProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnError(ErrorType errorType, string wzPackageId, int dwCode, string wzError, int dwUIHint, int cData, string[] rgwzData, Result nRecommendation, ref Result pResult) + { + ErrorEventArgs args = new ErrorEventArgs(errorType, wzPackageId, dwCode, wzError, dwUIHint, rgwzData, nRecommendation, pResult); + this.OnError(args); + + pResult = args.Result; + return args.HResult; + } + + int IBootstrapperApplication.OnRegisterBegin(ref bool fCancel) + { + RegisterBeginEventArgs args = new RegisterBeginEventArgs(fCancel); + this.OnRegisterBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnRegisterComplete(int hrStatus) + { + RegisterCompleteEventArgs args = new RegisterCompleteEventArgs(hrStatus); + this.OnRegisterComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnCacheBegin(ref bool fCancel) + { + CacheBeginEventArgs args = new CacheBeginEventArgs(fCancel); + this.OnCacheBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePackageBegin(string wzPackageId, int cCachePayloads, long dw64PackageCacheSize, ref bool fCancel) + { + CachePackageBeginEventArgs args = new CachePackageBeginEventArgs(wzPackageId, cCachePayloads, dw64PackageCacheSize, fCancel); + this.OnCachePackageBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, string wzSource, string wzDownloadUrl, string wzPayloadContainerId, CacheOperation recommendation, ref CacheOperation action, ref bool fCancel) + { + CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, wzSource, wzDownloadUrl, wzPayloadContainerId, recommendation, action, fCancel); + this.OnCacheAcquireBegin(args); + + action = args.Action; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) + { + CacheAcquireProgressEventArgs args = new CacheAcquireProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); + this.OnCacheAcquireProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireResolving(string wzPackageOrContainerId, string wzPayloadId, string[] searchPaths, int cSearchPaths, bool fFoundLocal, int dwRecommendedSearchPath, string wzDownloadUrl, string wzPayloadContainerId, CacheResolveOperation recommendation, ref int dwChosenSearchPath, ref CacheResolveOperation action, ref bool fCancel) + { + CacheAcquireResolvingEventArgs args = new CacheAcquireResolvingEventArgs(wzPackageOrContainerId, wzPayloadId, searchPaths, fFoundLocal, dwRecommendedSearchPath, wzDownloadUrl, wzPayloadContainerId, recommendation, dwChosenSearchPath, action, fCancel); + this.OnCacheAcquireResolving(args); + + dwChosenSearchPath = args.ChosenSearchPath; + action = args.Action; + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheAcquireComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) + { + CacheAcquireCompleteEventArgs args = new CacheAcquireCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, action); + this.OnCacheAcquireComplete(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheVerifyBegin(string wzPackageOrContainerId, string wzPayloadId, ref bool fCancel) + { + CacheVerifyBeginEventArgs args = new CacheVerifyBeginEventArgs(wzPackageOrContainerId, wzPayloadId, fCancel); + this.OnCacheVerifyBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheVerifyProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, CacheVerifyStep verifyStep, ref bool fCancel) + { + CacheVerifyProgressEventArgs args = new CacheVerifyProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, verifyStep, fCancel); + this.OnCacheVerifyProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheVerifyComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) + { + CacheVerifyCompleteEventArgs args = new CacheVerifyCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, action); + this.OnCacheVerifyComplete(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePackageComplete(string wzPackageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) + { + CachePackageCompleteEventArgs args = new CachePackageCompleteEventArgs(wzPackageId, hrStatus, recommendation, action); + this.OnCachePackageComplete(args); + + action = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheComplete(int hrStatus) + { + CacheCompleteEventArgs args = new CacheCompleteEventArgs(hrStatus); + this.OnCacheComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteBegin(int cExecutingPackages, ref bool fCancel) + { + ExecuteBeginEventArgs args = new ExecuteBeginEventArgs(cExecutingPackages, fCancel); + this.OnExecuteBegin(args); + + args.Cancel = fCancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecutePackageBegin(string wzPackageId, bool fExecute, ActionState action, INSTALLUILEVEL uiLevel, bool fDisableExternalUiHandler, ref bool fCancel) + { + ExecutePackageBeginEventArgs args = new ExecutePackageBeginEventArgs(wzPackageId, fExecute, action, uiLevel, fDisableExternalUiHandler, fCancel); + this.OnExecutePackageBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecutePatchTarget(string wzPackageId, string wzTargetProductCode, ref bool fCancel) + { + ExecutePatchTargetEventArgs args = new ExecutePatchTargetEventArgs(wzPackageId, wzTargetProductCode, fCancel); + this.OnExecutePatchTarget(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteProgress(string wzPackageId, int dwProgressPercentage, int dwOverallPercentage, ref bool fCancel) + { + ExecuteProgressEventArgs args = new ExecuteProgressEventArgs(wzPackageId, dwProgressPercentage, dwOverallPercentage, fCancel); + this.OnExecuteProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteMsiMessage(string wzPackageId, InstallMessage messageType, int dwUIHint, string wzMessage, int cData, string[] rgwzData, Result nRecommendation, ref Result pResult) + { + ExecuteMsiMessageEventArgs args = new ExecuteMsiMessageEventArgs(wzPackageId, messageType, dwUIHint, wzMessage, rgwzData, nRecommendation, pResult); + this.OnExecuteMsiMessage(args); + + pResult = args.Result; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteFilesInUse(string wzPackageId, int cFiles, string[] rgwzFiles, Result nRecommendation, ref Result pResult) + { + ExecuteFilesInUseEventArgs args = new ExecuteFilesInUseEventArgs(wzPackageId, rgwzFiles, nRecommendation, pResult); + this.OnExecuteFilesInUse(args); + + pResult = args.Result; + return args.HResult; + } + + int IBootstrapperApplication.OnExecutePackageComplete(string wzPackageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction) + { + ExecutePackageCompleteEventArgs args = new ExecutePackageCompleteEventArgs(wzPackageId, hrStatus, restart, recommendation, pAction); + this.OnExecutePackageComplete(args); + + pAction = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnExecuteComplete(int hrStatus) + { + ExecuteCompleteEventArgs args = new ExecuteCompleteEventArgs(hrStatus); + this.OnExecuteComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnUnregisterBegin(bool fKeepRegistration, ref bool fForceKeepRegistration) + { + UnregisterBeginEventArgs args = new UnregisterBeginEventArgs(fKeepRegistration, fForceKeepRegistration); + this.OnUnregisterBegin(args); + + fForceKeepRegistration = args.ForceKeepRegistration; + return args.HResult; + } + + int IBootstrapperApplication.OnUnregisterComplete(int hrStatus) + { + UnregisterCompleteEventArgs args = new UnregisterCompleteEventArgs(hrStatus); + this.OnUnregisterComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnApplyComplete(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction) + { + ApplyCompleteEventArgs args = new ApplyCompleteEventArgs(hrStatus, restart, recommendation, pAction); + this.OnApplyComplete(args); + + this.applying = false; + + pAction = args.Action; + return args.HResult; + } + + int IBootstrapperApplication.OnLaunchApprovedExeBegin(ref bool fCancel) + { + LaunchApprovedExeBeginEventArgs args = new LaunchApprovedExeBeginEventArgs(fCancel); + this.OnLaunchApprovedExeBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnLaunchApprovedExeComplete(int hrStatus, int processId) + { + LaunchApprovedExeCompleteEventArgs args = new LaunchApprovedExeCompleteEventArgs(hrStatus, processId); + this.OnLaunchApprovedExeComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnBeginMsiTransactionBegin(string transactionId, ref bool fCancel) + { + BeginMsiTransactionBeginEventArgs args = new BeginMsiTransactionBeginEventArgs(transactionId, fCancel); + this.OnBeginMsiTransactionBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnBeginMsiTransactionComplete(string transactionId, int hrStatus) + { + BeginMsiTransactionCompleteEventArgs args = new BeginMsiTransactionCompleteEventArgs(transactionId, hrStatus); + this.OnBeginMsiTransactionComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnCommitMsiTransactionBegin(string transactionId, ref bool fCancel) + { + CommitMsiTransactionBeginEventArgs args = new CommitMsiTransactionBeginEventArgs(transactionId, fCancel); + this.OnCommitMsiTransactionBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCommitMsiTransactionComplete(string transactionId, int hrStatus) + { + CommitMsiTransactionCompleteEventArgs args = new CommitMsiTransactionCompleteEventArgs(transactionId, hrStatus); + this.OnCommitMsiTransactionComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnRollbackMsiTransactionBegin(string transactionId) + { + RollbackMsiTransactionBeginEventArgs args = new RollbackMsiTransactionBeginEventArgs(transactionId); + this.OnRollbackMsiTransactionBegin(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnRollbackMsiTransactionComplete(string transactionId, int hrStatus) + { + RollbackMsiTransactionCompleteEventArgs args = new RollbackMsiTransactionCompleteEventArgs(transactionId, hrStatus); + this.OnRollbackMsiTransactionComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPauseAutomaticUpdatesBegin() + { + PauseAutomaticUpdatesBeginEventArgs args = new PauseAutomaticUpdatesBeginEventArgs(); + this.OnPauseAutomaticUpdatesBegin(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPauseAutomaticUpdatesComplete(int hrStatus) + { + PauseAutomaticUpdatesCompleteEventArgs args = new PauseAutomaticUpdatesCompleteEventArgs(hrStatus); + this.OnPauseAutomaticUpdatesComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnSystemRestorePointBegin() + { + SystemRestorePointBeginEventArgs args = new SystemRestorePointBeginEventArgs(); + this.OnSystemRestorePointBegin(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnSystemRestorePointComplete(int hrStatus) + { + SystemRestorePointCompleteEventArgs args = new SystemRestorePointCompleteEventArgs(hrStatus); + this.OnSystemRestorePointComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnPlanForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, bool fRecommendedIgnoreBundle, ref bool fCancel, ref bool fIgnoreBundle) + { + PlanForwardCompatibleBundleEventArgs args = new PlanForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fRecommendedIgnoreBundle, fCancel, fIgnoreBundle); + this.OnPlanForwardCompatibleBundle(args); + + fCancel = args.Cancel; + fIgnoreBundle = args.IgnoreBundle; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyBegin(string wzPackageOrContainerId, string wzPayloadId, ref bool fCancel) + { + CacheContainerOrPayloadVerifyBeginEventArgs args = new CacheContainerOrPayloadVerifyBeginEventArgs(wzPackageOrContainerId, wzPayloadId, fCancel); + this.OnCacheContainerOrPayloadVerifyBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyProgress(string wzPackageOrContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) + { + CacheContainerOrPayloadVerifyProgressEventArgs args = new CacheContainerOrPayloadVerifyProgressEventArgs(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); + this.OnCacheContainerOrPayloadVerifyProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCacheContainerOrPayloadVerifyComplete(string wzPackageOrContainerId, string wzPayloadId, int hrStatus) + { + CacheContainerOrPayloadVerifyCompleteEventArgs args = new CacheContainerOrPayloadVerifyCompleteEventArgs(wzPackageOrContainerId, wzPayloadId, hrStatus); + this.OnCacheContainerOrPayloadVerifyComplete(args); + + return args.HResult; + } + + int IBootstrapperApplication.OnCachePayloadExtractBegin(string wzContainerId, string wzPayloadId, ref bool fCancel) + { + CachePayloadExtractBeginEventArgs args = new CachePayloadExtractBeginEventArgs(wzContainerId, wzPayloadId, fCancel); + this.OnCachePayloadExtractBegin(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePayloadExtractProgress(string wzContainerId, string wzPayloadId, long dw64Progress, long dw64Total, int dwOverallPercentage, ref bool fCancel) + { + CachePayloadExtractProgressEventArgs args = new CachePayloadExtractProgressEventArgs(wzContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, fCancel); + this.OnCachePayloadExtractProgress(args); + + fCancel = args.Cancel; + return args.HResult; + } + + int IBootstrapperApplication.OnCachePayloadExtractComplete(string wzContainerId, string wzPayloadId, int hrStatus) + { + CachePayloadExtractCompleteEventArgs args = new CachePayloadExtractCompleteEventArgs(wzContainerId, wzPayloadId, hrStatus); + this.OnCachePayloadExtractComplete(args); + + return args.HResult; + } + + #endregion + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationData.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationData.cs new file mode 100644 index 00000000..739a08bb --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationData.cs @@ -0,0 +1,101 @@ +// 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 +{ + using System; + using System.IO; + using System.Xml.XPath; + + /// + /// Utility class for reading BootstrapperApplicationData.xml. + /// + public class BootstrapperApplicationData : IBootstrapperApplicationData + { + /// + /// + /// + public const string DefaultFileName = "BootstrapperApplicationData.xml"; + + /// + /// + /// + public const string XMLNamespace = "http://wixtoolset.org/schemas/v4/BootstrapperApplicationData"; + + /// + /// The default path of where the BA was extracted to. + /// + public static readonly DirectoryInfo DefaultFolder; + + /// + /// The default path to BootstrapperApplicationData.xml. + /// + public static readonly FileInfo DefaultFile; + + static BootstrapperApplicationData() + { + DefaultFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); + DefaultFile = new FileInfo(Path.Combine(DefaultFolder.FullName, DefaultFileName)); + } + + /// + public FileInfo BADataFile { get; private set; } + + /// + public IBundleInfo Bundle { get; private set; } + + /// + /// Uses the default location for BootstrapperApplicationData.xml. + /// + public BootstrapperApplicationData() : this(DefaultFile) { } + + /// + /// Uses the given file for BootstrapperApplicationData.xml. + /// + /// + public BootstrapperApplicationData(FileInfo baDataFile) + { + this.BADataFile = baDataFile; + + using (FileStream fs = this.BADataFile.OpenRead()) + { + this.Bundle = BundleInfo.ParseBundleFromStream(fs); + } + } + + /// + /// Utility method for parsing BootstrapperApplicationData.xml. + /// + /// + /// + /// + public static string GetAttribute(XPathNavigator node, string attributeName) + { + XPathNavigator attribute = node.SelectSingleNode("@" + attributeName); + + if (attribute == null) + { + return null; + } + + return attribute.Value; + } + + /// + /// Utility method for parsing BootstrapperApplicationData.xml. + /// + /// + /// + /// + public static bool? GetYesNoAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + return attributeValue.Equals("yes", StringComparison.InvariantCulture); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs new file mode 100644 index 00000000..95252cf3 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplicationFactoryAttribute.cs @@ -0,0 +1,35 @@ +// 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 +{ + using System; + + /// + /// Identifies the bootstrapper application factory class. + /// + /// + /// This required assembly attribute identifies the bootstrapper application factory class. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] + public sealed class BootstrapperApplicationFactoryAttribute : Attribute + { + private Type bootstrapperApplicationFactoryType; + + /// + /// Creates a new instance of the class. + /// + /// The of the BA factory. + public BootstrapperApplicationFactoryAttribute(Type bootstrapperApplicationFactoryType) + { + this.bootstrapperApplicationFactoryType = bootstrapperApplicationFactoryType; + } + + /// + /// Gets the type of the bootstrapper application factory class to create. + /// + public Type BootstrapperApplicationFactoryType + { + get { return this.bootstrapperApplicationFactoryType; } + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs new file mode 100644 index 00000000..65dde0f4 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperCommand.cs @@ -0,0 +1,145 @@ +// 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 +{ + using System; + using System.ComponentModel; + using System.Runtime.InteropServices; + + /// + /// Default implementation of . + /// + public sealed class BootstrapperCommand : IBootstrapperCommand + { + private readonly string commandLine; + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public BootstrapperCommand( + LaunchAction action, + Display display, + Restart restart, + string commandLine, + int cmdShow, + ResumeType resume, + IntPtr splashScreen, + RelationType relation, + bool passthrough, + string layoutDirectory, + string bootstrapperWorkingFolder, + string bootstrapperApplicationDataPath) + { + this.Action = action; + this.Display = display; + this.Restart = restart; + this.commandLine = commandLine; + this.CmdShow = cmdShow; + this.Resume = resume; + this.SplashScreen = splashScreen; + this.Relation = relation; + this.Passthrough = passthrough; + this.LayoutDirectory = layoutDirectory; + this.BootstrapperWorkingFolder = bootstrapperWorkingFolder; + this.BootstrapperApplicationDataPath = bootstrapperApplicationDataPath; + } + + /// + public LaunchAction Action { get; } + + /// + public Display Display { get; } + + /// + public Restart Restart { get; } + + /// + public string[] CommandLineArgs => GetCommandLineArgs(this.commandLine); + + /// + public int CmdShow { get; } + + /// + public ResumeType Resume { get; } + + /// + public IntPtr SplashScreen { get; } + + /// + public RelationType Relation { get; } + + /// + public bool Passthrough { get; } + + /// + public string LayoutDirectory { get; } + + /// + public string BootstrapperWorkingFolder { get; } + + /// + public string BootstrapperApplicationDataPath { get; } + + /// + /// Gets the command line arguments as a string array. + /// + /// + /// Array of command line arguments. + /// + /// The command line could not be parsed into an array. + /// + /// This method uses the same parsing as the operating system which handles quotes and spaces correctly. + /// + public static string[] GetCommandLineArgs(string commandLine) + { + if (null == commandLine) + { + return new string[0]; + } + + // Parse the filtered command line arguments into a native array. + int argc = 0; + + // CommandLineToArgvW tries to treat the first argument as the path to the process, + // which fails pretty miserably if your first argument is something like + // FOO="C:\Program Files\My Company". So give it something harmless to play with. + IntPtr argv = NativeMethods.CommandLineToArgvW("ignored " + commandLine, out argc); + + if (IntPtr.Zero == argv) + { + // Throw an exception with the last error. + throw new Win32Exception(); + } + + // Marshal each native array pointer to a managed string. + try + { + // Skip "ignored" argument/hack. + string[] args = new string[argc - 1]; + for (int i = 1; i < argc; ++i) + { + IntPtr argvi = Marshal.ReadIntPtr(argv, i * IntPtr.Size); + args[i - 1] = Marshal.PtrToStringUni(argvi); + } + + return args; + } + finally + { + NativeMethods.LocalFree(argv); + } + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs b/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs new file mode 100644 index 00000000..3d5d535d --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/BundleInfo.cs @@ -0,0 +1,86 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; + using System.Xml.XPath; + + /// + /// Default implementation of . + /// + public class BundleInfo : IBundleInfo + { + /// + public bool PerMachine { get; internal set; } + + /// + public string Name { get; internal set; } + + /// + public string LogVariable { get; internal set; } + + /// + public IDictionary Packages { get; internal set; } + + internal BundleInfo() + { + this.Packages = new Dictionary(); + } + + /// + public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) + { + var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); + this.Packages.Add(package.Id, package); + return package; + } + + /// + /// Parses BA manifest from the given stream. + /// + /// + /// + public static IBundleInfo ParseBundleFromStream(Stream stream) + { + XPathDocument manifest = new XPathDocument(stream); + XPathNavigator root = manifest.CreateNavigator(); + return ParseBundleFromXml(root); + } + + /// + /// Parses BA manifest from the given . + /// + /// The root of the BA manifest. + /// + public static IBundleInfo ParseBundleFromXml(XPathNavigator root) + { + BundleInfo bundle = new BundleInfo(); + + XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); + namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); + XPathNavigator bundleNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:WixBundleProperties", namespaceManager); + + if (bundleNode == null) + { + throw new Exception("Failed to select bundle information."); + } + + bool? perMachine = BootstrapperApplicationData.GetYesNoAttribute(bundleNode, "PerMachine"); + if (perMachine.HasValue) + { + bundle.PerMachine = perMachine.Value; + } + + bundle.Name = BootstrapperApplicationData.GetAttribute(bundleNode, "DisplayName"); + + bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable"); + + bundle.Packages = PackageInfo.ParsePackagesFromXml(root); + + return bundle; + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/Engine.cs b/src/api/burn/WixToolset.Mba.Core/Engine.cs new file mode 100644 index 00000000..aed420d5 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/Engine.cs @@ -0,0 +1,541 @@ +// 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 +{ + using System; + using System.ComponentModel; + using System.Runtime.InteropServices; + using System.Security; + using System.Text; + + /// + /// Default implementation of . + /// + public sealed class Engine : IEngine + { + // Burn errs on empty strings, so declare initial buffer size. + private const int InitialBufferSize = 80; + private static readonly string normalizeVersionFormatString = "{0} must be less than or equal to " + UInt16.MaxValue; + + private IBootstrapperEngine engine; + + /// + /// Creates a new instance of the container class. + /// + /// The to contain. + internal Engine(IBootstrapperEngine engine) + { + this.engine = engine; + } + + /// + public int PackageCount + { + get + { + int count; + this.engine.GetPackageCount(out count); + + return count; + } + } + + /// + public void Apply(IntPtr hwndParent) + { + this.engine.Apply(hwndParent); + } + + /// + public void CloseSplashScreen() + { + this.engine.CloseSplashScreen(); + } + + /// + public int CompareVersions(string version1, string version2) + { + this.engine.CompareVersions(version1, version2, out var result); + return result; + } + + /// + public bool ContainsVariable(string name) + { + IntPtr capacity = new IntPtr(0); + int ret = this.engine.GetVariableString(name, IntPtr.Zero, ref capacity); + return NativeMethods.E_NOTFOUND != ret; + } + + /// + public void Detect() + { + this.Detect(IntPtr.Zero); + } + + /// + public void Detect(IntPtr hwndParent) + { + this.engine.Detect(hwndParent); + } + + /// + public bool Elevate(IntPtr hwndParent) + { + int ret = this.engine.Elevate(hwndParent); + + if (NativeMethods.S_OK == ret || NativeMethods.E_ALREADYINITIALIZED == ret) + { + return true; + } + else if (NativeMethods.E_CANCELLED == ret) + { + return false; + } + else + { + throw new Win32Exception(ret); + } + } + + /// + public string EscapeString(string input) + { + IntPtr capacity = new IntPtr(InitialBufferSize); + StringBuilder sb = new StringBuilder(capacity.ToInt32()); + + // Get the size of the buffer. + int ret = this.engine.EscapeString(input, sb, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + capacity = new IntPtr(capacity.ToInt32() + 1); // Add one for the null terminator. + sb.Capacity = capacity.ToInt32(); + ret = this.engine.EscapeString(input, sb, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return sb.ToString(); + } + + /// + public bool EvaluateCondition(string condition) + { + bool value; + this.engine.EvaluateCondition(condition, out value); + + return value; + } + + /// + public string FormatString(string format) + { + IntPtr capacity = new IntPtr(InitialBufferSize); + StringBuilder sb = new StringBuilder(capacity.ToInt32()); + + // Get the size of the buffer. + int ret = this.engine.FormatString(format, sb, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + capacity = new IntPtr(capacity.ToInt32() + 1); // Add one for the null terminator. + sb.Capacity = capacity.ToInt32(); + ret = this.engine.FormatString(format, sb, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return sb.ToString(); + } + + /// + public long GetVariableNumeric(string name) + { + int ret = this.engine.GetVariableNumeric(name, out long value); + if (NativeMethods.S_OK != ret) + { + throw new Win32Exception(ret); + } + + return value; + } + + /// + public SecureString GetVariableSecureString(string name) + { + var pUniString = this.getStringVariable(name, out var length); + try + { + return this.convertToSecureString(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + } + + /// + public string GetVariableString(string name) + { + int length; + IntPtr pUniString = this.getStringVariable(name, out length); + try + { + return Marshal.PtrToStringUni(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + } + + /// + public string GetVariableVersion(string name) + { + int length; + IntPtr pUniString = this.getVersionVariable(name, out length); + try + { + return Marshal.PtrToStringUni(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } + } + } + + /// + public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) + { + this.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, 0); + } + + /// + public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout) + { + this.engine.LaunchApprovedExe(hwndParent, approvedExeForElevationId, arguments, waitForInputIdleTimeout); + } + /// + + public void Log(LogLevel level, string message) + { + this.engine.Log(level, message); + } + + /// + public void Plan(LaunchAction action) + { + this.engine.Plan(action); + } + + /// + public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash) + { + this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); + } + + /// + public void SetUpdateSource(string url) + { + this.engine.SetUpdateSource(url); + } + + /// + public void SetLocalSource(string packageOrContainerId, string payloadId, string path) + { + this.engine.SetLocalSource(packageOrContainerId, payloadId, path); + } + + /// + public void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password) + { + this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); + } + + /// + public void SetVariableNumeric(string name, long value) + { + this.engine.SetVariableNumeric(name, value); + } + + /// + public void SetVariableString(string name, SecureString value, bool formatted) + { + IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); + try + { + this.engine.SetVariableString(name, pValue, formatted); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + } + + /// + public void SetVariableString(string name, string value, bool formatted) + { + IntPtr pValue = Marshal.StringToCoTaskMemUni(value); + try + { + this.engine.SetVariableString(name, pValue, formatted); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + } + + /// + public void SetVariableVersion(string name, string value) + { + IntPtr pValue = Marshal.StringToCoTaskMemUni(value); + try + { + this.engine.SetVariableVersion(name, pValue); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } + } + + /// + public int SendEmbeddedError(int errorCode, string message, int uiHint) + { + int result = 0; + this.engine.SendEmbeddedError(errorCode, message, uiHint, out result); + return result; + } + + /// + public int SendEmbeddedProgress(int progressPercentage, int overallPercentage) + { + int result = 0; + this.engine.SendEmbeddedProgress(progressPercentage, overallPercentage, out result); + return result; + } + + /// + public void Quit(int exitCode) + { + this.engine.Quit(exitCode); + } + + /// + /// Gets the variable given by as a string. + /// + /// The name of the variable to get. + /// The length of the Unicode string. + /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. + /// An error occurred getting the variable. + internal IntPtr getStringVariable(string name, out int length) + { + IntPtr capacity = new IntPtr(InitialBufferSize); + bool success = false; + IntPtr pValue = Marshal.AllocCoTaskMem(capacity.ToInt32() * UnicodeEncoding.CharSize); + try + { + // Get the size of the buffer. + int ret = this.engine.GetVariableString(name, pValue, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + // Don't need to add 1 for the null terminator, the engine already includes that. + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity.ToInt32() * UnicodeEncoding.CharSize); + ret = this.engine.GetVariableString(name, pValue, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw Marshal.GetExceptionForHR(ret); + } + + // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. + int maxLength = capacity.ToInt32(); + for (length = 0; length < maxLength; ++length) + { + if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) + { + break; + } + } + + success = true; + return pValue; + } + finally + { + if (!success && IntPtr.Zero != pValue) + { + Marshal.FreeCoTaskMem(pValue); + } + } + } + + /// + /// Gets the variable given by as a version string. + /// + /// The name of the variable to get. + /// The length of the Unicode string. + /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. + /// An error occurred getting the variable. + internal IntPtr getVersionVariable(string name, out int length) + { + IntPtr capacity = new IntPtr(InitialBufferSize); + bool success = false; + IntPtr pValue = Marshal.AllocCoTaskMem(capacity.ToInt32() * UnicodeEncoding.CharSize); + try + { + // Get the size of the buffer. + int ret = this.engine.GetVariableVersion(name, pValue, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + // Don't need to add 1 for the null terminator, the engine already includes that. + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity.ToInt32() * UnicodeEncoding.CharSize); + ret = this.engine.GetVariableVersion(name, pValue, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw Marshal.GetExceptionForHR(ret); + } + + // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. + int maxLength = capacity.ToInt32(); + for (length = 0; length < maxLength; ++length) + { + if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) + { + break; + } + } + + success = true; + return pValue; + } + finally + { + if (!success && IntPtr.Zero != pValue) + { + Marshal.FreeCoTaskMem(pValue); + } + } + } + + /// + /// Initialize a SecureString with the given Unicode string. + /// + /// Pointer to Unicode string. + /// The string's length. + internal SecureString convertToSecureString(IntPtr pUniString, int length) + { + if (IntPtr.Zero == pUniString) + { + return null; + } + + SecureString value = new SecureString(); + short s; + char c; + for (int charIndex = 0; charIndex < length; charIndex++) + { + s = Marshal.ReadInt16(pUniString, charIndex * UnicodeEncoding.CharSize); + c = (char)s; + value.AppendChar(c); + s = 0; + c = (char)0; + } + return value; + } + + /// + /// Utility method for converting a into a . + /// + /// + /// + public static long VersionToLong(Version version) + { + // In Windows, each version component has a max value of 65535, + // so we truncate the version before shifting it, which will overflow if invalid. + long major = (long)(ushort)version.Major << 48; + long minor = (long)(ushort)version.Minor << 32; + long build = (long)(ushort)version.Build << 16; + long revision = (long)(ushort)version.Revision; + + return major | minor | build | revision; + } + + /// + /// Utility method for converting a into a . + /// + /// + /// + public static Version LongToVersion(long version) + { + int major = (int)((version & ((long)0xffff << 48)) >> 48); + int minor = (int)((version & ((long)0xffff << 32)) >> 32); + int build = (int)((version & ((long)0xffff << 16)) >> 16); + int revision = (int)(version & 0xffff); + + return new Version(major, minor, build, revision); + } + + /// + /// Verifies that Version can be represented in a . + /// If the Build or Revision fields are undefined, they are set to zero. + /// + public static Version NormalizeVersion(Version version) + { + if (version == null) + { + throw new ArgumentNullException("version"); + } + + int major = version.Major; + int minor = version.Minor; + int build = version.Build; + int revision = version.Revision; + + if (major > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Major")); + } + if (minor > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Minor")); + } + if (build > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Build")); + } + if (build == -1) + { + build = 0; + } + if (revision > UInt16.MaxValue) + { + throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Revision")); + } + if (revision == -1) + { + revision = 0; + } + + return new Version(major, minor, build, revision); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs new file mode 100644 index 00000000..8ef8af14 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -0,0 +1,2186 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + + /// + /// Base class for BA classes. + /// + [Serializable] + public abstract class HResultEventArgs : EventArgs + { + /// + /// Creates a new instance of the class. + /// + public HResultEventArgs() + { + } + + /// + /// Gets or sets the of the operation. This is passed back to the engine. + /// + public int HResult { get; set; } + } + + /// + /// Base class for cancellable BA classes. + /// + [Serializable] + public abstract class CancellableHResultEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public CancellableHResultEventArgs(bool cancelRecommendation) + { + this.Cancel = cancelRecommendation; + } + + /// + /// Gets or sets whether to cancel the operation. This is passed back to the engine. + /// + public bool Cancel { get; set; } + } + + /// + /// Base class for classes that must return a . + /// + [Serializable] + public abstract class ResultEventArgs : HResultEventArgs + { + /// + public ResultEventArgs(Result recommendation, Result result) + { + this.Recommendation = recommendation; + this.Result = result; + } + + /// + /// Gets the recommended of the operation. + /// + public Result Recommendation { get; private set; } + + /// + /// Gets or sets the of the operation. This is passed back to the engine. + /// + public Result Result { get; set; } + } + + /// + /// Base class for classes that receive status from the engine. + /// + [Serializable] + public abstract class StatusEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public StatusEventArgs(int hrStatus) + { + this.Status = hrStatus; + } + + /// + /// Gets the return code of the operation. + /// + public int Status { get; private set; } + } + + /// + /// Base class for classes that receive status from the engine and return an action. + /// + public abstract class ActionEventArgs : StatusEventArgs + { + /// + public ActionEventArgs(int hrStatus, T recommendation, T action) + : base(hrStatus) + { + this.Recommendation = recommendation; + this.Action = action; + } + + /// + /// Gets the recommended action from the engine. + /// + public T Recommendation { get; private set; } + + /// + /// Gets or sets the action to be performed. This is passed back to the engine. + /// + public T Action { get; set; } + } + + /// + /// Base class for cancellable action BA classes. + /// + [Serializable] + public abstract class CancellableActionEventArgs : CancellableHResultEventArgs + { + /// + public CancellableActionEventArgs(bool cancelRecommendation, T recommendation, T action) + : base(cancelRecommendation) + { + this.Recommendation = recommendation; + this.Action = action; + } + + /// + /// Gets the recommended action from the engine. + /// + public T Recommendation { get; private set; } + + /// + /// Gets or sets the action to be performed. This is passed back to the engine. + /// + public T Action { get; set; } + } + + /// + /// Base class for cache progress events. + /// + [Serializable] + public abstract class CacheProgressBaseEventArgs : CancellableHResultEventArgs + { + /// + public CacheProgressBaseEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.Progress = progress; + this.Total = total; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + + /// + /// Gets the number of bytes cached thus far. + /// + public long Progress { get; private set; } + + /// + /// Gets the total bytes to cache. + /// + public long Total { get; private set; } + + /// + /// Gets the overall percentage of progress of caching. + /// + public int OverallPercentage { get; private set; } + } + + /// + /// Additional arguments used when startup has begun. + /// + [Serializable] + public class StartupEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public StartupEventArgs() + { + } + } + + /// + /// Additional arguments used when shutdown has begun. + /// + [Serializable] + public class ShutdownEventArgs : HResultEventArgs + { + /// + /// Creates a new instance of the class. + /// + public ShutdownEventArgs(BOOTSTRAPPER_SHUTDOWN_ACTION action) + { + this.Action = action; + } + + /// + /// The action for OnShutdown. + /// + public BOOTSTRAPPER_SHUTDOWN_ACTION Action { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class SystemShutdownEventArgs : CancellableHResultEventArgs + { + /// + public SystemShutdownEventArgs(EndSessionReasons reasons, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.Reasons = reasons; + } + + /// + /// Gets the reason the application is requested to close or being closed. + /// + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// + public EndSessionReasons Reasons { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectBeginEventArgs : CancellableHResultEventArgs + { + /// + public DetectBeginEventArgs(bool cached, bool installed, int packageCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.Cached = cached; + this.Installed = installed; + this.PackageCount = packageCount; + } + + /// + /// Gets whether the bundle is cached. + /// + public bool Cached { get; private set; } + + /// + /// Gets whether the bundle is installed. + /// + public bool Installed { get; private set; } + + /// + /// Gets the number of packages to detect. + /// + public int PackageCount { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectForwardCompatibleBundleEventArgs : CancellableHResultEventArgs + { + /// + public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool missingFromCache, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RelationType = relationType; + this.BundleTag = bundleTag; + this.PerMachine = perMachine; + this.Version = version; + this.MissingFromCache = missingFromCache; + } + + /// + /// Gets the identity of the forward compatible bundle detected. + /// + public string BundleId { get; private set; } + + /// + /// Gets the relationship type of the forward compatible bundle. + /// + public RelationType RelationType { get; private set; } + + /// + /// Gets the tag of the forward compatible bundle. + /// + public string BundleTag { get; private set; } + + /// + /// Gets whether the detected forward compatible bundle is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the forward compatible bundle detected. + /// + public string Version { get; private set; } + + /// + /// Whether the forward compatible bundle is missing from the package cache. + /// + public bool MissingFromCache { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectUpdateBeginEventArgs : CancellableHResultEventArgs + { + /// + public DetectUpdateBeginEventArgs(string updateLocation, bool cancelRecommendation, bool skipRecommendation) + : base(cancelRecommendation) + { + this.UpdateLocation = updateLocation; + this.Skip = skipRecommendation; + } + + /// + /// Gets the identity of the bundle to detect. + /// + public string UpdateLocation { get; private set; } + + /// + /// Whether to skip checking for bundle updates. + /// + public bool Skip { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectUpdateEventArgs : CancellableHResultEventArgs + { + /// + public DetectUpdateEventArgs(string updateLocation, long size, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) + : base(cancelRecommendation) + { + this.UpdateLocation = updateLocation; + this.Size = size; + this.Version = version; + this.Title = title; + this.Summary = summary; + this.ContentType = contentType; + this.Content = content; + this.StopProcessingUpdates = stopRecommendation; + } + + /// + /// Gets the identity of the bundle to detect. + /// + public string UpdateLocation { get; private set; } + + /// + /// Gets the size of the updated bundle. + /// + public long Size { get; private set; } + + /// + /// Gets the version of the updated bundle. + /// + public string Version { get; private set; } + + /// + /// Gets the title of the the updated bundle. + /// + public string Title { get; private set; } + + /// + /// Gets the summary of the updated bundle. + /// + public string Summary { get; private set; } + + /// + /// Gets the content type of the content of the updated bundle. + /// + public string ContentType { get; private set; } + + /// + /// Gets the content of the updated bundle. + /// + public string Content { get; private set; } + + /// + /// Tells the engine to stop giving the rest of the updates found in the feed. + /// + public bool StopProcessingUpdates { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectUpdateCompleteEventArgs : StatusEventArgs + { + /// + public DetectUpdateCompleteEventArgs(int hrStatus, bool ignoreRecommendation) + : base(hrStatus) + { + this.IgnoreError = ignoreRecommendation; + } + + /// + /// If Status is an error, then set this to true to ignore it and continue detecting. + /// + public bool IgnoreError { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectRelatedBundleEventArgs : CancellableHResultEventArgs + { + /// + public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool missingFromCache, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.ProductCode = productCode; + this.RelationType = relationType; + this.BundleTag = bundleTag; + this.PerMachine = perMachine; + this.Version = version; + this.Operation = operation; + this.MissingFromCache = missingFromCache; + } + + /// + /// Gets the identity of the related bundle detected. + /// + public string ProductCode { get; private set; } + + /// + /// Gets the relationship type of the related bundle. + /// + public RelationType RelationType { get; private set; } + + /// + /// Gets the tag of the related package bundle. + /// + public string BundleTag { get; private set; } + + /// + /// Gets whether the detected bundle is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the related bundle detected. + /// + public string Version { get; private set; } + + /// + /// Gets the operation that will be taken on the detected bundle. + /// + public RelatedOperation Operation { get; private set; } + + /// + /// Whether the related bundle is missing from the package cache. + /// + public bool MissingFromCache { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectPackageBeginEventArgs : CancellableHResultEventArgs + { + /// + public DetectPackageBeginEventArgs(string packageId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + } + + /// + /// Gets the identity of the package to detect. + /// + public string PackageId { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class DetectRelatedMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.UpgradeCode = upgradeCode; + this.ProductCode = productCode; + this.PerMachine = perMachine; + this.Version = version; + this.Operation = operation; + } + + /// + /// Gets the identity of the product's package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the upgrade code of the related package detected. + /// + public string UpgradeCode { get; private set; } + + /// + /// Gets the identity of the related package detected. + /// + public string ProductCode { get; private set; } + + /// + /// Gets whether the detected package is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the related package detected. + /// + public string Version { get; private set; } + + /// + /// Gets the operation that will be taken on the detected package. + /// + public RelatedOperation Operation { get; private set; } + } + + /// + /// Event arguments for + /// + public class DetectPatchTargetEventArgs : CancellableHResultEventArgs + { + /// + /// + /// + /// + /// + /// + /// + public DetectPatchTargetEventArgs(string packageId, string productCode, PackageState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ProductCode = productCode; + this.State = state; + } + + /// + /// Gets the identity of the patch's package. + /// + public string PackageId { get; private set; } + + /// + /// Gets the product code of the target. + /// + public string ProductCode { get; private set; } + + /// + /// Gets the detected patch state for the target. + /// + public PackageState State { get; private set; } + } + + /// + /// Event arguments for + /// + public class DetectMsiFeatureEventArgs : CancellableHResultEventArgs + { + /// + public DetectMsiFeatureEventArgs(string packageId, string featureId, FeatureState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.FeatureId = featureId; + this.State = state; + } + + /// + /// Gets the identity of the feature's package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the feature detected. + /// + public string FeatureId { get; private set; } + + /// + /// Gets the detected feature state. + /// + public FeatureState State { get; private set; } + } + + /// + /// Additional arguments for . + /// + [Serializable] + public class DetectPackageCompleteEventArgs : StatusEventArgs + { + /// + public DetectPackageCompleteEventArgs(string packageId, int hrStatus, PackageState state, bool cached) + : base(hrStatus) + { + this.PackageId = packageId; + this.State = state; + this.Cached = cached; + } + + /// + /// Gets the identity of the package detected. + /// + public string PackageId { get; private set; } + + /// + /// Gets the state of the specified package. + /// + public PackageState State { get; private set; } + + /// + /// Gets whether any part of the package is cached. + /// + public bool Cached { get; private set; } + } + + /// + /// Additional arguments used when the detection phase has completed. + /// + [Serializable] + public class DetectCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + /// + public DetectCompleteEventArgs(int hrStatus, bool eligibleForCleanup) + : base(hrStatus) + { + this.EligibleForCleanup = eligibleForCleanup; + } + + /// + /// Indicates whether the engine will uninstall the bundle if shutdown without running Apply. + /// + public bool EligibleForCleanup { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanBeginEventArgs : CancellableHResultEventArgs + { + /// + public PlanBeginEventArgs(int packageCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageCount = packageCount; + } + + /// + /// Gets the number of packages to plan for. + /// + public int PackageCount { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanRelatedBundleEventArgs : CancellableHResultEventArgs + { + /// + public PlanRelatedBundleEventArgs(string bundleId, RequestState recommendedState, RequestState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the bundle to plan for. + /// + public string BundleId { get; private set; } + + /// + /// Gets the recommended requested state for the bundle. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// Gets or sets the requested state for the bundle. + /// + public RequestState State { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanPackageBeginEventArgs : CancellableHResultEventArgs + { + /// + public PlanPackageBeginEventArgs(string packageId, PackageState currentState, bool cached, BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, RequestState recommendedState, BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, RequestState state, BOOTSTRAPPER_CACHE_TYPE cacheType, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CurrentState = currentState; + this.Cached = cached; + this.InstallCondition = installCondition; + this.RecommendedState = recommendedState; + this.RecommendedCacheType = recommendedCacheType; + this.State = state; + this.CacheType = cacheType; + } + + /// + /// Gets the identity of the package to plan for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the current state of the package. + /// + public PackageState CurrentState { get; private set; } + + /// + /// Gets whether any part of the package is cached. + /// + public bool Cached { get; private set; } + + /// + /// Gets the evaluated result of the package's install condition. + /// + public BOOTSTRAPPER_PACKAGE_CONDITION_RESULT InstallCondition { get; private set; } + + /// + /// Gets the recommended requested state for the package. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// The authored cache type of the package. + /// + public BOOTSTRAPPER_CACHE_TYPE RecommendedCacheType { get; private set; } + + /// + /// Gets or sets the requested state for the package. + /// + public RequestState State { get; set; } + + /// + /// Gets or sets the requested cache type for the package. + /// + public BOOTSTRAPPER_CACHE_TYPE CacheType { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanPatchTargetEventArgs : CancellableHResultEventArgs + { + /// + /// + /// + /// + /// + /// + /// + /// + public PlanPatchTargetEventArgs(string packageId, string productCode, RequestState recommendedState, RequestState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ProductCode = productCode; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the patch's package. + /// + public string PackageId { get; private set; } + + /// + /// Gets the product code of the target. + /// + public string ProductCode { get; private set; } + + /// + /// Gets the recommended state of the patch to use by planning for the target. + /// + public RequestState RecommendedState { get; private set; } + + /// + /// Gets or sets the state of the patch to use by planning for the target. + /// + public RequestState State { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanMsiFeatureEventArgs : CancellableHResultEventArgs + { + /// + public PlanMsiFeatureEventArgs(string packageId, string featureId, FeatureState recommendedState, FeatureState state, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.FeatureId = featureId; + this.RecommendedState = recommendedState; + this.State = state; + } + + /// + /// Gets the identity of the feature's package to plan. + /// + public string PackageId { get; private set; } + + /// + /// Gets the identity of the feature to plan. + /// + public string FeatureId { get; private set; } + + /// + /// Gets the recommended feature state to use by planning. + /// + public FeatureState RecommendedState { get; private set; } + + /// + /// Gets or sets the feature state to use by planning. + /// + public FeatureState State { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanMsiPackageEventArgs : CancellableHResultEventArgs + { + /// + public PlanMsiPackageEventArgs(string packageId, bool shouldExecute, ActionState action, bool cancelRecommendation, BURN_MSI_PROPERTY actionMsiProperty, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ShouldExecute = shouldExecute; + this.Action = action; + this.ActionMsiProperty = actionMsiProperty; + this.UiLevel = uiLevel; + this.DisableExternalUiHandler = disableExternalUiHandler; + } + + /// + /// Gets identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets whether the package is planned to execute or roll back. + /// + public bool ShouldExecute { get; private set; } + + /// + /// Gets the action planned for the package. + /// + public ActionState Action { get; private set; } + + /// + /// Gets or sets the requested MSI property to add. + /// + public BURN_MSI_PROPERTY ActionMsiProperty { get; set; } + + /// + /// Gets or sets the requested internal UI level. + /// + public INSTALLUILEVEL UiLevel { get; set; } + + /// + /// Gets or sets whether Burn is requested to set up an external UI handler. + /// + public bool DisableExternalUiHandler { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanPackageCompleteEventArgs : StatusEventArgs + { + /// + /// + /// + /// + /// + /// + public PlanPackageCompleteEventArgs(string packageId, int hrStatus, RequestState requested) + : base(hrStatus) + { + this.PackageId = packageId; + this.Requested = requested; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the requested state for the package. + /// + public RequestState Requested { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlannedPackageEventArgs : HResultEventArgs + { + /// + public PlannedPackageEventArgs(string packageId, ActionState execute, ActionState rollback, bool cache, bool uncache) + { + this.PackageId = packageId; + this.Execute = execute; + this.Rollback = rollback; + this.Cache = cache; + this.Uncache = uncache; + } + + /// + /// Gets the identity of the package planned for. + /// + public string PackageId { get; private set; } + + /// + /// Gets the planned execution action. + /// + public ActionState Execute { get; private set; } + + /// + /// Gets the planned rollback action. + /// + public ActionState Rollback { get; private set; } + + /// + /// Gets whether the package will be cached. + /// + public bool Cache { get; private set; } + + /// + /// Gets whether the package will be removed from the package cache. + /// + public bool Uncache { get; private set; } + } + + /// + /// Additional arguments used when the engine has completed planning the installation. + /// + [Serializable] + public class PlanCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public PlanCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class PlanForwardCompatibleBundleEventArgs : CancellableHResultEventArgs + { + /// + public PlanForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool recommendedIgnoreBundle, bool cancelRecommendation, bool ignoreBundle) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RelationType = relationType; + this.BundleTag = bundleTag; + this.PerMachine = perMachine; + this.Version = version; + this.RecommendedIgnoreBundle = recommendedIgnoreBundle; + this.IgnoreBundle = ignoreBundle; + } + + /// + /// Gets the identity of the forward compatible bundle detected. + /// + public string BundleId { get; private set; } + + /// + /// Gets the relationship type of the forward compatible bundle. + /// + public RelationType RelationType { get; private set; } + + /// + /// Gets the tag of the forward compatible bundle. + /// + public string BundleTag { get; private set; } + + /// + /// Gets whether the forward compatible bundle is per machine. + /// + public bool PerMachine { get; private set; } + + /// + /// Gets the version of the forward compatible bundle. + /// + public string Version { get; private set; } + + /// + /// Gets the recommendation of whether the engine should use the forward compatible bundle. + /// + public bool RecommendedIgnoreBundle { get; set; } + + /// + /// Gets or sets whether the engine will use the forward compatible bundle. + /// + public bool IgnoreBundle { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ApplyBeginEventArgs : CancellableHResultEventArgs + { + /// + public ApplyBeginEventArgs(int phaseCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PhaseCount = phaseCount; + } + + /// + /// Gets the number of phases that the engine will go through in apply. + /// There are currently two possible phases: cache and execute. + /// + public int PhaseCount { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ElevateBeginEventArgs : CancellableHResultEventArgs + { + /// + public ElevateBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments used when the engine has completed starting the elevated process. + /// + [Serializable] + public class ElevateCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public ElevateCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ProgressEventArgs : CancellableHResultEventArgs + { + /// + public ProgressEventArgs(int progressPercentage, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.ProgressPercentage = progressPercentage; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the percentage from 0 to 100 completed for a package. + /// + public int ProgressPercentage { get; private set; } + + /// + /// Gets the percentage from 0 to 100 completed for the bundle. + /// + public int OverallPercentage { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ErrorEventArgs : ResultEventArgs + { + /// + public ErrorEventArgs(ErrorType errorType, string packageId, int errorCode, string errorMessage, int dwUIHint, string[] data, Result recommendation, Result result) + : base(recommendation, result) + { + this.ErrorType = errorType; + this.PackageId = packageId; + this.ErrorCode = errorCode; + this.ErrorMessage = errorMessage; + this.UIHint = dwUIHint; + this.Data = new ReadOnlyCollection(data ?? new string[] { }); + } + + /// + /// Gets the type of error that occurred. + /// + public ErrorType ErrorType { get; private set; } + + /// + /// Gets the identity of the package that yielded the error. + /// + public string PackageId { get; private set; } + + /// + /// Gets the error code. + /// + public int ErrorCode { get; private set; } + + /// + /// Gets the error message. + /// + public string ErrorMessage { get; private set; } + + /// + /// Gets the recommended display flags for an error dialog. + /// + public int UIHint { get; private set; } + + /// + /// Gets the extended data for the error. + /// + public IList Data { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class RegisterBeginEventArgs : CancellableHResultEventArgs + { + /// + public RegisterBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments used when the engine has completed registering the location and visilibity of the bundle. + /// + [Serializable] + public class RegisterCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public RegisterCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class UnregisterBeginEventArgs : HResultEventArgs + { + /// + /// + /// + /// + /// + public UnregisterBeginEventArgs(bool keepRegistration, bool forceKeepRegistration) + { + this.KeepRegistration = keepRegistration; + this.ForceKeepRegistration = forceKeepRegistration; + } + + /// + /// Indicates whether the engine will uninstall the bundle. + /// + public bool ForceKeepRegistration { get; set; } + + /// + /// If is FALSE, then this can be set to TRUE to make the engine keep the bundle installed. + /// + public bool KeepRegistration { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class UnregisterCompleteEventArgs : StatusEventArgs + { + /// + /// + /// + /// + public UnregisterCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CacheBeginEventArgs : CancellableHResultEventArgs + { + /// + public CacheBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheAcquireBeginEventArgs : CancellableActionEventArgs + { + /// + public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, string source, string downloadUrl, string payloadContainerId, CacheOperation recommendation, CacheOperation action, bool cancelRecommendation) + : base(cancelRecommendation, recommendation, action) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.Source = source; + this.DownloadUrl = downloadUrl; + this.PayloadContainerId = payloadContainerId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload (if acquiring a payload). + /// + public string PayloadId { get; private set; } + + /// + /// Gets the source of the container or payload. + /// + public string Source { get; private set; } + + /// + /// Gets the optional URL to download container or payload. + /// + public string DownloadUrl { get; private set; } + + /// + /// Gets the optional identity of the container that contains the payload being acquired. + /// + public string PayloadContainerId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheAcquireProgressEventArgs : CacheProgressBaseEventArgs + { + /// + public CacheAcquireProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheAcquireCompleteEventArgs : ActionEventArgs + { + /// + public CacheAcquireCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload (if acquiring a payload). + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheVerifyBeginEventArgs : CancellableHResultEventArgs + { + /// + public CacheVerifyBeginEventArgs(string packageOrContainerId, string payloadId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheVerifyProgressEventArgs : CacheProgressBaseEventArgs + { + /// + public CacheVerifyProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, CacheVerifyStep verifyStep, bool cancelRecommendation) + : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + this.Step = verifyStep; + } + + /// + /// Gets the current verification step. + /// + public CacheVerifyStep Step { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CacheVerifyCompleteEventArgs : ActionEventArgs + { + /// + public CacheVerifyCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// Additional arguments used after the engine has cached the installation sources. + /// + [Serializable] + public class CacheCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public CacheCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ExecuteBeginEventArgs : CancellableHResultEventArgs + { + /// + public ExecuteBeginEventArgs(int packageCount, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageCount = packageCount; + } + + /// + /// Gets the number of packages to act on. + /// + public int PackageCount { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ExecutePackageBeginEventArgs : CancellableHResultEventArgs + { + /// + public ExecutePackageBeginEventArgs(string packageId, bool shouldExecute, ActionState action, INSTALLUILEVEL uiLevel, bool disableExternalUiHandler, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ShouldExecute = shouldExecute; + this.Action = action; + this.UiLevel = uiLevel; + this.DisableExternalUiHandler = disableExternalUiHandler; + } + + /// + /// Gets the identity of the package to act on. + /// + public string PackageId { get; private set; } + + /// + /// Gets whether the package is being executed or rolled back. + /// + public bool ShouldExecute { get; private set; } + + /// + /// Gets the action about to be executed. + /// + public ActionState Action { get; private set; } + + /// + /// Gets the internal UI level (if this is an MSI or MSP package). + /// + public INSTALLUILEVEL UiLevel { get; private set; } + + /// + /// Gets whether Burn will set up an external UI handler (if this is an MSI or MSP package). + /// + public bool DisableExternalUiHandler { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ExecutePatchTargetEventArgs : CancellableHResultEventArgs + { + /// + public ExecutePatchTargetEventArgs(string packageId, string targetProductCode, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.TargetProductCode = targetProductCode; + } + + /// + /// Gets the identity of the package to act on. + /// + public string PackageId { get; private set; } + + /// + /// Gets the product code being targeted. + /// + public string TargetProductCode { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ExecuteMsiMessageEventArgs : ResultEventArgs + { + /// + public ExecuteMsiMessageEventArgs(string packageId, InstallMessage messageType, int dwUIHint, string message, string[] data, Result recommendation, Result result) + : base(recommendation, result) + { + this.PackageId = packageId; + this.MessageType = messageType; + this.UIHint = dwUIHint; + this.Message = message; + this.Data = new ReadOnlyCollection(data ?? new string[] { }); + } + + /// + /// Gets the identity of the package that yielded this message. + /// + public string PackageId { get; private set; } + + /// + /// Gets the type of this message. + /// + public InstallMessage MessageType { get; private set; } + + /// + /// Gets the recommended display flags for this message. + /// + public int UIHint { get; private set; } + + /// + /// Gets the message. + /// + public string Message { get; private set; } + + /// + /// Gets the extended data for the message. + /// + public IList Data { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ExecuteFilesInUseEventArgs : ResultEventArgs + { + /// + public ExecuteFilesInUseEventArgs(string packageId, string[] files, Result recommendation, Result result) + : base(recommendation, result) + { + this.PackageId = packageId; + this.Files = new ReadOnlyCollection(files ?? new string[] { }); + } + + /// + /// Gets the identity of the package that yielded the files in use message. + /// + public string PackageId { get; private set; } + + /// + /// Gets the list of files in use. + /// + public IList Files { get; private set; } + } + + /// + /// Event arguments for + /// Additional arguments used when the engine has completed installing a specific package. + /// + [Serializable] + public class ExecutePackageCompleteEventArgs : ActionEventArgs + { + /// + public ExecutePackageCompleteEventArgs(string packageId, int hrStatus, ApplyRestart restart, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageId = packageId; + this.Restart = restart; + } + + /// + /// Gets the identity of the package that was acted on. + /// + public string PackageId { get; private set; } + + /// + /// Gets the package restart state after being applied. + /// + public ApplyRestart Restart { get; private set; } + } + + /// + /// Additional arguments used when the engine has completed installing packages. + /// + [Serializable] + public class ExecuteCompleteEventArgs : StatusEventArgs + { + /// + /// Creates a new instance of the class. + /// + /// The return code of the operation. + public ExecuteCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ApplyCompleteEventArgs : ActionEventArgs + { + /// + public ApplyCompleteEventArgs(int hrStatus, ApplyRestart restart, BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, BOOTSTRAPPER_APPLYCOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.Restart = restart; + } + + /// + /// Gets the apply restart state when complete. + /// + public ApplyRestart Restart { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheAcquireResolvingEventArgs : CancellableActionEventArgs + { + /// + public CacheAcquireResolvingEventArgs(string packageOrContainerId, string payloadId, string[] searchPaths, bool foundLocal, int recommendedSearchPath, string downloadUrl, string payloadContainerId, CacheResolveOperation recommendation, int chosenSearchPath, CacheResolveOperation action, bool cancel) + : base(cancel, recommendation, action) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + this.SearchPaths = searchPaths; + this.FoundLocal = foundLocal; + this.RecommendedSearchPath = recommendedSearchPath; + this.DownloadUrl = downloadUrl; + this.PayloadContainerId = payloadContainerId; + this.ChosenSearchPath = chosenSearchPath; + } + + /// + /// Gets the identity of the package or container that is being acquired. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identity of the payload that is being acquired. + /// + public string PayloadId { get; private set; } + + /// + /// Gets the search paths used for source resolution. + /// + public string[] SearchPaths { get; private set; } + + /// + /// Gets whether indicates that a file was found at that search path. + /// + public bool FoundLocal { get; private set; } + + /// + /// When is true, the index to for the recommended local file. + /// + public int RecommendedSearchPath { get; private set; } + + /// + /// Gets the optional URL to download container or payload. + /// + public string DownloadUrl { get; private set; } + + /// + /// Gets the optional identity of the container that contains the payload being acquired. + /// + public string PayloadContainerId { get; private set; } + + /// + /// Gets or sets the index to to use when is set to . + /// + public int ChosenSearchPath { get; set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CachePackageBeginEventArgs : CancellableHResultEventArgs + { + /// + public CachePackageBeginEventArgs(string packageId, int cachePayloads, long packageCacheSize, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.CachePayloads = cachePayloads; + this.PackageCacheSize = packageCacheSize; + } + + /// + /// Gets the identity of the package that is being cached. + /// + public string PackageId { get; private set; } + + /// + /// Gets number of payloads to be cached. + /// + public long CachePayloads { get; private set; } + + /// + /// Gets the size on disk required by the specific package. + /// + public long PackageCacheSize { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CachePackageCompleteEventArgs : ActionEventArgs + { + /// + public CachePackageCompleteEventArgs(string packageId, int hrStatus, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action) + : base(hrStatus, recommendation, action) + { + this.PackageId = packageId; + } + + /// + /// Gets the identity of the package that was cached. + /// + public string PackageId { get; private set; } + } + + /// + /// Event arguments for + /// + [Serializable] + public class ExecuteProgressEventArgs : CancellableHResultEventArgs + { + /// + public ExecuteProgressEventArgs(string packageId, int progressPercentage, int overallPercentage, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageId = packageId; + this.ProgressPercentage = progressPercentage; + this.OverallPercentage = overallPercentage; + } + + /// + /// Gets the identity of the package that was executed. + /// + public string PackageId { get; private set; } + + /// + /// Gets the percentage from 0 to 100 of the execution progress for a single payload. + /// + public int ProgressPercentage { get; private set; } + + /// + /// Gets the percentage from 0 to 100 of the execution progress for all payloads. + /// + public int OverallPercentage { get; private set; } + } + + /// + /// Additional arguments passed by the engine before it tries to launch the preapproved executable. + /// + [Serializable] + public class LaunchApprovedExeBeginEventArgs : CancellableHResultEventArgs + { + /// + /// + /// + /// + public LaunchApprovedExeBeginEventArgs(bool cancelRecommendation) + : base(cancelRecommendation) + { + } + } + + /// + /// Additional arguments passed by the engine after it finished trying to launch the preapproved executable. + /// + [Serializable] + public class LaunchApprovedExeCompleteEventArgs : StatusEventArgs + { + private int processId; + + /// + /// + /// + /// + /// + public LaunchApprovedExeCompleteEventArgs(int hrStatus, int processId) + : base(hrStatus) + { + this.processId = processId; + } + + /// + /// Gets the ProcessId of the process that was launched. + /// This is only valid if the status reports success. + /// + public int ProcessId + { + get { return this.processId; } + } + } + + /// + /// Additional arguments passed by the engine before beginning an MSI transaction. + /// + [Serializable] + public class BeginMsiTransactionBeginEventArgs : CancellableHResultEventArgs + { + private string transactionId; + + /// + /// + /// + /// + /// + public BeginMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine after beginning an MSI transaction. + /// + [Serializable] + public class BeginMsiTransactionCompleteEventArgs : StatusEventArgs + { + private string transactionId; + + /// + /// + /// + /// + /// + public BeginMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) + : base(hrStatus) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine before committing an MSI transaction. + /// + [Serializable] + public class CommitMsiTransactionBeginEventArgs : CancellableHResultEventArgs + { + private string transactionId; + + /// + /// + /// + /// + /// + public CommitMsiTransactionBeginEventArgs(string transactionId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine after committing an MSI transaction. + /// + [Serializable] + public class CommitMsiTransactionCompleteEventArgs : StatusEventArgs + { + private string transactionId; + + /// + /// + /// + /// + /// + public CommitMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) + : base(hrStatus) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine before rolling back an MSI transaction. + /// + [Serializable] + public class RollbackMsiTransactionBeginEventArgs : HResultEventArgs + { + private string transactionId; + + /// + /// + /// + /// + public RollbackMsiTransactionBeginEventArgs(string transactionId) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine after rolling back an MSI transaction. + /// + [Serializable] + public class RollbackMsiTransactionCompleteEventArgs : StatusEventArgs + { + private string transactionId; + + /// + /// + /// + /// + /// + public RollbackMsiTransactionCompleteEventArgs(string transactionId, int hrStatus) + : base(hrStatus) + { + this.transactionId = transactionId; + } + + /// + /// Gets the MSI transaction Id. + /// + public string TransactionId + { + get { return this.transactionId; } + } + } + + /// + /// Additional arguments passed by the engine before pausing Windows automatic updates. + /// + [Serializable] + public class PauseAutomaticUpdatesBeginEventArgs : HResultEventArgs + { + /// + /// + /// + public PauseAutomaticUpdatesBeginEventArgs() + { + } + } + + /// + /// Additional arguments passed by the engine after pausing Windows automatic updates. + /// + [Serializable] + public class PauseAutomaticUpdatesCompleteEventArgs : StatusEventArgs + { + /// + /// + /// + /// + public PauseAutomaticUpdatesCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// Additional arguments passed by the engine before taking a system restore point. + /// + [Serializable] + public class SystemRestorePointBeginEventArgs : HResultEventArgs + { + /// + /// + /// + public SystemRestorePointBeginEventArgs() + { + } + } + + /// + /// Additional arguments passed by the engine after taking a system restore point. + /// + [Serializable] + public class SystemRestorePointCompleteEventArgs : StatusEventArgs + { + /// + /// + /// + /// + public SystemRestorePointCompleteEventArgs(int hrStatus) + : base(hrStatus) + { + } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheContainerOrPayloadVerifyBeginEventArgs : CancellableHResultEventArgs + { + /// + public CacheContainerOrPayloadVerifyBeginEventArgs(string packageOrContainerId, string payloadId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CacheContainerOrPayloadVerifyProgressEventArgs : CacheProgressBaseEventArgs + { + /// + public CacheContainerOrPayloadVerifyProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(packageOrContainerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CacheContainerOrPayloadVerifyCompleteEventArgs : StatusEventArgs + { + /// + public CacheContainerOrPayloadVerifyCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus) + : base(hrStatus) + { + this.PackageOrContainerId = packageOrContainerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container or package. + /// + public string PackageOrContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CachePayloadExtractBeginEventArgs : CancellableHResultEventArgs + { + /// + public CachePayloadExtractBeginEventArgs(string containerId, string payloadId, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.ContainerId = containerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container. + /// + public string ContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } + + /// + /// EventArgs for . + /// + [Serializable] + public class CachePayloadExtractProgressEventArgs : CacheProgressBaseEventArgs + { + /// + public CachePayloadExtractProgressEventArgs(string containerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) + : base(containerId, payloadId, progress, total, overallPercentage, cancelRecommendation) + { + } + } + + /// + /// Event arguments for + /// + [Serializable] + public class CachePayloadExtractCompleteEventArgs : StatusEventArgs + { + /// + public CachePayloadExtractCompleteEventArgs(string containerId, string payloadId, int hrStatus) + : base(hrStatus) + { + this.ContainerId = containerId; + this.PayloadId = payloadId; + } + + /// + /// Gets the identifier of the container. + /// + public string ContainerId { get; private set; } + + /// + /// Gets the identifier of the payload. + /// + public string PayloadId { get; private set; } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs new file mode 100644 index 00000000..530fb1a9 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -0,0 +1,1917 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Allows customization of the bootstrapper application. + /// + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("53C31D56-49C0-426B-AB06-099D717C67FE")] + public interface IBootstrapperApplication + { + /// + /// Low level method that is called directly from the engine. + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int BAProc( + int message, + IntPtr pvArgs, + IntPtr pvResults, + IntPtr pvContext + ); + + /// + /// Low level method that is called directly from the engine. + /// + void BAProcFallback( + int message, + IntPtr pvArgs, + IntPtr pvResults, + ref int phr, + IntPtr pvContext + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnStartup(); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnSystemShutdown( + [MarshalAs(UnmanagedType.U4)] EndSessionReasons dwEndSession, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectBegin( + [MarshalAs(UnmanagedType.Bool)] bool fCached, + [MarshalAs(UnmanagedType.Bool)] bool fInstalled, + [MarshalAs(UnmanagedType.U4)] int cPackages, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectForwardCompatibleBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelationType relationType, + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectUpdateBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fSkip + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectUpdate( + [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, + [MarshalAs(UnmanagedType.U8)] long dw64Size, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.LPWStr)] string wzTitle, + [MarshalAs(UnmanagedType.LPWStr)] string wzSummary, + [MarshalAs(UnmanagedType.LPWStr)] string wzContentType, + [MarshalAs(UnmanagedType.LPWStr)] string wzContent, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fStopProcessingUpdates + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectUpdateComplete( + int hrStatus, + [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreError + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectRelatedBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelationType relationType, + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, + [MarshalAs(UnmanagedType.Bool)] bool fMissingFromCache, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectPackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectRelatedMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzUpgradeCode, + [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectPatchTarget( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, + [MarshalAs(UnmanagedType.U4)] PackageState patchState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectMsiFeature( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzFeatureId, + [MarshalAs(UnmanagedType.U4)] FeatureState state, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectPackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] PackageState state, + [MarshalAs(UnmanagedType.Bool)] bool fCached + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnDetectComplete( + int hrStatus, + [MarshalAs(UnmanagedType.Bool)] bool fEligibleForCleanup + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanBegin( + [MarshalAs(UnmanagedType.U4)] int cPackages, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanRelatedBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanPackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] PackageState state, + [MarshalAs(UnmanagedType.Bool)] bool fCached, + [MarshalAs(UnmanagedType.U4)] BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.U4)] ref BOOTSTRAPPER_CACHE_TYPE pRequestedCacheType, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanPatchTarget( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, + [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanMsiFeature( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzFeatureId, + [MarshalAs(UnmanagedType.U4)] FeatureState recommendedState, + [MarshalAs(UnmanagedType.U4)] ref FeatureState pRequestedState, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanMsiPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.Bool)] bool fExecute, + [MarshalAs(UnmanagedType.U4)] ActionState action, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.U4)] ref BURN_MSI_PROPERTY actionMsiProperty, + [MarshalAs(UnmanagedType.U4)] ref INSTALLUILEVEL uiLevel, + [MarshalAs(UnmanagedType.Bool)] ref bool fDisableExternalUiHandler + ); + + /// + /// See . + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanPackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] RequestState requested + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlannedPackage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] ActionState execute, + [MarshalAs(UnmanagedType.U4)] ActionState rollback, + [MarshalAs(UnmanagedType.Bool)] bool fPlannedCache, + [MarshalAs(UnmanagedType.Bool)] bool fPlannedUncache + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnApplyBegin( + [MarshalAs(UnmanagedType.U4)] int dwPhaseCount, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnElevateBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnElevateComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnProgress( + [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnError( + [MarshalAs(UnmanagedType.U4)] ErrorType errorType, + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int dwCode, + [MarshalAs(UnmanagedType.LPWStr)] string wzError, + [MarshalAs(UnmanagedType.I4)] int dwUIHint, + [MarshalAs(UnmanagedType.U4)] int cData, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzData, + [MarshalAs(UnmanagedType.I4)] Result nRecommendation, + [MarshalAs(UnmanagedType.I4)] ref Result pResult + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRegisterBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRegisterComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int cCachePayloads, + [MarshalAs(UnmanagedType.U8)] long dw64PackageCacheSize, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPWStr)] string wzSource, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, + [MarshalAs(UnmanagedType.U4)] CacheOperation recommendation, + [MarshalAs(UnmanagedType.I4)] ref CacheOperation action, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireResolving( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3, ArraySubType = UnmanagedType.LPWStr), In] string[] searchPaths, + [MarshalAs(UnmanagedType.U4)] int cSearchPaths, + [MarshalAs(UnmanagedType.Bool)] bool fFoundLocal, + [MarshalAs(UnmanagedType.U4)] int dwRecommendedSearchPath, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, + [MarshalAs(UnmanagedType.I4)] CacheResolveOperation recommendation, + [MarshalAs(UnmanagedType.U4)] ref int dwChosenSearchPath, + [MarshalAs(UnmanagedType.I4)] ref CacheResolveOperation action, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheAcquireComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus, + BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, + ref BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION pAction + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheVerifyBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheVerifyProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.I4)] CacheVerifyStep verifyStep, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheVerifyComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus, + BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, + ref BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION action + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, + ref BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteBegin( + [MarshalAs(UnmanagedType.U4)] int cExecutingPackages, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecutePackageBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.Bool)] bool fExecute, + [MarshalAs(UnmanagedType.U4)] ActionState action, + [MarshalAs(UnmanagedType.U4)] INSTALLUILEVEL uiLevel, + [MarshalAs(UnmanagedType.Bool)] bool fDisableExternalUiHandler, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecutePatchTarget( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzTargetProductCode, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteMsiMessage( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] InstallMessage messageType, + [MarshalAs(UnmanagedType.I4)] int dwUIHint, + [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, + [MarshalAs(UnmanagedType.U4)] int cData, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzData, + [MarshalAs(UnmanagedType.I4)] Result nRecommendation, + [MarshalAs(UnmanagedType.I4)] ref Result pResult + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteFilesInUse( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.U4)] int cFiles, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.LPWStr), In] string[] rgwzFiles, + [MarshalAs(UnmanagedType.I4)] Result nRecommendation, + [MarshalAs(UnmanagedType.I4)] ref Result pResult + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecutePackageComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + int hrStatus, + [MarshalAs(UnmanagedType.U4)] ApplyRestart restart, + [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, + [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION pAction + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnExecuteComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnUnregisterBegin( + [MarshalAs(UnmanagedType.Bool)] bool fKeepRegistration, + [MarshalAs(UnmanagedType.Bool)] ref bool fForceKeepRegistration + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnUnregisterComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnApplyComplete( + int hrStatus, + [MarshalAs(UnmanagedType.U4)] ApplyRestart restart, + [MarshalAs(UnmanagedType.I4)] BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, + [MarshalAs(UnmanagedType.I4)] ref BOOTSTRAPPER_APPLYCOMPLETE_ACTION pAction + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnLaunchApprovedExeBegin( + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnLaunchApprovedExeComplete( + int hrStatus, + int processId + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnBeginMsiTransactionBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnBeginMsiTransactionComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCommitMsiTransactionBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCommitMsiTransactionComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + int hrStatus + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRollbackMsiTransactionBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnRollbackMsiTransactionComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzTransactionId, + int hrStatus + ); + + /// + /// See . + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPauseAutomaticUpdatesBegin( + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPauseAutomaticUpdatesComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnSystemRestorePointBegin( + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnSystemRestorePointComplete( + int hrStatus + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanForwardCompatibleBundle( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelationType relationType, + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, + [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.Bool)] bool fRecommendedIgnoreBundle, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, + [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheContainerOrPayloadVerifyBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheContainerOrPayloadVerifyProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCacheContainerOrPayloadVerifyComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePayloadExtractBegin( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePayloadExtractProgress( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.U8)] long dw64Progress, + [MarshalAs(UnmanagedType.U8)] long dw64Total, + [MarshalAs(UnmanagedType.U4)] int dwOverallPercentage, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnCachePayloadExtractComplete( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + int hrStatus + ); + } + + /// + /// The display level for the BA. + /// + public enum Display + { + /// + /// + /// + Unknown, + + /// + /// + /// + Embedded, + + /// + /// + /// + None, + + /// + /// + /// + Passive, + + /// + /// + /// + Full, + } + + /// + /// Messages from Windows Installer (msi.h). + /// + public enum InstallMessage + { + /// + /// premature termination, possibly fatal OOM + /// + FatalExit, + + /// + /// formatted error message + /// + Error = 0x01000000, + + /// + /// formatted warning message + /// + Warning = 0x02000000, + + /// + /// user request message + /// + User = 0x03000000, + + /// + /// informative message for log + /// + Info = 0x04000000, + + /// + /// list of files in use that need to be replaced + /// + FilesInUse = 0x05000000, + + /// + /// request to determine a valid source location + /// + ResolveSource = 0x06000000, + + /// + /// insufficient disk space message + /// + OutOfDiskSpace = 0x07000000, + + /// + /// start of action: action name & description + /// + ActionStart = 0x08000000, + + /// + /// formatted data associated with individual action item + /// + ActionData = 0x09000000, + + /// + /// progress gauge info: units so far, total + /// + Progress = 0x0a000000, + + /// + /// product info for dialog: language Id, dialog caption + /// + CommonData = 0x0b000000, + + /// + /// sent prior to UI initialization, no string data + /// + Initialize = 0x0c000000, + + /// + /// sent after UI termination, no string data + /// + Terminate = 0x0d000000, + + /// + /// sent prior to display or authored dialog or wizard + /// + ShowDialog = 0x0e000000, + + /// + /// log only, to log performance number like action time + /// + Performance = 0x0f000000, + + /// + /// the list of apps that the user can request Restart Manager to shut down and restart + /// + RMFilesInUse = 0x19000000, + + /// + /// sent prior to server-side install of a product + /// + InstallStart = 0x1a000000, + + /// + /// sent after server-side install + /// + InstallEnd = 0x1B000000, + } + + /// + /// The action to perform when a reboot is necessary. + /// + public enum Restart + { + /// + /// + /// + Unknown, + + /// + /// + /// + Never, + + /// + /// + /// + Prompt, + + /// + /// + /// + Automatic, + + /// + /// + /// + Always, + } + + /// + /// Result codes (based on Dialog Box Command IDs from WinUser.h). + /// + public enum Result + { + /// + /// + /// + Error = -1, + + /// + /// + /// + None, + + /// + /// + /// + Ok, + + /// + /// + /// + Cancel, + + /// + /// + /// + Abort, + + /// + /// + /// + Retry, + + /// + /// + /// + Ignore, + + /// + /// + /// + Yes, + + /// + /// + /// + No, + + /// + /// / + /// + Close, + + /// + /// + /// + Help, + + /// + /// + /// + TryAgain, + + /// + /// + /// + Continue, + } + + /// + /// Describes why a bundle or packaged is being resumed. + /// + public enum ResumeType + { + /// + /// + /// + None, + + /// + /// Resume information exists but is invalid. + /// + Invalid, + + /// + /// The bundle was re-launched after an unexpected interruption. + /// + Interrupted, + + /// + /// A reboot is pending. + /// + RebootPending, + + /// + /// The bundle was re-launched after a reboot. + /// + Reboot, + + /// + /// The bundle was re-launched after being suspended. + /// + Suspend, + + /// + /// The bundle was launched from Add/Remove Programs. + /// + Arp, + } + + /// + /// Indicates what caused the error. + /// + public enum ErrorType + { + /// + /// The error occurred trying to elevate. + /// + Elevate, + + /// + /// The error came from the Windows Installer. + /// + WindowsInstaller, + + /// + /// The error came from an EXE Package. + /// + ExePackage, + + /// + /// The error came while trying to authenticate with an HTTP server. + /// + HttpServerAuthentication, + + /// + /// The error came while trying to authenticate with an HTTP proxy. + /// + HttpProxyAuthentication, + + /// + /// The error occurred during apply. + /// + Apply, + }; + + /// + /// The calculated operation for the related bundle. + /// + public enum RelatedOperation + { + /// + /// + /// + None, + + /// + /// The related bundle or package will be downgraded. + /// + Downgrade, + + /// + /// The related package will be upgraded as a minor revision. + /// + MinorUpdate, + + /// + /// The related bundle or package will be upgraded as a major revision. + /// + MajorUpgrade, + + /// + /// The related bundle will be removed. + /// + Remove, + + /// + /// The related bundle will be installed. + /// + Install, + + /// + /// The related bundle will be repaired. + /// + Repair, + }; + + /// + /// The cache operation used to acquire a container or payload. + /// + public enum CacheOperation + { + /// + /// There is no source available. + /// + None, + + /// + /// Copy the payload or container from the chosen local source. + /// + Copy, + + /// + /// Download the payload or container using the download URL. + /// + Download, + + /// + /// Extract the payload from the container. + /// + Extract, + } + + /// + /// The source to be used to acquire a container or payload. + /// + public enum CacheResolveOperation + { + /// + /// There is no source available. + /// + None, + + /// + /// Copy the payload or container from the chosen local source. + /// + Local, + + /// + /// Download the payload or container from the download URL. + /// + Download, + + /// + /// Extract the payload from the container. + /// + Container, + + /// + /// Look again for the payload or container locally. + /// + Retry, + } + + /// + /// The current step when verifying a container or payload. + /// + public enum CacheVerifyStep + { + /// + /// Copying or moving the file from the working path to the unverified path. + /// Not used during Layout. + /// + Stage, + /// + /// Hashing the file. + /// + Hash, + /// + /// Copying or moving the file to the final location. + /// + Finalize, + } + + /// + /// The restart state after a package or all packages were applied. + /// + public enum ApplyRestart + { + /// + /// Package or chain does not require a restart. + /// + None, + + /// + /// Package or chain requires a restart but it has not been initiated yet. + /// + RestartRequired, + + /// + /// Package or chain has already initiated the restart. + /// + RestartInitiated + } + + /// + /// The relation type for related bundles. + /// + public enum RelationType + { + /// + /// + /// + None, + + /// + /// + /// + Detect, + + /// + /// + /// + Upgrade, + + /// + /// + /// + Addon, + + /// + /// + /// + Patch, + + /// + /// + /// + Dependent, + + /// + /// + /// + Update, + } + + /// + /// One or more reasons why the application is requested to be closed or is being closed. + /// + [Flags] + public enum EndSessionReasons + { + /// + /// The system is shutting down or restarting (it is not possible to determine which event is occurring). + /// + Unknown, + + /// + /// The application is using a file that must be replaced, the system is being serviced, or system resources are exhausted. + /// + CloseApplication, + + /// + /// The application is forced to shut down. + /// + Critical = 0x40000000, + + /// + /// The user is logging off. + /// + Logoff = unchecked((int)0x80000000) + } + + /// + /// The available actions for . + /// + public enum 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 . + /// + Restart, + } + + /// + /// The cache strategy to be used for the package. + /// + public enum BOOTSTRAPPER_CACHE_TYPE + { + /// + /// The package will be cached in order to securely run the package, but will always be cleaned from the cache at the end. + /// + Remove, + + /// + /// The package will be cached in order to run the package, and then kept in the cache until the package is uninstalled. + /// + Keep, + + /// + /// The package will always be cached and stay in the cache, unless the package and bundle are both being uninstalled. + /// + Force, + } + + /// + /// The available actions for . + /// + public enum BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION + { + /// + /// + /// + None, + + /// + /// Instructs the engine to try the acquisition of the payload again. + /// Ignored if hrStatus is a success. + /// + Retry, + } + + /// + /// The available actions for . + /// + public enum 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. + /// + Ignore, + + /// + /// Instructs the engine to try the acquisition and verification of the package again. + /// Ignored if hrStatus is a success. + /// + Retry, + } + + /// + /// The available actions for . + /// + public enum BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION + { + /// + /// + /// + None, + + /// + /// Ignored if hrStatus is a success. + /// + RetryVerification, + + /// + /// Ignored if hrStatus is a success. + /// + RetryAcquisition, + } + + /// + /// The available actions for . + /// + public enum 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. + /// + Ignore, + + /// + /// Instructs the engine to try the execution of the package again. + /// Ignored if hrStatus is a success. + /// + Retry, + + /// + /// Instructs the engine to stop processing the chain and restart. + /// The engine will launch again after the machine is restarted. + /// + Restart, + + /// + /// Instructs the engine to stop processing the chain and suspend the current state. + /// + Suspend, + } + + /// + /// The result of evaluating a condition from a package. + /// + public enum BOOTSTRAPPER_PACKAGE_CONDITION_RESULT + { + /// + /// No condition was authored. + /// + Default, + + /// + /// Evaluated to false. + /// + False, + + /// + /// Evaluated to true. + /// + True, + } + + /// + /// The available actions for . + /// + public enum BOOTSTRAPPER_RESOLVESOURCE_ACTION + { + /// + /// Instructs the engine that the source can't be found. + /// + None, + + /// + /// Instructs the engine to try the local source again. + /// + Retry, + + /// + /// Instructs the engine to try the download source. + /// + Download, + } + + /// + /// The available actions for . + /// + public enum 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 . + /// + 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. + /// + ReloadBootstrapper, + + /// + /// Opts out of the engine behavior of trying to uninstall itself when no non-permanent packages are installed. + /// + SkipCleanup, + } + + /// + /// The property Burn will add so the MSI can know the planned action for the package. + /// + public enum BURN_MSI_PROPERTY + { + /// + /// No property will be added. + /// + None, + + /// + /// Add BURNMSIINSTALL=1 + /// + Install, + + /// + /// Add BURNMSIMODFIY=1 + /// + Modify, + + /// + /// Add BURNMSIREPAIR=1 + /// + Repair, + + /// + /// Add BURNMSIUNINSTALL=1 + /// + Uninstall, + } + + /// + /// From msi.h + /// https://docs.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msisetinternalui + /// + [Flags] + public enum INSTALLUILEVEL + { + /// + /// UI level is unchanged + /// + NoChange = 0, + + /// + /// default UI is used + /// + Default = 1, + + /// + /// completely silent installation + /// + None = 2, + + /// + /// simple progress and error handling + /// + Basic = 3, + + /// + /// authored UI, wizard dialogs suppressed + /// + Reduced = 4, + + /// + /// authored UI with wizards, progress, errors + /// + Full = 5, + + /// + /// display success/failure dialog at end of install + /// + EndDialog = 0x80, + + /// + /// display only progress dialog + /// + ProgressOnly = 0x40, + + /// + /// do not display the cancel button in basic UI + /// + HideCancel = 0x20, + + /// + /// force display of source resolution even if quiet + /// + SourceResOnly = 0x100, + + /// + /// show UAC prompt even if quiet + /// Can only be used if on Windows Installer 5.0 or later + /// + UacOnly = 0x200, + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationData.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationData.cs new file mode 100644 index 00000000..23a1c8a3 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationData.cs @@ -0,0 +1,22 @@ +// 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 +{ + using System.IO; + + /// + /// Interface for BootstrapperApplicationData.xml. + /// + public interface IBootstrapperApplicationData + { + /// + /// The BootstrapperApplicationData.xml file. + /// + FileInfo BADataFile { get; } + + /// + /// The BA manifest. + /// + IBundleInfo Bundle { get; } + } +} \ No newline at end of file diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs new file mode 100644 index 00000000..0f9193d0 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs @@ -0,0 +1,66 @@ +// 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 +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.InteropServices; + + /// + /// Interface used by WixToolset.Mba.Host to dynamically load the BA. + /// + [ComVisible(true)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("2965A12F-AC7B-43A0-85DF-E4B2168478A4")] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public interface IBootstrapperApplicationFactory + { + /// + /// Low level method called by the native host. + /// + /// + /// + 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; + [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; + 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, + this.restart, + 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)); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperCommand.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperCommand.cs new file mode 100644 index 00000000..e861813f --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperCommand.cs @@ -0,0 +1,76 @@ +// 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 +{ + using System; + + /// + /// Command information passed from the engine for the BA to perform. + /// + public interface IBootstrapperCommand + { + /// + /// Gets the action for the BA to perform. + /// + LaunchAction Action { get; } + + /// + /// Gets the display level for the BA. + /// + Display Display { get; } + + /// + /// Gets the action to perform if a reboot is required. + /// + Restart Restart { get; } + + /// + /// Gets the command line arguments as a string array. + /// + /// + /// Array of command line arguments not handled by the engine. + /// + /// The command line could not be parsed into an array. + string[] CommandLineArgs { get; } + + /// + /// Hint for the initial visibility of the window. + /// + int CmdShow { get; } + + /// + /// Gets the method of how the engine was resumed from a previous installation step. + /// + ResumeType Resume { get; } + + /// + /// Gets the handle to the splash screen window. If no splash screen was displayed this value will be IntPtr.Zero. + /// + IntPtr SplashScreen { get; } + + /// + /// If this was run from a related bundle, specifies the relation type. + /// + RelationType Relation { get; } + + /// + /// If this was run from a backward compatible bundle. + /// + bool Passthrough { get; } + + /// + /// Gets layout directory. + /// + string LayoutDirectory { get; } + + /// + /// Gets bootstrapper working folder. + /// + string BootstrapperWorkingFolder { get; } + + /// + /// Gets path to BootstrapperApplicationData.xml. + /// + string BootstrapperApplicationDataPath { get; } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs new file mode 100644 index 00000000..4e19bf0f --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -0,0 +1,536 @@ +// 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 +{ + using System; + using System.CodeDom.Compiler; + using System.Runtime.InteropServices; + using System.Text; + + /// + /// Allows calls into the bootstrapper engine. + /// + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("6480D616-27A0-44D7-905B-81512C29C2FB")] + [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] + public interface IBootstrapperEngine + { + /// + /// See . + /// + /// + void GetPackageCount( + [MarshalAs(UnmanagedType.U4)] out int pcPackages + ); + + /// + /// See . + /// + /// + /// + /// + [PreserveSig] + int GetVariableNumeric( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + out long pllValue + ); + + /// + /// See . + /// + [PreserveSig] + int GetVariableString( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + IntPtr wzValue, + ref IntPtr pcchValue + ); + + /// + /// See . + /// + [PreserveSig] + int GetVariableVersion( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + IntPtr wzValue, + ref IntPtr pcchValue + ); + + /// + /// See . + /// + [PreserveSig] + int FormatString( + [MarshalAs(UnmanagedType.LPWStr)] string wzIn, + [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, + ref IntPtr pcchOut + ); + + /// + /// See . + /// + [PreserveSig] + int EscapeString( + [MarshalAs(UnmanagedType.LPWStr)] string wzIn, + [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, + ref IntPtr pcchOut + ); + + /// + /// See . + /// + /// + /// + void EvaluateCondition( + [MarshalAs(UnmanagedType.LPWStr)] string wzCondition, + [MarshalAs(UnmanagedType.Bool)] out bool pf + ); + + /// + /// See . + /// + /// + /// + void Log( + [MarshalAs(UnmanagedType.U4)] LogLevel level, + [MarshalAs(UnmanagedType.LPWStr)] string wzMessage + ); + + /// + /// See . + /// + /// + /// + /// + /// + void SendEmbeddedError( + [MarshalAs(UnmanagedType.U4)] int dwErrorCode, + [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, + [MarshalAs(UnmanagedType.U4)] int dwUIHint, + [MarshalAs(UnmanagedType.I4)] out int pnResult + ); + + /// + /// See . + /// + /// + /// + /// + void SendEmbeddedProgress( + [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, + [MarshalAs(UnmanagedType.U4)] int dwOverallProgressPercentage, + [MarshalAs(UnmanagedType.I4)] out int pnResult + ); + + /// + /// 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.LPArray, SizeParamIndex=4)] byte[] rgbHash, + [MarshalAs(UnmanagedType.U4)] int cbHash + ); + + /// + /// See . + /// + /// + /// + /// + void SetLocalSource( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPath + ); + + /// + /// See . + /// + /// + /// + /// + /// + /// + void SetDownloadSource( + [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, + [MarshalAs(UnmanagedType.LPWStr)] string wzUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzUser, + [MarshalAs(UnmanagedType.LPWStr)] string wzPassword + ); + + /// + /// See . + /// + /// + /// + void SetVariableNumeric( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + long llValue + ); + + /// + /// See . + /// + /// + /// + /// + void SetVariableString( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + IntPtr wzValue, + [MarshalAs(UnmanagedType.Bool)] bool fFormatted + ); + + /// + /// See . + /// + /// + /// + void SetVariableVersion( + [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, + IntPtr wzValue + ); + + /// + /// See . + /// + void CloseSplashScreen(); + + /// + /// See . + /// + /// + void Detect( + IntPtr hwndParent + ); + + /// + /// See . + /// + /// + void Plan( + [MarshalAs(UnmanagedType.U4)] LaunchAction action + ); + + /// + /// See . + /// + /// + /// + [PreserveSig] + int Elevate( + IntPtr hwndParent + ); + + /// + /// See . + /// + /// + void Apply( + IntPtr hwndParent + ); + + /// + /// See . + /// + /// + void Quit( + [MarshalAs(UnmanagedType.U4)] int dwExitCode + ); + + /// + /// See . + /// + /// + /// + /// + /// + void LaunchApprovedExe( + IntPtr hwndParent, + [MarshalAs(UnmanagedType.LPWStr)] string wzApprovedExeForElevationId, + [MarshalAs(UnmanagedType.LPWStr)] string wzArguments, + [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout + ); + + /// + /// Sets the URL to the update feed. + /// + /// URL of the update feed. + void SetUpdateSource( + [MarshalAs(UnmanagedType.LPWStr)] string url + ); + + /// + /// See . + /// + /// + /// + /// + void CompareVersions( + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, + [MarshalAs(UnmanagedType.I4)] out int pnResult + ); + } + + /// + /// The installation action for the bundle or current package. + /// + public enum ActionState + { + /// + /// + /// + None, + + /// + /// + /// + Uninstall, + + /// + /// + /// + Install, + + /// + /// + /// + Modify, + + /// + /// + /// + Mend, + + /// + /// + /// + Repair, + + /// + /// + /// + MinorUpgrade, + } + + /// + /// The action for the BA to perform. + /// + public enum LaunchAction + { + /// + /// + /// + Unknown, + + /// + /// + /// + Help, + + /// + /// + /// + Layout, + + /// + /// + /// + Uninstall, + + /// + /// + /// + Cache, + + /// + /// + /// + Install, + + /// + /// + /// + Modify, + + /// + /// + /// + Repair, + + /// + /// + /// + UpdateReplace, + + /// + /// + /// + UpdateReplaceEmbedded, + } + + /// + /// The message log level. + /// + public enum LogLevel + { + /// + /// No logging level (generic). + /// + None, + + /// + /// User messages. + /// + Standard, + + /// + /// Verbose messages. + /// + Verbose, + + /// + /// Messages for debugging. + /// + Debug, + + /// + /// Error messages. + /// + Error, + } + + /// + /// Type of hash used for update bundle. + /// + public enum UpdateHashType + { + /// + /// No hash provided. + /// + None, + + /// + /// SHA-1 based hash provided. + /// + Sha1, + } + + /// + /// Describes the state of an installation package. + /// + public enum PackageState + { + /// + /// + /// + Unknown, + + /// + /// + /// + Obsolete, + + /// + /// + /// + Absent, + + /// + /// + /// + Cached, + + /// + /// + /// + Present, + + /// + /// + /// + Superseded, + } + + /// + /// Indicates the state desired for an installation package. + /// + public enum RequestState + { + /// + /// + /// + None, + + /// + /// / + /// + ForceAbsent, + + /// + /// + /// + Absent, + + /// + /// + /// + Cache, + + /// + /// + /// + Present, + + /// + /// + /// + Mend, + + /// + /// + /// + Repair, + } + + /// + /// Indicates the state of a feature. + /// + public enum FeatureState + { + /// + /// + /// + Unknown, + + /// + /// + /// + Absent, + + /// + /// + /// + Advertised, + + /// + /// + /// + Local, + + /// + /// + /// + Source, + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs b/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs new file mode 100644 index 00000000..f4a82f36 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs @@ -0,0 +1,39 @@ +// 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 +{ + using System.Collections.Generic; + + /// + /// BA manifest data. + /// + public interface IBundleInfo + { + /// + /// + /// + string LogVariable { get; } + + /// + /// + /// + string Name { get; } + + /// + /// + /// + IDictionary Packages { get; } + + /// + /// + /// + bool PerMachine { get; } + + /// + /// Adds a related bundle as a package. + /// + /// + /// The created . + IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); + } +} \ No newline at end of file diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs new file mode 100644 index 00000000..a295f6c0 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -0,0 +1,387 @@ +// 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 +{ + using System; + + /// + /// Interface for built-in implementation of . + /// + public interface IDefaultBootstrapperApplication : IBootstrapperApplication + { + /// + /// Fired when the engine has begun installing the bundle. + /// + event EventHandler ApplyBegin; + + /// + /// Fired when the engine has completed installing the bundle. + /// + event EventHandler ApplyComplete; + + /// + /// Fired when the engine is about to begin an MSI transaction. + /// + event EventHandler BeginMsiTransactionBegin; + + /// + /// Fired when the engine has completed beginning an MSI transaction. + /// + event EventHandler BeginMsiTransactionComplete; + + /// + /// Fired when the engine has begun acquiring the payload or container. + /// The BA can change the source using + /// or . + /// + event EventHandler CacheAcquireBegin; + + /// + /// Fired when the engine has completed the acquisition of the payload or container. + /// The BA can change the source using + /// or . + /// + event EventHandler CacheAcquireComplete; + + /// + /// Fired when the engine has progress acquiring the payload or container. + /// + event EventHandler CacheAcquireProgress; + + /// + /// Fired by the engine to allow the BA to override the acquisition action. + /// + event EventHandler CacheAcquireResolving; + + /// + /// Fired when the engine has begun caching the installation sources. + /// + event EventHandler CacheBegin; + + /// + /// Fired after the engine has cached the installation sources. + /// + event EventHandler CacheComplete; + + /// + /// Fired when the engine begins the verification of the payload or container that was already in the package cache. + /// + event EventHandler CacheContainerOrPayloadVerifyBegin; + + /// + /// Fired when the engine has completed the verification of the payload or container that was already in the package cache. + /// + event EventHandler CacheContainerOrPayloadVerifyComplete; + + /// + /// Fired when the engine has progress verifying the payload or container that was already in the package cache. + /// + event EventHandler CacheContainerOrPayloadVerifyProgress; + + /// + /// Fired when the engine has begun caching a specific package. + /// + event EventHandler CachePackageBegin; + + /// + /// Fired when the engine has completed caching a specific package. + /// + event EventHandler CachePackageComplete; + + /// + /// Fired when the engine begins the extraction of the payload from the container. + /// + event EventHandler CachePayloadExtractBegin; + + /// + /// Fired when the engine has completed the extraction of the payload from the container. + /// + event EventHandler CachePayloadExtractComplete; + + /// + /// Fired when the engine has progress extracting the payload from the container. + /// + event EventHandler CachePayloadExtractProgress; + + /// + /// Fired when the engine begins the verification of the acquired payload or container. + /// + event EventHandler CacheVerifyBegin; + + /// + /// Fired when the engine has completed the verification of the acquired payload or container. + /// + event EventHandler CacheVerifyComplete; + + /// + /// Fired when the engine has progress verifying the payload or container. + /// + event EventHandler CacheVerifyProgress; + + /// + /// Fired when the engine is about to commit an MSI transaction. + /// + event EventHandler CommitMsiTransactionBegin; + + /// + /// Fired when the engine has completed comitting an MSI transaction. + /// + event EventHandler CommitMsiTransactionComplete; + + /// + /// Fired when the overall detection phase has begun. + /// + event EventHandler DetectBegin; + + /// + /// Fired when the detection phase has completed. + /// + event EventHandler DetectComplete; + + /// + /// Fired when a forward compatible bundle is detected. + /// + event EventHandler DetectForwardCompatibleBundle; + + /// + /// Fired when a feature in an MSI package has been detected. + /// + event EventHandler DetectMsiFeature; + + /// + /// Fired when the detection for a specific package has begun. + /// + event EventHandler DetectPackageBegin; + + /// + /// Fired when the detection for a specific package has completed. + /// + event EventHandler DetectPackageComplete; + + /// + /// Fired when the engine detects a target product for an MSP package. + /// + event EventHandler DetectPatchTarget; + + /// + /// Fired when a related bundle has been detected for a bundle. + /// + event EventHandler DetectRelatedBundle; + + /// + /// Fired when a related MSI package has been detected for a package. + /// + event EventHandler DetectRelatedMsiPackage; + + /// + /// Fired when the update detection has found a potential update candidate. + /// + event EventHandler DetectUpdate; + + /// + /// Fired when the update detection phase has begun. + /// + event EventHandler DetectUpdateBegin; + + /// + /// Fired when the update detection phase has completed. + /// + event EventHandler DetectUpdateComplete; + + /// + /// Fired when the engine is about to start the elevated process. + /// + event EventHandler ElevateBegin; + + /// + /// Fired when the engine has completed starting the elevated process. + /// + event EventHandler ElevateComplete; + + /// + /// Fired when the engine has encountered an error. + /// + event EventHandler Error; + + /// + /// Fired when the engine has begun installing packages. + /// + event EventHandler ExecuteBegin; + + /// + /// Fired when the engine has completed installing packages. + /// + event EventHandler ExecuteComplete; + + /// + /// Fired when a package sends a files in use installation message. + /// + event EventHandler ExecuteFilesInUse; + + /// + /// Fired when Windows Installer sends an installation message. + /// + event EventHandler ExecuteMsiMessage; + + /// + /// Fired when the engine has begun installing a specific package. + /// + event EventHandler ExecutePackageBegin; + + /// + /// Fired when the engine has completed installing a specific package. + /// + event EventHandler ExecutePackageComplete; + + /// + /// Fired when the engine executes one or more patches targeting a product. + /// + event EventHandler ExecutePatchTarget; + + /// + /// Fired by the engine while executing a package. + /// + event EventHandler ExecuteProgress; + + /// + /// Fired when the engine is about to launch the preapproved executable. + /// + event EventHandler LaunchApprovedExeBegin; + + /// + /// Fired when the engine has completed launching the preapproved executable. + /// + event EventHandler LaunchApprovedExeComplete; + + /// + /// Fired when the engine is about to pause Windows automatic updates. + /// + event EventHandler PauseAutomaticUpdatesBegin; + + /// + /// Fired when the engine has completed pausing Windows automatic updates. + /// + event EventHandler PauseAutomaticUpdatesComplete; + + /// + /// Fired when the engine has begun planning the installation. + /// + event EventHandler PlanBegin; + + /// + /// Fired when the engine has completed planning the installation. + /// + event EventHandler PlanComplete; + + /// + /// Fired when the engine is about to plan a forward compatible bundle. + /// + event EventHandler PlanForwardCompatibleBundle; + + /// + /// Fired when the engine has completed planning a package. + /// + event EventHandler PlannedPackage; + + /// + /// Fired when the engine is about to plan a feature in an MSI package. + /// + event EventHandler PlanMsiFeature; + + /// + /// Fired when the engine is planning an MSI or MSP package. + /// + event EventHandler PlanMsiPackage; + + /// + /// Fired when the engine has begun getting the BA's input for planning a package. + /// + event EventHandler PlanPackageBegin; + + /// + /// Fired when the engine has completed getting the BA's input for planning a package. + /// + event EventHandler PlanPackageComplete; + + /// + /// Fired when the engine is about to plan a target of an MSP package. + /// + event EventHandler PlanPatchTarget; + + /// + /// Fired when the engine has begun planning for a related bundle. + /// + event EventHandler PlanRelatedBundle; + + /// + /// Fired when the engine has changed progress for the bundle installation. + /// + event EventHandler Progress; + + /// + /// Fired when the engine has begun registering the location and visibility of the bundle. + /// + event EventHandler RegisterBegin; + + /// + /// Fired when the engine has completed registering the location and visibility of the bundle. + /// + event EventHandler RegisterComplete; + + /// + /// Fired when the engine is about to rollback an MSI transaction. + /// + event EventHandler RollbackMsiTransactionBegin; + + /// + /// Fired when the engine has completed rolling back an MSI transaction. + /// + event EventHandler RollbackMsiTransactionComplete; + + /// + /// Fired when the engine is shutting down the bootstrapper application. + /// + event EventHandler Shutdown; + + /// + /// Fired when the engine is starting up the bootstrapper application. + /// + event EventHandler Startup; + + /// + /// Fired when the engine is about to take a system restore point. + /// + event EventHandler SystemRestorePointBegin; + + /// + /// Fired when the engine has completed taking a system restore point. + /// + event EventHandler SystemRestorePointComplete; + + /// + /// Fired when the system is shutting down or user is logging off. + /// + /// + /// To prevent shutting down or logging off, set to + /// true; otherwise, set it to false. + /// By default setup will prevent shutting down or logging off between + /// and . + /// Derivatives can change this behavior by handling . + /// If contains + /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + /// critical operations before being closed by the operating system. + /// This event may be fired on a different thread. + /// + event EventHandler SystemShutdown; + + /// + /// Fired when the engine unregisters the bundle. + /// + event EventHandler UnregisterBegin; + + /// + /// Fired when the engine unregistration is complete. + /// + event EventHandler UnregisterComplete; + } +} \ No newline at end of file diff --git a/src/api/burn/WixToolset.Mba.Core/IEngine.cs b/src/api/burn/WixToolset.Mba.Core/IEngine.cs new file mode 100644 index 00000000..3e636961 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IEngine.cs @@ -0,0 +1,222 @@ +// 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 +{ + using System; + using System.ComponentModel; + using System.Security; + + /// + /// High level abstraction over the interface. + /// + public interface IEngine + { + /// + /// Gets the number of packages in the bundle. + /// + int PackageCount { get; } + + /// + /// Install the packages. + /// + /// The parent window for the installation user interface. + void Apply(IntPtr hwndParent); + + /// + /// Close the splash screen if it is still open. Does nothing if the splash screen is not or + /// never was opened. + /// + void CloseSplashScreen(); + + /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 + int CompareVersions(string version1, string version2); + + /// + /// Checks if a variable exists in the engine. + /// + /// The name of the variable. + /// Whether the variable exists. + bool ContainsVariable(string name); + + /// + /// Determine if all installation conditions are fulfilled. + /// + void Detect(); + + /// + /// Determine if all installation conditions are fulfilled. + /// + /// The parent window for the installation user interface. + void Detect(IntPtr hwndParent); + + /// + /// Elevate the install. + /// + /// The parent window of the elevation dialog. + /// true if elevation succeeded; otherwise, false if the user cancelled. + /// A Win32 error occurred. + bool Elevate(IntPtr hwndParent); + + /// + /// Escapes the input string. + /// + /// The string to escape. + /// The escaped string. + /// A Win32 error occurred. + string EscapeString(string input); + + /// + /// Evaluates the string. + /// + /// The string representing the condition to evaluate. + /// Whether the condition evaluated to true or false. + bool EvaluateCondition(string condition); + + /// + /// Formats the input string. + /// + /// The string to format. + /// The formatted string. + /// A Win32 error occurred. + string FormatString(string format); + + /// + /// Gets numeric variables for the engine. + /// + /// The name of the variable. + long GetVariableNumeric(string name); + + /// + /// Gets string variables for the engine using SecureStrings. + /// + /// The name of the variable. + SecureString GetVariableSecureString(string name); + + /// + /// Gets string variables for the engine. + /// + /// The name of the variable. + string GetVariableString(string name); + + /// + /// Gets variables for the engine. + /// + /// The name of the variable. + string GetVariableVersion(string name); + + /// + /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. + /// + /// The parent window of the elevation dialog (if the engine hasn't elevated yet). + /// Id of the ApprovedExeForElevation element specified when the bundle was authored. + /// Optional arguments. + void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments); + + /// + /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. + /// + /// The parent window of the elevation dialog (if the engine hasn't elevated yet). + /// Id of the ApprovedExeForElevation element specified when the bundle was authored. + /// Optional arguments. + /// Timeout in milliseconds. When set to something other than zero, the engine will call WaitForInputIdle for the new process with this timeout before calling OnLaunchApprovedExeComplete. + void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments, int waitForInputIdleTimeout); + + /// + /// Logs the . + /// + /// The logging level. + /// The message to log. + void Log(LogLevel level, string message); + + /// + /// Determine the installation sequencing and costing. + /// + /// The action to perform when planning. + void Plan(LaunchAction action); + + /// + /// Set the update information for a bundle. + /// + /// Optional local source path for the update. Default is "update\[OriginalNameOfBundle].exe". + /// Optional download source for the update. + /// 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, byte[] hash); + + /// + /// Sets the URL to the update feed. + /// + /// URL of the update feed. + void SetUpdateSource(string url); + + /// + /// Set the local source for a package or container. + /// + /// The id that uniquely identifies the package or container. + /// The id that uniquely identifies the payload. + /// The new source path. + void SetLocalSource(string packageOrContainerId, string payloadId, string path); + + /// + /// Set the new download URL for a package or container. + /// + /// The id that uniquely identifies the package or container. + /// The id that uniquely identifies the payload. + /// The new url. + /// The user name for proxy authentication. + /// The password for proxy authentication. + void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password); + + /// + /// Sets numeric variables for the engine. + /// + /// The name of the variable. + /// The value to set. + void SetVariableNumeric(string name, long value); + + /// + /// Sets string variables for the engine using SecureStrings. + /// + /// The name of the variable. + /// The value to set. + /// False if the value is a literal string. + void SetVariableString(string name, SecureString value, bool formatted); + + /// + /// Sets string variables for the engine. + /// + /// The name of the variable. + /// The value to set. + /// False if the value is a literal string. + void SetVariableString(string name, string value, bool formatted); + + /// + /// Sets version variables for the engine. + /// + /// The name of the variable. + /// The value to set. + void SetVariableVersion(string name, string value); + + /// + /// Sends error message when embedded. + /// + /// Error code. + /// Error message. + /// UI buttons to show on error dialog. + int SendEmbeddedError(int errorCode, string message, int uiHint); + + /// + /// Sends progress percentages when embedded. + /// + /// Percentage completed thus far. + /// Overall percentage completed. + int SendEmbeddedProgress(int progressPercentage, int overallPercentage); + + /// + /// Shuts down the engine. + /// + /// Exit code indicating reason for shut down. + void Quit(int exitCode); + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/IPackageInfo.cs b/src/api/burn/WixToolset.Mba.Core/IPackageInfo.cs new file mode 100644 index 00000000..a1d99b10 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/IPackageInfo.cs @@ -0,0 +1,90 @@ +// 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 +{ + /// + /// Package information from the BA manifest. + /// + public interface IPackageInfo + { + /// + /// + /// + BOOTSTRAPPER_CACHE_TYPE CacheType { get; } + + /// + /// Place for the BA to store it's own custom data for this package. + /// + object CustomData { get; set; } + + /// + /// + /// + string Description { get; } + + /// + /// + /// + string DisplayInternalUICondition { get; } + + /// + /// + /// + string DisplayName { get; } + + /// + /// + /// + string Id { get; } + + /// + /// + /// + string InstallCondition { get; } + + /// + /// + /// + bool Permanent { get; } + + /// + /// + /// + bool PrereqPackage { get; } + + /// + /// + /// + string PrereqLicenseFile { get; } + + /// + /// + /// + string PrereqLicenseUrl { get; } + + /// + /// + /// + string ProductCode { get; } + + /// + /// + /// + PackageType Type { get; } + + /// + /// + /// + string UpgradeCode { get; } + + /// + /// + /// + string Version { get; } + + /// + /// + /// + bool Vital { get; } + } +} \ No newline at end of file diff --git a/src/api/burn/WixToolset.Mba.Core/NativeMethods.cs b/src/api/burn/WixToolset.Mba.Core/NativeMethods.cs new file mode 100644 index 00000000..adb2256e --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/NativeMethods.cs @@ -0,0 +1,37 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Contains native constants, functions, and structures for this assembly. + /// + internal static class NativeMethods + { + #region Error Constants + internal const int S_OK = 0; + internal const int E_MOREDATA = unchecked((int)0x800700ea); + internal const int E_INSUFFICIENT_BUFFER = unchecked((int)0x8007007a); + internal const int E_CANCELLED = unchecked((int)0x800704c7); + internal const int E_ALREADYINITIALIZED = unchecked((int)0x800704df); + internal const int E_NOTFOUND = unchecked((int)0x80070490); + internal const int E_NOTIMPL = unchecked((int)0x80004001); + internal const int E_UNEXPECTED = unchecked((int)0x8000ffff); + #endregion + + #region Functions + [DllImport("shell32.dll", ExactSpelling = true, SetLastError = true)] + internal static extern IntPtr CommandLineToArgvW( + [MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine, + out int pNumArgs + ); + + [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)] + internal static extern IntPtr LocalFree( + IntPtr hMem + ); + #endregion + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs b/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs new file mode 100644 index 00000000..567a7cdd --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/PackageInfo.cs @@ -0,0 +1,317 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.Xml; + using System.Xml.XPath; + + /// + /// + /// + public enum PackageType + { + /// + /// + /// + Unknown, + + /// + /// + /// + Exe, + + /// + /// + /// + Msi, + + /// + /// + /// + Msp, + + /// + /// + /// + Msu, + + /// + /// + /// + UpgradeBundle, + + /// + /// + /// + AddonBundle, + + /// + /// + /// + PatchBundle, + } + + /// + /// Default implementation of . + /// + public class PackageInfo : IPackageInfo + { + /// + public string Id { get; internal set; } + + /// + public string DisplayName { get; internal set; } + + /// + public string Description { get; internal set; } + + /// + public PackageType Type { get; internal set; } + + /// + public bool Permanent { get; internal set; } + + /// + public bool Vital { get; internal set; } + + /// + public string DisplayInternalUICondition { get; internal set; } + + /// + public string ProductCode { get; internal set; } + + /// + public string UpgradeCode { get; internal set; } + + /// + public string Version { get; internal set; } + + /// + public string InstallCondition { get; internal set; } + + /// + public BOOTSTRAPPER_CACHE_TYPE CacheType { get; internal set; } + + /// + public bool PrereqPackage { get; internal set; } + + /// + public string PrereqLicenseFile { get; internal set; } + + /// + public string PrereqLicenseUrl { get; internal set; } + + /// + public object CustomData { get; set; } + + internal PackageInfo() { } + + /// + /// + /// + /// + /// + public static IDictionary ParsePackagesFromXml(XPathNavigator root) + { + var packagesById = new Dictionary(); + XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); + namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); + XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); + + foreach (XPathNavigator node in nodes) + { + var package = new PackageInfo(); + + string id = BootstrapperApplicationData.GetAttribute(node, "Package"); + if (id == null) + { + throw new Exception("Failed to get package identifier for package."); + } + package.Id = id; + + package.DisplayName = BootstrapperApplicationData.GetAttribute(node, "DisplayName"); + + package.Description = BootstrapperApplicationData.GetAttribute(node, "Description"); + + PackageType? packageType = GetPackageTypeAttribute(node, "PackageType"); + if (!packageType.HasValue) + { + throw new Exception("Failed to get package type for package."); + } + package.Type = packageType.Value; + + bool? permanent = BootstrapperApplicationData.GetYesNoAttribute(node, "Permanent"); + if (!permanent.HasValue) + { + throw new Exception("Failed to get permanent settings for package."); + } + package.Permanent = permanent.Value; + + bool? vital = BootstrapperApplicationData.GetYesNoAttribute(node, "Vital"); + if (!vital.HasValue) + { + throw new Exception("Failed to get vital setting for package."); + } + package.Vital = vital.Value; + + package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); + + package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); + + package.Version = BootstrapperApplicationData.GetAttribute(node, "Version"); + + package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); + + packagesById.Add(package.Id, package); + } + + ParseBalPackageInfoFromXml(root, namespaceManager, packagesById); + return packagesById; + } + + /// + /// + /// + /// + /// + /// + public static BOOTSTRAPPER_CACHE_TYPE? GetCacheTypeAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + if (attributeValue.Equals("keep", StringComparison.InvariantCulture)) + { + return BOOTSTRAPPER_CACHE_TYPE.Keep; + } + else if (attributeValue.Equals("force", StringComparison.InvariantCulture)) + { + return BOOTSTRAPPER_CACHE_TYPE.Force; + } + else + { + return BOOTSTRAPPER_CACHE_TYPE.Remove; + } + } + + /// + /// + /// + /// + /// + /// + public static PackageType? GetPackageTypeAttribute(XPathNavigator node, string attributeName) + { + string attributeValue = BootstrapperApplicationData.GetAttribute(node, attributeName); + + if (attributeValue == null) + { + return null; + } + + if (attributeValue.Equals("Exe", StringComparison.InvariantCulture)) + { + return PackageType.Exe; + } + else if (attributeValue.Equals("Msi", StringComparison.InvariantCulture)) + { + return PackageType.Msi; + } + else if (attributeValue.Equals("Msp", StringComparison.InvariantCulture)) + { + return PackageType.Msp; + } + else if (attributeValue.Equals("Msu", StringComparison.InvariantCulture)) + { + return PackageType.Msu; + } + else + { + return PackageType.Unknown; + } + } + + /// + /// + /// + /// + /// + /// + /// + /// + public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, string version) + { + PackageInfo package = new PackageInfo(); + package.Id = id; + package.Version = version; + + switch (relationType) + { + case RelationType.Addon: + package.Type = PackageType.AddonBundle; + break; + case RelationType.Patch: + package.Type = PackageType.PatchBundle; + break; + case RelationType.Upgrade: + package.Type = PackageType.UpgradeBundle; + break; + default: + throw new Exception(string.Format("Unknown related bundle type: {0}", relationType)); + } + + return package; + } + + internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespaceManager namespaceManager, Dictionary packagesById) + { + XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixBalPackageInfo", namespaceManager); + + foreach (XPathNavigator node in nodes) + { + string id = BootstrapperApplicationData.GetAttribute(node, "PackageId"); + if (id == null) + { + throw new Exception("Failed to get package identifier for WixBalPackageInfo."); + } + + if (!packagesById.TryGetValue(id, out var ipackage)) + { + throw new Exception(string.Format("Failed to find package specified in WixBalPackageInfo: {0}", id)); + } + + var package = (PackageInfo)ipackage; + + package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition"); + } + + nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", 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."); + } + + if (!packagesById.TryGetValue(id, out var ipackage)) + { + throw new Exception(string.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id)); + } + + var package = (PackageInfo)ipackage; + + package.PrereqPackage = true; + package.PrereqLicenseFile = BootstrapperApplicationData.GetAttribute(node, "LicenseFile"); + package.PrereqLicenseUrl = BootstrapperApplicationData.GetAttribute(node, "LicenseUrl"); + } + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/VerUtil.cs b/src/api/burn/WixToolset.Mba.Core/VerUtil.cs new file mode 100644 index 00000000..81c5b716 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/VerUtil.cs @@ -0,0 +1,145 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + using System.Text; + + /// + /// Managed wrapper for verutil. + /// + public static class VerUtil + { + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern int VerCompareParsedVersions( + VersionHandle pVersion1, + VersionHandle pVersion2 + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern int VerCompareStringVersions( + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, + [MarshalAs(UnmanagedType.Bool)] bool fStrict + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern VersionHandle VerCopyVersion( + VersionHandle pSource + ); + + [DllImport("mbanative.dll", ExactSpelling = true)] + internal static extern void VerFreeVersion( + IntPtr pVersion + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern VersionHandle VerParseVersion( + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, + [MarshalAs(UnmanagedType.U4)] uint cchValue, + [MarshalAs(UnmanagedType.Bool)] bool fStrict + ); + + [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)] + internal static extern VersionHandle VerVersionFromQword( + [MarshalAs(UnmanagedType.I8)] long qwVersion + ); + + [StructLayout(LayoutKind.Sequential)] + internal struct VersionReleaseLabelStruct + { + public bool fNumeric; + public uint dwValue; + public IntPtr cchLabelOffset; + public int cchLabel; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct VersionStruct + { + public IntPtr sczVersion; + public uint dwMajor; + public uint dwMinor; + public uint dwPatch; + public uint dwRevision; + public int cReleaseLabels; + public IntPtr rgReleaseLabels; + public IntPtr cchMetadataOffset; + public bool fInvalid; + } + + internal static string VersionStringFromOffset(IntPtr wzVersion, IntPtr cchOffset, int? cchLength = null) + { + var offset = cchOffset.ToInt64() * UnicodeEncoding.CharSize; + var wz = new IntPtr(wzVersion.ToInt64() + offset); + if (cchLength.HasValue) + { + return Marshal.PtrToStringUni(wz, (int)cchLength); + } + else + { + return Marshal.PtrToStringUni(wz); + } + } + + internal sealed class VersionHandle : SafeHandle + { + public VersionHandle() : base(IntPtr.Zero, true) { } + + public override bool IsInvalid => false; + + protected override bool ReleaseHandle() + { + VerFreeVersion(this.handle); + return true; + } + } + + /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 + public static int CompareParsedVersions(VerUtilVersion version1, VerUtilVersion version2) + { + return VerCompareParsedVersions(version1.GetHandle(), version2.GetHandle()); + } + + /// 0 if equal, 1 if version1 > version2, -1 if version1 < version2 + public static int CompareStringVersions(string version1, string version2, bool strict) + { + return VerCompareStringVersions(version1, version2, strict); + } + + /// + /// + /// + /// + /// + public static VerUtilVersion CopyVersion(VerUtilVersion version) + { + var handle = VerCopyVersion(version.GetHandle()); + return new VerUtilVersion(handle); + } + + /// + /// + /// + /// + /// Whether to throw exception on invalid version. + /// + public static VerUtilVersion ParseVersion(string version, bool strict) + { + var handle = VerParseVersion(version, 0, strict); + return new VerUtilVersion(handle); + } + + /// + /// + /// + /// + /// + public static VerUtilVersion VersionFromQword(long version) + { + var handle = VerVersionFromQword(version); + return new VerUtilVersion(handle); + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/VerUtilVersion.cs b/src/api/burn/WixToolset.Mba.Core/VerUtilVersion.cs new file mode 100644 index 00000000..7408c26f --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/VerUtilVersion.cs @@ -0,0 +1,99 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + /// + /// An enhanced implementation of SemVer 2.0. + /// + public sealed class VerUtilVersion : IDisposable + { + internal VerUtilVersion(VerUtil.VersionHandle handle) + { + this.Handle = handle; + + var pVersion = handle.DangerousGetHandle(); + var version = (VerUtil.VersionStruct)Marshal.PtrToStructure(pVersion, typeof(VerUtil.VersionStruct)); + this.Version = Marshal.PtrToStringUni(version.sczVersion); + this.Major = version.dwMajor; + this.Minor = version.dwMinor; + this.Patch = version.dwPatch; + this.Revision = version.dwRevision; + this.ReleaseLabels = new VerUtilVersionReleaseLabel[version.cReleaseLabels]; + this.Metadata = VerUtil.VersionStringFromOffset(version.sczVersion, version.cchMetadataOffset); + this.IsInvalid = version.fInvalid; + + for (var i = 0; i < version.cReleaseLabels; ++i) + { + var offset = i * Marshal.SizeOf(typeof(VerUtil.VersionReleaseLabelStruct)); + var pReleaseLabel = new IntPtr(version.rgReleaseLabels.ToInt64() + offset); + this.ReleaseLabels[i] = new VerUtilVersionReleaseLabel(pReleaseLabel, version.sczVersion); + } + } + + /// + /// String version, which would have stripped the leading 'v'. + /// + public string Version { get; private set; } + + /// + /// For version A.B.C.D, Major is A. It is 0 if not specified. + /// + public uint Major { get; private set; } + + /// + /// For version A.B.C.D, Minor is B. It is 0 if not specified. + /// + public uint Minor { get; private set; } + + /// + /// For version A.B.C.D, Patch is C. It is 0 if not specified. + /// + public uint Patch { get; private set; } + + /// + /// For version A.B.C.D, Revision is D. It is 0 if not specified. + /// + public uint Revision { get; private set; } + + /// + /// For version X.Y.Z-releaselabels+metadata, ReleaseLabels is the parsed information for releaselabels. + /// + public VerUtilVersionReleaseLabel[] ReleaseLabels { get; private set; } + + /// + /// For version X.Y.Z-releaselabels+metadata, Metadata is the rest of the string after +. + /// For invalid versions, it is all of the string after the point where it was an invalid string. + /// + public string Metadata { get; private set; } + + /// + /// Whether the version conformed to the spec. + /// + public bool IsInvalid { get; private set; } + + /// + public void Dispose() + { + if (this.Handle != null) + { + this.Handle.Dispose(); + this.Handle = null; + } + } + + private VerUtil.VersionHandle Handle { get; set; } + + internal VerUtil.VersionHandle GetHandle() + { + if (this.Handle == null) + { + throw new ObjectDisposedException(this.Version); + } + + return this.Handle; + } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs b/src/api/burn/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs new file mode 100644 index 00000000..97e8190d --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/VerUtilVersionReleaseLabel.cs @@ -0,0 +1,36 @@ +// 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 +{ + using System; + using System.Runtime.InteropServices; + + /// + /// A release label from a . + /// + public sealed class VerUtilVersionReleaseLabel + { + internal VerUtilVersionReleaseLabel(IntPtr pReleaseLabel, IntPtr wzVersion) + { + var releaseLabel = (VerUtil.VersionReleaseLabelStruct)Marshal.PtrToStructure(pReleaseLabel, typeof(VerUtil.VersionReleaseLabelStruct)); + this.IsNumeric = releaseLabel.fNumeric; + this.Value = releaseLabel.dwValue; + this.Label = VerUtil.VersionStringFromOffset(wzVersion, releaseLabel.cchLabelOffset, releaseLabel.cchLabel); + } + + /// + /// Whether the label was parsed as a number. + /// + public bool IsNumeric { get; private set; } + + /// + /// If then the value that was parsed. + /// + public uint Value { get; private set; } + + /// + /// The string version of the label. + /// + public string Label { get; private set; } + } +} diff --git a/src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj new file mode 100644 index 00000000..2bd7ca80 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj @@ -0,0 +1,59 @@ + + + + + + netstandard2.0;net20 + WixToolset.Mba.Core + WixToolset.Mba.Core + embedded + Managed Bootstrapper Application Core + $(MSBuildThisFileName).nuspec + true + true + + + + + + + + + $(OutputPath) + $(MSBuildProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt + $(NCrunchOriginalProjectDir)..\..\build\obj\$(ProjectName)\$(Configuration)\NativeFileList.txt + + + + + + + + + + + + + + PreserveNewest + %(Filename)%(Extension) + + + + + + + + + + + + + + + + + + + + diff --git a/src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec new file mode 100644 index 00000000..a5e09ea9 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec @@ -0,0 +1,33 @@ + + + + $id$ + $version$ + $authors$ + $authors$ + MS-RL + https://github.com/wixtoolset/balutil + false + $description$ + $copyright$ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/api/burn/appveyor.cmd b/src/api/burn/appveyor.cmd new file mode 100644 index 00000000..26f75243 --- /dev/null +++ b/src/api/burn/appveyor.cmd @@ -0,0 +1,27 @@ +@setlocal +@pushd %~dp0 +@set _C=Release +@if /i "%1"=="debug" set _C=Debug + +nuget restore || exit /b + +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v140 || exit /b +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v140 || exit /b + +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v141 || exit /b +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v141 || exit /b +msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v141 || exit /b + +msbuild -p:Configuration=%_C%;Platform=x86;PlatformToolset=v142 || exit /b +msbuild -p:Configuration=%_C%;Platform=x64;PlatformToolset=v142 || exit /b +msbuild -p:Configuration=%_C%;Platform=ARM64;PlatformToolset=v142 || exit /b + +dotnet test -c %_C% --no-build src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj || exit /b + +msbuild -t:PackNative -p:Configuration=%_C% src\balutil\balutil.vcxproj || exit /b +msbuild -t:PackNative -p:Configuration=%_C% src\bextutil\bextutil.vcxproj || exit /b +msbuild -t:PackNative -p:Configuration=%_C% src\WixToolset.BootstrapperCore.Native\WixToolset.BootstrapperCore.Native.proj || exit /b +msbuild -t:Pack -p:Configuration=%_C% -p:NoBuild=true src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj || exit /b + +@popd +@endlocal \ No newline at end of file diff --git a/src/api/burn/appveyor.yml b/src/api/burn/appveyor.yml new file mode 100644 index 00000000..e4d25586 --- /dev/null +++ b/src/api/burn/appveyor.yml @@ -0,0 +1,42 @@ +# 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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +test: off + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/api/burn/balutil.sln b/src/api/burn/balutil.sln new file mode 100644 index 00000000..cae580f3 --- /dev/null +++ b/src/api/burn/balutil.sln @@ -0,0 +1,113 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29503.13 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balutil", "src\balutil\balutil.vcxproj", "{EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bextutil", "src\bextutil\bextutil.vcxproj", "{06027492-1CB9-48BC-B31E-C1F9356ED07E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Mba.Core", "src\WixToolset.Mba.Core\WixToolset.Mba.Core.csproj", "{E7E1841E-A58E-4901-B9CA-4845B807D45F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbanative", "src\mbanative\mbanative.vcxproj", "{665E0441-17F9-4105-B202-EDF274657F6E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Mba.Core", "src\test\WixToolsetTest.Mba.Core\WixToolsetTest.Mba.Core.csproj", "{F54997F7-10D7-409B-B9F2-DB546490EDC0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BalUtilUnitTest", "src\test\BalUtilUnitTest\BalUtilUnitTest.vcxproj", "{9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BextUtilUnitTest", "src\test\BextUtilUnitTest\BextUtilUnitTest.vcxproj", "{B69E6422-49B0-4E28-92F9-B8A7410A6ED9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|ARM64.Build.0 = Debug|ARM64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.ActiveCfg = Debug|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x64.Build.0 = Debug|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.ActiveCfg = Debug|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Debug|x86.Build.0 = Debug|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM64.ActiveCfg = Release|ARM64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|ARM64.Build.0 = Release|ARM64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.ActiveCfg = Release|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x64.Build.0 = Release|x64 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.ActiveCfg = Release|Win32 + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB}.Release|x86.Build.0 = Release|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|ARM64.Build.0 = Debug|ARM64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.ActiveCfg = Debug|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x64.Build.0 = Debug|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.ActiveCfg = Debug|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Debug|x86.Build.0 = Debug|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM64.ActiveCfg = Release|ARM64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|ARM64.Build.0 = Release|ARM64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.ActiveCfg = Release|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x64.Build.0 = Release|x64 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.ActiveCfg = Release|Win32 + {06027492-1CB9-48BC-B31E-C1F9356ED07E}.Release|x86.Build.0 = Release|Win32 + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|ARM64.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x64.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.ActiveCfg = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Debug|x86.Build.0 = Debug|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM64.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|ARM64.Build.0 = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x64.Build.0 = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.ActiveCfg = Release|Any CPU + {E7E1841E-A58E-4901-B9CA-4845B807D45F}.Release|x86.Build.0 = Release|Any CPU + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|ARM64.Build.0 = Debug|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.ActiveCfg = Debug|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x64.Build.0 = Debug|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.ActiveCfg = Debug|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Debug|x86.Build.0 = Debug|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM64.ActiveCfg = Release|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|ARM64.Build.0 = Release|ARM64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.ActiveCfg = Release|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x64.Build.0 = Release|x64 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.ActiveCfg = Release|Win32 + {665E0441-17F9-4105-B202-EDF274657F6E}.Release|x86.Build.0 = Release|Win32 + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|ARM64.Build.0 = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x64.Build.0 = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.ActiveCfg = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Debug|x86.Build.0 = Debug|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM64.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|ARM64.Build.0 = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x64.Build.0 = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.ActiveCfg = Release|Any CPU + {F54997F7-10D7-409B-B9F2-DB546490EDC0}.Release|x86.Build.0 = Release|Any CPU + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|ARM64.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x64.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x86.ActiveCfg = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Debug|x86.Build.0 = Debug|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|ARM64.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x64.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x86.ActiveCfg = Release|Win32 + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631}.Release|x86.Build.0 = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|ARM64.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x64.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x86.ActiveCfg = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Debug|x86.Build.0 = Debug|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|ARM64.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x64.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x86.ActiveCfg = Release|Win32 + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8741FA43-6BD2-40F9-ABA5-A5BD466A6518} + EndGlobalSection +EndGlobal diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp new file mode 100644 index 00000000..301b88a5 --- /dev/null +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp @@ -0,0 +1,629 @@ +// 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" + + +class CBalBootstrapperEngine : public IBootstrapperEngine +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBootstrapperEngine), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IMarshal, riid)) + { + return m_pFreeThreadedMarshaler->QueryInterface(riid, ppvObject); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = reinterpret_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBootstrapperEngine + virtual STDMETHODIMP GetPackageCount( + __out DWORD* pcPackages + ) + { + HRESULT hr = S_OK; + BAENGINE_GETPACKAGECOUNT_ARGS args = { }; + BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; + + ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required"); + + args.cbSize = sizeof(args); + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &args, &results, m_pvBAEngineProcContext); + + *pcPackages = results.cPackages; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableNumeric( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) + { + HRESULT hr = S_OK; + BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; + BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; + + ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); + + *pllValue = results.llValue; + + LExit: + SecureZeroMemory(&results, sizeof(results)); + return hr; + } + + virtual STDMETHODIMP GetVariableString( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) + { + HRESULT hr = S_OK; + BAENGINE_GETVARIABLESTRING_ARGS args = { }; + BAENGINE_GETVARIABLESTRING_RESULTS results = { }; + + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); + + *pcchValue = results.cchValue; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableVersion( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) + { + HRESULT hr = S_OK; + BAENGINE_GETVARIABLEVERSION_ARGS args = { }; + BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; + + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); + + *pcchValue = results.cchValue; + + LExit: + return hr; + } + + virtual STDMETHODIMP FormatString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T* pcchOut + ) + { + HRESULT hr = S_OK; + BAENGINE_FORMATSTRING_ARGS args = { }; + BAENGINE_FORMATSTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBAEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP EscapeString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T* pcchOut + ) + { + HRESULT hr = S_OK; + BAENGINE_ESCAPESTRING_ARGS args = { }; + BAENGINE_ESCAPESTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBAEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP EvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) + { + HRESULT hr = S_OK; + BAENGINE_EVALUATECONDITION_ARGS args = { }; + BAENGINE_EVALUATECONDITION_RESULTS results = { }; + + ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); + + args.cbSize = sizeof(args); + args.wzCondition = wzCondition; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBAEngineProcContext); + + *pf = results.f; + + LExit: + return hr; + } + + virtual STDMETHODIMP Log( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) + { + BAENGINE_LOG_ARGS args = { }; + BAENGINE_LOG_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.level = level; + args.wzMessage = wzMessage; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SendEmbeddedError( + __in DWORD dwErrorCode, + __in_z_opt LPCWSTR wzMessage, + __in DWORD dwUIHint, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; + BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.dwErrorCode = dwErrorCode; + args.wzMessage = wzMessage; + args.dwUIHint = dwUIHint; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &args, &results, m_pvBAEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + + virtual STDMETHODIMP SendEmbeddedProgress( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; + BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.dwProgressPercentage = dwProgressPercentage; + args.dwOverallProgressPercentage = dwOverallProgressPercentage; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &args, &results, m_pvBAEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + + virtual STDMETHODIMP SetUpdate( + __in_z_opt LPCWSTR wzLocalSource, + __in_z_opt LPCWSTR wzDownloadSource, + __in DWORD64 qwSize, + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, + __in_bcount_opt(cbHash) BYTE* rgbHash, + __in DWORD cbHash + ) + { + BAENGINE_SETUPDATE_ARGS args = { }; + BAENGINE_SETUPDATE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzLocalSource = wzLocalSource; + args.wzDownloadSource = wzDownloadSource; + args.qwSize = qwSize; + args.hashType = hashType; + args.rgbHash = rgbHash; + args.cbHash = cbHash; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetLocalSource( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzPath + ) + { + BAENGINE_SETLOCALSOURCE_ARGS args = { }; + BAENGINE_SETLOCALSOURCE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzPackageOrContainerId = wzPackageOrContainerId; + args.wzPayloadId = wzPayloadId; + args.wzPath = wzPath; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetDownloadSource( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzUrl, + __in_z_opt LPCWSTR wzUser, + __in_z_opt LPCWSTR wzPassword + ) + { + BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; + BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzPackageOrContainerId = wzPackageOrContainerId; + args.wzPayloadId = wzPayloadId; + args.wzUrl = wzUrl; + args.wzUser = wzUser; + args.wzPassword = wzPassword; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetVariableNumeric( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) + { + BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; + BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.llValue = llValue; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetVariableString( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted + ) + { + BAENGINE_SETVARIABLESTRING_ARGS args = { }; + BAENGINE_SETVARIABLESTRING_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + args.fFormatted = fFormatted; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetVariableVersion( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) + { + BAENGINE_SETVARIABLEVERSION_ARGS args = { }; + BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP CloseSplashScreen() + { + BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; + BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; + + args.cbSize = sizeof(args); + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Detect( + __in_opt HWND hwndParent + ) + { + BAENGINE_DETECT_ARGS args = { }; + BAENGINE_DETECT_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Plan( + __in BOOTSTRAPPER_ACTION action + ) + { + BAENGINE_PLAN_ARGS args = { }; + BAENGINE_PLAN_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.action = action; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Elevate( + __in_opt HWND hwndParent + ) + { + BAENGINE_ELEVATE_ARGS args = { }; + BAENGINE_ELEVATE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Apply( + __in HWND hwndParent + ) + { + BAENGINE_APPLY_ARGS args = { }; + BAENGINE_APPLY_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP Quit( + __in DWORD dwExitCode + ) + { + BAENGINE_QUIT_ARGS args = { }; + BAENGINE_QUIT_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.dwExitCode = dwExitCode; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP LaunchApprovedExe( + __in_opt HWND hwndParent, + __in_z LPCWSTR wzApprovedExeForElevationId, + __in_z_opt LPCWSTR wzArguments, + __in DWORD dwWaitForInputIdleTimeout + ) + { + BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; + BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.hwndParent = hwndParent; + args.wzApprovedExeForElevationId = wzApprovedExeForElevationId; + args.wzArguments = wzArguments; + args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP SetUpdateSource( + __in_z LPCWSTR wzUrl + ) + { + BAENGINE_SETUPDATESOURCE_ARGS args = { }; + BAENGINE_SETUPDATESOURCE_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzUrl = wzUrl; + + results.cbSize = sizeof(results); + + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &args, &results, m_pvBAEngineProcContext); + } + + virtual STDMETHODIMP CompareVersions( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BAENGINE_COMPAREVERSIONS_ARGS args = { }; + BAENGINE_COMPAREVERSIONS_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.wzVersion1 = wzVersion1; + args.wzVersion2 = wzVersion2; + + results.cbSize = sizeof(results); + + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBAEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + +public: + HRESULT Init() + { + return ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); + } + + CBalBootstrapperEngine( + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, + __in_opt LPVOID pvBAEngineProcContext + ) + { + m_cReferences = 1; + m_pfnBAEngineProc = pfnBAEngineProc; + m_pvBAEngineProcContext = pvBAEngineProcContext; + m_pFreeThreadedMarshaler = NULL; + } + + ~CBalBootstrapperEngine() + { + ReleaseObject(m_pFreeThreadedMarshaler); + } + +private: + long m_cReferences; + PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc; + LPVOID m_pvBAEngineProcContext; + IUnknown* m_pFreeThreadedMarshaler; +}; + +HRESULT BalBootstrapperEngineCreate( + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, + __in_opt LPVOID pvBAEngineProcContext, + __out IBootstrapperEngine** ppBootstrapperEngine + ) +{ + HRESULT hr = S_OK; + CBalBootstrapperEngine* pBootstrapperEngine = NULL; + + pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext); + ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); + + hr = pBootstrapperEngine->Init(); + ExitOnFailure(hr, "Failed to initialize CBalBootstrapperEngine."); + + hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); + ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); + +LExit: + ReleaseObject(pBootstrapperEngine); + return hr; +} diff --git a/src/api/burn/balutil/balcondition.cpp b/src/api/burn/balutil/balcondition.cpp new file mode 100644 index 00000000..8b05508f --- /dev/null +++ b/src/api/burn/balutil/balcondition.cpp @@ -0,0 +1,124 @@ +// 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" + +// prototypes + + +DAPI_(HRESULT) BalConditionsParseFromXml( + __in BAL_CONDITIONS* pConditions, + __in IXMLDOMDocument* pixdManifest, + __in_opt WIX_LOCALIZATION* pWixLoc + ) +{ + HRESULT hr = S_OK; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + BAL_CONDITION* prgConditions = NULL; + DWORD cConditions = 0; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalCondition", &pNodeList); + ExitOnFailure(hr, "Failed to select all conditions."); + + hr = pNodeList->get_length(reinterpret_cast(&cConditions)); + ExitOnFailure(hr, "Failed to get the condition count."); + + if (!cConditions) + { + ExitFunction(); + } + + prgConditions = static_cast(MemAlloc(sizeof(BAL_CONDITION) * cConditions, TRUE)); + ExitOnNull(prgConditions, hr, E_OUTOFMEMORY, "Failed to allocate memory for conditions."); + + DWORD iCondition = 0; + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"Condition", &prgConditions[iCondition].sczCondition); + ExitOnFailure(hr, "Failed to get condition for condition."); + + hr = XmlGetAttributeEx(pNode, L"Message", &prgConditions[iCondition].sczMessage); + ExitOnFailure(hr, "Failed to get message for condition."); + + if (pWixLoc && prgConditions[iCondition].sczMessage && *prgConditions[iCondition].sczMessage) + { + hr = LocLocalizeString(pWixLoc, &prgConditions[iCondition].sczMessage); + ExitOnFailure(hr, "Failed to localize condition message."); + } + + ++iCondition; + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all condition elements."); + + if (S_FALSE == hr) + { + hr = S_OK; + } + + pConditions->cConditions = cConditions; + pConditions->rgConditions = prgConditions; + prgConditions = NULL; + +LExit: + ReleaseMem(prgConditions); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + + return hr; +} + + +//the contents of psczMessage may be sensitive, should keep encrypted and SecureZeroFree +DAPI_(HRESULT) BalConditionEvaluate( + __in BAL_CONDITION* pCondition, + __in IBootstrapperEngine* pEngine, + __out BOOL* pfResult, + __out_z_opt LPWSTR* psczMessage + ) +{ + HRESULT hr = S_OK; + SIZE_T cchMessage = 0; + + hr = pEngine->EvaluateCondition(pCondition->sczCondition, pfResult); + ExitOnFailure(hr, "Failed to evaluate condition with bootstrapper engine."); + + if (psczMessage) + { + if (*psczMessage) + { + hr = StrMaxLength(*psczMessage, &cchMessage); + ExitOnFailure(hr, "Failed to get length of message."); + } + + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, &cchMessage); + if (E_MOREDATA == hr) + { + ++cchMessage; + + hr = StrAllocSecure(psczMessage, cchMessage); + ExitOnFailure(hr, "Failed to allocate string for condition's formatted message."); + + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, &cchMessage); + } + ExitOnFailure(hr, "Failed to format condition's message."); + } + +LExit: + return hr; +} + + +DAPI_(void) BalConditionsUninitialize( + __in BAL_CONDITIONS* pConditions + ) +{ + for (DWORD i = 0; i < pConditions->cConditions; ++i) + { + ReleaseStr(pConditions->rgConditions[i].sczMessage); + ReleaseStr(pConditions->rgConditions[i].sczCondition); + } + + ReleaseMem(pConditions->rgConditions); + memset(pConditions, 0, sizeof(BAL_CONDITIONS)); +} diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp new file mode 100644 index 00000000..3abb9286 --- /dev/null +++ b/src/api/burn/balutil/balinfo.cpp @@ -0,0 +1,373 @@ +// 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" + +// prototypes +static HRESULT ParsePackagesFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ); +static HRESULT ParseBalPackageInfoFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ); + + +DAPI_(HRESULT) BalInfoParseFromXml( + __in BAL_INFO_BUNDLE* pBundle, + __in IXMLDOMDocument* pixdManifest + ) +{ + HRESULT hr = S_OK; + IXMLDOMNode* pNode = NULL; + + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBundleProperties", &pNode); + ExitOnFailure(hr, "Failed to select bundle information."); + + if (S_OK == hr) + { + hr = XmlGetYesNoAttribute(pNode, L"PerMachine", &pBundle->fPerMachine); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to read bundle information per-machine."); + } + + hr = XmlGetAttributeEx(pNode, L"DisplayName", &pBundle->sczName); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to read bundle information display name."); + } + + hr = XmlGetAttributeEx(pNode, L"LogPathVariable", &pBundle->sczLogVariable); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to read bundle information log path variable."); + } + } + + hr = ParsePackagesFromXml(&pBundle->packages, pixdManifest); + BalExitOnFailure(hr, "Failed to parse package information from bootstrapper application data."); + + hr = ParseBalPackageInfoFromXml(&pBundle->packages, pixdManifest); + BalExitOnFailure(hr, "Failed to parse bal package information from bootstrapper application data."); + +LExit: + ReleaseObject(pNode); + + return hr; +} + + +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in BOOL /*fPerMachine*/, + __out_opt BAL_INFO_PACKAGE** ppPackage + ) +{ + HRESULT hr = S_OK; + BAL_INFO_PACKAGE_TYPE type = BAL_INFO_PACKAGE_TYPE_UNKNOWN; + BAL_INFO_PACKAGE* pPackage = NULL; + + // Ensure we have a supported relation type. + switch (relationType) + { + case BOOTSTRAPPER_RELATION_ADDON: + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON; + break; + + case BOOTSTRAPPER_RELATION_PATCH: + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH; + break; + + case BOOTSTRAPPER_RELATION_UPGRADE: + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE; + break; + + default: + ExitOnFailure(hr = E_INVALIDARG, "Unknown related bundle type: %u", relationType); + } + + // Check to see if the bundle is already in the list of packages. + for (DWORD i = 0; i < pPackages->cPackages; ++i) + { + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1)) + { + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)); + } + } + + // Add the related bundle as a package. + hr = MemEnsureArraySize(reinterpret_cast(&pPackages->rgPackages), pPackages->cPackages + 1, sizeof(BAL_INFO_PACKAGE), 2); + ExitOnFailure(hr, "Failed to allocate memory for related bundle package information."); + + pPackage = pPackages->rgPackages + pPackages->cPackages; + ++pPackages->cPackages; + + hr = StrAllocString(&pPackage->sczId, wzId, 0); + ExitOnFailure(hr, "Failed to copy related bundle package id."); + + pPackage->type = type; + + // TODO: try to look up the DisplayName and Description in Add/Remove Programs with the wzId. + + if (ppPackage) + { + *ppPackage = pPackage; + } + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalInfoFindPackageById( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __out BAL_INFO_PACKAGE** ppPackage + ) +{ + *ppPackage = NULL; + + for (DWORD i = 0; i < pPackages->cPackages; ++i) + { + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1)) + { + *ppPackage = pPackages->rgPackages + i; + break; + } + } + + return *ppPackage ? S_OK : E_NOTFOUND; +} + + +DAPI_(void) BalInfoUninitialize( + __in BAL_INFO_BUNDLE* pBundle + ) +{ + for (DWORD i = 0; i < pBundle->packages.cPackages; ++i) + { + ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayName); + ReleaseStr(pBundle->packages.rgPackages[i].sczDescription); + ReleaseStr(pBundle->packages.rgPackages[i].sczId); + ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayInternalUICondition); + ReleaseStr(pBundle->packages.rgPackages[i].sczProductCode); + ReleaseStr(pBundle->packages.rgPackages[i].sczUpgradeCode); + ReleaseStr(pBundle->packages.rgPackages[i].sczVersion); + ReleaseStr(pBundle->packages.rgPackages[i].sczInstallCondition); + ReleaseStr(pBundle->packages.rgPackages[i].sczPrereqLicenseFile); + ReleaseStr(pBundle->packages.rgPackages[i].sczPrereqLicenseUrl); + } + + ReleaseMem(pBundle->packages.rgPackages); + + ReleaseStr(pBundle->sczName); + ReleaseStr(pBundle->sczLogVariable); + memset(pBundle, 0, sizeof(BAL_INFO_BUNDLE)); +} + + +static HRESULT ParsePackagesFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ) +{ + HRESULT hr = S_OK; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + BAL_INFO_PACKAGE* prgPackages = NULL; + DWORD cPackages = 0; + LPWSTR scz = NULL; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPackageProperties", &pNodeList); + ExitOnFailure(hr, "Failed to select all packages."); + + hr = pNodeList->get_length(reinterpret_cast(&cPackages)); + ExitOnFailure(hr, "Failed to get the package count."); + + prgPackages = static_cast(MemAlloc(sizeof(BAL_INFO_PACKAGE) * cPackages, TRUE)); + ExitOnNull(prgPackages, hr, E_OUTOFMEMORY, "Failed to allocate memory for packages."); + + DWORD iPackage = 0; + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"Package", &prgPackages[iPackage].sczId); + ExitOnFailure(hr, "Failed to get package identifier for package."); + + hr = XmlGetAttributeEx(pNode, L"DisplayName", &prgPackages[iPackage].sczDisplayName); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get display name for package."); + } + + hr = XmlGetAttributeEx(pNode, L"Description", &prgPackages[iPackage].sczDescription); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get description for package."); + } + + hr = XmlGetAttributeEx(pNode, L"PackageType", &scz); + ExitOnFailure(hr, "Failed to get package type for package."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Exe", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_EXE; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msi", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSI; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msp", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSP; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msu", -1, scz, -1)) + { + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSU; + } + + hr = XmlGetYesNoAttribute(pNode, L"Permanent", &prgPackages[iPackage].fPermanent); + ExitOnFailure(hr, "Failed to get permanent setting for package."); + + hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital); + ExitOnFailure(hr, "Failed to get vital setting for package."); + + hr = XmlGetAttributeEx(pNode, L"ProductCode", &prgPackages[iPackage].sczProductCode); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get product code for package."); + } + + hr = XmlGetAttributeEx(pNode, L"UpgradeCode", &prgPackages[iPackage].sczUpgradeCode); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get upgrade code for package."); + } + + hr = XmlGetAttributeEx(pNode, L"Version", &prgPackages[iPackage].sczVersion); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get version for package."); + } + + hr = XmlGetAttributeEx(pNode, L"InstallCondition", &prgPackages[iPackage].sczInstallCondition); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get install condition for package."); + } + + hr = XmlGetAttributeEx(pNode, L"Cache", &scz); + ExitOnFailure(hr, "Failed to get cache type for package."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"remove", -1)) + { + prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_REMOVE; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"keep", -1)) + { + prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_KEEP; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"force", -1)) + { + prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_FORCE; + } + + ++iPackage; + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all package property elements."); + + if (S_FALSE == hr) + { + hr = S_OK; + } + + pPackages->cPackages = cPackages; + pPackages->rgPackages = prgPackages; + prgPackages = NULL; + +LExit: + ReleaseStr(scz); + ReleaseMem(prgPackages); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + + return hr; +} + + +static HRESULT ParseBalPackageInfoFromXml( + __in BAL_INFO_PACKAGES* pPackages, + __in IXMLDOMDocument* pixdManifest + ) +{ + HRESULT hr = S_OK; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + LPWSTR scz = NULL; + BAL_INFO_PACKAGE* pPackage = NULL; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalPackageInfo", &pNodeList); + ExitOnFailure(hr, "Failed to select all packages."); + + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); + ExitOnFailure(hr, "Failed to get package identifier for WixBalPackageInfo."); + + hr = BalInfoFindPackageById(pPackages, scz, &pPackage); + ExitOnFailure(hr, "Failed to find package specified in WixBalPackageInfo: %ls", scz); + + hr = XmlGetAttributeEx(pNode, L"DisplayInternalUICondition", &pPackage->sczDisplayInternalUICondition); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get DisplayInternalUICondition setting for package."); + } + + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all WixBalPackageInfo elements."); + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixMbaPrereqInformation", &pNodeList); + ExitOnFailure(hr, "Failed to select all packages."); + + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); + ExitOnFailure(hr, "Failed to get package identifier for WixMbaPrereqInformation."); + + hr = BalInfoFindPackageById(pPackages, scz, &pPackage); + ExitOnFailure(hr, "Failed to find package specified in WixMbaPrereqInformation: %ls", scz); + + pPackage->fPrereqPackage = TRUE; + + hr = XmlGetAttributeEx(pNode, L"LicenseFile", &pPackage->sczPrereqLicenseFile); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get LicenseFile setting for prereq package."); + } + + hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &pPackage->sczPrereqLicenseUrl); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to get LicenseUrl setting for prereq package."); + } + + ReleaseNullObject(pNode); + } + ExitOnFailure(hr, "Failed to parse all WixMbaPrereqInformation elements."); + + if (S_FALSE == hr) + { + hr = S_OK; + } + +LExit: + ReleaseStr(scz); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + + return hr; +} diff --git a/src/api/burn/balutil/balretry.cpp b/src/api/burn/balutil/balretry.cpp new file mode 100644 index 00000000..9d8abd6d --- /dev/null +++ b/src/api/burn/balutil/balretry.cpp @@ -0,0 +1,246 @@ +// 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" + +typedef enum BALRETRY_TYPE +{ + BALRETRY_TYPE_CACHE_CONTAINER, + BALRETRY_TYPE_CACHE_PAYLOAD, + BALRETRY_TYPE_EXECUTE, +} BALRETRY_TYPE; + +struct BALRETRY_INFO +{ + LPWSTR sczId; + DWORD cRetries; + DWORD dwLastError; +}; + +static DWORD vdwMaxRetries = 0; +static DWORD vdwTimeout = 0; +static BALRETRY_INFO vrgRetryInfo[3]; + +// prototypes +static BOOL IsActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId + ); + +static HRESULT StartActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId + ); + + +DAPI_(void) BalRetryInitialize( + __in DWORD dwMaxRetries, + __in DWORD dwTimeout + ) +{ + BalRetryUninitialize(); // clean everything out. + + vdwMaxRetries = dwMaxRetries; + vdwTimeout = dwTimeout; +} + + +DAPI_(void) BalRetryUninitialize() +{ + for (DWORD i = 0; i < countof(vrgRetryInfo); ++i) + { + ReleaseStr(vrgRetryInfo[i].sczId); + memset(vrgRetryInfo + i, 0, sizeof(BALRETRY_INFO)); + } + + vdwMaxRetries = 0; + vdwTimeout = 0; +} + + +DAPI_(void) BalRetryStartContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId + ) +{ + if (!wzContainerOrPackageId && !wzPayloadId) + { + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); + } + else if (wzPayloadId) + { + StartActiveRetryEntry(BALRETRY_TYPE_CACHE_PAYLOAD, wzPayloadId); + } + else + { + StartActiveRetryEntry(BALRETRY_TYPE_CACHE_CONTAINER, wzContainerOrPackageId); + } +} + + +DAPI_(void) BalRetryStartPackage( + __in_z LPCWSTR wzPackageId + ) +{ + StartActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId); +} + + +DAPI_(void) BalRetryErrorOccurred( + __in_z LPCWSTR wzPackageId, + __in DWORD dwError + ) +{ + if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId)) + { + vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; + } +} + + +DAPI_(HRESULT) BalRetryEndContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ) +{ + HRESULT hr = S_OK; + BALRETRY_TYPE type = BALRETRY_TYPE_CACHE_PAYLOAD; + LPCWSTR wzId = NULL; + + if (!wzContainerOrPackageId && !wzPayloadId) + { + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); + ExitFunction(); + } + else if (wzPayloadId) + { + type = BALRETRY_TYPE_CACHE_PAYLOAD; + wzId = wzPayloadId; + } + else + { + type = BALRETRY_TYPE_CACHE_CONTAINER; + wzId = wzContainerOrPackageId; + } + + if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzId)) + { + // Retry on all errors except the following. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && + BG_E_NETWORK_DISCONNECTED != hrError && + HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && + HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) + { + *pfRetry = TRUE; + } + } + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalRetryEndPackage( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ) +{ + HRESULT hr = S_OK; + BALRETRY_TYPE type = BALRETRY_TYPE_EXECUTE; + + if (!wzPackageId || !*wzPackageId) + { + ReleaseNullStr(vrgRetryInfo[type].sczId); + } + else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId)) + { + // If the service is out of whack, just try again. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) + { + *pfRetry = TRUE; + } + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) + { + DWORD dwError = vrgRetryInfo[type].dwLastError; + + // If we failed with one of these specific error codes, then retry since + // we've seen these have a high success of succeeding on retry. + if (1303 == dwError || + 1304 == dwError || + 1306 == dwError || + 1307 == dwError || + 1309 == dwError || + 1310 == dwError || + 1311 == dwError || + 1312 == dwError || + 1316 == dwError || + 1317 == dwError || + 1321 == dwError || + 1335 == dwError || + 1402 == dwError || + 1406 == dwError || + 1606 == dwError || + 1706 == dwError || + 1719 == dwError || + 1723 == dwError || + 1923 == dwError || + 1931 == dwError) + { + *pfRetry = TRUE; + } + } + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) + { + *pfRetry = TRUE; + } + } + + return hr; +} + + +// Internal functions. + +static BOOL IsActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId + ) +{ + BOOL fActive = FALSE; + + fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, sczId, -1, vrgRetryInfo[type].sczId, -1); + + return fActive; +} + +static HRESULT StartActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId + ) +{ + HRESULT hr = S_OK; + + if (!sczId || !*sczId) + { + ReleaseNullStr(vrgRetryInfo[type].sczId); + } + else if (IsActiveRetryEntry(type, sczId)) + { + ++vrgRetryInfo[type].cRetries; + ::Sleep(vdwTimeout); + } + else + { + hr = StrAllocString(&vrgRetryInfo[type].sczId, sczId, 0); + + vrgRetryInfo[type].cRetries = 0; + } + + vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; + + return hr; +} diff --git a/src/api/burn/balutil/balutil.cpp b/src/api/burn/balutil/balutil.cpp new file mode 100644 index 00000000..7a638219 --- /dev/null +++ b/src/api/burn/balutil/balutil.cpp @@ -0,0 +1,425 @@ +// 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" + +const DWORD VARIABLE_GROW_FACTOR = 80; +static IBootstrapperEngine* vpEngine = NULL; + +// prototypes + +DAPI_(void) BalInitialize( + __in IBootstrapperEngine* pEngine + ) +{ + pEngine->AddRef(); + + ReleaseObject(vpEngine); + vpEngine = pEngine; +} + +DAPI_(HRESULT) BalInitializeFromCreateArgs( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __out_opt IBootstrapperEngine** ppEngine + ) +{ + HRESULT hr = S_OK; + IBootstrapperEngine* pEngine = NULL; + + hr = BalBootstrapperEngineCreate(pArgs->pfnBootstrapperEngineProc, pArgs->pvBootstrapperEngineProcContext, &pEngine); + ExitOnFailure(hr, "Failed to create BalBootstrapperEngine."); + + BalInitialize(pEngine); + + if (ppEngine) + { + *ppEngine = pEngine; + } + pEngine = NULL; + +LExit: + ReleaseObject(pEngine); + + return hr; +} + + +DAPI_(void) BalUninitialize() +{ + ReleaseNullObject(vpEngine); +} + + +DAPI_(HRESULT) BalManifestLoad( + __in HMODULE hBootstrapperApplicationModule, + __out IXMLDOMDocument** ppixdManifest + ) +{ + HRESULT hr = S_OK; + LPWSTR sczPath = NULL; + + hr = PathRelativeToModule(&sczPath, BAL_MANIFEST_FILENAME, hBootstrapperApplicationModule); + ExitOnFailure(hr, "Failed to get path to bootstrapper application manifest: %ls", BAL_MANIFEST_FILENAME); + + hr = XmlLoadDocumentFromFile(sczPath, ppixdManifest); + ExitOnFailure(hr, "Failed to load bootstrapper application manifest '%ls' from path: %ls", BAL_MANIFEST_FILENAME, sczPath); + +LExit: + ReleaseStr(sczPath); + return hr; +} + + +DAPI_(HRESULT) BalEvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->EvaluateCondition(wzCondition, pf); + +LExit: + return hr; +} + + +// The contents of psczOut may be sensitive, should keep encrypted and SecureZeroFree. +DAPI_(HRESULT) BalFormatString( + __in_z LPCWSTR wzFormat, + __inout LPWSTR* psczOut + ) +{ + HRESULT hr = S_OK; + SIZE_T cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + if (*psczOut) + { + hr = StrMaxLength(*psczOut, &cch); + ExitOnFailure(hr, "Failed to determine length of value."); + } + + hr = vpEngine->FormatString(wzFormat, *psczOut, &cch); + if (E_MOREDATA == hr) + { + ++cch; + + hr = StrAllocSecure(psczOut, cch); + ExitOnFailure(hr, "Failed to allocate value."); + + hr = vpEngine->FormatString(wzFormat, *psczOut, &cch); + } + +LExit: + return hr; +} + + +// The contents of pllValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroMemory. +DAPI_(HRESULT) BalGetNumericVariable( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->GetVariableNumeric(wzVariable, pllValue); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalSetNumericVariable( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->SetVariableNumeric(wzVariable, llValue); + +LExit: + return hr; +} + + +DAPI_(BOOL) BalVariableExists( + __in_z LPCWSTR wzVariable + ) +{ + HRESULT hr = S_OK; + SIZE_T cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->GetVariableString(wzVariable, NULL, &cch); + +LExit: + return E_NOTFOUND != hr; +} + + +// The contents of psczValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroFree. +DAPI_(HRESULT) BalGetStringVariable( + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue + ) +{ + HRESULT hr = S_OK; + SIZE_T cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + if (*psczValue) + { + hr = StrMaxLength(*psczValue, &cch); + ExitOnFailure(hr, "Failed to determine length of value."); + } + + hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch); + if (E_MOREDATA == hr) + { + ++cch; + + hr = StrAllocSecure(psczValue, cch); + ExitOnFailure(hr, "Failed to allocate value."); + + hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch); + } + +LExit: + return hr; +} + +DAPI_(HRESULT) BalSetStringVariable( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted + ) +{ + HRESULT hr = S_OK; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = vpEngine->SetVariableString(wzVariable, wzValue, fFormatted); + +LExit: + return hr; +} + + +DAPIV_(HRESULT) BalLog( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BalLogArgs(level, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalLogArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + ExitOnFailure(hr, "Failed to format log string."); + + hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); + ExitOnFailure(hr, "Failed to convert log string to Unicode."); + + hr = vpEngine->Log(level, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} + + +DAPIV_(HRESULT) BalLogError( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BalLogErrorArgs(hrError, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BalLogErrorArgs( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + ExitOnFailure(hr, "Failed to format error log string."); + + hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); + ExitOnFailure(hr, "Failed to prepend error number to error log string."); + + hr = vpEngine->Log(BOOTSTRAPPER_LOG_LEVEL_ERROR, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} + +DAPIV_(HRESULT) BalLogId( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + va_start(args, hModule); + hr = BalLogIdArgs(level, dwLogId, hModule, args); + va_end(args); + +LExit: + return hr; +} + +DAPI_(HRESULT) BalLogIdArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + __in va_list args + ) +{ + + HRESULT hr = S_OK; + LPWSTR pwz = NULL; + DWORD cch = 0; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BalInitialize() must be called first."); + } + + // Get the string for the id. +#pragma prefast(push) +#pragma prefast(disable:25028) +#pragma prefast(disable:25068) + cch = ::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE, + static_cast(hModule), dwLogId, 0, reinterpret_cast(&pwz), 0, &args); +#pragma prefast(pop) + + if (0 == cch) + { + ExitOnLastError(hr, "Failed to log id: %d", dwLogId); + } + + if (2 <= cch && L'\r' == pwz[cch - 2] && L'\n' == pwz[cch - 1]) + { + pwz[cch - 2] = L'\0'; // remove newline from message table. + } + + hr = vpEngine->Log(level, pwz); + +LExit: + if (pwz) + { + ::LocalFree(pwz); + } + + return hr; +} diff --git a/src/api/burn/balutil/balutil.nuspec b/src/api/burn/balutil/balutil.nuspec new file mode 100644 index 00000000..e38362ec --- /dev/null +++ b/src/api/burn/balutil/balutil.nuspec @@ -0,0 +1,31 @@ + + + + $id$ + $version$ + $authors$ + $authors$ + MS-RL + https://github.com/wixtoolset/balutil + false + $description$ + $copyright$ + + + + + + + + + + + + + + + + + + + diff --git a/src/api/burn/balutil/balutil.vcxproj b/src/api/burn/balutil/balutil.vcxproj new file mode 100644 index 00000000..ab33f159 --- /dev/null +++ b/src/api/burn/balutil/balutil.vcxproj @@ -0,0 +1,101 @@ + + + + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} + StaticLibrary + balutil + v142 + MultiByte + WiX Toolset Bootstrapper Application Layer native utility library + WixToolset.BalUtil + + + + + + + + + + + + + + + $(ProjectDir)..\inc + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/src/api/burn/balutil/build/WixToolset.BalUtil.props b/src/api/burn/balutil/build/WixToolset.BalUtil.props new file mode 100644 index 00000000..45b97f6a --- /dev/null +++ b/src/api/burn/balutil/build/WixToolset.BalUtil.props @@ -0,0 +1,28 @@ + + + + + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + + + $(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + + + + $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + + + + $(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) + + + diff --git a/src/api/burn/balutil/inc/BAFunctions.h b/src/api/burn/balutil/inc/BAFunctions.h new file mode 100644 index 00000000..2970478f --- /dev/null +++ b/src/api/burn/balutil/inc/BAFunctions.h @@ -0,0 +1,147 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +// The first 1024 messages are reserved so that the BA messages have the same value here. +enum BA_FUNCTIONS_MESSAGE +{ + 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_ONSYSTEMSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN, + BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, + BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONDETECTPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, + BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, + BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, + BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONPLANPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, + BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, + BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, + BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, + BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, + BA_FUNCTIONS_MESSAGE_ONERROR = BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, + BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, + BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, + BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, + BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, + BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, + BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, + BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, + BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, + BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, + BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, + BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, + BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, + BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, + BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, + BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, + BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, + + BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, + BA_FUNCTIONS_MESSAGE_WNDPROC, +}; + +typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_PROC)( + __in BA_FUNCTIONS_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + +struct BA_FUNCTIONS_CREATE_ARGS +{ + DWORD cbSize; + DWORD64 qwBAFunctionsAPIVersion; + BOOTSTRAPPER_CREATE_ARGS* pBootstrapperCreateArgs; +}; + +struct BA_FUNCTIONS_CREATE_RESULTS +{ + DWORD cbSize; + PFN_BA_FUNCTIONS_PROC pfnBAFunctionsProc; + LPVOID pvBAFunctionsProcContext; +}; + +struct BA_FUNCTIONS_ONTHEMELOADED_ARGS +{ + DWORD cbSize; + THEME* pTheme; + WIX_LOCALIZATION* pWixLoc; +}; + +struct BA_FUNCTIONS_ONTHEMELOADED_RESULTS +{ + DWORD cbSize; +}; + +struct BA_FUNCTIONS_WNDPROC_ARGS +{ + DWORD cbSize; + THEME* pTheme; + HWND hWnd; + UINT uMsg; + WPARAM wParam; + LPARAM lParam; +}; + +struct BA_FUNCTIONS_WNDPROC_RESULTS +{ + DWORD cbSize; + LRESULT lres; +}; + +typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_CREATE)( + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ); + +typedef void (WINAPI *PFN_BA_FUNCTIONS_DESTROY)(); + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h new file mode 100644 index 00000000..ee2e452f --- /dev/null +++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h @@ -0,0 +1,867 @@ +#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 "dutil.h" +#include "locutil.h" +#include "thmutil.h" +#include "BAFunctions.h" +#include "IBAFunctions.h" +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +class CBalBaseBAFunctions : public IBAFunctions +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBAFunctions), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = static_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBootstrapperApplication + virtual STDMETHODIMP_(HRESULT) BAProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __inout HRESULT* /*phr*/, + __in_opt LPVOID /*pvContext*/ + ) + { + } + + virtual STDMETHODIMP OnStartup() + { + return S_OK; + } + + virtual STDMETHODIMP OnShutdown( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemShutdown( + __in DWORD /*dwEndSession*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, + __in BOOL /*fInstalled*/, + __in DWORD /*cPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOL /*fMissingFromCache*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateBegin( + __in_z LPCWSTR /*wzUpdateLocation*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfSkip*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdate( + __in_z LPCWSTR /*wzUpdateLocation*/, + __in DWORD64 /*dw64Size*/, + __in LPCWSTR /*wzVersion*/, + __in_z LPCWSTR /*wzTitle*/, + __in_z LPCWSTR /*wzSummary*/, + __in_z LPCWSTR /*wzContentType*/, + __in_z LPCWSTR /*wzContent*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfStopProcessingUpdates*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateComplete( + __in HRESULT /*hrStatus*/, + __inout BOOL* /*pfIgnoreError*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __in BOOL /*fMissingFromCache*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzUpgradeCode*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectPatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*state*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fCached*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectComplete( + __in HRESULT /*hrStatus*/, + __in BOOL /*fEligibleForCleanup*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanBegin( + __in DWORD /*cPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fCached*/, + __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT /*installCondition*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __in BOOTSTRAPPER_CACHE_TYPE /*recommendedCacheType*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, + __inout BOOTSTRAPPER_CACHE_TYPE* /*pRequestedCacheType*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanPatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOL /*fExecute*/, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __inout BOOL* /*pfCancel*/, + __inout BURN_MSI_PROPERTY* /*pActionMsiProperty*/, + __inout INSTALLUILEVEL* /*pUiLevel*/, + __inout BOOL* /*pfDisableExternalUiHandler*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlannedPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_ACTION_STATE /*execute*/, + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/, + __in BOOL /*fPlannedCache*/, + __in BOOL /*fPlannedUncache*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyBegin( + __in DWORD /*dwPhaseCount*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnElevateBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnElevateComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnProgress( + __in DWORD /*dwProgressPercentage*/, + __in DWORD /*dwOverallProgressPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return IDNOACTION; + } + + virtual STDMETHODIMP OnError( + __in BOOTSTRAPPER_ERROR_TYPE /*errorType*/, + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*dwCode*/, + __in_z LPCWSTR /*wzError*/, + __in DWORD /*dwUIHint*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* /*pResult*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRegisterBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRegisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cCachePayloads*/, + __in DWORD64 /*dw64PackageCacheSize*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireBegin( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in_z LPCWSTR /*wzSource*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, + __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireProgress( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireResolving( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in_z LPCWSTR* /*rgSearchPaths*/, + __in DWORD /*cSearchPaths*/, + __in BOOL /*fFoundLocal*/, + __in DWORD /*dwRecommendedSearchPath*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, + __inout DWORD* /*pdwChosenSearchPath*/, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireComplete( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyBegin( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __in BOOTSTRAPPER_CACHE_VERIFY_STEP /*verifyStep*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyComplete( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteBegin( + __in DWORD /*cExecutingPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOL /*fExecute*/, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __in INSTALLUILEVEL /*uiLevel*/, + __in BOOL /*fDisableExternalUiHandler*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecutePatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzTargetProductCode*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteProgress( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*dwProgressPercentage*/, + __in DWORD /*dwOverallProgressPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteMsiMessage( + __in_z LPCWSTR /*wzPackageId*/, + __in INSTALLMESSAGE /*messageType*/, + __in DWORD /*dwUIHint*/, + __in_z LPCWSTR /*wzMessage*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* /*pResult*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteFilesInUse( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cFiles*/, + __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, + __in int /*nRecommendation*/, + __inout int* /*pResult*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterBegin( + __in BOOL /*fKeepRegistration*/, + __inout BOOL* /*pfForceKeepRegistration*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyComplete( + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnLaunchApprovedExeBegin( + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnLaunchApprovedExeComplete( + __in HRESULT /*hrStatus*/, + __in DWORD /*dwProcessId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOL /*fRecommendedIgnoreBundle*/, + __inout BOOL* /*pfCancel*/, + __inout BOOL* /*pfIgnoreBundle*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + +public: // IBAFunctions + virtual STDMETHODIMP OnPlan( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnThemeLoaded( + THEME* pTheme, + WIX_LOCALIZATION* pWixLoc + ) + { + HRESULT hr = S_OK; + + m_pTheme = pTheme; + m_pWixLoc = pWixLoc; + + return hr; + } + + virtual STDMETHODIMP WndProc( + __in THEME* pTheme, + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam, + __inout LRESULT* plRes + ) + { + HRESULT hr = S_OK; + + *plRes = ThemeDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); + + return hr; + } + + virtual STDMETHODIMP BAFunctionsProc( + __in BA_FUNCTIONS_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + +protected: + CBalBaseBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs + ) + { + 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; + } + + virtual ~CBalBaseBAFunctions() + { + ReleaseNullObject(m_pEngine); + } + +private: + long m_cReferences; + +protected: + IBootstrapperEngine* m_pEngine; + HMODULE m_hModule; + BA_FUNCTIONS_CREATE_ARGS m_bafCreateArgs; + BOOTSTRAPPER_CREATE_ARGS m_baCreateArgs; + BOOTSTRAPPER_COMMAND m_command; + THEME* m_pTheme; + WIX_LOCALIZATION* m_pWixLoc; +}; diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h new file mode 100644 index 00000000..7e89fe83 --- /dev/null +++ b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h @@ -0,0 +1,124 @@ +#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->pTheme, pArgs->pWixLoc); +} + +static HRESULT BalBaseBAFunctionsProcWndProc( + __in IBAFunctions* pBAFunctions, + __in BA_FUNCTIONS_WNDPROC_ARGS* pArgs, + __inout BA_FUNCTIONS_WNDPROC_RESULTS* pResults + ) +{ + return pBAFunctions->WndProc(pArgs->pTheme, pArgs->hWnd, pArgs->uMsg, pArgs->wParam, pArgs->lParam, &pResults->lres); +} + +/******************************************************************* +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( + __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_ONSYSTEMSHUTDOWN: + 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: + 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; + } + } + + return hr; +} diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h new file mode 100644 index 00000000..bf21c4a5 --- /dev/null +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h @@ -0,0 +1,1076 @@ +// 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 "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +#include "balutil.h" +#include "balretry.h" + +class CBalBaseBootstrapperApplication : public IBootstrapperApplication +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = static_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBootstrapperApplication + virtual STDMETHODIMP_(HRESULT) BAProc( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __inout HRESULT* /*phr*/, + __in_opt LPVOID /*pvContext*/ + ) + { + } + + virtual STDMETHODIMP OnStartup() + { + return S_OK; + } + + virtual STDMETHODIMP OnShutdown( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemShutdown( + __in DWORD dwEndSession, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + + // Allow requests to shut down when critical or not applying. + *pfCancel = !(ENDSESSION_CRITICAL & dwEndSession || !m_fApplying); + + return hr; + } + + virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, + __in BOOL /*fInstalled*/, + __in DWORD /*cPackages*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOL /*fMissingFromCache*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateBegin( + __in_z LPCWSTR /*wzUpdateLocation*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfSkip*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdate( + __in_z LPCWSTR /*wzUpdateLocation*/, + __in DWORD64 /*dw64Size*/, + __in LPCWSTR /*wzVersion*/, + __in_z LPCWSTR /*wzTitle*/, + __in_z LPCWSTR /*wzSummary*/, + __in_z LPCWSTR /*wzContentType*/, + __in_z LPCWSTR /*wzContent*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfStopProcessingUpdates*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectUpdateComplete( + __in HRESULT /*hrStatus*/, + __inout BOOL* /*pfIgnoreError*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __in BOOL /*fMissingFromCache*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectRelatedMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzUpgradeCode*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectPatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*state*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnDetectPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fCached*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnDetectComplete( + __in HRESULT /*hrStatus*/, + __in BOOL /*fEligibleForCleanup*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanBegin( + __in DWORD /*cPackages*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanRelatedBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, + __in BOOL /*fCached*/, + __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT /*installCondition*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __in BOOTSTRAPPER_CACHE_TYPE /*recommendedCacheType*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, + __inout BOOTSTRAPPER_CACHE_TYPE* /*pRequestedCacheType*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanPatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanMsiFeature( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzFeatureId*/, + __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/, + __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanMsiPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOL /*fExecute*/, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __inout BOOL* pfCancel, + __inout BURN_MSI_PROPERTY* /*pActionMsiProperty*/, + __inout INSTALLUILEVEL* /*pUiLevel*/, + __inout BOOL* /*pfDisableExternalUiHandler*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnPlanPackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlannedPackage( + __in_z LPCWSTR /*wzPackageId*/, + __in BOOTSTRAPPER_ACTION_STATE /*execute*/, + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/, + __in BOOL /*fPlannedCache*/, + __in BOOL /*fPlannedUncache*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyBegin( + __in DWORD /*dwPhaseCount*/, + __inout BOOL* pfCancel + ) + { + m_fApplying = TRUE; + + m_dwProgressPercentage = 0; + m_dwOverallProgressPercentage = 0; + + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnElevateBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnElevateComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnProgress( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + m_dwProgressPercentage = dwProgressPercentage; + m_dwOverallProgressPercentage = dwOverallProgressPercentage; + + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded overall progress."); + + if (IDERROR == nResult) + { + hr = E_FAIL; + } + else if (IDCANCEL == nResult) + { + *pfCancel = TRUE; + } + } + + LExit: + *pfCancel |= CheckCanceled(); + return hr; + } + + virtual STDMETHODIMP OnError( + __in BOOTSTRAPPER_ERROR_TYPE errorType, + __in_z LPCWSTR wzPackageId, + __in DWORD dwCode, + __in_z LPCWSTR /*wzError*/, + __in DWORD /*dwUIHint*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* pResult + ) + { + BalRetryErrorOccurred(wzPackageId, dwCode); + + if (CheckCanceled()) + { + *pResult = IDCANCEL; + } + else if (BOOTSTRAPPER_DISPLAY_FULL == m_display) + { + if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType) + { + *pResult = IDTRYAGAIN; + } + } + + return S_OK; + } + + virtual STDMETHODIMP OnRegisterBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnRegisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCacheBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageBegin( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cCachePayloads*/, + __in DWORD64 /*dw64PackageCacheSize*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireBegin( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR /*wzSource*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, + __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, + __inout BOOL* pfCancel + ) + { + BalRetryStartContainerOrPayload(wzPackageOrContainerId, wzPayloadId); + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireProgress( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + // 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) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded cache progress."); + + if (IDERROR == nResult) + { + hr = E_FAIL; + } + else if (IDCANCEL == nResult) + { + *pfCancel = TRUE; + } + } + + LExit: + *pfCancel |= CheckCanceled(); + return hr; + } + + virtual STDMETHODIMP OnCacheAcquireResolving( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in_z LPCWSTR* /*rgSearchPaths*/, + __in DWORD /*cSearchPaths*/, + __in BOOL /*fFoundLocal*/, + __in DWORD /*dwRecommendedSearchPath*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, + __inout DWORD* /*pdwChosenSearchPath*/, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheAcquireComplete( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction + ) + { + HRESULT hr = S_OK; + BOOL fRetry = FALSE; + + if (CheckCanceled()) + { + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); + } + + hr = BalRetryEndContainerOrPayload(wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); + ExitOnFailure(hr, "BalRetryEndPackage for cache failed"); + + if (fRetry) + { + *pAction = BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY; + } + + LExit: + return hr; + } + + virtual STDMETHODIMP OnCacheVerifyBegin( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __in BOOTSTRAPPER_CACHE_VERIFY_STEP /*verifyStep*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheVerifyComplete( + __in_z LPCWSTR /*wzPackageOrContainerId*/, + __in_z LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction + ) + { + if (CheckCanceled()) + { + *pAction = BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_NONE; + } + + return S_OK; + } + + virtual STDMETHODIMP OnCachePackageComplete( + __in_z LPCWSTR /*wzPackageId*/, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction + ) + { + if (CheckCanceled()) + { + *pAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE; + } + + return S_OK; + } + + virtual STDMETHODIMP OnCacheComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnExecuteBegin( + __in DWORD /*cExecutingPackages*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageBegin( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, + __in BOOTSTRAPPER_ACTION_STATE /*action*/, + __in INSTALLUILEVEL /*uiLevel*/, + __in BOOL /*fDisableExternalUiHandler*/, + __inout BOOL* pfCancel + ) + { + // Only track retry on execution (not rollback). + if (fExecute) + { + BalRetryStartPackage(wzPackageId); + } + + m_fRollingBack = !fExecute; + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnExecutePatchTarget( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzTargetProductCode*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnExecuteProgress( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*dwProgressPercentage*/, + __in DWORD /*dwOverallProgressPercentage*/, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + // 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) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded execute progress."); + + if (IDERROR == nResult) + { + hr = E_FAIL; + } + else if (IDCANCEL == nResult) + { + *pfCancel = TRUE; + } + } + + LExit: + *pfCancel |= CheckCanceled(); + return hr; + } + + virtual STDMETHODIMP OnExecuteMsiMessage( + __in_z LPCWSTR /*wzPackageId*/, + __in INSTALLMESSAGE /*messageType*/, + __in DWORD /*dwUIHint*/, + __in_z LPCWSTR /*wzMessage*/, + __in DWORD /*cData*/, + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, + __in int /*nRecommendation*/, + __inout int* pResult + ) + { + if (CheckCanceled()) + { + *pResult = IDCANCEL; + } + + return S_OK; + } + + virtual STDMETHODIMP OnExecuteFilesInUse( + __in_z LPCWSTR /*wzPackageId*/, + __in DWORD /*cFiles*/, + __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, + __in int /*nRecommendation*/, + __inout int* pResult + ) + { + if (CheckCanceled()) + { + *pResult = IDCANCEL; + } + + return S_OK; + } + + virtual STDMETHODIMP OnExecutePackageComplete( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction + ) + { + HRESULT hr = S_OK; + BOOL fRetry = FALSE; + + if (CheckCanceled()) + { + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); + } + + hr = BalRetryEndPackage(wzPackageId, hrStatus, &fRetry); + ExitOnFailure(hr, "BalRetryEndPackage for execute failed"); + + if (fRetry) + { + *pAction = BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RETRY; + } + + LExit: + return hr; + } + + virtual STDMETHODIMP OnExecuteComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterBegin( + __in BOOL /*fKeepRegistration*/, + __inout BOOL* /*pfForceKeepRegistration*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnUnregisterComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnApplyComplete( + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_APPLY_RESTART restart, + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction + ) + { + HRESULT hr = S_OK; + BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart; + BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BOOTSTRAPPER_RESTART_PROMPT >= m_restart; + + if (fRestartRequired && !fShouldBlockRestart) + { + *pAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART; + } + + m_fApplying = FALSE; + + return hr; + } + + virtual STDMETHODIMP OnLaunchApprovedExeBegin( + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnLaunchApprovedExeComplete( + __in HRESULT /*hrStatus*/, + __in DWORD /*dwProcessId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnBeginMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCommitMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionBegin( + __in_z LPCWSTR /*wzTransactionId*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnRollbackMsiTransactionComplete( + __in_z LPCWSTR /*wzTransactionId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointBegin( + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnSystemRestorePointComplete( + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnPlanForwardCompatibleBundle( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, + __in_z LPCWSTR /*wzBundleTag*/, + __in BOOL /*fPerMachine*/, + __in LPCWSTR /*wzVersion*/, + __in BOOL /*fRecommendedIgnoreBundle*/, + __inout BOOL* pfCancel, + __inout BOOL* /*pfIgnoreBundle*/ + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractBegin( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractProgress( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in DWORD64 /*dw64Progress*/, + __in DWORD64 /*dw64Total*/, + __in DWORD /*dwOverallPercentage*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + + virtual STDMETHODIMP OnCachePayloadExtractComplete( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, + __in_z_opt LPCWSTR /*wzPayloadId*/, + __in HRESULT /*hrStatus*/ + ) + { + return S_OK; + } + +protected: + // + // PromptCancel - prompts the user to close (if not forced). + // + virtual BOOL PromptCancel( + __in HWND hWnd, + __in BOOL fForceCancel, + __in_z_opt LPCWSTR wzMessage, + __in_z_opt LPCWSTR wzCaption + ) + { + ::EnterCriticalSection(&m_csCanceled); + + // Only prompt the user to close if we have not canceled already. + if (!m_fCanceled) + { + if (fForceCancel) + { + m_fCanceled = TRUE; + } + else + { + m_fCanceled = (IDYES == ::MessageBoxW(hWnd, wzMessage, wzCaption, MB_YESNO | MB_ICONEXCLAMATION)); + } + } + + ::LeaveCriticalSection(&m_csCanceled); + + return m_fCanceled; + } + + // + // CheckCanceled - waits if the cancel dialog is up and checks to see if the user canceled the operation. + // + BOOL CheckCanceled() + { + ::EnterCriticalSection(&m_csCanceled); + ::LeaveCriticalSection(&m_csCanceled); + return m_fRollingBack ? FALSE : m_fCanceled; + } + + BOOL IsRollingBack() + { + return m_fRollingBack; + } + + BOOL IsCanceled() + { + return m_fCanceled; + } + + CBalBaseBootstrapperApplication( + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __in DWORD dwRetryCount = 0, + __in DWORD dwRetryTimeout = 1000 + ) + { + m_cReferences = 1; + m_display = pArgs->pCommand->display; + m_restart = pArgs->pCommand->restart; + + pEngine->AddRef(); + m_pEngine = pEngine; + + ::InitializeCriticalSection(&m_csCanceled); + m_fCanceled = FALSE; + m_fApplying = FALSE; + m_fRollingBack = FALSE; + + m_dwProgressPercentage = 0; + m_dwOverallProgressPercentage = 0; + + BalRetryInitialize(dwRetryCount, dwRetryTimeout); + } + + virtual ~CBalBaseBootstrapperApplication() + { + BalRetryUninitialize(); + ::DeleteCriticalSection(&m_csCanceled); + + ReleaseNullObject(m_pEngine); + } + +protected: + CRITICAL_SECTION m_csCanceled; + BOOL m_fCanceled; + +private: + long m_cReferences; + BOOTSTRAPPER_DISPLAY m_display; + BOOTSTRAPPER_RESTART m_restart; + IBootstrapperEngine* m_pEngine; + + BOOL m_fApplying; + BOOL m_fRollingBack; + + DWORD m_dwProgressPercentage; + DWORD m_dwOverallProgressPercentage; +}; diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h new file mode 100644 index 00000000..7fe3ffd8 --- /dev/null +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -0,0 +1,901 @@ +#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->fInstalled, 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 BalBaseBAProcOnSystemShutdown( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMSHUTDOWN_ARGS* pArgs, + __inout BA_ONSYSTEMSHUTDOWN_RESULTS* pResults + ) +{ + return pBA->OnSystemShutdown(pArgs->dwEndSession, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( + __in IBootstrapperApplication* pBA, + __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, + __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->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->operation, 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 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 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->recommendedState, pArgs->recommendedCacheType, &pResults->requestedState, &pResults->requestedCacheType, &pResults->fCancel); +} + +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 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(&pResults->fCancel); +} + +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, &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, &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 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->fKeepRegistration, &pResults->fForceKeepRegistration); +} + +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, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler); +} + +static HRESULT BalBaseBAProcOnBeginMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONBEGINMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBA->OnBeginMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnBeginMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnBeginMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnCommitMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS* pResults + ) +{ + return pBA->OnCommitMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); +} + +static HRESULT BalBaseBAProcOnCommitMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnRollbackMsiTransactionBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnRollbackMsiTransactionBegin(pArgs->wzTransactionId); +} + +static HRESULT BalBaseBAProcOnRollbackMsiTransactionComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS* pArgs, + __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS* /*pArgs*/, + __inout BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnPauseAutomaticUpdatesBegin(); +} + +static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS* pArgs, + __inout BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnPauseAutomaticUpdatesComplete(pArgs->hrStatus); +} + +static HRESULT BalBaseBAProcOnSystemRestorePointBegin( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS* /*pArgs*/, + __inout BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS* /*pResults*/ + ) +{ + return pBA->OnSystemRestorePointBegin(); +} + +static HRESULT BalBaseBAProcOnSystemRestorePointComplete( + __in IBootstrapperApplication* pBA, + __in BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS* pArgs, + __inout BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS* /*pResults*/ + ) +{ + return pBA->OnSystemRestorePointComplete(pArgs->hrStatus); +} + +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); +} + +/******************************************************************* +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_ONSYSTEMSHUTDOWN: + hr = BalBaseBAProcOnSystemShutdown(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: + hr = BalBaseBAProcOnDetectForwardCompatibleBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + 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; + } + } + + 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 new file mode 100644 index 00000000..45131d98 --- /dev/null +++ b/src/api/burn/balutil/inc/BalBootstrapperEngine.h @@ -0,0 +1,17 @@ +// 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 new file mode 100644 index 00000000..7d8a07fa --- /dev/null +++ b/src/api/burn/balutil/inc/IBAFunctions.h @@ -0,0 +1,34 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBAFunctions, IBootstrapperApplication, "0FB445ED-17BD-49C7-BE19-479776F8AE96") +{ + // OnThemeLoaded - Called after the BA finished loading all the controls for the theme. + // + STDMETHOD(OnThemeLoaded)( + THEME* pTheme, + WIX_LOCALIZATION* pWixLoc + ) = 0; + + // WndProc - Called if the BA hasn't handled the message. + // The implementation must either return E_NOTIMPL or call ThemeDefWindowProc for unhandled messages. + // + STDMETHOD(WndProc)( + __in THEME* pTheme, + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam, + __inout LRESULT* plRes + ) = 0; + + // BAFunctionsProc - The PFN_BA_FUNCTIONS_PROC can call this method to give the BAFunctions raw access to the callback from WixStdBA. + // This might be used to help the BAFunctions support more than one version of the engine/WixStdBA. + STDMETHOD(BAFunctionsProc)( + __in BA_FUNCTIONS_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; +}; diff --git a/src/api/burn/balutil/inc/IBootstrapperApplication.h b/src/api/burn/balutil/inc/IBootstrapperApplication.h new file mode 100644 index 00000000..c284cb49 --- /dev/null +++ b/src/api/burn/balutil/inc/IBootstrapperApplication.h @@ -0,0 +1,649 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-AB06-099D717C67FE") +{ + // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. + // This might be used to help the BA support more than one version of the engine. + STDMETHOD(BAProc)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; + + // BAProcFallback - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method + // to give the BA the ability to use default behavior + // and then forward the message to extensions. + STDMETHOD_(void, BAProcFallback)( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __inout HRESULT* phr, + __in_opt LPVOID pvContext + ) = 0; + + // OnStartup - called when the engine is ready for the bootstrapper application to start. + // + STDMETHOD(OnStartup)() = 0; + + // OnShutdown - called after the bootstrapper application quits the engine. + STDMETHOD(OnShutdown)( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction + ) = 0; + + // OnSystemShutdown - called when the operating system is instructed to shutdown the machine. + STDMETHOD(OnSystemShutdown)( + __in DWORD dwEndSession, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectBegin - called when the engine begins detection. + STDMETHOD(OnDetectBegin)( + __in BOOL fCached, + __in BOOL fInstalled, + __in DWORD cPackages, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectForwardCompatibleBundle - called when the engine detects a forward compatible bundle. + STDMETHOD(OnDetectForwardCompatibleBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in_z LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in_z LPCWSTR wzVersion, + __in BOOL fMissingFromCache, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectUpdateBegin - called when the engine begins detection for bundle update. + STDMETHOD(OnDetectUpdateBegin)( + __in_z LPCWSTR wzUpdateLocation, + __inout BOOL* pfCancel, + __inout BOOL* pfSkip + ) = 0; + + // OnDetectUpdate - called when the engine has an update candidate for bundle update. + STDMETHOD(OnDetectUpdate)( + __in_z_opt LPCWSTR wzUpdateLocation, + __in DWORD64 dw64Size, + __in_z LPCWSTR wzVersion, + __in_z_opt LPCWSTR wzTitle, + __in_z_opt LPCWSTR wzSummary, + __in_z_opt LPCWSTR wzContentType, + __in_z_opt LPCWSTR wzContent, + __inout BOOL* pfCancel, + __inout BOOL* pfStopProcessingUpdates + ) = 0; + + // OnDetectUpdateComplete - called when the engine completes detection for bundle update. + STDMETHOD(OnDetectUpdateComplete)( + __in HRESULT hrStatus, + __inout BOOL* pfIgnoreError + ) = 0; + + // OnDetectRelatedBundle - called when the engine detects a related bundle. + STDMETHOD(OnDetectRelatedBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in_z LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in_z LPCWSTR wzVersion, + __in BOOTSTRAPPER_RELATED_OPERATION operation, + __in BOOL fMissingFromCache, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectPackageBegin - called when the engine begins detecting a package. + STDMETHOD(OnDetectPackageBegin)( + __in_z LPCWSTR wzPackageId, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectRelatedMsiPackage - called when the engine begins detects a related package. + STDMETHOD(OnDetectRelatedMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzUpgradeCode, + __in_z LPCWSTR wzProductCode, + __in BOOL fPerMachine, + __in_z LPCWSTR wzVersion, + __in BOOTSTRAPPER_RELATED_OPERATION operation, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectPatchTarget - called when the engine detects a target product + // for an MSP package. + STDMETHOD(OnDetectPatchTarget)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzProductCode, + __in BOOTSTRAPPER_PACKAGE_STATE patchState, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectMsiFeature - called when the engine detects a feature in an MSI package. + STDMETHOD(OnDetectMsiFeature)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzFeatureId, + __in BOOTSTRAPPER_FEATURE_STATE state, + __inout BOOL* pfCancel + ) = 0; + + // OnDetectPackageComplete - called after the engine detects a package. + // + STDMETHOD(OnDetectPackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_PACKAGE_STATE state, + __in BOOL fCached + ) = 0; + + // OnDetectPackageComplete - called after the engine completes detection. + // + STDMETHOD(OnDetectComplete)( + __in HRESULT hrStatus, + __in BOOL fEligibleForCleanup + ) = 0; + + // OnPlanBegin - called when the engine begins planning. + STDMETHOD(OnPlanBegin)( + __in DWORD cPackages, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanRelatedBundle - called when the engine begins planning a related bundle. + STDMETHOD(OnPlanRelatedBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanPackageBegin - called when the engine has begun getting the BA's input + // for planning a package. + STDMETHOD(OnPlanPackageBegin)( + __in_z LPCWSTR wzPackageId, + __in BOOTSTRAPPER_PACKAGE_STATE state, + __in BOOL fCached, + __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __in BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOTSTRAPPER_CACHE_TYPE* pRequestedCacheType, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanPatchTarget - called when the engine is about to plan a target + // of an MSP package. + STDMETHOD(OnPlanPatchTarget)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzProductCode, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanMsiFeature - called when the engine plans a feature in an + // MSI package. + STDMETHOD(OnPlanMsiFeature)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzFeatureId, + __in BOOTSTRAPPER_FEATURE_STATE recommendedState, + __inout BOOTSTRAPPER_FEATURE_STATE* pRequestedState, + __inout BOOL* pfCancel + ) = 0; + + // OnPlanMsiPackage - called when the engine plans an MSI or MSP package. + // + STDMETHOD(OnPlanMsiPackage)( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, // false means rollback. + __in BOOTSTRAPPER_ACTION_STATE action, + __inout BOOL* pfCancel, + __inout BURN_MSI_PROPERTY* pActionMsiProperty, + __inout INSTALLUILEVEL* pUiLevel, + __inout BOOL* pfDisableExternalUiHandler + ) = 0; + + // OnPlanPackageComplete - called after the engine has completed getting the BA's input + // for planning a package. + STDMETHOD(OnPlanPackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_REQUEST_STATE requested + ) = 0; + + // OnPlannedPackage - called after the engine has completed planning a package. + STDMETHOD(OnPlannedPackage)( + __in_z LPCWSTR wzPackageId, + __in BOOTSTRAPPER_ACTION_STATE execute, + __in BOOTSTRAPPER_ACTION_STATE rollback, + __in BOOL fPlannedCache, + __in BOOL fPlannedUncache + ) = 0; + + // OnPlanComplete - called when the engine completes planning. + // + STDMETHOD(OnPlanComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnApplyBegin - called when the engine begins applying the plan. + // + STDMETHOD(OnApplyBegin)( + __in DWORD dwPhaseCount, + __inout BOOL* pfCancel + ) = 0; + + // OnElevateBegin - called before the engine displays an elevation prompt. + // Will only happen once per execution of the engine, + // assuming the elevation was successful. + STDMETHOD(OnElevateBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnElevateComplete - called after the engine attempted to elevate. + // + STDMETHOD(OnElevateComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnProgress - called when the engine makes progress. + // + STDMETHOD(OnProgress)( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + // OnError - called when the engine encounters an error. + // + // nResult: + // uiFlags is a combination of valid ID* return values appropriate for + // the error. + // + // IDNOACTION instructs the engine to pass the error through to default + // handling which usually results in the apply failing. + STDMETHOD(OnError)( + __in BOOTSTRAPPER_ERROR_TYPE errorType, + __in_z_opt LPCWSTR wzPackageId, + __in DWORD dwCode, + __in_z_opt LPCWSTR wzError, + __in DWORD dwUIHint, + __in DWORD cData, + __in_ecount_z_opt(cData) LPCWSTR* rgwzData, + __in int nRecommendation, + __inout int* pResult + ) = 0; + + // OnRegisterBegin - called when the engine registers the bundle. + // + STDMETHOD(OnRegisterBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnRegisterComplete - called when the engine registration is + // complete. + // + STDMETHOD(OnRegisterComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnCacheBegin - called when the engine begins caching. + // + STDMETHOD(OnCacheBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnCachePackageBegin - called when the engine begins caching + // a package. + // + STDMETHOD(OnCachePackageBegin)( + __in_z LPCWSTR wzPackageId, + __in DWORD cCachePayloads, + __in DWORD64 dw64PackageCacheSize, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireBegin - called when the engine begins acquiring a payload or container. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning. + // + STDMETHOD(OnCacheAcquireBegin)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzSource, + __in_z_opt LPCWSTR wzDownloadUrl, + __in_z_opt LPCWSTR wzPayloadContainerId, + __in BOOTSTRAPPER_CACHE_OPERATION recommendation, + __inout BOOTSTRAPPER_CACHE_OPERATION* pAction, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireProgress - called when the engine makes progress acquiring the payload or container. + // + STDMETHOD(OnCacheAcquireProgress)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireResolving - called to allow the BA to override the acquisition action for the payload or container. + // + // Parameters: + // wzPackageOrContainerId will be NULL when resolving a layout-only payload. + // wzPayloadId will be NULL when resolving a container. + // wzDownloadUrl will be NULL if the container or payload does not provide a DownloadURL. + // wzPayloadContainerId will not be NULL if acquiring a payload that is in a container. + // + // rgSearchPaths are the search paths used for source resolution. + // fFoundLocal is TRUE when dwRecommendedSearchPath indicates that the file was found. + // dwRecommendedSearchPath is the index into rgSearchPaths for the recommended local file. + // + STDMETHOD(OnCacheAcquireResolving)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR* rgSearchPaths, + __in DWORD cSearchPaths, + __in BOOL fFoundLocal, + __in DWORD dwRecommendedSearchPath, + __in_z_opt LPCWSTR wzDownloadUrl, + __in_z_opt LPCWSTR wzPayloadContainerId, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION recommendation, + __inout DWORD* pdwChosenSearchPath, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* pAction, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheAcquireComplete - called after the engine acquired the payload or container. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY. + // + STDMETHOD(OnCacheAcquireComplete)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction + ) = 0; + + // OnCacheVerifyBegin - called when the engine begins to verify then copy + // a payload or container to the package cache folder. + // + STDMETHOD(OnCacheVerifyBegin)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCacheVerifyProgress)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __in BOOTSTRAPPER_CACHE_VERIFY_STEP verifyStep, + __inout BOOL* pfCancel + ) = 0; + + // OnCacheVerifyComplete - called after the engine verifies and copies + // a payload or container to the package cache folder. + // + STDMETHOD(OnCacheVerifyComplete)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction + ) = 0; + + // OnCachePackageComplete - called after the engine attempts to copy or download all + // payloads of a package into the package cache folder. + // + STDMETHOD(OnCachePackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction + ) = 0; + + // OnCacheComplete - called when the engine caching is complete. + // + STDMETHOD(OnCacheComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnExecuteBegin - called when the engine begins executing the plan. + // + STDMETHOD(OnExecuteBegin)( + __in DWORD cExecutingPackages, + __inout BOOL* pfCancel + ) = 0; + + // OnExecutePackageBegin - called when the engine begins executing a package. + // + STDMETHOD(OnExecutePackageBegin)( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, // false means rollback. + __in BOOTSTRAPPER_ACTION_STATE action, + __in INSTALLUILEVEL uiLevel, + __in BOOL fDisableExternalUiHandler, + __inout BOOL* pfCancel + ) = 0; + + // OnExecutePatchTarget - called for each patch in an MspPackage targeting the product + // when the engine begins executing the MspPackage. + // + STDMETHOD(OnExecutePatchTarget)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzTargetProductCode, + __inout BOOL* pfCancel + ) = 0; + + // OnExecuteProgress - called when the engine makes progress executing a package. + // + STDMETHOD(OnExecuteProgress)( + __in_z LPCWSTR wzPackageId, + __in DWORD dwProgressPercentage, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + // OnExecuteMsiMessage - called when the engine receives an MSI package message. + // + // Return: + // uiFlags is a combination of valid ID* return values appropriate for + // the message. + // + // IDNOACTION instructs the engine to pass the message through to default + // handling which usually results in the execution continuing. + STDMETHOD(OnExecuteMsiMessage)( + __in_z LPCWSTR wzPackageId, + __in INSTALLMESSAGE messageType, + __in DWORD dwUIHint, + __in_z LPCWSTR wzMessage, + __in DWORD cData, + __in_ecount_z_opt(cData) LPCWSTR* rgwzData, + __in int nRecommendation, + __inout int* pResult + ) = 0; + + // OnExecuteFilesInUse - called when the engine encounters files in use while + // executing a package. + // + // Return: + // IDOK instructs the engine to let the Restart Manager attempt to close the + // applications to avoid a restart. + // + // IDCANCEL instructs the engine to abort the execution and start rollback. + // + // IDIGNORE instructs the engine to ignore the running applications. A restart will be + // required. + // + // IDRETRY instructs the engine to check if the applications are still running again. + // + // IDNOACTION is equivalent to ignoring the running applications. A restart will be + // required. + STDMETHOD(OnExecuteFilesInUse)( + __in_z LPCWSTR wzPackageId, + __in DWORD cFiles, + __in_ecount_z(cFiles) LPCWSTR* rgwzFiles, + __in int nRecommendation, + __inout int* pResult + ) = 0; + + // OnExecutePackageComplete - called when a package execution is complete. + // + STDMETHOD(OnExecutePackageComplete)( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_APPLY_RESTART restart, + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction + ) = 0; + + // OnExecuteComplete - called when the engine execution is complete. + // + STDMETHOD(OnExecuteComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnUnregisterBegin - called when the engine unregisters the bundle. + // + STDMETHOD(OnUnregisterBegin)( + __in BOOL fKeepRegistration, + __inout BOOL* pfForceKeepRegistration + ) = 0; + + // OnUnregisterComplete - called when the engine unregistration is complete. + // + STDMETHOD(OnUnregisterComplete)( + __in HRESULT hrStatus + ) = 0; + + // OnApplyComplete - called after the plan has been applied. + // + STDMETHOD(OnApplyComplete)( + __in HRESULT hrStatus, + __in BOOTSTRAPPER_APPLY_RESTART restart, + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction + ) = 0; + + // OnLaunchApprovedExeBegin - called before trying to launch the preapproved executable. + // + STDMETHOD(OnLaunchApprovedExeBegin)( + __inout BOOL* pfCancel + ) = 0; + + // OnLaunchApprovedExeComplete - called after trying to launch the preapproved executable. + // + STDMETHOD(OnLaunchApprovedExeComplete)( + __in HRESULT hrStatus, + __in DWORD dwProcessId + ) = 0; + + STDMETHOD(OnBeginMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnBeginMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnCommitMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCommitMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnRollbackMsiTransactionBegin)( + __in_z LPCWSTR wzTransactionId + ) = 0; + + STDMETHOD(OnRollbackMsiTransactionComplete)( + __in_z LPCWSTR wzTransactionId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnPauseAutomaticUpdatesBegin)( + ) = 0; + + STDMETHOD(OnPauseAutomaticUpdatesComplete)( + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnSystemRestorePointBegin)( + ) = 0; + + STDMETHOD(OnSystemRestorePointComplete)( + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnPlanForwardCompatibleBundle)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in_z LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in_z LPCWSTR wzVersion, + __in BOOL fRecommendedIgnoreBundle, + __inout BOOL* pfCancel, + __inout BOOL* pfIgnoreBundle + ) = 0; + + STDMETHOD(OnCacheContainerOrPayloadVerifyBegin)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCacheContainerOrPayloadVerifyProgress)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCacheContainerOrPayloadVerifyComplete)( + __in_z_opt LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus + ) = 0; + + STDMETHOD(OnCachePayloadExtractBegin)( + __in_z_opt LPCWSTR wzContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCachePayloadExtractProgress)( + __in_z_opt LPCWSTR wzContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) = 0; + + STDMETHOD(OnCachePayloadExtractComplete)( + __in_z_opt LPCWSTR wzContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrStatus + ) = 0; +}; diff --git a/src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h b/src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h new file mode 100644 index 00000000..fd603e50 --- /dev/null +++ b/src/api/burn/balutil/inc/IBootstrapperApplicationFactory.h @@ -0,0 +1,13 @@ +#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 new file mode 100644 index 00000000..ccb07f4f --- /dev/null +++ b/src/api/burn/balutil/inc/IBootstrapperEngine.h @@ -0,0 +1,140 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-81512C29C2FB") +{ + STDMETHOD(GetPackageCount)( + __out DWORD* pcPackages + ) = 0; + + STDMETHOD(GetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) = 0; + + STDMETHOD(GetVariableString)( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) = 0; + + STDMETHOD(GetVariableVersion)( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T * pcchValue + ) = 0; + + STDMETHOD(FormatString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T * pcchOut + ) = 0; + + STDMETHOD(EscapeString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T * pcchOut + ) = 0; + + STDMETHOD(EvaluateCondition)( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) = 0; + + STDMETHOD(Log)( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) = 0; + + STDMETHOD(SendEmbeddedError)( + __in DWORD dwErrorCode, + __in_z_opt LPCWSTR wzMessage, + __in DWORD dwUIHint, + __out int* pnResult + ) = 0; + + STDMETHOD(SendEmbeddedProgress)( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __out int* pnResult + ) = 0; + + STDMETHOD(SetUpdate)( + __in_z_opt LPCWSTR wzLocalSource, + __in_z_opt LPCWSTR wzDownloadSource, + __in DWORD64 qwSize, + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, + __in_bcount_opt(cbHash) BYTE* rgbHash, + __in DWORD cbHash + ) = 0; + + STDMETHOD(SetLocalSource)( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzPath + ) = 0; + + STDMETHOD(SetDownloadSource)( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzUrl, + __in_z_opt LPCWSTR wzUser, + __in_z_opt LPCWSTR wzPassword + ) = 0; + + STDMETHOD(SetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) = 0; + + STDMETHOD(SetVariableString)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted + ) = 0; + + STDMETHOD(SetVariableVersion)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) = 0; + + STDMETHOD(CloseSplashScreen)() = 0; + + STDMETHOD(Detect)( + __in_opt HWND hwndParent = NULL + ) = 0; + + STDMETHOD(Plan)( + __in BOOTSTRAPPER_ACTION action + ) = 0; + + STDMETHOD(Elevate)( + __in_opt HWND hwndParent + ) = 0; + + STDMETHOD(Apply)( + __in HWND hwndParent + ) = 0; + + STDMETHOD(Quit)( + __in DWORD dwExitCode + ) = 0; + + STDMETHOD(LaunchApprovedExe)( + __in_opt HWND hwndParent, + __in_z LPCWSTR wzApprovedExeForElevationId, + __in_z_opt LPCWSTR wzArguments, + __in DWORD dwWaitForInputIdleTimeout + ) = 0; + + STDMETHOD(SetUpdateSource)( + __in_z LPCWSTR wzUrl + ) = 0; + + STDMETHOD(CompareVersions)( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) = 0; +}; diff --git a/src/api/burn/balutil/inc/balcondition.h b/src/api/burn/balutil/inc/balcondition.h new file mode 100644 index 00000000..677c593f --- /dev/null +++ b/src/api/burn/balutil/inc/balcondition.h @@ -0,0 +1,58 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _BAL_CONDITION +{ + LPWSTR sczCondition; + LPWSTR sczMessage; +} BAL_CONDITION; + + +typedef struct _BAL_CONDITIONS +{ + BAL_CONDITION* rgConditions; + DWORD cConditions; +} BAL_CONDITIONS; + + +/******************************************************************* + BalConditionsParseFromXml - loads the conditions from the UX manifest. + +********************************************************************/ +DAPI_(HRESULT) BalConditionsParseFromXml( + __in BAL_CONDITIONS* pConditions, + __in IXMLDOMDocument* pixdManifest, + __in_opt WIX_LOCALIZATION* pWixLoc + ); + + +/******************************************************************* + BalConditionEvaluate - evaluates condition against the provided IBurnCore. + + NOTE: psczMessage is optional. +********************************************************************/ +DAPI_(HRESULT) BalConditionEvaluate( + __in BAL_CONDITION* pCondition, + __in IBootstrapperEngine* pEngine, + __out BOOL* pfResult, + __out_z_opt LPWSTR* psczMessage + ); + + +/******************************************************************* + BalConditionsUninitialize - uninitializes any conditions previously loaded. + +********************************************************************/ +DAPI_(void) BalConditionsUninitialize( + __in BAL_CONDITIONS* pConditions + ); + + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/balutil/inc/balinfo.h b/src/api/burn/balutil/inc/balinfo.h new file mode 100644 index 00000000..8c2155e9 --- /dev/null +++ b/src/api/burn/balutil/inc/balinfo.h @@ -0,0 +1,105 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum BAL_INFO_PACKAGE_TYPE +{ + BAL_INFO_PACKAGE_TYPE_UNKNOWN, + BAL_INFO_PACKAGE_TYPE_EXE, + BAL_INFO_PACKAGE_TYPE_MSI, + BAL_INFO_PACKAGE_TYPE_MSP, + BAL_INFO_PACKAGE_TYPE_MSU, + BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE, + BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON, + BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, +} BAL_INFO_PACKAGE_TYPE; + + +typedef struct _BAL_INFO_PACKAGE +{ + LPWSTR sczId; + LPWSTR sczDisplayName; + LPWSTR sczDescription; + BAL_INFO_PACKAGE_TYPE type; + BOOL fPermanent; + BOOL fVital; + LPWSTR sczDisplayInternalUICondition; + LPWSTR sczProductCode; + LPWSTR sczUpgradeCode; + LPWSTR sczVersion; + LPWSTR sczInstallCondition; + BOOTSTRAPPER_CACHE_TYPE cacheType; + BOOL fPrereqPackage; + LPWSTR sczPrereqLicenseFile; + LPWSTR sczPrereqLicenseUrl; + LPVOID pvCustomData; +} BAL_INFO_PACKAGE; + + +typedef struct _BAL_INFO_PACKAGES +{ + BAL_INFO_PACKAGE* rgPackages; + DWORD cPackages; +} BAL_INFO_PACKAGES; + + +typedef struct _BAL_INFO_BUNDLE +{ + BOOL fPerMachine; + LPWSTR sczName; + LPWSTR sczLogVariable; + BAL_INFO_PACKAGES packages; +} BAL_INFO_BUNDLE; + + +/******************************************************************* + BalInfoParseFromXml - loads the bundle and package info from the UX + manifest. + +********************************************************************/ +DAPI_(HRESULT) BalInfoParseFromXml( + __in BAL_INFO_BUNDLE* pBundle, + __in IXMLDOMDocument* pixdManifest + ); + + +/******************************************************************* + BalInfoAddRelatedBundleAsPackage - adds a related bundle as a package. + + ********************************************************************/ +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in BOOL fPerMachine, + __out_opt BAL_INFO_PACKAGE** ppPackage + ); + + +/******************************************************************* + BalInfoFindPackageById - finds a package by its id. + + ********************************************************************/ +DAPI_(HRESULT) BalInfoFindPackageById( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __out BAL_INFO_PACKAGE** ppPackage + ); + + +/******************************************************************* + BalInfoUninitialize - uninitializes any info previously loaded. + +********************************************************************/ +DAPI_(void) BalInfoUninitialize( + __in BAL_INFO_BUNDLE* pBundle + ); + + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/balutil/inc/balretry.h b/src/api/burn/balutil/inc/balretry.h new file mode 100644 index 00000000..35282a7e --- /dev/null +++ b/src/api/burn/balutil/inc/balretry.h @@ -0,0 +1,74 @@ +#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. + + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************* + BalRetryInitialize - initialize the retry count and timeout between + retries (in milliseconds). +********************************************************************/ +DAPI_(void) BalRetryInitialize( + __in DWORD dwMaxRetries, + __in DWORD dwTimeout + ); + +/******************************************************************* + BalRetryUninitialize - call to cleanup any memory allocated during + use of the retry utility. +********************************************************************/ +DAPI_(void) BalRetryUninitialize(); + +/******************************************************************* + BalRetryStartPackage - call when a package begins to be modified. If + the package is being retried, the function will + wait the specified timeout. +********************************************************************/ +DAPI_(void) BalRetryStartPackage( + __in_z LPCWSTR wzPackageId + ); + +/******************************************************************* + BalRetryErrorOccured - call when an error occurs for the retry utility + to consider. +********************************************************************/ +DAPI_(void) BalRetryErrorOccurred( + __in_z LPCWSTR wzPackageId, + __in DWORD dwError + ); + +/******************************************************************* + BalRetryEndPackage - returns TRUE if a retry is recommended. +********************************************************************/ +DAPI_(HRESULT) BalRetryEndPackage( + __in_z LPCWSTR wzPackageId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ); + +/******************************************************************* + BalRetryStartContainerOrPayload - call when a container or payload + begins to be acquired. If the target is being retried, + the function will wait the specified timeout. +********************************************************************/ +DAPI_(void) BalRetryStartContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId + ); + +/******************************************************************* + BalRetryEndContainerOrPayload - returns TRUE if a retry is recommended. +********************************************************************/ +DAPI_(HRESULT) BalRetryEndContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ); + + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/balutil/inc/balutil.h b/src/api/burn/balutil/inc/balutil.h new file mode 100644 index 00000000..fad8a471 --- /dev/null +++ b/src/api/burn/balutil/inc/balutil.h @@ -0,0 +1,199 @@ +#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 "dutil.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define BalExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } +#define BalExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BalExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } + +#define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitOnLastError(x, f, ...) BalExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) +#define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) +#define BalExitWithLastError(x, f, ...) BalExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) + +#ifndef FACILITY_WIX +#define FACILITY_WIX 500 +#endif + +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); + + +/******************************************************************* + BalInitialize - remembers the engine interface to enable logging and + other functions. + +********************************************************************/ +DAPI_(void) BalInitialize( + __in IBootstrapperEngine* pEngine + ); + +/******************************************************************* + BalInitializeFromCreateArgs - convenience function to call BalBootstrapperEngineCreate + then pass it along to BalInitialize. + +********************************************************************/ +DAPI_(HRESULT) BalInitializeFromCreateArgs( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __out_opt IBootstrapperEngine** ppEngine + ); + +/******************************************************************* + BalUninitialize - cleans up utility layer internals. + +********************************************************************/ +DAPI_(void) BalUninitialize(); + +/******************************************************************* + BalManifestLoad - loads the Application manifest into an XML document. + +********************************************************************/ +DAPI_(HRESULT) BalManifestLoad( + __in HMODULE hUXModule, + __out IXMLDOMDocument** ppixdManifest + ); + +/******************************************************************* +BalEvaluateCondition - evaluates a condition using variables in the engine. + +********************************************************************/ +DAPI_(HRESULT) BalEvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ); + +/******************************************************************* +BalFormatString - formats a string using variables in the engine. + + Note: Use StrFree() to release psczOut. +********************************************************************/ +DAPI_(HRESULT) BalFormatString( + __in_z LPCWSTR wzFormat, + __inout LPWSTR* psczOut + ); + +/******************************************************************* +BalGetNumericVariable - gets a number from a variable in the engine. + + Note: Returns E_NOTFOUND if variable does not exist. +********************************************************************/ +DAPI_(HRESULT) BalGetNumericVariable( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ); + +/******************************************************************* +BalSetNumericVariable - sets a numeric variable in the engine. + +********************************************************************/ +DAPI_(HRESULT) BalSetNumericVariable( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ); + +/******************************************************************* +BalVariableExists - checks if a variable exists in the engine. + +********************************************************************/ +DAPI_(BOOL) BalVariableExists( + __in_z LPCWSTR wzVariable + ); + +/******************************************************************* +BalGetStringVariable - gets a string from a variable in the engine. + + Note: Use StrFree() to release psczValue. +********************************************************************/ +DAPI_(HRESULT) BalGetStringVariable( + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue + ); + +/******************************************************************* +BalSetStringVariable - sets a string variable in the engine. + +********************************************************************/ +DAPI_(HRESULT) BalSetStringVariable( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted + ); + +/******************************************************************* + BalLog - logs a message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BalLog( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* + BalLogArgs - logs a message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BalLogArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + +/******************************************************************* + BalLogError - logs an error message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BalLogError( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* + BalLogErrorArgs - logs an error message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BalLogErrorArgs( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + +/******************************************************************* +BalLogId - logs a message with the engine with a string embedded in a + MESSAGETABLE resource. + +********************************************************************/ +DAPIV_(HRESULT) BalLogId( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + ... + ); + +DAPI_(HRESULT) BalLogIdArgs( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in DWORD dwLogId, + __in HMODULE hModule, + __in va_list args + ); + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/balutil/packages.config b/src/api/burn/balutil/packages.config new file mode 100644 index 00000000..08ea3364 --- /dev/null +++ b/src/api/burn/balutil/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/api/burn/balutil/precomp.cpp b/src/api/burn/balutil/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/api/burn/balutil/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/api/burn/balutil/precomp.h b/src/api/burn/balutil/precomp.h new file mode 100644 index 00000000..c500060a --- /dev/null +++ b/src/api/burn/balutil/precomp.h @@ -0,0 +1,32 @@ +#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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +#include "BAFunctions.h" +#include "IBAFunctions.h" + +#include "balutil.h" +#include "BalBootstrapperEngine.h" +#include "balcondition.h" +#include "balinfo.h" +#include "balretry.h" diff --git a/src/api/burn/bextutil/BextBundleExtensionEngine.cpp b/src/api/burn/bextutil/BextBundleExtensionEngine.cpp new file mode 100644 index 00000000..6043e2db --- /dev/null +++ b/src/api/burn/bextutil/BextBundleExtensionEngine.cpp @@ -0,0 +1,344 @@ +// 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" + + +class CBextBundleExtensionEngine : public IBundleExtensionEngine +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBundleExtensionEngine), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = reinterpret_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBundleExtensionEngine + virtual STDMETHODIMP EscapeString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T* pcchOut + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP EvaluateCondition( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS results = { }; + + ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); + + args.cbSize = sizeof(args); + args.wzCondition = wzCondition; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pf = results.f; + + LExit: + return hr; + } + + virtual STDMETHODIMP FormatString( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T* pcchOut + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS results = { }; + + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); + + args.cbSize = sizeof(args); + args.wzIn = wzIn; + + results.cbSize = sizeof(results); + results.wzOut = wzOut; + results.cchOut = *pcchOut; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchOut = results.cchOut; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableNumeric( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS results = { }; + + ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pllValue = results.llValue; + + LExit: + SecureZeroMemory(&results, sizeof(results)); + return hr; + } + + virtual STDMETHODIMP GetVariableString( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS results = { }; + + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchValue = results.cchValue; + + LExit: + return hr; + } + + virtual STDMETHODIMP GetVariableVersion( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS results = { }; + + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + + results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pcchValue = results.cchValue; + + LExit: + return hr; + } + + virtual STDMETHODIMP Log( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) + { + BUNDLE_EXTENSION_ENGINE_LOG_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_LOG_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.level = level; + args.wzMessage = wzMessage; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableNumeric( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.llValue = llValue; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableString( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + args.fFormatted = fFormatted; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP SetVariableVersion( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) + { + BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS results = { }; + + args.cbSize = sizeof(args); + args.wzVariable = wzVariable; + args.wzValue = wzValue; + + results.cbSize = sizeof(results); + + return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); + } + + virtual STDMETHODIMP CompareVersions( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) + { + HRESULT hr = S_OK; + BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS args = { }; + BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS results = { }; + + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); + + args.cbSize = sizeof(args); + args.wzVersion1 = wzVersion1; + args.wzVersion2 = wzVersion2; + + results.cbSize = sizeof(results); + + hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBundleExtensionEngineProcContext); + + *pnResult = results.nResult; + + LExit: + return hr; + } + +public: + CBextBundleExtensionEngine( + __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, + __in_opt LPVOID pvBundleExtensionEngineProcContext + ) + { + m_cReferences = 1; + m_pfnBundleExtensionEngineProc = pfnBundleExtensionEngineProc; + m_pvBundleExtensionEngineProcContext = pvBundleExtensionEngineProcContext; + } + +private: + long m_cReferences; + PFN_BUNDLE_EXTENSION_ENGINE_PROC m_pfnBundleExtensionEngineProc; + LPVOID m_pvBundleExtensionEngineProcContext; +}; + +HRESULT BextBundleExtensionEngineCreate( + __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, + __in_opt LPVOID pvBundleExtensionEngineProcContext, + __out IBundleExtensionEngine** ppEngineForExtension + ) +{ + HRESULT hr = S_OK; + CBextBundleExtensionEngine* pBundleExtensionEngine = NULL; + + pBundleExtensionEngine = new CBextBundleExtensionEngine(pfnBundleExtensionEngineProc, pvBundleExtensionEngineProcContext); + ExitOnNull(pBundleExtensionEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BextBundleExtensionEngine object."); + + hr = pBundleExtensionEngine->QueryInterface(IID_PPV_ARGS(ppEngineForExtension)); + ExitOnFailure(hr, "Failed to QI for IBundleExtensionEngine from BextBundleExtensionEngine object."); + +LExit: + ReleaseObject(pBundleExtensionEngine); + return hr; +} diff --git a/src/api/burn/bextutil/bextutil.cpp b/src/api/burn/bextutil/bextutil.cpp new file mode 100644 index 00000000..4b22d502 --- /dev/null +++ b/src/api/burn/bextutil/bextutil.cpp @@ -0,0 +1,221 @@ +// 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 IBundleExtensionEngine* vpEngine = NULL; + +// prototypes + +DAPI_(void) BextInitialize( + __in IBundleExtensionEngine* pEngine + ) +{ + pEngine->AddRef(); + + ReleaseObject(vpEngine); + vpEngine = pEngine; +} + +DAPI_(HRESULT) BextInitializeFromCreateArgs( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __out_opt IBundleExtensionEngine** ppEngine + ) +{ + HRESULT hr = S_OK; + IBundleExtensionEngine* pEngine = NULL; + + hr = BextBundleExtensionEngineCreate(pArgs->pfnBundleExtensionEngineProc, pArgs->pvBundleExtensionEngineProcContext, &pEngine); + ExitOnFailure(hr, "Failed to create BextBundleExtensionEngine."); + + BextInitialize(pEngine); + + if (ppEngine) + { + *ppEngine = pEngine; + } + pEngine = NULL; + +LExit: + ReleaseObject(pEngine); + + return hr; +} + + +DAPI_(void) BextUninitialize() +{ + ReleaseNullObject(vpEngine); +} + +DAPI_(HRESULT) BextGetBundleExtensionDataNode( + __in IXMLDOMDocument* pixdManifest, + __in LPCWSTR wzExtensionId, + __out IXMLDOMNode** ppixnBundleExtension + ) +{ + HRESULT hr = S_OK; + IXMLDOMElement* pixeBundleExtensionData = NULL; + IXMLDOMNodeList* pixnNodes = NULL; + IXMLDOMNode* pixnNode = NULL; + DWORD cNodes = 0; + LPWSTR sczId = NULL; + + // Get BundleExtensionData element. + hr = pixdManifest->get_documentElement(&pixeBundleExtensionData); + ExitOnFailure(hr, "Failed to get BundleExtensionData element."); + + // Select BundleExtension nodes. + hr = XmlSelectNodes(pixeBundleExtensionData, L"BundleExtension", &pixnNodes); + ExitOnFailure(hr, "Failed to select BundleExtension nodes."); + + // Get BundleExtension node count. + hr = pixnNodes->get_length((long*)&cNodes); + ExitOnFailure(hr, "Failed to get BundleExtension node count."); + + if (!cNodes) + { + ExitFunction(); + } + + // Find requested extension. + for (DWORD i = 0; i < cNodes; ++i) + { + hr = XmlNextElement(pixnNodes, &pixnNode, NULL); + ExitOnFailure(hr, "Failed to get next node."); + + // @Id + hr = XmlGetAttributeEx(pixnNode, L"Id", &sczId); + ExitOnFailure(hr, "Failed to get @Id."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczId, -1, wzExtensionId, -1)) + { + *ppixnBundleExtension = pixnNode; + pixnNode = NULL; + + ExitFunction1(hr = S_OK); + } + + // Prepare next iteration. + ReleaseNullObject(pixnNode); + } + + hr = E_NOTFOUND; + +LExit: + ReleaseStr(sczId); + ReleaseObject(pixnNode); + ReleaseObject(pixnNodes); + ReleaseObject(pixeBundleExtensionData); + + return hr; +} + + +DAPIV_(HRESULT) BextLog( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BextLogArgs(level, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BextLogArgs( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + ExitOnFailure(hr, "Failed to format log string."); + + hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); + ExitOnFailure(hr, "Failed to convert log string to Unicode."); + + hr = vpEngine->Log(level, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} + + +DAPIV_(HRESULT) BextLogError( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + ... + ) +{ + HRESULT hr = S_OK; + va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BextLogErrorArgs(hrError, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BextLogErrorArgs( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; + LPSTR sczFormattedAnsi = NULL; + LPWSTR sczMessage = NULL; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); + ExitOnFailure(hr, "Failed to format error log string."); + + hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); + ExitOnFailure(hr, "Failed to prepend error number to error log string."); + + hr = vpEngine->Log(BUNDLE_EXTENSION_LOG_LEVEL_ERROR, sczMessage); + +LExit: + ReleaseStr(sczMessage); + ReleaseStr(sczFormattedAnsi); + return hr; +} diff --git a/src/api/burn/bextutil/bextutil.nuspec b/src/api/burn/bextutil/bextutil.nuspec new file mode 100644 index 00000000..752dbb97 --- /dev/null +++ b/src/api/burn/bextutil/bextutil.nuspec @@ -0,0 +1,31 @@ + + + + $id$ + $version$ + $authors$ + $authors$ + MS-RL + https://github.com/wixtoolset/balutil + false + $description$ + $copyright$ + + + + + + + + + + + + + + + + + + + diff --git a/src/api/burn/bextutil/bextutil.vcxproj b/src/api/burn/bextutil/bextutil.vcxproj new file mode 100644 index 00000000..b9334cf3 --- /dev/null +++ b/src/api/burn/bextutil/bextutil.vcxproj @@ -0,0 +1,90 @@ + + + + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {06027492-1CB9-48BC-B31E-C1F9356ED07E} + StaticLibrary + bextutil + v142 + MultiByte + WiX Toolset Bundle Extension native utility library + WixToolset.BextUtil + + + + + + + + + + + + + + + $(ProjectDir)..\inc + + + + + + + Create + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/src/api/burn/bextutil/build/WixToolset.BextUtil.props b/src/api/burn/bextutil/build/WixToolset.BextUtil.props new file mode 100644 index 00000000..60a2db54 --- /dev/null +++ b/src/api/burn/bextutil/build/WixToolset.BextUtil.props @@ -0,0 +1,28 @@ + + + + + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) + + + + + $(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + + + + $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + + + + $(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) + + + diff --git a/src/api/burn/bextutil/inc/BextBaseBundleExtension.h b/src/api/burn/bextutil/inc/BextBaseBundleExtension.h new file mode 100644 index 00000000..69c338e4 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBaseBundleExtension.h @@ -0,0 +1,120 @@ +// 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 "BundleExtensionEngine.h" +#include "BundleExtension.h" +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" + +#include "bextutil.h" + +class CBextBaseBundleExtension : public IBundleExtension +{ +public: // IUnknown + virtual STDMETHODIMP QueryInterface( + __in REFIID riid, + __out LPVOID *ppvObject + ) + { + if (!ppvObject) + { + return E_INVALIDARG; + } + + *ppvObject = NULL; + + if (::IsEqualIID(__uuidof(IBundleExtension), riid)) + { + *ppvObject = static_cast(this); + } + else if (::IsEqualIID(IID_IUnknown, riid)) + { + *ppvObject = static_cast(this); + } + else // no interface for requested iid + { + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; + } + + virtual STDMETHODIMP_(ULONG) AddRef() + { + return ::InterlockedIncrement(&this->m_cReferences); + } + + virtual STDMETHODIMP_(ULONG) Release() + { + long l = ::InterlockedDecrement(&this->m_cReferences); + if (0 < l) + { + return l; + } + + delete this; + return 0; + } + +public: // IBundleExtension + virtual STDMETHODIMP Search( + __in LPCWSTR /*wzId*/, + __in LPCWSTR /*wzVariable*/ + ) + { + return E_NOTIMPL; + } + + virtual STDMETHODIMP BundleExtensionProc( + __in BUNDLE_EXTENSION_MESSAGE /*message*/, + __in const LPVOID /*pvArgs*/, + __inout LPVOID /*pvResults*/, + __in_opt LPVOID /*pvContext*/ + ) + { + return E_NOTIMPL; + } + +public: //CBextBaseBundleExtension + virtual STDMETHODIMP Initialize( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs + ) + { + HRESULT hr = S_OK; + + hr = StrAllocString(&m_sczBundleExtensionDataPath, pCreateArgs->wzBundleExtensionDataPath, 0); + ExitOnFailure(hr, "Failed to copy BundleExtensionDataPath."); + + LExit: + return hr; + } + +protected: + + CBextBaseBundleExtension( + __in IBundleExtensionEngine* pEngine + ) + { + m_cReferences = 1; + + pEngine->AddRef(); + m_pEngine = pEngine; + + m_sczBundleExtensionDataPath = NULL; + } + + virtual ~CBextBaseBundleExtension() + { + ReleaseNullObject(m_pEngine); + ReleaseStr(m_sczBundleExtensionDataPath); + } + +protected: + IBundleExtensionEngine* m_pEngine; + LPWSTR m_sczBundleExtensionDataPath; + +private: + long m_cReferences; +}; diff --git a/src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h b/src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h new file mode 100644 index 00000000..f71e3b92 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h @@ -0,0 +1,48 @@ +#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 "BundleExtensionEngine.h" +#include "BundleExtension.h" +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" + +static HRESULT BextBaseBEProcSearch( + __in IBundleExtension* pBE, + __in BUNDLE_EXTENSION_SEARCH_ARGS* pArgs, + __inout BUNDLE_EXTENSION_SEARCH_RESULTS* /*pResults*/ + ) +{ + return pBE->Search(pArgs->wzId, pArgs->wzVariable); +} + +/******************************************************************* +BextBaseBundleExtensionProc - requires pvContext to be of type IBundleExtension. + Provides a default mapping between the message based + BundleExtension interface and the COM-based BundleExtension interface. + +*******************************************************************/ +static HRESULT WINAPI BextBaseBundleExtensionProc( + __in BUNDLE_EXTENSION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) +{ + IBundleExtension* pBE = reinterpret_cast(pvContext); + HRESULT hr = pBE->BundleExtensionProc(message, pvArgs, pvResults, pvContext); + + if (E_NOTIMPL == hr) + { + switch (message) + { + case BUNDLE_EXTENSION_MESSAGE_SEARCH: + hr = BextBaseBEProcSearch(pBE, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + } + } + + return hr; +} diff --git a/src/api/burn/bextutil/inc/BextBundleExtensionEngine.h b/src/api/burn/bextutil/inc/BextBundleExtensionEngine.h new file mode 100644 index 00000000..9fdcb700 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBundleExtensionEngine.h @@ -0,0 +1,17 @@ +// 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 BextBundleExtensionEngineCreate( + __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, + __in_opt LPVOID pvBundleExtensionEngineProcContext, + __out IBundleExtensionEngine** ppEngineForExtension + ); + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/bextutil/inc/IBundleExtension.h b/src/api/burn/bextutil/inc/IBundleExtension.h new file mode 100644 index 00000000..7516c11b --- /dev/null +++ b/src/api/burn/bextutil/inc/IBundleExtension.h @@ -0,0 +1,20 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBundleExtension, IUnknown, "93123C9D-796B-4FCD-A507-6EDEF9A925FD") +{ + STDMETHOD(Search)( + __in LPCWSTR wzId, + __in LPCWSTR wzVariable + ) = 0; + + // BundleExtensionProc - The PFN_BUNDLE_EXTENSION_PROC can call this method to give the BundleExtension raw access to the callback from the engine. + // This might be used to help the BundleExtension support more than one version of the engine. + STDMETHOD(BundleExtensionProc)( + __in BUNDLE_EXTENSION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) = 0; +}; diff --git a/src/api/burn/bextutil/inc/IBundleExtensionEngine.h b/src/api/burn/bextutil/inc/IBundleExtensionEngine.h new file mode 100644 index 00000000..63dadb06 --- /dev/null +++ b/src/api/burn/bextutil/inc/IBundleExtensionEngine.h @@ -0,0 +1,67 @@ +#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. + + +DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-9737-C185089EB263") +{ + STDMETHOD(EscapeString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T* pcchOut + ) = 0; + + STDMETHOD(EvaluateCondition)( + __in_z LPCWSTR wzCondition, + __out BOOL* pf + ) = 0; + + STDMETHOD(FormatString)( + __in_z LPCWSTR wzIn, + __out_ecount_opt(*pcchOut) LPWSTR wzOut, + __inout SIZE_T* pcchOut + ) = 0; + + STDMETHOD(GetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue + ) = 0; + + STDMETHOD(GetVariableString)( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) = 0; + + STDMETHOD(GetVariableVersion)( + __in_z LPCWSTR wzVariable, + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout SIZE_T* pcchValue + ) = 0; + + STDMETHOD(Log)( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z LPCWSTR wzMessage + ) = 0; + + STDMETHOD(SetVariableNumeric)( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue + ) = 0; + + STDMETHOD(SetVariableString)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted + ) = 0; + + STDMETHOD(SetVariableVersion)( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue + ) = 0; + + STDMETHOD(CompareVersions)( + __in_z LPCWSTR wzVersion1, + __in_z LPCWSTR wzVersion2, + __out int* pnResult + ) = 0; +}; diff --git a/src/api/burn/bextutil/inc/bextutil.h b/src/api/burn/bextutil/inc/bextutil.h new file mode 100644 index 00000000..ac9c0062 --- /dev/null +++ b/src/api/burn/bextutil/inc/bextutil.h @@ -0,0 +1,106 @@ +#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 "dutil.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define BextExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } +#define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } +#define BextExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } + +#define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitOnLastError(x, f, ...) BextExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) +#define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) +#define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) +#define BextExitWithLastError(x, f, ...) BextExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) + +const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml"; + + +/******************************************************************* + BextInitialize - remembers the engine interface to enable logging and + other functions. + +********************************************************************/ +DAPI_(void) BextInitialize( + __in IBundleExtensionEngine* pEngine + ); + +/******************************************************************* + BextInitializeFromCreateArgs - convenience function to call BextBundleExtensionEngineCreate + then pass it along to BextInitialize. + +********************************************************************/ +DAPI_(HRESULT) BextInitializeFromCreateArgs( + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __out IBundleExtensionEngine** ppEngine + ); + +/******************************************************************* + BextUninitialize - cleans up utility layer internals. + +********************************************************************/ +DAPI_(void) BextUninitialize(); + +/******************************************************************* + BextGetBundleExtensionDataNode - gets the requested BundleExtension node. + +********************************************************************/ +DAPI_(HRESULT) BextGetBundleExtensionDataNode( + __in IXMLDOMDocument* pixdManifest, + __in LPCWSTR wzExtensionId, + __out IXMLDOMNode** ppixnBundleExtension + ); + +/******************************************************************* + BextLog - logs a message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BextLog( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* + BextLogArgs - logs a message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BextLogArgs( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + +/******************************************************************* + BextLogError - logs an error message with the engine. + +********************************************************************/ +DAPIV_(HRESULT) BextLogError( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + ... + ); + +/******************************************************************* + BextLogErrorArgs - logs an error message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BextLogErrorArgs( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + +#ifdef __cplusplus +} +#endif diff --git a/src/api/burn/bextutil/packages.config b/src/api/burn/bextutil/packages.config new file mode 100644 index 00000000..08ea3364 --- /dev/null +++ b/src/api/burn/bextutil/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/api/burn/bextutil/precomp.cpp b/src/api/burn/bextutil/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/api/burn/bextutil/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/api/burn/bextutil/precomp.h b/src/api/burn/bextutil/precomp.h new file mode 100644 index 00000000..5d1dd20b --- /dev/null +++ b/src/api/burn/bextutil/precomp.h @@ -0,0 +1,22 @@ +#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 + +#include +#include +#include +#include +#include + +#include +#include + +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" + +#include "bextutil.h" +#include "BextBundleExtensionEngine.h" diff --git a/src/api/burn/mbanative/mbanative.cpp b/src/api/burn/mbanative/mbanative.cpp new file mode 100644 index 00000000..98ea3c30 --- /dev/null +++ b/src/api/burn/mbanative/mbanative.cpp @@ -0,0 +1,29 @@ +// 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 new file mode 100644 index 00000000..28e923b6 --- /dev/null +++ b/src/api/burn/mbanative/mbanative.def @@ -0,0 +1,12 @@ +; 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. + + +EXPORTS + InitializeFromCreateArgs + StoreBAInCreateResults + VerCompareParsedVersions + VerCompareStringVersions + VerCopyVersion + VerFreeVersion + VerParseVersion + VerVersionFromQword diff --git a/src/api/burn/mbanative/mbanative.vcxproj b/src/api/burn/mbanative/mbanative.vcxproj new file mode 100644 index 00000000..f91fe3be --- /dev/null +++ b/src/api/burn/mbanative/mbanative.vcxproj @@ -0,0 +1,102 @@ + + + + + + + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {665E0441-17F9-4105-B202-EDF274657F6E} + DynamicLibrary + v142 + Unicode + mbanative + mbanative.def + false + + + + + + + + + + + + + + + ..\balutil\inc + balutil.lib + + + + + + Create + + + + + + + + + + + + + + + + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + \ No newline at end of file diff --git a/src/api/burn/mbanative/packages.config b/src/api/burn/mbanative/packages.config new file mode 100644 index 00000000..745fcae9 --- /dev/null +++ b/src/api/burn/mbanative/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/api/burn/mbanative/precomp.cpp b/src/api/burn/mbanative/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/api/burn/mbanative/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/api/burn/mbanative/precomp.h b/src/api/burn/mbanative/precomp.h new file mode 100644 index 00000000..2e2f3ff8 --- /dev/null +++ b/src/api/burn/mbanative/precomp.h @@ -0,0 +1,16 @@ +#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 +#include + +#include +#include + +#include +#include +#include diff --git a/src/api/burn/nuget.config b/src/api/burn/nuget.config new file mode 100644 index 00000000..2c6c5608 --- /dev/null +++ b/src/api/burn/nuget.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj new file mode 100644 index 00000000..d3a81e2a --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -0,0 +1,76 @@ + + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631} + UnitTest + ManagedCProj + DynamicLibrary + Unicode + true + false + + + + + ..\..\balutil\inc + comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib + + + + Create + + 4564;4691 + + + + + + + + + + + + + + + ..\..\..\packages\WixBuildTools.TestSupport.4.0.50\lib\net472\WixBuildTools.TestSupport.dll + + + ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.50\lib\net472\WixBuildTools.TestSupport.Native.dll + + + + + {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters new file mode 100644 index 00000000..85f31076 --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp new file mode 100644 index 00000000..927a8d10 --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp @@ -0,0 +1,41 @@ +// 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 "BalBaseBAFunctions.h" +#include "BalBaseBAFunctionsProc.h" + +class CTestBAFunctions : public CBalBaseBAFunctions +{ +public: + CTestBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs + ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) + { + } +}; + +HRESULT CreateBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __in BA_FUNCTIONS_CREATE_RESULTS* pResults, + __out IBAFunctions** ppApplication + ) +{ + HRESULT hr = S_OK; + CTestBAFunctions* pApplication = NULL; + + pApplication = new CTestBAFunctions(hModule, pEngine, pArgs); + ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object."); + + pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; + pResults->pvBAFunctionsProcContext = pApplication; + *ppApplication = pApplication; + pApplication = NULL; + +LExit: + ReleaseObject(pApplication); + return hr; +} diff --git a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp new file mode 100644 index 00000000..13d22e72 --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp @@ -0,0 +1,39 @@ +// 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 "BalBaseBootstrapperApplication.h" +#include "BalBaseBootstrapperApplicationProc.h" + +class CTestBootstrapperApplication : public CBalBaseBootstrapperApplication +{ +public: + CTestBootstrapperApplication( + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs + ) : CBalBaseBootstrapperApplication(pEngine, pArgs) + { + } +}; + +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, pArgs); + ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bootstrapper application object."); + + pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; + pResults->pvBootstrapperApplicationProcContext = pApplication; + *ppApplication = pApplication; + pApplication = NULL; + +LExit: + ReleaseObject(pApplication); + return hr; +} diff --git a/src/api/burn/test/BalUtilUnitTest/packages.config b/src/api/burn/test/BalUtilUnitTest/packages.config new file mode 100644 index 00000000..6d381fbe --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/api/burn/test/BalUtilUnitTest/precomp.cpp b/src/api/burn/test/BalUtilUnitTest/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/api/burn/test/BalUtilUnitTest/precomp.h b/src/api/burn/test/BalUtilUnitTest/precomp.h new file mode 100644 index 00000000..a84391f9 --- /dev/null +++ b/src/api/burn/test/BalUtilUnitTest/precomp.h @@ -0,0 +1,23 @@ +#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 + +#include +#include +#include + +#include +#include + +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" +#include "balutil.h" +#include "balretry.h" +#include "BAFunctions.h" + +#pragma managed +#include diff --git a/src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj new file mode 100644 index 00000000..a9937894 --- /dev/null +++ b/src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -0,0 +1,75 @@ + + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {B69E6422-49B0-4E28-92F9-B8A7410A6ED9} + UnitTest + ManagedCProj + DynamicLibrary + Unicode + true + false + + + + + ..\..\bextutil\inc + + + + + Create + + 4564;4691 + + + + + + + + + + + + + + ..\..\..\packages\WixBuildTools.TestSupport.4.0.50\lib\net472\WixBuildTools.TestSupport.dll + + + ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.50\lib\net472\WixBuildTools.TestSupport.Native.dll + + + + + {06027492-1CB9-48BC-B31E-C1F9356ED07E} + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters b/src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters new file mode 100644 index 00000000..f1711f81 --- /dev/null +++ b/src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/src/api/burn/test/BextUtilUnitTest/TestBundleExtension.cpp b/src/api/burn/test/BextUtilUnitTest/TestBundleExtension.cpp new file mode 100644 index 00000000..921303bb --- /dev/null +++ b/src/api/burn/test/BextUtilUnitTest/TestBundleExtension.cpp @@ -0,0 +1,42 @@ +// 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 "BextBaseBundleExtension.h" +#include "BextBaseBundleExtensionProc.h" + +class CTestBundleExtension : public CBextBaseBundleExtension +{ +public: + CTestBundleExtension( + __in IBundleExtensionEngine* pEngine + ) : CBextBaseBundleExtension(pEngine) + { + } +}; + +HRESULT TestBundleExtensionCreate( + __in IBundleExtensionEngine* pEngine, + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, + __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults, + __out IBundleExtension** ppBundleExtension + ) +{ + HRESULT hr = S_OK; + CTestBundleExtension* pExtension = NULL; + + pExtension = new CTestBundleExtension(pEngine); + ExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CTestBundleExtension."); + + hr = pExtension->Initialize(pArgs); + ExitOnFailure(hr, "CTestBundleExtension initialization failed"); + + pResults->pfnBundleExtensionProc = BextBaseBundleExtensionProc; + pResults->pvBundleExtensionProcContext = pExtension; + + *ppBundleExtension = pExtension; + pExtension = NULL; + +LExit: + ReleaseObject(pExtension); + return hr; +} diff --git a/src/api/burn/test/BextUtilUnitTest/packages.config b/src/api/burn/test/BextUtilUnitTest/packages.config new file mode 100644 index 00000000..6d381fbe --- /dev/null +++ b/src/api/burn/test/BextUtilUnitTest/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/api/burn/test/BextUtilUnitTest/precomp.cpp b/src/api/burn/test/BextUtilUnitTest/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/api/burn/test/BextUtilUnitTest/precomp.cpp @@ -0,0 +1,3 @@ +// 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" diff --git a/src/api/burn/test/BextUtilUnitTest/precomp.h b/src/api/burn/test/BextUtilUnitTest/precomp.h new file mode 100644 index 00000000..a6586f70 --- /dev/null +++ b/src/api/burn/test/BextUtilUnitTest/precomp.h @@ -0,0 +1,19 @@ +#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 +#include + +#include +#include + +#include "IBundleExtensionEngine.h" +#include "IBundleExtension.h" +#include "bextutil.h" + +#pragma managed +#include diff --git a/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs new file mode 100644 index 00000000..aaf5ee29 --- /dev/null +++ b/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs @@ -0,0 +1,132 @@ +// 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.Runtime.InteropServices; + 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", + }; + 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); + Assert.Equal(baFactory.BA.Command.CommandLineArgs, new string[] { "this", "is a", "test" }); + } + 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; + public Restart restart; + [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/burn/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs b/src/api/burn/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs new file mode 100644 index 00000000..44142e3d --- /dev/null +++ b/src/api/burn/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs @@ -0,0 +1,93 @@ +// 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 WixToolset.Mba.Core; + using Xunit; + + public class VerUtilFixture + { + [Fact] + public void CanCompareStringVersions() + { + var version1 = "1.2.3.4+abcd"; + var version2 = "1.2.3.4+zyxw"; + + Assert.Equal(0, VerUtil.CompareStringVersions(version1, version2, strict: false)); + } + + [Fact] + public void CanCopyVersion() + { + var version = "1.2.3.4-5.6.7.8.9.0"; + + VerUtilVersion copiedVersion = null; + try + { + using (var parsedVersion = VerUtil.ParseVersion(version, strict: true)) + { + copiedVersion = VerUtil.CopyVersion(parsedVersion); + } + + using (var secondVersion = VerUtil.ParseVersion(version, strict: true)) + { + Assert.Equal(0, VerUtil.CompareParsedVersions(copiedVersion, secondVersion)); + } + } + finally + { + copiedVersion?.Dispose(); + } + } + + [Fact] + public void CanCreateFromQword() + { + var version = new Version(100, 200, 300, 400); + var qwVersion = Engine.VersionToLong(version); + + using var parsedVersion = VerUtil.VersionFromQword(qwVersion); + Assert.Equal("100.200.300.400", parsedVersion.Version); + Assert.Equal(100u, parsedVersion.Major); + Assert.Equal(200u, parsedVersion.Minor); + Assert.Equal(300u, parsedVersion.Patch); + Assert.Equal(400u, parsedVersion.Revision); + Assert.Empty(parsedVersion.ReleaseLabels); + Assert.Equal("", parsedVersion.Metadata); + Assert.False(parsedVersion.IsInvalid); + } + + [Fact] + public void CanParseVersion() + { + var version = "1.2.3.4-a.b.c.d.5.+abc123"; + + using var parsedVersion = VerUtil.ParseVersion(version, strict: false); + Assert.Equal(version, parsedVersion.Version); + Assert.Equal(1u, parsedVersion.Major); + Assert.Equal(2u, parsedVersion.Minor); + Assert.Equal(3u, parsedVersion.Patch); + Assert.Equal(4u, parsedVersion.Revision); + Assert.Equal(5, parsedVersion.ReleaseLabels.Length); + Assert.Equal("+abc123", parsedVersion.Metadata); + Assert.True(parsedVersion.IsInvalid); + + Assert.Equal("a", parsedVersion.ReleaseLabels[0].Label); + Assert.False(parsedVersion.ReleaseLabels[0].IsNumeric); + + Assert.Equal("b", parsedVersion.ReleaseLabels[1].Label); + Assert.False(parsedVersion.ReleaseLabels[1].IsNumeric); + + Assert.Equal("c", parsedVersion.ReleaseLabels[2].Label); + Assert.False(parsedVersion.ReleaseLabels[2].IsNumeric); + + Assert.Equal("d", parsedVersion.ReleaseLabels[3].Label); + Assert.False(parsedVersion.ReleaseLabels[3].IsNumeric); + + Assert.Equal("5", parsedVersion.ReleaseLabels[4].Label); + Assert.True(parsedVersion.ReleaseLabels[4].IsNumeric); + Assert.Equal(5u, parsedVersion.ReleaseLabels[4].Value); + } + } +} diff --git a/src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj new file mode 100644 index 00000000..53d82f7e --- /dev/null +++ b/src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj @@ -0,0 +1,21 @@ + + + + + + netcoreapp3.1 + false + win-x86 + false + + + + + + + + + + + + diff --git a/src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject b/src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/api/burn/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp deleted file mode 100644 index 301b88a5..00000000 --- a/src/balutil/BalBootstrapperEngine.cpp +++ /dev/null @@ -1,629 +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" - - -class CBalBootstrapperEngine : public IBootstrapperEngine -{ -public: // IUnknown - virtual STDMETHODIMP QueryInterface( - __in REFIID riid, - __out LPVOID *ppvObject - ) - { - if (!ppvObject) - { - return E_INVALIDARG; - } - - *ppvObject = NULL; - - if (::IsEqualIID(__uuidof(IBootstrapperEngine), riid)) - { - *ppvObject = static_cast(this); - } - else if (::IsEqualIID(IID_IMarshal, riid)) - { - return m_pFreeThreadedMarshaler->QueryInterface(riid, ppvObject); - } - else if (::IsEqualIID(IID_IUnknown, riid)) - { - *ppvObject = reinterpret_cast(this); - } - else // no interface for requested iid - { - return E_NOINTERFACE; - } - - AddRef(); - return S_OK; - } - - virtual STDMETHODIMP_(ULONG) AddRef() - { - return ::InterlockedIncrement(&this->m_cReferences); - } - - virtual STDMETHODIMP_(ULONG) Release() - { - long l = ::InterlockedDecrement(&this->m_cReferences); - if (0 < l) - { - return l; - } - - delete this; - return 0; - } - -public: // IBootstrapperEngine - virtual STDMETHODIMP GetPackageCount( - __out DWORD* pcPackages - ) - { - HRESULT hr = S_OK; - BAENGINE_GETPACKAGECOUNT_ARGS args = { }; - BAENGINE_GETPACKAGECOUNT_RESULTS results = { }; - - ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required"); - - args.cbSize = sizeof(args); - - results.cbSize = sizeof(results); - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &args, &results, m_pvBAEngineProcContext); - - *pcPackages = results.cPackages; - - LExit: - return hr; - } - - virtual STDMETHODIMP GetVariableNumeric( - __in_z LPCWSTR wzVariable, - __out LONGLONG* pllValue - ) - { - HRESULT hr = S_OK; - BAENGINE_GETVARIABLENUMERIC_ARGS args = { }; - BAENGINE_GETVARIABLENUMERIC_RESULTS results = { }; - - ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - - results.cbSize = sizeof(results); - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); - - *pllValue = results.llValue; - - LExit: - SecureZeroMemory(&results, sizeof(results)); - return hr; - } - - virtual STDMETHODIMP GetVariableString( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) - { - HRESULT hr = S_OK; - BAENGINE_GETVARIABLESTRING_ARGS args = { }; - BAENGINE_GETVARIABLESTRING_RESULTS results = { }; - - ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); - - *pcchValue = results.cchValue; - - LExit: - return hr; - } - - virtual STDMETHODIMP GetVariableVersion( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) - { - HRESULT hr = S_OK; - BAENGINE_GETVARIABLEVERSION_ARGS args = { }; - BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; - - ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); - - *pcchValue = results.cchValue; - - LExit: - return hr; - } - - virtual STDMETHODIMP FormatString( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T* pcchOut - ) - { - HRESULT hr = S_OK; - BAENGINE_FORMATSTRING_ARGS args = { }; - BAENGINE_FORMATSTRING_RESULTS results = { }; - - ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); - - args.cbSize = sizeof(args); - args.wzIn = wzIn; - - results.cbSize = sizeof(results); - results.wzOut = wzOut; - results.cchOut = *pcchOut; - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBAEngineProcContext); - - *pcchOut = results.cchOut; - - LExit: - return hr; - } - - virtual STDMETHODIMP EscapeString( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T* pcchOut - ) - { - HRESULT hr = S_OK; - BAENGINE_ESCAPESTRING_ARGS args = { }; - BAENGINE_ESCAPESTRING_RESULTS results = { }; - - ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); - - args.cbSize = sizeof(args); - args.wzIn = wzIn; - - results.cbSize = sizeof(results); - results.wzOut = wzOut; - results.cchOut = *pcchOut; - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBAEngineProcContext); - - *pcchOut = results.cchOut; - - LExit: - return hr; - } - - virtual STDMETHODIMP EvaluateCondition( - __in_z LPCWSTR wzCondition, - __out BOOL* pf - ) - { - HRESULT hr = S_OK; - BAENGINE_EVALUATECONDITION_ARGS args = { }; - BAENGINE_EVALUATECONDITION_RESULTS results = { }; - - ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); - - args.cbSize = sizeof(args); - args.wzCondition = wzCondition; - - results.cbSize = sizeof(results); - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBAEngineProcContext); - - *pf = results.f; - - LExit: - return hr; - } - - virtual STDMETHODIMP Log( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in_z LPCWSTR wzMessage - ) - { - BAENGINE_LOG_ARGS args = { }; - BAENGINE_LOG_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.level = level; - args.wzMessage = wzMessage; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SendEmbeddedError( - __in DWORD dwErrorCode, - __in_z_opt LPCWSTR wzMessage, - __in DWORD dwUIHint, - __out int* pnResult - ) - { - HRESULT hr = S_OK; - BAENGINE_SENDEMBEDDEDERROR_ARGS args = { }; - BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { }; - - ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - - args.cbSize = sizeof(args); - args.dwErrorCode = dwErrorCode; - args.wzMessage = wzMessage; - args.dwUIHint = dwUIHint; - - results.cbSize = sizeof(results); - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &args, &results, m_pvBAEngineProcContext); - - *pnResult = results.nResult; - - LExit: - return hr; - } - - virtual STDMETHODIMP SendEmbeddedProgress( - __in DWORD dwProgressPercentage, - __in DWORD dwOverallProgressPercentage, - __out int* pnResult - ) - { - HRESULT hr = S_OK; - BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { }; - BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { }; - - ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - - args.cbSize = sizeof(args); - args.dwProgressPercentage = dwProgressPercentage; - args.dwOverallProgressPercentage = dwOverallProgressPercentage; - - results.cbSize = sizeof(results); - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &args, &results, m_pvBAEngineProcContext); - - *pnResult = results.nResult; - - LExit: - return hr; - } - - virtual STDMETHODIMP SetUpdate( - __in_z_opt LPCWSTR wzLocalSource, - __in_z_opt LPCWSTR wzDownloadSource, - __in DWORD64 qwSize, - __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_bcount_opt(cbHash) BYTE* rgbHash, - __in DWORD cbHash - ) - { - BAENGINE_SETUPDATE_ARGS args = { }; - BAENGINE_SETUPDATE_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzLocalSource = wzLocalSource; - args.wzDownloadSource = wzDownloadSource; - args.qwSize = qwSize; - args.hashType = hashType; - args.rgbHash = rgbHash; - args.cbHash = cbHash; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SetLocalSource( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzPath - ) - { - BAENGINE_SETLOCALSOURCE_ARGS args = { }; - BAENGINE_SETLOCALSOURCE_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzPackageOrContainerId = wzPackageOrContainerId; - args.wzPayloadId = wzPayloadId; - args.wzPath = wzPath; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SetDownloadSource( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzUrl, - __in_z_opt LPCWSTR wzUser, - __in_z_opt LPCWSTR wzPassword - ) - { - BAENGINE_SETDOWNLOADSOURCE_ARGS args = { }; - BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzPackageOrContainerId = wzPackageOrContainerId; - args.wzPayloadId = wzPayloadId; - args.wzUrl = wzUrl; - args.wzUser = wzUser; - args.wzPassword = wzPassword; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SetVariableNumeric( - __in_z LPCWSTR wzVariable, - __in LONGLONG llValue - ) - { - BAENGINE_SETVARIABLENUMERIC_ARGS args = { }; - BAENGINE_SETVARIABLENUMERIC_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.llValue = llValue; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SetVariableString( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue, - __in BOOL fFormatted - ) - { - BAENGINE_SETVARIABLESTRING_ARGS args = { }; - BAENGINE_SETVARIABLESTRING_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.wzValue = wzValue; - args.fFormatted = fFormatted; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SetVariableVersion( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) - { - BAENGINE_SETVARIABLEVERSION_ARGS args = { }; - BAENGINE_SETVARIABLEVERSION_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.wzValue = wzValue; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP CloseSplashScreen() - { - BAENGINE_CLOSESPLASHSCREEN_ARGS args = { }; - BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { }; - - args.cbSize = sizeof(args); - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP Detect( - __in_opt HWND hwndParent - ) - { - BAENGINE_DETECT_ARGS args = { }; - BAENGINE_DETECT_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP Plan( - __in BOOTSTRAPPER_ACTION action - ) - { - BAENGINE_PLAN_ARGS args = { }; - BAENGINE_PLAN_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.action = action; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP Elevate( - __in_opt HWND hwndParent - ) - { - BAENGINE_ELEVATE_ARGS args = { }; - BAENGINE_ELEVATE_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP Apply( - __in HWND hwndParent - ) - { - BAENGINE_APPLY_ARGS args = { }; - BAENGINE_APPLY_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP Quit( - __in DWORD dwExitCode - ) - { - BAENGINE_QUIT_ARGS args = { }; - BAENGINE_QUIT_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.dwExitCode = dwExitCode; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP LaunchApprovedExe( - __in_opt HWND hwndParent, - __in_z LPCWSTR wzApprovedExeForElevationId, - __in_z_opt LPCWSTR wzArguments, - __in DWORD dwWaitForInputIdleTimeout - ) - { - BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { }; - BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.hwndParent = hwndParent; - args.wzApprovedExeForElevationId = wzApprovedExeForElevationId; - args.wzArguments = wzArguments; - args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP SetUpdateSource( - __in_z LPCWSTR wzUrl - ) - { - BAENGINE_SETUPDATESOURCE_ARGS args = { }; - BAENGINE_SETUPDATESOURCE_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzUrl = wzUrl; - - results.cbSize = sizeof(results); - - return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE, &args, &results, m_pvBAEngineProcContext); - } - - virtual STDMETHODIMP CompareVersions( - __in_z LPCWSTR wzVersion1, - __in_z LPCWSTR wzVersion2, - __out int* pnResult - ) - { - HRESULT hr = S_OK; - BAENGINE_COMPAREVERSIONS_ARGS args = { }; - BAENGINE_COMPAREVERSIONS_RESULTS results = { }; - - ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - - args.cbSize = sizeof(args); - args.wzVersion1 = wzVersion1; - args.wzVersion2 = wzVersion2; - - results.cbSize = sizeof(results); - - hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBAEngineProcContext); - - *pnResult = results.nResult; - - LExit: - return hr; - } - -public: - HRESULT Init() - { - return ::CoCreateFreeThreadedMarshaler(this, &m_pFreeThreadedMarshaler); - } - - CBalBootstrapperEngine( - __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, - __in_opt LPVOID pvBAEngineProcContext - ) - { - m_cReferences = 1; - m_pfnBAEngineProc = pfnBAEngineProc; - m_pvBAEngineProcContext = pvBAEngineProcContext; - m_pFreeThreadedMarshaler = NULL; - } - - ~CBalBootstrapperEngine() - { - ReleaseObject(m_pFreeThreadedMarshaler); - } - -private: - long m_cReferences; - PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc; - LPVOID m_pvBAEngineProcContext; - IUnknown* m_pFreeThreadedMarshaler; -}; - -HRESULT BalBootstrapperEngineCreate( - __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc, - __in_opt LPVOID pvBAEngineProcContext, - __out IBootstrapperEngine** ppBootstrapperEngine - ) -{ - HRESULT hr = S_OK; - CBalBootstrapperEngine* pBootstrapperEngine = NULL; - - pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext); - ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object."); - - hr = pBootstrapperEngine->Init(); - ExitOnFailure(hr, "Failed to initialize CBalBootstrapperEngine."); - - hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine)); - ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object."); - -LExit: - ReleaseObject(pBootstrapperEngine); - return hr; -} diff --git a/src/balutil/balcondition.cpp b/src/balutil/balcondition.cpp deleted file mode 100644 index 8b05508f..00000000 --- a/src/balutil/balcondition.cpp +++ /dev/null @@ -1,124 +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" - -// prototypes - - -DAPI_(HRESULT) BalConditionsParseFromXml( - __in BAL_CONDITIONS* pConditions, - __in IXMLDOMDocument* pixdManifest, - __in_opt WIX_LOCALIZATION* pWixLoc - ) -{ - HRESULT hr = S_OK; - IXMLDOMNodeList* pNodeList = NULL; - IXMLDOMNode* pNode = NULL; - BAL_CONDITION* prgConditions = NULL; - DWORD cConditions = 0; - - hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalCondition", &pNodeList); - ExitOnFailure(hr, "Failed to select all conditions."); - - hr = pNodeList->get_length(reinterpret_cast(&cConditions)); - ExitOnFailure(hr, "Failed to get the condition count."); - - if (!cConditions) - { - ExitFunction(); - } - - prgConditions = static_cast(MemAlloc(sizeof(BAL_CONDITION) * cConditions, TRUE)); - ExitOnNull(prgConditions, hr, E_OUTOFMEMORY, "Failed to allocate memory for conditions."); - - DWORD iCondition = 0; - while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) - { - hr = XmlGetAttributeEx(pNode, L"Condition", &prgConditions[iCondition].sczCondition); - ExitOnFailure(hr, "Failed to get condition for condition."); - - hr = XmlGetAttributeEx(pNode, L"Message", &prgConditions[iCondition].sczMessage); - ExitOnFailure(hr, "Failed to get message for condition."); - - if (pWixLoc && prgConditions[iCondition].sczMessage && *prgConditions[iCondition].sczMessage) - { - hr = LocLocalizeString(pWixLoc, &prgConditions[iCondition].sczMessage); - ExitOnFailure(hr, "Failed to localize condition message."); - } - - ++iCondition; - ReleaseNullObject(pNode); - } - ExitOnFailure(hr, "Failed to parse all condition elements."); - - if (S_FALSE == hr) - { - hr = S_OK; - } - - pConditions->cConditions = cConditions; - pConditions->rgConditions = prgConditions; - prgConditions = NULL; - -LExit: - ReleaseMem(prgConditions); - ReleaseObject(pNode); - ReleaseObject(pNodeList); - - return hr; -} - - -//the contents of psczMessage may be sensitive, should keep encrypted and SecureZeroFree -DAPI_(HRESULT) BalConditionEvaluate( - __in BAL_CONDITION* pCondition, - __in IBootstrapperEngine* pEngine, - __out BOOL* pfResult, - __out_z_opt LPWSTR* psczMessage - ) -{ - HRESULT hr = S_OK; - SIZE_T cchMessage = 0; - - hr = pEngine->EvaluateCondition(pCondition->sczCondition, pfResult); - ExitOnFailure(hr, "Failed to evaluate condition with bootstrapper engine."); - - if (psczMessage) - { - if (*psczMessage) - { - hr = StrMaxLength(*psczMessage, &cchMessage); - ExitOnFailure(hr, "Failed to get length of message."); - } - - hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, &cchMessage); - if (E_MOREDATA == hr) - { - ++cchMessage; - - hr = StrAllocSecure(psczMessage, cchMessage); - ExitOnFailure(hr, "Failed to allocate string for condition's formatted message."); - - hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, &cchMessage); - } - ExitOnFailure(hr, "Failed to format condition's message."); - } - -LExit: - return hr; -} - - -DAPI_(void) BalConditionsUninitialize( - __in BAL_CONDITIONS* pConditions - ) -{ - for (DWORD i = 0; i < pConditions->cConditions; ++i) - { - ReleaseStr(pConditions->rgConditions[i].sczMessage); - ReleaseStr(pConditions->rgConditions[i].sczCondition); - } - - ReleaseMem(pConditions->rgConditions); - memset(pConditions, 0, sizeof(BAL_CONDITIONS)); -} diff --git a/src/balutil/balinfo.cpp b/src/balutil/balinfo.cpp deleted file mode 100644 index 3abb9286..00000000 --- a/src/balutil/balinfo.cpp +++ /dev/null @@ -1,373 +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" - -// prototypes -static HRESULT ParsePackagesFromXml( - __in BAL_INFO_PACKAGES* pPackages, - __in IXMLDOMDocument* pixdManifest - ); -static HRESULT ParseBalPackageInfoFromXml( - __in BAL_INFO_PACKAGES* pPackages, - __in IXMLDOMDocument* pixdManifest - ); - - -DAPI_(HRESULT) BalInfoParseFromXml( - __in BAL_INFO_BUNDLE* pBundle, - __in IXMLDOMDocument* pixdManifest - ) -{ - HRESULT hr = S_OK; - IXMLDOMNode* pNode = NULL; - - hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBundleProperties", &pNode); - ExitOnFailure(hr, "Failed to select bundle information."); - - if (S_OK == hr) - { - hr = XmlGetYesNoAttribute(pNode, L"PerMachine", &pBundle->fPerMachine); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to read bundle information per-machine."); - } - - hr = XmlGetAttributeEx(pNode, L"DisplayName", &pBundle->sczName); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to read bundle information display name."); - } - - hr = XmlGetAttributeEx(pNode, L"LogPathVariable", &pBundle->sczLogVariable); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to read bundle information log path variable."); - } - } - - hr = ParsePackagesFromXml(&pBundle->packages, pixdManifest); - BalExitOnFailure(hr, "Failed to parse package information from bootstrapper application data."); - - hr = ParseBalPackageInfoFromXml(&pBundle->packages, pixdManifest); - BalExitOnFailure(hr, "Failed to parse bal package information from bootstrapper application data."); - -LExit: - ReleaseObject(pNode); - - return hr; -} - - -DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( - __in BAL_INFO_PACKAGES* pPackages, - __in LPCWSTR wzId, - __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in BOOL /*fPerMachine*/, - __out_opt BAL_INFO_PACKAGE** ppPackage - ) -{ - HRESULT hr = S_OK; - BAL_INFO_PACKAGE_TYPE type = BAL_INFO_PACKAGE_TYPE_UNKNOWN; - BAL_INFO_PACKAGE* pPackage = NULL; - - // Ensure we have a supported relation type. - switch (relationType) - { - case BOOTSTRAPPER_RELATION_ADDON: - type = BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON; - break; - - case BOOTSTRAPPER_RELATION_PATCH: - type = BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH; - break; - - case BOOTSTRAPPER_RELATION_UPGRADE: - type = BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE; - break; - - default: - ExitOnFailure(hr = E_INVALIDARG, "Unknown related bundle type: %u", relationType); - } - - // Check to see if the bundle is already in the list of packages. - for (DWORD i = 0; i < pPackages->cPackages; ++i) - { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1)) - { - ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)); - } - } - - // Add the related bundle as a package. - hr = MemEnsureArraySize(reinterpret_cast(&pPackages->rgPackages), pPackages->cPackages + 1, sizeof(BAL_INFO_PACKAGE), 2); - ExitOnFailure(hr, "Failed to allocate memory for related bundle package information."); - - pPackage = pPackages->rgPackages + pPackages->cPackages; - ++pPackages->cPackages; - - hr = StrAllocString(&pPackage->sczId, wzId, 0); - ExitOnFailure(hr, "Failed to copy related bundle package id."); - - pPackage->type = type; - - // TODO: try to look up the DisplayName and Description in Add/Remove Programs with the wzId. - - if (ppPackage) - { - *ppPackage = pPackage; - } - -LExit: - return hr; -} - - -DAPI_(HRESULT) BalInfoFindPackageById( - __in BAL_INFO_PACKAGES* pPackages, - __in LPCWSTR wzId, - __out BAL_INFO_PACKAGE** ppPackage - ) -{ - *ppPackage = NULL; - - for (DWORD i = 0; i < pPackages->cPackages; ++i) - { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1)) - { - *ppPackage = pPackages->rgPackages + i; - break; - } - } - - return *ppPackage ? S_OK : E_NOTFOUND; -} - - -DAPI_(void) BalInfoUninitialize( - __in BAL_INFO_BUNDLE* pBundle - ) -{ - for (DWORD i = 0; i < pBundle->packages.cPackages; ++i) - { - ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayName); - ReleaseStr(pBundle->packages.rgPackages[i].sczDescription); - ReleaseStr(pBundle->packages.rgPackages[i].sczId); - ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayInternalUICondition); - ReleaseStr(pBundle->packages.rgPackages[i].sczProductCode); - ReleaseStr(pBundle->packages.rgPackages[i].sczUpgradeCode); - ReleaseStr(pBundle->packages.rgPackages[i].sczVersion); - ReleaseStr(pBundle->packages.rgPackages[i].sczInstallCondition); - ReleaseStr(pBundle->packages.rgPackages[i].sczPrereqLicenseFile); - ReleaseStr(pBundle->packages.rgPackages[i].sczPrereqLicenseUrl); - } - - ReleaseMem(pBundle->packages.rgPackages); - - ReleaseStr(pBundle->sczName); - ReleaseStr(pBundle->sczLogVariable); - memset(pBundle, 0, sizeof(BAL_INFO_BUNDLE)); -} - - -static HRESULT ParsePackagesFromXml( - __in BAL_INFO_PACKAGES* pPackages, - __in IXMLDOMDocument* pixdManifest - ) -{ - HRESULT hr = S_OK; - IXMLDOMNodeList* pNodeList = NULL; - IXMLDOMNode* pNode = NULL; - BAL_INFO_PACKAGE* prgPackages = NULL; - DWORD cPackages = 0; - LPWSTR scz = NULL; - - hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPackageProperties", &pNodeList); - ExitOnFailure(hr, "Failed to select all packages."); - - hr = pNodeList->get_length(reinterpret_cast(&cPackages)); - ExitOnFailure(hr, "Failed to get the package count."); - - prgPackages = static_cast(MemAlloc(sizeof(BAL_INFO_PACKAGE) * cPackages, TRUE)); - ExitOnNull(prgPackages, hr, E_OUTOFMEMORY, "Failed to allocate memory for packages."); - - DWORD iPackage = 0; - while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) - { - hr = XmlGetAttributeEx(pNode, L"Package", &prgPackages[iPackage].sczId); - ExitOnFailure(hr, "Failed to get package identifier for package."); - - hr = XmlGetAttributeEx(pNode, L"DisplayName", &prgPackages[iPackage].sczDisplayName); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get display name for package."); - } - - hr = XmlGetAttributeEx(pNode, L"Description", &prgPackages[iPackage].sczDescription); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get description for package."); - } - - hr = XmlGetAttributeEx(pNode, L"PackageType", &scz); - ExitOnFailure(hr, "Failed to get package type for package."); - - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Exe", -1, scz, -1)) - { - prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_EXE; - } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msi", -1, scz, -1)) - { - prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSI; - } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msp", -1, scz, -1)) - { - prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSP; - } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msu", -1, scz, -1)) - { - prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSU; - } - - hr = XmlGetYesNoAttribute(pNode, L"Permanent", &prgPackages[iPackage].fPermanent); - ExitOnFailure(hr, "Failed to get permanent setting for package."); - - hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital); - ExitOnFailure(hr, "Failed to get vital setting for package."); - - hr = XmlGetAttributeEx(pNode, L"ProductCode", &prgPackages[iPackage].sczProductCode); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get product code for package."); - } - - hr = XmlGetAttributeEx(pNode, L"UpgradeCode", &prgPackages[iPackage].sczUpgradeCode); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get upgrade code for package."); - } - - hr = XmlGetAttributeEx(pNode, L"Version", &prgPackages[iPackage].sczVersion); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get version for package."); - } - - hr = XmlGetAttributeEx(pNode, L"InstallCondition", &prgPackages[iPackage].sczInstallCondition); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get install condition for package."); - } - - hr = XmlGetAttributeEx(pNode, L"Cache", &scz); - ExitOnFailure(hr, "Failed to get cache type for package."); - - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"remove", -1)) - { - prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_REMOVE; - } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"keep", -1)) - { - prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_KEEP; - } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"force", -1)) - { - prgPackages[iPackage].cacheType = BOOTSTRAPPER_CACHE_TYPE_FORCE; - } - - ++iPackage; - ReleaseNullObject(pNode); - } - ExitOnFailure(hr, "Failed to parse all package property elements."); - - if (S_FALSE == hr) - { - hr = S_OK; - } - - pPackages->cPackages = cPackages; - pPackages->rgPackages = prgPackages; - prgPackages = NULL; - -LExit: - ReleaseStr(scz); - ReleaseMem(prgPackages); - ReleaseObject(pNode); - ReleaseObject(pNodeList); - - return hr; -} - - -static HRESULT ParseBalPackageInfoFromXml( - __in BAL_INFO_PACKAGES* pPackages, - __in IXMLDOMDocument* pixdManifest - ) -{ - HRESULT hr = S_OK; - IXMLDOMNodeList* pNodeList = NULL; - IXMLDOMNode* pNode = NULL; - LPWSTR scz = NULL; - BAL_INFO_PACKAGE* pPackage = NULL; - - hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalPackageInfo", &pNodeList); - ExitOnFailure(hr, "Failed to select all packages."); - - while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) - { - hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); - ExitOnFailure(hr, "Failed to get package identifier for WixBalPackageInfo."); - - hr = BalInfoFindPackageById(pPackages, scz, &pPackage); - ExitOnFailure(hr, "Failed to find package specified in WixBalPackageInfo: %ls", scz); - - hr = XmlGetAttributeEx(pNode, L"DisplayInternalUICondition", &pPackage->sczDisplayInternalUICondition); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get DisplayInternalUICondition setting for package."); - } - - ReleaseNullObject(pNode); - } - ExitOnFailure(hr, "Failed to parse all WixBalPackageInfo elements."); - - hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixMbaPrereqInformation", &pNodeList); - ExitOnFailure(hr, "Failed to select all packages."); - - while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) - { - hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); - ExitOnFailure(hr, "Failed to get package identifier for WixMbaPrereqInformation."); - - hr = BalInfoFindPackageById(pPackages, scz, &pPackage); - ExitOnFailure(hr, "Failed to find package specified in WixMbaPrereqInformation: %ls", scz); - - pPackage->fPrereqPackage = TRUE; - - hr = XmlGetAttributeEx(pNode, L"LicenseFile", &pPackage->sczPrereqLicenseFile); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get LicenseFile setting for prereq package."); - } - - hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &pPackage->sczPrereqLicenseUrl); - if (E_NOTFOUND != hr) - { - ExitOnFailure(hr, "Failed to get LicenseUrl setting for prereq package."); - } - - ReleaseNullObject(pNode); - } - ExitOnFailure(hr, "Failed to parse all WixMbaPrereqInformation elements."); - - if (S_FALSE == hr) - { - hr = S_OK; - } - -LExit: - ReleaseStr(scz); - ReleaseObject(pNode); - ReleaseObject(pNodeList); - - return hr; -} diff --git a/src/balutil/balretry.cpp b/src/balutil/balretry.cpp deleted file mode 100644 index 9d8abd6d..00000000 --- a/src/balutil/balretry.cpp +++ /dev/null @@ -1,246 +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" - -typedef enum BALRETRY_TYPE -{ - BALRETRY_TYPE_CACHE_CONTAINER, - BALRETRY_TYPE_CACHE_PAYLOAD, - BALRETRY_TYPE_EXECUTE, -} BALRETRY_TYPE; - -struct BALRETRY_INFO -{ - LPWSTR sczId; - DWORD cRetries; - DWORD dwLastError; -}; - -static DWORD vdwMaxRetries = 0; -static DWORD vdwTimeout = 0; -static BALRETRY_INFO vrgRetryInfo[3]; - -// prototypes -static BOOL IsActiveRetryEntry( - __in BALRETRY_TYPE type, - __in_z LPCWSTR sczId - ); - -static HRESULT StartActiveRetryEntry( - __in BALRETRY_TYPE type, - __in_z LPCWSTR sczId - ); - - -DAPI_(void) BalRetryInitialize( - __in DWORD dwMaxRetries, - __in DWORD dwTimeout - ) -{ - BalRetryUninitialize(); // clean everything out. - - vdwMaxRetries = dwMaxRetries; - vdwTimeout = dwTimeout; -} - - -DAPI_(void) BalRetryUninitialize() -{ - for (DWORD i = 0; i < countof(vrgRetryInfo); ++i) - { - ReleaseStr(vrgRetryInfo[i].sczId); - memset(vrgRetryInfo + i, 0, sizeof(BALRETRY_INFO)); - } - - vdwMaxRetries = 0; - vdwTimeout = 0; -} - - -DAPI_(void) BalRetryStartContainerOrPayload( - __in_z_opt LPCWSTR wzContainerOrPackageId, - __in_z_opt LPCWSTR wzPayloadId - ) -{ - if (!wzContainerOrPackageId && !wzPayloadId) - { - ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); - ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); - } - else if (wzPayloadId) - { - StartActiveRetryEntry(BALRETRY_TYPE_CACHE_PAYLOAD, wzPayloadId); - } - else - { - StartActiveRetryEntry(BALRETRY_TYPE_CACHE_CONTAINER, wzContainerOrPackageId); - } -} - - -DAPI_(void) BalRetryStartPackage( - __in_z LPCWSTR wzPackageId - ) -{ - StartActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId); -} - - -DAPI_(void) BalRetryErrorOccurred( - __in_z LPCWSTR wzPackageId, - __in DWORD dwError - ) -{ - if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId)) - { - vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; - } -} - - -DAPI_(HRESULT) BalRetryEndContainerOrPayload( - __in_z_opt LPCWSTR wzContainerOrPackageId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrError, - __inout BOOL* pfRetry - ) -{ - HRESULT hr = S_OK; - BALRETRY_TYPE type = BALRETRY_TYPE_CACHE_PAYLOAD; - LPCWSTR wzId = NULL; - - if (!wzContainerOrPackageId && !wzPayloadId) - { - ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); - ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); - ExitFunction(); - } - else if (wzPayloadId) - { - type = BALRETRY_TYPE_CACHE_PAYLOAD; - wzId = wzPayloadId; - } - else - { - type = BALRETRY_TYPE_CACHE_CONTAINER; - wzId = wzContainerOrPackageId; - } - - if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzId)) - { - // Retry on all errors except the following. - if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && - BG_E_NETWORK_DISCONNECTED != hrError && - HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && - HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) - { - *pfRetry = TRUE; - } - } - -LExit: - return hr; -} - - -DAPI_(HRESULT) BalRetryEndPackage( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrError, - __inout BOOL* pfRetry - ) -{ - HRESULT hr = S_OK; - BALRETRY_TYPE type = BALRETRY_TYPE_EXECUTE; - - if (!wzPackageId || !*wzPackageId) - { - ReleaseNullStr(vrgRetryInfo[type].sczId); - } - else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId)) - { - // If the service is out of whack, just try again. - if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) - { - *pfRetry = TRUE; - } - else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) - { - DWORD dwError = vrgRetryInfo[type].dwLastError; - - // If we failed with one of these specific error codes, then retry since - // we've seen these have a high success of succeeding on retry. - if (1303 == dwError || - 1304 == dwError || - 1306 == dwError || - 1307 == dwError || - 1309 == dwError || - 1310 == dwError || - 1311 == dwError || - 1312 == dwError || - 1316 == dwError || - 1317 == dwError || - 1321 == dwError || - 1335 == dwError || - 1402 == dwError || - 1406 == dwError || - 1606 == dwError || - 1706 == dwError || - 1719 == dwError || - 1723 == dwError || - 1923 == dwError || - 1931 == dwError) - { - *pfRetry = TRUE; - } - } - else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) - { - *pfRetry = TRUE; - } - } - - return hr; -} - - -// Internal functions. - -static BOOL IsActiveRetryEntry( - __in BALRETRY_TYPE type, - __in_z LPCWSTR sczId - ) -{ - BOOL fActive = FALSE; - - fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, sczId, -1, vrgRetryInfo[type].sczId, -1); - - return fActive; -} - -static HRESULT StartActiveRetryEntry( - __in BALRETRY_TYPE type, - __in_z LPCWSTR sczId - ) -{ - HRESULT hr = S_OK; - - if (!sczId || !*sczId) - { - ReleaseNullStr(vrgRetryInfo[type].sczId); - } - else if (IsActiveRetryEntry(type, sczId)) - { - ++vrgRetryInfo[type].cRetries; - ::Sleep(vdwTimeout); - } - else - { - hr = StrAllocString(&vrgRetryInfo[type].sczId, sczId, 0); - - vrgRetryInfo[type].cRetries = 0; - } - - vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; - - return hr; -} diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp deleted file mode 100644 index 7a638219..00000000 --- a/src/balutil/balutil.cpp +++ /dev/null @@ -1,425 +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" - -const DWORD VARIABLE_GROW_FACTOR = 80; -static IBootstrapperEngine* vpEngine = NULL; - -// prototypes - -DAPI_(void) BalInitialize( - __in IBootstrapperEngine* pEngine - ) -{ - pEngine->AddRef(); - - ReleaseObject(vpEngine); - vpEngine = pEngine; -} - -DAPI_(HRESULT) BalInitializeFromCreateArgs( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __out_opt IBootstrapperEngine** ppEngine - ) -{ - HRESULT hr = S_OK; - IBootstrapperEngine* pEngine = NULL; - - hr = BalBootstrapperEngineCreate(pArgs->pfnBootstrapperEngineProc, pArgs->pvBootstrapperEngineProcContext, &pEngine); - ExitOnFailure(hr, "Failed to create BalBootstrapperEngine."); - - BalInitialize(pEngine); - - if (ppEngine) - { - *ppEngine = pEngine; - } - pEngine = NULL; - -LExit: - ReleaseObject(pEngine); - - return hr; -} - - -DAPI_(void) BalUninitialize() -{ - ReleaseNullObject(vpEngine); -} - - -DAPI_(HRESULT) BalManifestLoad( - __in HMODULE hBootstrapperApplicationModule, - __out IXMLDOMDocument** ppixdManifest - ) -{ - HRESULT hr = S_OK; - LPWSTR sczPath = NULL; - - hr = PathRelativeToModule(&sczPath, BAL_MANIFEST_FILENAME, hBootstrapperApplicationModule); - ExitOnFailure(hr, "Failed to get path to bootstrapper application manifest: %ls", BAL_MANIFEST_FILENAME); - - hr = XmlLoadDocumentFromFile(sczPath, ppixdManifest); - ExitOnFailure(hr, "Failed to load bootstrapper application manifest '%ls' from path: %ls", BAL_MANIFEST_FILENAME, sczPath); - -LExit: - ReleaseStr(sczPath); - return hr; -} - - -DAPI_(HRESULT) BalEvaluateCondition( - __in_z LPCWSTR wzCondition, - __out BOOL* pf - ) -{ - HRESULT hr = S_OK; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = vpEngine->EvaluateCondition(wzCondition, pf); - -LExit: - return hr; -} - - -// The contents of psczOut may be sensitive, should keep encrypted and SecureZeroFree. -DAPI_(HRESULT) BalFormatString( - __in_z LPCWSTR wzFormat, - __inout LPWSTR* psczOut - ) -{ - HRESULT hr = S_OK; - SIZE_T cch = 0; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - if (*psczOut) - { - hr = StrMaxLength(*psczOut, &cch); - ExitOnFailure(hr, "Failed to determine length of value."); - } - - hr = vpEngine->FormatString(wzFormat, *psczOut, &cch); - if (E_MOREDATA == hr) - { - ++cch; - - hr = StrAllocSecure(psczOut, cch); - ExitOnFailure(hr, "Failed to allocate value."); - - hr = vpEngine->FormatString(wzFormat, *psczOut, &cch); - } - -LExit: - return hr; -} - - -// The contents of pllValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroMemory. -DAPI_(HRESULT) BalGetNumericVariable( - __in_z LPCWSTR wzVariable, - __out LONGLONG* pllValue - ) -{ - HRESULT hr = S_OK; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = vpEngine->GetVariableNumeric(wzVariable, pllValue); - -LExit: - return hr; -} - - -DAPI_(HRESULT) BalSetNumericVariable( - __in_z LPCWSTR wzVariable, - __in LONGLONG llValue - ) -{ - HRESULT hr = S_OK; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = vpEngine->SetVariableNumeric(wzVariable, llValue); - -LExit: - return hr; -} - - -DAPI_(BOOL) BalVariableExists( - __in_z LPCWSTR wzVariable - ) -{ - HRESULT hr = S_OK; - SIZE_T cch = 0; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = vpEngine->GetVariableString(wzVariable, NULL, &cch); - -LExit: - return E_NOTFOUND != hr; -} - - -// The contents of psczValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroFree. -DAPI_(HRESULT) BalGetStringVariable( - __in_z LPCWSTR wzVariable, - __inout LPWSTR* psczValue - ) -{ - HRESULT hr = S_OK; - SIZE_T cch = 0; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - if (*psczValue) - { - hr = StrMaxLength(*psczValue, &cch); - ExitOnFailure(hr, "Failed to determine length of value."); - } - - hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch); - if (E_MOREDATA == hr) - { - ++cch; - - hr = StrAllocSecure(psczValue, cch); - ExitOnFailure(hr, "Failed to allocate value."); - - hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch); - } - -LExit: - return hr; -} - -DAPI_(HRESULT) BalSetStringVariable( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue, - __in BOOL fFormatted - ) -{ - HRESULT hr = S_OK; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = vpEngine->SetVariableString(wzVariable, wzValue, fFormatted); - -LExit: - return hr; -} - - -DAPIV_(HRESULT) BalLog( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - ... - ) -{ - HRESULT hr = S_OK; - va_list args; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - va_start(args, szFormat); - hr = BalLogArgs(level, szFormat, args); - va_end(args); - -LExit: - return hr; -} - - -DAPI_(HRESULT) BalLogArgs( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ) -{ - HRESULT hr = S_OK; - LPSTR sczFormattedAnsi = NULL; - LPWSTR sczMessage = NULL; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - ExitOnFailure(hr, "Failed to format log string."); - - hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); - ExitOnFailure(hr, "Failed to convert log string to Unicode."); - - hr = vpEngine->Log(level, sczMessage); - -LExit: - ReleaseStr(sczMessage); - ReleaseStr(sczFormattedAnsi); - return hr; -} - - -DAPIV_(HRESULT) BalLogError( - __in HRESULT hrError, - __in_z __format_string LPCSTR szFormat, - ... - ) -{ - HRESULT hr = S_OK; - va_list args; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - va_start(args, szFormat); - hr = BalLogErrorArgs(hrError, szFormat, args); - va_end(args); - -LExit: - return hr; -} - - -DAPI_(HRESULT) BalLogErrorArgs( - __in HRESULT hrError, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ) -{ - HRESULT hr = S_OK; - LPSTR sczFormattedAnsi = NULL; - LPWSTR sczMessage = NULL; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - ExitOnFailure(hr, "Failed to format error log string."); - - hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); - ExitOnFailure(hr, "Failed to prepend error number to error log string."); - - hr = vpEngine->Log(BOOTSTRAPPER_LOG_LEVEL_ERROR, sczMessage); - -LExit: - ReleaseStr(sczMessage); - ReleaseStr(sczFormattedAnsi); - return hr; -} - -DAPIV_(HRESULT) BalLogId( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in DWORD dwLogId, - __in HMODULE hModule, - ... - ) -{ - HRESULT hr = S_OK; - va_list args; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - va_start(args, hModule); - hr = BalLogIdArgs(level, dwLogId, hModule, args); - va_end(args); - -LExit: - return hr; -} - -DAPI_(HRESULT) BalLogIdArgs( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in DWORD dwLogId, - __in HMODULE hModule, - __in va_list args - ) -{ - - HRESULT hr = S_OK; - LPWSTR pwz = NULL; - DWORD cch = 0; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BalInitialize() must be called first."); - } - - // Get the string for the id. -#pragma prefast(push) -#pragma prefast(disable:25028) -#pragma prefast(disable:25068) - cch = ::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE, - static_cast(hModule), dwLogId, 0, reinterpret_cast(&pwz), 0, &args); -#pragma prefast(pop) - - if (0 == cch) - { - ExitOnLastError(hr, "Failed to log id: %d", dwLogId); - } - - if (2 <= cch && L'\r' == pwz[cch - 2] && L'\n' == pwz[cch - 1]) - { - pwz[cch - 2] = L'\0'; // remove newline from message table. - } - - hr = vpEngine->Log(level, pwz); - -LExit: - if (pwz) - { - ::LocalFree(pwz); - } - - return hr; -} diff --git a/src/balutil/balutil.nuspec b/src/balutil/balutil.nuspec deleted file mode 100644 index e38362ec..00000000 --- a/src/balutil/balutil.nuspec +++ /dev/null @@ -1,31 +0,0 @@ - - - - $id$ - $version$ - $authors$ - $authors$ - MS-RL - https://github.com/wixtoolset/balutil - false - $description$ - $copyright$ - - - - - - - - - - - - - - - - - - - diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj deleted file mode 100644 index ab33f159..00000000 --- a/src/balutil/balutil.vcxproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - Debug - ARM64 - - - Release - ARM64 - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} - StaticLibrary - balutil - v142 - MultiByte - WiX Toolset Bootstrapper Application Layer native utility library - WixToolset.BalUtil - - - - - - - - - - - - - - - $(ProjectDir)..\inc - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/src/balutil/build/WixToolset.BalUtil.props b/src/balutil/build/WixToolset.BalUtil.props deleted file mode 100644 index 45b97f6a..00000000 --- a/src/balutil/build/WixToolset.BalUtil.props +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) - - - $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) - - - - - $(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) - - - - - $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) - - - - - $(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\balutil.lib;%(AdditionalDependencies) - - - diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h deleted file mode 100644 index 2970478f..00000000 --- a/src/balutil/inc/BAFunctions.h +++ /dev/null @@ -1,147 +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. - - -#ifdef __cplusplus -extern "C" { -#endif - -// The first 1024 messages are reserved so that the BA messages have the same value here. -enum BA_FUNCTIONS_MESSAGE -{ - 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_ONSYSTEMSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN, - BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, - BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, - BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, - BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, - BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, - BA_FUNCTIONS_MESSAGE_ONDETECTPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, - BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, - BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, - BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONPLANPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, - BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, - BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, - BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, - BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, - BA_FUNCTIONS_MESSAGE_ONERROR = BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, - BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, - BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, - BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, - BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, - BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, - BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, - BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, - BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, - BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, - BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, - BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, - BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, - BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, - BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, - BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, - BA_FUNCTIONS_MESSAGE_ONPLANMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, - BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, - BA_FUNCTIONS_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, - BA_FUNCTIONS_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, - BA_FUNCTIONS_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, - BA_FUNCTIONS_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, - BA_FUNCTIONS_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONPLANNEDPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, - BA_FUNCTIONS_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, - BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, - BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, - BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, - BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, - BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, - BA_FUNCTIONS_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, - - BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, - BA_FUNCTIONS_MESSAGE_WNDPROC, -}; - -typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_PROC)( - __in BA_FUNCTIONS_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ); - -struct BA_FUNCTIONS_CREATE_ARGS -{ - DWORD cbSize; - DWORD64 qwBAFunctionsAPIVersion; - BOOTSTRAPPER_CREATE_ARGS* pBootstrapperCreateArgs; -}; - -struct BA_FUNCTIONS_CREATE_RESULTS -{ - DWORD cbSize; - PFN_BA_FUNCTIONS_PROC pfnBAFunctionsProc; - LPVOID pvBAFunctionsProcContext; -}; - -struct BA_FUNCTIONS_ONTHEMELOADED_ARGS -{ - DWORD cbSize; - THEME* pTheme; - WIX_LOCALIZATION* pWixLoc; -}; - -struct BA_FUNCTIONS_ONTHEMELOADED_RESULTS -{ - DWORD cbSize; -}; - -struct BA_FUNCTIONS_WNDPROC_ARGS -{ - DWORD cbSize; - THEME* pTheme; - HWND hWnd; - UINT uMsg; - WPARAM wParam; - LPARAM lParam; -}; - -struct BA_FUNCTIONS_WNDPROC_RESULTS -{ - DWORD cbSize; - LRESULT lres; -}; - -typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_CREATE)( - __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, - __inout BA_FUNCTIONS_CREATE_RESULTS* pResults - ); - -typedef void (WINAPI *PFN_BA_FUNCTIONS_DESTROY)(); - -#ifdef __cplusplus -} -#endif diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h deleted file mode 100644 index ee2e452f..00000000 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ /dev/null @@ -1,867 +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 - -#include "dutil.h" -#include "locutil.h" -#include "thmutil.h" -#include "BAFunctions.h" -#include "IBAFunctions.h" -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" - -class CBalBaseBAFunctions : public IBAFunctions -{ -public: // IUnknown - virtual STDMETHODIMP QueryInterface( - __in REFIID riid, - __out LPVOID *ppvObject - ) - { - if (!ppvObject) - { - return E_INVALIDARG; - } - - *ppvObject = NULL; - - if (::IsEqualIID(__uuidof(IBAFunctions), riid)) - { - *ppvObject = static_cast(this); - } - else if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid)) - { - *ppvObject = static_cast(this); - } - else if (::IsEqualIID(IID_IUnknown, riid)) - { - *ppvObject = static_cast(this); - } - else // no interface for requested iid - { - return E_NOINTERFACE; - } - - AddRef(); - return S_OK; - } - - virtual STDMETHODIMP_(ULONG) AddRef() - { - return ::InterlockedIncrement(&this->m_cReferences); - } - - virtual STDMETHODIMP_(ULONG) Release() - { - long l = ::InterlockedDecrement(&this->m_cReferences); - if (0 < l) - { - return l; - } - - delete this; - return 0; - } - -public: // IBootstrapperApplication - virtual STDMETHODIMP_(HRESULT) BAProc( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ - ) - { - return E_NOTIMPL; - } - - virtual STDMETHODIMP_(void) BAProcFallback( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __inout HRESULT* /*phr*/, - __in_opt LPVOID /*pvContext*/ - ) - { - } - - virtual STDMETHODIMP OnStartup() - { - return S_OK; - } - - virtual STDMETHODIMP OnShutdown( - __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnSystemShutdown( - __in DWORD /*dwEndSession*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectBegin( - __in BOOL /*fCached*/, - __in BOOL /*fInstalled*/, - __in DWORD /*cPackages*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectForwardCompatibleBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, - __in_z LPCWSTR /*wzBundleTag*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOL /*fMissingFromCache*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectUpdateBegin( - __in_z LPCWSTR /*wzUpdateLocation*/, - __inout BOOL* /*pfCancel*/, - __inout BOOL* /*pfSkip*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectUpdate( - __in_z LPCWSTR /*wzUpdateLocation*/, - __in DWORD64 /*dw64Size*/, - __in LPCWSTR /*wzVersion*/, - __in_z LPCWSTR /*wzTitle*/, - __in_z LPCWSTR /*wzSummary*/, - __in_z LPCWSTR /*wzContentType*/, - __in_z LPCWSTR /*wzContent*/, - __inout BOOL* /*pfCancel*/, - __inout BOOL* /*pfStopProcessingUpdates*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectUpdateComplete( - __in HRESULT /*hrStatus*/, - __inout BOOL* /*pfIgnoreError*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectRelatedBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, - __in_z LPCWSTR /*wzBundleTag*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, - __in BOOL /*fMissingFromCache*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectPackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectRelatedMsiPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzUpgradeCode*/, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectPatchTarget( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectMsiFeature( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzFeatureId*/, - __in BOOTSTRAPPER_FEATURE_STATE /*state*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectPackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOL /*fCached*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectComplete( - __in HRESULT /*hrStatus*/, - __in BOOL /*fEligibleForCleanup*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanBegin( - __in DWORD /*cPackages*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanRelatedBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanPackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOL /*fCached*/, - __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT /*installCondition*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __in BOOTSTRAPPER_CACHE_TYPE /*recommendedCacheType*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, - __inout BOOTSTRAPPER_CACHE_TYPE* /*pRequestedCacheType*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanPatchTarget( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanMsiFeature( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzFeatureId*/, - __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanMsiPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOL /*fExecute*/, - __in BOOTSTRAPPER_ACTION_STATE /*action*/, - __inout BOOL* /*pfCancel*/, - __inout BURN_MSI_PROPERTY* /*pActionMsiProperty*/, - __inout INSTALLUILEVEL* /*pUiLevel*/, - __inout BOOL* /*pfDisableExternalUiHandler*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanPackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_REQUEST_STATE /*requested*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlannedPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOTSTRAPPER_ACTION_STATE /*execute*/, - __in BOOTSTRAPPER_ACTION_STATE /*rollback*/, - __in BOOL /*fPlannedCache*/, - __in BOOL /*fPlannedUncache*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnApplyBegin( - __in DWORD /*dwPhaseCount*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnElevateBegin( - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnElevateComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnProgress( - __in DWORD /*dwProgressPercentage*/, - __in DWORD /*dwOverallProgressPercentage*/, - __inout BOOL* /*pfCancel*/ - ) - { - return IDNOACTION; - } - - virtual STDMETHODIMP OnError( - __in BOOTSTRAPPER_ERROR_TYPE /*errorType*/, - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*dwCode*/, - __in_z LPCWSTR /*wzError*/, - __in DWORD /*dwUIHint*/, - __in DWORD /*cData*/, - __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, - __in int /*nRecommendation*/, - __inout int* /*pResult*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnRegisterBegin( - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnRegisterComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheBegin( - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCachePackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*cCachePayloads*/, - __in DWORD64 /*dw64PackageCacheSize*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireBegin( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR /*wzSource*/, - __in_z_opt LPCWSTR /*wzDownloadUrl*/, - __in_z_opt LPCWSTR /*wzPayloadContainerId*/, - __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, - __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireProgress( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireResolving( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR* /*rgSearchPaths*/, - __in DWORD /*cSearchPaths*/, - __in BOOL /*fFoundLocal*/, - __in DWORD /*dwRecommendedSearchPath*/, - __in_z_opt LPCWSTR /*wzDownloadUrl*/, - __in_z_opt LPCWSTR /*wzPayloadContainerId*/, - __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, - __inout DWORD* /*pdwChosenSearchPath*/, - __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireComplete( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheVerifyBegin( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z LPCWSTR /*wzPayloadId*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheVerifyProgress( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __in BOOTSTRAPPER_CACHE_VERIFY_STEP /*verifyStep*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheVerifyComplete( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCachePackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecuteBegin( - __in DWORD /*cExecutingPackages*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecutePackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOL /*fExecute*/, - __in BOOTSTRAPPER_ACTION_STATE /*action*/, - __in INSTALLUILEVEL /*uiLevel*/, - __in BOOL /*fDisableExternalUiHandler*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecutePatchTarget( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzTargetProductCode*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecuteProgress( - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*dwProgressPercentage*/, - __in DWORD /*dwOverallProgressPercentage*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecuteMsiMessage( - __in_z LPCWSTR /*wzPackageId*/, - __in INSTALLMESSAGE /*messageType*/, - __in DWORD /*dwUIHint*/, - __in_z LPCWSTR /*wzMessage*/, - __in DWORD /*cData*/, - __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, - __in int /*nRecommendation*/, - __inout int* /*pResult*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecuteFilesInUse( - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*cFiles*/, - __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, - __in int /*nRecommendation*/, - __inout int* /*pResult*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecutePackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, - __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecuteComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnUnregisterBegin( - __in BOOL /*fKeepRegistration*/, - __inout BOOL* /*pfForceKeepRegistration*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnUnregisterComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnApplyComplete( - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, - __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnLaunchApprovedExeBegin( - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnLaunchApprovedExeComplete( - __in HRESULT /*hrStatus*/, - __in DWORD /*dwProcessId*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnBeginMsiTransactionBegin( - __in_z LPCWSTR /*wzTransactionId*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnBeginMsiTransactionComplete( - __in_z LPCWSTR /*wzTransactionId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCommitMsiTransactionBegin( - __in_z LPCWSTR /*wzTransactionId*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCommitMsiTransactionComplete( - __in_z LPCWSTR /*wzTransactionId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnRollbackMsiTransactionBegin( - __in_z LPCWSTR /*wzTransactionId*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnRollbackMsiTransactionComplete( - __in_z LPCWSTR /*wzTransactionId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnSystemRestorePointBegin( - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnSystemRestorePointComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanForwardCompatibleBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, - __in_z LPCWSTR /*wzBundleTag*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOL /*fRecommendedIgnoreBundle*/, - __inout BOOL* /*pfCancel*/, - __inout BOOL* /*pfIgnoreBundle*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyBegin( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyProgress( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyComplete( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCachePayloadExtractBegin( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCachePayloadExtractProgress( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __inout BOOL* /*pfCancel*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCachePayloadExtractComplete( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - -public: // IBAFunctions - virtual STDMETHODIMP OnPlan( - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnThemeLoaded( - THEME* pTheme, - WIX_LOCALIZATION* pWixLoc - ) - { - HRESULT hr = S_OK; - - m_pTheme = pTheme; - m_pWixLoc = pWixLoc; - - return hr; - } - - virtual STDMETHODIMP WndProc( - __in THEME* pTheme, - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __inout LRESULT* plRes - ) - { - HRESULT hr = S_OK; - - *plRes = ThemeDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); - - return hr; - } - - virtual STDMETHODIMP BAFunctionsProc( - __in BA_FUNCTIONS_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ - ) - { - return E_NOTIMPL; - } - -protected: - CBalBaseBAFunctions( - __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, - __in const BA_FUNCTIONS_CREATE_ARGS* pArgs - ) - { - 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; - } - - virtual ~CBalBaseBAFunctions() - { - ReleaseNullObject(m_pEngine); - } - -private: - long m_cReferences; - -protected: - IBootstrapperEngine* m_pEngine; - HMODULE m_hModule; - BA_FUNCTIONS_CREATE_ARGS m_bafCreateArgs; - BOOTSTRAPPER_CREATE_ARGS m_baCreateArgs; - BOOTSTRAPPER_COMMAND m_command; - THEME* m_pTheme; - WIX_LOCALIZATION* m_pWixLoc; -}; diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h deleted file mode 100644 index 7e89fe83..00000000 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ /dev/null @@ -1,124 +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 "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->pTheme, pArgs->pWixLoc); -} - -static HRESULT BalBaseBAFunctionsProcWndProc( - __in IBAFunctions* pBAFunctions, - __in BA_FUNCTIONS_WNDPROC_ARGS* pArgs, - __inout BA_FUNCTIONS_WNDPROC_RESULTS* pResults - ) -{ - return pBAFunctions->WndProc(pArgs->pTheme, pArgs->hWnd, pArgs->uMsg, pArgs->wParam, pArgs->lParam, &pResults->lres); -} - -/******************************************************************* -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( - __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_ONSYSTEMSHUTDOWN: - 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: - 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; - } - } - - return hr; -} diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h deleted file mode 100644 index bf21c4a5..00000000 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ /dev/null @@ -1,1076 +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 -#include - -#include "BootstrapperEngine.h" -#include "BootstrapperApplication.h" -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" - -#include "balutil.h" -#include "balretry.h" - -class CBalBaseBootstrapperApplication : public IBootstrapperApplication -{ -public: // IUnknown - virtual STDMETHODIMP QueryInterface( - __in REFIID riid, - __out LPVOID *ppvObject - ) - { - if (!ppvObject) - { - return E_INVALIDARG; - } - - *ppvObject = NULL; - - if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid)) - { - *ppvObject = static_cast(this); - } - else if (::IsEqualIID(IID_IUnknown, riid)) - { - *ppvObject = static_cast(this); - } - else // no interface for requested iid - { - return E_NOINTERFACE; - } - - AddRef(); - return S_OK; - } - - virtual STDMETHODIMP_(ULONG) AddRef() - { - return ::InterlockedIncrement(&this->m_cReferences); - } - - virtual STDMETHODIMP_(ULONG) Release() - { - long l = ::InterlockedDecrement(&this->m_cReferences); - if (0 < l) - { - return l; - } - - delete this; - return 0; - } - -public: // IBootstrapperApplication - virtual STDMETHODIMP_(HRESULT) BAProc( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ - ) - { - return E_NOTIMPL; - } - - virtual STDMETHODIMP_(void) BAProcFallback( - __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __inout HRESULT* /*phr*/, - __in_opt LPVOID /*pvContext*/ - ) - { - } - - virtual STDMETHODIMP OnStartup() - { - return S_OK; - } - - virtual STDMETHODIMP OnShutdown( - __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnSystemShutdown( - __in DWORD dwEndSession, - __inout BOOL* pfCancel - ) - { - HRESULT hr = S_OK; - - // Allow requests to shut down when critical or not applying. - *pfCancel = !(ENDSESSION_CRITICAL & dwEndSession || !m_fApplying); - - return hr; - } - - virtual STDMETHODIMP OnDetectBegin( - __in BOOL /*fCached*/, - __in BOOL /*fInstalled*/, - __in DWORD /*cPackages*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectForwardCompatibleBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, - __in_z LPCWSTR /*wzBundleTag*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOL /*fMissingFromCache*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectUpdateBegin( - __in_z LPCWSTR /*wzUpdateLocation*/, - __inout BOOL* pfCancel, - __inout BOOL* /*pfSkip*/ - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectUpdate( - __in_z LPCWSTR /*wzUpdateLocation*/, - __in DWORD64 /*dw64Size*/, - __in LPCWSTR /*wzVersion*/, - __in_z LPCWSTR /*wzTitle*/, - __in_z LPCWSTR /*wzSummary*/, - __in_z LPCWSTR /*wzContentType*/, - __in_z LPCWSTR /*wzContent*/, - __inout BOOL* pfCancel, - __inout BOOL* /*pfStopProcessingUpdates*/ - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectUpdateComplete( - __in HRESULT /*hrStatus*/, - __inout BOOL* /*pfIgnoreError*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectRelatedBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, - __in_z LPCWSTR /*wzBundleTag*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, - __in BOOL /*fMissingFromCache*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectPackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectRelatedMsiPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzUpgradeCode*/, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectPatchTarget( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectMsiFeature( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzFeatureId*/, - __in BOOTSTRAPPER_FEATURE_STATE /*state*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnDetectPackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOL /*fCached*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnDetectComplete( - __in HRESULT /*hrStatus*/, - __in BOOL /*fEligibleForCleanup*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanBegin( - __in DWORD /*cPackages*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanRelatedBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanPackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOTSTRAPPER_PACKAGE_STATE /*state*/, - __in BOOL /*fCached*/, - __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT /*installCondition*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __in BOOTSTRAPPER_CACHE_TYPE /*recommendedCacheType*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/, - __inout BOOTSTRAPPER_CACHE_TYPE* /*pRequestedCacheType*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanPatchTarget( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanMsiFeature( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzFeatureId*/, - __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/, - __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanMsiPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOL /*fExecute*/, - __in BOOTSTRAPPER_ACTION_STATE /*action*/, - __inout BOOL* pfCancel, - __inout BURN_MSI_PROPERTY* /*pActionMsiProperty*/, - __inout INSTALLUILEVEL* /*pUiLevel*/, - __inout BOOL* /*pfDisableExternalUiHandler*/ - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnPlanPackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_REQUEST_STATE /*requested*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlannedPackage( - __in_z LPCWSTR /*wzPackageId*/, - __in BOOTSTRAPPER_ACTION_STATE /*execute*/, - __in BOOTSTRAPPER_ACTION_STATE /*rollback*/, - __in BOOL /*fPlannedCache*/, - __in BOOL /*fPlannedUncache*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnApplyBegin( - __in DWORD /*dwPhaseCount*/, - __inout BOOL* pfCancel - ) - { - m_fApplying = TRUE; - - m_dwProgressPercentage = 0; - m_dwOverallProgressPercentage = 0; - - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnElevateBegin( - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnElevateComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnProgress( - __in DWORD dwProgressPercentage, - __in DWORD dwOverallProgressPercentage, - __inout BOOL* pfCancel - ) - { - HRESULT hr = S_OK; - int nResult = IDNOACTION; - - m_dwProgressPercentage = dwProgressPercentage; - m_dwOverallProgressPercentage = dwOverallProgressPercentage; - - if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) - { - hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); - BalExitOnFailure(hr, "Failed to send embedded overall progress."); - - if (IDERROR == nResult) - { - hr = E_FAIL; - } - else if (IDCANCEL == nResult) - { - *pfCancel = TRUE; - } - } - - LExit: - *pfCancel |= CheckCanceled(); - return hr; - } - - virtual STDMETHODIMP OnError( - __in BOOTSTRAPPER_ERROR_TYPE errorType, - __in_z LPCWSTR wzPackageId, - __in DWORD dwCode, - __in_z LPCWSTR /*wzError*/, - __in DWORD /*dwUIHint*/, - __in DWORD /*cData*/, - __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, - __in int /*nRecommendation*/, - __inout int* pResult - ) - { - BalRetryErrorOccurred(wzPackageId, dwCode); - - if (CheckCanceled()) - { - *pResult = IDCANCEL; - } - else if (BOOTSTRAPPER_DISPLAY_FULL == m_display) - { - if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType) - { - *pResult = IDTRYAGAIN; - } - } - - return S_OK; - } - - virtual STDMETHODIMP OnRegisterBegin( - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnRegisterComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCacheBegin( - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCachePackageBegin( - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*cCachePayloads*/, - __in DWORD64 /*dw64PackageCacheSize*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireBegin( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR /*wzSource*/, - __in_z_opt LPCWSTR /*wzDownloadUrl*/, - __in_z_opt LPCWSTR /*wzPayloadContainerId*/, - __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, - __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, - __inout BOOL* pfCancel - ) - { - BalRetryStartContainerOrPayload(wzPackageOrContainerId, wzPayloadId); - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireProgress( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __inout BOOL* pfCancel - ) - { - HRESULT hr = S_OK; - int nResult = IDNOACTION; - - // 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) - { - hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); - BalExitOnFailure(hr, "Failed to send embedded cache progress."); - - if (IDERROR == nResult) - { - hr = E_FAIL; - } - else if (IDCANCEL == nResult) - { - *pfCancel = TRUE; - } - } - - LExit: - *pfCancel |= CheckCanceled(); - return hr; - } - - virtual STDMETHODIMP OnCacheAcquireResolving( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR* /*rgSearchPaths*/, - __in DWORD /*cSearchPaths*/, - __in BOOL /*fFoundLocal*/, - __in DWORD /*dwRecommendedSearchPath*/, - __in_z_opt LPCWSTR /*wzDownloadUrl*/, - __in_z_opt LPCWSTR /*wzPayloadContainerId*/, - __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, - __inout DWORD* /*pdwChosenSearchPath*/, - __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheAcquireComplete( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction - ) - { - HRESULT hr = S_OK; - BOOL fRetry = FALSE; - - if (CheckCanceled()) - { - ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); - } - - hr = BalRetryEndContainerOrPayload(wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); - ExitOnFailure(hr, "BalRetryEndPackage for cache failed"); - - if (fRetry) - { - *pAction = BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY; - } - - LExit: - return hr; - } - - virtual STDMETHODIMP OnCacheVerifyBegin( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z LPCWSTR /*wzPayloadId*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheVerifyProgress( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __in BOOTSTRAPPER_CACHE_VERIFY_STEP /*verifyStep*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheVerifyComplete( - __in_z LPCWSTR /*wzPackageOrContainerId*/, - __in_z LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction - ) - { - if (CheckCanceled()) - { - *pAction = BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_NONE; - } - - return S_OK; - } - - virtual STDMETHODIMP OnCachePackageComplete( - __in_z LPCWSTR /*wzPackageId*/, - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction - ) - { - if (CheckCanceled()) - { - *pAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE; - } - - return S_OK; - } - - virtual STDMETHODIMP OnCacheComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnExecuteBegin( - __in DWORD /*cExecutingPackages*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnExecutePackageBegin( - __in_z LPCWSTR wzPackageId, - __in BOOL fExecute, - __in BOOTSTRAPPER_ACTION_STATE /*action*/, - __in INSTALLUILEVEL /*uiLevel*/, - __in BOOL /*fDisableExternalUiHandler*/, - __inout BOOL* pfCancel - ) - { - // Only track retry on execution (not rollback). - if (fExecute) - { - BalRetryStartPackage(wzPackageId); - } - - m_fRollingBack = !fExecute; - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnExecutePatchTarget( - __in_z LPCWSTR /*wzPackageId*/, - __in_z LPCWSTR /*wzTargetProductCode*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnExecuteProgress( - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*dwProgressPercentage*/, - __in DWORD /*dwOverallProgressPercentage*/, - __inout BOOL* pfCancel - ) - { - HRESULT hr = S_OK; - int nResult = IDNOACTION; - - // 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) - { - hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); - BalExitOnFailure(hr, "Failed to send embedded execute progress."); - - if (IDERROR == nResult) - { - hr = E_FAIL; - } - else if (IDCANCEL == nResult) - { - *pfCancel = TRUE; - } - } - - LExit: - *pfCancel |= CheckCanceled(); - return hr; - } - - virtual STDMETHODIMP OnExecuteMsiMessage( - __in_z LPCWSTR /*wzPackageId*/, - __in INSTALLMESSAGE /*messageType*/, - __in DWORD /*dwUIHint*/, - __in_z LPCWSTR /*wzMessage*/, - __in DWORD /*cData*/, - __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, - __in int /*nRecommendation*/, - __inout int* pResult - ) - { - if (CheckCanceled()) - { - *pResult = IDCANCEL; - } - - return S_OK; - } - - virtual STDMETHODIMP OnExecuteFilesInUse( - __in_z LPCWSTR /*wzPackageId*/, - __in DWORD /*cFiles*/, - __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/, - __in int /*nRecommendation*/, - __inout int* pResult - ) - { - if (CheckCanceled()) - { - *pResult = IDCANCEL; - } - - return S_OK; - } - - virtual STDMETHODIMP OnExecutePackageComplete( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_APPLY_RESTART /*restart*/, - __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction - ) - { - HRESULT hr = S_OK; - BOOL fRetry = FALSE; - - if (CheckCanceled()) - { - ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); - } - - hr = BalRetryEndPackage(wzPackageId, hrStatus, &fRetry); - ExitOnFailure(hr, "BalRetryEndPackage for execute failed"); - - if (fRetry) - { - *pAction = BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RETRY; - } - - LExit: - return hr; - } - - virtual STDMETHODIMP OnExecuteComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnUnregisterBegin( - __in BOOL /*fKeepRegistration*/, - __inout BOOL* /*pfForceKeepRegistration*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnUnregisterComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnApplyComplete( - __in HRESULT /*hrStatus*/, - __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction - ) - { - HRESULT hr = S_OK; - BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart; - BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BOOTSTRAPPER_RESTART_PROMPT >= m_restart; - - if (fRestartRequired && !fShouldBlockRestart) - { - *pAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART; - } - - m_fApplying = FALSE; - - return hr; - } - - virtual STDMETHODIMP OnLaunchApprovedExeBegin( - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnLaunchApprovedExeComplete( - __in HRESULT /*hrStatus*/, - __in DWORD /*dwProcessId*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnBeginMsiTransactionBegin( - __in_z LPCWSTR /*wzTransactionId*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnBeginMsiTransactionComplete( - __in_z LPCWSTR /*wzTransactionId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCommitMsiTransactionBegin( - __in_z LPCWSTR /*wzTransactionId*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCommitMsiTransactionComplete( - __in_z LPCWSTR /*wzTransactionId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnRollbackMsiTransactionBegin( - __in_z LPCWSTR /*wzTransactionId*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnRollbackMsiTransactionComplete( - __in_z LPCWSTR /*wzTransactionId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin( - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPauseAutomaticUpdatesComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnSystemRestorePointBegin( - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnSystemRestorePointComplete( - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnPlanForwardCompatibleBundle( - __in_z LPCWSTR /*wzBundleId*/, - __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, - __in_z LPCWSTR /*wzBundleTag*/, - __in BOOL /*fPerMachine*/, - __in LPCWSTR /*wzVersion*/, - __in BOOL /*fRecommendedIgnoreBundle*/, - __inout BOOL* pfCancel, - __inout BOOL* /*pfIgnoreBundle*/ - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyBegin( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyProgress( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCacheContainerOrPayloadVerifyComplete( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - - virtual STDMETHODIMP OnCachePayloadExtractBegin( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCachePayloadExtractProgress( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in DWORD64 /*dw64Progress*/, - __in DWORD64 /*dw64Total*/, - __in DWORD /*dwOverallPercentage*/, - __inout BOOL* pfCancel - ) - { - *pfCancel |= CheckCanceled(); - return S_OK; - } - - virtual STDMETHODIMP OnCachePayloadExtractComplete( - __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, - __in_z_opt LPCWSTR /*wzPayloadId*/, - __in HRESULT /*hrStatus*/ - ) - { - return S_OK; - } - -protected: - // - // PromptCancel - prompts the user to close (if not forced). - // - virtual BOOL PromptCancel( - __in HWND hWnd, - __in BOOL fForceCancel, - __in_z_opt LPCWSTR wzMessage, - __in_z_opt LPCWSTR wzCaption - ) - { - ::EnterCriticalSection(&m_csCanceled); - - // Only prompt the user to close if we have not canceled already. - if (!m_fCanceled) - { - if (fForceCancel) - { - m_fCanceled = TRUE; - } - else - { - m_fCanceled = (IDYES == ::MessageBoxW(hWnd, wzMessage, wzCaption, MB_YESNO | MB_ICONEXCLAMATION)); - } - } - - ::LeaveCriticalSection(&m_csCanceled); - - return m_fCanceled; - } - - // - // CheckCanceled - waits if the cancel dialog is up and checks to see if the user canceled the operation. - // - BOOL CheckCanceled() - { - ::EnterCriticalSection(&m_csCanceled); - ::LeaveCriticalSection(&m_csCanceled); - return m_fRollingBack ? FALSE : m_fCanceled; - } - - BOOL IsRollingBack() - { - return m_fRollingBack; - } - - BOOL IsCanceled() - { - return m_fCanceled; - } - - CBalBaseBootstrapperApplication( - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __in DWORD dwRetryCount = 0, - __in DWORD dwRetryTimeout = 1000 - ) - { - m_cReferences = 1; - m_display = pArgs->pCommand->display; - m_restart = pArgs->pCommand->restart; - - pEngine->AddRef(); - m_pEngine = pEngine; - - ::InitializeCriticalSection(&m_csCanceled); - m_fCanceled = FALSE; - m_fApplying = FALSE; - m_fRollingBack = FALSE; - - m_dwProgressPercentage = 0; - m_dwOverallProgressPercentage = 0; - - BalRetryInitialize(dwRetryCount, dwRetryTimeout); - } - - virtual ~CBalBaseBootstrapperApplication() - { - BalRetryUninitialize(); - ::DeleteCriticalSection(&m_csCanceled); - - ReleaseNullObject(m_pEngine); - } - -protected: - CRITICAL_SECTION m_csCanceled; - BOOL m_fCanceled; - -private: - long m_cReferences; - BOOTSTRAPPER_DISPLAY m_display; - BOOTSTRAPPER_RESTART m_restart; - IBootstrapperEngine* m_pEngine; - - BOOL m_fApplying; - BOOL m_fRollingBack; - - DWORD m_dwProgressPercentage; - DWORD m_dwOverallProgressPercentage; -}; diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h deleted file mode 100644 index 7fe3ffd8..00000000 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ /dev/null @@ -1,901 +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->fInstalled, 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 BalBaseBAProcOnSystemShutdown( - __in IBootstrapperApplication* pBA, - __in BA_ONSYSTEMSHUTDOWN_ARGS* pArgs, - __inout BA_ONSYSTEMSHUTDOWN_RESULTS* pResults - ) -{ - return pBA->OnSystemShutdown(pArgs->dwEndSession, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( - __in IBootstrapperApplication* pBA, - __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, - __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->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->operation, 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 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 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->recommendedState, pArgs->recommendedCacheType, &pResults->requestedState, &pResults->requestedCacheType, &pResults->fCancel); -} - -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 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(&pResults->fCancel); -} - -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, &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, &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 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->fKeepRegistration, &pResults->fForceKeepRegistration); -} - -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, &pResults->fCancel, &pResults->actionMsiProperty, &pResults->uiLevel, &pResults->fDisableExternalUiHandler); -} - -static HRESULT BalBaseBAProcOnBeginMsiTransactionBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONBEGINMSITRANSACTIONBEGIN_ARGS* pArgs, - __inout BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS* pResults - ) -{ - return pBA->OnBeginMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnBeginMsiTransactionComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS* pArgs, - __inout BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnBeginMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnCommitMsiTransactionBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS* pArgs, - __inout BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS* pResults - ) -{ - return pBA->OnCommitMsiTransactionBegin(pArgs->wzTransactionId, &pResults->fCancel); -} - -static HRESULT BalBaseBAProcOnCommitMsiTransactionComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS* pArgs, - __inout BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnCommitMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnRollbackMsiTransactionBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS* pArgs, - __inout BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS* /*pResults*/ - ) -{ - return pBA->OnRollbackMsiTransactionBegin(pArgs->wzTransactionId); -} - -static HRESULT BalBaseBAProcOnRollbackMsiTransactionComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS* pArgs, - __inout BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnRollbackMsiTransactionComplete(pArgs->wzTransactionId, pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS* /*pArgs*/, - __inout BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPauseAutomaticUpdatesBegin(); -} - -static HRESULT BalBaseBAProcOnPauseAutomaticUpdatesComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS* pArgs, - __inout BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnPauseAutomaticUpdatesComplete(pArgs->hrStatus); -} - -static HRESULT BalBaseBAProcOnSystemRestorePointBegin( - __in IBootstrapperApplication* pBA, - __in BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS* /*pArgs*/, - __inout BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS* /*pResults*/ - ) -{ - return pBA->OnSystemRestorePointBegin(); -} - -static HRESULT BalBaseBAProcOnSystemRestorePointComplete( - __in IBootstrapperApplication* pBA, - __in BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS* pArgs, - __inout BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS* /*pResults*/ - ) -{ - return pBA->OnSystemRestorePointComplete(pArgs->hrStatus); -} - -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); -} - -/******************************************************************* -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_ONSYSTEMSHUTDOWN: - hr = BalBaseBAProcOnSystemShutdown(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: - hr = BalBaseBAProcOnDetectForwardCompatibleBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - 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; - } - } - - pBA->BAProcFallback(message, pvArgs, pvResults, &hr, pvContext); - - return hr; -} diff --git a/src/balutil/inc/BalBootstrapperEngine.h b/src/balutil/inc/BalBootstrapperEngine.h deleted file mode 100644 index 45131d98..00000000 --- a/src/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/balutil/inc/IBAFunctions.h b/src/balutil/inc/IBAFunctions.h deleted file mode 100644 index 7d8a07fa..00000000 --- a/src/balutil/inc/IBAFunctions.h +++ /dev/null @@ -1,34 +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. - - -DECLARE_INTERFACE_IID_(IBAFunctions, IBootstrapperApplication, "0FB445ED-17BD-49C7-BE19-479776F8AE96") -{ - // OnThemeLoaded - Called after the BA finished loading all the controls for the theme. - // - STDMETHOD(OnThemeLoaded)( - THEME* pTheme, - WIX_LOCALIZATION* pWixLoc - ) = 0; - - // WndProc - Called if the BA hasn't handled the message. - // The implementation must either return E_NOTIMPL or call ThemeDefWindowProc for unhandled messages. - // - STDMETHOD(WndProc)( - __in THEME* pTheme, - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __inout LRESULT* plRes - ) = 0; - - // BAFunctionsProc - The PFN_BA_FUNCTIONS_PROC can call this method to give the BAFunctions raw access to the callback from WixStdBA. - // This might be used to help the BAFunctions support more than one version of the engine/WixStdBA. - STDMETHOD(BAFunctionsProc)( - __in BA_FUNCTIONS_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ) = 0; -}; diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h deleted file mode 100644 index c284cb49..00000000 --- a/src/balutil/inc/IBootstrapperApplication.h +++ /dev/null @@ -1,649 +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. - - -DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-AB06-099D717C67FE") -{ - // BAProc - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method to give the BA raw access to the callback from the engine. - // This might be used to help the BA support more than one version of the engine. - STDMETHOD(BAProc)( - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ) = 0; - - // BAProcFallback - The PFN_BOOTSTRAPPER_APPLICATION_PROC can call this method - // to give the BA the ability to use default behavior - // and then forward the message to extensions. - STDMETHOD_(void, BAProcFallback)( - __in BOOTSTRAPPER_APPLICATION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __inout HRESULT* phr, - __in_opt LPVOID pvContext - ) = 0; - - // OnStartup - called when the engine is ready for the bootstrapper application to start. - // - STDMETHOD(OnStartup)() = 0; - - // OnShutdown - called after the bootstrapper application quits the engine. - STDMETHOD(OnShutdown)( - __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction - ) = 0; - - // OnSystemShutdown - called when the operating system is instructed to shutdown the machine. - STDMETHOD(OnSystemShutdown)( - __in DWORD dwEndSession, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectBegin - called when the engine begins detection. - STDMETHOD(OnDetectBegin)( - __in BOOL fCached, - __in BOOL fInstalled, - __in DWORD cPackages, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectForwardCompatibleBundle - called when the engine detects a forward compatible bundle. - STDMETHOD(OnDetectForwardCompatibleBundle)( - __in_z LPCWSTR wzBundleId, - __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in_z LPCWSTR wzBundleTag, - __in BOOL fPerMachine, - __in_z LPCWSTR wzVersion, - __in BOOL fMissingFromCache, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectUpdateBegin - called when the engine begins detection for bundle update. - STDMETHOD(OnDetectUpdateBegin)( - __in_z LPCWSTR wzUpdateLocation, - __inout BOOL* pfCancel, - __inout BOOL* pfSkip - ) = 0; - - // OnDetectUpdate - called when the engine has an update candidate for bundle update. - STDMETHOD(OnDetectUpdate)( - __in_z_opt LPCWSTR wzUpdateLocation, - __in DWORD64 dw64Size, - __in_z LPCWSTR wzVersion, - __in_z_opt LPCWSTR wzTitle, - __in_z_opt LPCWSTR wzSummary, - __in_z_opt LPCWSTR wzContentType, - __in_z_opt LPCWSTR wzContent, - __inout BOOL* pfCancel, - __inout BOOL* pfStopProcessingUpdates - ) = 0; - - // OnDetectUpdateComplete - called when the engine completes detection for bundle update. - STDMETHOD(OnDetectUpdateComplete)( - __in HRESULT hrStatus, - __inout BOOL* pfIgnoreError - ) = 0; - - // OnDetectRelatedBundle - called when the engine detects a related bundle. - STDMETHOD(OnDetectRelatedBundle)( - __in_z LPCWSTR wzBundleId, - __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in_z LPCWSTR wzBundleTag, - __in BOOL fPerMachine, - __in_z LPCWSTR wzVersion, - __in BOOTSTRAPPER_RELATED_OPERATION operation, - __in BOOL fMissingFromCache, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectPackageBegin - called when the engine begins detecting a package. - STDMETHOD(OnDetectPackageBegin)( - __in_z LPCWSTR wzPackageId, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectRelatedMsiPackage - called when the engine begins detects a related package. - STDMETHOD(OnDetectRelatedMsiPackage)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzUpgradeCode, - __in_z LPCWSTR wzProductCode, - __in BOOL fPerMachine, - __in_z LPCWSTR wzVersion, - __in BOOTSTRAPPER_RELATED_OPERATION operation, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectPatchTarget - called when the engine detects a target product - // for an MSP package. - STDMETHOD(OnDetectPatchTarget)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzProductCode, - __in BOOTSTRAPPER_PACKAGE_STATE patchState, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectMsiFeature - called when the engine detects a feature in an MSI package. - STDMETHOD(OnDetectMsiFeature)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzFeatureId, - __in BOOTSTRAPPER_FEATURE_STATE state, - __inout BOOL* pfCancel - ) = 0; - - // OnDetectPackageComplete - called after the engine detects a package. - // - STDMETHOD(OnDetectPackageComplete)( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_PACKAGE_STATE state, - __in BOOL fCached - ) = 0; - - // OnDetectPackageComplete - called after the engine completes detection. - // - STDMETHOD(OnDetectComplete)( - __in HRESULT hrStatus, - __in BOOL fEligibleForCleanup - ) = 0; - - // OnPlanBegin - called when the engine begins planning. - STDMETHOD(OnPlanBegin)( - __in DWORD cPackages, - __inout BOOL* pfCancel - ) = 0; - - // OnPlanRelatedBundle - called when the engine begins planning a related bundle. - STDMETHOD(OnPlanRelatedBundle)( - __in_z LPCWSTR wzBundleId, - __in BOOTSTRAPPER_REQUEST_STATE recommendedState, - __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, - __inout BOOL* pfCancel - ) = 0; - - // OnPlanPackageBegin - called when the engine has begun getting the BA's input - // for planning a package. - STDMETHOD(OnPlanPackageBegin)( - __in_z LPCWSTR wzPackageId, - __in BOOTSTRAPPER_PACKAGE_STATE state, - __in BOOL fCached, - __in BOOTSTRAPPER_PACKAGE_CONDITION_RESULT installCondition, - __in BOOTSTRAPPER_REQUEST_STATE recommendedState, - __in BOOTSTRAPPER_CACHE_TYPE recommendedCacheType, - __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, - __inout BOOTSTRAPPER_CACHE_TYPE* pRequestedCacheType, - __inout BOOL* pfCancel - ) = 0; - - // OnPlanPatchTarget - called when the engine is about to plan a target - // of an MSP package. - STDMETHOD(OnPlanPatchTarget)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzProductCode, - __in BOOTSTRAPPER_REQUEST_STATE recommendedState, - __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, - __inout BOOL* pfCancel - ) = 0; - - // OnPlanMsiFeature - called when the engine plans a feature in an - // MSI package. - STDMETHOD(OnPlanMsiFeature)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzFeatureId, - __in BOOTSTRAPPER_FEATURE_STATE recommendedState, - __inout BOOTSTRAPPER_FEATURE_STATE* pRequestedState, - __inout BOOL* pfCancel - ) = 0; - - // OnPlanMsiPackage - called when the engine plans an MSI or MSP package. - // - STDMETHOD(OnPlanMsiPackage)( - __in_z LPCWSTR wzPackageId, - __in BOOL fExecute, // false means rollback. - __in BOOTSTRAPPER_ACTION_STATE action, - __inout BOOL* pfCancel, - __inout BURN_MSI_PROPERTY* pActionMsiProperty, - __inout INSTALLUILEVEL* pUiLevel, - __inout BOOL* pfDisableExternalUiHandler - ) = 0; - - // OnPlanPackageComplete - called after the engine has completed getting the BA's input - // for planning a package. - STDMETHOD(OnPlanPackageComplete)( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_REQUEST_STATE requested - ) = 0; - - // OnPlannedPackage - called after the engine has completed planning a package. - STDMETHOD(OnPlannedPackage)( - __in_z LPCWSTR wzPackageId, - __in BOOTSTRAPPER_ACTION_STATE execute, - __in BOOTSTRAPPER_ACTION_STATE rollback, - __in BOOL fPlannedCache, - __in BOOL fPlannedUncache - ) = 0; - - // OnPlanComplete - called when the engine completes planning. - // - STDMETHOD(OnPlanComplete)( - __in HRESULT hrStatus - ) = 0; - - // OnApplyBegin - called when the engine begins applying the plan. - // - STDMETHOD(OnApplyBegin)( - __in DWORD dwPhaseCount, - __inout BOOL* pfCancel - ) = 0; - - // OnElevateBegin - called before the engine displays an elevation prompt. - // Will only happen once per execution of the engine, - // assuming the elevation was successful. - STDMETHOD(OnElevateBegin)( - __inout BOOL* pfCancel - ) = 0; - - // OnElevateComplete - called after the engine attempted to elevate. - // - STDMETHOD(OnElevateComplete)( - __in HRESULT hrStatus - ) = 0; - - // OnProgress - called when the engine makes progress. - // - STDMETHOD(OnProgress)( - __in DWORD dwProgressPercentage, - __in DWORD dwOverallPercentage, - __inout BOOL* pfCancel - ) = 0; - - // OnError - called when the engine encounters an error. - // - // nResult: - // uiFlags is a combination of valid ID* return values appropriate for - // the error. - // - // IDNOACTION instructs the engine to pass the error through to default - // handling which usually results in the apply failing. - STDMETHOD(OnError)( - __in BOOTSTRAPPER_ERROR_TYPE errorType, - __in_z_opt LPCWSTR wzPackageId, - __in DWORD dwCode, - __in_z_opt LPCWSTR wzError, - __in DWORD dwUIHint, - __in DWORD cData, - __in_ecount_z_opt(cData) LPCWSTR* rgwzData, - __in int nRecommendation, - __inout int* pResult - ) = 0; - - // OnRegisterBegin - called when the engine registers the bundle. - // - STDMETHOD(OnRegisterBegin)( - __inout BOOL* pfCancel - ) = 0; - - // OnRegisterComplete - called when the engine registration is - // complete. - // - STDMETHOD(OnRegisterComplete)( - __in HRESULT hrStatus - ) = 0; - - // OnCacheBegin - called when the engine begins caching. - // - STDMETHOD(OnCacheBegin)( - __inout BOOL* pfCancel - ) = 0; - - // OnCachePackageBegin - called when the engine begins caching - // a package. - // - STDMETHOD(OnCachePackageBegin)( - __in_z LPCWSTR wzPackageId, - __in DWORD cCachePayloads, - __in DWORD64 dw64PackageCacheSize, - __inout BOOL* pfCancel - ) = 0; - - // OnCacheAcquireBegin - called when the engine begins acquiring a payload or container. - // - // Notes: - // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() - // to update the source location before returning. - // - STDMETHOD(OnCacheAcquireBegin)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzSource, - __in_z_opt LPCWSTR wzDownloadUrl, - __in_z_opt LPCWSTR wzPayloadContainerId, - __in BOOTSTRAPPER_CACHE_OPERATION recommendation, - __inout BOOTSTRAPPER_CACHE_OPERATION* pAction, - __inout BOOL* pfCancel - ) = 0; - - // OnCacheAcquireProgress - called when the engine makes progress acquiring the payload or container. - // - STDMETHOD(OnCacheAcquireProgress)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in DWORD64 dw64Progress, - __in DWORD64 dw64Total, - __in DWORD dwOverallPercentage, - __inout BOOL* pfCancel - ) = 0; - - // OnCacheAcquireResolving - called to allow the BA to override the acquisition action for the payload or container. - // - // Parameters: - // wzPackageOrContainerId will be NULL when resolving a layout-only payload. - // wzPayloadId will be NULL when resolving a container. - // wzDownloadUrl will be NULL if the container or payload does not provide a DownloadURL. - // wzPayloadContainerId will not be NULL if acquiring a payload that is in a container. - // - // rgSearchPaths are the search paths used for source resolution. - // fFoundLocal is TRUE when dwRecommendedSearchPath indicates that the file was found. - // dwRecommendedSearchPath is the index into rgSearchPaths for the recommended local file. - // - STDMETHOD(OnCacheAcquireResolving)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR* rgSearchPaths, - __in DWORD cSearchPaths, - __in BOOL fFoundLocal, - __in DWORD dwRecommendedSearchPath, - __in_z_opt LPCWSTR wzDownloadUrl, - __in_z_opt LPCWSTR wzPayloadContainerId, - __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION recommendation, - __inout DWORD* pdwChosenSearchPath, - __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* pAction, - __inout BOOL* pfCancel - ) = 0; - - // OnCacheAcquireComplete - called after the engine acquired the payload or container. - // - // Notes: - // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() - // to update the source location before returning BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY. - // - STDMETHOD(OnCacheAcquireComplete)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, - __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction - ) = 0; - - // OnCacheVerifyBegin - called when the engine begins to verify then copy - // a payload or container to the package cache folder. - // - STDMETHOD(OnCacheVerifyBegin)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnCacheVerifyProgress)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in DWORD64 dw64Progress, - __in DWORD64 dw64Total, - __in DWORD dwOverallPercentage, - __in BOOTSTRAPPER_CACHE_VERIFY_STEP verifyStep, - __inout BOOL* pfCancel - ) = 0; - - // OnCacheVerifyComplete - called after the engine verifies and copies - // a payload or container to the package cache folder. - // - STDMETHOD(OnCacheVerifyComplete)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, - __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction - ) = 0; - - // OnCachePackageComplete - called after the engine attempts to copy or download all - // payloads of a package into the package cache folder. - // - STDMETHOD(OnCachePackageComplete)( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION recommendation, - __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction - ) = 0; - - // OnCacheComplete - called when the engine caching is complete. - // - STDMETHOD(OnCacheComplete)( - __in HRESULT hrStatus - ) = 0; - - // OnExecuteBegin - called when the engine begins executing the plan. - // - STDMETHOD(OnExecuteBegin)( - __in DWORD cExecutingPackages, - __inout BOOL* pfCancel - ) = 0; - - // OnExecutePackageBegin - called when the engine begins executing a package. - // - STDMETHOD(OnExecutePackageBegin)( - __in_z LPCWSTR wzPackageId, - __in BOOL fExecute, // false means rollback. - __in BOOTSTRAPPER_ACTION_STATE action, - __in INSTALLUILEVEL uiLevel, - __in BOOL fDisableExternalUiHandler, - __inout BOOL* pfCancel - ) = 0; - - // OnExecutePatchTarget - called for each patch in an MspPackage targeting the product - // when the engine begins executing the MspPackage. - // - STDMETHOD(OnExecutePatchTarget)( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzTargetProductCode, - __inout BOOL* pfCancel - ) = 0; - - // OnExecuteProgress - called when the engine makes progress executing a package. - // - STDMETHOD(OnExecuteProgress)( - __in_z LPCWSTR wzPackageId, - __in DWORD dwProgressPercentage, - __in DWORD dwOverallPercentage, - __inout BOOL* pfCancel - ) = 0; - - // OnExecuteMsiMessage - called when the engine receives an MSI package message. - // - // Return: - // uiFlags is a combination of valid ID* return values appropriate for - // the message. - // - // IDNOACTION instructs the engine to pass the message through to default - // handling which usually results in the execution continuing. - STDMETHOD(OnExecuteMsiMessage)( - __in_z LPCWSTR wzPackageId, - __in INSTALLMESSAGE messageType, - __in DWORD dwUIHint, - __in_z LPCWSTR wzMessage, - __in DWORD cData, - __in_ecount_z_opt(cData) LPCWSTR* rgwzData, - __in int nRecommendation, - __inout int* pResult - ) = 0; - - // OnExecuteFilesInUse - called when the engine encounters files in use while - // executing a package. - // - // Return: - // IDOK instructs the engine to let the Restart Manager attempt to close the - // applications to avoid a restart. - // - // IDCANCEL instructs the engine to abort the execution and start rollback. - // - // IDIGNORE instructs the engine to ignore the running applications. A restart will be - // required. - // - // IDRETRY instructs the engine to check if the applications are still running again. - // - // IDNOACTION is equivalent to ignoring the running applications. A restart will be - // required. - STDMETHOD(OnExecuteFilesInUse)( - __in_z LPCWSTR wzPackageId, - __in DWORD cFiles, - __in_ecount_z(cFiles) LPCWSTR* rgwzFiles, - __in int nRecommendation, - __inout int* pResult - ) = 0; - - // OnExecutePackageComplete - called when a package execution is complete. - // - STDMETHOD(OnExecutePackageComplete)( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION recommendation, - __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction - ) = 0; - - // OnExecuteComplete - called when the engine execution is complete. - // - STDMETHOD(OnExecuteComplete)( - __in HRESULT hrStatus - ) = 0; - - // OnUnregisterBegin - called when the engine unregisters the bundle. - // - STDMETHOD(OnUnregisterBegin)( - __in BOOL fKeepRegistration, - __inout BOOL* pfForceKeepRegistration - ) = 0; - - // OnUnregisterComplete - called when the engine unregistration is complete. - // - STDMETHOD(OnUnregisterComplete)( - __in HRESULT hrStatus - ) = 0; - - // OnApplyComplete - called after the plan has been applied. - // - STDMETHOD(OnApplyComplete)( - __in HRESULT hrStatus, - __in BOOTSTRAPPER_APPLY_RESTART restart, - __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION recommendation, - __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction - ) = 0; - - // OnLaunchApprovedExeBegin - called before trying to launch the preapproved executable. - // - STDMETHOD(OnLaunchApprovedExeBegin)( - __inout BOOL* pfCancel - ) = 0; - - // OnLaunchApprovedExeComplete - called after trying to launch the preapproved executable. - // - STDMETHOD(OnLaunchApprovedExeComplete)( - __in HRESULT hrStatus, - __in DWORD dwProcessId - ) = 0; - - STDMETHOD(OnBeginMsiTransactionBegin)( - __in_z LPCWSTR wzTransactionId, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnBeginMsiTransactionComplete)( - __in_z LPCWSTR wzTransactionId, - __in HRESULT hrStatus - ) = 0; - - STDMETHOD(OnCommitMsiTransactionBegin)( - __in_z LPCWSTR wzTransactionId, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnCommitMsiTransactionComplete)( - __in_z LPCWSTR wzTransactionId, - __in HRESULT hrStatus - ) = 0; - - STDMETHOD(OnRollbackMsiTransactionBegin)( - __in_z LPCWSTR wzTransactionId - ) = 0; - - STDMETHOD(OnRollbackMsiTransactionComplete)( - __in_z LPCWSTR wzTransactionId, - __in HRESULT hrStatus - ) = 0; - - STDMETHOD(OnPauseAutomaticUpdatesBegin)( - ) = 0; - - STDMETHOD(OnPauseAutomaticUpdatesComplete)( - __in HRESULT hrStatus - ) = 0; - - STDMETHOD(OnSystemRestorePointBegin)( - ) = 0; - - STDMETHOD(OnSystemRestorePointComplete)( - __in HRESULT hrStatus - ) = 0; - - STDMETHOD(OnPlanForwardCompatibleBundle)( - __in_z LPCWSTR wzBundleId, - __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in_z LPCWSTR wzBundleTag, - __in BOOL fPerMachine, - __in_z LPCWSTR wzVersion, - __in BOOL fRecommendedIgnoreBundle, - __inout BOOL* pfCancel, - __inout BOOL* pfIgnoreBundle - ) = 0; - - STDMETHOD(OnCacheContainerOrPayloadVerifyBegin)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnCacheContainerOrPayloadVerifyProgress)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in DWORD64 dw64Progress, - __in DWORD64 dw64Total, - __in DWORD dwOverallPercentage, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnCacheContainerOrPayloadVerifyComplete)( - __in_z_opt LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrStatus - ) = 0; - - STDMETHOD(OnCachePayloadExtractBegin)( - __in_z_opt LPCWSTR wzContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnCachePayloadExtractProgress)( - __in_z_opt LPCWSTR wzContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in DWORD64 dw64Progress, - __in DWORD64 dw64Total, - __in DWORD dwOverallPercentage, - __inout BOOL* pfCancel - ) = 0; - - STDMETHOD(OnCachePayloadExtractComplete)( - __in_z_opt LPCWSTR wzContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrStatus - ) = 0; -}; diff --git a/src/balutil/inc/IBootstrapperApplicationFactory.h b/src/balutil/inc/IBootstrapperApplicationFactory.h deleted file mode 100644 index fd603e50..00000000 --- a/src/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/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h deleted file mode 100644 index ccb07f4f..00000000 --- a/src/balutil/inc/IBootstrapperEngine.h +++ /dev/null @@ -1,140 +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. - - -DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-81512C29C2FB") -{ - STDMETHOD(GetPackageCount)( - __out DWORD* pcPackages - ) = 0; - - STDMETHOD(GetVariableNumeric)( - __in_z LPCWSTR wzVariable, - __out LONGLONG* pllValue - ) = 0; - - STDMETHOD(GetVariableString)( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) = 0; - - STDMETHOD(GetVariableVersion)( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T * pcchValue - ) = 0; - - STDMETHOD(FormatString)( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T * pcchOut - ) = 0; - - STDMETHOD(EscapeString)( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T * pcchOut - ) = 0; - - STDMETHOD(EvaluateCondition)( - __in_z LPCWSTR wzCondition, - __out BOOL* pf - ) = 0; - - STDMETHOD(Log)( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in_z LPCWSTR wzMessage - ) = 0; - - STDMETHOD(SendEmbeddedError)( - __in DWORD dwErrorCode, - __in_z_opt LPCWSTR wzMessage, - __in DWORD dwUIHint, - __out int* pnResult - ) = 0; - - STDMETHOD(SendEmbeddedProgress)( - __in DWORD dwProgressPercentage, - __in DWORD dwOverallProgressPercentage, - __out int* pnResult - ) = 0; - - STDMETHOD(SetUpdate)( - __in_z_opt LPCWSTR wzLocalSource, - __in_z_opt LPCWSTR wzDownloadSource, - __in DWORD64 qwSize, - __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_bcount_opt(cbHash) BYTE* rgbHash, - __in DWORD cbHash - ) = 0; - - STDMETHOD(SetLocalSource)( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzPath - ) = 0; - - STDMETHOD(SetDownloadSource)( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzUrl, - __in_z_opt LPCWSTR wzUser, - __in_z_opt LPCWSTR wzPassword - ) = 0; - - STDMETHOD(SetVariableNumeric)( - __in_z LPCWSTR wzVariable, - __in LONGLONG llValue - ) = 0; - - STDMETHOD(SetVariableString)( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue, - __in BOOL fFormatted - ) = 0; - - STDMETHOD(SetVariableVersion)( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) = 0; - - STDMETHOD(CloseSplashScreen)() = 0; - - STDMETHOD(Detect)( - __in_opt HWND hwndParent = NULL - ) = 0; - - STDMETHOD(Plan)( - __in BOOTSTRAPPER_ACTION action - ) = 0; - - STDMETHOD(Elevate)( - __in_opt HWND hwndParent - ) = 0; - - STDMETHOD(Apply)( - __in HWND hwndParent - ) = 0; - - STDMETHOD(Quit)( - __in DWORD dwExitCode - ) = 0; - - STDMETHOD(LaunchApprovedExe)( - __in_opt HWND hwndParent, - __in_z LPCWSTR wzApprovedExeForElevationId, - __in_z_opt LPCWSTR wzArguments, - __in DWORD dwWaitForInputIdleTimeout - ) = 0; - - STDMETHOD(SetUpdateSource)( - __in_z LPCWSTR wzUrl - ) = 0; - - STDMETHOD(CompareVersions)( - __in_z LPCWSTR wzVersion1, - __in_z LPCWSTR wzVersion2, - __out int* pnResult - ) = 0; -}; diff --git a/src/balutil/inc/balcondition.h b/src/balutil/inc/balcondition.h deleted file mode 100644 index 677c593f..00000000 --- a/src/balutil/inc/balcondition.h +++ /dev/null @@ -1,58 +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. - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _BAL_CONDITION -{ - LPWSTR sczCondition; - LPWSTR sczMessage; -} BAL_CONDITION; - - -typedef struct _BAL_CONDITIONS -{ - BAL_CONDITION* rgConditions; - DWORD cConditions; -} BAL_CONDITIONS; - - -/******************************************************************* - BalConditionsParseFromXml - loads the conditions from the UX manifest. - -********************************************************************/ -DAPI_(HRESULT) BalConditionsParseFromXml( - __in BAL_CONDITIONS* pConditions, - __in IXMLDOMDocument* pixdManifest, - __in_opt WIX_LOCALIZATION* pWixLoc - ); - - -/******************************************************************* - BalConditionEvaluate - evaluates condition against the provided IBurnCore. - - NOTE: psczMessage is optional. -********************************************************************/ -DAPI_(HRESULT) BalConditionEvaluate( - __in BAL_CONDITION* pCondition, - __in IBootstrapperEngine* pEngine, - __out BOOL* pfResult, - __out_z_opt LPWSTR* psczMessage - ); - - -/******************************************************************* - BalConditionsUninitialize - uninitializes any conditions previously loaded. - -********************************************************************/ -DAPI_(void) BalConditionsUninitialize( - __in BAL_CONDITIONS* pConditions - ); - - -#ifdef __cplusplus -} -#endif diff --git a/src/balutil/inc/balinfo.h b/src/balutil/inc/balinfo.h deleted file mode 100644 index 8c2155e9..00000000 --- a/src/balutil/inc/balinfo.h +++ /dev/null @@ -1,105 +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. - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum BAL_INFO_PACKAGE_TYPE -{ - BAL_INFO_PACKAGE_TYPE_UNKNOWN, - BAL_INFO_PACKAGE_TYPE_EXE, - BAL_INFO_PACKAGE_TYPE_MSI, - BAL_INFO_PACKAGE_TYPE_MSP, - BAL_INFO_PACKAGE_TYPE_MSU, - BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE, - BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON, - BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, -} BAL_INFO_PACKAGE_TYPE; - - -typedef struct _BAL_INFO_PACKAGE -{ - LPWSTR sczId; - LPWSTR sczDisplayName; - LPWSTR sczDescription; - BAL_INFO_PACKAGE_TYPE type; - BOOL fPermanent; - BOOL fVital; - LPWSTR sczDisplayInternalUICondition; - LPWSTR sczProductCode; - LPWSTR sczUpgradeCode; - LPWSTR sczVersion; - LPWSTR sczInstallCondition; - BOOTSTRAPPER_CACHE_TYPE cacheType; - BOOL fPrereqPackage; - LPWSTR sczPrereqLicenseFile; - LPWSTR sczPrereqLicenseUrl; - LPVOID pvCustomData; -} BAL_INFO_PACKAGE; - - -typedef struct _BAL_INFO_PACKAGES -{ - BAL_INFO_PACKAGE* rgPackages; - DWORD cPackages; -} BAL_INFO_PACKAGES; - - -typedef struct _BAL_INFO_BUNDLE -{ - BOOL fPerMachine; - LPWSTR sczName; - LPWSTR sczLogVariable; - BAL_INFO_PACKAGES packages; -} BAL_INFO_BUNDLE; - - -/******************************************************************* - BalInfoParseFromXml - loads the bundle and package info from the UX - manifest. - -********************************************************************/ -DAPI_(HRESULT) BalInfoParseFromXml( - __in BAL_INFO_BUNDLE* pBundle, - __in IXMLDOMDocument* pixdManifest - ); - - -/******************************************************************* - BalInfoAddRelatedBundleAsPackage - adds a related bundle as a package. - - ********************************************************************/ -DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( - __in BAL_INFO_PACKAGES* pPackages, - __in LPCWSTR wzId, - __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in BOOL fPerMachine, - __out_opt BAL_INFO_PACKAGE** ppPackage - ); - - -/******************************************************************* - BalInfoFindPackageById - finds a package by its id. - - ********************************************************************/ -DAPI_(HRESULT) BalInfoFindPackageById( - __in BAL_INFO_PACKAGES* pPackages, - __in LPCWSTR wzId, - __out BAL_INFO_PACKAGE** ppPackage - ); - - -/******************************************************************* - BalInfoUninitialize - uninitializes any info previously loaded. - -********************************************************************/ -DAPI_(void) BalInfoUninitialize( - __in BAL_INFO_BUNDLE* pBundle - ); - - -#ifdef __cplusplus -} -#endif diff --git a/src/balutil/inc/balretry.h b/src/balutil/inc/balretry.h deleted file mode 100644 index 35282a7e..00000000 --- a/src/balutil/inc/balretry.h +++ /dev/null @@ -1,74 +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. - - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************* - BalRetryInitialize - initialize the retry count and timeout between - retries (in milliseconds). -********************************************************************/ -DAPI_(void) BalRetryInitialize( - __in DWORD dwMaxRetries, - __in DWORD dwTimeout - ); - -/******************************************************************* - BalRetryUninitialize - call to cleanup any memory allocated during - use of the retry utility. -********************************************************************/ -DAPI_(void) BalRetryUninitialize(); - -/******************************************************************* - BalRetryStartPackage - call when a package begins to be modified. If - the package is being retried, the function will - wait the specified timeout. -********************************************************************/ -DAPI_(void) BalRetryStartPackage( - __in_z LPCWSTR wzPackageId - ); - -/******************************************************************* - BalRetryErrorOccured - call when an error occurs for the retry utility - to consider. -********************************************************************/ -DAPI_(void) BalRetryErrorOccurred( - __in_z LPCWSTR wzPackageId, - __in DWORD dwError - ); - -/******************************************************************* - BalRetryEndPackage - returns TRUE if a retry is recommended. -********************************************************************/ -DAPI_(HRESULT) BalRetryEndPackage( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrError, - __inout BOOL* pfRetry - ); - -/******************************************************************* - BalRetryStartContainerOrPayload - call when a container or payload - begins to be acquired. If the target is being retried, - the function will wait the specified timeout. -********************************************************************/ -DAPI_(void) BalRetryStartContainerOrPayload( - __in_z_opt LPCWSTR wzContainerOrPackageId, - __in_z_opt LPCWSTR wzPayloadId - ); - -/******************************************************************* - BalRetryEndContainerOrPayload - returns TRUE if a retry is recommended. -********************************************************************/ -DAPI_(HRESULT) BalRetryEndContainerOrPayload( - __in_z_opt LPCWSTR wzContainerOrPackageId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrError, - __inout BOOL* pfRetry - ); - - -#ifdef __cplusplus -} -#endif diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h deleted file mode 100644 index fad8a471..00000000 --- a/src/balutil/inc/balutil.h +++ /dev/null @@ -1,199 +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 "dutil.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -#define BalExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BalExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BalExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } -#define BalExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BalExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BalExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } - -#define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) -#define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) -#define BalExitOnLastError(x, f, ...) BalExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) -#define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) -#define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) -#define BalExitWithLastError(x, f, ...) BalExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) - -#ifndef FACILITY_WIX -#define FACILITY_WIX 500 -#endif - -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); - - -/******************************************************************* - BalInitialize - remembers the engine interface to enable logging and - other functions. - -********************************************************************/ -DAPI_(void) BalInitialize( - __in IBootstrapperEngine* pEngine - ); - -/******************************************************************* - BalInitializeFromCreateArgs - convenience function to call BalBootstrapperEngineCreate - then pass it along to BalInitialize. - -********************************************************************/ -DAPI_(HRESULT) BalInitializeFromCreateArgs( - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, - __out_opt IBootstrapperEngine** ppEngine - ); - -/******************************************************************* - BalUninitialize - cleans up utility layer internals. - -********************************************************************/ -DAPI_(void) BalUninitialize(); - -/******************************************************************* - BalManifestLoad - loads the Application manifest into an XML document. - -********************************************************************/ -DAPI_(HRESULT) BalManifestLoad( - __in HMODULE hUXModule, - __out IXMLDOMDocument** ppixdManifest - ); - -/******************************************************************* -BalEvaluateCondition - evaluates a condition using variables in the engine. - -********************************************************************/ -DAPI_(HRESULT) BalEvaluateCondition( - __in_z LPCWSTR wzCondition, - __out BOOL* pf - ); - -/******************************************************************* -BalFormatString - formats a string using variables in the engine. - - Note: Use StrFree() to release psczOut. -********************************************************************/ -DAPI_(HRESULT) BalFormatString( - __in_z LPCWSTR wzFormat, - __inout LPWSTR* psczOut - ); - -/******************************************************************* -BalGetNumericVariable - gets a number from a variable in the engine. - - Note: Returns E_NOTFOUND if variable does not exist. -********************************************************************/ -DAPI_(HRESULT) BalGetNumericVariable( - __in_z LPCWSTR wzVariable, - __out LONGLONG* pllValue - ); - -/******************************************************************* -BalSetNumericVariable - sets a numeric variable in the engine. - -********************************************************************/ -DAPI_(HRESULT) BalSetNumericVariable( - __in_z LPCWSTR wzVariable, - __in LONGLONG llValue - ); - -/******************************************************************* -BalVariableExists - checks if a variable exists in the engine. - -********************************************************************/ -DAPI_(BOOL) BalVariableExists( - __in_z LPCWSTR wzVariable - ); - -/******************************************************************* -BalGetStringVariable - gets a string from a variable in the engine. - - Note: Use StrFree() to release psczValue. -********************************************************************/ -DAPI_(HRESULT) BalGetStringVariable( - __in_z LPCWSTR wzVariable, - __inout LPWSTR* psczValue - ); - -/******************************************************************* -BalSetStringVariable - sets a string variable in the engine. - -********************************************************************/ -DAPI_(HRESULT) BalSetStringVariable( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue, - __in BOOL fFormatted - ); - -/******************************************************************* - BalLog - logs a message with the engine. - -********************************************************************/ -DAPIV_(HRESULT) BalLog( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - ... - ); - -/******************************************************************* - BalLogArgs - logs a message with the engine. - -********************************************************************/ -DAPI_(HRESULT) BalLogArgs( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ); - -/******************************************************************* - BalLogError - logs an error message with the engine. - -********************************************************************/ -DAPIV_(HRESULT) BalLogError( - __in HRESULT hr, - __in_z __format_string LPCSTR szFormat, - ... - ); - -/******************************************************************* - BalLogErrorArgs - logs an error message with the engine. - -********************************************************************/ -DAPI_(HRESULT) BalLogErrorArgs( - __in HRESULT hr, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ); - -/******************************************************************* -BalLogId - logs a message with the engine with a string embedded in a - MESSAGETABLE resource. - -********************************************************************/ -DAPIV_(HRESULT) BalLogId( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in DWORD dwLogId, - __in HMODULE hModule, - ... - ); - -DAPI_(HRESULT) BalLogIdArgs( - __in BOOTSTRAPPER_LOG_LEVEL level, - __in DWORD dwLogId, - __in HMODULE hModule, - __in va_list args - ); - -#ifdef __cplusplus -} -#endif diff --git a/src/balutil/packages.config b/src/balutil/packages.config deleted file mode 100644 index 08ea3364..00000000 --- a/src/balutil/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/balutil/precomp.cpp b/src/balutil/precomp.cpp deleted file mode 100644 index 37664a1c..00000000 --- a/src/balutil/precomp.cpp +++ /dev/null @@ -1,3 +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" diff --git a/src/balutil/precomp.h b/src/balutil/precomp.h deleted file mode 100644 index c500060a..00000000 --- a/src/balutil/precomp.h +++ /dev/null @@ -1,32 +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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" - -#include "BAFunctions.h" -#include "IBAFunctions.h" - -#include "balutil.h" -#include "BalBootstrapperEngine.h" -#include "balcondition.h" -#include "balinfo.h" -#include "balretry.h" diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp deleted file mode 100644 index 6043e2db..00000000 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ /dev/null @@ -1,344 +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" - - -class CBextBundleExtensionEngine : public IBundleExtensionEngine -{ -public: // IUnknown - virtual STDMETHODIMP QueryInterface( - __in REFIID riid, - __out LPVOID *ppvObject - ) - { - if (!ppvObject) - { - return E_INVALIDARG; - } - - *ppvObject = NULL; - - if (::IsEqualIID(__uuidof(IBundleExtensionEngine), riid)) - { - *ppvObject = static_cast(this); - } - else if (::IsEqualIID(IID_IUnknown, riid)) - { - *ppvObject = reinterpret_cast(this); - } - else // no interface for requested iid - { - return E_NOINTERFACE; - } - - AddRef(); - return S_OK; - } - - virtual STDMETHODIMP_(ULONG) AddRef() - { - return ::InterlockedIncrement(&this->m_cReferences); - } - - virtual STDMETHODIMP_(ULONG) Release() - { - long l = ::InterlockedDecrement(&this->m_cReferences); - if (0 < l) - { - return l; - } - - delete this; - return 0; - } - -public: // IBundleExtensionEngine - virtual STDMETHODIMP EscapeString( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T* pcchOut - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS results = { }; - - ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); - - args.cbSize = sizeof(args); - args.wzIn = wzIn; - - results.cbSize = sizeof(results); - results.wzOut = wzOut; - results.cchOut = *pcchOut; - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pcchOut = results.cchOut; - - LExit: - return hr; - } - - virtual STDMETHODIMP EvaluateCondition( - __in_z LPCWSTR wzCondition, - __out BOOL* pf - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS results = { }; - - ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); - - args.cbSize = sizeof(args); - args.wzCondition = wzCondition; - - results.cbSize = sizeof(results); - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pf = results.f; - - LExit: - return hr; - } - - virtual STDMETHODIMP FormatString( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T* pcchOut - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS results = { }; - - ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); - - args.cbSize = sizeof(args); - args.wzIn = wzIn; - - results.cbSize = sizeof(results); - results.wzOut = wzOut; - results.cchOut = *pcchOut; - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pcchOut = results.cchOut; - - LExit: - return hr; - } - - virtual STDMETHODIMP GetVariableNumeric( - __in_z LPCWSTR wzVariable, - __out LONGLONG* pllValue - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS results = { }; - - ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - - results.cbSize = sizeof(results); - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pllValue = results.llValue; - - LExit: - SecureZeroMemory(&results, sizeof(results)); - return hr; - } - - virtual STDMETHODIMP GetVariableString( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS results = { }; - - ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pcchValue = results.cchValue; - - LExit: - return hr; - } - - virtual STDMETHODIMP GetVariableVersion( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS results = { }; - - ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - - results.cbSize = sizeof(results); - results.wzValue = wzValue; - results.cchValue = *pcchValue; - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pcchValue = results.cchValue; - - LExit: - return hr; - } - - virtual STDMETHODIMP Log( - __in BUNDLE_EXTENSION_LOG_LEVEL level, - __in_z LPCWSTR wzMessage - ) - { - BUNDLE_EXTENSION_ENGINE_LOG_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_LOG_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.level = level; - args.wzMessage = wzMessage; - - results.cbSize = sizeof(results); - - return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); - } - - virtual STDMETHODIMP SetVariableNumeric( - __in_z LPCWSTR wzVariable, - __in LONGLONG llValue - ) - { - BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.llValue = llValue; - - results.cbSize = sizeof(results); - - return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); - } - - virtual STDMETHODIMP SetVariableString( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue, - __in BOOL fFormatted - ) - { - BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.wzValue = wzValue; - args.fFormatted = fFormatted; - - results.cbSize = sizeof(results); - - return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); - } - - virtual STDMETHODIMP SetVariableVersion( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) - { - BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.wzValue = wzValue; - - results.cbSize = sizeof(results); - - return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); - } - - virtual STDMETHODIMP CompareVersions( - __in_z LPCWSTR wzVersion1, - __in_z LPCWSTR wzVersion2, - __out int* pnResult - ) - { - HRESULT hr = S_OK; - BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS results = { }; - - ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); - - args.cbSize = sizeof(args); - args.wzVersion1 = wzVersion1; - args.wzVersion2 = wzVersion2; - - results.cbSize = sizeof(results); - - hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBundleExtensionEngineProcContext); - - *pnResult = results.nResult; - - LExit: - return hr; - } - -public: - CBextBundleExtensionEngine( - __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, - __in_opt LPVOID pvBundleExtensionEngineProcContext - ) - { - m_cReferences = 1; - m_pfnBundleExtensionEngineProc = pfnBundleExtensionEngineProc; - m_pvBundleExtensionEngineProcContext = pvBundleExtensionEngineProcContext; - } - -private: - long m_cReferences; - PFN_BUNDLE_EXTENSION_ENGINE_PROC m_pfnBundleExtensionEngineProc; - LPVOID m_pvBundleExtensionEngineProcContext; -}; - -HRESULT BextBundleExtensionEngineCreate( - __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, - __in_opt LPVOID pvBundleExtensionEngineProcContext, - __out IBundleExtensionEngine** ppEngineForExtension - ) -{ - HRESULT hr = S_OK; - CBextBundleExtensionEngine* pBundleExtensionEngine = NULL; - - pBundleExtensionEngine = new CBextBundleExtensionEngine(pfnBundleExtensionEngineProc, pvBundleExtensionEngineProcContext); - ExitOnNull(pBundleExtensionEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BextBundleExtensionEngine object."); - - hr = pBundleExtensionEngine->QueryInterface(IID_PPV_ARGS(ppEngineForExtension)); - ExitOnFailure(hr, "Failed to QI for IBundleExtensionEngine from BextBundleExtensionEngine object."); - -LExit: - ReleaseObject(pBundleExtensionEngine); - return hr; -} diff --git a/src/bextutil/bextutil.cpp b/src/bextutil/bextutil.cpp deleted file mode 100644 index 4b22d502..00000000 --- a/src/bextutil/bextutil.cpp +++ /dev/null @@ -1,221 +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" - -static IBundleExtensionEngine* vpEngine = NULL; - -// prototypes - -DAPI_(void) BextInitialize( - __in IBundleExtensionEngine* pEngine - ) -{ - pEngine->AddRef(); - - ReleaseObject(vpEngine); - vpEngine = pEngine; -} - -DAPI_(HRESULT) BextInitializeFromCreateArgs( - __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, - __out_opt IBundleExtensionEngine** ppEngine - ) -{ - HRESULT hr = S_OK; - IBundleExtensionEngine* pEngine = NULL; - - hr = BextBundleExtensionEngineCreate(pArgs->pfnBundleExtensionEngineProc, pArgs->pvBundleExtensionEngineProcContext, &pEngine); - ExitOnFailure(hr, "Failed to create BextBundleExtensionEngine."); - - BextInitialize(pEngine); - - if (ppEngine) - { - *ppEngine = pEngine; - } - pEngine = NULL; - -LExit: - ReleaseObject(pEngine); - - return hr; -} - - -DAPI_(void) BextUninitialize() -{ - ReleaseNullObject(vpEngine); -} - -DAPI_(HRESULT) BextGetBundleExtensionDataNode( - __in IXMLDOMDocument* pixdManifest, - __in LPCWSTR wzExtensionId, - __out IXMLDOMNode** ppixnBundleExtension - ) -{ - HRESULT hr = S_OK; - IXMLDOMElement* pixeBundleExtensionData = NULL; - IXMLDOMNodeList* pixnNodes = NULL; - IXMLDOMNode* pixnNode = NULL; - DWORD cNodes = 0; - LPWSTR sczId = NULL; - - // Get BundleExtensionData element. - hr = pixdManifest->get_documentElement(&pixeBundleExtensionData); - ExitOnFailure(hr, "Failed to get BundleExtensionData element."); - - // Select BundleExtension nodes. - hr = XmlSelectNodes(pixeBundleExtensionData, L"BundleExtension", &pixnNodes); - ExitOnFailure(hr, "Failed to select BundleExtension nodes."); - - // Get BundleExtension node count. - hr = pixnNodes->get_length((long*)&cNodes); - ExitOnFailure(hr, "Failed to get BundleExtension node count."); - - if (!cNodes) - { - ExitFunction(); - } - - // Find requested extension. - for (DWORD i = 0; i < cNodes; ++i) - { - hr = XmlNextElement(pixnNodes, &pixnNode, NULL); - ExitOnFailure(hr, "Failed to get next node."); - - // @Id - hr = XmlGetAttributeEx(pixnNode, L"Id", &sczId); - ExitOnFailure(hr, "Failed to get @Id."); - - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczId, -1, wzExtensionId, -1)) - { - *ppixnBundleExtension = pixnNode; - pixnNode = NULL; - - ExitFunction1(hr = S_OK); - } - - // Prepare next iteration. - ReleaseNullObject(pixnNode); - } - - hr = E_NOTFOUND; - -LExit: - ReleaseStr(sczId); - ReleaseObject(pixnNode); - ReleaseObject(pixnNodes); - ReleaseObject(pixeBundleExtensionData); - - return hr; -} - - -DAPIV_(HRESULT) BextLog( - __in BUNDLE_EXTENSION_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - ... - ) -{ - HRESULT hr = S_OK; - va_list args; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BextInitialize() must be called first."); - } - - va_start(args, szFormat); - hr = BextLogArgs(level, szFormat, args); - va_end(args); - -LExit: - return hr; -} - - -DAPI_(HRESULT) BextLogArgs( - __in BUNDLE_EXTENSION_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ) -{ - HRESULT hr = S_OK; - LPSTR sczFormattedAnsi = NULL; - LPWSTR sczMessage = NULL; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BextInitialize() must be called first."); - } - - hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - ExitOnFailure(hr, "Failed to format log string."); - - hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); - ExitOnFailure(hr, "Failed to convert log string to Unicode."); - - hr = vpEngine->Log(level, sczMessage); - -LExit: - ReleaseStr(sczMessage); - ReleaseStr(sczFormattedAnsi); - return hr; -} - - -DAPIV_(HRESULT) BextLogError( - __in HRESULT hrError, - __in_z __format_string LPCSTR szFormat, - ... - ) -{ - HRESULT hr = S_OK; - va_list args; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BextInitialize() must be called first."); - } - - va_start(args, szFormat); - hr = BextLogErrorArgs(hrError, szFormat, args); - va_end(args); - -LExit: - return hr; -} - - -DAPI_(HRESULT) BextLogErrorArgs( - __in HRESULT hrError, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ) -{ - HRESULT hr = S_OK; - LPSTR sczFormattedAnsi = NULL; - LPWSTR sczMessage = NULL; - - if (!vpEngine) - { - hr = E_POINTER; - ExitOnRootFailure(hr, "BextInitialize() must be called first."); - } - - hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - ExitOnFailure(hr, "Failed to format error log string."); - - hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); - ExitOnFailure(hr, "Failed to prepend error number to error log string."); - - hr = vpEngine->Log(BUNDLE_EXTENSION_LOG_LEVEL_ERROR, sczMessage); - -LExit: - ReleaseStr(sczMessage); - ReleaseStr(sczFormattedAnsi); - return hr; -} diff --git a/src/bextutil/bextutil.nuspec b/src/bextutil/bextutil.nuspec deleted file mode 100644 index 752dbb97..00000000 --- a/src/bextutil/bextutil.nuspec +++ /dev/null @@ -1,31 +0,0 @@ - - - - $id$ - $version$ - $authors$ - $authors$ - MS-RL - https://github.com/wixtoolset/balutil - false - $description$ - $copyright$ - - - - - - - - - - - - - - - - - - - diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj deleted file mode 100644 index b9334cf3..00000000 --- a/src/bextutil/bextutil.vcxproj +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - Debug - ARM64 - - - Release - ARM64 - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - {06027492-1CB9-48BC-B31E-C1F9356ED07E} - StaticLibrary - bextutil - v142 - MultiByte - WiX Toolset Bundle Extension native utility library - WixToolset.BextUtil - - - - - - - - - - - - - - - $(ProjectDir)..\inc - - - - - - - Create - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/src/bextutil/build/WixToolset.BextUtil.props b/src/bextutil/build/WixToolset.BextUtil.props deleted file mode 100644 index 60a2db54..00000000 --- a/src/bextutil/build/WixToolset.BextUtil.props +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) - - - $(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories) - - - - - $(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) - - - - - $(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) - - - - - $(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies) - - - diff --git a/src/bextutil/inc/BextBaseBundleExtension.h b/src/bextutil/inc/BextBaseBundleExtension.h deleted file mode 100644 index 69c338e4..00000000 --- a/src/bextutil/inc/BextBaseBundleExtension.h +++ /dev/null @@ -1,120 +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 - -#include "BundleExtensionEngine.h" -#include "BundleExtension.h" -#include "IBundleExtensionEngine.h" -#include "IBundleExtension.h" - -#include "bextutil.h" - -class CBextBaseBundleExtension : public IBundleExtension -{ -public: // IUnknown - virtual STDMETHODIMP QueryInterface( - __in REFIID riid, - __out LPVOID *ppvObject - ) - { - if (!ppvObject) - { - return E_INVALIDARG; - } - - *ppvObject = NULL; - - if (::IsEqualIID(__uuidof(IBundleExtension), riid)) - { - *ppvObject = static_cast(this); - } - else if (::IsEqualIID(IID_IUnknown, riid)) - { - *ppvObject = static_cast(this); - } - else // no interface for requested iid - { - return E_NOINTERFACE; - } - - AddRef(); - return S_OK; - } - - virtual STDMETHODIMP_(ULONG) AddRef() - { - return ::InterlockedIncrement(&this->m_cReferences); - } - - virtual STDMETHODIMP_(ULONG) Release() - { - long l = ::InterlockedDecrement(&this->m_cReferences); - if (0 < l) - { - return l; - } - - delete this; - return 0; - } - -public: // IBundleExtension - virtual STDMETHODIMP Search( - __in LPCWSTR /*wzId*/, - __in LPCWSTR /*wzVariable*/ - ) - { - return E_NOTIMPL; - } - - virtual STDMETHODIMP BundleExtensionProc( - __in BUNDLE_EXTENSION_MESSAGE /*message*/, - __in const LPVOID /*pvArgs*/, - __inout LPVOID /*pvResults*/, - __in_opt LPVOID /*pvContext*/ - ) - { - return E_NOTIMPL; - } - -public: //CBextBaseBundleExtension - virtual STDMETHODIMP Initialize( - __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs - ) - { - HRESULT hr = S_OK; - - hr = StrAllocString(&m_sczBundleExtensionDataPath, pCreateArgs->wzBundleExtensionDataPath, 0); - ExitOnFailure(hr, "Failed to copy BundleExtensionDataPath."); - - LExit: - return hr; - } - -protected: - - CBextBaseBundleExtension( - __in IBundleExtensionEngine* pEngine - ) - { - m_cReferences = 1; - - pEngine->AddRef(); - m_pEngine = pEngine; - - m_sczBundleExtensionDataPath = NULL; - } - - virtual ~CBextBaseBundleExtension() - { - ReleaseNullObject(m_pEngine); - ReleaseStr(m_sczBundleExtensionDataPath); - } - -protected: - IBundleExtensionEngine* m_pEngine; - LPWSTR m_sczBundleExtensionDataPath; - -private: - long m_cReferences; -}; diff --git a/src/bextutil/inc/BextBaseBundleExtensionProc.h b/src/bextutil/inc/BextBaseBundleExtensionProc.h deleted file mode 100644 index f71e3b92..00000000 --- a/src/bextutil/inc/BextBaseBundleExtensionProc.h +++ /dev/null @@ -1,48 +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 "BundleExtensionEngine.h" -#include "BundleExtension.h" -#include "IBundleExtensionEngine.h" -#include "IBundleExtension.h" - -static HRESULT BextBaseBEProcSearch( - __in IBundleExtension* pBE, - __in BUNDLE_EXTENSION_SEARCH_ARGS* pArgs, - __inout BUNDLE_EXTENSION_SEARCH_RESULTS* /*pResults*/ - ) -{ - return pBE->Search(pArgs->wzId, pArgs->wzVariable); -} - -/******************************************************************* -BextBaseBundleExtensionProc - requires pvContext to be of type IBundleExtension. - Provides a default mapping between the message based - BundleExtension interface and the COM-based BundleExtension interface. - -*******************************************************************/ -static HRESULT WINAPI BextBaseBundleExtensionProc( - __in BUNDLE_EXTENSION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ) -{ - IBundleExtension* pBE = reinterpret_cast(pvContext); - HRESULT hr = pBE->BundleExtensionProc(message, pvArgs, pvResults, pvContext); - - if (E_NOTIMPL == hr) - { - switch (message) - { - case BUNDLE_EXTENSION_MESSAGE_SEARCH: - hr = BextBaseBEProcSearch(pBE, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); - break; - } - } - - return hr; -} diff --git a/src/bextutil/inc/BextBundleExtensionEngine.h b/src/bextutil/inc/BextBundleExtensionEngine.h deleted file mode 100644 index 9fdcb700..00000000 --- a/src/bextutil/inc/BextBundleExtensionEngine.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 BextBundleExtensionEngineCreate( - __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, - __in_opt LPVOID pvBundleExtensionEngineProcContext, - __out IBundleExtensionEngine** ppEngineForExtension - ); - -#ifdef __cplusplus -} -#endif diff --git a/src/bextutil/inc/IBundleExtension.h b/src/bextutil/inc/IBundleExtension.h deleted file mode 100644 index 7516c11b..00000000 --- a/src/bextutil/inc/IBundleExtension.h +++ /dev/null @@ -1,20 +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. - - -DECLARE_INTERFACE_IID_(IBundleExtension, IUnknown, "93123C9D-796B-4FCD-A507-6EDEF9A925FD") -{ - STDMETHOD(Search)( - __in LPCWSTR wzId, - __in LPCWSTR wzVariable - ) = 0; - - // BundleExtensionProc - The PFN_BUNDLE_EXTENSION_PROC can call this method to give the BundleExtension raw access to the callback from the engine. - // This might be used to help the BundleExtension support more than one version of the engine. - STDMETHOD(BundleExtensionProc)( - __in BUNDLE_EXTENSION_MESSAGE message, - __in const LPVOID pvArgs, - __inout LPVOID pvResults, - __in_opt LPVOID pvContext - ) = 0; -}; diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h deleted file mode 100644 index 63dadb06..00000000 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ /dev/null @@ -1,67 +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. - - -DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-9737-C185089EB263") -{ - STDMETHOD(EscapeString)( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T* pcchOut - ) = 0; - - STDMETHOD(EvaluateCondition)( - __in_z LPCWSTR wzCondition, - __out BOOL* pf - ) = 0; - - STDMETHOD(FormatString)( - __in_z LPCWSTR wzIn, - __out_ecount_opt(*pcchOut) LPWSTR wzOut, - __inout SIZE_T* pcchOut - ) = 0; - - STDMETHOD(GetVariableNumeric)( - __in_z LPCWSTR wzVariable, - __out LONGLONG* pllValue - ) = 0; - - STDMETHOD(GetVariableString)( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) = 0; - - STDMETHOD(GetVariableVersion)( - __in_z LPCWSTR wzVariable, - __out_ecount_opt(*pcchValue) LPWSTR wzValue, - __inout SIZE_T* pcchValue - ) = 0; - - STDMETHOD(Log)( - __in BUNDLE_EXTENSION_LOG_LEVEL level, - __in_z LPCWSTR wzMessage - ) = 0; - - STDMETHOD(SetVariableNumeric)( - __in_z LPCWSTR wzVariable, - __in LONGLONG llValue - ) = 0; - - STDMETHOD(SetVariableString)( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue, - __in BOOL fFormatted - ) = 0; - - STDMETHOD(SetVariableVersion)( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) = 0; - - STDMETHOD(CompareVersions)( - __in_z LPCWSTR wzVersion1, - __in_z LPCWSTR wzVersion2, - __out int* pnResult - ) = 0; -}; diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h deleted file mode 100644 index ac9c0062..00000000 --- a/src/bextutil/inc/bextutil.h +++ /dev/null @@ -1,106 +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 "dutil.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -#define BextExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BextExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BextExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } -#define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } -#define BextExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } - -#define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) -#define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) -#define BextExitOnLastError(x, f, ...) BextExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) -#define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) -#define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) -#define BextExitWithLastError(x, f, ...) BextExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) - -const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml"; - - -/******************************************************************* - BextInitialize - remembers the engine interface to enable logging and - other functions. - -********************************************************************/ -DAPI_(void) BextInitialize( - __in IBundleExtensionEngine* pEngine - ); - -/******************************************************************* - BextInitializeFromCreateArgs - convenience function to call BextBundleExtensionEngineCreate - then pass it along to BextInitialize. - -********************************************************************/ -DAPI_(HRESULT) BextInitializeFromCreateArgs( - __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, - __out IBundleExtensionEngine** ppEngine - ); - -/******************************************************************* - BextUninitialize - cleans up utility layer internals. - -********************************************************************/ -DAPI_(void) BextUninitialize(); - -/******************************************************************* - BextGetBundleExtensionDataNode - gets the requested BundleExtension node. - -********************************************************************/ -DAPI_(HRESULT) BextGetBundleExtensionDataNode( - __in IXMLDOMDocument* pixdManifest, - __in LPCWSTR wzExtensionId, - __out IXMLDOMNode** ppixnBundleExtension - ); - -/******************************************************************* - BextLog - logs a message with the engine. - -********************************************************************/ -DAPIV_(HRESULT) BextLog( - __in BUNDLE_EXTENSION_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - ... - ); - -/******************************************************************* - BextLogArgs - logs a message with the engine. - -********************************************************************/ -DAPI_(HRESULT) BextLogArgs( - __in BUNDLE_EXTENSION_LOG_LEVEL level, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ); - -/******************************************************************* - BextLogError - logs an error message with the engine. - -********************************************************************/ -DAPIV_(HRESULT) BextLogError( - __in HRESULT hr, - __in_z __format_string LPCSTR szFormat, - ... - ); - -/******************************************************************* - BextLogErrorArgs - logs an error message with the engine. - -********************************************************************/ -DAPI_(HRESULT) BextLogErrorArgs( - __in HRESULT hr, - __in_z __format_string LPCSTR szFormat, - __in va_list args - ); - -#ifdef __cplusplus -} -#endif diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config deleted file mode 100644 index 08ea3364..00000000 --- a/src/bextutil/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/bextutil/precomp.cpp b/src/bextutil/precomp.cpp deleted file mode 100644 index 37664a1c..00000000 --- a/src/bextutil/precomp.cpp +++ /dev/null @@ -1,3 +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" diff --git a/src/bextutil/precomp.h b/src/bextutil/precomp.h deleted file mode 100644 index 5d1dd20b..00000000 --- a/src/bextutil/precomp.h +++ /dev/null @@ -1,22 +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 -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "IBundleExtensionEngine.h" -#include "IBundleExtension.h" - -#include "bextutil.h" -#include "BextBundleExtensionEngine.h" diff --git a/src/mbanative/mbanative.cpp b/src/mbanative/mbanative.cpp deleted file mode 100644 index 98ea3c30..00000000 --- a/src/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/mbanative/mbanative.def b/src/mbanative/mbanative.def deleted file mode 100644 index 28e923b6..00000000 --- a/src/mbanative/mbanative.def +++ /dev/null @@ -1,12 +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. - - -EXPORTS - InitializeFromCreateArgs - StoreBAInCreateResults - VerCompareParsedVersions - VerCompareStringVersions - VerCopyVersion - VerFreeVersion - VerParseVersion - VerVersionFromQword diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj deleted file mode 100644 index f91fe3be..00000000 --- a/src/mbanative/mbanative.vcxproj +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - Debug - ARM64 - - - Release - ARM64 - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - {665E0441-17F9-4105-B202-EDF274657F6E} - DynamicLibrary - v142 - Unicode - mbanative - mbanative.def - false - - - - - - - - - - - - - - - ..\balutil\inc - balutil.lib - - - - - - Create - - - - - - - - - - - - - - - - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config deleted file mode 100644 index 745fcae9..00000000 --- a/src/mbanative/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/mbanative/precomp.cpp b/src/mbanative/precomp.cpp deleted file mode 100644 index 37664a1c..00000000 --- a/src/mbanative/precomp.cpp +++ /dev/null @@ -1,3 +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" diff --git a/src/mbanative/precomp.h b/src/mbanative/precomp.h deleted file mode 100644 index 2e2f3ff8..00000000 --- a/src/mbanative/precomp.h +++ /dev/null @@ -1,16 +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 - -#include -#include - -#include -#include - -#include -#include -#include diff --git a/src/signing.json b/src/signing.json new file mode 100644 index 00000000..fe1c8c9b --- /dev/null +++ b/src/signing.json @@ -0,0 +1,13 @@ +{ + "SignClient": { + "AzureAd": { + "AADInstance": "https://login.microsoftonline.com/", + "ClientId": "c248d68a-ba6f-4aa9-8a68-71fe872063f8", + "TenantId": "16076fdc-fcc1-4a15-b1ca-32c9a255900e" + }, + "Service": { + "Url": "https://codesign.dotnetfoundation.org/", + "ResourceId": "https://SignService/3c30251f-36f3-490b-a955-520addb85001" + } + } +} diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj deleted file mode 100644 index d3a81e2a..00000000 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - Debug - Win32 - - - Release - Win32 - - - - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} - {9B507AF9-035E-4DB6-8C0C-5DCC3FEF2631} - UnitTest - ManagedCProj - DynamicLibrary - Unicode - true - false - - - - - ..\..\balutil\inc - comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib - - - - Create - - 4564;4691 - - - - - - - - - - - - - - - ..\..\..\packages\WixBuildTools.TestSupport.4.0.50\lib\net472\WixBuildTools.TestSupport.dll - - - ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.50\lib\net472\WixBuildTools.TestSupport.Native.dll - - - - - {EDCB8095-0E6A-43E0-BC33-C4F762FC5CDB} - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters deleted file mode 100644 index 85f31076..00000000 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/TestBAFunctions.cpp b/src/test/BalUtilUnitTest/TestBAFunctions.cpp deleted file mode 100644 index 927a8d10..00000000 --- a/src/test/BalUtilUnitTest/TestBAFunctions.cpp +++ /dev/null @@ -1,41 +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 "BalBaseBAFunctions.h" -#include "BalBaseBAFunctionsProc.h" - -class CTestBAFunctions : public CBalBaseBAFunctions -{ -public: - CTestBAFunctions( - __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, - __in const BA_FUNCTIONS_CREATE_ARGS* pArgs - ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) - { - } -}; - -HRESULT CreateBAFunctions( - __in HMODULE hModule, - __in IBootstrapperEngine* pEngine, - __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, - __in BA_FUNCTIONS_CREATE_RESULTS* pResults, - __out IBAFunctions** ppApplication - ) -{ - HRESULT hr = S_OK; - CTestBAFunctions* pApplication = NULL; - - pApplication = new CTestBAFunctions(hModule, pEngine, pArgs); - ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object."); - - pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; - pResults->pvBAFunctionsProcContext = pApplication; - *ppApplication = pApplication; - pApplication = NULL; - -LExit: - ReleaseObject(pApplication); - return hr; -} diff --git a/src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp b/src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp deleted file mode 100644 index 13d22e72..00000000 --- a/src/test/BalUtilUnitTest/TestBootstrapperApplication.cpp +++ /dev/null @@ -1,39 +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 "BalBaseBootstrapperApplication.h" -#include "BalBaseBootstrapperApplicationProc.h" - -class CTestBootstrapperApplication : public CBalBaseBootstrapperApplication -{ -public: - CTestBootstrapperApplication( - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_CREATE_ARGS* pArgs - ) : CBalBaseBootstrapperApplication(pEngine, pArgs) - { - } -}; - -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, pArgs); - ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bootstrapper application object."); - - pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; - pResults->pvBootstrapperApplicationProcContext = pApplication; - *ppApplication = pApplication; - pApplication = NULL; - -LExit: - ReleaseObject(pApplication); - return hr; -} diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config deleted file mode 100644 index 6d381fbe..00000000 --- a/src/test/BalUtilUnitTest/packages.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/precomp.cpp b/src/test/BalUtilUnitTest/precomp.cpp deleted file mode 100644 index 37664a1c..00000000 --- a/src/test/BalUtilUnitTest/precomp.cpp +++ /dev/null @@ -1,3 +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" diff --git a/src/test/BalUtilUnitTest/precomp.h b/src/test/BalUtilUnitTest/precomp.h deleted file mode 100644 index a84391f9..00000000 --- a/src/test/BalUtilUnitTest/precomp.h +++ /dev/null @@ -1,23 +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 -#include - -#include -#include -#include - -#include -#include - -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" -#include "balutil.h" -#include "balretry.h" -#include "BAFunctions.h" - -#pragma managed -#include diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj deleted file mode 100644 index a9937894..00000000 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - Debug - Win32 - - - Release - Win32 - - - - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} - {B69E6422-49B0-4E28-92F9-B8A7410A6ED9} - UnitTest - ManagedCProj - DynamicLibrary - Unicode - true - false - - - - - ..\..\bextutil\inc - - - - - Create - - 4564;4691 - - - - - - - - - - - - - - ..\..\..\packages\WixBuildTools.TestSupport.4.0.50\lib\net472\WixBuildTools.TestSupport.dll - - - ..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.50\lib\net472\WixBuildTools.TestSupport.Native.dll - - - - - {06027492-1CB9-48BC-B31E-C1F9356ED07E} - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters deleted file mode 100644 index f1711f81..00000000 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/TestBundleExtension.cpp b/src/test/BextUtilUnitTest/TestBundleExtension.cpp deleted file mode 100644 index 921303bb..00000000 --- a/src/test/BextUtilUnitTest/TestBundleExtension.cpp +++ /dev/null @@ -1,42 +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 "BextBaseBundleExtension.h" -#include "BextBaseBundleExtensionProc.h" - -class CTestBundleExtension : public CBextBaseBundleExtension -{ -public: - CTestBundleExtension( - __in IBundleExtensionEngine* pEngine - ) : CBextBaseBundleExtension(pEngine) - { - } -}; - -HRESULT TestBundleExtensionCreate( - __in IBundleExtensionEngine* pEngine, - __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, - __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults, - __out IBundleExtension** ppBundleExtension - ) -{ - HRESULT hr = S_OK; - CTestBundleExtension* pExtension = NULL; - - pExtension = new CTestBundleExtension(pEngine); - ExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CTestBundleExtension."); - - hr = pExtension->Initialize(pArgs); - ExitOnFailure(hr, "CTestBundleExtension initialization failed"); - - pResults->pfnBundleExtensionProc = BextBaseBundleExtensionProc; - pResults->pvBundleExtensionProcContext = pExtension; - - *ppBundleExtension = pExtension; - pExtension = NULL; - -LExit: - ReleaseObject(pExtension); - return hr; -} diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config deleted file mode 100644 index 6d381fbe..00000000 --- a/src/test/BextUtilUnitTest/packages.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/precomp.cpp b/src/test/BextUtilUnitTest/precomp.cpp deleted file mode 100644 index 37664a1c..00000000 --- a/src/test/BextUtilUnitTest/precomp.cpp +++ /dev/null @@ -1,3 +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" diff --git a/src/test/BextUtilUnitTest/precomp.h b/src/test/BextUtilUnitTest/precomp.h deleted file mode 100644 index a6586f70..00000000 --- a/src/test/BextUtilUnitTest/precomp.h +++ /dev/null @@ -1,19 +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 - -#include -#include - -#include -#include - -#include "IBundleExtensionEngine.h" -#include "IBundleExtension.h" -#include "bextutil.h" - -#pragma managed -#include diff --git a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs deleted file mode 100644 index aaf5ee29..00000000 --- a/src/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs +++ /dev/null @@ -1,132 +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.Runtime.InteropServices; - 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", - }; - 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); - Assert.Equal(baFactory.BA.Command.CommandLineArgs, new string[] { "this", "is a", "test" }); - } - 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; - public Restart restart; - [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/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs b/src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs deleted file mode 100644 index 44142e3d..00000000 --- a/src/test/WixToolsetTest.Mba.Core/VerUtilFixture.cs +++ /dev/null @@ -1,93 +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 WixToolset.Mba.Core; - using Xunit; - - public class VerUtilFixture - { - [Fact] - public void CanCompareStringVersions() - { - var version1 = "1.2.3.4+abcd"; - var version2 = "1.2.3.4+zyxw"; - - Assert.Equal(0, VerUtil.CompareStringVersions(version1, version2, strict: false)); - } - - [Fact] - public void CanCopyVersion() - { - var version = "1.2.3.4-5.6.7.8.9.0"; - - VerUtilVersion copiedVersion = null; - try - { - using (var parsedVersion = VerUtil.ParseVersion(version, strict: true)) - { - copiedVersion = VerUtil.CopyVersion(parsedVersion); - } - - using (var secondVersion = VerUtil.ParseVersion(version, strict: true)) - { - Assert.Equal(0, VerUtil.CompareParsedVersions(copiedVersion, secondVersion)); - } - } - finally - { - copiedVersion?.Dispose(); - } - } - - [Fact] - public void CanCreateFromQword() - { - var version = new Version(100, 200, 300, 400); - var qwVersion = Engine.VersionToLong(version); - - using var parsedVersion = VerUtil.VersionFromQword(qwVersion); - Assert.Equal("100.200.300.400", parsedVersion.Version); - Assert.Equal(100u, parsedVersion.Major); - Assert.Equal(200u, parsedVersion.Minor); - Assert.Equal(300u, parsedVersion.Patch); - Assert.Equal(400u, parsedVersion.Revision); - Assert.Empty(parsedVersion.ReleaseLabels); - Assert.Equal("", parsedVersion.Metadata); - Assert.False(parsedVersion.IsInvalid); - } - - [Fact] - public void CanParseVersion() - { - var version = "1.2.3.4-a.b.c.d.5.+abc123"; - - using var parsedVersion = VerUtil.ParseVersion(version, strict: false); - Assert.Equal(version, parsedVersion.Version); - Assert.Equal(1u, parsedVersion.Major); - Assert.Equal(2u, parsedVersion.Minor); - Assert.Equal(3u, parsedVersion.Patch); - Assert.Equal(4u, parsedVersion.Revision); - Assert.Equal(5, parsedVersion.ReleaseLabels.Length); - Assert.Equal("+abc123", parsedVersion.Metadata); - Assert.True(parsedVersion.IsInvalid); - - Assert.Equal("a", parsedVersion.ReleaseLabels[0].Label); - Assert.False(parsedVersion.ReleaseLabels[0].IsNumeric); - - Assert.Equal("b", parsedVersion.ReleaseLabels[1].Label); - Assert.False(parsedVersion.ReleaseLabels[1].IsNumeric); - - Assert.Equal("c", parsedVersion.ReleaseLabels[2].Label); - Assert.False(parsedVersion.ReleaseLabels[2].IsNumeric); - - Assert.Equal("d", parsedVersion.ReleaseLabels[3].Label); - Assert.False(parsedVersion.ReleaseLabels[3].IsNumeric); - - Assert.Equal("5", parsedVersion.ReleaseLabels[4].Label); - Assert.True(parsedVersion.ReleaseLabels[4].IsNumeric); - Assert.Equal(5u, parsedVersion.ReleaseLabels[4].Value); - } - } -} diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj deleted file mode 100644 index 53d82f7e..00000000 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - netcoreapp3.1 - false - win-x86 - false - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject b/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject deleted file mode 100644 index 7b5b2139..00000000 --- a/src/test/WixToolsetTest.Mba.Core/WixToolsetTest.Mba.Core.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/src/version.json b/src/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/src/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} diff --git a/version.json b/version.json deleted file mode 100644 index 5f857771..00000000 --- a/version.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "4.0", - "publicReleaseRefSpec": [ - "^refs/heads/master$" - ], - "cloudBuild": { - "buildNumber": { - "enabled": true - } - } -} -- cgit v1.2.3-55-g6feb