From af10c45d7b3a44af0b461a557847fe03263dcc10 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 17:06:54 -0700 Subject: Move burn into burn --- src/burn/stub/StubSection.cpp | 23 +++++++ src/burn/stub/WixToolset.Burn.props | 13 ++++ src/burn/stub/packages.config | 8 +++ src/burn/stub/precomp.cpp | 3 + src/burn/stub/precomp.h | 17 +++++ src/burn/stub/stub.cpp | 106 +++++++++++++++++++++++++++++++ src/burn/stub/stub.ico | Bin 0 -> 2238 bytes src/burn/stub/stub.nuspec | 25 ++++++++ src/burn/stub/stub.rc | 3 + src/burn/stub/stub.vcxproj | 120 ++++++++++++++++++++++++++++++++++++ 10 files changed, 318 insertions(+) create mode 100644 src/burn/stub/StubSection.cpp create mode 100644 src/burn/stub/WixToolset.Burn.props create mode 100644 src/burn/stub/packages.config create mode 100644 src/burn/stub/precomp.cpp create mode 100644 src/burn/stub/precomp.h create mode 100644 src/burn/stub/stub.cpp create mode 100644 src/burn/stub/stub.ico create mode 100644 src/burn/stub/stub.nuspec create mode 100644 src/burn/stub/stub.rc create mode 100644 src/burn/stub/stub.vcxproj (limited to 'src/burn/stub') diff --git a/src/burn/stub/StubSection.cpp b/src/burn/stub/StubSection.cpp new file mode 100644 index 00000000..962bb3cf --- /dev/null +++ b/src/burn/stub/StubSection.cpp @@ -0,0 +1,23 @@ +// Copyright (c) .NET 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" + +#pragma section(".wixburn",read) + +// If these defaults ever change, be sure to update constants in burn\engine\section.cpp as well. +#pragma data_seg(push, ".wixburn") +static DWORD dwMagic = 0x00f14300; +static DWORD dwVersion = 0x00000002; + +static GUID guidBundleId = { }; + +static DWORD dwStubSize = 0; +static DWORD dwOriginalChecksum = 0; +static DWORD dwOriginalSignatureOffset = 0; +static DWORD dwOriginalSignatureSize = 0; + +static DWORD dwContainerFormat = 1; +static DWORD dwContainerCount = 0; +static DWORD qwBootstrapperApplicationContainerSize = 0; +static DWORD qwAttachedContainerSize = 0; +#pragma data_seg(pop) diff --git a/src/burn/stub/WixToolset.Burn.props b/src/burn/stub/WixToolset.Burn.props new file mode 100644 index 00000000..38cd333e --- /dev/null +++ b/src/burn/stub/WixToolset.Burn.props @@ -0,0 +1,13 @@ + + + + + + + + %(RecursiveDir)%(FileName)%(Extension) + False + PreserveNewest + + + diff --git a/src/burn/stub/packages.config b/src/burn/stub/packages.config new file mode 100644 index 00000000..a98c0c8e --- /dev/null +++ b/src/burn/stub/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/burn/stub/precomp.cpp b/src/burn/stub/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/burn/stub/precomp.cpp @@ -0,0 +1,3 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" diff --git a/src/burn/stub/precomp.h b/src/burn/stub/precomp.h new file mode 100644 index 00000000..bb7ded9c --- /dev/null +++ b/src/burn/stub/precomp.h @@ -0,0 +1,17 @@ +#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 "engine.h" diff --git a/src/burn/stub/stub.cpp b/src/burn/stub/stub.cpp new file mode 100644 index 00000000..0cb202e0 --- /dev/null +++ b/src/burn/stub/stub.cpp @@ -0,0 +1,106 @@ +// Copyright (c) .NET 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 void CALLBACK BurnTraceError( + __in_z LPCSTR szFile, + __in int iLine, + __in REPORT_LEVEL rl, + __in UINT source, + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + +int WINAPI wWinMain( + __in HINSTANCE hInstance, + __in_opt HINSTANCE /* hPrevInstance */, + __in_z_opt LPWSTR lpCmdLine, + __in int nCmdShow + ) +{ + HRESULT hr = S_OK; + DWORD dwExitCode = 0; + LPWSTR sczPath = NULL; + HANDLE hEngineFile = INVALID_HANDLE_VALUE; + + LPCWSTR rgsczSafelyLoadSystemDlls[] = + { + L"cabinet.dll", // required by Burn. + L"msi.dll", // required by Burn. + L"version.dll", // required by Burn. + L"wininet.dll", // required by Burn. + + L"comres.dll", // required by CLSIDFromProgID() when loading clbcatq.dll. + L"clbcatq.dll", // required by CLSIDFromProgID() when loading msxml?.dll. + + L"msasn1.dll", // required by DecryptFile() when loading crypt32.dll. + L"crypt32.dll", // required by DecryptFile() when loading feclient.dll. + L"feclient.dll", // unsafely loaded by DecryptFile(). + }; + + DutilInitialize(&BurnTraceError); + + // Best effort attempt to get our file handle as soon as possible. + hr = PathForCurrentProcess(&sczPath, NULL); + if (SUCCEEDED(hr)) + { + hEngineFile = ::CreateFileW(sczPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + } + + // If the engine is in the clean room, we'll do the unsafe initialization + // because some systems in Windows (namely GDI+) will fail when run in + // a process that protects against DLL hijacking. Since we know the clean + // room is in a clean folder and not subject to DLL hijacking we won't + // make ourselves perfectly secure so that we can load BAs that still + // depend on those parts of Windows that are insecure to DLL hijacking. + if (EngineInCleanRoom(lpCmdLine)) + { + AppInitializeUnsafe(); + } + else + { + AppInitialize(rgsczSafelyLoadSystemDlls, countof(rgsczSafelyLoadSystemDlls)); + } + + // call run + hr = EngineRun(hInstance, hEngineFile, lpCmdLine, nCmdShow, &dwExitCode); + ExitOnFailure(hr, "Failed to run application."); + +LExit: + ReleaseFileHandle(hEngineFile); + ReleaseStr(sczPath); + + DutilUninitialize(); + + return FAILED(hr) ? (int)hr : (int)dwExitCode; +} + +static void CALLBACK BurnTraceError( + __in_z LPCSTR /*szFile*/, + __in int /*iLine*/, + __in REPORT_LEVEL /*rl*/, + __in UINT source, + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + BOOL fLog = FALSE; + + switch (source) + { + case DUTIL_SOURCE_DEFAULT: + fLog = TRUE; + break; + default: + fLog = REPORT_VERBOSE < LogGetLevel(); + break; + } + + if (fLog) + { + LogErrorStringArgs(hrError, szFormat, args); + } +} diff --git a/src/burn/stub/stub.ico b/src/burn/stub/stub.ico new file mode 100644 index 00000000..c2e2717c Binary files /dev/null and b/src/burn/stub/stub.ico differ diff --git a/src/burn/stub/stub.nuspec b/src/burn/stub/stub.nuspec new file mode 100644 index 00000000..968feff3 --- /dev/null +++ b/src/burn/stub/stub.nuspec @@ -0,0 +1,25 @@ + + + + $id$ + $version$ + $title$ + $description$ + $authors$ + MS-RL + false + $copyright$ + $projectUrl$ + + + + + + + + + + + + + diff --git a/src/burn/stub/stub.rc b/src/burn/stub/stub.rc new file mode 100644 index 00000000..80e1aac4 --- /dev/null +++ b/src/burn/stub/stub.rc @@ -0,0 +1,3 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +1 ICON "stub.ico" diff --git a/src/burn/stub/stub.vcxproj b/src/burn/stub/stub.vcxproj new file mode 100644 index 00000000..97972848 --- /dev/null +++ b/src/burn/stub/stub.vcxproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + + {C38373AA-882F-4F55-B03F-2AAB4BFBE3F1} + Application + Windows + burn + v142 + Unicode + false + Native component of WixToolset.Burn + + 1033 + Burn + WixToolset.Burn + false + + + + + + + + + + + + + + + + + $(ProjectDir)..\engine\inc + cabinet.lib;crypt32.lib;msi.lib;rpcrt4.lib;shlwapi.lib;wininet.lib;wuguid.lib;engine.res + + + + + true + true + cabinet.dll;crypt32.dll;msi.dll;shlwapi.dll;version.dll;wininet.dll + + + + + + + + + Create + + + + + false + + + + + + + + + {8119537D-E1D9-6591-D51A-49768A2F9C37} + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + + + + + + + + -- cgit v1.2.3-55-g6feb