From 61847dddd4fd497057c780658e383c4627de19ec Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 29 Dec 2018 22:12:08 -0600 Subject: Import code from old v4 repo --- src/stub/StubSection.cpp | 23 +++++++++++++++++ src/stub/precomp.h | 13 ++++++++++ src/stub/stub.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++ src/stub/stub.ico | Bin 0 -> 2238 bytes src/stub/stub.manifest | 18 +++++++++++++ src/stub/stub.rc | 14 +++++++++++ 6 files changed, 132 insertions(+) create mode 100644 src/stub/StubSection.cpp create mode 100644 src/stub/precomp.h create mode 100644 src/stub/stub.cpp create mode 100644 src/stub/stub.ico create mode 100644 src/stub/stub.manifest create mode 100644 src/stub/stub.rc (limited to 'src/stub') diff --git a/src/stub/StubSection.cpp b/src/stub/StubSection.cpp new file mode 100644 index 00000000..962bb3cf --- /dev/null +++ b/src/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/stub/precomp.h b/src/stub/precomp.h new file mode 100644 index 00000000..387d4f0f --- /dev/null +++ b/src/stub/precomp.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include + +#include +#include +#include +#include +#include + +#include "engine.h" diff --git a/src/stub/stub.cpp b/src/stub/stub.cpp new file mode 100644 index 00000000..2f09eede --- /dev/null +++ b/src/stub/stub.cpp @@ -0,0 +1,64 @@ +// Copyright (c) .NET 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" + + +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(). + }; + + // 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); + + return FAILED(hr) ? (int)hr : (int)dwExitCode; +} diff --git a/src/stub/stub.ico b/src/stub/stub.ico new file mode 100644 index 00000000..c2e2717c Binary files /dev/null and b/src/stub/stub.ico differ diff --git a/src/stub/stub.manifest b/src/stub/stub.manifest new file mode 100644 index 00000000..d5767cdb --- /dev/null +++ b/src/stub/stub.manifest @@ -0,0 +1,18 @@ + + + + + + + WiX Toolset Bootstrapper + true + + + + + + + + + + diff --git a/src/stub/stub.rc b/src/stub/stub.rc new file mode 100644 index 00000000..5601703d --- /dev/null +++ b/src/stub/stub.rc @@ -0,0 +1,14 @@ +// Copyright (c) .NET 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 VER_APP +#define VER_ORIGINAL_FILENAME "setup.exe" +#define VER_INTERNAL_NAME "setup" +#define VER_FILE_DESCRIPTION "WiX Toolset Bootstrapper" +#include "wix.rc" + +1 ICON "stub.ico" + +//#define MANIFEST_RESOURCE_ID 1 +#ifndef ARM // the ARM manifest is automatically injected but other platforms need it done manually. +//MANIFEST_RESOURCE_ID RT_MANIFEST "stub.manifest" +#endif -- cgit v1.2.3-55-g6feb