diff options
author | Rob Mensching <rob@firegiant.com> | 2021-04-22 17:06:54 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2021-04-29 16:36:06 -0700 |
commit | af10c45d7b3a44af0b461a557847fe03263dcc10 (patch) | |
tree | 6a5c1532304782c36ffe4200b38f3afb76789a43 /src/burn/stub/stub.cpp | |
parent | 9c2aed97299fb96aeee3f1471ce40225437aaecf (diff) | |
download | wix-af10c45d7b3a44af0b461a557847fe03263dcc10.tar.gz wix-af10c45d7b3a44af0b461a557847fe03263dcc10.tar.bz2 wix-af10c45d7b3a44af0b461a557847fe03263dcc10.zip |
Move burn into burn
Diffstat (limited to 'src/burn/stub/stub.cpp')
-rw-r--r-- | src/burn/stub/stub.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
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 @@ | |||
1 | // 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. | ||
2 | |||
3 | #include "precomp.h" | ||
4 | |||
5 | |||
6 | static void CALLBACK BurnTraceError( | ||
7 | __in_z LPCSTR szFile, | ||
8 | __in int iLine, | ||
9 | __in REPORT_LEVEL rl, | ||
10 | __in UINT source, | ||
11 | __in HRESULT hrError, | ||
12 | __in_z __format_string LPCSTR szFormat, | ||
13 | __in va_list args | ||
14 | ); | ||
15 | |||
16 | int WINAPI wWinMain( | ||
17 | __in HINSTANCE hInstance, | ||
18 | __in_opt HINSTANCE /* hPrevInstance */, | ||
19 | __in_z_opt LPWSTR lpCmdLine, | ||
20 | __in int nCmdShow | ||
21 | ) | ||
22 | { | ||
23 | HRESULT hr = S_OK; | ||
24 | DWORD dwExitCode = 0; | ||
25 | LPWSTR sczPath = NULL; | ||
26 | HANDLE hEngineFile = INVALID_HANDLE_VALUE; | ||
27 | |||
28 | LPCWSTR rgsczSafelyLoadSystemDlls[] = | ||
29 | { | ||
30 | L"cabinet.dll", // required by Burn. | ||
31 | L"msi.dll", // required by Burn. | ||
32 | L"version.dll", // required by Burn. | ||
33 | L"wininet.dll", // required by Burn. | ||
34 | |||
35 | L"comres.dll", // required by CLSIDFromProgID() when loading clbcatq.dll. | ||
36 | L"clbcatq.dll", // required by CLSIDFromProgID() when loading msxml?.dll. | ||
37 | |||
38 | L"msasn1.dll", // required by DecryptFile() when loading crypt32.dll. | ||
39 | L"crypt32.dll", // required by DecryptFile() when loading feclient.dll. | ||
40 | L"feclient.dll", // unsafely loaded by DecryptFile(). | ||
41 | }; | ||
42 | |||
43 | DutilInitialize(&BurnTraceError); | ||
44 | |||
45 | // Best effort attempt to get our file handle as soon as possible. | ||
46 | hr = PathForCurrentProcess(&sczPath, NULL); | ||
47 | if (SUCCEEDED(hr)) | ||
48 | { | ||
49 | hEngineFile = ::CreateFileW(sczPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | ||
50 | } | ||
51 | |||
52 | // If the engine is in the clean room, we'll do the unsafe initialization | ||
53 | // because some systems in Windows (namely GDI+) will fail when run in | ||
54 | // a process that protects against DLL hijacking. Since we know the clean | ||
55 | // room is in a clean folder and not subject to DLL hijacking we won't | ||
56 | // make ourselves perfectly secure so that we can load BAs that still | ||
57 | // depend on those parts of Windows that are insecure to DLL hijacking. | ||
58 | if (EngineInCleanRoom(lpCmdLine)) | ||
59 | { | ||
60 | AppInitializeUnsafe(); | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | AppInitialize(rgsczSafelyLoadSystemDlls, countof(rgsczSafelyLoadSystemDlls)); | ||
65 | } | ||
66 | |||
67 | // call run | ||
68 | hr = EngineRun(hInstance, hEngineFile, lpCmdLine, nCmdShow, &dwExitCode); | ||
69 | ExitOnFailure(hr, "Failed to run application."); | ||
70 | |||
71 | LExit: | ||
72 | ReleaseFileHandle(hEngineFile); | ||
73 | ReleaseStr(sczPath); | ||
74 | |||
75 | DutilUninitialize(); | ||
76 | |||
77 | return FAILED(hr) ? (int)hr : (int)dwExitCode; | ||
78 | } | ||
79 | |||
80 | static void CALLBACK BurnTraceError( | ||
81 | __in_z LPCSTR /*szFile*/, | ||
82 | __in int /*iLine*/, | ||
83 | __in REPORT_LEVEL /*rl*/, | ||
84 | __in UINT source, | ||
85 | __in HRESULT hrError, | ||
86 | __in_z __format_string LPCSTR szFormat, | ||
87 | __in va_list args | ||
88 | ) | ||
89 | { | ||
90 | BOOL fLog = FALSE; | ||
91 | |||
92 | switch (source) | ||
93 | { | ||
94 | case DUTIL_SOURCE_DEFAULT: | ||
95 | fLog = TRUE; | ||
96 | break; | ||
97 | default: | ||
98 | fLog = REPORT_VERBOSE < LogGetLevel(); | ||
99 | break; | ||
100 | } | ||
101 | |||
102 | if (fLog) | ||
103 | { | ||
104 | LogErrorStringArgs(hrError, szFormat, args); | ||
105 | } | ||
106 | } | ||