From a8504dc4eb1c2d09965b0858699ac737336ef3c1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 6 Mar 2024 10:20:29 -0800 Subject: WIP - BA header simplification --- src/burn/engine/ba.h | 160 ++++++++++++++++++++++++++++++ src/burn/engine/bootstrapperapplication.h | 160 ------------------------------ src/burn/engine/engine.vcxproj | 6 +- src/burn/engine/precomp.h | 6 +- src/burn/test/BurnUnitTest/precomp.h | 5 +- 5 files changed, 168 insertions(+), 169 deletions(-) create mode 100644 src/burn/engine/ba.h delete mode 100644 src/burn/engine/bootstrapperapplication.h (limited to 'src/burn') diff --git a/src/burn/engine/ba.h b/src/burn/engine/ba.h new file mode 100644 index 00000000..c092fedf --- /dev/null +++ b/src/burn/engine/ba.h @@ -0,0 +1,160 @@ +#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. + +#define BAAPI HRESULT __stdcall + +#if defined(__cplusplus) +extern "C" { +#endif + + +// constants + +const DWORD BURN_MB_RETRYTRYAGAIN = 0x10; +const DWORD64 BOOTSTRAPPER_APPLICATION_API_VERSION = MAKEQWORDVERSION(2024, 1, 1, 0); + + +// structs + +typedef struct _BURN_USER_EXPERIENCE +{ + BURN_PAYLOADS payloads; + + BURN_PAYLOAD* pPrimaryExePayload; + BURN_PAYLOAD* pSecondaryExePayload; + + //HMODULE hUXModule; + //PFN_BOOTSTRAPPER_APPLICATION_PROC pfnBAProc; + //LPVOID pvBAProcContext; + HANDLE hBAProcess; + PIPE_RPC_HANDLE hBARpcPipe; + BAENGINE_CONTEXT* pEngineContext; + + LPWSTR sczTempDirectory; + + CRITICAL_SECTION csEngineActive; // Changing the engine active state in the user experience must be + // syncronized through this critical section. + // Note: The engine must never do a UX callback while in this critical section. + + BOOL fEngineActive; // Indicates that the engine is currently active with one of the execution + // steps (detect, plan, apply), and cannot accept requests from the UX. + // This flag should be cleared by the engine prior to UX callbacks that + // allow altering of the engine state. + + HRESULT hrApplyError; // Tracks if an error occurs during apply that requires the cache or + // execute threads to bail. + + HWND hwndApply; // The window handle provided at the beginning of Apply(). Only valid + // during apply. + + HWND hwndDetect; // The window handle provided at the beginning of Detect(). Only valid + // during Detect. + + DWORD dwExitCode; // Exit code returned by the user experience for the engine overall. +} BURN_USER_EXPERIENCE; + + +// functions + +/******************************************************************* + BootstrapperApplicationParseFromXml - parses the bootstrapper application + data embedded in the bundle. + +*******************************************************************/ +HRESULT BootstrapperApplicationParseFromXml( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in IXMLDOMNode* pixnBundle +); + +/******************************************************************* + BootstrapperApplicationUninitialize - uninitializes the bootstrapper + application data. + +*******************************************************************/ +void BootstrapperApplicationUninitialize( + __in BURN_USER_EXPERIENCE* pUserExperience +); + +/******************************************************************* + BootstrapperApplicationStart - starts the bootstrapper application + process and creates the bootstrapper application in it. + +*******************************************************************/ +HRESULT BootstrapperApplicationStart( + __in BURN_ENGINE_STATE* pEngineState, + __in BOOL fSecondary +); + +/******************************************************************* + BootstrapperApplicationStop - destroys the bootstrapper application + in the bootstrapper application process, disconnects and waits + for the process to exit. + +*******************************************************************/ +HRESULT BootstrapperApplicationStop( + __in BURN_USER_EXPERIENCE* pUserExperience, + __inout BOOL* pfReload +); + +int BootstrapperApplicationCheckExecuteResult( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in BOOL fRollback, + __in DWORD dwAllowedResults, + __in int nResult +); + +HRESULT BootstrapperApplicationInterpretExecuteResult( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in BOOL fRollback, + __in DWORD dwAllowedResults, + __in int nResult +); + +HRESULT BootstrapperApplicationEnsureWorkingFolder( + __in BURN_CACHE* pCache, + __deref_out_z LPWSTR* psczUserExperienceWorkingFolder +); + +HRESULT BootstrapperApplicationRemove( + __in BURN_USER_EXPERIENCE* pUserExperience +); + +int BootstrapperApplicationSendError( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in BOOTSTRAPPER_ERROR_TYPE errorType, + __in_z_opt LPCWSTR wzPackageId, + __in HRESULT hrCode, + __in_z_opt LPCWSTR wzError, + __in DWORD uiFlags, + __in int nRecommendation +); + +void BootstrapperApplicationActivateEngine( + __in BURN_USER_EXPERIENCE* pUserExperience +); + +void BootstrapperApplicationDeactivateEngine( + __in BURN_USER_EXPERIENCE* pUserExperience +); + +/******************************************************************** + BootstrapperApplicationEnsureEngineInactive - Verifies the engine is inactive. + The caller MUST enter the csActive critical section before calling. + +*********************************************************************/ +HRESULT BootstrapperApplicationEnsureEngineInactive( + __in BURN_USER_EXPERIENCE* pUserExperience + ); + +void BootstrapperApplicationExecuteReset( + __in BURN_USER_EXPERIENCE* pUserExperience + ); + +void BootstrapperApplicationExecutePhaseComplete( + __in BURN_USER_EXPERIENCE* pUserExperience, + __in HRESULT hrResult + ); + +#if defined(__cplusplus) +} +#endif diff --git a/src/burn/engine/bootstrapperapplication.h b/src/burn/engine/bootstrapperapplication.h deleted file mode 100644 index c092fedf..00000000 --- a/src/burn/engine/bootstrapperapplication.h +++ /dev/null @@ -1,160 +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. - -#define BAAPI HRESULT __stdcall - -#if defined(__cplusplus) -extern "C" { -#endif - - -// constants - -const DWORD BURN_MB_RETRYTRYAGAIN = 0x10; -const DWORD64 BOOTSTRAPPER_APPLICATION_API_VERSION = MAKEQWORDVERSION(2024, 1, 1, 0); - - -// structs - -typedef struct _BURN_USER_EXPERIENCE -{ - BURN_PAYLOADS payloads; - - BURN_PAYLOAD* pPrimaryExePayload; - BURN_PAYLOAD* pSecondaryExePayload; - - //HMODULE hUXModule; - //PFN_BOOTSTRAPPER_APPLICATION_PROC pfnBAProc; - //LPVOID pvBAProcContext; - HANDLE hBAProcess; - PIPE_RPC_HANDLE hBARpcPipe; - BAENGINE_CONTEXT* pEngineContext; - - LPWSTR sczTempDirectory; - - CRITICAL_SECTION csEngineActive; // Changing the engine active state in the user experience must be - // syncronized through this critical section. - // Note: The engine must never do a UX callback while in this critical section. - - BOOL fEngineActive; // Indicates that the engine is currently active with one of the execution - // steps (detect, plan, apply), and cannot accept requests from the UX. - // This flag should be cleared by the engine prior to UX callbacks that - // allow altering of the engine state. - - HRESULT hrApplyError; // Tracks if an error occurs during apply that requires the cache or - // execute threads to bail. - - HWND hwndApply; // The window handle provided at the beginning of Apply(). Only valid - // during apply. - - HWND hwndDetect; // The window handle provided at the beginning of Detect(). Only valid - // during Detect. - - DWORD dwExitCode; // Exit code returned by the user experience for the engine overall. -} BURN_USER_EXPERIENCE; - - -// functions - -/******************************************************************* - BootstrapperApplicationParseFromXml - parses the bootstrapper application - data embedded in the bundle. - -*******************************************************************/ -HRESULT BootstrapperApplicationParseFromXml( - __in BURN_USER_EXPERIENCE* pUserExperience, - __in IXMLDOMNode* pixnBundle -); - -/******************************************************************* - BootstrapperApplicationUninitialize - uninitializes the bootstrapper - application data. - -*******************************************************************/ -void BootstrapperApplicationUninitialize( - __in BURN_USER_EXPERIENCE* pUserExperience -); - -/******************************************************************* - BootstrapperApplicationStart - starts the bootstrapper application - process and creates the bootstrapper application in it. - -*******************************************************************/ -HRESULT BootstrapperApplicationStart( - __in BURN_ENGINE_STATE* pEngineState, - __in BOOL fSecondary -); - -/******************************************************************* - BootstrapperApplicationStop - destroys the bootstrapper application - in the bootstrapper application process, disconnects and waits - for the process to exit. - -*******************************************************************/ -HRESULT BootstrapperApplicationStop( - __in BURN_USER_EXPERIENCE* pUserExperience, - __inout BOOL* pfReload -); - -int BootstrapperApplicationCheckExecuteResult( - __in BURN_USER_EXPERIENCE* pUserExperience, - __in BOOL fRollback, - __in DWORD dwAllowedResults, - __in int nResult -); - -HRESULT BootstrapperApplicationInterpretExecuteResult( - __in BURN_USER_EXPERIENCE* pUserExperience, - __in BOOL fRollback, - __in DWORD dwAllowedResults, - __in int nResult -); - -HRESULT BootstrapperApplicationEnsureWorkingFolder( - __in BURN_CACHE* pCache, - __deref_out_z LPWSTR* psczUserExperienceWorkingFolder -); - -HRESULT BootstrapperApplicationRemove( - __in BURN_USER_EXPERIENCE* pUserExperience -); - -int BootstrapperApplicationSendError( - __in BURN_USER_EXPERIENCE* pUserExperience, - __in BOOTSTRAPPER_ERROR_TYPE errorType, - __in_z_opt LPCWSTR wzPackageId, - __in HRESULT hrCode, - __in_z_opt LPCWSTR wzError, - __in DWORD uiFlags, - __in int nRecommendation -); - -void BootstrapperApplicationActivateEngine( - __in BURN_USER_EXPERIENCE* pUserExperience -); - -void BootstrapperApplicationDeactivateEngine( - __in BURN_USER_EXPERIENCE* pUserExperience -); - -/******************************************************************** - BootstrapperApplicationEnsureEngineInactive - Verifies the engine is inactive. - The caller MUST enter the csActive critical section before calling. - -*********************************************************************/ -HRESULT BootstrapperApplicationEnsureEngineInactive( - __in BURN_USER_EXPERIENCE* pUserExperience - ); - -void BootstrapperApplicationExecuteReset( - __in BURN_USER_EXPERIENCE* pUserExperience - ); - -void BootstrapperApplicationExecutePhaseComplete( - __in BURN_USER_EXPERIENCE* pUserExperience, - __in HRESULT hrResult - ); - -#if defined(__cplusplus) -} -#endif diff --git a/src/burn/engine/engine.vcxproj b/src/burn/engine/engine.vcxproj index 7a2447f8..a897140d 100644 --- a/src/burn/engine/engine.vcxproj +++ b/src/burn/engine/engine.vcxproj @@ -102,12 +102,12 @@ - - + + + - diff --git a/src/burn/engine/precomp.h b/src/burn/engine/precomp.h index 1150b2a0..24a01140 100644 --- a/src/burn/engine/precomp.h +++ b/src/burn/engine/precomp.h @@ -61,8 +61,8 @@ #include #include -#include "baenginetypes.h" -#include "batypes.h" +#include "BootstrapperApplication.h" + #include "BundleExtensionEngine.h" #include "BundleExtension.h" @@ -77,7 +77,7 @@ #include "cabextract.h" #include "burnextension.h" #include "search.h" -#include "bootstrapperapplication.h" +#include "ba.h" #include "userexperience.h" #include "package.h" #include "update.h" diff --git a/src/burn/test/BurnUnitTest/precomp.h b/src/burn/test/BurnUnitTest/precomp.h index 82fedf10..1b297429 100644 --- a/src/burn/test/BurnUnitTest/precomp.h +++ b/src/burn/test/BurnUnitTest/precomp.h @@ -37,8 +37,7 @@ #include #include -#include "baenginetypes.h" -#include "batypes.h" +#include "BootstrapperApplication.h" #include "BundleExtensionEngine.h" #include "BundleExtension.h" @@ -53,7 +52,7 @@ #include "cabextract.h" #include "burnextension.h" #include "search.h" -#include "bootstrapperapplication.h" +#include "ba.h" #include "userexperience.h" #include "package.h" #include "update.h" -- cgit v1.2.3-55-g6feb