From 2c568de11510b453f499827919964badef22304e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 31 Dec 2018 23:52:58 -0600 Subject: Import code from old v4 repo --- src/Samples/bafunctions/Readme.txt | 85 + src/Samples/bafunctions/WixSampleBAFunctions.cpp | 95 + src/Samples/bafunctions/bafunctions.cpp | 46 + src/Samples/bafunctions/bafunctions.def | 6 + src/Samples/bafunctions/bafunctions.rc | 118 + src/Samples/bafunctions/bafunctions.vcxproj | 54 + src/Samples/bafunctions/bafunctionsver.h | 13 + src/Samples/bafunctions/precomp.h | 47 + src/Samples/bafunctions/resource.h | 15 + src/mbahost/host.cpp | 656 ++++ src/mbahost/host.def | 6 + src/mbahost/host.vcxproj | 51 + src/mbahost/precomp.h | 25 + src/wixext/BalBinder.cs | 125 + src/wixext/BalCompiler.cs | 562 +++ src/wixext/BalExtensionData.cs | 55 + src/wixext/WixBalExtension.csproj | 47 + src/wixext/bal.xsd | 266 ++ src/wixext/messages.xml | 43 + src/wixext/tables.xml | 41 + src/wixlib/BalExtension.wixproj | 39 + src/wixlib/BalExtension.wxs | 8 + src/wixlib/Mba.wxs | 78 + src/wixlib/NetFx451AsPrereq.wxs | 34 + src/wixlib/NetFx452AsPrereq.wxs | 34 + src/wixlib/NetFx45AsPrereq.wxs | 34 + src/wixlib/NetFx461AsPrereq.wxs | 34 + src/wixlib/NetFx462AsPrereq.wxs | 34 + src/wixlib/NetFx46AsPrereq.wxs | 34 + src/wixlib/NetFx4AsPrereq.wxs | 71 + src/wixlib/wixstdba.wxs | 93 + src/wixlib/wixstdba_platform.wxi | 41 + src/wixlib/wixstdba_x86.wxs | 8 + src/wixstdba/Resources/1028/mbapreq.wxl | 27 + src/wixstdba/Resources/1029/mbapreq.wxl | 30 + src/wixstdba/Resources/1030/mbapreq.wxl | 30 + src/wixstdba/Resources/1031/mbapreq.wxl | 33 + src/wixstdba/Resources/1032/mbapreq.wxl | 32 + src/wixstdba/Resources/1035/mbapreq.wxl | 30 + src/wixstdba/Resources/1036/mbapreq.wxl | 30 + src/wixstdba/Resources/1038/mbapreq.wxl | 30 + src/wixstdba/Resources/1040/mbapreq.wxl | 31 + src/wixstdba/Resources/1041/mbapreq.wxl | 27 + src/wixstdba/Resources/1042/mbapreq.wxl | 27 + src/wixstdba/Resources/1043/mbapreq.wxl | 30 + src/wixstdba/Resources/1044/mbapreq.wxl | 30 + src/wixstdba/Resources/1045/mbapreq.wxl | 30 + src/wixstdba/Resources/1046/mbapreq.wxl | 29 + src/wixstdba/Resources/1049/mbapreq.wxl | 29 + src/wixstdba/Resources/1051/mbapreq.wxl | 30 + src/wixstdba/Resources/1053/mbapreq.wxl | 30 + src/wixstdba/Resources/1055/mbapreq.wxl | 30 + src/wixstdba/Resources/1060/mbapreq.wxl | 30 + src/wixstdba/Resources/2052/mbapreq.wxl | 27 + src/wixstdba/Resources/2070/mbapreq.wxl | 29 + src/wixstdba/Resources/3082/mbapreq.wxl | 31 + src/wixstdba/Resources/HyperlinkLargeTheme.xml | 109 + src/wixstdba/Resources/HyperlinkSidebarTheme.xml | 120 + src/wixstdba/Resources/HyperlinkTheme.wxl | 61 + src/wixstdba/Resources/HyperlinkTheme.xml | 106 + src/wixstdba/Resources/LoremIpsumLicense.rtf | Bin 0 -> 4908 bytes src/wixstdba/Resources/RtfLargeTheme.xml | 108 + src/wixstdba/Resources/RtfTheme.wxl | 58 + src/wixstdba/Resources/RtfTheme.xml | 106 + src/wixstdba/Resources/logo.png | Bin 0 -> 852 bytes src/wixstdba/Resources/logoSide.png | Bin 0 -> 3477 bytes src/wixstdba/Resources/mbapreq.png | Bin 0 -> 797 bytes src/wixstdba/Resources/mbapreq.thm | 47 + src/wixstdba/Resources/mbapreq.wxl | 29 + .../WixStandardBootstrapperApplication.cpp | 3849 ++++++++++++++++++++ src/wixstdba/precomp.h | 51 + src/wixstdba/resource.h | 15 + src/wixstdba/wixstdba.cpp | 78 + src/wixstdba/wixstdba.def | 8 + src/wixstdba/wixstdba.mc | 73 + src/wixstdba/wixstdba.vcxproj | 106 + 76 files changed, 8504 insertions(+) create mode 100644 src/Samples/bafunctions/Readme.txt create mode 100644 src/Samples/bafunctions/WixSampleBAFunctions.cpp create mode 100644 src/Samples/bafunctions/bafunctions.cpp create mode 100644 src/Samples/bafunctions/bafunctions.def create mode 100644 src/Samples/bafunctions/bafunctions.rc create mode 100644 src/Samples/bafunctions/bafunctions.vcxproj create mode 100644 src/Samples/bafunctions/bafunctionsver.h create mode 100644 src/Samples/bafunctions/precomp.h create mode 100644 src/Samples/bafunctions/resource.h create mode 100644 src/mbahost/host.cpp create mode 100644 src/mbahost/host.def create mode 100644 src/mbahost/host.vcxproj create mode 100644 src/mbahost/precomp.h create mode 100644 src/wixext/BalBinder.cs create mode 100644 src/wixext/BalCompiler.cs create mode 100644 src/wixext/BalExtensionData.cs create mode 100644 src/wixext/WixBalExtension.csproj create mode 100644 src/wixext/bal.xsd create mode 100644 src/wixext/messages.xml create mode 100644 src/wixext/tables.xml create mode 100644 src/wixlib/BalExtension.wixproj create mode 100644 src/wixlib/BalExtension.wxs create mode 100644 src/wixlib/Mba.wxs create mode 100644 src/wixlib/NetFx451AsPrereq.wxs create mode 100644 src/wixlib/NetFx452AsPrereq.wxs create mode 100644 src/wixlib/NetFx45AsPrereq.wxs create mode 100644 src/wixlib/NetFx461AsPrereq.wxs create mode 100644 src/wixlib/NetFx462AsPrereq.wxs create mode 100644 src/wixlib/NetFx46AsPrereq.wxs create mode 100644 src/wixlib/NetFx4AsPrereq.wxs create mode 100644 src/wixlib/wixstdba.wxs create mode 100644 src/wixlib/wixstdba_platform.wxi create mode 100644 src/wixlib/wixstdba_x86.wxs create mode 100644 src/wixstdba/Resources/1028/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1029/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1030/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1031/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1032/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1035/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1036/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1038/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1040/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1041/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1042/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1043/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1044/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1045/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1046/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1049/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1051/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1053/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1055/mbapreq.wxl create mode 100644 src/wixstdba/Resources/1060/mbapreq.wxl create mode 100644 src/wixstdba/Resources/2052/mbapreq.wxl create mode 100644 src/wixstdba/Resources/2070/mbapreq.wxl create mode 100644 src/wixstdba/Resources/3082/mbapreq.wxl create mode 100644 src/wixstdba/Resources/HyperlinkLargeTheme.xml create mode 100644 src/wixstdba/Resources/HyperlinkSidebarTheme.xml create mode 100644 src/wixstdba/Resources/HyperlinkTheme.wxl create mode 100644 src/wixstdba/Resources/HyperlinkTheme.xml create mode 100644 src/wixstdba/Resources/LoremIpsumLicense.rtf create mode 100644 src/wixstdba/Resources/RtfLargeTheme.xml create mode 100644 src/wixstdba/Resources/RtfTheme.wxl create mode 100644 src/wixstdba/Resources/RtfTheme.xml create mode 100644 src/wixstdba/Resources/logo.png create mode 100644 src/wixstdba/Resources/logoSide.png create mode 100644 src/wixstdba/Resources/mbapreq.png create mode 100644 src/wixstdba/Resources/mbapreq.thm create mode 100644 src/wixstdba/Resources/mbapreq.wxl create mode 100644 src/wixstdba/WixStandardBootstrapperApplication.cpp create mode 100644 src/wixstdba/precomp.h create mode 100644 src/wixstdba/resource.h create mode 100644 src/wixstdba/wixstdba.cpp create mode 100644 src/wixstdba/wixstdba.def create mode 100644 src/wixstdba/wixstdba.mc create mode 100644 src/wixstdba/wixstdba.vcxproj (limited to 'src') diff --git a/src/Samples/bafunctions/Readme.txt b/src/Samples/bafunctions/Readme.txt new file mode 100644 index 00000000..517d0d4c --- /dev/null +++ b/src/Samples/bafunctions/Readme.txt @@ -0,0 +1,85 @@ + +This is a sample project showing how to create a BA function assembly. + +The four interfaces are in the WixSampleBAFunctions.cpp file. + + +Example code: +~~~~~~~~~~~~~ + + + HRESULT hr = S_OK; + HKEY hkKey = NULL; + LPWSTR sczValue = NULL; + LPWSTR sczFormatedValue = NULL; + + + //--------------------------------------------------------------------------------------------- + // Example of BA function failure + hr = E_NOTIMPL; + BalExitOnFailure(hr, "Test failure."); + //--------------------------------------------------------------------------------------------- + + //--------------------------------------------------------------------------------------------- + // Example of setting a variables + hr = m_pEngine->SetVariableString(L"Variable1", L"String value"); + BalExitOnFailure(hr, "Failed to set variable."); + hr = m_pEngine->SetVariableNumeric(L"Variable2", 1234); + BalExitOnFailure(hr, "Failed to set variable."); + //--------------------------------------------------------------------------------------------- + + //--------------------------------------------------------------------------------------------- + // Example of reading burn variable. + BalGetStringVariable(L"WixBundleName", &sczValue); + BalExitOnFailure(hr, "Failed to get variable."); + + hr = m_pEngine->SetVariableString(L"Variable4", sczValue); + BalExitOnFailure(hr, "Failed to set variable."); + //--------------------------------------------------------------------------------------------- + + ReleaseNullStr(sczValue); // Release string so it can be re-used + + //--------------------------------------------------------------------------------------------- + // Examples of reading burn variable and formatting it. + BalGetStringVariable(L"InstallFolder", &sczValue); + BalExitOnFailure(hr, "Failed to get variable."); + + hr = m_pEngine->SetVariableString(L"Variable5", sczValue); + BalExitOnFailure(hr, "Failed to set variable."); + + BalFormatString(sczValue, &sczFormatedValue); + BalExitOnFailure(hr, "Failed to format variable."); + + hr = m_pEngine->SetVariableString(L"Variable6", sczFormatedValue); + BalExitOnFailure(hr, "Failed to set variable."); + //--------------------------------------------------------------------------------------------- + + ReleaseNullStr(sczValue); // Release string so it can be re-used + + //--------------------------------------------------------------------------------------------- + // Example of reading 64 bit registry and setting the InstallFolder variable to the value read. + hr = RegOpen(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v3.5", KEY_READ | KEY_WOW64_64KEY, &hkKey); + BalExitOnFailure(hr, "Failed to open registry key."); + + hr = RegReadString(hkKey, L"InstallPath", &sczValue); + BalExitOnFailure(hr, "Failed to read registry value."); + + // Example of function call + PathBackslashTerminate(&sczValue); + + hr = m_pEngine->SetVariableString(L"InstallFolder", sczValue); + BalExitOnFailure(hr, "Failed to set variable."); + //--------------------------------------------------------------------------------------------- + + ReleaseNullStr(sczValue); // Release string so it can be re-used + + //--------------------------------------------------------------------------------------------- + // Example of calling a function that return HRESULT + hr = GetFileVersion(); + BalExitOnFailure(hr, "Failed to get version."); + //--------------------------------------------------------------------------------------------- + + LExit: + ReleaseRegKey(hkKey); + ReleaseStr(sczValue); + ReleaseStr(sczFormatedValue); diff --git a/src/Samples/bafunctions/WixSampleBAFunctions.cpp b/src/Samples/bafunctions/WixSampleBAFunctions.cpp new file mode 100644 index 00000000..531b86a3 --- /dev/null +++ b/src/Samples/bafunctions/WixSampleBAFunctions.cpp @@ -0,0 +1,95 @@ +// Copyright (c) .NET 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 CWixSampleBAFunctions : public CBalBaseBAFunctions +{ +public: // IBootstrapperApplication + virtual STDMETHODIMP OnDetectBegin( + __in BOOL fInstalled, + __in DWORD cPackages, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running detect begin BA function. fInstalled=%d, cPackages=%u, fCancel=%d", fInstalled, cPackages, *pfCancel); + + //------------------------------------------------------------------------------------------------- + // YOUR CODE GOES HERE + BalExitOnFailure(hr, "Change this message to represent real error handling."); + //------------------------------------------------------------------------------------------------- + + LExit: + return hr; + } + +public: // IBAFunctions + virtual STDMETHODIMP OnPlanBegin( + __in DWORD cPackages, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running plan begin BA function. cPackages=%u, fCancel=%d", cPackages, *pfCancel); + + //------------------------------------------------------------------------------------------------- + // YOUR CODE GOES HERE + BalExitOnFailure(hr, "Change this message to represent real error handling."); + //------------------------------------------------------------------------------------------------- + + LExit: + return hr; + } + +public: + // + // Constructor - initialize member variables. + // + CWixSampleBAFunctions( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs + ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) + { + } + + // + // Destructor - release member variables. + // + ~CWixSampleBAFunctions() + { + } +}; + + +HRESULT WINAPI CreateBAFunctions( + __in HMODULE hModule, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + CWixSampleBAFunctions* pBAFunctions = NULL; + IBootstrapperEngine* pEngine = NULL; + + // This is required to enable logging functions. + hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine); + ExitOnFailure(hr, "Failed to initialize Bal."); + + pBAFunctions = new CWixSampleBAFunctions(hModule, pEngine, pArgs); + ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CWixSampleBAFunctions object."); + + pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; + pResults->pvBAFunctionsProcContext = pBAFunctions; + pBAFunctions = NULL; + +LExit: + ReleaseObject(pBAFunctions); + ReleaseObject(pEngine); + + return hr; +} diff --git a/src/Samples/bafunctions/bafunctions.cpp b/src/Samples/bafunctions/bafunctions.cpp new file mode 100644 index 00000000..b20f4230 --- /dev/null +++ b/src/Samples/bafunctions/bafunctions.cpp @@ -0,0 +1,46 @@ +// Copyright (c) .NET 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 HINSTANCE vhInstance = NULL; + +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInstance, + IN DWORD dwReason, + IN LPVOID /* pvReserved */ + ) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + ::DisableThreadLibraryCalls(hInstance); + vhInstance = hInstance; + break; + + case DLL_PROCESS_DETACH: + vhInstance = NULL; + break; + } + + return TRUE; +} + +extern "C" HRESULT WINAPI BAFunctionsCreate( + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + + hr = CreateBAFunctions(vhInstance, pArgs, pResults); + BalExitOnFailure(hr, "Failed to create BAFunctions interface."); + +LExit: + return hr; +} + +extern "C" void WINAPI BAFunctionsDestroy( + ) +{ + BalUninitialize(); +} diff --git a/src/Samples/bafunctions/bafunctions.def b/src/Samples/bafunctions/bafunctions.def new file mode 100644 index 00000000..6e016dad --- /dev/null +++ b/src/Samples/bafunctions/bafunctions.def @@ -0,0 +1,6 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +EXPORTS + BAFunctionsCreate + BAFunctionsDestroy diff --git a/src/Samples/bafunctions/bafunctions.rc b/src/Samples/bafunctions/bafunctions.rc new file mode 100644 index 00000000..9643d240 --- /dev/null +++ b/src/Samples/bafunctions/bafunctions.rc @@ -0,0 +1,118 @@ +// Copyright (c) .NET 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 "bafunctionsver.h" + +#define VER_APP +#define VER_ORIGINAL_FILENAME "bafunctions.dll" +#define VER_INTERNAL_NAME "bafunctions" +#define VER_PRODUCT_NAME "WiX Sample BAFunctions" +#define VER_FILE_DESCRIPTION "WiX Sample BAFunctions" + +#ifdef DEBUG + #define VER_DEBUG VS_FF_DEBUG + #define VER_PRIVATE_BUILD VS_FF_PRIVATEBUILD + #define VER_PRE_RELEASE (VS_FF_PRERELEASE | VS_FF_SPECIALBUILD) +#else + #define VER_DEBUG 0 + #define VER_PRIVATE_BUILD 0 + #define VER_PRE_RELEASE 0 +#endif + +#if defined(VER_APP) + #define VER_FILE_TYPE VFT_APP +#elif defined(VER_DLL) + #define VER_FILE_TYPE VFT_DLL +#elif defined(VER_TYPELIB) + #define VER_FILE_TYPE VFT_UNKNOWN +#else + #define VER_FILE_TYPE VFT_UNKNOWN +#endif + +#if defined(VER_LANG_NEUTRAL) + #ifndef VER_LANG + #define VER_LANG 0x0000 + #endif + #ifndef VER_CP + #define VER_CP 0x04E4 + #endif + #ifndef VER_BLOCK + #define VER_BLOCK "000004E4" + #endif +#else + #ifndef VER_LANG + #define VER_LANG 0x0409 + #endif + #ifndef VER_CP + #define VER_CP 0x04E4 + #endif + #ifndef VER_BLOCK + #define VER_BLOCK "040904E4" + #endif +#endif + +#define VER_FILE_VERSION rmj, rmm, rbd, rev +#define VER_PRODUCT_VERSION rmj, rmm, rbd, rev +#define VER_FILE_VERSION_STRING szVerMajorMinorBuildRev +#define VER_PRODUCT_VERSION_STRING VER_FILE_VERSION_STRING +#define VER_FILE_FLAGS_MASK VS_FFI_FILEFLAGSMASK +#define VER_FILE_FLAGS (VER_DEBUG | VER_PRIVATE_BUILD | VER_PRE_RELEASE) + +#define VER_FILE_OS VOS__WINDOWS32 + +#define VER_COMPANY_NAME ".NET Foundation" +#ifndef VER_PRODUCT_NAME + #define VER_PRODUCT_NAME "Windows Installer XML (WiX)" +#endif +#ifndef VER_FILE_DESCRIPTION + #define VER_FILE_DESCRIPTION "Windows Installer XML (WiX) component" +#endif + +#if defined(VER_LEGAL_COPYRIGHT) + #error +#endif +#define VER_LEGAL_COPYRIGHT "Copyright (c) .NET Foundation and contributors.\240 All rights reserved." + +#if !defined(VER_FILE_SUBTYPE) + #define VER_FILE_SUBTYPE 0 +#endif + +#ifdef RC_INVOKED + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILE_VERSION +PRODUCTVERSION VER_PRODUCT_VERSION +FILEFLAGSMASK VER_FILE_FLAGS_MASK +FILEFLAGS VER_FILE_FLAGS +FILEOS VER_FILE_OS +FILETYPE VER_FILE_TYPE +FILESUBTYPE VER_FILE_SUBTYPE +BEGIN +BLOCK "StringFileInfo" + BEGIN + BLOCK VER_BLOCK + BEGIN + VALUE "CompanyName", VER_COMPANY_NAME + VALUE "FileDescription", VER_FILE_DESCRIPTION + VALUE "FileVersion", VER_FILE_VERSION_STRING + VALUE "InternalName", VER_INTERNAL_NAME + + VALUE "LegalCopyright", VER_LEGAL_COPYRIGHT + + VALUE "OriginalFilename", VER_ORIGINAL_FILENAME + VALUE "ProductName", VER_PRODUCT_NAME + VALUE "ProductVersion", VER_FILE_VERSION_STRING +#if defined(DEBUG) + VALUE "WiX Common Resource Format", "Debug Only" +#endif + END + END + +BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", VER_LANG, VER_CP + END +END + +#endif diff --git a/src/Samples/bafunctions/bafunctions.vcxproj b/src/Samples/bafunctions/bafunctions.vcxproj new file mode 100644 index 00000000..71b27bca --- /dev/null +++ b/src/Samples/bafunctions/bafunctions.vcxproj @@ -0,0 +1,54 @@ + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + + Debug + ARM + + + Release + ARM + + + + {EB0A7D51-2133-4EE7-B6CA-87DBEAC67E02} + DynamicLibrary + Unicode + BAFunctions + bafunctions.def + + + + $(WixRoot)src\libs\dutil\inc;$(WixRoot)src\burn\inc;$(WixRoot)src\libs\balutil\inc + comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib;dutil.lib;balutil.lib;version.lib + + + + + + + + + + + + + + + + + + diff --git a/src/Samples/bafunctions/bafunctionsver.h b/src/Samples/bafunctions/bafunctionsver.h new file mode 100644 index 00000000..e6e22f4e --- /dev/null +++ b/src/Samples/bafunctions/bafunctionsver.h @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#ifndef _VERSION_FILE_H_ +#define _VERSION_FILE_H_ + +#define szVerMajorMinor "1.0" +#define szVerMajorMinorBuildRev "1.0.0.0" +#define rmj 1 +#define rmm 0 +#define rbd 0 +#define rev 0 + +#endif diff --git a/src/Samples/bafunctions/precomp.h b/src/Samples/bafunctions/precomp.h new file mode 100644 index 00000000..82ce2dae --- /dev/null +++ b/src/Samples/bafunctions/precomp.h @@ -0,0 +1,47 @@ +#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 + +// Standard WiX header files, include as required +#include "dutil.h" +//#include "memutil.h" +//#include "dictutil.h" +//#include "dirutil.h" +#include "fileutil.h" +#include "locutil.h" +//#include "logutil.h" +#include "pathutil.h" +//#include "resrutil.h" +//#include "shelutil.h" +#include "strutil.h" +#include "thmutil.h" +//#include "uriutil.h" +//#include "xmlutil.h" +#include "regutil.h" + +//#include "IBootstrapperEngine.h" +//#include "IBootstrapperApplication.h" + +#include "BalBaseBootstrapperApplication.h" +//#include "balinfo.h" +//#include "balcondition.h" +#include "balutil.h" + +#include "BAFunctions.h" +#include "IBAFunctions.h" + +HRESULT WINAPI CreateBAFunctions( + __in HMODULE hModule, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ); diff --git a/src/Samples/bafunctions/resource.h b/src/Samples/bafunctions/resource.h new file mode 100644 index 00000000..149a8ff4 --- /dev/null +++ b/src/Samples/bafunctions/resource.h @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#define IDC_STATIC -1 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1003 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/mbahost/host.cpp b/src/mbahost/host.cpp new file mode 100644 index 00000000..694db357 --- /dev/null +++ b/src/mbahost/host.cpp @@ -0,0 +1,656 @@ +// Copyright (c) .NET 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 // includes the generated assembly name macros. +#include "BalBaseBootstrapperApplicationProc.h" + +static const DWORD NET452_RELEASE = 379893; + +using namespace mscorlib; + +extern "C" typedef HRESULT (WINAPI *PFN_CORBINDTOCURRENTRUNTIME)( + __in LPCWSTR pwszFileName, + __in REFCLSID rclsid, + __in REFIID riid, + __out LPVOID *ppv + ); + +extern "C" typedef HRESULT(WINAPI *PFN_MBAPREQ_BOOTSTRAPPER_APPLICATION_CREATE)( + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ); + +static HINSTANCE vhInstance = NULL; +static ICorRuntimeHost *vpCLRHost = NULL; +static _AppDomain *vpAppDomain = NULL; +static HMODULE vhMbapreqModule = NULL; + + +// internal function declarations + +static HRESULT GetAppDomain( + __out _AppDomain** ppAppDomain + ); +static HRESULT GetAppBase( + __out LPWSTR* psczAppBase + ); +static HRESULT CheckSupportedFrameworks( + __in LPCWSTR wzConfigPath + ); +static HRESULT UpdateSupportedRuntime( + __in IXMLDOMDocument* pixdManifest, + __in IXMLDOMNode* pixnSupportedFramework, + __out BOOL* pfUpdatedManifest + ); +static HRESULT GetCLRHost( + __in LPCWSTR wzConfigPath, + __out ICorRuntimeHost** ppCLRHost + ); +static HRESULT CreateManagedBootstrapperApplication( + __in _AppDomain* pAppDomain, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ); +static HRESULT CreateManagedBootstrapperApplicationFactory( + __in _AppDomain* pAppDomain, + __out IBootstrapperApplicationFactory** ppAppFactory + ); +static HRESULT CreatePrerequisiteBA( + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ); +static HRESULT VerifyNET4RuntimeIsSupported( + ); + + +// function definitions + +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInstance, + IN DWORD dwReason, + IN LPVOID /* pvReserved */ + ) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + ::DisableThreadLibraryCalls(hInstance); + vhInstance = hInstance; + break; + + case DLL_PROCESS_DETACH: + vhInstance = NULL; + break; + } + + return TRUE; +} + +// Note: This function assumes that COM was already initialized on the thread. +extern "C" HRESULT WINAPI BootstrapperApplicationCreate( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + HRESULT hrHostInitialization = S_OK; + IBootstrapperEngine* pEngine = NULL; + + hr = BalInitializeFromCreateArgs(pArgs, &pEngine); + ExitOnFailure(hr, "Failed to initialize Bal."); + + hr = GetAppDomain(&vpAppDomain); + if (SUCCEEDED(hr)) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Loading managed bootstrapper application."); + + hr = CreateManagedBootstrapperApplication(vpAppDomain, pEngine, pArgs, pResults); + BalExitOnFailure(hr, "Failed to create the managed bootstrapper application."); + } + else // fallback to the prerequisite BA. + { + if (E_MBAHOST_NET452_ON_WIN7RTM == hr) + { + BalLogError(hr, "The Burn engine cannot run with an MBA under the .NET 4 CLR on Windows 7 RTM with .NET 4.5.2 (or greater) installed."); + hrHostInitialization = hr; + } + else + { + hrHostInitialization = S_OK; + } + + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Loading prerequisite bootstrapper application because managed host could not be loaded, error: 0x%08x.", hr); + + hr = CreatePrerequisiteBA(hrHostInitialization, pEngine, pArgs, pResults); + BalExitOnFailure(hr, "Failed to create the pre-requisite bootstrapper application."); + } + +LExit: + return hr; +} + +extern "C" void WINAPI BootstrapperApplicationDestroy() +{ + if (vpAppDomain) + { + HRESULT hr = vpCLRHost->UnloadDomain(vpAppDomain); + if (FAILED(hr)) + { + BalLogError(hr, "Failed to unload app domain."); + } + + vpAppDomain->Release(); + } + + if (vpCLRHost) + { + vpCLRHost->Stop(); + vpCLRHost->Release(); + } + + if (vhMbapreqModule) + { + PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = reinterpret_cast(::GetProcAddress(vhMbapreqModule, "MbaPrereqBootstrapperApplicationDestroy")); + if (pfnDestroy) + { + (*pfnDestroy)(); + } + + ::FreeLibrary(vhMbapreqModule); + vhMbapreqModule = NULL; + } + + BalUninitialize(); +} + +// Gets the custom AppDomain for loading managed BA. +static HRESULT GetAppDomain( + __out _AppDomain **ppAppDomain + ) +{ + HRESULT hr = S_OK; + ICorRuntimeHost *pCLRHost = NULL; + IUnknown *pUnk = NULL; + LPWSTR sczAppBase = NULL; + LPWSTR sczConfigPath = NULL; + IAppDomainSetup *pAppDomainSetup; + BSTR bstrAppBase = NULL; + BSTR bstrConfigPath = NULL; + + hr = GetAppBase(&sczAppBase); + ExitOnFailure(hr, "Failed to get the host base path."); + + hr = PathConcat(sczAppBase, L"BootstrapperCore.config", &sczConfigPath); + ExitOnFailure(hr, "Failed to get the full path to the application configuration file."); + + // Check that the supported framework is installed. + hr = CheckSupportedFrameworks(sczConfigPath); + ExitOnFailure(hr, "Failed to find supported framework."); + + // Load the CLR. + hr = GetCLRHost(sczConfigPath, &pCLRHost); + ExitOnFailure(hr, "Failed to create the CLR host."); + + hr = pCLRHost->Start(); + ExitOnRootFailure(hr, "Failed to start the CLR host."); + + // Create the setup information for a new AppDomain to set the app base and config. + hr = pCLRHost->CreateDomainSetup(&pUnk); + ExitOnRootFailure(hr, "Failed to create the AppDomainSetup object."); + + hr = pUnk->QueryInterface(__uuidof(IAppDomainSetup), reinterpret_cast(&pAppDomainSetup)); + ExitOnRootFailure(hr, "Failed to query for the IAppDomainSetup interface."); + ReleaseNullObject(pUnk); + + // Set properties on the AppDomainSetup object. + bstrAppBase = ::SysAllocString(sczAppBase); + ExitOnNull(bstrAppBase, hr, E_OUTOFMEMORY, "Failed to allocate the application base path for the AppDomainSetup."); + + hr = pAppDomainSetup->put_ApplicationBase(bstrAppBase); + ExitOnRootFailure(hr, "Failed to set the application base path for the AppDomainSetup."); + + bstrConfigPath = ::SysAllocString(sczConfigPath); + ExitOnNull(bstrConfigPath, hr, E_OUTOFMEMORY, "Failed to allocate the application configuration file for the AppDomainSetup."); + + hr = pAppDomainSetup->put_ConfigurationFile(bstrConfigPath); + ExitOnRootFailure(hr, "Failed to set the configuration file path for the AppDomainSetup."); + + // Create the AppDomain to load the factory type. + hr = pCLRHost->CreateDomainEx(L"MBA", pAppDomainSetup, NULL, &pUnk); + ExitOnRootFailure(hr, "Failed to create the MBA AppDomain."); + + hr = pUnk->QueryInterface(__uuidof(_AppDomain), reinterpret_cast(ppAppDomain)); + ExitOnRootFailure(hr, "Failed to query for the _AppDomain interface."); + +LExit: + ReleaseBSTR(bstrConfigPath); + ReleaseBSTR(bstrAppBase); + ReleaseStr(sczConfigPath); + ReleaseStr(sczAppBase); + ReleaseNullObject(pUnk); + ReleaseNullObject(pCLRHost); + + return hr; +} + +static HRESULT GetAppBase( + __out LPWSTR *psczAppBase + ) +{ + HRESULT hr = S_OK; + LPWSTR sczFullPath = NULL; + + hr = PathForCurrentProcess(&sczFullPath, vhInstance); + ExitOnFailure(hr, "Failed to get the full host path."); + + hr = PathGetDirectory(sczFullPath, psczAppBase); + ExitOnFailure(hr, "Failed to get the directory of the full process path."); + +LExit: + ReleaseStr(sczFullPath); + + return hr; +} + +// Checks whether at least one of required supported frameworks is installed via the NETFX registry keys. +static HRESULT CheckSupportedFrameworks( + __in LPCWSTR wzConfigPath + ) +{ + HRESULT hr = S_OK; + IXMLDOMDocument* pixdManifest = NULL; + IXMLDOMNodeList* pNodeList = NULL; + IXMLDOMNode* pNode = NULL; + DWORD cSupportedFrameworks = 0; + LPWSTR sczSupportedFrameworkVersion = NULL; + LPWSTR sczFrameworkRegistryKey = NULL; + HKEY hkFramework = NULL; + DWORD dwFrameworkInstalled = 0; + BOOL fUpdatedManifest = FALSE; + + hr = XmlInitialize(); + ExitOnFailure(hr, "Failed to initialize XML."); + + hr = XmlLoadDocumentFromFile(wzConfigPath, &pixdManifest); + ExitOnFailure(hr, "Failed to load bootstrapper config file from path: %ls", wzConfigPath); + + hr = XmlSelectNodes(pixdManifest, L"/configuration/wix.bootstrapper/host/supportedFramework", &pNodeList); + ExitOnFailure(hr, "Failed to select all supportedFramework elements."); + + hr = pNodeList->get_length(reinterpret_cast(&cSupportedFrameworks)); + ExitOnFailure(hr, "Failed to get the supported framework count."); + + if (cSupportedFrameworks) + { + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL))) + { + hr = XmlGetAttributeEx(pNode, L"version", &sczSupportedFrameworkVersion); + ExitOnFailure(hr, "Failed to get supportedFramework/@version."); + + hr = StrAllocFormatted(&sczFrameworkRegistryKey, L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\%ls", sczSupportedFrameworkVersion); + ExitOnFailure(hr, "Failed to allocate path to supported framework Install registry key."); + + hr = RegOpen(HKEY_LOCAL_MACHINE, sczFrameworkRegistryKey, KEY_READ, &hkFramework); + if (SUCCEEDED(hr)) + { + hr = RegReadNumber(hkFramework, L"Install", &dwFrameworkInstalled); + if (dwFrameworkInstalled) + { + hr = S_OK; + break; + } + } + + ReleaseNullObject(pNode); + } + + // If we looped through all the supported frameworks but didn't find anything, ensure we return a failure. + if (S_FALSE == hr) + { + hr = E_NOTFOUND; + ExitOnRootFailure(hr, "Failed to find a supported framework."); + } + + hr = UpdateSupportedRuntime(pixdManifest, pNode, &fUpdatedManifest); + ExitOnFailure(hr, "Failed to update supportedRuntime."); + } + // else no supported frameworks specified, so the startup/supportedRuntime must be enough. + + if (fUpdatedManifest) + { + hr = XmlSaveDocument(pixdManifest, wzConfigPath); + ExitOnFailure(hr, "Failed to save updated manifest over config file: %ls", wzConfigPath); + } + +LExit: + ReleaseRegKey(hkFramework); + ReleaseStr(sczFrameworkRegistryKey); + ReleaseStr(sczSupportedFrameworkVersion); + ReleaseObject(pNode); + ReleaseObject(pNodeList); + ReleaseObject(pixdManifest); + + XmlUninitialize(); + + return hr; +} + +// Fixes the supportedRuntime element if necessary. +static HRESULT UpdateSupportedRuntime( + __in IXMLDOMDocument* pixdManifest, + __in IXMLDOMNode* pixnSupportedFramework, + __out BOOL* pfUpdatedManifest + ) +{ + HRESULT hr = S_OK; + LPWSTR sczSupportedRuntimeVersion = NULL; + IXMLDOMNode* pixnStartup = NULL; + IXMLDOMNode* pixnSupportedRuntime = NULL; + + *pfUpdatedManifest = FALSE; + + // If the runtime version attribute is not specified, don't update the manifest. + hr = XmlGetAttributeEx(pixnSupportedFramework, L"runtimeVersion", &sczSupportedRuntimeVersion); + if (E_NOTFOUND == hr) + { + ExitFunction1(hr = S_OK); + } + ExitOnFailure(hr, "Failed to get supportedFramework/@runtimeVersion."); + + // Get the startup element. Fail if we can't find it since it'll be necessary to load the + // correct runtime. + hr = XmlSelectSingleNode(pixdManifest, L"/configuration/startup", &pixnStartup); + ExitOnFailure(hr, "Failed to get startup element."); + + if (S_FALSE == hr) + { + hr = E_NOTFOUND; + ExitOnRootFailure(hr, "Failed to find startup element in bootstrapper application config."); + } + + // Remove any pre-existing supported runtimes because they'll just get in the way and create our new one. + hr = XmlRemoveChildren(pixnStartup, L"supportedRuntime"); + ExitOnFailure(hr, "Failed to remove pre-existing supportedRuntime elements."); + + hr = XmlCreateChild(pixnStartup, L"supportedRuntime", &pixnSupportedRuntime); + ExitOnFailure(hr, "Failed to create supportedRuntime element."); + + hr = XmlSetAttribute(pixnSupportedRuntime, L"version", sczSupportedRuntimeVersion); + ExitOnFailure(hr, "Failed to set supportedRuntime/@version to '%ls'.", sczSupportedRuntimeVersion); + + *pfUpdatedManifest = TRUE; + +LExit: + ReleaseObject(pixnSupportedRuntime); + ReleaseObject(pixnStartup); + ReleaseStr(sczSupportedRuntimeVersion); + + return hr; +} + +// Gets the CLR host and caches it. +static HRESULT GetCLRHost( + __in LPCWSTR wzConfigPath, + __out ICorRuntimeHost **ppCLRHost + ) +{ + HRESULT hr = S_OK; + UINT uiMode = 0; + HMODULE hModule = NULL; + BOOL fFallbackToCorBindToCurrentRuntime = TRUE; + CLRCreateInstanceFnPtr pfnCLRCreateInstance = NULL; + ICLRMetaHostPolicy* pCLRMetaHostPolicy = NULL; + IStream* pCfgStream = NULL; + LPWSTR pwzVersion = NULL; + DWORD cchVersion = 0; + DWORD dwConfigFlags = 0; + ICLRRuntimeInfo* pCLRRuntimeInfo = NULL; + PFN_CORBINDTOCURRENTRUNTIME pfnCorBindToCurrentRuntime = NULL; + + // Always set the error mode because we will always restore it below. + uiMode = ::SetErrorMode(0); + + // Cache the CLR host to be shutdown later. This can occur on a different thread. + if (!vpCLRHost) + { + // Disable message boxes from being displayed on error and blocking execution. + ::SetErrorMode(uiMode | SEM_FAILCRITICALERRORS); + + hr = LoadSystemLibrary(L"mscoree.dll", &hModule); + ExitOnFailure(hr, "Failed to load mscoree.dll"); + + pfnCLRCreateInstance = reinterpret_cast(::GetProcAddress(hModule, "CLRCreateInstance")); + + if (pfnCLRCreateInstance) + { + hr = pfnCLRCreateInstance(CLSID_CLRMetaHostPolicy, IID_ICLRMetaHostPolicy, reinterpret_cast(&pCLRMetaHostPolicy)); + if (E_NOTIMPL != hr) + { + ExitOnRootFailure(hr, "Failed to create instance of ICLRMetaHostPolicy."); + + fFallbackToCorBindToCurrentRuntime = FALSE; + } + } + + if (fFallbackToCorBindToCurrentRuntime) + { + pfnCorBindToCurrentRuntime = reinterpret_cast(::GetProcAddress(hModule, "CorBindToCurrentRuntime")); + ExitOnNullWithLastError(pfnCorBindToCurrentRuntime, hr, "Failed to get procedure address for CorBindToCurrentRuntime."); + + hr = pfnCorBindToCurrentRuntime(wzConfigPath, CLSID_CorRuntimeHost, IID_ICorRuntimeHost, reinterpret_cast(&vpCLRHost)); + ExitOnRootFailure(hr, "Failed to create the CLR host using the application configuration file path."); + } + else + { + + hr = SHCreateStreamOnFileEx(wzConfigPath, STGM_READ | STGM_SHARE_DENY_WRITE, 0, FALSE, NULL, &pCfgStream); + ExitOnFailure(hr, "Failed to load bootstrapper config file from path: %ls", wzConfigPath); + + hr = pCLRMetaHostPolicy->GetRequestedRuntime(METAHOST_POLICY_HIGHCOMPAT, NULL, pCfgStream, NULL, &cchVersion, NULL, NULL, &dwConfigFlags, IID_ICLRRuntimeInfo, reinterpret_cast(&pCLRRuntimeInfo)); + ExitOnRootFailure(hr, "Failed to get the CLR runtime info using the application configuration file path."); + + // .NET 4 RTM had a bug where it wouldn't set pcchVersion if pwzVersion was NULL. + if (!cchVersion) + { + hr = pCLRRuntimeInfo->GetVersionString(NULL, &cchVersion); + if (HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) != hr) + { + ExitOnFailure(hr, "Failed to get the length of the CLR version string."); + } + } + + hr = StrAlloc(&pwzVersion, cchVersion); + ExitOnFailure(hr, "Failed to allocate the CLR version string."); + + hr = pCLRRuntimeInfo->GetVersionString(pwzVersion, &cchVersion); + ExitOnFailure(hr, "Failed to get the CLR version string."); + + if (CSTR_EQUAL == CompareString(LOCALE_NEUTRAL, 0, L"v4.0.30319", -1, pwzVersion, cchVersion)) + { + hr = VerifyNET4RuntimeIsSupported(); + ExitOnFailure(hr, "Found unsupported .NET 4 Runtime."); + } + + if (METAHOST_CONFIG_FLAGS_LEGACY_V2_ACTIVATION_POLICY_TRUE == (METAHOST_CONFIG_FLAGS_LEGACY_V2_ACTIVATION_POLICY_MASK & dwConfigFlags)) + { + hr = pCLRRuntimeInfo->BindAsLegacyV2Runtime(); + ExitOnRootFailure(hr, "Failed to bind as legacy V2 runtime."); + } + + hr = pCLRRuntimeInfo->GetInterface(CLSID_CorRuntimeHost, IID_ICorRuntimeHost, reinterpret_cast(&vpCLRHost)); + ExitOnRootFailure(hr, "Failed to get instance of ICorRuntimeHost."); + + // TODO: use ICLRRuntimeHost instead of ICorRuntimeHost on .NET 4 since the former is faster and the latter is deprecated + //hr = pCLRRuntimeInfo->GetInterface(CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, reinterpret_cast(&pCLRRuntimeHost)); + //ExitOnRootFailure(hr, "Failed to get instance of ICLRRuntimeHost."); + } + } + + vpCLRHost->AddRef(); + *ppCLRHost = vpCLRHost; + +LExit: + ReleaseStr(pwzVersion); + ReleaseNullObject(pCLRRuntimeInfo); + ReleaseNullObject(pCfgStream); + ReleaseNullObject(pCLRMetaHostPolicy); + + // Unload the module so it's not in use when we install .NET. + if (FAILED(hr)) + { + ::FreeLibrary(hModule); + } + + ::SetErrorMode(uiMode); // restore the previous error mode. + + return hr; +} + +// Creates the bootstrapper app and returns it for the engine. +static HRESULT CreateManagedBootstrapperApplication( + __in _AppDomain* pAppDomain, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + IBootstrapperApplicationFactory* pAppFactory = NULL; + IBootstrapperApplication* pApp = NULL; + + hr = CreateManagedBootstrapperApplicationFactory(pAppDomain, &pAppFactory); + ExitOnFailure(hr, "Failed to create the factory to create the bootstrapper application."); + + hr = pAppFactory->Create(pEngine, pArgs->pCommand, &pApp); + ExitOnFailure(hr, "Failed to create the bootstrapper application."); + + pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; + pResults->pvBootstrapperApplicationProcContext = pApp; + pApp = NULL; + +LExit: + ReleaseNullObject(pApp); + ReleaseNullObject(pAppFactory); + + return hr; +} + +// Creates the app factory to create the managed app in the default AppDomain. +static HRESULT CreateManagedBootstrapperApplicationFactory( + __in _AppDomain* pAppDomain, + __out IBootstrapperApplicationFactory** ppAppFactory + ) +{ + HRESULT hr = S_OK; + BSTR bstrAssemblyName = NULL; + BSTR bstrTypeName = NULL; + _ObjectHandle* pObj = NULL; + VARIANT vtBAFactory; + + ::VariantInit(&vtBAFactory); + + bstrAssemblyName = ::SysAllocString(MUX_ASSEMBLY_FULL_NAME); + ExitOnNull(bstrAssemblyName, hr, E_OUTOFMEMORY, "Failed to allocate the full assembly name for the bootstrapper application factory."); + + bstrTypeName = ::SysAllocString(L"WixToolset.Bootstrapper.BootstrapperApplicationFactory"); + ExitOnNull(bstrTypeName, hr, E_OUTOFMEMORY, "Failed to allocate the full type name for the BA factory."); + + hr = pAppDomain->CreateInstance(bstrAssemblyName, bstrTypeName, &pObj); + ExitOnRootFailure(hr, "Failed to create the BA factory object."); + + hr = pObj->Unwrap(&vtBAFactory); + ExitOnRootFailure(hr, "Failed to unwrap the BA factory object into the host domain."); + ExitOnNull(vtBAFactory.punkVal, hr, E_UNEXPECTED, "The variant did not contain the expected IUnknown pointer."); + + hr = vtBAFactory.punkVal->QueryInterface(__uuidof(IBootstrapperApplicationFactory), reinterpret_cast(ppAppFactory)); + ExitOnRootFailure(hr, "Failed to query for the bootstrapper app factory interface."); + +LExit: + ReleaseVariant(vtBAFactory); + ReleaseNullObject(pObj); + ReleaseBSTR(bstrTypeName); + ReleaseBSTR(bstrAssemblyName); + + return hr; +} + +static HRESULT CreatePrerequisiteBA( + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + LPWSTR sczMbapreqPath = NULL; + HMODULE hModule = NULL; + + hr = PathRelativeToModule(&sczMbapreqPath, L"mbapreq.dll", vhInstance); + ExitOnFailure(hr, "Failed to get path to pre-requisite BA."); + + hModule = ::LoadLibraryW(sczMbapreqPath); + ExitOnNullWithLastError(hModule, hr, "Failed to load pre-requisite BA DLL."); + + PFN_MBAPREQ_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = reinterpret_cast(::GetProcAddress(hModule, "MbaPrereqBootstrapperApplicationCreate")); + ExitOnNullWithLastError(pfnCreate, hr, "Failed to get MbaPrereqBootstrapperApplicationCreate entry-point from: %ls", sczMbapreqPath); + + hr = pfnCreate(hrHostInitialization, pEngine, pArgs, pResults); + ExitOnFailure(hr, "Failed to create prequisite bootstrapper app."); + + vhMbapreqModule = hModule; + hModule = NULL; + +LExit: + if (hModule) + { + ::FreeLibrary(hModule); + } + ReleaseStr(sczMbapreqPath); + + return hr; +} + +static HRESULT VerifyNET4RuntimeIsSupported( + ) +{ + HRESULT hr = S_OK; + OS_VERSION osv = OS_VERSION_UNKNOWN; + DWORD dwServicePack = 0; + HKEY hKey = NULL; + DWORD er = ERROR_SUCCESS; + DWORD dwRelease = 0; + DWORD cchRelease = sizeof(dwRelease); + + OsGetVersion(&osv, &dwServicePack); + if (OS_VERSION_WIN7 == osv && 0 == dwServicePack) + { + hr = RegOpen(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full", KEY_QUERY_VALUE, &hKey); + if (E_FILENOTFOUND == hr) + { + ExitFunction1(hr = S_OK); + } + ExitOnFailure(hr, "Failed to open registry key for .NET 4."); + + er = ::RegQueryValueExW(hKey, L"Release", NULL, NULL, reinterpret_cast(&dwRelease), &cchRelease); + if (ERROR_FILE_NOT_FOUND == er) + { + ExitFunction1(hr = S_OK); + } + ExitOnWin32Error(er, hr, "Failed to get Release value."); + + if (NET452_RELEASE <= dwRelease) + { + hr = E_MBAHOST_NET452_ON_WIN7RTM; + } + } + +LExit: + ReleaseRegKey(hKey); + + return hr; +} diff --git a/src/mbahost/host.def b/src/mbahost/host.def new file mode 100644 index 00000000..4488df94 --- /dev/null +++ b/src/mbahost/host.def @@ -0,0 +1,6 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +EXPORTS + BootstrapperApplicationCreate + BootstrapperApplicationDestroy diff --git a/src/mbahost/host.vcxproj b/src/mbahost/host.vcxproj new file mode 100644 index 00000000..a4c3ea16 --- /dev/null +++ b/src/mbahost/host.vcxproj @@ -0,0 +1,51 @@ + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + + {12C87C77-3547-44F8-8134-29BC915CB19D} + DynamicLibrary + Unicode + mbahost + host.def + + + + + + $(WixRoot)src\libs\dutil\inc;$(WixRoot)src\burn\inc;$(WixRoot)src\libs\balutil\inc;$(BaseIntermediateOutputPath)\core + dutil.lib;balutil.lib;shlwapi.lib + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mbahost/precomp.h b/src/mbahost/precomp.h new file mode 100644 index 00000000..d29a23f3 --- /dev/null +++ b/src/mbahost/precomp.h @@ -0,0 +1,25 @@ +#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 + +#import raw_interfaces_only rename("ReportEvent", "mscorlib_ReportEvent") + +#include +#include +#include +#include +#include +#include + +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" +#include "IBootstrapperApplicationFactory.h" + +#include "balutil.h" diff --git a/src/wixext/BalBinder.cs b/src/wixext/BalBinder.cs new file mode 100644 index 00000000..30f7ab44 --- /dev/null +++ b/src/wixext/BalBinder.cs @@ -0,0 +1,125 @@ +// Copyright (c) .NET 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.Extensions +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using WixToolset; + using WixToolset.Data; + using WixToolset.Data.Rows; + using WixToolset.Extensibility; + + public class BalBinder : BinderExtension + { + public override void Finish(Output output) + { + // Only process Bundles. + if (OutputType.Bundle != output.Type) + { + return; + } + + Table baTable = output.Tables["WixBootstrapperApplication"]; + Row baRow = baTable.Rows[0]; + string baId = (string)baRow[0]; + if (null == baId) + { + return; + } + + bool isStdBA = baId.StartsWith("WixStandardBootstrapperApplication"); + bool isMBA = baId.StartsWith("ManagedBootstrapperApplicationHost"); + + if (isStdBA || isMBA) + { + VerifyBAFunctions(output); + } + + if (isMBA) + { + VerifyPrereqPackages(output); + } + } + + private void VerifyBAFunctions(Output output) + { + Row baFunctionsRow = null; + Table baFunctionsTable = output.Tables["WixBalBAFunctions"]; + foreach (Row row in baFunctionsTable.RowsAs()) + { + if (null == baFunctionsRow) + { + baFunctionsRow = row; + } + else + { + this.Core.OnMessage(BalErrors.MultipleBAFunctions(row.SourceLineNumbers)); + } + } + + Table payloadPropertiesTable = output.Tables["WixPayloadProperties"]; + IEnumerable payloadPropertiesRows = payloadPropertiesTable.RowsAs(); + if (null == baFunctionsRow) + { + foreach (WixPayloadPropertiesRow payloadPropertiesRow in payloadPropertiesRows) + { + // TODO: Make core WiX canonicalize Name (this won't catch '.\bafunctions.dll'). + if (String.Equals(payloadPropertiesRow.Name, "bafunctions.dll", StringComparison.OrdinalIgnoreCase)) + { + this.Core.OnMessage(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesRow.SourceLineNumbers)); + } + } + } + else + { + // TODO: May need to revisit this depending on the outcome of #5273. + string payloadId = (string)baFunctionsRow[0]; + WixPayloadPropertiesRow bundlePayloadRow = payloadPropertiesRows.Single(x => payloadId == x.Id); + if (Compiler.BurnUXContainerId != bundlePayloadRow.Container) + { + this.Core.OnMessage(BalErrors.BAFunctionsPayloadRequiredInUXContainer(baFunctionsRow.SourceLineNumbers)); + } + } + } + + private void VerifyPrereqPackages(Output output) + { + Table prereqInfoTable = output.Tables["WixMbaPrereqInformation"]; + if (null == prereqInfoTable || prereqInfoTable.Rows.Count == 0) + { + this.Core.OnMessage(BalErrors.MissingPrereq()); + return; + } + + bool foundLicenseFile = false; + bool foundLicenseUrl = false; + + foreach (Row prereqInfoRow in prereqInfoTable.Rows) + { + if (null != prereqInfoRow[1]) + { + if (foundLicenseFile || foundLicenseUrl) + { + this.Core.OnMessage(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); + return; + } + + foundLicenseFile = true; + } + + if (null != prereqInfoRow[2]) + { + if (foundLicenseFile || foundLicenseUrl) + { + this.Core.OnMessage(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers)); + return; + } + + foundLicenseUrl = true; + } + } + } + } +} diff --git a/src/wixext/BalCompiler.cs b/src/wixext/BalCompiler.cs new file mode 100644 index 00000000..38ca9e3c --- /dev/null +++ b/src/wixext/BalCompiler.cs @@ -0,0 +1,562 @@ +// Copyright (c) .NET 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.Extensions +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Data.Rows; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset Bal Extension. + /// + public sealed class BalCompiler : CompilerExtension + { + private SourceLineNumber addedConditionLineNumber; + private Dictionary prereqInfoRows; + + /// + /// Instantiate a new BalCompiler. + /// + public BalCompiler() + { + this.addedConditionLineNumber = null; + prereqInfoRows = new Dictionary(); + this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/bal"; + } + + /// + /// Processes an element for the Compiler. + /// + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "Bundle": + case "Fragment": + switch (element.Name.LocalName) + { + case "Condition": + this.ParseConditionElement(element); + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + break; + case "BootstrapperApplicationRef": + switch (element.Name.LocalName) + { + case "WixStandardBootstrapperApplication": + this.ParseWixStandardBootstrapperApplicationElement(element); + break; + case "WixManagedBootstrapperApplicationHost": + this.ParseWixManagedBootstrapperApplicationHostElement(element); + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Processes an attribute for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Attribute to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary context) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); + Row row; + + switch (parentElement.Name.LocalName) + { + case "ExePackage": + case "MsiPackage": + case "MspPackage": + case "MsuPackage": + string packageId; + if (!context.TryGetValue("PackageId", out packageId) || String.IsNullOrEmpty(packageId)) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); + } + else + { + switch (attribute.Name.LocalName) + { + case "PrereqLicenseFile": + + if (!prereqInfoRows.TryGetValue(packageId, out row)) + { + // at the time the extension attribute is parsed, the compiler might not yet have + // parsed the PrereqPackage attribute, so we need to get it directly from the parent element. + XAttribute prereqPackage = parentElement.Attribute(this.Namespace + "PrereqPackage"); + + if (null != prereqPackage && YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) + { + row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); + row[0] = packageId; + + prereqInfoRows.Add(packageId, row); + } + else + { + this.Core.OnMessage(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile")); + break; + } + } + + if (null != row[2]) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseFile", "PrereqLicenseUrl")); + } + else + { + row[1] = this.Core.GetAttributeValue(sourceLineNumbers, attribute); + } + break; + case "PrereqLicenseUrl": + + if (!prereqInfoRows.TryGetValue(packageId, out row)) + { + // at the time the extension attribute is parsed, the compiler might not yet have + // parsed the PrereqPackage attribute, so we need to get it directly from the parent element. + XAttribute prereqPackage = parentElement.Attribute(this.Namespace + "PrereqPackage"); + + if (null != prereqPackage && YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, prereqPackage)) + { + row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); + row[0] = packageId; + + prereqInfoRows.Add(packageId, row); + } + else + { + this.Core.OnMessage(BalErrors.AttributeRequiresPrereqPackage(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl")); + break; + } + } + + if (null != row[1]) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttribute(sourceLineNumbers, parentElement.Name.LocalName, "PrereqLicenseUrl", "PrereqLicenseFile")); + } + else + { + row[2] = this.Core.GetAttributeValue(sourceLineNumbers, attribute); + } + break; + case "PrereqPackage": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) + { + if (!prereqInfoRows.TryGetValue(packageId, out row)) + { + row = this.Core.CreateRow(sourceLineNumbers, "WixMbaPrereqInformation"); + row[0] = packageId; + + prereqInfoRows.Add(packageId, row); + } + } + break; + default: + this.Core.UnexpectedAttribute(parentElement, attribute); + break; + } + } + break; + case "Payload": + string payloadId; + if (!context.TryGetValue("Id", out payloadId) || String.IsNullOrEmpty(payloadId)) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.Name.LocalName, "Id", attribute.Name.LocalName)); + } + else + { + switch (attribute.Name.LocalName) + { + case "BAFunctions": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) + { + row = this.Core.CreateRow(sourceLineNumbers, "WixBalBAFunctions"); + row[0] = payloadId; + } + break; + default: + this.Core.UnexpectedAttribute(parentElement, attribute); + break; + } + } + break; + case "Variable": + // at the time the extension attribute is parsed, the compiler might not yet have + // parsed the Name attribute, so we need to get it directly from the parent element. + XAttribute variableName = parentElement.Attribute("Name"); + if (null == variableName) + { + this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name")); + } + else + { + switch (attribute.Name.LocalName) + { + case "Overridable": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute)) + { + row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOverridableVariable"); + row[0] = variableName; + } + break; + default: + this.Core.UnexpectedAttribute(parentElement, attribute); + break; + } + } + break; + } + } + + /// + /// Parses a Condition element for Bundles. + /// + /// The element to parse. + private void ParseConditionElement(XElement node) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string condition = this.Core.GetConditionInnerText(node); // condition is the inner text of the element. + string message = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Message": + message = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + this.Core.ParseForExtensionElements(node); + + // Error check the values. + if (String.IsNullOrEmpty(condition)) + { + this.Core.OnMessage(WixErrors.ConditionExpected(sourceLineNumbers, node.Name.LocalName)); + } + + if (null == message) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Message")); + } + + if (!this.Core.EncounteredError) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "WixBalCondition"); + row[0] = condition; + row[1] = message; + + if (null == this.addedConditionLineNumber) + { + this.addedConditionLineNumber = sourceLineNumbers; + } + } + } + + /// + /// Parses a WixStandardBootstrapperApplication element for Bundles. + /// + /// The element to parse. + private void ParseWixStandardBootstrapperApplicationElement(XElement node) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string launchTarget = null; + string launchTargetElevatedId = null; + string launchArguments = null; + YesNoType launchHidden = YesNoType.NotSet; + string launchWorkingDir = null; + string licenseFile = null; + string licenseUrl = null; + string logoFile = null; + string logoSideFile = null; + string themeFile = null; + string localizationFile = null; + YesNoType suppressOptionsUI = YesNoType.NotSet; + YesNoType suppressDowngradeFailure = YesNoType.NotSet; + YesNoType suppressRepair = YesNoType.NotSet; + YesNoType showVersion = YesNoType.NotSet; + YesNoType supportCacheOnly = YesNoType.NotSet; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "LaunchTarget": + launchTarget = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LaunchTargetElevatedId": + launchTargetElevatedId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "LaunchArguments": + launchArguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LaunchHidden": + launchHidden = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "LaunchWorkingFolder": + launchWorkingDir = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LicenseFile": + licenseFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LicenseUrl": + licenseUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "LogoFile": + logoFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LogoSideFile": + logoSideFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ThemeFile": + themeFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LocalizationFile": + localizationFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SuppressOptionsUI": + suppressOptionsUI = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "SuppressDowngradeFailure": + suppressDowngradeFailure = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "SuppressRepair": + suppressRepair = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ShowVersion": + showVersion = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "SupportCacheOnly": + supportCacheOnly = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + this.Core.ParseForExtensionElements(node); + + if (String.IsNullOrEmpty(licenseFile) && null == licenseUrl) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true)); + } + + if (!this.Core.EncounteredError) + { + if (!String.IsNullOrEmpty(launchTarget)) + { + WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); + row.Id = "LaunchTarget"; + row.Value = launchTarget; + row.Type = "string"; + } + + if (!String.IsNullOrEmpty(launchTargetElevatedId)) + { + WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); + row.Id = "LaunchTargetElevatedId"; + row.Value = launchTargetElevatedId; + row.Type = "string"; + } + + if (!String.IsNullOrEmpty(launchArguments)) + { + WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); + row.Id = "LaunchArguments"; + row.Value = launchArguments; + row.Type = "string"; + } + + if (YesNoType.Yes == launchHidden) + { + WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixBundleVariable"); + row.Id = "LaunchHidden"; + row.Value = "yes"; + row.Type = "string"; + } + + + if (!String.IsNullOrEmpty(launchWorkingDir)) + { + WixBundleVariableRow row = (WixBundleVariableRow)this.Core.CreateRow(sourceLineNumbers, "Variable"); + row.Id = "LaunchWorkingFolder"; + row.Value = launchWorkingDir; + row.Type = "string"; + } + + if (!String.IsNullOrEmpty(licenseFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "WixStdbaLicenseRtf"; + wixVariableRow.Value = licenseFile; + } + + if (null != licenseUrl) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "WixStdbaLicenseUrl"; + wixVariableRow.Value = licenseUrl; + } + + if (!String.IsNullOrEmpty(logoFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "WixStdbaLogo"; + wixVariableRow.Value = logoFile; + } + + if (!String.IsNullOrEmpty(logoSideFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "WixStdbaLogoSide"; + wixVariableRow.Value = logoSideFile; + } + + if (!String.IsNullOrEmpty(themeFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "WixStdbaThemeXml"; + wixVariableRow.Value = themeFile; + } + + if (!String.IsNullOrEmpty(localizationFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "WixStdbaThemeWxl"; + wixVariableRow.Value = localizationFile; + } + + if (YesNoType.Yes == suppressOptionsUI || YesNoType.Yes == suppressDowngradeFailure || YesNoType.Yes == suppressRepair || YesNoType.Yes == showVersion || YesNoType.Yes == supportCacheOnly) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOptions"); + if (YesNoType.Yes == suppressOptionsUI) + { + row[0] = 1; + } + + if (YesNoType.Yes == suppressDowngradeFailure) + { + row[1] = 1; + } + + if (YesNoType.Yes == suppressRepair) + { + row[2] = 1; + } + + if (YesNoType.Yes == showVersion) + { + row[3] = 1; + } + + if (YesNoType.Yes == supportCacheOnly) + { + row[4] = 1; + } + } + } + } + + /// + /// Parses a WixManagedBootstrapperApplicationHost element for Bundles. + /// + /// The element to parse. + private void ParseWixManagedBootstrapperApplicationHostElement(XElement node) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string logoFile = null; + string themeFile = null; + string localizationFile = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "LogoFile": + logoFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ThemeFile": + themeFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "LocalizationFile": + localizationFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + this.Core.ParseForExtensionElements(node); + + if (!this.Core.EncounteredError) + { + if (!String.IsNullOrEmpty(logoFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "PreqbaLogo"; + wixVariableRow.Value = logoFile; + } + + if (!String.IsNullOrEmpty(themeFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "PreqbaThemeXml"; + wixVariableRow.Value = themeFile; + } + + if (!String.IsNullOrEmpty(localizationFile)) + { + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = "PreqbaThemeWxl"; + wixVariableRow.Value = localizationFile; + } + } + } + } +} diff --git a/src/wixext/BalExtensionData.cs b/src/wixext/BalExtensionData.cs new file mode 100644 index 00000000..7e8dea5b --- /dev/null +++ b/src/wixext/BalExtensionData.cs @@ -0,0 +1,55 @@ +// Copyright (c) .NET 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.Extensions +{ + using System; + using System.Reflection; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset Bal Extension. + /// + public sealed class BalExtensionData : ExtensionData + { + /// + /// Gets the optional table definitions for this extension. + /// + /// The optional table definitions for this extension. + public override TableDefinitionCollection TableDefinitions + { + get + { + return BalExtensionData.GetExtensionTableDefinitions(); + } + } + + /// + /// Gets the library associated with this extension. + /// + /// The table definitions to use while loading the library. + /// The loaded library. + public override Library GetLibrary(TableDefinitionCollection tableDefinitions) + { + return BalExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Internal mechanism to access the extension's table definitions. + /// + /// Extension's table definitions. + internal static TableDefinitionCollection GetExtensionTableDefinitions() + { + return ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); + } + + /// + /// Internal mechanism to access the extension's library. + /// + /// Extension's library. + internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) + { + return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.bal.wixlib", tableDefinitions); + } + } +} diff --git a/src/wixext/WixBalExtension.csproj b/src/wixext/WixBalExtension.csproj new file mode 100644 index 00000000..3e9d382e --- /dev/null +++ b/src/wixext/WixBalExtension.csproj @@ -0,0 +1,47 @@ + + + + + + + {BF720A63-9D7B-456E-B60C-8122852D9FED} + WixBalExtension + Library + WixToolset.Extensions + + + + + + + + $(RootNamespace).Data.Messages.resources + + + $(RootNamespace).Data.tables.xml + + + $(RootNamespace).Xsd.bal.xsd + PreserveNewest + + + WixToolset.Data.Serialize + WixToolset.Extensions.Serialize.Bal + + + Data\bal.wixlib + + + + + + + + + + + false + + + + diff --git a/src/wixext/bal.xsd b/src/wixext/bal.xsd new file mode 100644 index 00000000..73f10540 --- /dev/null +++ b/src/wixext/bal.xsd @@ -0,0 +1,266 @@ + + + + + + + + The source code schema for the WiX Toolset Burn User Experience Extension. + + + + + + + + + Conditions for a bundle. The condition is specified in the inner text of the element. + + + + + + + + + + + + The condition that must evaluate to true for the installation to continue. + + + + + + Set the value to the text to display when the condition fails and the installation must be terminated. + + + + + + + + + + + + Configures WixStandardBootstrapperApplication for a Bundle. + + + + + + + + + + If set, the success page will show a Launch button the user can use to launch the application being installed. + The string value can be formatted using Burn variables enclosed in brackets, + to refer to installation directories and so forth. + + + + + + + Id of the target ApprovedExeForElevation element. + If set with LaunchTarget, WixStdBA will launch the application through the Engine's LaunchApprovedExe method instead of through ShellExecute. + + + + + + + If set, WixStdBA will supply these arguments when launching the application specified by the LaunchTarget attribute. + The string value can be formatted using Burn variables enclosed in brackets, + to refer to installation directories and so forth. + + + + + + + If set to "yes", WixStdBA will launch the application specified by the LaunchTarget attribute with the SW_HIDE flag. + This attribute is ignored when the LaunchTargetElevatedId attribute is specified. + + + + + + + WixStdBA will use this working folder when launching the specified application. + The string value can be formatted using Burn variables enclosed in brackets, + to refer to installation directories and so forth. + This attribute is ignored when the LaunchTargetElevatedId attribute is specified. + + + + + + Source file of the RTF license file. Cannot be used simultaneously with LicenseUrl. + + + + + URL target of the license link. Cannot be used simultaneously with LicenseFile. This attribute can be empty to hide the license link completely. + + + + + Source file of the logo graphic. + + + + + Source file of the side logo graphic. + + + + + Source file of the theme XML. + + + + + Source file of the theme localization .wxl file. + + + + + If set to "yes", the Options button will not be shown and the user will not be able to choose an installation directory. + + + + + If set to "yes", attempting to installer a downgraded version of a bundle will be treated as a successful do-nothing operation. + The default behavior (or when explicitly set to "no") is to treat downgrade attempts as failures. + + + + + If set to "yes", the Repair button will not be shown in the maintenance-mode UI. + + + + + If set to "yes", the application version will be displayed on the UI. + + + + + If set to "yes", the bundle can be pre-cached using the /cache command line argument. + + + + + + + + + Configures the ManagedBootstrapperApplicationHost for a Bundle. + + + + + + + + + Source file of the logo graphic. + + + + + Source file of the theme XML. + + + + + Source file of the theme localization .wxl file. + + + + + + + + + When set to "yes", WixStdBA will load the DLL and work with it to handle BA messages. + + + + + + + + + + + When set to "yes", lets the user override the variable's default value by specifying another value on the command line, + in the form Variable=Value. Otherwise, WixStdBA won't overwrite the default value and will log + "Ignoring attempt to set non-overridable variable: 'BAR'." + + + + + + + + + + + Source file of the RTF license file. + There may only be one package in the bundle that has either the PrereqLicenseFile attribute or the PrereqLicenseUrl attribute. + + + + + + + + + + + + + + URL target of the license link. + There may only be one package in the bundle that has either the PrereqLicenseFile attribute or the PrereqLicenseUrl attribute. + + + + + + + + + + + + + + When set to "yes", the Prereq BA will plan the package to be installed if its InstallCondition is "true" or empty. + + + + + + + + + + + + + Values of this type will either be "yes" or "no". + + + + + + + diff --git a/src/wixext/messages.xml b/src/wixext/messages.xml new file mode 100644 index 00000000..9b11981d --- /dev/null +++ b/src/wixext/messages.xml @@ -0,0 +1,43 @@ + + + + + + + + + When the {0}/@{1} attribute is specified, the {0}/@PrereqPackage attribute must be set to "yes". + + + + + + + There must be at least one PrereqPackage when using the ManagedBootstrapperApplicationHost. + This is typically done by using the WixNetFxExtension and referencing one of the NetFxAsPrereq package groups. + + + + + There may only be one package in the bundle that has either the PrereqLicenseFile attribute or the PrereqLicenseUrl attribute. + + + + + WixStandardBootstrapperApplication doesn't support multiple BAFunctions DLLs. + + + + + The BAFunctions DLL Payload element must be located inside the BootstrapperApplication container. + + + + + + + WixStandardBootstrapperApplication doesn't automatically load BAFunctions.dll. Use the bal:BAFunctions attribute to indicate that it should be loaded. + + + + diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml new file mode 100644 index 00000000..18abf1d7 --- /dev/null +++ b/src/wixext/tables.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/BalExtension.wixproj b/src/wixlib/BalExtension.wixproj new file mode 100644 index 00000000..e2898e83 --- /dev/null +++ b/src/wixlib/BalExtension.wixproj @@ -0,0 +1,39 @@ + + + + + + + {3444D952-F21C-496F-AB6B-56435BFD0787} + bal + Library + true + true + en-us + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/BalExtension.wxs b/src/wixlib/BalExtension.wxs new file mode 100644 index 00000000..2da3d5b2 --- /dev/null +++ b/src/wixlib/BalExtension.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/Mba.wxs b/src/wixlib/Mba.wxs new file mode 100644 index 00000000..6f18bf51 --- /dev/null +++ b/src/wixlib/Mba.wxs @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/NetFx451AsPrereq.wxs b/src/wixlib/NetFx451AsPrereq.wxs new file mode 100644 index 00000000..67c05b05 --- /dev/null +++ b/src/wixlib/NetFx451AsPrereq.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + $(var.NetFx451WebId) + $(var.NetFx451EulaLink) + + + + + + + + + + + + + $(var.NetFx451RedistId) + $(var.NetFx451EulaLink) + + + + diff --git a/src/wixlib/NetFx452AsPrereq.wxs b/src/wixlib/NetFx452AsPrereq.wxs new file mode 100644 index 00000000..b41a9986 --- /dev/null +++ b/src/wixlib/NetFx452AsPrereq.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + $(var.NetFx452WebId) + $(var.NetFx452EulaLink) + + + + + + + + + + + + + $(var.NetFx452RedistId) + $(var.NetFx452EulaLink) + + + + diff --git a/src/wixlib/NetFx45AsPrereq.wxs b/src/wixlib/NetFx45AsPrereq.wxs new file mode 100644 index 00000000..b95fc8a4 --- /dev/null +++ b/src/wixlib/NetFx45AsPrereq.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + $(var.NetFx45WebId) + $(var.NetFx45EulaLink) + + + + + + + + + + + + + $(var.NetFx45RedistId) + $(var.NetFx45EulaLink) + + + + diff --git a/src/wixlib/NetFx461AsPrereq.wxs b/src/wixlib/NetFx461AsPrereq.wxs new file mode 100644 index 00000000..d6b24b43 --- /dev/null +++ b/src/wixlib/NetFx461AsPrereq.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + $(var.NetFx461WebId) + $(var.NetFx461EulaLink) + + + + + + + + + + + + + $(var.NetFx461RedistId) + $(var.NetFx461EulaLink) + + + + diff --git a/src/wixlib/NetFx462AsPrereq.wxs b/src/wixlib/NetFx462AsPrereq.wxs new file mode 100644 index 00000000..e6f6889a --- /dev/null +++ b/src/wixlib/NetFx462AsPrereq.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + $(var.NetFx462WebId) + $(var.NetFx462EulaLink) + + + + + + + + + + + + + $(var.NetFx462RedistId) + $(var.NetFx462EulaLink) + + + + diff --git a/src/wixlib/NetFx46AsPrereq.wxs b/src/wixlib/NetFx46AsPrereq.wxs new file mode 100644 index 00000000..52880022 --- /dev/null +++ b/src/wixlib/NetFx46AsPrereq.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + $(var.NetFx46WebId) + $(var.NetFx46EulaLink) + + + + + + + + + + + + + $(var.NetFx46RedistId) + $(var.NetFx46EulaLink) + + + + diff --git a/src/wixlib/NetFx4AsPrereq.wxs b/src/wixlib/NetFx4AsPrereq.wxs new file mode 100644 index 00000000..83fc8e35 --- /dev/null +++ b/src/wixlib/NetFx4AsPrereq.wxs @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + $(var.NetFx40WebId) + $(var.NetFx40EulaLink) + + + + + + + + + + + + + $(var.NetFx40RedistId) + $(var.NetFx40EulaLink) + + + + + + + + + + + + + $(var.NetFx40ClientWebId) + $(var.NetFx40EulaLink) + + + + + + + + + + + + + $(var.NetFx40ClientRedistId) + $(var.NetFx40EulaLink) + + + + + + + + + + + + + diff --git a/src/wixlib/wixstdba.wxs b/src/wixlib/wixstdba.wxs new file mode 100644 index 00000000..b0476fe2 --- /dev/null +++ b/src/wixlib/wixstdba.wxs @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + !(wix.WixStdbaLicenseRtfName=license.rtf) + + + + + + + + + + + + + + + + + !(wix.WixStdbaLicenseRtfName=license.rtf) + + + + + + + + + + + + + + + !(wix.WixStdbaLicenseUrl) + + + + + + + + + + + + + + + !(wix.WixStdbaLicenseUrl) + + + + + + + + + + + + + + + + !(wix.WixStdbaLicenseUrl) + + + + + + + + + + + + diff --git a/src/wixlib/wixstdba_platform.wxi b/src/wixlib/wixstdba_platform.wxi new file mode 100644 index 00000000..4076e30c --- /dev/null +++ b/src/wixlib/wixstdba_platform.wxi @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/wixstdba_x86.wxs b/src/wixlib/wixstdba_x86.wxs new file mode 100644 index 00000000..09a5080c --- /dev/null +++ b/src/wixlib/wixstdba_x86.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixstdba/Resources/1028/mbapreq.wxl b/src/wixstdba/Resources/1028/mbapreq.wxl new file mode 100644 index 00000000..abd35ac7 --- /dev/null +++ b/src/wixstdba/Resources/1028/mbapreq.wxl @@ -0,0 +1,27 @@ + + + + + + [WixBundleName] 安裝程式 + [WixBundleName] 安裝程式需要 Microsoft .NET Framework + 您確定要取消嗎? + 安裝程式說明 + /passive | /quiet - 顯示最基本的 UI 但不顯示提示,或者不顯示 UI 也 + 不顯示提示。預設會顯示 UI 和所有提示。 + +/norestart - 隱藏任何重新啟動嘗試。根據預設,UI 會在重新啟動之前提示。 +/log log.txt - 記錄至特定檔案。預設會在 %TEMP% 建立記錄檔。 + 關閉(&C) + 請按一下 「接受並安裝」5D; 按鈕,接受 Microsoft .NET Framework <a href="#">授權合約</a>。 + 接受並安裝(&A) + 拒絕(&D) + 安裝進度 + 正在處理: + 取消(&) + 安裝失敗 + 一或多個問題導致安裝失敗。請修正這些問題,然後再重試安裝。如需詳細資訊,請查看<a href="#">記錄檔</a>。 + 必須重新啟動電腦,才能完成軟體的復原。 + 重新啟動(&R) + 關閉(&C) + diff --git a/src/wixstdba/Resources/1029/mbapreq.wxl b/src/wixstdba/Resources/1029/mbapreq.wxl new file mode 100644 index 00000000..e28b4f74 --- /dev/null +++ b/src/wixstdba/Resources/1029/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + Instalace produktu [WixBundleName] + Pro instalaci produktu [WixBundleName] je vyžadováno rozhraní Microsoft .NET Framework. + Opravdu chcete akci zrušit? + Nápověda k instalaci + /passive | /quiet - Zobrazí minimální uživatelské rozhraní bez jakýchkoli + výzev, nebo nezobrazí žádné uživatelské rozhraní ani žádné výzvy. Ve výchozím + nastavení se jak uživatelské rozhraní, tak i všechny výzvy zobrazují. + +/norestart - Potlačí jakékoli pokusy o restartování. Ve výchozím nastavení + se v uživatelském rozhraní před restartováním zobrazí výzva. +/log log.txt - Nastaví, že se má zapisovat do konkrétního souboru protokolu. + Ve výchozím nastavení je soubor protokolu vytvořen v umístění %TEMP%. + &Zavřít + Kliknutím na tlačítko Přijmout a nainstalovat přijmete <a href="#">licenční podmínky</a> rozhraní Microsoft .NET Framework. + &Přijmout a instalovat + &Odmítnout + Průběh instalace + Probíhá zpracování: + &Storno + Instalace se nezdařila + Byly zjištěny problémy, kvůli kterým se instalaci nepodařilo dokončit. Odstraňte tyto problémy a potom instalaci opakujte. Další informace naleznete v <a href="#">souboru protokolu</a>. + Aby bylo možné zrušení instalace softwaru dokončit, je nutné počítač restartovat. + &Restartovat + &Zavřít + diff --git a/src/wixstdba/Resources/1030/mbapreq.wxl b/src/wixstdba/Resources/1030/mbapreq.wxl new file mode 100644 index 00000000..a531467a --- /dev/null +++ b/src/wixstdba/Resources/1030/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + Installation af [WixBundleName] + Microsoft .NET Framework skal være installeret i forbindelse med Installationen af [WixBundleName] + Er du sikker på, at du vil annullere? + Hjælp til installation + /passive | /quiet - viser en minimal brugergrænseflade uden prompter eller + viser ingen brugergrænseflade og ingen prompter. + Brugergrænsefladen og alle prompter vises som standard. + +/norestart - skjuler forsøg på genstart. Der vises som standard en + forespørgsel i brugergrænsefladen, før der genstartes. +/log log.txt - logfører til en bestemt fil. Der oprettes som standard en + logfil i %TEMP%. + &Luk + Klik på knappen "Acceptér og installér" for at acceptere <a href="#">licensvilkårene</a> for Microsoft .NET Framework. + &Acceptér og installér + &Afvis + Status for installation + Behandler: + &Annuller + Installationen blev ikke gennemført + Installationen blev ikke gennemført på grund af et eller flere problemer. Løs problemerne, og prøv derefter at installere igen. Se <a href="#">logfilen</a> for at få flere oplysninger. + Du skal genstarte computeren for at fuldføre annulleringen af opdateringen af softwaren. + &Genstart + &Luk + diff --git a/src/wixstdba/Resources/1031/mbapreq.wxl b/src/wixstdba/Resources/1031/mbapreq.wxl new file mode 100644 index 00000000..ff8111f9 --- /dev/null +++ b/src/wixstdba/Resources/1031/mbapreq.wxl @@ -0,0 +1,33 @@ + + + + + + + + [WixBundleName]-Setup + Für das [WixBundleName]-Setup ist Microsoft .NET Framework erforderlich. + Sind Sie sicher, dass Sie den Vorgang abbrechen möchten? + Setup-Hilfe + /passive | /quiet - zeigt eine minimale Benutzeroberfläche ohne + Eingabeaufforderungen oder keine Benutzeroberfläche und keine + Eingabeaufforderungen an. Standardmäßig werden die Benutzeroberfläche und + alle Eingabeaufforderungen angezeigt. + +/norestart - unterdrückt alle Neustartversuche. Standardmäßig fordert die + Benutzeroberfläche zum Bestätigen eines Neustarts auf. +/log log.txt - erstellt das Protokoll in einer bestimmten Datei. + Standardmäßig wird die Protokolldatei in "%TEMP%" erstellt. + &Schließen + Klicken Sie auf die Schaltfläche "Akzeptieren und installieren", um den Microsoft .NET Framework <a href="#">-Lizenzbedingungen</a> zuzustimmen. + &Akzeptieren und installieren + &Ablehnen + Setup-Status + Verarbeitung: + &Abbrechen + Setup-Fehler + Beim Setup ist aufgrund mindestens eines Problems ein Fehler aufgetreten. Beheben Sie die Probleme, und wiederholen Sie das Setup. Weitere Informationen finden Sie in der <a href="#">Protokolldatei</a>. + Sie müssen den Computer neu starten, um das Zurücksetzen der Software abzuschließen. + &Neu starten + &Schließen + diff --git a/src/wixstdba/Resources/1032/mbapreq.wxl b/src/wixstdba/Resources/1032/mbapreq.wxl new file mode 100644 index 00000000..bc3703a3 --- /dev/null +++ b/src/wixstdba/Resources/1032/mbapreq.wxl @@ -0,0 +1,32 @@ + + + + + + Εγκατάσταση του [WixBundleName] + Για την εγκατάσταση του [WixBundleName] απαιτείται το Microsoft .NET Framework + Είστε βέβαιοι ότι θέλετε να γίνει ακύρωση; + Βοήθεια για την εγκατάσταση + /passive | /quiet - εμφανίζει ελάχιστο περιεχόμενο του περιβάλλοντος εργασίας + χρήστη χωρίς μηνύματα ή δεν εμφανίζει περιβάλλον εργασίας χρήστη και + μηνύματα. Από προεπιλογή, εμφανίζονται όλα τα μηνύματα και το περιβάλλον + εργασίας χρήστη. + +/norestart - αποκρύπτει οποιεσδήποτε προσπάθειες για επανεκκίνηση. Από + προεπιλογή, το περιβάλλον εργασίας χρήστη θα εμφανίσει μήνυμα πριν από την + επανεκκίνηση. +/log log.txt - πραγματοποιεί καταγραφή σε ένα συγκεκριμένο αρχείο. Από + προεπιλογή, δημιουργείται ένα αρχείο καταγραφής στο %TEMP%. + &Κλείσιμο + Κάντε κλικ στο κουμπί "Αποδοχή και εγκατάσταση" για να αποδεχτείτε τους <a href="#">όρους της άδειας χρήσης</a> του Microsoft .NET Framework. + &Αποδοχή και εγκατάσταση + &Απόρριψη + Πρόοδος εγκατάστασης + Επεξεργασία: + &Άκυρο + Αποτυχία εγκατάστασης + Ένα ή περισσότερα προβλήματα προκάλεσαν την αποτυχία της εγκατάστασης. Διορθώστε τα προβλήματα και μετά επαναλάβετε την εγκατάσταση. Για περισσότερες πληροφορίες, ανατρέξτε στο <a href="#">αρχείο καταγραφής</a>. + Για να ολοκληρωθεί η επαναφορά του λογισμικού, πρέπει να κάνετε επανεκκίνηση του υπολογιστή. + &Επανεκκίνηση + &Κλείσιμο + diff --git a/src/wixstdba/Resources/1035/mbapreq.wxl b/src/wixstdba/Resources/1035/mbapreq.wxl new file mode 100644 index 00000000..859e5b23 --- /dev/null +++ b/src/wixstdba/Resources/1035/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] -asennus + Microsoft .NET Framework tarvitaan [WixBundleName] -asennusta varten + Haluatko varmasti peruuttaa? + Asennusohjelman ohje + /passive | /quiet - näyttää mahdollisimman vähän käyttöliittymästä; ei + kehotteita tai ei käyttöliittymää ja kehotteita. Oletusarvoisesti + käyttöliittymä ja kaikki kehotteet näytetään. + +/norestart - estää uudelleenkäynnistysyritykset. Oletusarvoisesti + käyttöliittymä kysyy ennen uudelleenkäynnistystä. +/log loki.txt - kirjaa lokitiedot erityiseen tiedostoon. Oletusarvoisesti + lokitiedosto luodaan %TEMP%-kansioon. + &Sulje + Hyväksy Microsoft .NET Framework -ohjelman <a href="#">käyttöoikeusehdot</a> valitsemalla Hyväksy ja asenna. + &Hyväksy ja asenna + &Hylkää + Asennuksen edistyminen + Käsitellään: + &Peruuta + Asennus epäonnistui + Asennus epäonnistui yhdestä tai useammasta syystä. Korjaa ongelmat ja yritä suorittaa asennus sitten uudelleen. Lisätietoja on <a href="#">lokitiedostossa</a>. + Tietokone täytyy käynnistää uudelleen ohjelmiston palautuksen viimeistelemiseksi. + &Käynnistä uudelleen + &Sulje + diff --git a/src/wixstdba/Resources/1036/mbapreq.wxl b/src/wixstdba/Resources/1036/mbapreq.wxl new file mode 100644 index 00000000..f67dfa8e --- /dev/null +++ b/src/wixstdba/Resources/1036/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + Installation de [WixBundleName] + Microsoft .NET Framework requis pour l'installation de [WixBundleName] + Êtes-vous sûr de vouloir annuler ? + Aide de l'installation + /passive | /quiet - affiche une interface minimale sans invites ou n'affiche + aucune interface ni aucune invite. Par défaut, l'interface et toutes les + invites sont affichées. + +/norestart - annule toute tentative de redémarrage. Par défaut, l'interface + affiche une invite avant de redémarrer. +/log journal.txt - consigne les entrées de journal dans un fichier spécifique. + Par défaut, un fichier journal est créé dans %TEMP%. + &Fermer + Cliquez sur le bouton « Accepter et installer » pour accepter les <a href="#">termes du contrat de licence</a> Microsoft .NET Framework. + &Accepter et installer + &Refuser + Progression de l'installation + Traitement en cours : + &Annuler + L'installation a échoué + L'installation a échoué pour une ou plusieurs raisons. Corrigez les problèmes et recommencez l'installation. Pour plus d'informations, consultez le <a href="#">fichier journal</a>. + Vous devez redémarrer votre ordinateur pour effectuer la restauration du logiciel. + &Redémarrer + &Fermer + diff --git a/src/wixstdba/Resources/1038/mbapreq.wxl b/src/wixstdba/Resources/1038/mbapreq.wxl new file mode 100644 index 00000000..6a4b109d --- /dev/null +++ b/src/wixstdba/Resources/1038/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] telepítő + A(z) [WixBundleName] telepítéséhez Microsoft .NET-keretrendszer szükséges + Biztosan megszakítja? + A telepítő súgója + /passive | /quiet - Minimális felhasználói felület megjelenítése kérdések + nélkül, illetve felhasználói felület és kérdések megjelenítése nélküli + telepítés. Alapesetben a felhasználói felület és minden kérdés megjelenik. + +/norestart - Az újraindítási kérések elrejtése. Alapesetben a felhasználói + felületen megjelennek az újraindítási kérések. +/log naplo.txt - Naplózás a megadott fájlba. Alapesetben a naplófájl a %TEMP% + könyvtárban jön létre. + &Bezárás + A Microsoft .NET-keretrendszer <a href="#">licencszerződésének</a> elfogadásához kattintson az „Elfogadás és telepítés” gombra. + &Elfogadás és telepítés + &Elutasítás + Telepítési folyamat + Feldolgozás: + &Mégse + A telepítés nem sikerült + Legalább egy olyan hiba lépett fel, amely a telepítés meghiúsulását okozta. Hárítsa el a hibákat, majd futtassa újra a telepítőt. További információt a <a href="#">naplófájlban </a> talál. + A szoftver visszaállításának befejezéséhez újra kell indítania a számítógépet. + &Újraindítás + &Bezárás + diff --git a/src/wixstdba/Resources/1040/mbapreq.wxl b/src/wixstdba/Resources/1040/mbapreq.wxl new file mode 100644 index 00000000..f57d58e5 --- /dev/null +++ b/src/wixstdba/Resources/1040/mbapreq.wxl @@ -0,0 +1,31 @@ + + + + + + Installazione di [WixBundleName] + Microsoft .NET Framework necessario per l'installazione di [WixBundleName] + Annullare? + Guida dell'installazione + /passive | /quiet - visualizza l'interfaccia utente minima senza istruzioni + oppure non visualizza né l'interfaccia utente né le istruzioni. Per + impostazione predefinita vengono visualizzate interfaccia utente e + istruzioni. + +/norestart - elimina eventuali tentativi di riavvio. Per impostazione + predefinita l'interfaccia utente chiede istruzioni prima del riavvio. +/log log.txt - registra in un file specifico. Per impostazione predefinita un + file di log viene creato in %TEMP%. + &Chiudi + Fare clic sul pulsante "Accetta e installa" per accettare le <a href="#">condizioni di licenza</a> di Microsoft .NET Framework. + &Accetta e installa + &Rifiuta + Stato installazione + Elaborazione in corso: + &Annulla + Installazione non riuscita + L'installazione non è riuscita a causa di uno o più problemi. Risolvere i problemi e provare di nuovo l'installazione. Per ulteriori informazioni vedere il <a href="#">file di log</a>. + È necessario riavviare il computer per completare il rollback del software. + &Riavvia + &Chiudi + diff --git a/src/wixstdba/Resources/1041/mbapreq.wxl b/src/wixstdba/Resources/1041/mbapreq.wxl new file mode 100644 index 00000000..3fe7b9b3 --- /dev/null +++ b/src/wixstdba/Resources/1041/mbapreq.wxl @@ -0,0 +1,27 @@ + + + + + + [WixBundleName] セットアップ + [WixBundleName] セットアップには Microsoft .NET Framework が必要です + 取り消しますか? + セットアップのヘルプ + /passive | /quiet - 最小の UI だけを表示してプロンプトは表示しないか、UI + もプロンプトも表示しません。 既定では、UI とすべてのプロンプトが表示されます。 + +/norestart - 再起動の試みをすべて抑制します。既定では、再起動の前に UI によりプロンプトが表示されます。 +/log log.txt - 特定のファイルにログを記録します。既定では、%TEMP% にログ ファイルが作成されます。 + 閉じる(&C) + Microsoft .NET Framework の<a href="#">ライセンス条項</a>に同意する場合は、[同意してインストール]5D; ボタンをクリックします。 + 同意してインストール(&A) + 同意しない(&) + セットアップの進行状況 + 処理中: + キャンセル(&C) + セットアップに失敗しました + 1 つ以上の問題が原因でセットアップに失敗しました。問題を解決してからセットアップをやり直してください。詳細については、<a href="#">ログ ファイル</a>を参照してください。 + ソフトウェアのロールバックを完了するには、コンピューターを再起動する必要があります。 + 再起動(&R) + 閉じる(&C) + diff --git a/src/wixstdba/Resources/1042/mbapreq.wxl b/src/wixstdba/Resources/1042/mbapreq.wxl new file mode 100644 index 00000000..0f53dcc3 --- /dev/null +++ b/src/wixstdba/Resources/1042/mbapreq.wxl @@ -0,0 +1,27 @@ + + + + + + [WixBundleName] 설치 + [WixBundleName] 설치에 필요한 Microsoft .NET Framework + 취소하시겠습니까? + 설치 도움말 + /passive | /quiet - 메시지 없이 최소 UI를 표시하거나 UI와 메시지를 전혀 + 표시하지 않습니다. 기본적으로 UI 및 모든 메시지는 표시됩니다. + +/norestart - 다시 시작하려는 시도를 무시합니다. 기본적으로 UI는 다시 시작하기 전에 메시지를 표시합니다. +/log log.txt - 특정 파일에 기록합니다. 기본적으로 로그 파일이 %TEMP%에 생성됩니다. + 닫기(&C) + Microsoft .NET Framework <a href="#">사용 조건</a>에 동의하려면 "동의 및 설치"를 클릭하십시오. + 동의 및 설치(&A) + 동의 안 함(&D) + 설치 진행률 + 처리 중: + 취소(&C) + 설치 실패 + 하나 이상의 문제로 인해 설치에 실패했습니다. 문제를 수정하고 설치를 다시 시도하십시오. 자세한 내용은 <a href="#">로그 파일</a>을 참조하십시오. + 소프트웨어의 롤백을 완료하려면 컴퓨터를 다시 시작해야 합니다. + 다시 시작(&R) + 닫기(&C) + diff --git a/src/wixstdba/Resources/1043/mbapreq.wxl b/src/wixstdba/Resources/1043/mbapreq.wxl new file mode 100644 index 00000000..f4a2c78c --- /dev/null +++ b/src/wixstdba/Resources/1043/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] Installatie + Microsoft .NET Framework is vereist voor installatie [WixBundleName] + Weet u zeker dat u de installatie wilt annuleren? + Help bij Setup + /passive | /quiet - geeft een minimale gebruikersinterface weer zonder prompts + of geeft geen gebruikersinterface en geen prompts weer. Gebruikersinterface + en alle prompts worden standaard weergegeven. + +/norestart - pogingen tot opnieuw opstarten onderdrukken. + Gebruikersinterface vraagt standaard alvorens opnieuw op te starten. +/log log.txt - registreert gegevens in een specifiek bestand. Een logbestand + wordt standaard in %TEMP% gemaakt. + &Sluiten + Klik op de knop 'Accepteren en installeren' om de <a href="#">licentievoorwaarden</a> van het Microsoft .NET Framework te accepteren. + &Accepteren en installeren + &Weigeren + Voortgang van de installatie + Verwerken: + &Annuleren + Installatie mislukt + Er zijn een of meer fouten opgetreden waardoor de installatie is mislukt. Corrigeer de problemen en voer Setup opnieuw uit. Raadpleeg het <a href="#">log boekbestand</a> voor meer informatie. + U moet uw computer opnieuw opstarten om het terugdraaien van de software te voltooien. + &Opnieuw opstarten + &Sluiten + diff --git a/src/wixstdba/Resources/1044/mbapreq.wxl b/src/wixstdba/Resources/1044/mbapreq.wxl new file mode 100644 index 00000000..da5c8283 --- /dev/null +++ b/src/wixstdba/Resources/1044/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] Installasjonsprogram + Microsoft .NET Framework kreves for [WixBundleName]-installasjon + Er du sikker på at du vil avbryte? + Installasjonshjelp + /passive | /quiet - viser minimalt brukergrensesnitt uten ledetekster, eller + ikke noe brukergrensesnitt og ingen ledetekster. Som standard vises + brukergrensesnitt og alle ledetekster. + +/norestart - undertrykker alle forsøk på omstart. Som standard spør + brukergrensesnittet før omstart. +/log log.txt - skriver logg til en bestemt fil. Som standard opprettes en + loggfil i %TEMP%. + &Lukk + Klikk Godta og installer for å godta<a href="#">lisensvilkårene</a> for Microsoft .NET Framework. + &Godta og installer + &Avslå + Fremdrift for installasjon + Behandler: + &Avbryt + Installasjon mislyktes + Ett eller flere problemer var årsak til at installasjonen mislyktes. Løs problemene, og installer på nytt. Du finner flere opplysninger i <a href="#">loggfilen</a>. + Du må starte datamaskinen på nytt for å fullføre tilbakerullingen av programvaren. + &Start på nytt + &Lukk + diff --git a/src/wixstdba/Resources/1045/mbapreq.wxl b/src/wixstdba/Resources/1045/mbapreq.wxl new file mode 100644 index 00000000..7aca87c2 --- /dev/null +++ b/src/wixstdba/Resources/1045/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + Instalator programu [WixBundleName] + Do zainstalowania programu [WixBundleName] jest wymagany program Microsoft .NET Framework + Czy na pewno chcesz anulować? + Pomoc instalatora + /passive | /quiet - wyświetla minimalny interfejs użytkownika bez monitów + lub nie wyświetla interfejsu użytkownika ani monitów. Domyślnie jest + wyświetlany interfejs użytkownika i wszystkie monity. + +/norestart - pomija wszelkie próby ponownego uruchomienia. Domyślnie + interfejs użytkownika będzie wyświetlał monit przed ponownym uruchomieniem. +/log log.txt - zapisuje wpisy dziennika do określonego pliku. + Domyślnie plik dziennika jest tworzony w folderze %TEMP%. + &Zamknij + Kliknij przycisk Zaakceptuj i zainstaluj, aby zaakceptować <a href="#">warunki licencji</a> programu Microsoft .NET Framework. + &Zaakceptuj i zainstaluj + &Odrzuć + Postęp instalacji + Trwa przetwarzanie: + &Anuluj + Instalacja nie powiodła się + Co najmniej jeden problem spowodował niepowodzenie instalacji. Usuń problemy, a następnie ponów próbę instalacji. Aby uzyskać więcej informacji można znaleźć w <a href="#">pliku dziennika</a>. + Aby zakończyć wycofywanie oprogramowania, musisz ponownie uruchomić komputer. + &Uruchom ponownie + &Zamknij + diff --git a/src/wixstdba/Resources/1046/mbapreq.wxl b/src/wixstdba/Resources/1046/mbapreq.wxl new file mode 100644 index 00000000..be185502 --- /dev/null +++ b/src/wixstdba/Resources/1046/mbapreq.wxl @@ -0,0 +1,29 @@ + + + + + + [WixBundleName] Instalação + Microsoft .NET Framework é necessário para instalação do [WixBundleName] + Tem certeza de que deseja cancelar? + Ajuda da Instalação + /passive | /quiet - exibe UI mínima sem avisos ou exibe sem UI e + sem avisos. Por padrão a UI e todos avisos são exibidos. + +/norestart - suprime qualquer tentativa de reinicialização. Por padrão a UI + irá solicitar antes de reiniciar. +/log log.txt - logs para um arquivo específico. Por padrão um arquivo de log é + criado em %TEMP%. + &Fechar + Clique o botão "Aceitar e Instalar" para aceitar os termos de licença do Microsoft .NET Framework <a href="#"></a>. + &Aceitar e Instalar + &Recusar + Progresso da Instalação + Processando: + &Cancelar + Falha na Instalação + Um ou mais problemas causaram falha na instalação. Corrija os problemas e tente a instalação novamente. Para mais informações consulte o <a href="#">arquivo de log</a>. + Você deve reiniciar o computador para completar a reversão do software. + &Reiniciar + &Fechar + diff --git a/src/wixstdba/Resources/1049/mbapreq.wxl b/src/wixstdba/Resources/1049/mbapreq.wxl new file mode 100644 index 00000000..a1aec7ed --- /dev/null +++ b/src/wixstdba/Resources/1049/mbapreq.wxl @@ -0,0 +1,29 @@ + + + + + + Установка [WixBundleName] + Для установки [WixBundleName] требуется Microsoft .NET Framework + Вы действительно хотите отменить операцию? + Справка по установке + /passive | /quiet - отображение минимального ИП без запросов или работа без ИП + и беззапросов. По умолчанию отображаются ИП и все запросы. + +/norestart - отключение всех попыток перезагрузки. По умолчанию в ИП перед + перезагрузкой отображается запрос. +/log log.txt - запись журнала в указанный файл. По умолчанию файл журнала + создается в папке %TEMP%. + &Закрыть + Нажмите кнопку "Принять и установить", чтобы принять <a href="#">условия лицензии</a> Microsoft .NET Framework. + &Принять и установить + &Отклонить + Выполнение установки + Обработка: + &Отмена + Сбой установки + Не удалось выполнить установку из-за одной или нескольких проблем. Устраните эти проблемы, а затем снова запустите программу установки. Дополнительные сведения см. в <a href="#">файле журнала</a>. + Необходимо перезагрузить компьютер, чтобы завершить откат программного обеспечения. + &Перезагрузить + &Закрыть + diff --git a/src/wixstdba/Resources/1051/mbapreq.wxl b/src/wixstdba/Resources/1051/mbapreq.wxl new file mode 100644 index 00000000..9f0b4711 --- /dev/null +++ b/src/wixstdba/Resources/1051/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] – inštalácia + Na inštaláciu aplikácie [WixBundleName] sa vyžaduje súčasť Microsoft .NET Framework + Naozaj chcete zrušiť operáciu? + Pomocník pre inštaláciu + /passive | /quiet – zobrazí minimálne používateľské rozhranie bez výziev alebo + nezobrazí žiadne používateľské rozhranie ani výzvy. Predvolene sa + zobrazuje používateľské rozhranie aj všetky výzvy. + +/norestart – zruší všetky pokusy o reštart. Používateľské rozhranie + predvolene zobrazí pred reštartom výzvu. +/log log.txt – urobí záznam do určeného súboru. Súbor denníka sa predvolene + vytvorí v priečinku %TEMP%. + &Zavrieť + Kliknutím na tlačidlo Súhlasiť a inštalovať vyjadrite svoj súhlas s <a href="#">licenčnými podmienkami</a> súčasti Microsoft .NET Framework. + &Súhlasiť a inštalovať + &Odmietnuť + Priebeh inštalácie + Spracúva sa: + &Zrušiť + Inštalácia zlyhala + Inštalácia zlyhala pre jednu alebo viac príčin. Odstráňte problémy a skúste znova spustiť inštaláciu. Ďalšie informácie nájdete v <a href="#">súbore denníka</a>. + Dokončenie všetkých zmien softvéru vyžaduje reštart počítača. + &Reštartovať + &Zavrieť + diff --git a/src/wixstdba/Resources/1053/mbapreq.wxl b/src/wixstdba/Resources/1053/mbapreq.wxl new file mode 100644 index 00000000..72961409 --- /dev/null +++ b/src/wixstdba/Resources/1053/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName]-installation + Microsoft .NET Framework krävs för installation av [WixBundleName] + Vill du avbryta? + Installationshjälp + /passive | /quiet - visar ett minimalt användargränssnitt utan prompter, + alternativt inget användargränssnitt och inga prompter. Som standard visas + användargränssnitt och samtliga prompter. + +/norestart - hejdar omstart. Som standard visar användargränssnittet en + prompt före omstart. +/log log.txt - skapar logg till en specifik fil. Som standard skapas loggfilen + i %TEMP%. + &Stäng + Klicka på knappen "Godkänn och installera" för att godkänna <a href="#">licensvillkoren</a> för Microsoft .NET Framework. + &Godkänn och installera + &Avbryt + Installationsförlopp + Bearbetar: + &Avbryt + Installationen misslyckades + Installationen misslyckades på grund av ett eller flera problem. Åtgärda problemen och försök igen. Se <a href="#">loggfilen</a> för mer information. + Starta om datorn för att återställa programmet. + &Starta om + &Stäng + diff --git a/src/wixstdba/Resources/1055/mbapreq.wxl b/src/wixstdba/Resources/1055/mbapreq.wxl new file mode 100644 index 00000000..ee52da98 --- /dev/null +++ b/src/wixstdba/Resources/1055/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] Kurulumu + [WixBundleName] kurulumu için Microsoft .NET Framework gerekir + İptal etmek istediğinizden emin misiniz? + Kurulum Yardımı + /passive | /quiet - komut istemi olmayan olabildiğince küçük bir UI + görüntüler veya komut istemi ve UI görüntülemez. Varsayılan olarak UI + ve tüm komut istemleri görüntülenir. + +/norestart - yeniden başlatma denemelerini engeller. Varsayılan + olarak UI yeniden başlatmadan önce komut isteyecektir. +/log log.txt - belirli bir dosyayı günlük dosyası olarak kullanır. + Varsayılan olarak %TEMP% konumunda bir günlük dosyası oluşturulur. + &Kapat + Microsoft .NET Framework <a href="#">lisans şartlarını</a> kabul etmek için "Kabul Et ve Yükle" düğmesini tıklatın. + &Kabul Et ve Yükle + &Reddet + Kurulum İlerleme Durumu + İşleniyor: + &İptal + Kurulum Başarısız + Bir veya daha fazla sorun kurulumun başarısız olmasına neden oldu. Lütfen sorunları çözün ve kurulumu yeniden deneyin. Daha fazla bilgi için <a href="#">günlük dosyasına</a> bakın. + Yazılım geri alma işlemini tamamlamak için bilgisayarınızı yeniden başlatmanız gerekir. + &Yeniden Başlat + &Kapat + diff --git a/src/wixstdba/Resources/1060/mbapreq.wxl b/src/wixstdba/Resources/1060/mbapreq.wxl new file mode 100644 index 00000000..f3b4bfe5 --- /dev/null +++ b/src/wixstdba/Resources/1060/mbapreq.wxl @@ -0,0 +1,30 @@ + + + + + + [WixBundleName] Namestitev + Microsoft .NET Framework, potreben za namestitev paketa [WixBundleName] + Ali ste prepričani, da želite preklicati? + Pomoč za namestitev + /passive | /quiet - prikaže minimalni uporabniški vmesnik brez pozivov ali ne prikaže + uporabniškega vmesnika in pozivov. Privzeto so prikazani uporabniški vmesnik in + vsi pozivi. + +/norestart - skrije vse možnosti za vnovicni zagon. Privzeto uporabniški vmesnik + prikaže poziv pred ponovnim zagonom. +/log log.txt - beleži vnose v dnevnik v doloceno datoteko. Privzeto je datoteko + ustvarjena v mapi %TEMP%. + &Zapri + Kliknite »Sprejmi in namesti« in sprejmite <a href="#">licenčne pogoje</a> za Microsoft .NET Framework. + &Sprejmi in namesti + &Zavrni + Potek namestitve + Obdelovanje: + &Prekliči + Namestitev ni uspela + Namestitev ni uspela zaradi ene ali več težav. Odpravite težave in ponovno zaženite namestitev. Za več informacij glejte <a href="#">dnevniško datoteko</a>. + Za povrnitev prejšnjega stanja programske opreme morate ponovno zagnati računalnik. + &Ponovni zagon + &Zapri + diff --git a/src/wixstdba/Resources/2052/mbapreq.wxl b/src/wixstdba/Resources/2052/mbapreq.wxl new file mode 100644 index 00000000..63cdb418 --- /dev/null +++ b/src/wixstdba/Resources/2052/mbapreq.wxl @@ -0,0 +1,27 @@ + + + + + + [WixBundleName] 安装 + [WixBundleName] 安装需要 Microsoft .NET Framework + 是否确实要取消? + 安装程序帮助 + /passive | /quiet - 显示最小的 UI 且无提示,或者不显示 UI 且 + 无提示。默认情况下显示 UI 和所有提示。 + +/norestart - 隐藏任何重启提示。默认情况下 UI 会在重启前提示。 +/log log.txt - 记录到特定文件。默认情况下在 %TEMP% 中创建日志文件。 + 关闭(&C) + 单击“接受并安装”按钮以接受 Microsoft .NET Framework <a href="#">许可证条款</a>。 + 接受并安装(&A) + 拒绝(&D) + 安装进度 + 正在处理: + 取消(&C) + 安装失败 + 一个或多个问题导致安装失败。请解决问题,然后重新尝试安装。有关详情,请查看<a href="#">日志文件</a>。 + 必须重启计算机才能完成软件的回滚。 + 重启(&R) + 关闭(&C) + diff --git a/src/wixstdba/Resources/2070/mbapreq.wxl b/src/wixstdba/Resources/2070/mbapreq.wxl new file mode 100644 index 00000000..6a49ca31 --- /dev/null +++ b/src/wixstdba/Resources/2070/mbapreq.wxl @@ -0,0 +1,29 @@ + + + + + + Configuração do [WixBundleName] + O Microsoft .NET Framework é necessário para a configuração do [WixBundleName] + Tem a certeza de que pretende cancelar? + Ajuda da Configuração + /passive | /quiet - apresenta IU mínima sem mensagens ou não apresenta IU nem + mensagens. Por predefinição, são apresentadas a IU e todas as mensagens. + +/norestart - suprimir qualquer tentativa de reinício. Por predefinição, a IU + avisará antes de reiniciar. +/log log.txt - regista num ficheiro específico. Por predefinição, é criado um + ficheiro de registo em %TEMP%. + &Fechar + Clique no botão "Aceitar e Instalar" para aceitar os <a href="#">termos de licenciamento</a> do Microsoft .NET Framework. + &Aceitar e Instalar + &Recusar + Progresso da Configuração + A processar: + &Cancelar + Falha da Configuração + Um ou mais problemas provocaram a falha da configuração. Corrija os problemas e repita a configuração. Para mais informações, consulte o <a href="#">ficheiro de registo</a>. + Tem de reiniciar o computador para concluir a reversão do software. + &Reiniciar + &Fechar + diff --git a/src/wixstdba/Resources/3082/mbapreq.wxl b/src/wixstdba/Resources/3082/mbapreq.wxl new file mode 100644 index 00000000..0290624c --- /dev/null +++ b/src/wixstdba/Resources/3082/mbapreq.wxl @@ -0,0 +1,31 @@ + + + + + + Instalación de [WixBundleName] + La instalación de [WixBundleName] requiere Microsoft .NET Framework + ¿Está seguro de que desea cancelar? + Ayuda del programa de instalación + /passive | /quiet - muestra una interfaz de usuario mínima y no realiza + preguntas, o bien no muestra interfaz de usuario y no realiza preguntas. + De manera predeterminada se muestra la interfaz de usuario completa y se + realizan todas las preguntas necesarias. + +/norestart - suprime cualquier intento de reinicio. De manera predeterminada, + la interfaz de usuario preguntará si se desea reiniciar. +/log log.txt - registra los datos de instalación en un archivo específico. + De manera predeterminada se crea un archivo de registro en %TEMP%. + &Cerrar + Haga clic en el botón "Aceptar e instalar" para aceptar los <a href="#">términos de licencia</a> de Microsoft .NET Framework. + &Aceptar e instalar + &Rechazar + Progreso de la instalación + Procesando: + &Cancelar + Error de la instalación + No se pudo completar la instalación a causa de uno o varios problemas. Corrija los problemas y vuelva a intentar la instalación. Para más información, vea el <a href="#">archivo de registro</a>. + Debe reiniciar el equipo para completar la reversión del software. + &Reiniciar + &Cerrar + diff --git a/src/wixstdba/Resources/HyperlinkLargeTheme.xml b/src/wixstdba/Resources/HyperlinkLargeTheme.xml new file mode 100644 index 00000000..9aff929f --- /dev/null +++ b/src/wixstdba/Resources/HyperlinkLargeTheme.xml @@ -0,0 +1,109 @@ + + + + + + Segoe UI + Segoe UI + Segoe UI + Segoe UI + + + + + + + + + + + + + + #(loc.InstallLicenseLinkText) + + #(loc.InstallAcceptCheckbox) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #(loc.FailureHyperlinkLogText) + + + + + + + diff --git a/src/wixstdba/Resources/HyperlinkSidebarTheme.xml b/src/wixstdba/Resources/HyperlinkSidebarTheme.xml new file mode 100644 index 00000000..24a53583 --- /dev/null +++ b/src/wixstdba/Resources/HyperlinkSidebarTheme.xml @@ -0,0 +1,120 @@ + + + + + + Segoe UI + Segoe UI + Segoe UI + Segoe UI + + + + + + + + + + + + + + + #(loc.InstallLicenseLinkText) + + #(loc.InstallAcceptCheckbox) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #(loc.FailureHyperlinkLogText) + + + + + + + diff --git a/src/wixstdba/Resources/HyperlinkTheme.wxl b/src/wixstdba/Resources/HyperlinkTheme.wxl new file mode 100644 index 00000000..e6e3f8ab --- /dev/null +++ b/src/wixstdba/Resources/HyperlinkTheme.wxl @@ -0,0 +1,61 @@ + + + + + + [WixBundleName] Setup + [WixBundleName] + Welcome + Setup will install [WixBundleName] on your computer. Click install to continue, options to set the install directory or Close to exit. + Version [WixBundleVersion] + Are you sure you want to cancel? + Previous version + Setup Help + /install | /repair | /uninstall | /layout [directory] - installs, repairs, uninstalls or + creates a complete local copy of the bundle in directory. Install is the default. + +/passive | /quiet - displays minimal UI with no prompts or displays no UI and + no prompts. By default UI and all prompts are displayed. + +/norestart - suppress any attempts to restart. By default UI will prompt before restart. +/log log.txt - logs to a specific file. By default a log file is created in %TEMP%. + &Close + [WixBundleName] <a href="#">license terms</a>. + I &agree to the license terms and conditions + &Options + &Install + &Cancel + Setup Options + Install location: + &Browse + &OK + &Cancel + Setup Progress + Processing: + Initializing... + &Cancel + Modify Setup + &Repair + &Uninstall + &Cancel + Setup Successful + Installation Successfully Completed + Layout Successfully Completed + Repair Successfully Completed + Uninstall Successfully Completed + &Launch + You must restart your computer before you can use the software. + You must restart your computer to complete the removal of the software. + &Restart + &Close + Setup Failed + Setup Failed + Layout Failed + Repair Failed + Uninstall Failed + One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the <a href="#">log file</a>. + You must restart your computer to complete the rollback of the software. + &Restart + &Close + No action was taken as a system reboot is required. + diff --git a/src/wixstdba/Resources/HyperlinkTheme.xml b/src/wixstdba/Resources/HyperlinkTheme.xml new file mode 100644 index 00000000..51a5be5b --- /dev/null +++ b/src/wixstdba/Resources/HyperlinkTheme.xml @@ -0,0 +1,106 @@ + + + + + + Segoe UI + Segoe UI + Segoe UI + Segoe UI + + + + + + + + + + + + #(loc.InstallLicenseLinkText) + #(loc.InstallAcceptCheckbox) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #(loc.FailureHyperlinkLogText) + + + + + + + diff --git a/src/wixstdba/Resources/LoremIpsumLicense.rtf b/src/wixstdba/Resources/LoremIpsumLicense.rtf new file mode 100644 index 00000000..1a183236 Binary files /dev/null and b/src/wixstdba/Resources/LoremIpsumLicense.rtf differ diff --git a/src/wixstdba/Resources/RtfLargeTheme.xml b/src/wixstdba/Resources/RtfLargeTheme.xml new file mode 100644 index 00000000..2a87f912 --- /dev/null +++ b/src/wixstdba/Resources/RtfLargeTheme.xml @@ -0,0 +1,108 @@ + + + + + + Segoe UI + Segoe UI + Segoe UI + Segoe UI + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #(loc.FailureHyperlinkLogText) + + + + + + + diff --git a/src/wixstdba/Resources/RtfTheme.wxl b/src/wixstdba/Resources/RtfTheme.wxl new file mode 100644 index 00000000..f73fb994 --- /dev/null +++ b/src/wixstdba/Resources/RtfTheme.wxl @@ -0,0 +1,58 @@ + + + + + + [WixBundleName] Setup + [WixBundleName] + Version [WixBundleVersion] + Are you sure you want to cancel? + Previous version + Setup Help + /install | /repair | /uninstall | /layout [directory] - installs, repairs, uninstalls or + creates a complete local copy of the bundle in directory. Install is the default. + +/passive | /quiet - displays minimal UI with no prompts or displays no UI and + no prompts. By default UI and all prompts are displayed. + +/norestart - suppress any attempts to restart. By default UI will prompt before restart. +/log log.txt - logs to a specific file. By default a log file is created in %TEMP%. + &Close + I &agree to the license terms and conditions + &Options + &Install + &Cancel + Setup Options + Install location: + &Browse + &OK + &Cancel + Setup Progress + Processing: + Initializing... + &Cancel + Modify Setup + &Repair + &Uninstall + &Cancel + Setup Successful + Installation Successfully Completed + Layout Successfully Completed + Repair Successfully Completed + Uninstall Successfully Completed + &Launch + You must restart your computer before you can use the software. + You must restart your computer to complete the removal of the software. + &Restart + &Close + Setup Failed + Setup Failed + Layout Failed + Repair Failed + Uninstall Failed + One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the <a href="#">log file</a>. + You must restart your computer to complete the rollback of the software. + &Restart + &Close + No action was taken as a system reboot is required. + diff --git a/src/wixstdba/Resources/RtfTheme.xml b/src/wixstdba/Resources/RtfTheme.xml new file mode 100644 index 00000000..6654c3f2 --- /dev/null +++ b/src/wixstdba/Resources/RtfTheme.xml @@ -0,0 +1,106 @@ + + + + + + Segoe UI + Segoe UI + Segoe UI + Segoe UI + + + + + + + + + + + + + #(loc.InstallAcceptCheckbox) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #(loc.FailureHyperlinkLogText) + + + + + + + diff --git a/src/wixstdba/Resources/logo.png b/src/wixstdba/Resources/logo.png new file mode 100644 index 00000000..7adc6e11 Binary files /dev/null and b/src/wixstdba/Resources/logo.png differ diff --git a/src/wixstdba/Resources/logoSide.png b/src/wixstdba/Resources/logoSide.png new file mode 100644 index 00000000..308841c5 Binary files /dev/null and b/src/wixstdba/Resources/logoSide.png differ diff --git a/src/wixstdba/Resources/mbapreq.png b/src/wixstdba/Resources/mbapreq.png new file mode 100644 index 00000000..c6e9527b Binary files /dev/null and b/src/wixstdba/Resources/mbapreq.png differ diff --git a/src/wixstdba/Resources/mbapreq.thm b/src/wixstdba/Resources/mbapreq.thm new file mode 100644 index 00000000..4ae61819 --- /dev/null +++ b/src/wixstdba/Resources/mbapreq.thm @@ -0,0 +1,47 @@ + + + Segoe UI + Segoe UI + Segoe UI + Segoe UI + + + + + + + + + + + + #(loc.InstallLicenseTerms) + + + + + + + + + + + + + #(loc.FailureLogLinkText) + + + + + + + diff --git a/src/wixstdba/Resources/mbapreq.wxl b/src/wixstdba/Resources/mbapreq.wxl new file mode 100644 index 00000000..95e3a6ae --- /dev/null +++ b/src/wixstdba/Resources/mbapreq.wxl @@ -0,0 +1,29 @@ + + + + + + [WixBundleName] Setup + Microsoft .NET Framework required for [WixBundleName] setup + Are you sure you want to cancel? + Setup Help + /passive | /quiet - displays minimal UI with no prompts or displays no UI and + no prompts. By default UI and all prompts are displayed. + +/norestart - suppress any attempts to restart. By default UI will prompt before restart. +/log log.txt - logs to a specific file. By default a log file is created in %TEMP%. + &Close + Click the "Accept and Install" button to accept the Microsoft .NET Framework <a href="#">license terms</a>. + &Accept and Install + &Decline + Setup Progress + Processing: + &Cancel + Setup Failed + One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the <a href="#">log file</a>. + You must restart your computer to complete the rollback of the software. + &Restart + &Close + [WixBundleName] cannot run on Windows 7 RTM with .NET 4.5.2 installed. Install Windows 7 SP1 to run in a supported environment. + No action was taken as a system reboot is required. + diff --git a/src/wixstdba/WixStandardBootstrapperApplication.cpp b/src/wixstdba/WixStandardBootstrapperApplication.cpp new file mode 100644 index 00000000..6d2fd3e2 --- /dev/null +++ b/src/wixstdba/WixStandardBootstrapperApplication.cpp @@ -0,0 +1,3849 @@ +// Copyright (c) .NET 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" +#include "BalBaseBootstrapperApplication.h" + +static const LPCWSTR WIXBUNDLE_VARIABLE_ELEVATED = L"WixBundleElevated"; + +static const LPCWSTR WIXSTDBA_WINDOW_CLASS = L"WixStdBA"; + +static const LPCWSTR WIXSTDBA_VARIABLE_INSTALL_FOLDER = L"InstallFolder"; +static const LPCWSTR WIXSTDBA_VARIABLE_LAUNCH_TARGET_PATH = L"LaunchTarget"; +static const LPCWSTR WIXSTDBA_VARIABLE_LAUNCH_TARGET_ELEVATED_ID = L"LaunchTargetElevatedId"; +static const LPCWSTR WIXSTDBA_VARIABLE_LAUNCH_ARGUMENTS = L"LaunchArguments"; +static const LPCWSTR WIXSTDBA_VARIABLE_LAUNCH_HIDDEN = L"LaunchHidden"; +static const LPCWSTR WIXSTDBA_VARIABLE_LAUNCH_WORK_FOLDER = L"LaunchWorkingFolder"; + +static const DWORD WIXSTDBA_ACQUIRE_PERCENTAGE = 30; + +static const LPCWSTR WIXSTDBA_VARIABLE_BUNDLE_FILE_VERSION = L"WixBundleFileVersion"; +static const LPCWSTR WIXSTDBA_VARIABLE_LANGUAGE_ID = L"WixStdBALanguageId"; +static const LPCWSTR WIXSTDBA_VARIABLE_RESTART_REQUIRED = L"WixStdBARestartRequired"; +static const LPCWSTR WIXSTDBA_VARIABLE_SHOW_VERSION = L"WixStdBAShowVersion"; +static const LPCWSTR WIXSTDBA_VARIABLE_SUPPRESS_OPTIONS_UI = L"WixStdBASuppressOptionsUI"; + +enum WIXSTDBA_STATE +{ + WIXSTDBA_STATE_INITIALIZING, + WIXSTDBA_STATE_INITIALIZED, + WIXSTDBA_STATE_HELP, + WIXSTDBA_STATE_DETECTING, + WIXSTDBA_STATE_DETECTED, + WIXSTDBA_STATE_PLANNING, + WIXSTDBA_STATE_PLANNED, + WIXSTDBA_STATE_APPLYING, + WIXSTDBA_STATE_CACHING, + WIXSTDBA_STATE_CACHED, + WIXSTDBA_STATE_EXECUTING, + WIXSTDBA_STATE_EXECUTED, + WIXSTDBA_STATE_APPLIED, + WIXSTDBA_STATE_FAILED, +}; + +enum WM_WIXSTDBA +{ + WM_WIXSTDBA_SHOW_HELP = WM_APP + 100, + WM_WIXSTDBA_DETECT_PACKAGES, + WM_WIXSTDBA_PLAN_PACKAGES, + WM_WIXSTDBA_APPLY_PACKAGES, + WM_WIXSTDBA_CHANGE_STATE, + WM_WIXSTDBA_SHOW_FAILURE, +}; + +// This enum must be kept in the same order as the vrgwzPageNames array. +enum WIXSTDBA_PAGE +{ + WIXSTDBA_PAGE_LOADING, + WIXSTDBA_PAGE_HELP, + WIXSTDBA_PAGE_INSTALL, + WIXSTDBA_PAGE_MODIFY, + WIXSTDBA_PAGE_PROGRESS, + WIXSTDBA_PAGE_PROGRESS_PASSIVE, + WIXSTDBA_PAGE_SUCCESS, + WIXSTDBA_PAGE_FAILURE, + COUNT_WIXSTDBA_PAGE, +}; + +// This array must be kept in the same order as the WIXSTDBA_PAGE enum. +static LPCWSTR vrgwzPageNames[] = { + L"Loading", + L"Help", + L"Install", + L"Modify", + L"Progress", + L"ProgressPassive", + L"Success", + L"Failure", +}; + +enum WIXSTDBA_CONTROL +{ + // Welcome page + WIXSTDBA_CONTROL_INSTALL_BUTTON = THEME_FIRST_ASSIGN_CONTROL_ID, + WIXSTDBA_CONTROL_EULA_RICHEDIT, + WIXSTDBA_CONTROL_EULA_LINK, + WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX, + + // Modify page + WIXSTDBA_CONTROL_REPAIR_BUTTON, + WIXSTDBA_CONTROL_UNINSTALL_BUTTON, + + // Progress page + WIXSTDBA_CONTROL_CACHE_PROGRESS_PACKAGE_TEXT, + WIXSTDBA_CONTROL_CACHE_PROGRESS_BAR, + WIXSTDBA_CONTROL_CACHE_PROGRESS_TEXT, + + WIXSTDBA_CONTROL_EXECUTE_PROGRESS_PACKAGE_TEXT, + WIXSTDBA_CONTROL_EXECUTE_PROGRESS_BAR, + WIXSTDBA_CONTROL_EXECUTE_PROGRESS_TEXT, + WIXSTDBA_CONTROL_EXECUTE_PROGRESS_ACTIONDATA_TEXT, + + WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, + WIXSTDBA_CONTROL_OVERALL_PROGRESS_BAR, + WIXSTDBA_CONTROL_OVERALL_CALCULATED_PROGRESS_BAR, + WIXSTDBA_CONTROL_OVERALL_PROGRESS_TEXT, + + WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, + + // Success page + WIXSTDBA_CONTROL_LAUNCH_BUTTON, + WIXSTDBA_CONTROL_SUCCESS_RESTART_BUTTON, + + // Failure page + WIXSTDBA_CONTROL_FAILURE_LOGFILE_LINK, + WIXSTDBA_CONTROL_FAILURE_MESSAGE_TEXT, + WIXSTDBA_CONTROL_FAILURE_RESTART_BUTTON, +}; + +static THEME_ASSIGN_CONTROL_ID vrgInitControls[] = { + { WIXSTDBA_CONTROL_INSTALL_BUTTON, L"InstallButton" }, + { WIXSTDBA_CONTROL_EULA_RICHEDIT, L"EulaRichedit" }, + { WIXSTDBA_CONTROL_EULA_LINK, L"EulaHyperlink" }, + { WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX, L"EulaAcceptCheckbox" }, + + { WIXSTDBA_CONTROL_REPAIR_BUTTON, L"RepairButton" }, + { WIXSTDBA_CONTROL_UNINSTALL_BUTTON, L"UninstallButton" }, + + { WIXSTDBA_CONTROL_CACHE_PROGRESS_PACKAGE_TEXT, L"CacheProgressPackageText" }, + { WIXSTDBA_CONTROL_CACHE_PROGRESS_BAR, L"CacheProgressbar" }, + { WIXSTDBA_CONTROL_CACHE_PROGRESS_TEXT, L"CacheProgressText" }, + { WIXSTDBA_CONTROL_EXECUTE_PROGRESS_PACKAGE_TEXT, L"ExecuteProgressPackageText" }, + { WIXSTDBA_CONTROL_EXECUTE_PROGRESS_BAR, L"ExecuteProgressbar" }, + { WIXSTDBA_CONTROL_EXECUTE_PROGRESS_TEXT, L"ExecuteProgressText" }, + { WIXSTDBA_CONTROL_EXECUTE_PROGRESS_ACTIONDATA_TEXT, L"ExecuteProgressActionDataText"}, + { WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, L"OverallProgressPackageText" }, + { WIXSTDBA_CONTROL_OVERALL_PROGRESS_BAR, L"OverallProgressbar" }, + { WIXSTDBA_CONTROL_OVERALL_CALCULATED_PROGRESS_BAR, L"OverallCalculatedProgressbar" }, + { WIXSTDBA_CONTROL_OVERALL_PROGRESS_TEXT, L"OverallProgressText" }, + { WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, L"ProgressCancelButton" }, + + { WIXSTDBA_CONTROL_LAUNCH_BUTTON, L"LaunchButton" }, + { WIXSTDBA_CONTROL_SUCCESS_RESTART_BUTTON, L"SuccessRestartButton" }, + + { WIXSTDBA_CONTROL_FAILURE_LOGFILE_LINK, L"FailureLogFileLink" }, + { WIXSTDBA_CONTROL_FAILURE_MESSAGE_TEXT, L"FailureMessageText" }, + { WIXSTDBA_CONTROL_FAILURE_RESTART_BUTTON, L"FailureRestartButton" }, +}; + +typedef struct _WIXSTDBA_PREREQ_PACKAGE +{ + LPWSTR sczPackageId; + BOOL fWasAlreadyInstalled; + BOOL fPlannedToBeInstalled; + BOOL fSuccessfullyInstalled; +} WIXSTDBA_PREREQ_PACKAGE; + + +static HRESULT DAPI EvaluateVariableConditionCallback( + __in_z LPCWSTR wzCondition, + __out BOOL* pf, + __in_opt LPVOID pvContext + ); +static HRESULT DAPI FormatVariableStringCallback( + __in_z LPCWSTR wzFormat, + __inout LPWSTR* psczOut, + __in_opt LPVOID pvContext + ); +static HRESULT DAPI GetVariableNumericCallback( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue, + __in_opt LPVOID pvContext + ); +static HRESULT DAPI SetVariableNumericCallback( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue, + __in_opt LPVOID pvContext + ); +static HRESULT DAPI GetVariableStringCallback( + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue, + __in_opt LPVOID pvContext + ); +static HRESULT DAPI SetVariableStringCallback( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in_opt LPVOID pvContext + ); +static LPCSTR LoggingRequestStateToString( + __in BOOTSTRAPPER_REQUEST_STATE requestState + ); +static LPCSTR LoggingMsiFeatureStateToString( + __in BOOTSTRAPPER_FEATURE_STATE featureState + ); + + +class CWixStandardBootstrapperApplication : public CBalBaseBootstrapperApplication +{ +public: // IBootstrapperApplication + virtual STDMETHODIMP OnStartup() + { + HRESULT hr = S_OK; + DWORD dwUIThreadId = 0; + + // create UI thread + m_hUiThread = ::CreateThread(NULL, 0, UiThreadProc, this, 0, &dwUIThreadId); + if (!m_hUiThread) + { + ExitWithLastError(hr, "Failed to create UI thread."); + } + + LExit: + return hr; + } + + + virtual STDMETHODIMP OnShutdown( + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* pAction + ) + { + HRESULT hr = S_OK; + + // wait for UI thread to terminate + if (m_hUiThread) + { + ::WaitForSingleObject(m_hUiThread, INFINITE); + ReleaseHandle(m_hUiThread); + } + + // If a restart was required. + if (m_fRestartRequired) + { + if (m_fAllowRestart) + { + *pAction = BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART; + } + + if (m_fPrereq) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, m_fAllowRestart ? "The prerequisites scheduled a restart. The bootstrapper application will be reloaded after the computer is restarted." + : "A restart is required by the prerequisites but the user delayed it. The bootstrapper application will be reloaded after the computer is restarted."); + } + } + else if (m_fPrereqInstalled) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "The prerequisites were successfully installed. The bootstrapper application will be reloaded."); + *pAction = BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER; + } + else if (m_fPrereqAlreadyInstalled) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "The prerequisites were already installed. The bootstrapper application will not be reloaded to prevent an infinite loop."); + } + else if (m_fPrereq) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "The prerequisites were not successfully installed, error: 0x%x. The bootstrapper application will be not reloaded.", m_hrFinal); + } + + return hr; + } + + + virtual STDMETHODIMP OnDetectRelatedBundle( + __in LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in LPCWSTR wzBundleTag, + __in BOOL fPerMachine, + __in DWORD64 dw64Version, + __in BOOTSTRAPPER_RELATED_OPERATION operation, + __inout BOOL* pfCancel + ) + { + BalInfoAddRelatedBundleAsPackage(&m_Bundle.packages, wzBundleId, relationType, fPerMachine); + + // If we're not doing a prerequisite install, remember when our bundle would cause a downgrade. + if (!m_fPrereq && BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE == operation) + { + m_fDowngrading = TRUE; + } + + return CBalBaseBootstrapperApplication::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, dw64Version, operation, pfCancel); + } + + + virtual STDMETHODIMP OnDetectPackageComplete( + __in LPCWSTR wzPackageId, + __in HRESULT /*hrStatus*/, + __in BOOTSTRAPPER_PACKAGE_STATE state + ) + { + WIXSTDBA_PREREQ_PACKAGE* pPrereqPackage = NULL; + BAL_INFO_PACKAGE* pPackage = NULL; + HRESULT hr = GetPrereqPackage(wzPackageId, &pPrereqPackage, &pPackage); + if (SUCCEEDED(hr) && BOOTSTRAPPER_PACKAGE_STATE_PRESENT == state) + { + // If the prerequisite package is already installed, remember that. + pPrereqPackage->fWasAlreadyInstalled = TRUE; + } + + return S_OK; + } + + + virtual STDMETHODIMP OnDetectComplete( + __in HRESULT hrStatus + ) + { + HRESULT hr = S_OK; + + if (SUCCEEDED(hrStatus)) + { + hrStatus = EvaluateConditions(); + + if (m_fPrereq) + { + m_fPrereqAlreadyInstalled = TRUE; + + // At this point we have to assume that all prerequisite packages need to be installed, so set to false if any of them aren't installed. + for (DWORD i = 0; i < m_cPrereqPackages; ++i) + { + if (m_rgPrereqPackages[i].sczPackageId && !m_rgPrereqPackages[i].fWasAlreadyInstalled) + { + m_fPrereqAlreadyInstalled = FALSE; + break; + } + } + } + } + + SetState(WIXSTDBA_STATE_DETECTED, hrStatus); + + if (BOOTSTRAPPER_ACTION_CACHE == m_plannedAction) + { + if (m_fSupportCacheOnly) + { + // Doesn't make sense to prompt the user if cache only is requested. + if (BOOTSTRAPPER_DISPLAY_PASSIVE < m_command.display) + { + m_command.display = BOOTSTRAPPER_DISPLAY_PASSIVE; + } + + m_command.action = BOOTSTRAPPER_ACTION_CACHE; + } + else + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to only cache a bundle that does not explicitly support it."); + } + } + + // If we're not interacting with the user or we're doing a layout or we're just after a force restart + // then automatically start planning. + if (BOOTSTRAPPER_DISPLAY_FULL > m_command.display || BOOTSTRAPPER_ACTION_LAYOUT == m_command.action || BOOTSTRAPPER_RESUME_TYPE_REBOOT == m_command.resumeType) + { + if (SUCCEEDED(hrStatus)) + { + ::PostMessageW(m_hWnd, WM_WIXSTDBA_PLAN_PACKAGES, 0, m_command.action); + } + } + + return hr; + } + + + virtual STDMETHODIMP OnPlanRelatedBundle( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout_z BOOTSTRAPPER_REQUEST_STATE* pRequestedState, + __inout BOOL* pfCancel + ) + { + // If we're only installing prerequisites, do not touch related bundles. + if (m_fPrereq) + { + *pRequestedState = BOOTSTRAPPER_REQUEST_STATE_NONE; + } + + return CBalBaseBootstrapperApplication::OnPlanRelatedBundle(wzBundleId, recommendedState, pRequestedState, pfCancel); + } + + + virtual STDMETHODIMP OnPlanPackageBegin( + __in_z LPCWSTR wzPackageId, + __in BOOTSTRAPPER_REQUEST_STATE recommendedState, + __inout BOOTSTRAPPER_REQUEST_STATE *pRequestState, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + WIXSTDBA_PREREQ_PACKAGE* pPrereqPackage = NULL; + BAL_INFO_PACKAGE* pPackage = NULL; + + // If we're planning to install a prerequisite, install it. The prerequisite needs to be installed + // in all cases (even uninstall!) so the BA can load next. + if (m_fPrereq) + { + // Only install prerequisite packages, and check the InstallCondition on prerequisite support packages. + BOOL fInstall = FALSE; + hr = GetPrereqPackage(wzPackageId, &pPrereqPackage, &pPackage); + if (SUCCEEDED(hr) && pPackage) + { + if (pPackage->sczInstallCondition && *pPackage->sczInstallCondition) + { + hr = BalEvaluateCondition(pPackage->sczInstallCondition, &fInstall); + if (FAILED(hr)) + { + fInstall = FALSE; + } + } + else + { + // If the InstallCondition is missing, then it should always be installed. + fInstall = TRUE; + } + + pPrereqPackage->fPlannedToBeInstalled = fInstall; + } + + if (fInstall) + { + *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; + } + else + { + *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; + } + } + else if (m_sczAfterForcedRestartPackage) // after force restart, skip packages until after the package that caused the restart. + { + // After restart we need to finish the dependency registration for our package so allow the package + // to go present. + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, m_sczAfterForcedRestartPackage, -1)) + { + // Do not allow a repair because that could put us in a perpetual restart loop. + if (BOOTSTRAPPER_REQUEST_STATE_REPAIR == *pRequestState) + { + *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; + } + + ReleaseNullStr(m_sczAfterForcedRestartPackage); // no more skipping now. + } + else // not the matching package, so skip it. + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Skipping package: %ls, after restart because it was applied before the restart.", wzPackageId); + + *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; + } + } + + return CBalBaseBootstrapperApplication::OnPlanPackageBegin(wzPackageId, recommendedState, pRequestState, pfCancel); + } + + + virtual STDMETHODIMP OnPlanComplete( + __in HRESULT hrStatus + ) + { + HRESULT hr = S_OK; + + if (m_fPrereq) + { + m_fPrereqAlreadyInstalled = TRUE; + + // Now that we've planned the packages, we can focus on the prerequisite packages that are supposed to be installed. + for (DWORD i = 0; i < m_cPrereqPackages; ++i) + { + if (m_rgPrereqPackages[i].sczPackageId && !m_rgPrereqPackages[i].fWasAlreadyInstalled && m_rgPrereqPackages[i].fPlannedToBeInstalled) + { + m_fPrereqAlreadyInstalled = FALSE; + break; + } + } + } + + SetState(WIXSTDBA_STATE_PLANNED, hrStatus); + + if (SUCCEEDED(hrStatus)) + { + ::PostMessageW(m_hWnd, WM_WIXSTDBA_APPLY_PACKAGES, 0, 0); + } + + m_fStartedExecution = FALSE; + m_dwCalculatedCacheProgress = 0; + m_dwCalculatedExecuteProgress = 0; + + return hr; + } + + + virtual STDMETHODIMP OnCachePackageBegin( + __in_z LPCWSTR wzPackageId, + __in DWORD cCachePayloads, + __in DWORD64 dw64PackageCacheSize, + __inout BOOL* pfCancel + ) + { + if (wzPackageId && *wzPackageId) + { + BAL_INFO_PACKAGE* pPackage = NULL; + HRESULT hr = BalInfoFindPackageById(&m_Bundle.packages, wzPackageId, &pPackage); + LPCWSTR wz = (SUCCEEDED(hr) && pPackage->sczDisplayName) ? pPackage->sczDisplayName : wzPackageId; + + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_CACHE_PROGRESS_PACKAGE_TEXT, wz); + + // If something started executing, leave it in the overall progress text. + if (!m_fStartedExecution) + { + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, wz); + } + } + + return __super::OnCachePackageBegin(wzPackageId, cCachePayloads, dw64PackageCacheSize, pfCancel); + } + + + virtual STDMETHODIMP OnCacheAcquireProgress( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in DWORD64 dw64Progress, + __in DWORD64 dw64Total, + __in DWORD dwOverallPercentage, + __inout BOOL* pfCancel + ) + { +#ifdef DEBUG + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: OnCacheAcquireProgress() - container/package: %ls, payload: %ls, progress: %I64u, total: %I64u, overall progress: %u%%", wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage); +#endif + + UpdateCacheProgress(dwOverallPercentage); + + return __super::OnCacheAcquireProgress(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage, pfCancel); + } + + + 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 + ) + { + SetProgressState(hrStatus); + return __super::OnCacheAcquireComplete(wzPackageOrContainerId, wzPayloadId, hrStatus, recommendation, pAction); + } + + + virtual STDMETHODIMP OnCacheVerifyComplete( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzPayloadId, + __in HRESULT hrStatus, + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION recommendation, + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction + ) + { + SetProgressState(hrStatus); + return __super::OnCacheVerifyComplete(wzPackageId, wzPayloadId, hrStatus, recommendation, pAction); + } + + + virtual STDMETHODIMP OnCacheComplete( + __in HRESULT hrStatus + ) + { + UpdateCacheProgress(SUCCEEDED(hrStatus) ? 100 : 0); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_CACHE_PROGRESS_PACKAGE_TEXT, L""); + SetState(WIXSTDBA_STATE_CACHED, S_OK); // we always return success here and let OnApplyComplete() deal with the error. + return __super::OnCacheComplete(hrStatus); + } + + + virtual STDMETHODIMP OnError( + __in BOOTSTRAPPER_ERROR_TYPE errorType, + __in 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 + ) + { + HRESULT hr = S_OK; + int nResult = *pResult; + LPWSTR sczError = NULL; + + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_command.display) + { + hr = m_pEngine->SendEmbeddedError(dwCode, wzError, dwUIHint, &nResult); + if (FAILED(hr)) + { + nResult = IDERROR; + } + } + else if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display) + { + // If this is an authentication failure, let the engine try to handle it for us. + if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType) + { + nResult = IDTRYAGAIN; + } + else // show a generic error message box. + { + BalRetryErrorOccurred(wzPackageId, dwCode); + + if (!m_fShowingInternalUiThisPackage) + { + // If no error message was provided, use the error code to try and get an error message. + if (!wzError || !*wzError || BOOTSTRAPPER_ERROR_TYPE_WINDOWS_INSTALLER != errorType) + { + hr = StrAllocFromError(&sczError, dwCode, NULL); + if (FAILED(hr) || !sczError || !*sczError) + { + // special case for ERROR_FAIL_NOACTION_REBOOT: use loc string for Windows XP + if (ERROR_FAIL_NOACTION_REBOOT == dwCode) + { + LOC_STRING* pLocString = NULL; + hr = LocGetString(m_pWixLoc, L"#(loc.ErrorFailNoActionReboot)", &pLocString); + if (SUCCEEDED(hr)) + { + StrAllocString(&sczError, pLocString->wzText, 0); + } + else + { + StrAllocFormatted(&sczError, L"0x%x", dwCode); + } + } + else + { + StrAllocFormatted(&sczError, L"0x%x", dwCode); + } + } + hr = S_OK; + } + + nResult = ::MessageBoxW(m_hWnd, sczError ? sczError : wzError, m_pTheme->sczCaption, dwUIHint); + } + } + + SetProgressState(HRESULT_FROM_WIN32(dwCode)); + } + else // just take note of the error code and let things continue. + { + BalRetryErrorOccurred(wzPackageId, dwCode); + } + + ReleaseStr(sczError); + *pResult = nResult; + 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 + ) + { +#ifdef DEBUG + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: OnExecuteMsiMessage() - package: %ls, message: %ls", wzPackageId, wzMessage); +#endif + if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display && (INSTALLMESSAGE_WARNING == messageType || INSTALLMESSAGE_USER == messageType)) + { + if (!m_fShowingInternalUiThisPackage) + { + int nResult = ::MessageBoxW(m_hWnd, wzMessage, m_pTheme->sczCaption, dwUIHint); + return nResult; + } + } + + if (INSTALLMESSAGE_ACTIONSTART == messageType) + { + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_ACTIONDATA_TEXT, wzMessage); + } + + return __super::OnExecuteMsiMessage(wzPackageId, messageType, dwUIHint, wzMessage, cData, rgwzData, nRecommendation, pResult); + } + + + virtual STDMETHODIMP OnProgress( + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __inout BOOL* pfCancel + ) + { + WCHAR wzProgress[5] = { }; + +#ifdef DEBUG + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: OnProgress() - progress: %u%%, overall progress: %u%%", dwProgressPercentage, dwOverallProgressPercentage); +#endif + + ::StringCchPrintfW(wzProgress, countof(wzProgress), L"%u%%", dwOverallProgressPercentage); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_TEXT, wzProgress); + + ThemeSetProgressControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_BAR, dwOverallProgressPercentage); + SetTaskbarButtonProgress(dwOverallProgressPercentage); + + return __super::OnProgress(dwProgressPercentage, dwOverallProgressPercentage, pfCancel); + } + + + virtual STDMETHODIMP OnExecutePackageBegin( + __in_z LPCWSTR wzPackageId, + __in BOOL fExecute, + __inout BOOL* pfCancel + ) + { + LPWSTR sczFormattedString = NULL; + + m_fStartedExecution = TRUE; + + if (wzPackageId && *wzPackageId) + { + BAL_INFO_PACKAGE* pPackage = NULL; + BalInfoFindPackageById(&m_Bundle.packages, wzPackageId, &pPackage); + + LPCWSTR wz = wzPackageId; + if (pPackage) + { + LOC_STRING* pLocString = NULL; + + switch (pPackage->type) + { + case BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON: + LocGetString(m_pWixLoc, L"#(loc.ExecuteAddonRelatedBundleMessage)", &pLocString); + break; + + case BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH: + LocGetString(m_pWixLoc, L"#(loc.ExecutePatchRelatedBundleMessage)", &pLocString); + break; + + case BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE: + LocGetString(m_pWixLoc, L"#(loc.ExecuteUpgradeRelatedBundleMessage)", &pLocString); + break; + } + + if (pLocString) + { + // If the wix developer is showing a hidden variable in the UI, then obviously they don't care about keeping it safe + // so don't go down the rabbit hole of making sure that this is securely freed. + BalFormatString(pLocString->wzText, &sczFormattedString); + } + + wz = sczFormattedString ? sczFormattedString : pPackage->sczDisplayName ? pPackage->sczDisplayName : wzPackageId; + } + + //Burn engine doesn't show internal UI for msi packages during uninstall or repair actions. + m_fShowingInternalUiThisPackage = pPackage && pPackage->fDisplayInternalUI && BOOTSTRAPPER_ACTION_UNINSTALL != m_plannedAction && BOOTSTRAPPER_ACTION_REPAIR != m_plannedAction; + + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_PACKAGE_TEXT, wz); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, wz); + } + else + { + m_fShowingInternalUiThisPackage = FALSE; + } + + ReleaseStr(sczFormattedString); + return __super::OnExecutePackageBegin(wzPackageId, fExecute, pfCancel); + } + + + virtual STDMETHODIMP OnExecuteProgress( + __in_z LPCWSTR wzPackageId, + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage, + __inout BOOL* pfCancel + ) + { + WCHAR wzProgress[5] = { }; + +#ifdef DEBUG + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: OnExecuteProgress() - package: %ls, progress: %u%%, overall progress: %u%%", wzPackageId, dwProgressPercentage, dwOverallProgressPercentage); +#endif + + ::StringCchPrintfW(wzProgress, countof(wzProgress), L"%u%%", dwOverallProgressPercentage); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_TEXT, wzProgress); + + ThemeSetProgressControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_BAR, dwOverallProgressPercentage); + + m_dwCalculatedExecuteProgress = dwOverallProgressPercentage * (100 - WIXSTDBA_ACQUIRE_PERCENTAGE) / 100; + ThemeSetProgressControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_CALCULATED_PROGRESS_BAR, m_dwCalculatedCacheProgress + m_dwCalculatedExecuteProgress); + + SetTaskbarButtonProgress(m_dwCalculatedCacheProgress + m_dwCalculatedExecuteProgress); + + return __super::OnExecuteProgress(wzPackageId, dwProgressPercentage, dwOverallProgressPercentage, pfCancel); + } + + + 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; + SetProgressState(hrStatus); + + hr = __super::OnExecutePackageComplete(wzPackageId, hrStatus, restart, recommendation, pAction); + + WIXSTDBA_PREREQ_PACKAGE* pPrereqPackage = NULL; + BAL_INFO_PACKAGE* pPackage; + HRESULT hrPrereq = GetPrereqPackage(wzPackageId, &pPrereqPackage, &pPackage); + if (SUCCEEDED(hrPrereq)) + { + pPrereqPackage->fSuccessfullyInstalled = SUCCEEDED(hrStatus); + + // If the prerequisite required a restart (any restart) then do an immediate + // restart to ensure that the bundle will get launched again post reboot. + if (BOOTSTRAPPER_APPLY_RESTART_NONE != restart) + { + *pAction = BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RESTART; + } + } + + return hr; + } + + + virtual STDMETHODIMP OnExecuteComplete( + __in HRESULT hrStatus + ) + { + HRESULT hr = S_OK; + + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_PACKAGE_TEXT, L""); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_EXECUTE_PROGRESS_ACTIONDATA_TEXT, L""); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_PROGRESS_PACKAGE_TEXT, L""); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, FALSE); // no more cancel. + + SetState(WIXSTDBA_STATE_EXECUTED, S_OK); // we always return success here and let OnApplyComplete() deal with the error. + SetProgressState(hrStatus); + + return hr; + } + + + virtual STDMETHODIMP OnResolveSource( + __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzLocalSource, + __in_z_opt LPCWSTR wzDownloadSource, + __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, + __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* pAction, + __inout BOOL* pfCancel + ) + { + HRESULT hr = S_OK; + + if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display) + { + if (wzDownloadSource) + { + *pAction = BOOTSTRAPPER_RESOLVESOURCE_ACTION_DOWNLOAD; + } + else // prompt to change the source location. + { + OPENFILENAMEW ofn = { }; + WCHAR wzFile[MAX_PATH] = { }; + + ::StringCchCopyW(wzFile, countof(wzFile), wzLocalSource); + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = m_hWnd; + ofn.lpstrFile = wzFile; + ofn.nMaxFile = countof(wzFile); + ofn.lpstrFilter = L"All Files\0*.*\0"; + ofn.nFilterIndex = 1; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + ofn.lpstrTitle = m_pTheme->sczCaption; + + if (::GetOpenFileNameW(&ofn)) + { + hr = m_pEngine->SetLocalSource(wzPackageOrContainerId, wzPayloadId, ofn.lpstrFile); + *pAction = BOOTSTRAPPER_RESOLVESOURCE_ACTION_RETRY; + } + else + { + *pfCancel = TRUE; + } + } + } + else if (wzDownloadSource) + { + // If doing a non-interactive install and download source is available, let's try downloading the package silently + *pAction = BOOTSTRAPPER_RESOLVESOURCE_ACTION_DOWNLOAD; + } + // else there's nothing more we can do in non-interactive mode + + *pfCancel |= CheckCanceled(); + return hr; + } + + + 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; + + __super::OnApplyComplete(hrStatus, restart, recommendation, pAction); + + m_restartResult = restart; // remember the restart result so we return the correct error code no matter what the user chooses to do in the UI. + + // If a restart was encountered and we are not suppressing restarts, then restart is required. + m_fRestartRequired = (BOOTSTRAPPER_APPLY_RESTART_NONE != restart && BOOTSTRAPPER_RESTART_NEVER < m_command.restart); + BalSetStringVariable(WIXSTDBA_VARIABLE_RESTART_REQUIRED, m_fRestartRequired ? L"1" : NULL); + + // If a restart is required and we're not displaying a UI or we are not supposed to prompt for restart then allow the restart. + m_fAllowRestart = m_fRestartRequired && (BOOTSTRAPPER_DISPLAY_FULL > m_command.display || BOOTSTRAPPER_RESTART_PROMPT < m_command.restart); + + if (m_fPrereq) + { + m_fPrereqInstalled = TRUE; + BOOL fInstalledAPackage = FALSE; + + for (DWORD i = 0; i < m_cPrereqPackages; ++i) + { + if (m_rgPrereqPackages[i].sczPackageId && m_rgPrereqPackages[i].fPlannedToBeInstalled && !m_rgPrereqPackages[i].fWasAlreadyInstalled) + { + if (m_rgPrereqPackages[i].fSuccessfullyInstalled) + { + fInstalledAPackage = TRUE; + } + else + { + m_fPrereqInstalled = FALSE; + break; + } + } + } + + m_fPrereqInstalled = m_fPrereqInstalled && fInstalledAPackage; + } + + // If we are showing UI, wait a beat before moving to the final screen. + if (BOOTSTRAPPER_DISPLAY_NONE < m_command.display) + { + ::Sleep(250); + } + + SetState(WIXSTDBA_STATE_APPLIED, hrStatus); + SetTaskbarButtonProgress(100); // show full progress bar, green, yellow, or red + + *pAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE; + + return hr; + } + + virtual STDMETHODIMP OnLaunchApprovedExeComplete( + __in HRESULT hrStatus, + __in DWORD /*processId*/ + ) + { + HRESULT hr = S_OK; + + if (HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) == hrStatus) + { + //try with ShelExec next time + OnClickLaunchButton(); + } + else + { + ::PostMessageW(m_hWnd, WM_CLOSE, 0, 0); + } + + return hr; + } + + virtual STDMETHODIMP_(void) BAProcFallback( + __in BOOTSTRAPPER_APPLICATION_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __inout HRESULT* phr, + __in_opt LPVOID /*pvContext*/ + ) + { + if (!m_pfnBAFunctionsProc || FAILED(*phr)) + { + return; + } + + // Always log before and after so we don't get blamed when BAFunctions changes something. + switch (message) + { + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN: + OnDetectBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE: + OnDetectCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN: + OnPlanBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE: + OnPlanCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP: // BAFunctions is loaded during this event on a separate thread so it's not possible to forward it. + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN: + OnShutdownFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN: + OnSystemShutdownFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE: + OnDetectForwardCompatibleBundleFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN: + OnDetectUpdateBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE: + OnDetectUpdateFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE: + OnDetectUpdateCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE: + OnDetectRelatedBundleFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN: + OnDetectPackageBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE: + OnDetectCompatibleMsiPackageFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE: + OnDetectRelatedMsiPackageFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE: + OnDetectTargetMsiPackageFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE: + OnDetectMsiFeatureFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE: + OnDetectPackageCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE: + OnPlanRelatedBundleFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN: + OnPlanPackageBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN: + OnPlanCompatibleMsiPackageBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: + OnPlanCompatibleMsiPackageCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE: + OnPlanTargetMsiPackageFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE: + OnPlanMsiFeatureFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE: + OnPlanPackageCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN: + OnApplyBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN: + OnElevateBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE: + OnElevateCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS: + OnProgressFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR: + OnErrorFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN: + OnRegisterBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE: + OnRegisterCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN: + OnCacheBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN: + OnCachePackageBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN: + OnCacheAcquireBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: + OnCacheAcquireProgressFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE: + OnResolveSourceFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE: + OnCacheAcquireCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN: + OnCacheVerifyBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE: + OnCacheVerifyCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE: + OnCachePackageCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE: + OnCacheCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN: + OnExecuteBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN: + OnExecutePackageBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET: + OnExecutePatchTargetFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS: + OnExecuteProgressFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE: + OnExecuteMsiMessageFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE: + OnExecuteFilesInUseFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE: + OnExecutePackageCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE: + OnExecuteCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN: + OnUnregisterBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE: + OnUnregisterCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE: + OnApplyCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN: + OnLaunchApprovedExeBeginFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE: + OnLaunchApprovedExeCompleteFallback(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + default: + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: Forwarding unknown BA message: %d", message); + m_pfnBAFunctionsProc((BA_FUNCTIONS_MESSAGE)message, pvArgs, pvResults, m_pvBAFunctionsProcContext); + break; + } + } + + +private: // privates + void OnDetectBeginFallback( + __in BA_ONDETECTBEGIN_ARGS* pArgs, + __inout BA_ONDETECTBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectCompleteFallback( + __in BA_ONDETECTCOMPLETE_ARGS* pArgs, + __inout BA_ONDETECTCOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTCOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnPlanBeginFallback( + __in BA_ONPLANBEGIN_ARGS* pArgs, + __inout BA_ONPLANBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnPlanCompleteFallback( + __in BA_ONPLANCOMPLETE_ARGS* pArgs, + __inout BA_ONPLANCOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnShutdownFallback( + __in BA_ONSHUTDOWN_ARGS* pArgs, + __inout BA_ONSHUTDOWN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONSHUTDOWN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnSystemShutdownFallback( + __in BA_ONSYSTEMSHUTDOWN_ARGS* pArgs, + __inout BA_ONSYSTEMSHUTDOWN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectForwardCompatibleBundleFallback( + __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs, + __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults + ) + { + BOOL fIgnoreBundle = pResults->fIgnoreBundle; + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, pArgs, pResults, m_pvBAFunctionsProcContext); + BalLogId(BOOTSTRAPPER_LOG_LEVEL_STANDARD, MSG_WIXSTDBA_DETECTED_FORWARD_COMPATIBLE_BUNDLE, m_hModule, pArgs->wzBundleId, fIgnoreBundle ? "ignore" : "enable", pResults->fIgnoreBundle ? "ignore" : "enable"); + } + + void OnDetectUpdateBeginFallback( + __in BA_ONDETECTUPDATEBEGIN_ARGS* pArgs, + __inout BA_ONDETECTUPDATEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectUpdateFallback( + __in BA_ONDETECTUPDATE_ARGS* pArgs, + __inout BA_ONDETECTUPDATE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectUpdateCompleteFallback( + __in BA_ONDETECTUPDATECOMPLETE_ARGS* pArgs, + __inout BA_ONDETECTUPDATECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectRelatedBundleFallback( + __in BA_ONDETECTRELATEDBUNDLE_ARGS* pArgs, + __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectPackageBeginFallback( + __in BA_ONDETECTPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONDETECTPACKAGEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectCompatibleMsiPackageFallback( + __in BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectRelatedMsiPackageFallback( + __in BA_ONDETECTRELATEDMSIPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTRELATEDMSIPACKAGE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectTargetMsiPackageFallback( + __in BA_ONDETECTTARGETMSIPACKAGE_ARGS* pArgs, + __inout BA_ONDETECTTARGETMSIPACKAGE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectMsiFeatureFallback( + __in BA_ONDETECTMSIFEATURE_ARGS* pArgs, + __inout BA_ONDETECTMSIFEATURE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnDetectPackageCompleteFallback( + __in BA_ONDETECTPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONDETECTPACKAGECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnPlanRelatedBundleFallback( + __in BA_ONPLANRELATEDBUNDLE_ARGS* pArgs, + __inout BA_ONPLANRELATEDBUNDLE_RESULTS* pResults + ) + { + BOOTSTRAPPER_REQUEST_STATE requestedState = pResults->requestedState; + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE, pArgs, pResults, m_pvBAFunctionsProcContext); + BalLogId(BOOTSTRAPPER_LOG_LEVEL_STANDARD, MSG_WIXSTDBA_PLANNED_RELATED_BUNDLE, m_hModule, pArgs->wzBundleId, LoggingRequestStateToString(requestedState), LoggingRequestStateToString(pResults->requestedState)); + } + + void OnPlanPackageBeginFallback( + __in BA_ONPLANPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults + ) + { + BOOTSTRAPPER_REQUEST_STATE requestedState = pResults->requestedState; + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + BalLogId(BOOTSTRAPPER_LOG_LEVEL_STANDARD, MSG_WIXSTDBA_PLANNED_PACKAGE, m_hModule, pArgs->wzPackageId, LoggingRequestStateToString(requestedState), LoggingRequestStateToString(pResults->requestedState)); + } + + void OnPlanCompatibleMsiPackageBeginFallback( + __in BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS* pResults + ) + { + BOOTSTRAPPER_REQUEST_STATE requestedState = pResults->requestedState; + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + BalLogId(BOOTSTRAPPER_LOG_LEVEL_STANDARD, MSG_WIXSTDBA_PLANNED_COMPATIBLE_MSI_PACKAGE, m_hModule, pArgs->wzPackageId, pArgs->wzCompatiblePackageId, LoggingRequestStateToString(requestedState), LoggingRequestStateToString(pResults->requestedState)); + } + + void OnPlanCompatibleMsiPackageCompleteFallback( + __in BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnPlanTargetMsiPackageFallback( + __in BA_ONPLANTARGETMSIPACKAGE_ARGS* pArgs, + __inout BA_ONPLANTARGETMSIPACKAGE_RESULTS* pResults + ) + { + BOOTSTRAPPER_REQUEST_STATE requestedState = pResults->requestedState; + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE, pArgs, pResults, m_pvBAFunctionsProcContext); + BalLogId(BOOTSTRAPPER_LOG_LEVEL_STANDARD, MSG_WIXSTDBA_PLANNED_TARGET_MSI_PACKAGE, m_hModule, pArgs->wzPackageId, pArgs->wzProductCode, LoggingRequestStateToString(requestedState), LoggingRequestStateToString(pResults->requestedState)); + } + + void OnPlanMsiFeatureFallback( + __in BA_ONPLANMSIFEATURE_ARGS* pArgs, + __inout BA_ONPLANMSIFEATURE_RESULTS* pResults + ) + { + BOOTSTRAPPER_FEATURE_STATE requestedState = pResults->requestedState; + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE, pArgs, pResults, m_pvBAFunctionsProcContext); + BalLogId(BOOTSTRAPPER_LOG_LEVEL_STANDARD, MSG_WIXSTDBA_PLANNED_MSI_FEATURE, m_hModule, pArgs->wzPackageId, pArgs->wzFeatureId, LoggingMsiFeatureStateToString(requestedState), LoggingMsiFeatureStateToString(pResults->requestedState)); + } + + void OnPlanPackageCompleteFallback( + __in BA_ONPLANPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONPLANPACKAGECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnApplyBeginFallback( + __in BA_ONAPPLYBEGIN_ARGS* pArgs, + __inout BA_ONAPPLYBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnElevateBeginFallback( + __in BA_ONELEVATEBEGIN_ARGS* pArgs, + __inout BA_ONELEVATEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnElevateCompleteFallback( + __in BA_ONELEVATECOMPLETE_ARGS* pArgs, + __inout BA_ONELEVATECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnProgressFallback( + __in BA_ONPROGRESS_ARGS* pArgs, + __inout BA_ONPROGRESS_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONPROGRESS, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnErrorFallback( + __in BA_ONERROR_ARGS* pArgs, + __inout BA_ONERROR_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONERROR, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnRegisterBeginFallback( + __in BA_ONREGISTERBEGIN_ARGS* pArgs, + __inout BA_ONREGISTERBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnRegisterCompleteFallback( + __in BA_ONREGISTERCOMPLETE_ARGS* pArgs, + __inout BA_ONREGISTERCOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheBeginFallback( + __in BA_ONCACHEBEGIN_ARGS* pArgs, + __inout BA_ONCACHEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCachePackageBeginFallback( + __in BA_ONCACHEPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONCACHEPACKAGEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheAcquireBeginFallback( + __in BA_ONCACHEACQUIREBEGIN_ARGS* pArgs, + __inout BA_ONCACHEACQUIREBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheAcquireProgressFallback( + __in BA_ONCACHEACQUIREPROGRESS_ARGS* pArgs, + __inout BA_ONCACHEACQUIREPROGRESS_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnResolveSourceFallback( + __in BA_ONRESOLVESOURCE_ARGS* pArgs, + __inout BA_ONRESOLVESOURCE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheAcquireCompleteFallback( + __in BA_ONCACHEACQUIRECOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEACQUIRECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheVerifyBeginFallback( + __in BA_ONCACHEVERIFYBEGIN_ARGS* pArgs, + __inout BA_ONCACHEVERIFYBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheVerifyCompleteFallback( + __in BA_ONCACHEVERIFYCOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEVERIFYCOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCachePackageCompleteFallback( + __in BA_ONCACHEPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONCACHEPACKAGECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnCacheCompleteFallback( + __in BA_ONCACHECOMPLETE_ARGS* pArgs, + __inout BA_ONCACHECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecuteBeginFallback( + __in BA_ONEXECUTEBEGIN_ARGS* pArgs, + __inout BA_ONEXECUTEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecutePackageBeginFallback( + __in BA_ONEXECUTEPACKAGEBEGIN_ARGS* pArgs, + __inout BA_ONEXECUTEPACKAGEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecutePatchTargetFallback( + __in BA_ONEXECUTEPATCHTARGET_ARGS* pArgs, + __inout BA_ONEXECUTEPATCHTARGET_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecuteProgressFallback( + __in BA_ONEXECUTEPROGRESS_ARGS* pArgs, + __inout BA_ONEXECUTEPROGRESS_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecuteMsiMessageFallback( + __in BA_ONEXECUTEMSIMESSAGE_ARGS* pArgs, + __inout BA_ONEXECUTEMSIMESSAGE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecuteFilesInUseFallback( + __in BA_ONEXECUTEFILESINUSE_ARGS* pArgs, + __inout BA_ONEXECUTEFILESINUSE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecutePackageCompleteFallback( + __in BA_ONEXECUTEPACKAGECOMPLETE_ARGS* pArgs, + __inout BA_ONEXECUTEPACKAGECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnExecuteCompleteFallback( + __in BA_ONEXECUTECOMPLETE_ARGS* pArgs, + __inout BA_ONEXECUTECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnUnregisterBeginFallback( + __in BA_ONUNREGISTERBEGIN_ARGS* pArgs, + __inout BA_ONUNREGISTERBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnUnregisterCompleteFallback( + __in BA_ONUNREGISTERCOMPLETE_ARGS* pArgs, + __inout BA_ONUNREGISTERCOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnApplyCompleteFallback( + __in BA_ONAPPLYCOMPLETE_ARGS* pArgs, + __inout BA_ONAPPLYCOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnLaunchApprovedExeBeginFallback( + __in BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS* pArgs, + __inout BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + void OnLaunchApprovedExeCompleteFallback( + __in BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS* pArgs, + __inout BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS* pResults + ) + { + m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, pArgs, pResults, m_pvBAFunctionsProcContext); + } + + // + // UiThreadProc - entrypoint for UI thread. + // + static DWORD WINAPI UiThreadProc( + __in LPVOID pvContext + ) + { + HRESULT hr = S_OK; + CWixStandardBootstrapperApplication* pThis = (CWixStandardBootstrapperApplication*)pvContext; + BOOL fComInitialized = FALSE; + BOOL fRet = FALSE; + MSG msg = { }; + + // Initialize COM and theme. + hr = ::CoInitialize(NULL); + BalExitOnFailure(hr, "Failed to initialize COM."); + fComInitialized = TRUE; + + hr = ThemeInitialize(pThis->m_hModule); + BalExitOnFailure(hr, "Failed to initialize theme manager."); + + hr = pThis->InitializeData(); + BalExitOnFailure(hr, "Failed to initialize data in bootstrapper application."); + + // Create main window. + pThis->InitializeTaskbarButton(); + hr = pThis->CreateMainWindow(); + BalExitOnFailure(hr, "Failed to create main window."); + + if (FAILED(pThis->m_hrFinal)) + { + pThis->SetState(WIXSTDBA_STATE_FAILED, hr); + ::PostMessageW(pThis->m_hWnd, WM_WIXSTDBA_SHOW_FAILURE, 0, 0); + } + else + { + // Okay, we're ready for packages now. + pThis->SetState(WIXSTDBA_STATE_INITIALIZED, hr); + ::PostMessageW(pThis->m_hWnd, BOOTSTRAPPER_ACTION_HELP == pThis->m_command.action ? WM_WIXSTDBA_SHOW_HELP : WM_WIXSTDBA_DETECT_PACKAGES, 0, 0); + } + + // message pump + while (0 != (fRet = ::GetMessageW(&msg, NULL, 0, 0))) + { + if (-1 == fRet) + { + hr = E_UNEXPECTED; + BalExitOnFailure(hr, "Unexpected return value from message pump."); + } + else if (!ThemeHandleKeyboardMessage(pThis->m_pTheme, msg.hwnd, &msg)) + { + ::TranslateMessage(&msg); + ::DispatchMessageW(&msg); + } + } + + // Succeeded thus far, check to see if anything went wrong while actually + // executing changes. + if (FAILED(pThis->m_hrFinal)) + { + hr = pThis->m_hrFinal; + } + else if (pThis->CheckCanceled()) + { + hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT); + } + + LExit: + // destroy main window + pThis->DestroyMainWindow(); + + // initiate engine shutdown + DWORD dwQuit = HRESULT_CODE(hr); + if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == pThis->m_restartResult) + { + dwQuit = ERROR_SUCCESS_REBOOT_INITIATED; + } + else if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == pThis->m_restartResult) + { + dwQuit = ERROR_SUCCESS_REBOOT_REQUIRED; + } + pThis->m_pEngine->Quit(dwQuit); + + ReleaseTheme(pThis->m_pTheme); + ThemeUninitialize(); + + // uninitialize COM + if (fComInitialized) + { + ::CoUninitialize(); + } + + return hr; + } + + + // + // InitializeData - initializes all the package and prerequisite information. + // + HRESULT InitializeData() + { + HRESULT hr = S_OK; + LPWSTR sczModulePath = NULL; + IXMLDOMDocument *pixdManifest = NULL; + + hr = BalManifestLoad(m_hModule, &pixdManifest); + BalExitOnFailure(hr, "Failed to load bootstrapper application manifest."); + + hr = ParseOverridableVariablesFromXml(pixdManifest); + BalExitOnFailure(hr, "Failed to read overridable variables."); + + hr = ProcessCommandLine(&m_sczLanguage); + ExitOnFailure(hr, "Unknown commandline parameters."); + + hr = PathRelativeToModule(&sczModulePath, NULL, m_hModule); + BalExitOnFailure(hr, "Failed to get module path."); + + hr = LoadLocalization(sczModulePath, m_sczLanguage); + ExitOnFailure(hr, "Failed to load localization."); + + hr = LoadTheme(sczModulePath, m_sczLanguage); + ExitOnFailure(hr, "Failed to load theme."); + + hr = BalInfoParseFromXml(&m_Bundle, pixdManifest); + BalExitOnFailure(hr, "Failed to load bundle information."); + + hr = BalConditionsParseFromXml(&m_Conditions, pixdManifest, m_pWixLoc); + BalExitOnFailure(hr, "Failed to load conditions from XML."); + + hr = LoadBAFunctions(pixdManifest); + BalExitOnFailure(hr, "Failed to load bootstrapper functions."); + + GetBundleFileVersion(); + // don't fail if we couldn't get the version info; best-effort only + + if (m_fPrereq) + { + hr = ParsePrerequisiteInformationFromXml(pixdManifest); + BalExitOnFailure(hr, "Failed to read prerequisite information."); + } + else + { + hr = ParseBootstrapperApplicationDataFromXml(pixdManifest); + BalExitOnFailure(hr, "Failed to read bootstrapper application data."); + } + + LExit: + ReleaseObject(pixdManifest); + ReleaseStr(sczModulePath); + + return hr; + } + + + // + // ProcessCommandLine - process the provided command line arguments. + // + HRESULT ProcessCommandLine( + __inout LPWSTR* psczLanguage + ) + { + HRESULT hr = S_OK; + int argc = 0; + LPWSTR* argv = NULL; + LPWSTR sczVariableName = NULL; + LPWSTR sczVariableValue = NULL; + + if (m_command.wzCommandLine && *m_command.wzCommandLine) + { + hr = AppParseCommandLine(m_command.wzCommandLine, &argc, &argv); + ExitOnFailure(hr, "Failed to parse command line."); + + for (int i = 0; i < argc; ++i) + { + if (argv[i][0] == L'-' || argv[i][0] == L'/') + { + if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"lang", -1)) + { + if (i + 1 >= argc) + { + hr = E_INVALIDARG; + BalExitOnFailure(hr, "Must specify a language."); + } + + ++i; + + hr = StrAllocString(psczLanguage, &argv[i][0], 0); + BalExitOnFailure(hr, "Failed to copy language."); + } + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"cache", -1)) + { + m_plannedAction = BOOTSTRAPPER_ACTION_CACHE; + } + else if (m_sdOverridableVariables) + { + const wchar_t* pwc = wcschr(argv[i], L'='); + if (pwc) + { + hr = StrAllocString(&sczVariableName, argv[i], pwc - argv[i]); + BalExitOnFailure(hr, "Failed to copy variable name."); + + hr = DictKeyExists(m_sdOverridableVariables, sczVariableName); + if (E_NOTFOUND == hr) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to set non-overridable variable: '%ls'.", sczVariableName); + hr = S_OK; + continue; + } + ExitOnFailure(hr, "Failed to check the dictionary of overridable variables."); + + hr = StrAllocString(&sczVariableValue, ++pwc, 0); + BalExitOnFailure(hr, "Failed to copy variable value."); + + hr = m_pEngine->SetVariableString(sczVariableName, sczVariableValue); + BalExitOnFailure(hr, "Failed to set variable."); + } + else + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Ignoring unknown argument: %ls", argv[i]); + } + } + } + } + + LExit: + if (argv) + { + AppFreeCommandLineArgs(argv); + } + + ReleaseStr(sczVariableName); + ReleaseStr(sczVariableValue); + + return hr; + } + + HRESULT LoadLocalization( + __in_z LPCWSTR wzModulePath, + __in_z_opt LPCWSTR wzLanguage + ) + { + HRESULT hr = S_OK; + LPWSTR sczLocPath = NULL; + LPWSTR sczFormatted = NULL; + LPCWSTR wzLocFileName = m_fPrereq ? L"mbapreq.wxl" : L"thm.wxl"; + + // Find and load .wxl file. + hr = LocProbeForFile(wzModulePath, wzLocFileName, wzLanguage, &sczLocPath); + BalExitOnFailure(hr, "Failed to probe for loc file: %ls in path: %ls", wzLocFileName, wzModulePath); + + hr = LocLoadFromFile(sczLocPath, &m_pWixLoc); + BalExitOnFailure(hr, "Failed to load loc file from path: %ls", sczLocPath); + + // Set WixStdBALanguageId to .wxl language id. + if (WIX_LOCALIZATION_LANGUAGE_NOT_SET != m_pWixLoc->dwLangId) + { + ::SetThreadLocale(m_pWixLoc->dwLangId); + + hr = m_pEngine->SetVariableNumeric(WIXSTDBA_VARIABLE_LANGUAGE_ID, m_pWixLoc->dwLangId); + BalExitOnFailure(hr, "Failed to set WixStdBALanguageId variable."); + } + + // Load ConfirmCancelMessage. + hr = StrAllocString(&m_sczConfirmCloseMessage, L"#(loc.ConfirmCancelMessage)", 0); + ExitOnFailure(hr, "Failed to initialize confirm message loc identifier."); + + hr = LocLocalizeString(m_pWixLoc, &m_sczConfirmCloseMessage); + BalExitOnFailure(hr, "Failed to localize confirm close message: %ls", m_sczConfirmCloseMessage); + + hr = BalFormatString(m_sczConfirmCloseMessage, &sczFormatted); + if (SUCCEEDED(hr)) + { + ReleaseStr(m_sczConfirmCloseMessage); + m_sczConfirmCloseMessage = sczFormatted; + sczFormatted = NULL; + } + + LExit: + ReleaseStr(sczFormatted); + ReleaseStr(sczLocPath); + + return hr; + } + + + HRESULT LoadTheme( + __in_z LPCWSTR wzModulePath, + __in_z_opt LPCWSTR wzLanguage + ) + { + HRESULT hr = S_OK; + LPWSTR sczThemePath = NULL; + LPCWSTR wzThemeFileName = m_fPrereq ? L"mbapreq.thm" : L"thm.xml"; + + hr = LocProbeForFile(wzModulePath, wzThemeFileName, wzLanguage, &sczThemePath); + BalExitOnFailure(hr, "Failed to probe for theme file: %ls in path: %ls", wzThemeFileName, wzModulePath); + + hr = ThemeLoadFromFile(sczThemePath, &m_pTheme); + BalExitOnFailure(hr, "Failed to load theme from path: %ls", sczThemePath); + + hr = ThemeRegisterVariableCallbacks(m_pTheme, EvaluateVariableConditionCallback, FormatVariableStringCallback, GetVariableNumericCallback, SetVariableNumericCallback, GetVariableStringCallback, SetVariableStringCallback, NULL); + BalExitOnFailure(hr, "Failed to register variable theme callbacks."); + + hr = ThemeLocalize(m_pTheme, m_pWixLoc); + BalExitOnFailure(hr, "Failed to localize theme: %ls", sczThemePath); + + LExit: + ReleaseStr(sczThemePath); + + return hr; + } + + + HRESULT ParseOverridableVariablesFromXml( + __in IXMLDOMDocument* pixdManifest + ) + { + HRESULT hr = S_OK; + IXMLDOMNode* pNode = NULL; + IXMLDOMNodeList* pNodes = NULL; + DWORD cNodes = 0; + LPWSTR scz = NULL; + + // Get the list of variables users can override on the command line. + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOverridableVariable", &pNodes); + if (S_FALSE == hr) + { + ExitFunction1(hr = S_OK); + } + ExitOnFailure(hr, "Failed to select overridable variable nodes."); + + hr = pNodes->get_length((long*)&cNodes); + ExitOnFailure(hr, "Failed to get overridable variable node count."); + + if (cNodes) + { + hr = DictCreateStringList(&m_sdOverridableVariables, 32, DICT_FLAG_NONE); + ExitOnFailure(hr, "Failed to create the string dictionary."); + + for (DWORD i = 0; i < cNodes; ++i) + { + hr = XmlNextElement(pNodes, &pNode, NULL); + ExitOnFailure(hr, "Failed to get next node."); + + // @Name + hr = XmlGetAttributeEx(pNode, L"Name", &scz); + ExitOnFailure(hr, "Failed to get @Name."); + + hr = DictAddKey(m_sdOverridableVariables, scz); + ExitOnFailure(hr, "Failed to add \"%ls\" to the string dictionary.", scz); + + // prepare next iteration + ReleaseNullObject(pNode); + } + } + + LExit: + ReleaseObject(pNode); + ReleaseObject(pNodes); + ReleaseStr(scz); + return hr; + } + + + HRESULT ParsePrerequisiteInformationFromXml( + __in IXMLDOMDocument* pixdManifest + ) + { + HRESULT hr = S_OK; + IXMLDOMNode* pNode = NULL; + IXMLDOMNodeList* pNodes = NULL; + DWORD cNodes = 0; + LPWSTR scz = NULL; + WIXSTDBA_PREREQ_PACKAGE* pPrereqPackage = NULL; + BAL_INFO_PACKAGE* pPackage = NULL; + + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixMbaPrereqInformation", &pNodes); + if (S_FALSE == hr) + { + hr = E_INVALIDARG; + BalExitOnFailure(hr, "BootstrapperApplication.xml manifest is missing prerequisite information."); + } + BalExitOnFailure(hr, "Failed to select prerequisite information nodes."); + + hr = pNodes->get_length((long*)&cNodes); + BalExitOnFailure(hr, "Failed to get prerequisite information node count."); + + m_cPrereqPackages = cNodes; + m_rgPrereqPackages = static_cast(MemAlloc(sizeof(WIXSTDBA_PREREQ_PACKAGE) * m_cPrereqPackages, TRUE)); + + hr = DictCreateWithEmbeddedKey(&m_shPrereqSupportPackages, m_cPrereqPackages, reinterpret_cast(&m_rgPrereqPackages), offsetof(WIXSTDBA_PREREQ_PACKAGE, sczPackageId), DICT_FLAG_NONE); + BalExitOnFailure(hr, "Failed to create the prerequisite package dictionary."); + + for (DWORD i = 0; i < cNodes; ++i) + { + hr = XmlNextElement(pNodes, &pNode, NULL); + BalExitOnFailure(hr, "Failed to get next node."); + + hr = XmlGetAttributeEx(pNode, L"PackageId", &scz); + BalExitOnFailure(hr, "Failed to get @PackageId."); + + hr = DictGetValue(m_shPrereqSupportPackages, scz, reinterpret_cast(&pPrereqPackage)); + if (SUCCEEDED(hr)) + { + hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); + BalExitOnFailure(hr, "Duplicate prerequisite information: %ls", scz); + } + else if (E_NOTFOUND != hr) + { + BalExitOnFailure(hr, "Failed to check if \"%ls\" was in the prerequisite package dictionary.", scz); + } + + hr = BalInfoFindPackageById(&m_Bundle.packages, scz, &pPackage); + BalExitOnFailure(hr, "Failed to get info about \"%ls\" from BootstrapperApplicationData.", scz); + + pPrereqPackage = &m_rgPrereqPackages[i]; + pPrereqPackage->sczPackageId = pPackage->sczId; + hr = DictAddValue(m_shPrereqSupportPackages, pPrereqPackage); + BalExitOnFailure(hr, "Failed to add \"%ls\" to the prerequisite package dictionary.", pPrereqPackage->sczPackageId); + + hr = XmlGetAttributeEx(pNode, L"LicenseFile", &scz); + if (E_NOTFOUND != hr) + { + BalExitOnFailure(hr, "Failed to get @LicenseFile."); + + if (m_sczLicenseFile) + { + hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); + BalExitOnFailure(hr, "More than one license file specified in prerequisite info."); + } + + m_sczLicenseFile = scz; + scz = NULL; + } + + hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &scz); + if (E_NOTFOUND != hr) + { + BalExitOnFailure(hr, "Failed to get @LicenseUrl."); + + if (m_sczLicenseUrl) + { + hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); + BalExitOnFailure(hr, "More than one license URL specified in prerequisite info."); + } + + m_sczLicenseUrl = scz; + scz = NULL; + } + + // Prepare next iteration. + ReleaseNullObject(pNode); + } + + LExit: + ReleaseObject(pNode); + ReleaseObject(pNodes); + ReleaseStr(scz); + return hr; + } + + + HRESULT ParseBootstrapperApplicationDataFromXml( + __in IXMLDOMDocument* pixdManifest + ) + { + HRESULT hr = S_OK; + IXMLDOMNode* pNode = NULL; + DWORD dwBool = 0; + + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixStdbaInformation", &pNode); + if (S_FALSE == hr) + { + hr = E_INVALIDARG; + } + BalExitOnFailure(hr, "BootstrapperApplication.xml manifest is missing wixstdba information."); + + hr = XmlGetAttributeEx(pNode, L"LicenseFile", &m_sczLicenseFile); + if (E_NOTFOUND == hr) + { + hr = S_OK; + } + BalExitOnFailure(hr, "Failed to get license file."); + + hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &m_sczLicenseUrl); + if (E_NOTFOUND == hr) + { + hr = S_OK; + } + BalExitOnFailure(hr, "Failed to get license URL."); + + ReleaseObject(pNode); + + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOptions", &pNode); + if (S_FALSE == hr) + { + ExitFunction1(hr = S_OK); + } + BalExitOnFailure(hr, "Failed to read wixstdba options from BootstrapperApplication.xml manifest."); + + hr = XmlGetAttributeNumber(pNode, L"SuppressOptionsUI", &dwBool); + if (S_FALSE == hr) + { + hr = S_OK; + } + else if (SUCCEEDED(hr) && dwBool) + { + hr = BalSetNumericVariable(WIXSTDBA_VARIABLE_SUPPRESS_OPTIONS_UI, 1); + BalExitOnFailure(hr, "Failed to set '%ls' variable.", WIXSTDBA_VARIABLE_SUPPRESS_OPTIONS_UI); + } + BalExitOnFailure(hr, "Failed to get SuppressOptionsUI value."); + + dwBool = 0; + hr = XmlGetAttributeNumber(pNode, L"SuppressDowngradeFailure", &dwBool); + if (S_FALSE == hr) + { + hr = S_OK; + } + else if (SUCCEEDED(hr)) + { + m_fSuppressDowngradeFailure = 0 < dwBool; + } + BalExitOnFailure(hr, "Failed to get SuppressDowngradeFailure value."); + + dwBool = 0; + hr = XmlGetAttributeNumber(pNode, L"SuppressRepair", &dwBool); + if (S_FALSE == hr) + { + hr = S_OK; + } + else if (SUCCEEDED(hr)) + { + m_fSuppressRepair = 0 < dwBool; + } + BalExitOnFailure(hr, "Failed to get SuppressRepair value."); + + hr = XmlGetAttributeNumber(pNode, L"ShowVersion", &dwBool); + if (S_FALSE == hr) + { + hr = S_OK; + } + else if (SUCCEEDED(hr) && dwBool) + { + hr = BalSetNumericVariable(WIXSTDBA_VARIABLE_SHOW_VERSION, 1); + BalExitOnFailure(hr, "Failed to set '%ls' variable.", WIXSTDBA_VARIABLE_SHOW_VERSION); + } + BalExitOnFailure(hr, "Failed to get ShowVersion value."); + + hr = XmlGetAttributeNumber(pNode, L"SupportCacheOnly", &dwBool); + if (S_FALSE == hr) + { + hr = S_OK; + } + else if (SUCCEEDED(hr)) + { + m_fSupportCacheOnly = 0 < dwBool; + } + BalExitOnFailure(hr, "Failed to get SupportCacheOnly value."); + + LExit: + ReleaseObject(pNode); + return hr; + } + + HRESULT GetPrereqPackage( + __in_z LPCWSTR wzPackageId, + __out WIXSTDBA_PREREQ_PACKAGE** ppPrereqPackage, + __out BAL_INFO_PACKAGE** ppPackage + ) + { + HRESULT hr = E_NOTFOUND; + WIXSTDBA_PREREQ_PACKAGE* pPrereqPackage = NULL; + BAL_INFO_PACKAGE* pPackage = NULL; + + Assert(wzPackageId && *wzPackageId); + Assert(ppPackage); + Assert(ppPrereqPackage); + + if (m_shPrereqSupportPackages) + { + hr = DictGetValue(m_shPrereqSupportPackages, wzPackageId, reinterpret_cast(&pPrereqPackage)); + if (E_NOTFOUND != hr) + { + ExitOnFailure(hr, "Failed to check the dictionary of prerequisite packages."); + + // Ignore error. + BalInfoFindPackageById(&m_Bundle.packages, wzPackageId, &pPackage); + } + } + + if (pPrereqPackage) + { + *ppPrereqPackage = pPrereqPackage; + *ppPackage = pPackage; + } + LExit: + return hr; + } + + + // + // Get the file version of the bootstrapper and record in bootstrapper log file + // + HRESULT GetBundleFileVersion() + { + HRESULT hr = S_OK; + ULARGE_INTEGER uliVersion = { }; + LPWSTR sczCurrentPath = NULL; + + hr = PathForCurrentProcess(&sczCurrentPath, NULL); + BalExitOnFailure(hr, "Failed to get bundle path."); + + hr = FileVersion(sczCurrentPath, &uliVersion.HighPart, &uliVersion.LowPart); + BalExitOnFailure(hr, "Failed to get bundle file version."); + + hr = m_pEngine->SetVariableVersion(WIXSTDBA_VARIABLE_BUNDLE_FILE_VERSION, uliVersion.QuadPart); + BalExitOnFailure(hr, "Failed to set WixBundleFileVersion variable."); + + LExit: + ReleaseStr(sczCurrentPath); + + return hr; + } + + + // + // CreateMainWindow - creates the main install window. + // + HRESULT CreateMainWindow() + { + HRESULT hr = S_OK; + HICON hIcon = reinterpret_cast(m_pTheme->hIcon); + WNDCLASSW wc = { }; + DWORD dwWindowStyle = 0; + int x = CW_USEDEFAULT; + int y = CW_USEDEFAULT; + POINT ptCursor = { }; + HMONITOR hMonitor = NULL; + MONITORINFO mi = { }; + + // If the theme did not provide an icon, try using the icon from the bundle engine. + if (!hIcon) + { + HMODULE hBootstrapperEngine = ::GetModuleHandleW(NULL); + if (hBootstrapperEngine) + { + hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1)); + } + } + + // Register the window class and create the window. + wc.lpfnWndProc = CWixStandardBootstrapperApplication::WndProc; + wc.hInstance = m_hModule; + wc.hIcon = hIcon; + wc.hCursor = ::LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + wc.hbrBackground = m_pTheme->rgFonts[m_pTheme->dwFontId].hBackground; + wc.lpszMenuName = NULL; + wc.lpszClassName = WIXSTDBA_WINDOW_CLASS; + if (!::RegisterClassW(&wc)) + { + ExitWithLastError(hr, "Failed to register window."); + } + + m_fRegistered = TRUE; + + // Calculate the window style based on the theme style and command display value. + dwWindowStyle = m_pTheme->dwStyle; + if (BOOTSTRAPPER_DISPLAY_NONE >= m_command.display) + { + dwWindowStyle &= ~WS_VISIBLE; + } + + // Don't show the window if there is a splash screen (it will be made visible when the splash screen is hidden) + if (::IsWindow(m_command.hwndSplashScreen)) + { + dwWindowStyle &= ~WS_VISIBLE; + } + + // Center the window on the monitor with the mouse. + if (::GetCursorPos(&ptCursor)) + { + hMonitor = ::MonitorFromPoint(ptCursor, MONITOR_DEFAULTTONEAREST); + if (hMonitor) + { + mi.cbSize = sizeof(mi); + if (::GetMonitorInfoW(hMonitor, &mi)) + { + x = mi.rcWork.left + (mi.rcWork.right - mi.rcWork.left - m_pTheme->nWidth) / 2; + y = mi.rcWork.top + (mi.rcWork.bottom - mi.rcWork.top - m_pTheme->nHeight) / 2; + } + } + } + + m_hWnd = ::CreateWindowExW(0, wc.lpszClassName, m_pTheme->sczCaption, dwWindowStyle, x, y, m_pTheme->nWidth, m_pTheme->nHeight, HWND_DESKTOP, NULL, m_hModule, this); + ExitOnNullWithLastError(m_hWnd, hr, "Failed to create window."); + + hr = S_OK; + + LExit: + return hr; + } + + + // + // InitializeTaskbarButton - initializes taskbar button for progress. + // + void InitializeTaskbarButton() + { + HRESULT hr = S_OK; + + hr = ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, __uuidof(ITaskbarList3), reinterpret_cast(&m_pTaskbarList)); + if (REGDB_E_CLASSNOTREG == hr) // not supported before Windows 7 + { + ExitFunction1(hr = S_OK); + } + BalExitOnFailure(hr, "Failed to create ITaskbarList3. Continuing."); + + m_uTaskbarButtonCreatedMessage = ::RegisterWindowMessageW(L"TaskbarButtonCreated"); + BalExitOnNullWithLastError(m_uTaskbarButtonCreatedMessage, hr, "Failed to get TaskbarButtonCreated message. Continuing."); + + LExit: + return; + } + + // + // DestroyMainWindow - clean up all the window registration. + // + void DestroyMainWindow() + { + if (::IsWindow(m_hWnd)) + { + ::DestroyWindow(m_hWnd); + m_hWnd = NULL; + m_fTaskbarButtonOK = FALSE; + } + + if (m_fRegistered) + { + ::UnregisterClassW(WIXSTDBA_WINDOW_CLASS, m_hModule); + m_fRegistered = FALSE; + } + } + + static LRESULT CallDefaultWndProc( + __in CWixStandardBootstrapperApplication* pBA, + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam + ) + { + LRESULT lres = NULL; + THEME* pTheme = NULL; + HRESULT hr = S_OK; + BA_FUNCTIONS_WNDPROC_ARGS wndProcArgs = { }; + BA_FUNCTIONS_WNDPROC_RESULTS wndProcResults = { }; + + if (pBA) + { + pTheme = pBA->m_pTheme; + + if (pBA->m_pfnBAFunctionsProc) + { + wndProcArgs.cbSize = sizeof(wndProcArgs); + wndProcArgs.pTheme = pTheme; + wndProcArgs.hWnd = hWnd; + wndProcArgs.uMsg = uMsg; + wndProcArgs.wParam = wParam; + wndProcArgs.lParam = lParam; + wndProcResults.cbSize = sizeof(wndProcResults); + + hr = pBA->m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_WNDPROC, &wndProcArgs, &wndProcResults, pBA->m_pvBAFunctionsProcContext); + if (E_NOTIMPL != hr) + { + lres = wndProcResults.lres; + ExitFunction(); + } + } + } + + lres = ThemeDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); + + LExit: + return lres; + } + + // + // WndProc - standard windows message handler. + // + static LRESULT CALLBACK WndProc( + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam + ) + { +#pragma warning(suppress:4312) + CWixStandardBootstrapperApplication* pBA = reinterpret_cast(::GetWindowLongPtrW(hWnd, GWLP_USERDATA)); + BOOL fCancel = FALSE; + + switch (uMsg) + { + case WM_NCCREATE: + { + LPCREATESTRUCT lpcs = reinterpret_cast(lParam); + pBA = reinterpret_cast(lpcs->lpCreateParams); +#pragma warning(suppress:4244) + ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast(pBA)); + } + break; + + case WM_NCDESTROY: + { + LRESULT lres = CallDefaultWndProc(pBA, hWnd, uMsg, wParam, lParam); + ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, 0); + ::PostQuitMessage(0); + return lres; + } + + case WM_CREATE: + if (!pBA->OnCreate(hWnd)) + { + return -1; + } + break; + + case WM_QUERYENDSESSION: + fCancel = true; + pBA->OnSystemShutdown(static_cast(lParam), &fCancel); + return !fCancel; + + case WM_CLOSE: + // If the user chose not to close, do *not* let the default window proc handle the message. + if (!pBA->OnClose()) + { + return 0; + } + break; + + case WM_WIXSTDBA_SHOW_HELP: + pBA->OnShowHelp(); + return 0; + + case WM_WIXSTDBA_DETECT_PACKAGES: + pBA->OnDetect(); + return 0; + + case WM_WIXSTDBA_PLAN_PACKAGES: + pBA->OnPlan(static_cast(lParam)); + return 0; + + case WM_WIXSTDBA_APPLY_PACKAGES: + pBA->OnApply(); + return 0; + + case WM_WIXSTDBA_CHANGE_STATE: + pBA->OnChangeState(static_cast(lParam)); + return 0; + + case WM_WIXSTDBA_SHOW_FAILURE: + pBA->OnShowFailure(); + return 0; + + case WM_COMMAND: + switch (HIWORD(wParam)) + { + case BN_CLICKED: + switch (LOWORD(wParam)) + { + case WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX: + pBA->OnClickAcceptCheckbox(); + return 0; + + case WIXSTDBA_CONTROL_INSTALL_BUTTON: + pBA->OnClickInstallButton(); + return 0; + + case WIXSTDBA_CONTROL_REPAIR_BUTTON: + pBA->OnClickRepairButton(); + return 0; + + case WIXSTDBA_CONTROL_UNINSTALL_BUTTON: + pBA->OnClickUninstallButton(); + return 0; + + case WIXSTDBA_CONTROL_LAUNCH_BUTTON: + pBA->OnClickLaunchButton(); + return 0; + + case WIXSTDBA_CONTROL_SUCCESS_RESTART_BUTTON: __fallthrough; + case WIXSTDBA_CONTROL_FAILURE_RESTART_BUTTON: + pBA->OnClickRestartButton(); + return 0; + + case WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON: + pBA->OnClickCloseButton(); + return 0; + } + break; + } + break; + + case WM_NOTIFY: + if (lParam) + { + LPNMHDR pnmhdr = reinterpret_cast(lParam); + switch (pnmhdr->code) + { + case NM_CLICK: __fallthrough; + case NM_RETURN: + switch (static_cast(pnmhdr->idFrom)) + { + case WIXSTDBA_CONTROL_EULA_LINK: + pBA->OnClickEulaLink(); + return 1; + case WIXSTDBA_CONTROL_FAILURE_LOGFILE_LINK: + pBA->OnClickLogFileLink(); + return 1; + } + } + } + break; + } + + if (pBA && pBA->m_pTaskbarList && uMsg == pBA->m_uTaskbarButtonCreatedMessage) + { + pBA->m_fTaskbarButtonOK = TRUE; + return 0; + } + + return CallDefaultWndProc(pBA, hWnd, uMsg, wParam, lParam); + } + + + // + // OnCreate - finishes loading the theme. + // + BOOL OnCreate( + __in HWND hWnd + ) + { + HRESULT hr = S_OK; + LPWSTR sczLicenseFormatted = NULL; + LPWSTR sczLicensePath = NULL; + LPWSTR sczLicenseDirectory = NULL; + LPWSTR sczLicenseFilename = NULL; + BA_FUNCTIONS_ONTHEMELOADED_ARGS themeLoadedArgs = { }; + BA_FUNCTIONS_ONTHEMELOADED_RESULTS themeLoadedResults = { }; + + hr = ThemeLoadControls(m_pTheme, hWnd, vrgInitControls, countof(vrgInitControls)); + BalExitOnFailure(hr, "Failed to load theme controls."); + + C_ASSERT(COUNT_WIXSTDBA_PAGE == countof(vrgwzPageNames)); + C_ASSERT(countof(m_rgdwPageIds) == countof(vrgwzPageNames)); + + ThemeGetPageIds(m_pTheme, vrgwzPageNames, m_rgdwPageIds, countof(m_rgdwPageIds)); + + // Load the RTF EULA control with text if the control exists. + if (ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_EULA_RICHEDIT)) + { + hr = (m_sczLicenseFile && *m_sczLicenseFile) ? S_OK : E_INVALIDDATA; + if (SUCCEEDED(hr)) + { + hr = StrAllocString(&sczLicenseFormatted, m_sczLicenseFile, 0); + if (SUCCEEDED(hr)) + { + hr = LocLocalizeString(m_pWixLoc, &sczLicenseFormatted); + if (SUCCEEDED(hr)) + { + // Assume there is no hidden variables to be formatted + // so don't worry about securely freeing it. + hr = BalFormatString(sczLicenseFormatted, &sczLicenseFormatted); + if (SUCCEEDED(hr)) + { + hr = PathRelativeToModule(&sczLicensePath, sczLicenseFormatted, m_hModule); + if (SUCCEEDED(hr)) + { + hr = PathGetDirectory(sczLicensePath, &sczLicenseDirectory); + if (SUCCEEDED(hr)) + { + hr = StrAllocString(&sczLicenseFilename, PathFile(sczLicenseFormatted), 0); + if (SUCCEEDED(hr)) + { + hr = LocProbeForFile(sczLicenseDirectory, sczLicenseFilename, m_sczLanguage, &sczLicensePath); + if (SUCCEEDED(hr)) + { + hr = ThemeLoadRichEditFromFile(m_pTheme, WIXSTDBA_CONTROL_EULA_RICHEDIT, sczLicensePath, m_hModule); + } + } + } + } + } + } + } + } + + if (FAILED(hr)) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load file into license richedit control from path '%ls' manifest value: %ls", sczLicensePath, m_sczLicenseFile); + hr = S_OK; + } + } + + if (m_pfnBAFunctionsProc) + { + themeLoadedArgs.cbSize = sizeof(themeLoadedArgs); + themeLoadedArgs.pTheme = m_pTheme; + themeLoadedArgs.pWixLoc = m_pWixLoc; + themeLoadedResults.cbSize = sizeof(themeLoadedResults); + hr = m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONTHEMELOADED, &themeLoadedArgs, &themeLoadedResults, m_pvBAFunctionsProcContext); + BalExitOnFailure(hr, "BAFunctions OnThemeLoaded failed."); + } + + LExit: + ReleaseStr(sczLicenseFilename); + ReleaseStr(sczLicenseDirectory); + ReleaseStr(sczLicensePath); + ReleaseStr(sczLicenseFormatted); + + return SUCCEEDED(hr); + } + + + // + // OnShowFailure - display the failure page. + // + void OnShowFailure() + { + SetState(WIXSTDBA_STATE_FAILED, S_OK); + + // If the UI should be visible, display it now and hide the splash screen + if (BOOTSTRAPPER_DISPLAY_NONE < m_command.display) + { + ::ShowWindow(m_pTheme->hwndParent, SW_SHOW); + } + + m_pEngine->CloseSplashScreen(); + + return; + } + + + // + // OnShowHelp - display the help page. + // + void OnShowHelp() + { + SetState(WIXSTDBA_STATE_HELP, S_OK); + + // If the UI should be visible, display it now and hide the splash screen + if (BOOTSTRAPPER_DISPLAY_NONE < m_command.display) + { + ::ShowWindow(m_pTheme->hwndParent, SW_SHOW); + } + + m_pEngine->CloseSplashScreen(); + + return; + } + + + // + // OnDetect - start the processing of packages. + // + void OnDetect() + { + HRESULT hr = S_OK; + + SetState(WIXSTDBA_STATE_DETECTING, hr); + + // If the UI should be visible, display it now and hide the splash screen + if (BOOTSTRAPPER_DISPLAY_NONE < m_command.display) + { + ::ShowWindow(m_pTheme->hwndParent, SW_SHOW); + } + + m_pEngine->CloseSplashScreen(); + + // Tell the core we're ready for the packages to be processed now. + hr = m_pEngine->Detect(); + BalExitOnFailure(hr, "Failed to start detecting chain."); + + LExit: + if (FAILED(hr)) + { + SetState(WIXSTDBA_STATE_DETECTING, hr); + } + + return; + } + + + // + // OnPlan - plan the detected changes. + // + void OnPlan( + __in BOOTSTRAPPER_ACTION action + ) + { + HRESULT hr = S_OK; + + m_plannedAction = action; + + // If we are going to apply a downgrade, bail. + if (m_fDowngrading && BOOTSTRAPPER_ACTION_UNINSTALL < action) + { + if (m_fSuppressDowngradeFailure) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "A newer version of this product is installed but downgrade failure has been suppressed; continuing..."); + } + else + { + hr = HRESULT_FROM_WIN32(ERROR_PRODUCT_VERSION); + BalExitOnFailure(hr, "Cannot install a product when a newer version is installed."); + } + } + + SetState(WIXSTDBA_STATE_PLANNING, hr); + + hr = m_pEngine->Plan(action); + BalExitOnFailure(hr, "Failed to start planning packages."); + + LExit: + if (FAILED(hr)) + { + SetState(WIXSTDBA_STATE_PLANNING, hr); + } + + return; + } + + + // + // OnApply - apply the packages. + // + void OnApply() + { + HRESULT hr = S_OK; + + SetState(WIXSTDBA_STATE_APPLYING, hr); + SetProgressState(hr); + SetTaskbarButtonProgress(0); + + hr = m_pEngine->Apply(m_hWnd); + BalExitOnFailure(hr, "Failed to start applying packages."); + + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, TRUE); // ensure the cancel button is enabled before starting. + + LExit: + if (FAILED(hr)) + { + SetState(WIXSTDBA_STATE_APPLYING, hr); + } + + return; + } + + + // + // OnChangeState - change state. + // + void OnChangeState( + __in WIXSTDBA_STATE state + ) + { + WIXSTDBA_STATE stateOld = m_state; + DWORD dwOldPageId = 0; + DWORD dwNewPageId = 0; + LPWSTR sczText = NULL; + LPWSTR sczUnformattedText = NULL; + LPWSTR sczControlState = NULL; + LPWSTR sczControlName = NULL; + + m_state = state; + + // If our install is at the end (success or failure) and we're not showing full UI or + // we successfully installed the prerequisite then exit (prompt for restart if required). + if ((WIXSTDBA_STATE_APPLIED <= m_state && BOOTSTRAPPER_DISPLAY_FULL > m_command.display) || + (WIXSTDBA_STATE_APPLIED == m_state && m_fPrereq)) + { + // If a restart was required but we were not automatically allowed to + // accept the reboot then do the prompt. + if (m_fRestartRequired && !m_fAllowRestart) + { + StrAllocFromError(&sczUnformattedText, HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED), NULL); + + int nResult = ::MessageBoxW(m_hWnd, sczUnformattedText ? sczUnformattedText : L"The requested operation is successful. Changes will not be effective until the system is rebooted.", m_pTheme->sczCaption, MB_ICONEXCLAMATION | MB_OKCANCEL); + m_fAllowRestart = (IDOK == nResult); + } + + // Quietly exit. + ::PostMessageW(m_hWnd, WM_CLOSE, 0, 0); + } + else // try to change the pages. + { + DeterminePageId(stateOld, &dwOldPageId); + DeterminePageId(m_state, &dwNewPageId); + + if (dwOldPageId != dwNewPageId) + { + // Enable disable controls per-page. + if (m_rgdwPageIds[WIXSTDBA_PAGE_INSTALL] == dwNewPageId) // on the "Install" page, ensure the install button is enabled/disabled correctly. + { + LONGLONG llElevated = 0; + if (m_Bundle.fPerMachine) + { + BalGetNumericVariable(WIXBUNDLE_VARIABLE_ELEVATED, &llElevated); + } + ThemeControlElevates(m_pTheme, WIXSTDBA_CONTROL_INSTALL_BUTTON, (m_Bundle.fPerMachine && !llElevated)); + + // If the EULA control exists, show it only if a license URL is provided as well. + if (ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_EULA_LINK)) + { + BOOL fEulaLink = (m_sczLicenseUrl && *m_sczLicenseUrl); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_EULA_LINK, fEulaLink); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX, fEulaLink); + } + + BOOL fAcceptedLicense = !ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX) || !ThemeControlEnabled(m_pTheme, WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX) || ThemeIsControlChecked(m_pTheme, WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_INSTALL_BUTTON, fAcceptedLicense); + } + else if (m_rgdwPageIds[WIXSTDBA_PAGE_MODIFY] == dwNewPageId) + { + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_REPAIR_BUTTON, !m_fSuppressRepair); + } + else if (m_rgdwPageIds[WIXSTDBA_PAGE_SUCCESS] == dwNewPageId) // on the "Success" page, check if the restart or launch button should be enabled. + { + BOOL fShowRestartButton = FALSE; + BOOL fLaunchTargetExists = FALSE; + if (m_fRestartRequired) + { + if (BOOTSTRAPPER_RESTART_PROMPT == m_command.restart) + { + fShowRestartButton = TRUE; + } + } + else if (ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_LAUNCH_BUTTON)) + { + fLaunchTargetExists = BalStringVariableExists(WIXSTDBA_VARIABLE_LAUNCH_TARGET_PATH); + } + + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_LAUNCH_BUTTON, fLaunchTargetExists && BOOTSTRAPPER_ACTION_UNINSTALL < m_plannedAction); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_SUCCESS_RESTART_BUTTON, fShowRestartButton); + } + else if (m_rgdwPageIds[WIXSTDBA_PAGE_FAILURE] == dwNewPageId) // on the "Failure" page, show error message and check if the restart button should be enabled. + { + BOOL fShowLogLink = (m_Bundle.sczLogVariable && *m_Bundle.sczLogVariable); // if there is a log file variable then we'll assume the log file exists. + BOOL fShowErrorMessage = FALSE; + BOOL fShowRestartButton = FALSE; + + if (FAILED(m_hrFinal)) + { + // If we know the failure message, use that. + if (m_sczFailedMessage && *m_sczFailedMessage) + { + StrAllocString(&sczUnformattedText, m_sczFailedMessage, 0); + } + else if (E_MBAHOST_NET452_ON_WIN7RTM == m_hrFinal) + { + HRESULT hr = StrAllocString(&sczUnformattedText, L"#(loc.NET452WIN7RTMErrorMessage)", 0); + if (FAILED(hr)) + { + BalLogError(hr, "Failed to initialize NET452WIN7RTMErrorMessage loc identifier."); + } + else + { + hr = LocLocalizeString(m_pWixLoc, &sczUnformattedText); + if (FAILED(hr)) + { + BalLogError(hr, "Failed to localize NET452WIN7RTMErrorMessage: %ls", sczUnformattedText); + ReleaseNullStr(sczUnformattedText); + } + } + } + else // try to get the error message from the error code. + { + StrAllocFromError(&sczUnformattedText, m_hrFinal, NULL); + if (!sczUnformattedText || !*sczUnformattedText) + { + StrAllocFromError(&sczUnformattedText, E_FAIL, NULL); + } + } + + if (E_WIXSTDBA_CONDITION_FAILED == m_hrFinal) + { + if (sczUnformattedText) + { + StrAllocString(&sczText, sczUnformattedText, 0); + } + } + else if (E_MBAHOST_NET452_ON_WIN7RTM == m_hrFinal) + { + if (sczUnformattedText) + { + BalFormatString(sczUnformattedText, &sczText); + } + } + else + { + StrAllocFormatted(&sczText, L"0x%08x - %ls", m_hrFinal, sczUnformattedText); + } + + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_FAILURE_MESSAGE_TEXT, sczText); + fShowErrorMessage = TRUE; + } + + if (m_fRestartRequired) + { + if (BOOTSTRAPPER_RESTART_PROMPT == m_command.restart) + { + fShowRestartButton = TRUE; + } + } + + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_LOGFILE_LINK, fShowLogLink); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_MESSAGE_TEXT, fShowErrorMessage); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_RESTART_BUTTON, fShowRestartButton); + } + + HRESULT hr = ThemeShowPage(m_pTheme, dwOldPageId, SW_HIDE); + if (FAILED(hr)) + { + BalLogError(hr, "Failed to hide page: %u", dwOldPageId); + } + + hr = ThemeShowPage(m_pTheme, dwNewPageId, SW_SHOW); + if (FAILED(hr)) + { + BalLogError(hr, "Failed to show page: %u", dwOldPageId); + } + + // On the install page set the focus to the install button or the next enabled control if install is disabled. + if (m_rgdwPageIds[WIXSTDBA_PAGE_INSTALL] == dwNewPageId) + { + ThemeSetFocus(m_pTheme, WIXSTDBA_CONTROL_INSTALL_BUTTON); + } + } + } + + ReleaseStr(sczText); + ReleaseStr(sczUnformattedText); + ReleaseStr(sczControlState); + ReleaseStr(sczControlName); + } + + + // + // OnClose - called when the window is trying to be closed. + // + BOOL OnClose() + { + BOOL fClose = FALSE; + BOOL fCancel = FALSE; + + // If we've already succeeded or failed or showing the help page, just close (prompts are annoying if the bootstrapper is done). + if (WIXSTDBA_STATE_APPLIED <= m_state || WIXSTDBA_STATE_HELP == m_state) + { + fClose = TRUE; + } + else // prompt the user or force the cancel if there is no UI. + { + fClose = PromptCancel(m_hWnd, BOOTSTRAPPER_DISPLAY_FULL != m_command.display, m_sczConfirmCloseMessage ? m_sczConfirmCloseMessage : L"Are you sure you want to cancel?", m_pTheme->sczCaption); + fCancel = fClose; + } + + // If we're doing progress then we never close, we just cancel to let rollback occur. + if (WIXSTDBA_STATE_APPLYING <= m_state && WIXSTDBA_STATE_APPLIED > m_state) + { + // If we canceled, disable cancel button since clicking it again is silly. + if (fClose) + { + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_PROGRESS_CANCEL_BUTTON, FALSE); + } + + fClose = FALSE; + } + + if (fClose) + { + DWORD dwCurrentPageId = 0; + DeterminePageId(m_state, &dwCurrentPageId); + + // Hide the current page to let thmutil do its thing with variables. + ThemeShowPageEx(m_pTheme, dwCurrentPageId, SW_HIDE, fCancel ? THEME_SHOW_PAGE_REASON_CANCEL : THEME_SHOW_PAGE_REASON_DEFAULT); + } + + return fClose; + } + + + // + // OnClickAcceptCheckbox - allow the install to continue. + // + void OnClickAcceptCheckbox() + { + BOOL fAcceptedLicense = ThemeIsControlChecked(m_pTheme, WIXSTDBA_CONTROL_EULA_ACCEPT_CHECKBOX); + ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_INSTALL_BUTTON, fAcceptedLicense); + } + + + // + // OnClickInstallButton - start the install by planning the packages. + // + void OnClickInstallButton() + { + this->OnPlan(BOOTSTRAPPER_ACTION_INSTALL); + } + + + // + // OnClickRepairButton - start the repair. + // + void OnClickRepairButton() + { + this->OnPlan(BOOTSTRAPPER_ACTION_REPAIR); + } + + + // + // OnClickUninstallButton - start the uninstall. + // + void OnClickUninstallButton() + { + this->OnPlan(BOOTSTRAPPER_ACTION_UNINSTALL); + } + + + // + // OnClickCloseButton - close the application. + // + void OnClickCloseButton() + { + ::SendMessageW(m_hWnd, WM_CLOSE, 0, 0); + } + + + // + // OnClickEulaLink - show the end user license agreement. + // + void OnClickEulaLink() + { + HRESULT hr = S_OK; + LPWSTR sczLicenseUrl = NULL; + LPWSTR sczLicensePath = NULL; + LPWSTR sczLicenseDirectory = NULL; + LPWSTR sczLicenseFilename = NULL; + URI_PROTOCOL protocol = URI_PROTOCOL_UNKNOWN; + + hr = StrAllocString(&sczLicenseUrl, m_sczLicenseUrl, 0); + BalExitOnFailure(hr, "Failed to copy license URL: %ls", m_sczLicenseUrl); + + hr = LocLocalizeString(m_pWixLoc, &sczLicenseUrl); + BalExitOnFailure(hr, "Failed to localize license URL: %ls", m_sczLicenseUrl); + + // Assume there is no hidden variables to be formatted + // so don't worry about securely freeing it. + hr = BalFormatString(sczLicenseUrl, &sczLicenseUrl); + BalExitOnFailure(hr, "Failed to get formatted license URL: %ls", m_sczLicenseUrl); + + hr = UriProtocol(sczLicenseUrl, &protocol); + if (FAILED(hr) || URI_PROTOCOL_UNKNOWN == protocol) + { + // Probe for localized license file + hr = PathRelativeToModule(&sczLicensePath, sczLicenseUrl, m_hModule); + if (SUCCEEDED(hr)) + { + hr = PathGetDirectory(sczLicensePath, &sczLicenseDirectory); + if (SUCCEEDED(hr)) + { + hr = LocProbeForFile(sczLicenseDirectory, PathFile(sczLicenseUrl), m_sczLanguage, &sczLicensePath); + } + } + } + + hr = ShelExecUnelevated(sczLicensePath ? sczLicensePath : sczLicenseUrl, NULL, L"open", NULL, SW_SHOWDEFAULT); + BalExitOnFailure(hr, "Failed to launch URL to EULA."); + + LExit: + ReleaseStr(sczLicensePath); + ReleaseStr(sczLicenseUrl); + ReleaseStr(sczLicenseDirectory); + ReleaseStr(sczLicenseFilename); + + return; + } + + + // + // OnClickLaunchButton - launch the app from the success page. + // + void OnClickLaunchButton() + { + HRESULT hr = S_OK; + LPWSTR sczUnformattedLaunchTarget = NULL; + LPWSTR sczLaunchTarget = NULL; + LPWSTR sczLaunchTargetElevatedId = NULL; + LPWSTR sczUnformattedArguments = NULL; + LPWSTR sczArguments = NULL; + LPWSTR sczUnformattedLaunchFolder = NULL; + LPWSTR sczLaunchFolder = NULL; + int nCmdShow = SW_SHOWNORMAL; + + hr = BalGetStringVariable(WIXSTDBA_VARIABLE_LAUNCH_TARGET_PATH, &sczUnformattedLaunchTarget); + BalExitOnFailure(hr, "Failed to get launch target variable '%ls'.", WIXSTDBA_VARIABLE_LAUNCH_TARGET_PATH); + + hr = BalFormatString(sczUnformattedLaunchTarget, &sczLaunchTarget); + BalExitOnFailure(hr, "Failed to format launch target variable: %ls", sczUnformattedLaunchTarget); + + if (BalStringVariableExists(WIXSTDBA_VARIABLE_LAUNCH_TARGET_ELEVATED_ID)) + { + hr = BalGetStringVariable(WIXSTDBA_VARIABLE_LAUNCH_TARGET_ELEVATED_ID, &sczLaunchTargetElevatedId); + BalExitOnFailure(hr, "Failed to get launch target elevated id '%ls'.", WIXSTDBA_VARIABLE_LAUNCH_TARGET_ELEVATED_ID); + } + + if (BalStringVariableExists(WIXSTDBA_VARIABLE_LAUNCH_ARGUMENTS)) + { + hr = BalGetStringVariable(WIXSTDBA_VARIABLE_LAUNCH_ARGUMENTS, &sczUnformattedArguments); + BalExitOnFailure(hr, "Failed to get launch arguments '%ls'.", WIXSTDBA_VARIABLE_LAUNCH_ARGUMENTS); + } + + if (BalStringVariableExists(WIXSTDBA_VARIABLE_LAUNCH_HIDDEN)) + { + nCmdShow = SW_HIDE; + } + + if (BalStringVariableExists(WIXSTDBA_VARIABLE_LAUNCH_WORK_FOLDER)) + { + hr = BalGetStringVariable(WIXSTDBA_VARIABLE_LAUNCH_WORK_FOLDER, &sczUnformattedLaunchFolder); + BalExitOnFailure(hr, "Failed to get launch working directory variable '%ls'.", WIXSTDBA_VARIABLE_LAUNCH_WORK_FOLDER); + } + + if (sczLaunchTargetElevatedId && !m_fTriedToLaunchElevated) + { + m_fTriedToLaunchElevated = TRUE; + hr = m_pEngine->LaunchApprovedExe(m_hWnd, sczLaunchTargetElevatedId, sczUnformattedArguments, 0); + if (FAILED(hr)) + { + BalLogError(hr, "Failed to launch elevated target: %ls", sczLaunchTargetElevatedId); + + //try with ShelExec next time + OnClickLaunchButton(); + } + } + else + { + if (sczUnformattedArguments) + { + hr = BalFormatString(sczUnformattedArguments, &sczArguments); + BalExitOnFailure(hr, "Failed to format launch arguments variable: %ls", sczUnformattedArguments); + } + + if (sczUnformattedLaunchFolder) + { + hr = BalFormatString(sczUnformattedLaunchFolder, &sczLaunchFolder); + BalExitOnFailure(hr, "Failed to format launch working directory variable: %ls", sczUnformattedLaunchFolder); + } + + hr = ShelExec(sczLaunchTarget, sczArguments, L"open", sczLaunchFolder, nCmdShow, m_hWnd, NULL); + BalExitOnFailure(hr, "Failed to launch target: %ls", sczLaunchTarget); + + ::PostMessageW(m_hWnd, WM_CLOSE, 0, 0); + } + + LExit: + StrSecureZeroFreeString(sczLaunchFolder); + ReleaseStr(sczUnformattedLaunchFolder); + StrSecureZeroFreeString(sczArguments); + ReleaseStr(sczUnformattedArguments); + ReleaseStr(sczLaunchTargetElevatedId); + StrSecureZeroFreeString(sczLaunchTarget); + ReleaseStr(sczUnformattedLaunchTarget); + + return; + } + + + // + // OnClickRestartButton - allows the restart and closes the app. + // + void OnClickRestartButton() + { + AssertSz(m_fRestartRequired, "Restart must be requested to be able to click on the restart button."); + + m_fAllowRestart = TRUE; + ::SendMessageW(m_hWnd, WM_CLOSE, 0, 0); + + return; + } + + + // + // OnClickLogFileLink - show the log file. + // + void OnClickLogFileLink() + { + HRESULT hr = S_OK; + LPWSTR sczLogFile = NULL; + + hr = BalGetStringVariable(m_Bundle.sczLogVariable, &sczLogFile); + BalExitOnFailure(hr, "Failed to get log file variable '%ls'.", m_Bundle.sczLogVariable); + + hr = ShelExecUnelevated(L"notepad.exe", sczLogFile, L"open", NULL, SW_SHOWDEFAULT); + BalExitOnFailure(hr, "Failed to open log file target: %ls", sczLogFile); + + LExit: + ReleaseStr(sczLogFile); + + return; + } + + + // + // SetState + // + void SetState( + __in WIXSTDBA_STATE state, + __in HRESULT hrStatus + ) + { + if (FAILED(hrStatus)) + { + m_hrFinal = hrStatus; + } + + if (FAILED(m_hrFinal)) + { + state = WIXSTDBA_STATE_FAILED; + } + + if (m_state < state) + { + ::PostMessageW(m_hWnd, WM_WIXSTDBA_CHANGE_STATE, 0, state); + } + } + + + void DeterminePageId( + __in WIXSTDBA_STATE state, + __out DWORD* pdwPageId + ) + { + if (BOOTSTRAPPER_DISPLAY_PASSIVE == m_command.display) + { + switch (state) + { + case WIXSTDBA_STATE_INITIALIZED: + *pdwPageId = BOOTSTRAPPER_ACTION_HELP == m_command.action ? m_rgdwPageIds[WIXSTDBA_PAGE_HELP] : m_rgdwPageIds[WIXSTDBA_PAGE_LOADING]; + break; + + case WIXSTDBA_STATE_HELP: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_HELP]; + break; + + case WIXSTDBA_STATE_DETECTING: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_LOADING] ? m_rgdwPageIds[WIXSTDBA_PAGE_LOADING] : m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS_PASSIVE] ? m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS_PASSIVE] : m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS]; + break; + + case WIXSTDBA_STATE_DETECTED: __fallthrough; + case WIXSTDBA_STATE_PLANNING: __fallthrough; + case WIXSTDBA_STATE_PLANNED: __fallthrough; + case WIXSTDBA_STATE_APPLYING: __fallthrough; + case WIXSTDBA_STATE_CACHING: __fallthrough; + case WIXSTDBA_STATE_CACHED: __fallthrough; + case WIXSTDBA_STATE_EXECUTING: __fallthrough; + case WIXSTDBA_STATE_EXECUTED: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS_PASSIVE] ? m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS_PASSIVE] : m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS]; + break; + + default: + *pdwPageId = 0; + break; + } + } + else if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display) + { + switch (state) + { + case WIXSTDBA_STATE_INITIALIZING: + *pdwPageId = 0; + break; + + case WIXSTDBA_STATE_INITIALIZED: + *pdwPageId = BOOTSTRAPPER_ACTION_HELP == m_command.action ? m_rgdwPageIds[WIXSTDBA_PAGE_HELP] : m_rgdwPageIds[WIXSTDBA_PAGE_LOADING]; + break; + + case WIXSTDBA_STATE_HELP: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_HELP]; + break; + + case WIXSTDBA_STATE_DETECTING: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_LOADING]; + break; + + case WIXSTDBA_STATE_DETECTED: + switch (m_command.action) + { + case BOOTSTRAPPER_ACTION_INSTALL: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_INSTALL]; + break; + + case BOOTSTRAPPER_ACTION_MODIFY: __fallthrough; + case BOOTSTRAPPER_ACTION_REPAIR: __fallthrough; + case BOOTSTRAPPER_ACTION_UNINSTALL: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_MODIFY]; + break; + } + break; + + case WIXSTDBA_STATE_PLANNING: __fallthrough; + case WIXSTDBA_STATE_PLANNED: __fallthrough; + case WIXSTDBA_STATE_APPLYING: __fallthrough; + case WIXSTDBA_STATE_CACHING: __fallthrough; + case WIXSTDBA_STATE_CACHED: __fallthrough; + case WIXSTDBA_STATE_EXECUTING: __fallthrough; + case WIXSTDBA_STATE_EXECUTED: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_PROGRESS]; + break; + + case WIXSTDBA_STATE_APPLIED: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_SUCCESS]; + break; + + case WIXSTDBA_STATE_FAILED: + *pdwPageId = m_rgdwPageIds[WIXSTDBA_PAGE_FAILURE]; + break; + } + } + } + + + HRESULT EvaluateConditions() + { + HRESULT hr = S_OK; + BOOL fResult = FALSE; + + for (DWORD i = 0; i < m_Conditions.cConditions; ++i) + { + BAL_CONDITION* pCondition = m_Conditions.rgConditions + i; + + hr = BalConditionEvaluate(pCondition, m_pEngine, &fResult, &m_sczFailedMessage); + BalExitOnFailure(hr, "Failed to evaluate condition."); + + if (!fResult) + { + hr = E_WIXSTDBA_CONDITION_FAILED; + BalExitOnFailure(hr, "%ls", m_sczFailedMessage); + } + } + + ReleaseNullStrSecure(m_sczFailedMessage); + + LExit: + return hr; + } + + void UpdateCacheProgress( + __in DWORD dwOverallPercentage + ) + { + WCHAR wzProgress[5] = { }; + + ::StringCchPrintfW(wzProgress, countof(wzProgress), L"%u%%", dwOverallPercentage); + ThemeSetTextControl(m_pTheme, WIXSTDBA_CONTROL_CACHE_PROGRESS_TEXT, wzProgress); + + ThemeSetProgressControl(m_pTheme, WIXSTDBA_CONTROL_CACHE_PROGRESS_BAR, dwOverallPercentage); + + m_dwCalculatedCacheProgress = dwOverallPercentage * WIXSTDBA_ACQUIRE_PERCENTAGE / 100; + ThemeSetProgressControl(m_pTheme, WIXSTDBA_CONTROL_OVERALL_CALCULATED_PROGRESS_BAR, m_dwCalculatedCacheProgress + m_dwCalculatedExecuteProgress); + + SetTaskbarButtonProgress(m_dwCalculatedCacheProgress + m_dwCalculatedExecuteProgress); + } + + + void SetTaskbarButtonProgress( + __in DWORD dwOverallPercentage + ) + { + HRESULT hr = S_OK; + + if (m_fTaskbarButtonOK) + { + hr = m_pTaskbarList->SetProgressValue(m_hWnd, dwOverallPercentage, 100UL); + BalExitOnFailure(hr, "Failed to set taskbar button progress to: %d%%.", dwOverallPercentage); + } + + LExit: + return; + } + + + void SetTaskbarButtonState( + __in TBPFLAG tbpFlags + ) + { + HRESULT hr = S_OK; + + if (m_fTaskbarButtonOK) + { + hr = m_pTaskbarList->SetProgressState(m_hWnd, tbpFlags); + BalExitOnFailure(hr, "Failed to set taskbar button state.", tbpFlags); + } + + LExit: + return; + } + + + void SetProgressState( + __in HRESULT hrStatus + ) + { + TBPFLAG flag = TBPF_NORMAL; + + if (IsCanceled() || HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) == hrStatus) + { + flag = TBPF_PAUSED; + } + else if (IsRollingBack() || FAILED(hrStatus)) + { + flag = TBPF_ERROR; + } + + SetTaskbarButtonState(flag); + } + + + HRESULT LoadBAFunctions( + __in IXMLDOMDocument* pixdManifest + ) + { + HRESULT hr = S_OK; + IXMLDOMNode* pBAFunctionsNode = NULL; + IXMLDOMNode* pPayloadNode = NULL; + LPWSTR sczPayloadId = NULL; + LPWSTR sczPayloadXPath = NULL; + LPWSTR sczBafName = NULL; + LPWSTR sczBafPath = NULL; + BA_FUNCTIONS_CREATE_ARGS bafCreateArgs = { }; + BA_FUNCTIONS_CREATE_RESULTS bafCreateResults = { }; + + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBalBAFunctions", &pBAFunctionsNode); + BalExitOnFailure(hr, "Failed to read WixBalBAFunctions node from BootstrapperApplicationData.xml."); + + if (S_FALSE == hr) + { + ExitFunction(); + } + + hr = XmlGetAttributeEx(pBAFunctionsNode, L"PayloadId", &sczPayloadId); + BalExitOnFailure(hr, "Failed to get BAFunctions PayloadId."); + + hr = StrAllocFormatted(&sczPayloadXPath, L"/BootstrapperApplicationData/WixPayloadProperties[@Payload='%ls']", sczPayloadId); + BalExitOnFailure(hr, "Failed to format BAFunctions payload XPath."); + + hr = XmlSelectSingleNode(pixdManifest, sczPayloadXPath, &pPayloadNode); + if (S_FALSE == hr) + { + hr = E_NOTFOUND; + } + BalExitOnFailure(hr, "Failed to find WixPayloadProperties node for BAFunctions PayloadId: %ls.", sczPayloadId); + + hr = XmlGetAttributeEx(pPayloadNode, L"Name", &sczBafName); + BalExitOnFailure(hr, "Failed to get BAFunctions Name."); + + hr = PathRelativeToModule(&sczBafPath, sczBafName, m_hModule); + BalExitOnFailure(hr, "Failed to get path to BAFunctions DLL."); + + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "WIXSTDBA: LoadBAFunctions() - BAFunctions DLL %ls", sczBafPath); + + m_hBAFModule = ::LoadLibraryExW(sczBafPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + BalExitOnNullWithLastError(m_hBAFModule, hr, "WIXSTDBA: LoadBAFunctions() - Failed to load DLL %ls", sczBafPath); + + PFN_BA_FUNCTIONS_CREATE pfnBAFunctionsCreate = reinterpret_cast(::GetProcAddress(m_hBAFModule, "BAFunctionsCreate")); + BalExitOnNullWithLastError(pfnBAFunctionsCreate, hr, "Failed to get BAFunctionsCreate entry-point from: %ls", sczBafPath); + + bafCreateArgs.cbSize = sizeof(bafCreateArgs); + bafCreateArgs.qwBAFunctionsAPIVersion = MAKEQWORDVERSION(0, 0, 0, 2); // TODO: need to decide whether to keep this, and if so when to update it. + bafCreateArgs.pBootstrapperCreateArgs = &m_createArgs; + + bafCreateResults.cbSize = sizeof(bafCreateResults); + + hr = pfnBAFunctionsCreate(&bafCreateArgs, &bafCreateResults); + BalExitOnFailure(hr, "Failed to create BAFunctions."); + + m_pfnBAFunctionsProc = bafCreateResults.pfnBAFunctionsProc; + m_pvBAFunctionsProcContext = bafCreateResults.pvBAFunctionsProcContext; + + LExit: + if (m_hBAFModule && !m_pfnBAFunctionsProc) + { + ::FreeLibrary(m_hBAFModule); + m_hBAFModule = NULL; + } + ReleaseStr(sczBafPath); + ReleaseStr(sczBafName); + ReleaseStr(sczPayloadXPath); + ReleaseStr(sczPayloadId); + ReleaseObject(pBAFunctionsNode); + ReleaseObject(pPayloadNode); + + return hr; + } + + +public: + // + // Constructor - initialize member variables. + // + CWixStandardBootstrapperApplication( + __in HMODULE hModule, + __in BOOL fPrereq, + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs + ) : CBalBaseBootstrapperApplication(pEngine, pArgs, 3, 3000) + { + m_hModule = hModule; + memcpy_s(&m_command, sizeof(m_command), pArgs->pCommand, sizeof(BOOTSTRAPPER_COMMAND)); + memcpy_s(&m_createArgs, sizeof(m_createArgs), pArgs, sizeof(BOOTSTRAPPER_CREATE_ARGS)); + m_createArgs.pCommand = &m_command; + + if (fPrereq) + { + // Pre-req BA should only show help or do an install (to launch the Managed BA which can then do the right action). + if (BOOTSTRAPPER_ACTION_HELP != m_command.action) + { + m_command.action = BOOTSTRAPPER_ACTION_INSTALL; + } + } + else // maybe modify the action state if the bundle is or is not already installed. + { + LONGLONG llInstalled = 0; + HRESULT hr = BalGetNumericVariable(L"WixBundleInstalled", &llInstalled); + if (SUCCEEDED(hr) && BOOTSTRAPPER_RESUME_TYPE_REBOOT != m_command.resumeType && 0 < llInstalled && BOOTSTRAPPER_ACTION_INSTALL == m_command.action) + { + m_command.action = BOOTSTRAPPER_ACTION_MODIFY; + } + else if (0 == llInstalled && (BOOTSTRAPPER_ACTION_MODIFY == m_command.action || BOOTSTRAPPER_ACTION_REPAIR == m_command.action)) + { + m_command.action = BOOTSTRAPPER_ACTION_INSTALL; + } + } + + m_plannedAction = BOOTSTRAPPER_ACTION_UNKNOWN; + + // When resuming from restart doing some install-like operation, try to find the package that forced the + // restart. We'll use this information during planning. + m_sczAfterForcedRestartPackage = NULL; + + if (BOOTSTRAPPER_RESUME_TYPE_REBOOT == m_command.resumeType && BOOTSTRAPPER_ACTION_UNINSTALL < m_command.action) + { + // Ensure the forced restart package variable is null when it is an empty string. + HRESULT hr = BalGetStringVariable(L"WixBundleForcedRestartPackage", &m_sczAfterForcedRestartPackage); + if (FAILED(hr) || !m_sczAfterForcedRestartPackage || !*m_sczAfterForcedRestartPackage) + { + ReleaseNullStr(m_sczAfterForcedRestartPackage); + } + } + + m_pWixLoc = NULL; + memset(&m_Bundle, 0, sizeof(m_Bundle)); + memset(&m_Conditions, 0, sizeof(m_Conditions)); + m_sczConfirmCloseMessage = NULL; + m_sczFailedMessage = NULL; + + m_sczLanguage = NULL; + m_pTheme = NULL; + memset(m_rgdwPageIds, 0, sizeof(m_rgdwPageIds)); + m_hUiThread = NULL; + m_fRegistered = FALSE; + m_hWnd = NULL; + + m_state = WIXSTDBA_STATE_INITIALIZING; + m_hrFinal = hrHostInitialization; + + m_fDowngrading = FALSE; + m_restartResult = BOOTSTRAPPER_APPLY_RESTART_NONE; + m_fRestartRequired = FALSE; + m_fAllowRestart = FALSE; + + m_sczLicenseFile = NULL; + m_sczLicenseUrl = NULL; + m_fSuppressDowngradeFailure = FALSE; + m_fSuppressRepair = FALSE; + m_fSupportCacheOnly = FALSE; + + m_sdOverridableVariables = NULL; + m_shPrereqSupportPackages = NULL; + m_rgPrereqPackages = NULL; + m_cPrereqPackages = 0; + m_pTaskbarList = NULL; + m_uTaskbarButtonCreatedMessage = UINT_MAX; + m_fTaskbarButtonOK = FALSE; + m_fShowingInternalUiThisPackage = FALSE; + m_fTriedToLaunchElevated = FALSE; + + m_fPrereq = fPrereq; + m_fPrereqInstalled = FALSE; + m_fPrereqAlreadyInstalled = FALSE; + + pEngine->AddRef(); + m_pEngine = pEngine; + + m_hBAFModule = NULL; + m_pfnBAFunctionsProc = NULL; + m_pvBAFunctionsProcContext = NULL; + } + + + // + // Destructor - release member variables. + // + ~CWixStandardBootstrapperApplication() + { + AssertSz(!::IsWindow(m_hWnd), "Window should have been destroyed before destructor."); + AssertSz(!m_pTheme, "Theme should have been released before destructor."); + + ReleaseObject(m_pTaskbarList); + ReleaseDict(m_sdOverridableVariables); + ReleaseDict(m_shPrereqSupportPackages); + ReleaseMem(m_rgPrereqPackages); + ReleaseStr(m_sczFailedMessage); + ReleaseStr(m_sczConfirmCloseMessage); + BalConditionsUninitialize(&m_Conditions); + BalInfoUninitialize(&m_Bundle); + LocFree(m_pWixLoc); + + ReleaseStr(m_sczLanguage); + ReleaseStr(m_sczLicenseFile); + ReleaseStr(m_sczLicenseUrl); + ReleaseStr(m_sczAfterForcedRestartPackage); + ReleaseNullObject(m_pEngine); + + if (m_hBAFModule) + { + PFN_BA_FUNCTIONS_DESTROY pfnBAFunctionsDestroy = reinterpret_cast(::GetProcAddress(m_hBAFModule, "BAFunctionsDestroy")); + if (pfnBAFunctionsDestroy) + { + pfnBAFunctionsDestroy(); + } + + ::FreeLibrary(m_hBAFModule); + m_hBAFModule = NULL; + } + } + +private: + HMODULE m_hModule; + BOOTSTRAPPER_CREATE_ARGS m_createArgs; + BOOTSTRAPPER_COMMAND m_command; + IBootstrapperEngine* m_pEngine; + BOOTSTRAPPER_ACTION m_plannedAction; + + LPWSTR m_sczAfterForcedRestartPackage; + + WIX_LOCALIZATION* m_pWixLoc; + BAL_INFO_BUNDLE m_Bundle; + BAL_CONDITIONS m_Conditions; + LPWSTR m_sczFailedMessage; + LPWSTR m_sczConfirmCloseMessage; + + LPWSTR m_sczLanguage; + THEME* m_pTheme; + DWORD m_rgdwPageIds[countof(vrgwzPageNames)]; + HANDLE m_hUiThread; + BOOL m_fRegistered; + HWND m_hWnd; + + WIXSTDBA_STATE m_state; + HRESULT m_hrFinal; + + BOOL m_fStartedExecution; + DWORD m_dwCalculatedCacheProgress; + DWORD m_dwCalculatedExecuteProgress; + + BOOL m_fDowngrading; + BOOTSTRAPPER_APPLY_RESTART m_restartResult; + BOOL m_fRestartRequired; + BOOL m_fAllowRestart; + + LPWSTR m_sczLicenseFile; + LPWSTR m_sczLicenseUrl; + BOOL m_fSuppressDowngradeFailure; + BOOL m_fSuppressRepair; + BOOL m_fSupportCacheOnly; + + STRINGDICT_HANDLE m_sdOverridableVariables; + + WIXSTDBA_PREREQ_PACKAGE* m_rgPrereqPackages; + DWORD m_cPrereqPackages; + STRINGDICT_HANDLE m_shPrereqSupportPackages; + + BOOL m_fPrereq; + BOOL m_fPrereqInstalled; + BOOL m_fPrereqAlreadyInstalled; + + ITaskbarList3* m_pTaskbarList; + UINT m_uTaskbarButtonCreatedMessage; + BOOL m_fTaskbarButtonOK; + BOOL m_fShowingInternalUiThisPackage; + BOOL m_fTriedToLaunchElevated; + + HMODULE m_hBAFModule; + PFN_BA_FUNCTIONS_PROC m_pfnBAFunctionsProc; + LPVOID m_pvBAFunctionsProcContext; +}; + + +// +// CreateBootstrapperApplication - creates a new IBootstrapperApplication object. +// +HRESULT CreateBootstrapperApplication( + __in HMODULE hModule, + __in BOOL fPrereq, + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + CWixStandardBootstrapperApplication* pApplication = NULL; + + pApplication = new CWixStandardBootstrapperApplication(hModule, fPrereq, hrHostInitialization, pEngine, pArgs); + ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new standard bootstrapper application object."); + + pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc; + pResults->pvBootstrapperApplicationProcContext = pApplication; + pApplication = NULL; + +LExit: + ReleaseObject(pApplication); + return hr; +} + + +static HRESULT DAPI EvaluateVariableConditionCallback( + __in_z LPCWSTR wzCondition, + __out BOOL* pf, + __in_opt LPVOID /*pvContext*/ + ) +{ + return BalEvaluateCondition(wzCondition, pf); +} + + +static HRESULT DAPI FormatVariableStringCallback( + __in_z LPCWSTR wzFormat, + __inout LPWSTR* psczOut, + __in_opt LPVOID /*pvContext*/ + ) +{ + return BalFormatString(wzFormat, psczOut); +} + + +static HRESULT DAPI GetVariableNumericCallback( + __in_z LPCWSTR wzVariable, + __out LONGLONG* pllValue, + __in_opt LPVOID /*pvContext*/ + ) +{ + return BalGetNumericVariable(wzVariable, pllValue); +} + + +static HRESULT DAPI SetVariableNumericCallback( + __in_z LPCWSTR wzVariable, + __in LONGLONG llValue, + __in_opt LPVOID /*pvContext*/ + ) +{ + return BalSetNumericVariable(wzVariable, llValue); +} + + +static HRESULT DAPI GetVariableStringCallback( + __in_z LPCWSTR wzVariable, + __inout LPWSTR* psczValue, + __in_opt LPVOID /*pvContext*/ + ) +{ + return BalGetStringVariable(wzVariable, psczValue); +} + + +static HRESULT DAPI SetVariableStringCallback( + __in_z LPCWSTR wzVariable, + __in_z_opt LPCWSTR wzValue, + __in_opt LPVOID /*pvContext*/ + ) +{ + return BalSetStringVariable(wzVariable, wzValue); +} + +static LPCSTR LoggingRequestStateToString( + __in BOOTSTRAPPER_REQUEST_STATE requestState + ) +{ + switch (requestState) + { + case BOOTSTRAPPER_REQUEST_STATE_NONE: + return "None"; + case BOOTSTRAPPER_REQUEST_STATE_FORCE_ABSENT: + return "ForceAbsent"; + case BOOTSTRAPPER_REQUEST_STATE_ABSENT: + return "Absent"; + case BOOTSTRAPPER_REQUEST_STATE_CACHE: + return "Cache"; + case BOOTSTRAPPER_REQUEST_STATE_PRESENT: + return "Present"; + case BOOTSTRAPPER_REQUEST_STATE_REPAIR: + return "Repair"; + default: + return "Invalid"; + } +} + +static LPCSTR LoggingMsiFeatureStateToString( + __in BOOTSTRAPPER_FEATURE_STATE featureState + ) +{ + switch (featureState) + { + case BOOTSTRAPPER_FEATURE_STATE_UNKNOWN: + return "Unknown"; + case BOOTSTRAPPER_FEATURE_STATE_ABSENT: + return "Absent"; + case BOOTSTRAPPER_FEATURE_STATE_ADVERTISED: + return "Advertised"; + case BOOTSTRAPPER_FEATURE_STATE_LOCAL: + return "Local"; + case BOOTSTRAPPER_FEATURE_STATE_SOURCE: + return "Source"; + default: + return "Invalid"; + } +} diff --git a/src/wixstdba/precomp.h b/src/wixstdba/precomp.h new file mode 100644 index 00000000..a0390fe2 --- /dev/null +++ b/src/wixstdba/precomp.h @@ -0,0 +1,51 @@ +#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 "dutil.h" +#include "apputil.h" +#include "memutil.h" +#include "dictutil.h" +#include "dirutil.h" +#include "fileutil.h" +#include "locutil.h" +#include "logutil.h" +#include "pathutil.h" +#include "resrutil.h" +#include "shelutil.h" +#include "strutil.h" +#include "thmutil.h" +#include "uriutil.h" +#include "xmlutil.h" + +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" +#include "IBootstrapperEngine.h" +#include "IBootstrapperApplication.h" + +#include "balutil.h" +#include "balinfo.h" +#include "balcondition.h" + +#include "BAFunctions.h" + +#include "wixstdba.messages.h" + +HRESULT CreateBootstrapperApplication( + __in HMODULE hModule, + __in BOOL fPrereq, + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ); diff --git a/src/wixstdba/resource.h b/src/wixstdba/resource.h new file mode 100644 index 00000000..149a8ff4 --- /dev/null +++ b/src/wixstdba/resource.h @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#define IDC_STATIC -1 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1003 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/wixstdba/wixstdba.cpp b/src/wixstdba/wixstdba.cpp new file mode 100644 index 00000000..f47c1f4e --- /dev/null +++ b/src/wixstdba/wixstdba.cpp @@ -0,0 +1,78 @@ +// Copyright (c) .NET 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 HINSTANCE vhInstance = NULL; + +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInstance, + IN DWORD dwReason, + IN LPVOID /* pvReserved */ + ) +{ + switch(dwReason) + { + case DLL_PROCESS_ATTACH: + ::DisableThreadLibraryCalls(hInstance); + vhInstance = hInstance; + break; + + case DLL_PROCESS_DETACH: + vhInstance = NULL; + break; + } + + return TRUE; +} + + +extern "C" HRESULT WINAPI BootstrapperApplicationCreate( + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + IBootstrapperEngine* pEngine = NULL; + + hr = BalInitializeFromCreateArgs(pArgs, &pEngine); + ExitOnFailure(hr, "Failed to initialize Bal."); + + hr = CreateBootstrapperApplication(vhInstance, FALSE, S_OK, pEngine, pArgs, pResults); + BalExitOnFailure(hr, "Failed to create bootstrapper application interface."); + +LExit: + ReleaseObject(pEngine); + + return hr; +} + + +extern "C" void WINAPI BootstrapperApplicationDestroy() +{ + BalUninitialize(); +} + + +extern "C" HRESULT WINAPI MbaPrereqBootstrapperApplicationCreate( + __in HRESULT hrHostInitialization, + __in IBootstrapperEngine* pEngine, + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + + BalInitialize(pEngine); + + hr = CreateBootstrapperApplication(vhInstance, TRUE, hrHostInitialization, pEngine, pArgs, pResults); + BalExitOnFailure(hr, "Failed to create managed prerequisite bootstrapper application interface."); + +LExit: + return hr; +} + + +extern "C" void WINAPI MbaPrereqBootstrapperApplicationDestroy() +{ + BalUninitialize(); +} diff --git a/src/wixstdba/wixstdba.def b/src/wixstdba/wixstdba.def new file mode 100644 index 00000000..815d2977 --- /dev/null +++ b/src/wixstdba/wixstdba.def @@ -0,0 +1,8 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +EXPORTS + BootstrapperApplicationCreate + BootstrapperApplicationDestroy + MbaPrereqBootstrapperApplicationCreate + MbaPrereqBootstrapperApplicationDestroy diff --git a/src/wixstdba/wixstdba.mc b/src/wixstdba/wixstdba.mc new file mode 100644 index 00000000..66aa9767 --- /dev/null +++ b/src/wixstdba/wixstdba.mc @@ -0,0 +1,73 @@ +; // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +MessageIdTypedef=DWORD + +LanguageNames=(English=0x409:MSG00409) + + +; // message definitions + +; // MessageId=# +; // Severity=Success +; // SymbolicName=MSG_SUCCESS +; // Language=English +; // Success %1. +; // . +; +; // MessageId=# +; // Severity=Warning +; // SymbolicName=MSG_WARNING +; // Language=English +; // Warning %1. +; // . +; +; // MessageId=# +; // Severity=Error +; // SymbolicName=MSG_ERROR +; // Language=English +; // Error %1. +; // . + +MessageId=1 +Severity=Success +SymbolicName=MSG_WIXSTDBA_DETECTED_FORWARD_COMPATIBLE_BUNDLE +Language=English +WIXSTDBA: Detected forward compatible bundle: %1!ls!, wixstdba requested: %2!hs!, bafunctions requested: %3!hs! +. + +MessageId=2 +Severity=Success +SymbolicName=MSG_WIXSTDBA_PLANNED_PACKAGE +Language=English +WIXSTDBA: Planned package: %1!ls!, wixstdba requested: %2!hs!, bafunctions requested: %3!hs! +. + +MessageId=3 +Severity=Success +SymbolicName=MSG_WIXSTDBA_PLANNED_RELATED_BUNDLE +Language=English +WIXSTDBA: Planned related bundle: %1!ls!, wixstdba requested: %2!hs!, bafunctions requested: %3!hs! +. + +MessageId=4 +Severity=Success +SymbolicName=MSG_WIXSTDBA_PLANNED_COMPATIBLE_MSI_PACKAGE +Language=English +WIXSTDBA: Planned compatible package: %2!ls! for %1!ls!, wixstdba requested: %3!hs!, bafunctions requested: %4!hs! +. + +MessageId=5 +Severity=Success +SymbolicName=MSG_WIXSTDBA_PLANNED_TARGET_MSI_PACKAGE +Language=English +WIXSTDBA: Planned target MSI package: %1!ls!, productCode: %2!ls!, wixstdba requested: %3!hs!, bafunctions requested: %4!hs! +. + +MessageId=6 +Severity=Success +SymbolicName=MSG_WIXSTDBA_PLANNED_MSI_FEATURE +Language=English +WIXSTDBA: Planned MSI feature: %2!ls! for %1!ls!, wixstdba requested: %3!hs!, bafunctions requested: %4!hs! +. + diff --git a/src/wixstdba/wixstdba.vcxproj b/src/wixstdba/wixstdba.vcxproj new file mode 100644 index 00000000..ddc0bc57 --- /dev/null +++ b/src/wixstdba/wixstdba.vcxproj @@ -0,0 +1,106 @@ + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + + Debug + ARM + + + Release + ARM + + + + + {41085A22-E6AA-4E8B-AB1B-DDEE0DC89DFA} + DynamicLibrary + Unicode + WixStdBA + wixstdba.def + + + + + + $(WixRoot)src\libs\dutil\inc;$(WixRoot)src\burn\inc;$(WixRoot)src\libs\balutil\inc + comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib;dutil.lib;balutil.lib;wixstdba.res + + + + + + + + + + + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + WixstdbaResources + + + Wixstdba%(RelativeDir) + + + + + + + Compiling message file... + mc.exe -h "$(IntDir)." -r "$(IntDir)." -A -c -z wixstdba.messages "$(InputDir)wixstdba.mc" +rc.exe -fo "$(OutDir)wixstdba.res" "$(IntDir)wixstdba.messages.rc" + $(IntDir)wixstdba.messages.h;$(OutDir)wixstdba.messages.rc + + + + + -- cgit v1.2.3-55-g6feb