diff options
Diffstat (limited to 'src/api/burn/bextutil')
-rw-r--r-- | src/api/burn/bextutil/BextBundleExtensionEngine.cpp | 344 | ||||
-rw-r--r-- | src/api/burn/bextutil/bextutil.cpp | 221 | ||||
-rw-r--r-- | src/api/burn/bextutil/bextutil.nuspec | 31 | ||||
-rw-r--r-- | src/api/burn/bextutil/bextutil.vcxproj | 90 | ||||
-rw-r--r-- | src/api/burn/bextutil/build/WixToolset.BextUtil.props | 28 | ||||
-rw-r--r-- | src/api/burn/bextutil/inc/BextBaseBundleExtension.h | 120 | ||||
-rw-r--r-- | src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h | 48 | ||||
-rw-r--r-- | src/api/burn/bextutil/inc/BextBundleExtensionEngine.h | 17 | ||||
-rw-r--r-- | src/api/burn/bextutil/inc/IBundleExtension.h | 20 | ||||
-rw-r--r-- | src/api/burn/bextutil/inc/IBundleExtensionEngine.h | 67 | ||||
-rw-r--r-- | src/api/burn/bextutil/inc/bextutil.h | 106 | ||||
-rw-r--r-- | src/api/burn/bextutil/packages.config | 6 | ||||
-rw-r--r-- | src/api/burn/bextutil/precomp.cpp | 3 | ||||
-rw-r--r-- | src/api/burn/bextutil/precomp.h | 22 |
14 files changed, 1123 insertions, 0 deletions
diff --git a/src/api/burn/bextutil/BextBundleExtensionEngine.cpp b/src/api/burn/bextutil/BextBundleExtensionEngine.cpp new file mode 100644 index 00000000..6043e2db --- /dev/null +++ b/src/api/burn/bextutil/BextBundleExtensionEngine.cpp | |||
@@ -0,0 +1,344 @@ | |||
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 | class CBextBundleExtensionEngine : public IBundleExtensionEngine | ||
7 | { | ||
8 | public: // IUnknown | ||
9 | virtual STDMETHODIMP QueryInterface( | ||
10 | __in REFIID riid, | ||
11 | __out LPVOID *ppvObject | ||
12 | ) | ||
13 | { | ||
14 | if (!ppvObject) | ||
15 | { | ||
16 | return E_INVALIDARG; | ||
17 | } | ||
18 | |||
19 | *ppvObject = NULL; | ||
20 | |||
21 | if (::IsEqualIID(__uuidof(IBundleExtensionEngine), riid)) | ||
22 | { | ||
23 | *ppvObject = static_cast<IBundleExtensionEngine*>(this); | ||
24 | } | ||
25 | else if (::IsEqualIID(IID_IUnknown, riid)) | ||
26 | { | ||
27 | *ppvObject = reinterpret_cast<IUnknown*>(this); | ||
28 | } | ||
29 | else // no interface for requested iid | ||
30 | { | ||
31 | return E_NOINTERFACE; | ||
32 | } | ||
33 | |||
34 | AddRef(); | ||
35 | return S_OK; | ||
36 | } | ||
37 | |||
38 | virtual STDMETHODIMP_(ULONG) AddRef() | ||
39 | { | ||
40 | return ::InterlockedIncrement(&this->m_cReferences); | ||
41 | } | ||
42 | |||
43 | virtual STDMETHODIMP_(ULONG) Release() | ||
44 | { | ||
45 | long l = ::InterlockedDecrement(&this->m_cReferences); | ||
46 | if (0 < l) | ||
47 | { | ||
48 | return l; | ||
49 | } | ||
50 | |||
51 | delete this; | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | public: // IBundleExtensionEngine | ||
56 | virtual STDMETHODIMP EscapeString( | ||
57 | __in_z LPCWSTR wzIn, | ||
58 | __out_ecount_opt(*pcchOut) LPWSTR wzOut, | ||
59 | __inout SIZE_T* pcchOut | ||
60 | ) | ||
61 | { | ||
62 | HRESULT hr = S_OK; | ||
63 | BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS args = { }; | ||
64 | BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_RESULTS results = { }; | ||
65 | |||
66 | ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); | ||
67 | |||
68 | args.cbSize = sizeof(args); | ||
69 | args.wzIn = wzIn; | ||
70 | |||
71 | results.cbSize = sizeof(results); | ||
72 | results.wzOut = wzOut; | ||
73 | results.cchOut = *pcchOut; | ||
74 | |||
75 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
76 | |||
77 | *pcchOut = results.cchOut; | ||
78 | |||
79 | LExit: | ||
80 | return hr; | ||
81 | } | ||
82 | |||
83 | virtual STDMETHODIMP EvaluateCondition( | ||
84 | __in_z LPCWSTR wzCondition, | ||
85 | __out BOOL* pf | ||
86 | ) | ||
87 | { | ||
88 | HRESULT hr = S_OK; | ||
89 | BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_ARGS args = { }; | ||
90 | BUNDLE_EXTENSION_ENGINE_EVALUATECONDITION_RESULTS results = { }; | ||
91 | |||
92 | ExitOnNull(pf, hr, E_INVALIDARG, "pf is required"); | ||
93 | |||
94 | args.cbSize = sizeof(args); | ||
95 | args.wzCondition = wzCondition; | ||
96 | |||
97 | results.cbSize = sizeof(results); | ||
98 | |||
99 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
100 | |||
101 | *pf = results.f; | ||
102 | |||
103 | LExit: | ||
104 | return hr; | ||
105 | } | ||
106 | |||
107 | virtual STDMETHODIMP FormatString( | ||
108 | __in_z LPCWSTR wzIn, | ||
109 | __out_ecount_opt(*pcchOut) LPWSTR wzOut, | ||
110 | __inout SIZE_T* pcchOut | ||
111 | ) | ||
112 | { | ||
113 | HRESULT hr = S_OK; | ||
114 | BUNDLE_EXTENSION_ENGINE_FORMATSTRING_ARGS args = { }; | ||
115 | BUNDLE_EXTENSION_ENGINE_FORMATSTRING_RESULTS results = { }; | ||
116 | |||
117 | ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required"); | ||
118 | |||
119 | args.cbSize = sizeof(args); | ||
120 | args.wzIn = wzIn; | ||
121 | |||
122 | results.cbSize = sizeof(results); | ||
123 | results.wzOut = wzOut; | ||
124 | results.cchOut = *pcchOut; | ||
125 | |||
126 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
127 | |||
128 | *pcchOut = results.cchOut; | ||
129 | |||
130 | LExit: | ||
131 | return hr; | ||
132 | } | ||
133 | |||
134 | virtual STDMETHODIMP GetVariableNumeric( | ||
135 | __in_z LPCWSTR wzVariable, | ||
136 | __out LONGLONG* pllValue | ||
137 | ) | ||
138 | { | ||
139 | HRESULT hr = S_OK; | ||
140 | BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_ARGS args = { }; | ||
141 | BUNDLE_EXTENSION_ENGINE_GETVARIABLENUMERIC_RESULTS results = { }; | ||
142 | |||
143 | ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required"); | ||
144 | |||
145 | args.cbSize = sizeof(args); | ||
146 | args.wzVariable = wzVariable; | ||
147 | |||
148 | results.cbSize = sizeof(results); | ||
149 | |||
150 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
151 | |||
152 | *pllValue = results.llValue; | ||
153 | |||
154 | LExit: | ||
155 | SecureZeroMemory(&results, sizeof(results)); | ||
156 | return hr; | ||
157 | } | ||
158 | |||
159 | virtual STDMETHODIMP GetVariableString( | ||
160 | __in_z LPCWSTR wzVariable, | ||
161 | __out_ecount_opt(*pcchValue) LPWSTR wzValue, | ||
162 | __inout SIZE_T* pcchValue | ||
163 | ) | ||
164 | { | ||
165 | HRESULT hr = S_OK; | ||
166 | BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_ARGS args = { }; | ||
167 | BUNDLE_EXTENSION_ENGINE_GETVARIABLESTRING_RESULTS results = { }; | ||
168 | |||
169 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); | ||
170 | |||
171 | args.cbSize = sizeof(args); | ||
172 | args.wzVariable = wzVariable; | ||
173 | |||
174 | results.cbSize = sizeof(results); | ||
175 | results.wzValue = wzValue; | ||
176 | results.cchValue = *pcchValue; | ||
177 | |||
178 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
179 | |||
180 | *pcchValue = results.cchValue; | ||
181 | |||
182 | LExit: | ||
183 | return hr; | ||
184 | } | ||
185 | |||
186 | virtual STDMETHODIMP GetVariableVersion( | ||
187 | __in_z LPCWSTR wzVariable, | ||
188 | __out_ecount_opt(*pcchValue) LPWSTR wzValue, | ||
189 | __inout SIZE_T* pcchValue | ||
190 | ) | ||
191 | { | ||
192 | HRESULT hr = S_OK; | ||
193 | BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS args = { }; | ||
194 | BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS results = { }; | ||
195 | |||
196 | ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); | ||
197 | |||
198 | args.cbSize = sizeof(args); | ||
199 | args.wzVariable = wzVariable; | ||
200 | |||
201 | results.cbSize = sizeof(results); | ||
202 | results.wzValue = wzValue; | ||
203 | results.cchValue = *pcchValue; | ||
204 | |||
205 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
206 | |||
207 | *pcchValue = results.cchValue; | ||
208 | |||
209 | LExit: | ||
210 | return hr; | ||
211 | } | ||
212 | |||
213 | virtual STDMETHODIMP Log( | ||
214 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
215 | __in_z LPCWSTR wzMessage | ||
216 | ) | ||
217 | { | ||
218 | BUNDLE_EXTENSION_ENGINE_LOG_ARGS args = { }; | ||
219 | BUNDLE_EXTENSION_ENGINE_LOG_RESULTS results = { }; | ||
220 | |||
221 | args.cbSize = sizeof(args); | ||
222 | args.level = level; | ||
223 | args.wzMessage = wzMessage; | ||
224 | |||
225 | results.cbSize = sizeof(results); | ||
226 | |||
227 | return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
228 | } | ||
229 | |||
230 | virtual STDMETHODIMP SetVariableNumeric( | ||
231 | __in_z LPCWSTR wzVariable, | ||
232 | __in LONGLONG llValue | ||
233 | ) | ||
234 | { | ||
235 | BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_ARGS args = { }; | ||
236 | BUNDLE_EXTENSION_ENGINE_SETVARIABLENUMERIC_RESULTS results = { }; | ||
237 | |||
238 | args.cbSize = sizeof(args); | ||
239 | args.wzVariable = wzVariable; | ||
240 | args.llValue = llValue; | ||
241 | |||
242 | results.cbSize = sizeof(results); | ||
243 | |||
244 | return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
245 | } | ||
246 | |||
247 | virtual STDMETHODIMP SetVariableString( | ||
248 | __in_z LPCWSTR wzVariable, | ||
249 | __in_z_opt LPCWSTR wzValue, | ||
250 | __in BOOL fFormatted | ||
251 | ) | ||
252 | { | ||
253 | BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; | ||
254 | BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_RESULTS results = { }; | ||
255 | |||
256 | args.cbSize = sizeof(args); | ||
257 | args.wzVariable = wzVariable; | ||
258 | args.wzValue = wzValue; | ||
259 | args.fFormatted = fFormatted; | ||
260 | |||
261 | results.cbSize = sizeof(results); | ||
262 | |||
263 | return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
264 | } | ||
265 | |||
266 | virtual STDMETHODIMP SetVariableVersion( | ||
267 | __in_z LPCWSTR wzVariable, | ||
268 | __in_z_opt LPCWSTR wzValue | ||
269 | ) | ||
270 | { | ||
271 | BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS args = { }; | ||
272 | BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_RESULTS results = { }; | ||
273 | |||
274 | args.cbSize = sizeof(args); | ||
275 | args.wzVariable = wzVariable; | ||
276 | args.wzValue = wzValue; | ||
277 | |||
278 | results.cbSize = sizeof(results); | ||
279 | |||
280 | return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
281 | } | ||
282 | |||
283 | virtual STDMETHODIMP CompareVersions( | ||
284 | __in_z LPCWSTR wzVersion1, | ||
285 | __in_z LPCWSTR wzVersion2, | ||
286 | __out int* pnResult | ||
287 | ) | ||
288 | { | ||
289 | HRESULT hr = S_OK; | ||
290 | BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS args = { }; | ||
291 | BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS results = { }; | ||
292 | |||
293 | ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required"); | ||
294 | |||
295 | args.cbSize = sizeof(args); | ||
296 | args.wzVersion1 = wzVersion1; | ||
297 | args.wzVersion2 = wzVersion2; | ||
298 | |||
299 | results.cbSize = sizeof(results); | ||
300 | |||
301 | hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, &args, &results, m_pvBundleExtensionEngineProcContext); | ||
302 | |||
303 | *pnResult = results.nResult; | ||
304 | |||
305 | LExit: | ||
306 | return hr; | ||
307 | } | ||
308 | |||
309 | public: | ||
310 | CBextBundleExtensionEngine( | ||
311 | __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, | ||
312 | __in_opt LPVOID pvBundleExtensionEngineProcContext | ||
313 | ) | ||
314 | { | ||
315 | m_cReferences = 1; | ||
316 | m_pfnBundleExtensionEngineProc = pfnBundleExtensionEngineProc; | ||
317 | m_pvBundleExtensionEngineProcContext = pvBundleExtensionEngineProcContext; | ||
318 | } | ||
319 | |||
320 | private: | ||
321 | long m_cReferences; | ||
322 | PFN_BUNDLE_EXTENSION_ENGINE_PROC m_pfnBundleExtensionEngineProc; | ||
323 | LPVOID m_pvBundleExtensionEngineProcContext; | ||
324 | }; | ||
325 | |||
326 | HRESULT BextBundleExtensionEngineCreate( | ||
327 | __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, | ||
328 | __in_opt LPVOID pvBundleExtensionEngineProcContext, | ||
329 | __out IBundleExtensionEngine** ppEngineForExtension | ||
330 | ) | ||
331 | { | ||
332 | HRESULT hr = S_OK; | ||
333 | CBextBundleExtensionEngine* pBundleExtensionEngine = NULL; | ||
334 | |||
335 | pBundleExtensionEngine = new CBextBundleExtensionEngine(pfnBundleExtensionEngineProc, pvBundleExtensionEngineProcContext); | ||
336 | ExitOnNull(pBundleExtensionEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BextBundleExtensionEngine object."); | ||
337 | |||
338 | hr = pBundleExtensionEngine->QueryInterface(IID_PPV_ARGS(ppEngineForExtension)); | ||
339 | ExitOnFailure(hr, "Failed to QI for IBundleExtensionEngine from BextBundleExtensionEngine object."); | ||
340 | |||
341 | LExit: | ||
342 | ReleaseObject(pBundleExtensionEngine); | ||
343 | return hr; | ||
344 | } | ||
diff --git a/src/api/burn/bextutil/bextutil.cpp b/src/api/burn/bextutil/bextutil.cpp new file mode 100644 index 00000000..4b22d502 --- /dev/null +++ b/src/api/burn/bextutil/bextutil.cpp | |||
@@ -0,0 +1,221 @@ | |||
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 IBundleExtensionEngine* vpEngine = NULL; | ||
6 | |||
7 | // prototypes | ||
8 | |||
9 | DAPI_(void) BextInitialize( | ||
10 | __in IBundleExtensionEngine* pEngine | ||
11 | ) | ||
12 | { | ||
13 | pEngine->AddRef(); | ||
14 | |||
15 | ReleaseObject(vpEngine); | ||
16 | vpEngine = pEngine; | ||
17 | } | ||
18 | |||
19 | DAPI_(HRESULT) BextInitializeFromCreateArgs( | ||
20 | __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, | ||
21 | __out_opt IBundleExtensionEngine** ppEngine | ||
22 | ) | ||
23 | { | ||
24 | HRESULT hr = S_OK; | ||
25 | IBundleExtensionEngine* pEngine = NULL; | ||
26 | |||
27 | hr = BextBundleExtensionEngineCreate(pArgs->pfnBundleExtensionEngineProc, pArgs->pvBundleExtensionEngineProcContext, &pEngine); | ||
28 | ExitOnFailure(hr, "Failed to create BextBundleExtensionEngine."); | ||
29 | |||
30 | BextInitialize(pEngine); | ||
31 | |||
32 | if (ppEngine) | ||
33 | { | ||
34 | *ppEngine = pEngine; | ||
35 | } | ||
36 | pEngine = NULL; | ||
37 | |||
38 | LExit: | ||
39 | ReleaseObject(pEngine); | ||
40 | |||
41 | return hr; | ||
42 | } | ||
43 | |||
44 | |||
45 | DAPI_(void) BextUninitialize() | ||
46 | { | ||
47 | ReleaseNullObject(vpEngine); | ||
48 | } | ||
49 | |||
50 | DAPI_(HRESULT) BextGetBundleExtensionDataNode( | ||
51 | __in IXMLDOMDocument* pixdManifest, | ||
52 | __in LPCWSTR wzExtensionId, | ||
53 | __out IXMLDOMNode** ppixnBundleExtension | ||
54 | ) | ||
55 | { | ||
56 | HRESULT hr = S_OK; | ||
57 | IXMLDOMElement* pixeBundleExtensionData = NULL; | ||
58 | IXMLDOMNodeList* pixnNodes = NULL; | ||
59 | IXMLDOMNode* pixnNode = NULL; | ||
60 | DWORD cNodes = 0; | ||
61 | LPWSTR sczId = NULL; | ||
62 | |||
63 | // Get BundleExtensionData element. | ||
64 | hr = pixdManifest->get_documentElement(&pixeBundleExtensionData); | ||
65 | ExitOnFailure(hr, "Failed to get BundleExtensionData element."); | ||
66 | |||
67 | // Select BundleExtension nodes. | ||
68 | hr = XmlSelectNodes(pixeBundleExtensionData, L"BundleExtension", &pixnNodes); | ||
69 | ExitOnFailure(hr, "Failed to select BundleExtension nodes."); | ||
70 | |||
71 | // Get BundleExtension node count. | ||
72 | hr = pixnNodes->get_length((long*)&cNodes); | ||
73 | ExitOnFailure(hr, "Failed to get BundleExtension node count."); | ||
74 | |||
75 | if (!cNodes) | ||
76 | { | ||
77 | ExitFunction(); | ||
78 | } | ||
79 | |||
80 | // Find requested extension. | ||
81 | for (DWORD i = 0; i < cNodes; ++i) | ||
82 | { | ||
83 | hr = XmlNextElement(pixnNodes, &pixnNode, NULL); | ||
84 | ExitOnFailure(hr, "Failed to get next node."); | ||
85 | |||
86 | // @Id | ||
87 | hr = XmlGetAttributeEx(pixnNode, L"Id", &sczId); | ||
88 | ExitOnFailure(hr, "Failed to get @Id."); | ||
89 | |||
90 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczId, -1, wzExtensionId, -1)) | ||
91 | { | ||
92 | *ppixnBundleExtension = pixnNode; | ||
93 | pixnNode = NULL; | ||
94 | |||
95 | ExitFunction1(hr = S_OK); | ||
96 | } | ||
97 | |||
98 | // Prepare next iteration. | ||
99 | ReleaseNullObject(pixnNode); | ||
100 | } | ||
101 | |||
102 | hr = E_NOTFOUND; | ||
103 | |||
104 | LExit: | ||
105 | ReleaseStr(sczId); | ||
106 | ReleaseObject(pixnNode); | ||
107 | ReleaseObject(pixnNodes); | ||
108 | ReleaseObject(pixeBundleExtensionData); | ||
109 | |||
110 | return hr; | ||
111 | } | ||
112 | |||
113 | |||
114 | DAPIV_(HRESULT) BextLog( | ||
115 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
116 | __in_z __format_string LPCSTR szFormat, | ||
117 | ... | ||
118 | ) | ||
119 | { | ||
120 | HRESULT hr = S_OK; | ||
121 | va_list args; | ||
122 | |||
123 | if (!vpEngine) | ||
124 | { | ||
125 | hr = E_POINTER; | ||
126 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | ||
127 | } | ||
128 | |||
129 | va_start(args, szFormat); | ||
130 | hr = BextLogArgs(level, szFormat, args); | ||
131 | va_end(args); | ||
132 | |||
133 | LExit: | ||
134 | return hr; | ||
135 | } | ||
136 | |||
137 | |||
138 | DAPI_(HRESULT) BextLogArgs( | ||
139 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
140 | __in_z __format_string LPCSTR szFormat, | ||
141 | __in va_list args | ||
142 | ) | ||
143 | { | ||
144 | HRESULT hr = S_OK; | ||
145 | LPSTR sczFormattedAnsi = NULL; | ||
146 | LPWSTR sczMessage = NULL; | ||
147 | |||
148 | if (!vpEngine) | ||
149 | { | ||
150 | hr = E_POINTER; | ||
151 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | ||
152 | } | ||
153 | |||
154 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); | ||
155 | ExitOnFailure(hr, "Failed to format log string."); | ||
156 | |||
157 | hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); | ||
158 | ExitOnFailure(hr, "Failed to convert log string to Unicode."); | ||
159 | |||
160 | hr = vpEngine->Log(level, sczMessage); | ||
161 | |||
162 | LExit: | ||
163 | ReleaseStr(sczMessage); | ||
164 | ReleaseStr(sczFormattedAnsi); | ||
165 | return hr; | ||
166 | } | ||
167 | |||
168 | |||
169 | DAPIV_(HRESULT) BextLogError( | ||
170 | __in HRESULT hrError, | ||
171 | __in_z __format_string LPCSTR szFormat, | ||
172 | ... | ||
173 | ) | ||
174 | { | ||
175 | HRESULT hr = S_OK; | ||
176 | va_list args; | ||
177 | |||
178 | if (!vpEngine) | ||
179 | { | ||
180 | hr = E_POINTER; | ||
181 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | ||
182 | } | ||
183 | |||
184 | va_start(args, szFormat); | ||
185 | hr = BextLogErrorArgs(hrError, szFormat, args); | ||
186 | va_end(args); | ||
187 | |||
188 | LExit: | ||
189 | return hr; | ||
190 | } | ||
191 | |||
192 | |||
193 | DAPI_(HRESULT) BextLogErrorArgs( | ||
194 | __in HRESULT hrError, | ||
195 | __in_z __format_string LPCSTR szFormat, | ||
196 | __in va_list args | ||
197 | ) | ||
198 | { | ||
199 | HRESULT hr = S_OK; | ||
200 | LPSTR sczFormattedAnsi = NULL; | ||
201 | LPWSTR sczMessage = NULL; | ||
202 | |||
203 | if (!vpEngine) | ||
204 | { | ||
205 | hr = E_POINTER; | ||
206 | ExitOnRootFailure(hr, "BextInitialize() must be called first."); | ||
207 | } | ||
208 | |||
209 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); | ||
210 | ExitOnFailure(hr, "Failed to format error log string."); | ||
211 | |||
212 | hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); | ||
213 | ExitOnFailure(hr, "Failed to prepend error number to error log string."); | ||
214 | |||
215 | hr = vpEngine->Log(BUNDLE_EXTENSION_LOG_LEVEL_ERROR, sczMessage); | ||
216 | |||
217 | LExit: | ||
218 | ReleaseStr(sczMessage); | ||
219 | ReleaseStr(sczFormattedAnsi); | ||
220 | return hr; | ||
221 | } | ||
diff --git a/src/api/burn/bextutil/bextutil.nuspec b/src/api/burn/bextutil/bextutil.nuspec new file mode 100644 index 00000000..752dbb97 --- /dev/null +++ b/src/api/burn/bextutil/bextutil.nuspec | |||
@@ -0,0 +1,31 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <package > | ||
3 | <metadata> | ||
4 | <id>$id$</id> | ||
5 | <version>$version$</version> | ||
6 | <authors>$authors$</authors> | ||
7 | <owners>$authors$</owners> | ||
8 | <license type="expression">MS-RL</license> | ||
9 | <projectUrl>https://github.com/wixtoolset/balutil</projectUrl> | ||
10 | <requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
11 | <description>$description$</description> | ||
12 | <copyright>$copyright$</copyright> | ||
13 | <dependencies> | ||
14 | <dependency id="WixToolset.BootstrapperCore.Native" version="[4,5)" /> | ||
15 | <dependency id="WixToolset.DUtil" version="[4,5)" /> | ||
16 | </dependencies> | ||
17 | </metadata> | ||
18 | |||
19 | <files> | ||
20 | <file src="build\$id$.props" target="build\" /> | ||
21 | <file src="inc\*" target="build\native\include" /> | ||
22 | <file src="..\..\build\$configuration$\v140\x86\bextutil.lib" target="build\native\v140\x86" /> | ||
23 | <file src="..\..\build\$configuration$\v140\x64\bextutil.lib" target="build\native\v140\x64" /> | ||
24 | <file src="..\..\build\$configuration$\v141\x86\bextutil.lib" target="build\native\v141\x86" /> | ||
25 | <file src="..\..\build\$configuration$\v141\x64\bextutil.lib" target="build\native\v141\x64" /> | ||
26 | <file src="..\..\build\$configuration$\v141\ARM64\bextutil.lib" target="build\native\v141\ARM64" /> | ||
27 | <file src="..\..\build\$configuration$\v142\x86\bextutil.lib" target="build\native\v142\x86" /> | ||
28 | <file src="..\..\build\$configuration$\v142\x64\bextutil.lib" target="build\native\v142\x64" /> | ||
29 | <file src="..\..\build\$configuration$\v142\ARM64\bextutil.lib" target="build\native\v142\ARM64" /> | ||
30 | </files> | ||
31 | </package> | ||
diff --git a/src/api/burn/bextutil/bextutil.vcxproj b/src/api/burn/bextutil/bextutil.vcxproj new file mode 100644 index 00000000..b9334cf3 --- /dev/null +++ b/src/api/burn/bextutil/bextutil.vcxproj | |||
@@ -0,0 +1,90 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
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 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
5 | <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.141\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.141\build\WixToolset.BootstrapperCore.Native.props')" /> | ||
6 | <Import Project="..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props')" /> | ||
7 | |||
8 | <ItemGroup Label="ProjectConfigurations"> | ||
9 | <ProjectConfiguration Include="Debug|ARM64"> | ||
10 | <Configuration>Debug</Configuration> | ||
11 | <Platform>ARM64</Platform> | ||
12 | </ProjectConfiguration> | ||
13 | <ProjectConfiguration Include="Release|ARM64"> | ||
14 | <Configuration>Release</Configuration> | ||
15 | <Platform>ARM64</Platform> | ||
16 | </ProjectConfiguration> | ||
17 | <ProjectConfiguration Include="Debug|Win32"> | ||
18 | <Configuration>Debug</Configuration> | ||
19 | <Platform>Win32</Platform> | ||
20 | </ProjectConfiguration> | ||
21 | <ProjectConfiguration Include="Release|Win32"> | ||
22 | <Configuration>Release</Configuration> | ||
23 | <Platform>Win32</Platform> | ||
24 | </ProjectConfiguration> | ||
25 | <ProjectConfiguration Include="Debug|x64"> | ||
26 | <Configuration>Debug</Configuration> | ||
27 | <Platform>x64</Platform> | ||
28 | </ProjectConfiguration> | ||
29 | <ProjectConfiguration Include="Release|x64"> | ||
30 | <Configuration>Release</Configuration> | ||
31 | <Platform>x64</Platform> | ||
32 | </ProjectConfiguration> | ||
33 | </ItemGroup> | ||
34 | |||
35 | <PropertyGroup Label="Globals"> | ||
36 | <ProjectGuid>{06027492-1CB9-48BC-B31E-C1F9356ED07E}</ProjectGuid> | ||
37 | <ConfigurationType>StaticLibrary</ConfigurationType> | ||
38 | <TargetName>bextutil</TargetName> | ||
39 | <PlatformToolset>v142</PlatformToolset> | ||
40 | <CharacterSet>MultiByte</CharacterSet> | ||
41 | <Description>WiX Toolset Bundle Extension native utility library</Description> | ||
42 | <PackageId>WixToolset.BextUtil</PackageId> | ||
43 | </PropertyGroup> | ||
44 | |||
45 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
46 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
47 | <Import Project="..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" /> | ||
48 | <Import Project="..\NativeMultiTargeting.Build.props" /> | ||
49 | |||
50 | <ImportGroup Label="ExtensionSettings"> | ||
51 | </ImportGroup> | ||
52 | |||
53 | <ImportGroup Label="Shared"> | ||
54 | </ImportGroup> | ||
55 | |||
56 | <PropertyGroup> | ||
57 | <ProjectAdditionalIncludeDirectories>$(ProjectDir)..\inc</ProjectAdditionalIncludeDirectories> | ||
58 | </PropertyGroup> | ||
59 | |||
60 | <ItemGroup> | ||
61 | <ClCompile Include="BextBundleExtensionEngine.cpp" /> | ||
62 | <ClCompile Include="bextutil.cpp" /> | ||
63 | <ClCompile Include="precomp.cpp"> | ||
64 | <PrecompiledHeader>Create</PrecompiledHeader> | ||
65 | </ClCompile> | ||
66 | </ItemGroup> | ||
67 | <ItemGroup> | ||
68 | <ClInclude Include="inc\BextBaseBundleExtension.h" /> | ||
69 | <ClInclude Include="inc\BextBaseBundleExtensionProc.h" /> | ||
70 | <ClInclude Include="inc\BextBundleExtensionEngine.h" /> | ||
71 | <ClInclude Include="inc\bextutil.h" /> | ||
72 | <ClInclude Include="inc\IBundleExtension.h" /> | ||
73 | <ClInclude Include="inc\IBundleExtensionEngine.h" /> | ||
74 | <ClInclude Include="precomp.h" /> | ||
75 | </ItemGroup> | ||
76 | |||
77 | <ItemGroup> | ||
78 | <None Include="packages.config" /> | ||
79 | </ItemGroup> | ||
80 | |||
81 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
82 | <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
83 | <PropertyGroup> | ||
84 | <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
85 | </PropertyGroup> | ||
86 | <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props'))" /> | ||
87 | <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets'))" /> | ||
88 | <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.141\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.141\build\WixToolset.BootstrapperCore.Native.props'))" /> | ||
89 | </Target> | ||
90 | </Project> \ No newline at end of file | ||
diff --git a/src/api/burn/bextutil/build/WixToolset.BextUtil.props b/src/api/burn/bextutil/build/WixToolset.BextUtil.props new file mode 100644 index 00000000..60a2db54 --- /dev/null +++ b/src/api/burn/bextutil/build/WixToolset.BextUtil.props | |||
@@ -0,0 +1,28 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
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 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
5 | <ItemDefinitionGroup> | ||
6 | <ClCompile> | ||
7 | <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
8 | </ClCompile> | ||
9 | <ResourceCompile> | ||
10 | <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)native\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
11 | </ResourceCompile> | ||
12 | </ItemDefinitionGroup> | ||
13 | <ItemDefinitionGroup Condition=" $(PlatformToolset.ToLower().StartsWith('v140')) "> | ||
14 | <Link> | ||
15 | <AdditionalDependencies>$(MSBuildThisFileDirectory)native\v140\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
16 | </Link> | ||
17 | </ItemDefinitionGroup> | ||
18 | <ItemDefinitionGroup Condition=" $(PlatformToolset.ToLower().StartsWith('v141')) "> | ||
19 | <Link> | ||
20 | <AdditionalDependencies>$(MSBuildThisFileDirectory)native\v141\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
21 | </Link> | ||
22 | </ItemDefinitionGroup> | ||
23 | <ItemDefinitionGroup Condition=" $(PlatformToolset.ToLower().StartsWith('v142')) "> | ||
24 | <Link> | ||
25 | <AdditionalDependencies>$(MSBuildThisFileDirectory)native\v142\$(PlatformTarget)\bextutil.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
26 | </Link> | ||
27 | </ItemDefinitionGroup> | ||
28 | </Project> | ||
diff --git a/src/api/burn/bextutil/inc/BextBaseBundleExtension.h b/src/api/burn/bextutil/inc/BextBaseBundleExtension.h new file mode 100644 index 00000000..69c338e4 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBaseBundleExtension.h | |||
@@ -0,0 +1,120 @@ | |||
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 <windows.h> | ||
4 | |||
5 | #include "BundleExtensionEngine.h" | ||
6 | #include "BundleExtension.h" | ||
7 | #include "IBundleExtensionEngine.h" | ||
8 | #include "IBundleExtension.h" | ||
9 | |||
10 | #include "bextutil.h" | ||
11 | |||
12 | class CBextBaseBundleExtension : public IBundleExtension | ||
13 | { | ||
14 | public: // IUnknown | ||
15 | virtual STDMETHODIMP QueryInterface( | ||
16 | __in REFIID riid, | ||
17 | __out LPVOID *ppvObject | ||
18 | ) | ||
19 | { | ||
20 | if (!ppvObject) | ||
21 | { | ||
22 | return E_INVALIDARG; | ||
23 | } | ||
24 | |||
25 | *ppvObject = NULL; | ||
26 | |||
27 | if (::IsEqualIID(__uuidof(IBundleExtension), riid)) | ||
28 | { | ||
29 | *ppvObject = static_cast<IBundleExtension*>(this); | ||
30 | } | ||
31 | else if (::IsEqualIID(IID_IUnknown, riid)) | ||
32 | { | ||
33 | *ppvObject = static_cast<IUnknown*>(this); | ||
34 | } | ||
35 | else // no interface for requested iid | ||
36 | { | ||
37 | return E_NOINTERFACE; | ||
38 | } | ||
39 | |||
40 | AddRef(); | ||
41 | return S_OK; | ||
42 | } | ||
43 | |||
44 | virtual STDMETHODIMP_(ULONG) AddRef() | ||
45 | { | ||
46 | return ::InterlockedIncrement(&this->m_cReferences); | ||
47 | } | ||
48 | |||
49 | virtual STDMETHODIMP_(ULONG) Release() | ||
50 | { | ||
51 | long l = ::InterlockedDecrement(&this->m_cReferences); | ||
52 | if (0 < l) | ||
53 | { | ||
54 | return l; | ||
55 | } | ||
56 | |||
57 | delete this; | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | public: // IBundleExtension | ||
62 | virtual STDMETHODIMP Search( | ||
63 | __in LPCWSTR /*wzId*/, | ||
64 | __in LPCWSTR /*wzVariable*/ | ||
65 | ) | ||
66 | { | ||
67 | return E_NOTIMPL; | ||
68 | } | ||
69 | |||
70 | virtual STDMETHODIMP BundleExtensionProc( | ||
71 | __in BUNDLE_EXTENSION_MESSAGE /*message*/, | ||
72 | __in const LPVOID /*pvArgs*/, | ||
73 | __inout LPVOID /*pvResults*/, | ||
74 | __in_opt LPVOID /*pvContext*/ | ||
75 | ) | ||
76 | { | ||
77 | return E_NOTIMPL; | ||
78 | } | ||
79 | |||
80 | public: //CBextBaseBundleExtension | ||
81 | virtual STDMETHODIMP Initialize( | ||
82 | __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs | ||
83 | ) | ||
84 | { | ||
85 | HRESULT hr = S_OK; | ||
86 | |||
87 | hr = StrAllocString(&m_sczBundleExtensionDataPath, pCreateArgs->wzBundleExtensionDataPath, 0); | ||
88 | ExitOnFailure(hr, "Failed to copy BundleExtensionDataPath."); | ||
89 | |||
90 | LExit: | ||
91 | return hr; | ||
92 | } | ||
93 | |||
94 | protected: | ||
95 | |||
96 | CBextBaseBundleExtension( | ||
97 | __in IBundleExtensionEngine* pEngine | ||
98 | ) | ||
99 | { | ||
100 | m_cReferences = 1; | ||
101 | |||
102 | pEngine->AddRef(); | ||
103 | m_pEngine = pEngine; | ||
104 | |||
105 | m_sczBundleExtensionDataPath = NULL; | ||
106 | } | ||
107 | |||
108 | virtual ~CBextBaseBundleExtension() | ||
109 | { | ||
110 | ReleaseNullObject(m_pEngine); | ||
111 | ReleaseStr(m_sczBundleExtensionDataPath); | ||
112 | } | ||
113 | |||
114 | protected: | ||
115 | IBundleExtensionEngine* m_pEngine; | ||
116 | LPWSTR m_sczBundleExtensionDataPath; | ||
117 | |||
118 | private: | ||
119 | long m_cReferences; | ||
120 | }; | ||
diff --git a/src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h b/src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h new file mode 100644 index 00000000..f71e3b92 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBaseBundleExtensionProc.h | |||
@@ -0,0 +1,48 @@ | |||
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 <windows.h> | ||
6 | |||
7 | #include "BundleExtensionEngine.h" | ||
8 | #include "BundleExtension.h" | ||
9 | #include "IBundleExtensionEngine.h" | ||
10 | #include "IBundleExtension.h" | ||
11 | |||
12 | static HRESULT BextBaseBEProcSearch( | ||
13 | __in IBundleExtension* pBE, | ||
14 | __in BUNDLE_EXTENSION_SEARCH_ARGS* pArgs, | ||
15 | __inout BUNDLE_EXTENSION_SEARCH_RESULTS* /*pResults*/ | ||
16 | ) | ||
17 | { | ||
18 | return pBE->Search(pArgs->wzId, pArgs->wzVariable); | ||
19 | } | ||
20 | |||
21 | /******************************************************************* | ||
22 | BextBaseBundleExtensionProc - requires pvContext to be of type IBundleExtension. | ||
23 | Provides a default mapping between the message based | ||
24 | BundleExtension interface and the COM-based BundleExtension interface. | ||
25 | |||
26 | *******************************************************************/ | ||
27 | static HRESULT WINAPI BextBaseBundleExtensionProc( | ||
28 | __in BUNDLE_EXTENSION_MESSAGE message, | ||
29 | __in const LPVOID pvArgs, | ||
30 | __inout LPVOID pvResults, | ||
31 | __in_opt LPVOID pvContext | ||
32 | ) | ||
33 | { | ||
34 | IBundleExtension* pBE = reinterpret_cast<IBundleExtension*>(pvContext); | ||
35 | HRESULT hr = pBE->BundleExtensionProc(message, pvArgs, pvResults, pvContext); | ||
36 | |||
37 | if (E_NOTIMPL == hr) | ||
38 | { | ||
39 | switch (message) | ||
40 | { | ||
41 | case BUNDLE_EXTENSION_MESSAGE_SEARCH: | ||
42 | hr = BextBaseBEProcSearch(pBE, reinterpret_cast<BUNDLE_EXTENSION_SEARCH_ARGS*>(pvArgs), reinterpret_cast<BUNDLE_EXTENSION_SEARCH_RESULTS*>(pvResults)); | ||
43 | break; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | return hr; | ||
48 | } | ||
diff --git a/src/api/burn/bextutil/inc/BextBundleExtensionEngine.h b/src/api/burn/bextutil/inc/BextBundleExtensionEngine.h new file mode 100644 index 00000000..9fdcb700 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBundleExtensionEngine.h | |||
@@ -0,0 +1,17 @@ | |||
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 | #ifdef __cplusplus | ||
4 | extern "C" { | ||
5 | #endif | ||
6 | |||
7 | // function declarations | ||
8 | |||
9 | HRESULT BextBundleExtensionEngineCreate( | ||
10 | __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc, | ||
11 | __in_opt LPVOID pvBundleExtensionEngineProcContext, | ||
12 | __out IBundleExtensionEngine** ppEngineForExtension | ||
13 | ); | ||
14 | |||
15 | #ifdef __cplusplus | ||
16 | } | ||
17 | #endif | ||
diff --git a/src/api/burn/bextutil/inc/IBundleExtension.h b/src/api/burn/bextutil/inc/IBundleExtension.h new file mode 100644 index 00000000..7516c11b --- /dev/null +++ b/src/api/burn/bextutil/inc/IBundleExtension.h | |||
@@ -0,0 +1,20 @@ | |||
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 | DECLARE_INTERFACE_IID_(IBundleExtension, IUnknown, "93123C9D-796B-4FCD-A507-6EDEF9A925FD") | ||
6 | { | ||
7 | STDMETHOD(Search)( | ||
8 | __in LPCWSTR wzId, | ||
9 | __in LPCWSTR wzVariable | ||
10 | ) = 0; | ||
11 | |||
12 | // BundleExtensionProc - The PFN_BUNDLE_EXTENSION_PROC can call this method to give the BundleExtension raw access to the callback from the engine. | ||
13 | // This might be used to help the BundleExtension support more than one version of the engine. | ||
14 | STDMETHOD(BundleExtensionProc)( | ||
15 | __in BUNDLE_EXTENSION_MESSAGE message, | ||
16 | __in const LPVOID pvArgs, | ||
17 | __inout LPVOID pvResults, | ||
18 | __in_opt LPVOID pvContext | ||
19 | ) = 0; | ||
20 | }; | ||
diff --git a/src/api/burn/bextutil/inc/IBundleExtensionEngine.h b/src/api/burn/bextutil/inc/IBundleExtensionEngine.h new file mode 100644 index 00000000..63dadb06 --- /dev/null +++ b/src/api/burn/bextutil/inc/IBundleExtensionEngine.h | |||
@@ -0,0 +1,67 @@ | |||
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 | DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-9737-C185089EB263") | ||
6 | { | ||
7 | STDMETHOD(EscapeString)( | ||
8 | __in_z LPCWSTR wzIn, | ||
9 | __out_ecount_opt(*pcchOut) LPWSTR wzOut, | ||
10 | __inout SIZE_T* pcchOut | ||
11 | ) = 0; | ||
12 | |||
13 | STDMETHOD(EvaluateCondition)( | ||
14 | __in_z LPCWSTR wzCondition, | ||
15 | __out BOOL* pf | ||
16 | ) = 0; | ||
17 | |||
18 | STDMETHOD(FormatString)( | ||
19 | __in_z LPCWSTR wzIn, | ||
20 | __out_ecount_opt(*pcchOut) LPWSTR wzOut, | ||
21 | __inout SIZE_T* pcchOut | ||
22 | ) = 0; | ||
23 | |||
24 | STDMETHOD(GetVariableNumeric)( | ||
25 | __in_z LPCWSTR wzVariable, | ||
26 | __out LONGLONG* pllValue | ||
27 | ) = 0; | ||
28 | |||
29 | STDMETHOD(GetVariableString)( | ||
30 | __in_z LPCWSTR wzVariable, | ||
31 | __out_ecount_opt(*pcchValue) LPWSTR wzValue, | ||
32 | __inout SIZE_T* pcchValue | ||
33 | ) = 0; | ||
34 | |||
35 | STDMETHOD(GetVariableVersion)( | ||
36 | __in_z LPCWSTR wzVariable, | ||
37 | __out_ecount_opt(*pcchValue) LPWSTR wzValue, | ||
38 | __inout SIZE_T* pcchValue | ||
39 | ) = 0; | ||
40 | |||
41 | STDMETHOD(Log)( | ||
42 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
43 | __in_z LPCWSTR wzMessage | ||
44 | ) = 0; | ||
45 | |||
46 | STDMETHOD(SetVariableNumeric)( | ||
47 | __in_z LPCWSTR wzVariable, | ||
48 | __in LONGLONG llValue | ||
49 | ) = 0; | ||
50 | |||
51 | STDMETHOD(SetVariableString)( | ||
52 | __in_z LPCWSTR wzVariable, | ||
53 | __in_z_opt LPCWSTR wzValue, | ||
54 | __in BOOL fFormatted | ||
55 | ) = 0; | ||
56 | |||
57 | STDMETHOD(SetVariableVersion)( | ||
58 | __in_z LPCWSTR wzVariable, | ||
59 | __in_z_opt LPCWSTR wzValue | ||
60 | ) = 0; | ||
61 | |||
62 | STDMETHOD(CompareVersions)( | ||
63 | __in_z LPCWSTR wzVersion1, | ||
64 | __in_z LPCWSTR wzVersion2, | ||
65 | __out int* pnResult | ||
66 | ) = 0; | ||
67 | }; | ||
diff --git a/src/api/burn/bextutil/inc/bextutil.h b/src/api/burn/bextutil/inc/bextutil.h new file mode 100644 index 00000000..ac9c0062 --- /dev/null +++ b/src/api/burn/bextutil/inc/bextutil.h | |||
@@ -0,0 +1,106 @@ | |||
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 BextExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
13 | #define BextExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
14 | #define BextExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } | ||
15 | #define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
16 | #define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
17 | #define BextExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
18 | |||
19 | #define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
20 | #define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
21 | #define BextExitOnLastError(x, f, ...) BextExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
22 | #define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__) | ||
23 | #define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__) | ||
24 | #define BextExitWithLastError(x, f, ...) BextExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__) | ||
25 | |||
26 | const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml"; | ||
27 | |||
28 | |||
29 | /******************************************************************* | ||
30 | BextInitialize - remembers the engine interface to enable logging and | ||
31 | other functions. | ||
32 | |||
33 | ********************************************************************/ | ||
34 | DAPI_(void) BextInitialize( | ||
35 | __in IBundleExtensionEngine* pEngine | ||
36 | ); | ||
37 | |||
38 | /******************************************************************* | ||
39 | BextInitializeFromCreateArgs - convenience function to call BextBundleExtensionEngineCreate | ||
40 | then pass it along to BextInitialize. | ||
41 | |||
42 | ********************************************************************/ | ||
43 | DAPI_(HRESULT) BextInitializeFromCreateArgs( | ||
44 | __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, | ||
45 | __out IBundleExtensionEngine** ppEngine | ||
46 | ); | ||
47 | |||
48 | /******************************************************************* | ||
49 | BextUninitialize - cleans up utility layer internals. | ||
50 | |||
51 | ********************************************************************/ | ||
52 | DAPI_(void) BextUninitialize(); | ||
53 | |||
54 | /******************************************************************* | ||
55 | BextGetBundleExtensionDataNode - gets the requested BundleExtension node. | ||
56 | |||
57 | ********************************************************************/ | ||
58 | DAPI_(HRESULT) BextGetBundleExtensionDataNode( | ||
59 | __in IXMLDOMDocument* pixdManifest, | ||
60 | __in LPCWSTR wzExtensionId, | ||
61 | __out IXMLDOMNode** ppixnBundleExtension | ||
62 | ); | ||
63 | |||
64 | /******************************************************************* | ||
65 | BextLog - logs a message with the engine. | ||
66 | |||
67 | ********************************************************************/ | ||
68 | DAPIV_(HRESULT) BextLog( | ||
69 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
70 | __in_z __format_string LPCSTR szFormat, | ||
71 | ... | ||
72 | ); | ||
73 | |||
74 | /******************************************************************* | ||
75 | BextLogArgs - logs a message with the engine. | ||
76 | |||
77 | ********************************************************************/ | ||
78 | DAPI_(HRESULT) BextLogArgs( | ||
79 | __in BUNDLE_EXTENSION_LOG_LEVEL level, | ||
80 | __in_z __format_string LPCSTR szFormat, | ||
81 | __in va_list args | ||
82 | ); | ||
83 | |||
84 | /******************************************************************* | ||
85 | BextLogError - logs an error message with the engine. | ||
86 | |||
87 | ********************************************************************/ | ||
88 | DAPIV_(HRESULT) BextLogError( | ||
89 | __in HRESULT hr, | ||
90 | __in_z __format_string LPCSTR szFormat, | ||
91 | ... | ||
92 | ); | ||
93 | |||
94 | /******************************************************************* | ||
95 | BextLogErrorArgs - logs an error message with the engine. | ||
96 | |||
97 | ********************************************************************/ | ||
98 | DAPI_(HRESULT) BextLogErrorArgs( | ||
99 | __in HRESULT hr, | ||
100 | __in_z __format_string LPCSTR szFormat, | ||
101 | __in va_list args | ||
102 | ); | ||
103 | |||
104 | #ifdef __cplusplus | ||
105 | } | ||
106 | #endif | ||
diff --git a/src/api/burn/bextutil/packages.config b/src/api/burn/bextutil/packages.config new file mode 100644 index 00000000..08ea3364 --- /dev/null +++ b/src/api/burn/bextutil/packages.config | |||
@@ -0,0 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <packages> | ||
3 | <package id="Nerdbank.GitVersioning" version="3.3.37" targetFramework="native" developmentDependency="true" /> | ||
4 | <package id="WixToolset.BootstrapperCore.Native" version="4.0.141" targetFramework="native" /> | ||
5 | <package id="WixToolset.DUtil" version="4.0.72" targetFramework="native" /> | ||
6 | </packages> \ No newline at end of file | ||
diff --git a/src/api/burn/bextutil/precomp.cpp b/src/api/burn/bextutil/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/api/burn/bextutil/precomp.cpp | |||
@@ -0,0 +1,3 @@ | |||
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" | ||
diff --git a/src/api/burn/bextutil/precomp.h b/src/api/burn/bextutil/precomp.h new file mode 100644 index 00000000..5d1dd20b --- /dev/null +++ b/src/api/burn/bextutil/precomp.h | |||
@@ -0,0 +1,22 @@ | |||
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 <windows.h> | ||
6 | #include <strsafe.h> | ||
7 | #include <msxml2.h> | ||
8 | |||
9 | #include <dutil.h> | ||
10 | #include <locutil.h> | ||
11 | #include <memutil.h> | ||
12 | #include <strutil.h> | ||
13 | #include <xmlutil.h> | ||
14 | |||
15 | #include <BundleExtensionEngine.h> | ||
16 | #include <BundleExtension.h> | ||
17 | |||
18 | #include "IBundleExtensionEngine.h" | ||
19 | #include "IBundleExtension.h" | ||
20 | |||
21 | #include "bextutil.h" | ||
22 | #include "BextBundleExtensionEngine.h" | ||