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 --- .../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 + 105 files changed, 19988 insertions(+) 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 (limited to 'src/api') 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 -- cgit v1.2.3-55-g6feb