diff options
Diffstat (limited to 'src/api/burn/balutil/inc/balutil.h')
-rw-r--r-- | src/api/burn/balutil/inc/balutil.h | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/src/api/burn/balutil/inc/balutil.h b/src/api/burn/balutil/inc/balutil.h new file mode 100644 index 00000000..fad8a471 --- /dev/null +++ b/src/api/burn/balutil/inc/balutil.h | |||
@@ -0,0 +1,199 @@ | |||
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 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; } } | ||
15 | #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; } | ||
16 | #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; } | ||
17 | #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; } | ||
18 | |||
19 | #define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
20 | #define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
21 | #define BalExitOnLastError(x, f, ...) BalExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
22 | #define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) | ||
23 | #define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) | ||
24 | #define BalExitWithLastError(x, f, ...) BalExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
25 | |||
26 | #ifndef FACILITY_WIX | ||
27 | #define FACILITY_WIX 500 | ||
28 | #endif | ||
29 | |||
30 | const LPCWSTR BAL_MANIFEST_FILENAME = L"BootstrapperApplicationData.xml"; | ||
31 | |||
32 | static const HRESULT E_WIXSTDBA_CONDITION_FAILED = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1); | ||
33 | |||
34 | static const HRESULT E_MBAHOST_NET452_ON_WIN7RTM = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1000); | ||
35 | static const HRESULT E_DNCHOST_SCD_RUNTIME_FAILURE = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1001); | ||
36 | |||
37 | |||
38 | /******************************************************************* | ||
39 | BalInitialize - remembers the engine interface to enable logging and | ||
40 | other functions. | ||
41 | |||
42 | ********************************************************************/ | ||
43 | DAPI_(void) BalInitialize( | ||
44 | __in IBootstrapperEngine* pEngine | ||
45 | ); | ||
46 | |||
47 | /******************************************************************* | ||
48 | BalInitializeFromCreateArgs - convenience function to call BalBootstrapperEngineCreate | ||
49 | then pass it along to BalInitialize. | ||
50 | |||
51 | ********************************************************************/ | ||
52 | DAPI_(HRESULT) BalInitializeFromCreateArgs( | ||
53 | __in const BOOTSTRAPPER_CREATE_ARGS* pArgs, | ||
54 | __out_opt IBootstrapperEngine** ppEngine | ||
55 | ); | ||
56 | |||
57 | /******************************************************************* | ||
58 | BalUninitialize - cleans up utility layer internals. | ||
59 | |||
60 | ********************************************************************/ | ||
61 | DAPI_(void) BalUninitialize(); | ||
62 | |||
63 | /******************************************************************* | ||
64 | BalManifestLoad - loads the Application manifest into an XML document. | ||
65 | |||
66 | ********************************************************************/ | ||
67 | DAPI_(HRESULT) BalManifestLoad( | ||
68 | __in HMODULE hUXModule, | ||
69 | __out IXMLDOMDocument** ppixdManifest | ||
70 | ); | ||
71 | |||
72 | /******************************************************************* | ||
73 | BalEvaluateCondition - evaluates a condition using variables in the engine. | ||
74 | |||
75 | ********************************************************************/ | ||
76 | DAPI_(HRESULT) BalEvaluateCondition( | ||
77 | __in_z LPCWSTR wzCondition, | ||
78 | __out BOOL* pf | ||
79 | ); | ||
80 | |||
81 | /******************************************************************* | ||
82 | BalFormatString - formats a string using variables in the engine. | ||
83 | |||
84 | Note: Use StrFree() to release psczOut. | ||
85 | ********************************************************************/ | ||
86 | DAPI_(HRESULT) BalFormatString( | ||
87 | __in_z LPCWSTR wzFormat, | ||
88 | __inout LPWSTR* psczOut | ||
89 | ); | ||
90 | |||
91 | /******************************************************************* | ||
92 | BalGetNumericVariable - gets a number from a variable in the engine. | ||
93 | |||
94 | Note: Returns E_NOTFOUND if variable does not exist. | ||
95 | ********************************************************************/ | ||
96 | DAPI_(HRESULT) BalGetNumericVariable( | ||
97 | __in_z LPCWSTR wzVariable, | ||
98 | __out LONGLONG* pllValue | ||
99 | ); | ||
100 | |||
101 | /******************************************************************* | ||
102 | BalSetNumericVariable - sets a numeric variable in the engine. | ||
103 | |||
104 | ********************************************************************/ | ||
105 | DAPI_(HRESULT) BalSetNumericVariable( | ||
106 | __in_z LPCWSTR wzVariable, | ||
107 | __in LONGLONG llValue | ||
108 | ); | ||
109 | |||
110 | /******************************************************************* | ||
111 | BalVariableExists - checks if a variable exists in the engine. | ||
112 | |||
113 | ********************************************************************/ | ||
114 | DAPI_(BOOL) BalVariableExists( | ||
115 | __in_z LPCWSTR wzVariable | ||
116 | ); | ||
117 | |||
118 | /******************************************************************* | ||
119 | BalGetStringVariable - gets a string from a variable in the engine. | ||
120 | |||
121 | Note: Use StrFree() to release psczValue. | ||
122 | ********************************************************************/ | ||
123 | DAPI_(HRESULT) BalGetStringVariable( | ||
124 | __in_z LPCWSTR wzVariable, | ||
125 | __inout LPWSTR* psczValue | ||
126 | ); | ||
127 | |||
128 | /******************************************************************* | ||
129 | BalSetStringVariable - sets a string variable in the engine. | ||
130 | |||
131 | ********************************************************************/ | ||
132 | DAPI_(HRESULT) BalSetStringVariable( | ||
133 | __in_z LPCWSTR wzVariable, | ||
134 | __in_z_opt LPCWSTR wzValue, | ||
135 | __in BOOL fFormatted | ||
136 | ); | ||
137 | |||
138 | /******************************************************************* | ||
139 | BalLog - logs a message with the engine. | ||
140 | |||
141 | ********************************************************************/ | ||
142 | DAPIV_(HRESULT) BalLog( | ||
143 | __in BOOTSTRAPPER_LOG_LEVEL level, | ||
144 | __in_z __format_string LPCSTR szFormat, | ||
145 | ... | ||
146 | ); | ||
147 | |||
148 | /******************************************************************* | ||
149 | BalLogArgs - logs a message with the engine. | ||
150 | |||
151 | ********************************************************************/ | ||
152 | DAPI_(HRESULT) BalLogArgs( | ||
153 | __in BOOTSTRAPPER_LOG_LEVEL level, | ||
154 | __in_z __format_string LPCSTR szFormat, | ||
155 | __in va_list args | ||
156 | ); | ||
157 | |||
158 | /******************************************************************* | ||
159 | BalLogError - logs an error message with the engine. | ||
160 | |||
161 | ********************************************************************/ | ||
162 | DAPIV_(HRESULT) BalLogError( | ||
163 | __in HRESULT hr, | ||
164 | __in_z __format_string LPCSTR szFormat, | ||
165 | ... | ||
166 | ); | ||
167 | |||
168 | /******************************************************************* | ||
169 | BalLogErrorArgs - logs an error message with the engine. | ||
170 | |||
171 | ********************************************************************/ | ||
172 | DAPI_(HRESULT) BalLogErrorArgs( | ||
173 | __in HRESULT hr, | ||
174 | __in_z __format_string LPCSTR szFormat, | ||
175 | __in va_list args | ||
176 | ); | ||
177 | |||
178 | /******************************************************************* | ||
179 | BalLogId - logs a message with the engine with a string embedded in a | ||
180 | MESSAGETABLE resource. | ||
181 | |||
182 | ********************************************************************/ | ||
183 | DAPIV_(HRESULT) BalLogId( | ||
184 | __in BOOTSTRAPPER_LOG_LEVEL level, | ||
185 | __in DWORD dwLogId, | ||
186 | __in HMODULE hModule, | ||
187 | ... | ||
188 | ); | ||
189 | |||
190 | DAPI_(HRESULT) BalLogIdArgs( | ||
191 | __in BOOTSTRAPPER_LOG_LEVEL level, | ||
192 | __in DWORD dwLogId, | ||
193 | __in HMODULE hModule, | ||
194 | __in va_list args | ||
195 | ); | ||
196 | |||
197 | #ifdef __cplusplus | ||
198 | } | ||
199 | #endif | ||