diff options
Diffstat (limited to 'src/ext/Bal/wixstdba/wixstdba.cpp')
-rw-r--r-- | src/ext/Bal/wixstdba/wixstdba.cpp | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/src/ext/Bal/wixstdba/wixstdba.cpp b/src/ext/Bal/wixstdba/wixstdba.cpp new file mode 100644 index 00000000..a96f1738 --- /dev/null +++ b/src/ext/Bal/wixstdba/wixstdba.cpp | |||
@@ -0,0 +1,144 @@ | |||
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 | static HINSTANCE vhInstance = NULL; | ||
6 | static IBootstrapperApplication* vpApplication = NULL; | ||
7 | |||
8 | static void CALLBACK WixstdbaTraceError( | ||
9 | __in_z LPCSTR szFile, | ||
10 | __in int iLine, | ||
11 | __in REPORT_LEVEL rl, | ||
12 | __in UINT source, | ||
13 | __in HRESULT hrError, | ||
14 | __in_z __format_string LPCSTR szFormat, | ||
15 | __in va_list args | ||
16 | ); | ||
17 | |||
18 | extern "C" BOOL WINAPI DllMain( | ||
19 | IN HINSTANCE hInstance, | ||
20 | IN DWORD dwReason, | ||
21 | IN LPVOID /* pvReserved */ | ||
22 | ) | ||
23 | { | ||
24 | switch(dwReason) | ||
25 | { | ||
26 | case DLL_PROCESS_ATTACH: | ||
27 | ::DisableThreadLibraryCalls(hInstance); | ||
28 | vhInstance = hInstance; | ||
29 | break; | ||
30 | |||
31 | case DLL_PROCESS_DETACH: | ||
32 | vhInstance = NULL; | ||
33 | break; | ||
34 | } | ||
35 | |||
36 | return TRUE; | ||
37 | } | ||
38 | |||
39 | |||
40 | extern "C" HRESULT WINAPI BootstrapperApplicationCreate( | ||
41 | __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, | ||
42 | __inout BOOTSTRAPPER_CREATE_RESULTS* pResults | ||
43 | ) | ||
44 | { | ||
45 | HRESULT hr = S_OK; | ||
46 | IBootstrapperEngine* pEngine = NULL; | ||
47 | |||
48 | DutilInitialize(&WixstdbaTraceError); | ||
49 | |||
50 | hr = BalInitializeFromCreateArgs(pArgs, &pEngine); | ||
51 | ExitOnFailure(hr, "Failed to initialize Bal."); | ||
52 | |||
53 | hr = CreateBootstrapperApplication(vhInstance, FALSE, S_OK, pEngine, pArgs, pResults, &vpApplication); | ||
54 | BalExitOnFailure(hr, "Failed to create bootstrapper application interface."); | ||
55 | |||
56 | LExit: | ||
57 | ReleaseObject(pEngine); | ||
58 | |||
59 | return hr; | ||
60 | } | ||
61 | |||
62 | |||
63 | extern "C" void WINAPI BootstrapperApplicationDestroy() | ||
64 | { | ||
65 | ReleaseNullObject(vpApplication); | ||
66 | BalUninitialize(); | ||
67 | DutilUninitialize(); | ||
68 | } | ||
69 | |||
70 | |||
71 | extern "C" HRESULT WINAPI DncPrereqBootstrapperApplicationCreate( | ||
72 | __in HRESULT hrHostInitialization, | ||
73 | __in IBootstrapperEngine* pEngine, | ||
74 | __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, | ||
75 | __inout BOOTSTRAPPER_CREATE_RESULTS* pResults | ||
76 | ) | ||
77 | { | ||
78 | HRESULT hr = S_OK; | ||
79 | |||
80 | DutilInitialize(&WixstdbaTraceError); | ||
81 | |||
82 | BalInitialize(pEngine); | ||
83 | |||
84 | hr = CreateBootstrapperApplication(vhInstance, TRUE, hrHostInitialization, pEngine, pArgs, pResults, &vpApplication); | ||
85 | BalExitOnFailure(hr, "Failed to create .NET Core prerequisite bootstrapper application interface."); | ||
86 | |||
87 | LExit: | ||
88 | return hr; | ||
89 | } | ||
90 | |||
91 | |||
92 | extern "C" void WINAPI DncPrereqBootstrapperApplicationDestroy() | ||
93 | { | ||
94 | ReleaseNullObject(vpApplication); | ||
95 | BalUninitialize(); | ||
96 | DutilUninitialize(); | ||
97 | } | ||
98 | |||
99 | |||
100 | extern "C" HRESULT WINAPI MbaPrereqBootstrapperApplicationCreate( | ||
101 | __in HRESULT hrHostInitialization, | ||
102 | __in IBootstrapperEngine* pEngine, | ||
103 | __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, | ||
104 | __inout BOOTSTRAPPER_CREATE_RESULTS* pResults | ||
105 | ) | ||
106 | { | ||
107 | HRESULT hr = S_OK; | ||
108 | |||
109 | DutilInitialize(&WixstdbaTraceError); | ||
110 | |||
111 | BalInitialize(pEngine); | ||
112 | |||
113 | hr = CreateBootstrapperApplication(vhInstance, TRUE, hrHostInitialization, pEngine, pArgs, pResults, &vpApplication); | ||
114 | BalExitOnFailure(hr, "Failed to create managed prerequisite bootstrapper application interface."); | ||
115 | |||
116 | LExit: | ||
117 | return hr; | ||
118 | } | ||
119 | |||
120 | |||
121 | extern "C" void WINAPI MbaPrereqBootstrapperApplicationDestroy() | ||
122 | { | ||
123 | ReleaseNullObject(vpApplication); | ||
124 | BalUninitialize(); | ||
125 | DutilUninitialize(); | ||
126 | } | ||
127 | |||
128 | static void CALLBACK WixstdbaTraceError( | ||
129 | __in_z LPCSTR /*szFile*/, | ||
130 | __in int /*iLine*/, | ||
131 | __in REPORT_LEVEL /*rl*/, | ||
132 | __in UINT source, | ||
133 | __in HRESULT hrError, | ||
134 | __in_z __format_string LPCSTR szFormat, | ||
135 | __in va_list args | ||
136 | ) | ||
137 | { | ||
138 | // BalLogError currently uses the Exit... macros, | ||
139 | // so if expanding the scope need to ensure this doesn't get called recursively. | ||
140 | if (DUTIL_SOURCE_THMUTIL == source) | ||
141 | { | ||
142 | BalLogErrorArgs(hrError, szFormat, args); | ||
143 | } | ||
144 | } | ||