main
h 311 lines 12.8 KB
Raw
1 #pragma once
2 // 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.
3
4
5 #include "dutil.h"
6
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #define BalExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
13 #define BalExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
14 #define BalExitWithRootFailureSource(d, x, e, f, ...) { x = FAILED(e) ? e : E_FAIL; BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
15 #define BalExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } }
16 #define BalExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
17 #define BalExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
18 #define BalExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
19 #define BalExitOnWin32ErrorSource(d, e, x, f, ...) if (ERROR_SUCCESS != e) { x = HRESULT_FROM_WIN32(e); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
20 #define BalExitOnOptionalXmlQueryFailureSource(d, x, b, f, ...) { { if (S_FALSE == x || E_NOTFOUND == x) { b = FALSE; x = S_OK; } else { b = SUCCEEDED(x); } }; BalExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
21 #define BalExitOnRequiredXmlQueryFailureSource(d, x, f, ...) { if (S_FALSE == x) { x = E_NOTFOUND; } BalExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
22
23 #define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
24 #define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
25 #define BalExitWithRootFailure(x, e, f, ...) BalExitWithRootFailureSource(DUTIL_SOURCE_DEFAULT, x, e, f, __VA_ARGS__)
26 #define BalExitOnLastError(x, f, ...) BalExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
27 #define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__)
28 #define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__)
29 #define BalExitWithLastError(x, f, ...) BalExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
30 #define BalExitOnWin32Error(e, x, f, ...) BalExitOnWin32ErrorSource(DUTIL_SOURCE_DEFAULT, e, x, f, __VA_ARGS__)
31 #define BalExitOnOptionalXmlQueryFailure(x, b, f, ...) BalExitOnOptionalXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, b, f, __VA_ARGS__)
32 #define BalExitOnRequiredXmlQueryFailure(x, f, ...) BalExitOnRequiredXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
33
34 #ifndef FACILITY_WIX
35 #define FACILITY_WIX 500
36 #endif
37
38 const LPCWSTR BAL_MANIFEST_FILENAME = L"BootstrapperApplicationData.xml";
39
40 static const HRESULT E_WIXSTDBA_CONDITION_FAILED = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1);
41
42 static const HRESULT E_PREREQBA_INFINITE_LOOP = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1002);
43
44
45 /*******************************************************************
46 BalDebuggerCheck - allows bootstrapper application to explicitly check
47 whether a debugger should be attached to the bootstrapper application.
48
49 Note: Automatically called in BootstrapperApplicationRun().
50 ********************************************************************/
51 DAPI_(VOID) BalDebuggerCheck();
52
53 /*******************************************************************
54 BalInitialize - remembers the engine interface to enable logging and
55 other functions.
56
57 ********************************************************************/
58 DAPI_(void) BalInitialize(
59 __in IBootstrapperEngine* pEngine
60 );
61
62 /*******************************************************************
63 BalUninitialize - cleans up utility layer internals.
64
65 ********************************************************************/
66 DAPI_(void) BalUninitialize();
67
68 /*******************************************************************
69 BalManifestLoad - loads the Application manifest into an XML document.
70
71 ********************************************************************/
72 DAPI_(HRESULT) BalManifestLoad(
73 __in HMODULE hUXModule,
74 __out IXMLDOMDocument** ppixdManifest
75 );
76
77 /*******************************************************************
78 BalEvaluateCondition - evaluates a condition using variables in the engine.
79
80 ********************************************************************/
81 DAPI_(HRESULT) BalEvaluateCondition(
82 __in_z LPCWSTR wzCondition,
83 __out BOOL* pf
84 );
85
86 /*******************************************************************
87 BalEscapeString - escapes a string to use as part of a formatted string variable.
88
89 Note: Use StrFree() to release psczOut.
90 ********************************************************************/
91 DAPI_(HRESULT) BalEscapeString(
92 __in_z LPCWSTR wzIn,
93 __inout LPWSTR* psczOut
94 );
95
96 /*******************************************************************
97 BalEscapeStringFromEngine - escapes a string to use as part of a formatted string variable.
98
99 Note: Use StrFree() to release psczOut.
100 ********************************************************************/
101 DAPI_(HRESULT) BalEscapeStringFromEngine(
102 __in IBootstrapperEngine* pEngine,
103 __in_z LPCWSTR wzIn,
104 __inout LPWSTR* psczOut
105 );
106
107 /*******************************************************************
108 BalFormatString - formats a string using variables in the engine.
109
110 Note: Use StrFree() to release psczOut.
111 ********************************************************************/
112 DAPI_(HRESULT) BalFormatString(
113 __in_z LPCWSTR wzFormat,
114 __inout LPWSTR* psczOut
115 );
116
117 /*******************************************************************
118 BalFormatStringFromEngine - formats a string using variables in the engine.
119
120 Note: Use StrFree() to release psczOut.
121 ********************************************************************/
122 DAPI_(HRESULT) BalFormatStringFromEngine(
123 __in IBootstrapperEngine* pEngine,
124 __in_z LPCWSTR wzFormat,
125 __inout LPWSTR* psczOut
126 );
127
128 /*******************************************************************
129 BalGetNumericVariable - gets a number from a variable in the engine.
130
131 Note: Returns E_NOTFOUND if variable does not exist.
132 ********************************************************************/
133 DAPI_(HRESULT) BalGetNumericVariable(
134 __in_z LPCWSTR wzVariable,
135 __out LONGLONG* pllValue
136 );
137
138 /*******************************************************************
139 BalGetRelatedBundleVariable - gets a string from a shared variable in the engine.
140
141 Note: Use StrFree() to release psczValue.
142 ********************************************************************/
143 DAPI_(HRESULT) BalGetRelatedBundleVariable(
144 __in_z LPCWSTR wzBundleId,
145 __in_z LPCWSTR wzVariable,
146 __inout LPWSTR* psczValue
147 );
148
149 /*******************************************************************
150 BalGetRelatedBundleVariableFromEngine - gets a string from a shared variable in the engine.
151
152 Note: Use StrFree() to release psczValue.
153 ********************************************************************/
154 DAPI_(HRESULT) BalGetRelatedBundleVariableFromEngine(
155 __in IBootstrapperEngine* pEngine,
156 __in_z LPCWSTR wzBundleId,
157 __in_z LPCWSTR wzVariable,
158 __inout LPWSTR* psczValue
159 );
160
161
162 /*******************************************************************
163 BalSetNumericVariable - sets a numeric variable in the engine.
164
165 ********************************************************************/
166 DAPI_(HRESULT) BalSetNumericVariable(
167 __in_z LPCWSTR wzVariable,
168 __in LONGLONG llValue
169 );
170
171 /*******************************************************************
172 BalVariableExists - checks if a variable exists in the engine.
173
174 ********************************************************************/
175 DAPI_(BOOL) BalVariableExists(
176 __in_z LPCWSTR wzVariable
177 );
178
179 /*******************************************************************
180 BalVariableExistsFromEngine - checks if a variable exists in the engine.
181
182 ********************************************************************/
183 DAPI_(BOOL) BalVariableExistsFromEngine(
184 __in IBootstrapperEngine* pEngine,
185 __in_z LPCWSTR wzVariable
186 );
187
188 /*******************************************************************
189 BalGetStringVariable - gets a string from a variable in the engine.
190
191 Note: Use StrFree() to release psczValue.
192 ********************************************************************/
193 DAPI_(HRESULT) BalGetStringVariable(
194 __in_z LPCWSTR wzVariable,
195 __inout LPWSTR* psczValue
196 );
197
198 /*******************************************************************
199 BalGetStringVariableFromEngine - gets a string from a variable in the engine.
200
201 Note: Use StrFree() to release psczValue.
202 ********************************************************************/
203 DAPI_(HRESULT) BalGetStringVariableFromEngine(
204 __in IBootstrapperEngine* pEngine,
205 __in_z LPCWSTR wzVariable,
206 __inout LPWSTR* psczValue
207 );
208
209 /*******************************************************************
210 BalSetStringVariable - sets a string variable in the engine.
211 If the value contains unexpanded variables, set fFormatted to true.
212
213 ********************************************************************/
214 DAPI_(HRESULT) BalSetStringVariable(
215 __in_z LPCWSTR wzVariable,
216 __in_z_opt LPCWSTR wzValue,
217 __in BOOL fFormatted
218 );
219
220 /*******************************************************************
221 BalGetVersionVariable - gets a version from a variable in the engine.
222
223 Note: Use StrFree() to release psczValue.
224 ********************************************************************/
225 DAPI_(HRESULT) BalGetVersionVariable(
226 __in_z LPCWSTR wzVariable,
227 __inout LPWSTR* psczValue
228 );
229
230 /*******************************************************************
231 BalGetVersionVariableFromEngine - gets a version from a variable in the engine.
232
233 Note: Use StrFree() to release psczValue.
234 ********************************************************************/
235 DAPI_(HRESULT) BalGetVersionVariableFromEngine(
236 __in IBootstrapperEngine* pEngine,
237 __in_z LPCWSTR wzVariable,
238 __inout LPWSTR* psczValue
239 );
240
241 /*******************************************************************
242 BalSetVersionVariable - sets a version variable in the engine.
243
244 ********************************************************************/
245 DAPI_(HRESULT) BalSetVersionVariable(
246 __in_z LPCWSTR wzVariable,
247 __in_z_opt LPCWSTR wzValue
248 );
249
250 /*******************************************************************
251 BalLog - logs a message with the engine.
252
253 ********************************************************************/
254 DAPIV_(HRESULT) BalLog(
255 __in BOOTSTRAPPER_LOG_LEVEL level,
256 __in_z __format_string LPCSTR szFormat,
257 ...
258 );
259
260 /*******************************************************************
261 BalLogArgs - logs a message with the engine.
262
263 ********************************************************************/
264 DAPI_(HRESULT) BalLogArgs(
265 __in BOOTSTRAPPER_LOG_LEVEL level,
266 __in_z __format_string LPCSTR szFormat,
267 __in va_list args
268 );
269
270 /*******************************************************************
271 BalLogError - logs an error message with the engine.
272
273 ********************************************************************/
274 DAPIV_(HRESULT) BalLogError(
275 __in HRESULT hr,
276 __in_z __format_string LPCSTR szFormat,
277 ...
278 );
279
280 /*******************************************************************
281 BalLogErrorArgs - logs an error message with the engine.
282
283 ********************************************************************/
284 DAPI_(HRESULT) BalLogErrorArgs(
285 __in HRESULT hr,
286 __in_z __format_string LPCSTR szFormat,
287 __in va_list args
288 );
289
290 /*******************************************************************
291 BalLogId - logs a message with the engine with a string embedded in a
292 MESSAGETABLE resource.
293
294 ********************************************************************/
295 DAPIV_(HRESULT) BalLogId(
296 __in BOOTSTRAPPER_LOG_LEVEL level,
297 __in DWORD dwLogId,
298 __in HMODULE hModule,
299 ...
300 );
301
302 DAPI_(HRESULT) BalLogIdArgs(
303 __in BOOTSTRAPPER_LOG_LEVEL level,
304 __in DWORD dwLogId,
305 __in HMODULE hModule,
306 __in va_list args
307 );
308
309 #ifdef __cplusplus
310 }
311 #endif