@joebigelow / wix-1 / commits / 60069b18

Import code from old v4 repo

Sean Hall committed Dec 29, 2018 at 22:24 UTC 60069b189db09521558b99827aee47fe3f81309b
17 files changed +4724
src/balutil/BalBootstrapperEngine.cpp new
+720
@@ -0,0 +1,720 @@
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 CBalBootstrapperEngine : public IBootstrapperEngine, public IMarshal
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(IBootstrapperEngine), riid))
22 + {
23 + *ppvObject = static_cast<IBootstrapperEngine*>(this);
24 + }
25 + else if (::IsEqualIID(IID_IMarshal, riid))
26 + {
27 + *ppvObject = static_cast<IMarshal*>(this);
28 + }
29 + else if (::IsEqualIID(IID_IUnknown, riid))
30 + {
31 + *ppvObject = reinterpret_cast<IUnknown*>(this);
32 + }
33 + else // no interface for requested iid
34 + {
35 + return E_NOINTERFACE;
36 + }
37 +
38 + AddRef();
39 + return S_OK;
40 + }
41 +
42 + virtual STDMETHODIMP_(ULONG) AddRef()
43 + {
44 + return ::InterlockedIncrement(&this->m_cReferences);
45 + }
46 +
47 + virtual STDMETHODIMP_(ULONG) Release()
48 + {
49 + long l = ::InterlockedDecrement(&this->m_cReferences);
50 + if (0 < l)
51 + {
52 + return l;
53 + }
54 +
55 + delete this;
56 + return 0;
57 + }
58 +
59 +public: // IBootstrapperEngine
60 + virtual STDMETHODIMP GetPackageCount(
61 + __out DWORD* pcPackages
62 + )
63 + {
64 + HRESULT hr = S_OK;
65 + BAENGINE_GETPACKAGECOUNT_ARGS args = { };
66 + BAENGINE_GETPACKAGECOUNT_RESULTS results = { };
67 +
68 + ExitOnNull(pcPackages, hr, E_INVALIDARG, "pcPackages is required");
69 +
70 + args.cbSize = sizeof(args);
71 +
72 + results.cbSize = sizeof(results);
73 +
74 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETPACKAGECOUNT, &args, &results, m_pvBAEngineProcContext);
75 +
76 + *pcPackages = results.cPackages;
77 +
78 + LExit:
79 + return hr;
80 + }
81 +
82 + virtual STDMETHODIMP GetVariableNumeric(
83 + __in_z LPCWSTR wzVariable,
84 + __out LONGLONG* pllValue
85 + )
86 + {
87 + HRESULT hr = S_OK;
88 + BAENGINE_GETVARIABLENUMERIC_ARGS args = { };
89 + BAENGINE_GETVARIABLENUMERIC_RESULTS results = { };
90 +
91 + ExitOnNull(pllValue, hr, E_INVALIDARG, "pllValue is required");
92 +
93 + args.cbSize = sizeof(args);
94 + args.wzVariable = wzVariable;
95 +
96 + results.cbSize = sizeof(results);
97 +
98 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext);
99 +
100 + *pllValue = results.llValue;
101 +
102 + LExit:
103 + SecureZeroMemory(&results, sizeof(results));
104 + return hr;
105 + }
106 +
107 + virtual STDMETHODIMP GetVariableString(
108 + __in_z LPCWSTR wzVariable,
109 + __out_ecount_opt(*pcchValue) LPWSTR wzValue,
110 + __inout DWORD* pcchValue
111 + )
112 + {
113 + HRESULT hr = S_OK;
114 + BAENGINE_GETVARIABLESTRING_ARGS args = { };
115 + BAENGINE_GETVARIABLESTRING_RESULTS results = { };
116 +
117 + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required");
118 +
119 + args.cbSize = sizeof(args);
120 + args.wzVariable = wzVariable;
121 +
122 + results.cbSize = sizeof(results);
123 + results.wzValue = wzValue;
124 + results.cchValue = *pcchValue;
125 +
126 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext);
127 +
128 + *pcchValue = results.cchValue;
129 +
130 + LExit:
131 + return hr;
132 + }
133 +
134 + virtual STDMETHODIMP GetVariableVersion(
135 + __in_z LPCWSTR wzVariable,
136 + __out DWORD64* pqwValue
137 + )
138 + {
139 + HRESULT hr = S_OK;
140 + BAENGINE_GETVARIABLEVERSION_ARGS args = { };
141 + BAENGINE_GETVARIABLEVERSION_RESULTS results = { };
142 +
143 + ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required");
144 +
145 + args.cbSize = sizeof(args);
146 + args.wzVariable = wzVariable;
147 +
148 + results.cbSize = sizeof(results);
149 +
150 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext);
151 +
152 + *pqwValue = results.qwValue;
153 +
154 + LExit:
155 + SecureZeroMemory(&results, sizeof(results));
156 + return hr;
157 + }
158 +
159 + virtual STDMETHODIMP FormatString(
160 + __in_z LPCWSTR wzIn,
161 + __out_ecount_opt(*pcchOut) LPWSTR wzOut,
162 + __inout DWORD* pcchOut
163 + )
164 + {
165 + HRESULT hr = S_OK;
166 + BAENGINE_FORMATSTRING_ARGS args = { };
167 + BAENGINE_FORMATSTRING_RESULTS results = { };
168 +
169 + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required");
170 +
171 + args.cbSize = sizeof(args);
172 + args.wzIn = wzIn;
173 +
174 + results.cbSize = sizeof(results);
175 + results.wzOut = wzOut;
176 + results.cchOut = *pcchOut;
177 +
178 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_FORMATSTRING, &args, &results, m_pvBAEngineProcContext);
179 +
180 + *pcchOut = results.cchOut;
181 +
182 + LExit:
183 + return hr;
184 + }
185 +
186 + virtual STDMETHODIMP EscapeString(
187 + __in_z LPCWSTR wzIn,
188 + __out_ecount_opt(*pcchOut) LPWSTR wzOut,
189 + __inout DWORD* pcchOut
190 + )
191 + {
192 + HRESULT hr = S_OK;
193 + BAENGINE_ESCAPESTRING_ARGS args = { };
194 + BAENGINE_ESCAPESTRING_RESULTS results = { };
195 +
196 + ExitOnNull(pcchOut, hr, E_INVALIDARG, "pcchOut is required");
197 +
198 + args.cbSize = sizeof(args);
199 + args.wzIn = wzIn;
200 +
201 + results.cbSize = sizeof(results);
202 + results.wzOut = wzOut;
203 + results.cchOut = *pcchOut;
204 +
205 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ESCAPESTRING, &args, &results, m_pvBAEngineProcContext);
206 +
207 + *pcchOut = results.cchOut;
208 +
209 + LExit:
210 + return hr;
211 + }
212 +
213 + virtual STDMETHODIMP EvaluateCondition(
214 + __in_z LPCWSTR wzCondition,
215 + __out BOOL* pf
216 + )
217 + {
218 + HRESULT hr = S_OK;
219 + BAENGINE_EVALUATECONDITION_ARGS args = { };
220 + BAENGINE_EVALUATECONDITION_RESULTS results = { };
221 +
222 + ExitOnNull(pf, hr, E_INVALIDARG, "pf is required");
223 +
224 + args.cbSize = sizeof(args);
225 + args.wzCondition = wzCondition;
226 +
227 + results.cbSize = sizeof(results);
228 +
229 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_EVALUATECONDITION, &args, &results, m_pvBAEngineProcContext);
230 +
231 + *pf = results.f;
232 +
233 + LExit:
234 + return hr;
235 + }
236 +
237 + virtual STDMETHODIMP Log(
238 + __in BOOTSTRAPPER_LOG_LEVEL level,
239 + __in_z LPCWSTR wzMessage
240 + )
241 + {
242 + BAENGINE_LOG_ARGS args = { };
243 + BAENGINE_LOG_RESULTS results = { };
244 +
245 + args.cbSize = sizeof(args);
246 + args.level = level;
247 + args.wzMessage = wzMessage;
248 +
249 + results.cbSize = sizeof(results);
250 +
251 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LOG, &args, &results, m_pvBAEngineProcContext);
252 + }
253 +
254 + virtual STDMETHODIMP SendEmbeddedError(
255 + __in DWORD dwErrorCode,
256 + __in_z_opt LPCWSTR wzMessage,
257 + __in DWORD dwUIHint,
258 + __out int* pnResult
259 + )
260 + {
261 + HRESULT hr = S_OK;
262 + BAENGINE_SENDEMBEDDEDERROR_ARGS args = { };
263 + BAENGINE_SENDEMBEDDEDERROR_RESULTS results = { };
264 +
265 + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required");
266 +
267 + args.cbSize = sizeof(args);
268 + args.dwErrorCode = dwErrorCode;
269 + args.wzMessage = wzMessage;
270 + args.dwUIHint = dwUIHint;
271 +
272 + results.cbSize = sizeof(results);
273 +
274 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDERROR, &args, &results, m_pvBAEngineProcContext);
275 +
276 + *pnResult = results.nResult;
277 +
278 + LExit:
279 + return hr;
280 + }
281 +
282 + virtual STDMETHODIMP SendEmbeddedProgress(
283 + __in DWORD dwProgressPercentage,
284 + __in DWORD dwOverallProgressPercentage,
285 + __out int* pnResult
286 + )
287 + {
288 + HRESULT hr = S_OK;
289 + BAENGINE_SENDEMBEDDEDPROGRESS_ARGS args = { };
290 + BAENGINE_SENDEMBEDDEDPROGRESS_RESULTS results = { };
291 +
292 + ExitOnNull(pnResult, hr, E_INVALIDARG, "pnResult is required");
293 +
294 + args.cbSize = sizeof(args);
295 + args.dwProgressPercentage = dwProgressPercentage;
296 + args.dwOverallProgressPercentage = dwOverallProgressPercentage;
297 +
298 + results.cbSize = sizeof(results);
299 +
300 + hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SENDEMBEDDEDPROGRESS, &args, &results, m_pvBAEngineProcContext);
301 +
302 + *pnResult = results.nResult;
303 +
304 + LExit:
305 + return hr;
306 + }
307 +
308 + virtual STDMETHODIMP SetUpdate(
309 + __in_z_opt LPCWSTR wzLocalSource,
310 + __in_z_opt LPCWSTR wzDownloadSource,
311 + __in DWORD64 qwSize,
312 + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
313 + __in_bcount_opt(cbHash) BYTE* rgbHash,
314 + __in DWORD cbHash
315 + )
316 + {
317 + BAENGINE_SETUPDATE_ARGS args = { };
318 + BAENGINE_SETUPDATE_RESULTS results = { };
319 +
320 + args.cbSize = sizeof(args);
321 + args.wzLocalSource = wzLocalSource;
322 + args.wzDownloadSource = wzDownloadSource;
323 + args.qwSize = qwSize;
324 + args.hashType = hashType;
325 + args.rgbHash = rgbHash;
326 + args.cbHash = cbHash;
327 +
328 + results.cbSize = sizeof(results);
329 +
330 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATE, &args, &results, m_pvBAEngineProcContext);
331 + }
332 +
333 + virtual STDMETHODIMP SetLocalSource(
334 + __in_z LPCWSTR wzPackageOrContainerId,
335 + __in_z_opt LPCWSTR wzPayloadId,
336 + __in_z LPCWSTR wzPath
337 + )
338 + {
339 + BAENGINE_SETLOCALSOURCE_ARGS args = { };
340 + BAENGINE_SETLOCALSOURCE_RESULTS results = { };
341 +
342 + args.cbSize = sizeof(args);
343 + args.wzPackageOrContainerId = wzPackageOrContainerId;
344 + args.wzPayloadId = wzPayloadId;
345 + args.wzPath = wzPath;
346 +
347 + results.cbSize = sizeof(results);
348 +
349 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETLOCALSOURCE, &args, &results, m_pvBAEngineProcContext);
350 + }
351 +
352 + virtual STDMETHODIMP SetDownloadSource(
353 + __in_z LPCWSTR wzPackageOrContainerId,
354 + __in_z_opt LPCWSTR wzPayloadId,
355 + __in_z LPCWSTR wzUrl,
356 + __in_z_opt LPCWSTR wzUser,
357 + __in_z_opt LPCWSTR wzPassword
358 + )
359 + {
360 + BAENGINE_SETDOWNLOADSOURCE_ARGS args = { };
361 + BAENGINE_SETDOWNLOADSOURCE_RESULTS results = { };
362 +
363 + args.cbSize = sizeof(args);
364 + args.wzPackageOrContainerId = wzPackageOrContainerId;
365 + args.wzPayloadId = wzPayloadId;
366 + args.wzUrl = wzUrl;
367 + args.wzUser = wzUser;
368 + args.wzPassword = wzPassword;
369 +
370 + results.cbSize = sizeof(results);
371 +
372 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETDOWNLOADSOURCE, &args, &results, m_pvBAEngineProcContext);
373 + }
374 +
375 + virtual STDMETHODIMP SetVariableNumeric(
376 + __in_z LPCWSTR wzVariable,
377 + __in LONGLONG llValue
378 + )
379 + {
380 + BAENGINE_SETVARIABLENUMERIC_ARGS args = { };
381 + BAENGINE_SETVARIABLENUMERIC_RESULTS results = { };
382 +
383 + args.cbSize = sizeof(args);
384 + args.wzVariable = wzVariable;
385 + args.llValue = llValue;
386 +
387 + results.cbSize = sizeof(results);
388 +
389 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLENUMERIC, &args, &results, m_pvBAEngineProcContext);
390 + }
391 +
392 + virtual STDMETHODIMP SetVariableString(
393 + __in_z LPCWSTR wzVariable,
394 + __in_z_opt LPCWSTR wzValue
395 + )
396 + {
397 + BAENGINE_SETVARIABLESTRING_ARGS args = { };
398 + BAENGINE_SETVARIABLESTRING_RESULTS results = { };
399 +
400 + args.cbSize = sizeof(args);
401 + args.wzVariable = wzVariable;
402 + args.wzValue = wzValue;
403 +
404 + results.cbSize = sizeof(results);
405 +
406 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLESTRING, &args, &results, m_pvBAEngineProcContext);
407 + }
408 +
409 + virtual STDMETHODIMP SetVariableVersion(
410 + __in_z LPCWSTR wzVariable,
411 + __in DWORD64 qwValue
412 + )
413 + {
414 + BAENGINE_SETVARIABLEVERSION_ARGS args = { };
415 + BAENGINE_SETVARIABLEVERSION_RESULTS results = { };
416 +
417 + args.cbSize = sizeof(args);
418 + args.wzVariable = wzVariable;
419 + args.qwValue = qwValue;
420 +
421 + results.cbSize = sizeof(results);
422 +
423 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_SETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext);
424 + }
425 +
426 + virtual STDMETHODIMP CloseSplashScreen()
427 + {
428 + BAENGINE_CLOSESPLASHSCREEN_ARGS args = { };
429 + BAENGINE_CLOSESPLASHSCREEN_RESULTS results = { };
430 +
431 + args.cbSize = sizeof(args);
432 +
433 + results.cbSize = sizeof(results);
434 +
435 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_CLOSESPLASHSCREEN, &args, &results, m_pvBAEngineProcContext);
436 + }
437 +
438 + virtual STDMETHODIMP Detect(
439 + __in_opt HWND hwndParent
440 + )
441 + {
442 + BAENGINE_DETECT_ARGS args = { };
443 + BAENGINE_DETECT_RESULTS results = { };
444 +
445 + args.cbSize = sizeof(args);
446 + args.hwndParent = hwndParent;
447 +
448 + results.cbSize = sizeof(results);
449 +
450 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_DETECT, &args, &results, m_pvBAEngineProcContext);
451 + }
452 +
453 + virtual STDMETHODIMP Plan(
454 + __in BOOTSTRAPPER_ACTION action
455 + )
456 + {
457 + BAENGINE_PLAN_ARGS args = { };
458 + BAENGINE_PLAN_RESULTS results = { };
459 +
460 + args.cbSize = sizeof(args);
461 + args.action = action;
462 +
463 + results.cbSize = sizeof(results);
464 +
465 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_PLAN, &args, &results, m_pvBAEngineProcContext);
466 + }
467 +
468 + virtual STDMETHODIMP Elevate(
469 + __in_opt HWND hwndParent
470 + )
471 + {
472 + BAENGINE_ELEVATE_ARGS args = { };
473 + BAENGINE_ELEVATE_RESULTS results = { };
474 +
475 + args.cbSize = sizeof(args);
476 + args.hwndParent = hwndParent;
477 +
478 + results.cbSize = sizeof(results);
479 +
480 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_ELEVATE, &args, &results, m_pvBAEngineProcContext);
481 + }
482 +
483 + virtual STDMETHODIMP Apply(
484 + __in_opt HWND hwndParent
485 + )
486 + {
487 + BAENGINE_APPLY_ARGS args = { };
488 + BAENGINE_APPLY_RESULTS results = { };
489 +
490 + args.cbSize = sizeof(args);
491 + args.hwndParent = hwndParent;
492 +
493 + results.cbSize = sizeof(results);
494 +
495 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, &args, &results, m_pvBAEngineProcContext);
496 + }
497 +
498 + virtual STDMETHODIMP Quit(
499 + __in DWORD dwExitCode
500 + )
501 + {
502 + BAENGINE_QUIT_ARGS args = { };
503 + BAENGINE_QUIT_RESULTS results = { };
504 +
505 + args.cbSize = sizeof(args);
506 + args.dwExitCode = dwExitCode;
507 +
508 + results.cbSize = sizeof(results);
509 +
510 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, &args, &results, m_pvBAEngineProcContext);
511 + }
512 +
513 + virtual STDMETHODIMP LaunchApprovedExe(
514 + __in_opt HWND hwndParent,
515 + __in_z LPCWSTR wzApprovedExeForElevationId,
516 + __in_z_opt LPCWSTR wzArguments,
517 + __in DWORD dwWaitForInputIdleTimeout
518 + )
519 + {
520 + BAENGINE_LAUNCHAPPROVEDEXE_ARGS args = { };
521 + BAENGINE_LAUNCHAPPROVEDEXE_RESULTS results = { };
522 +
523 + args.cbSize = sizeof(args);
524 + args.hwndParent = hwndParent;
525 + args.wzApprovedExeForElevationId = wzApprovedExeForElevationId;
526 + args.wzArguments = wzArguments;
527 + args.dwWaitForInputIdleTimeout = dwWaitForInputIdleTimeout;
528 +
529 + results.cbSize = sizeof(results);
530 +
531 + return m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, &args, &results, m_pvBAEngineProcContext);
532 + }
533 +
534 +public: // IMarshal
535 + virtual STDMETHODIMP GetUnmarshalClass(
536 + __in REFIID /*riid*/,
537 + __in_opt LPVOID /*pv*/,
538 + __in DWORD /*dwDestContext*/,
539 + __reserved LPVOID /*pvDestContext*/,
540 + __in DWORD /*mshlflags*/,
541 + __out LPCLSID /*pCid*/
542 + )
543 + {
544 + return E_NOTIMPL;
545 + }
546 +
547 + virtual STDMETHODIMP GetMarshalSizeMax(
548 + __in REFIID riid,
549 + __in_opt LPVOID /*pv*/,
550 + __in DWORD dwDestContext,
551 + __reserved LPVOID /*pvDestContext*/,
552 + __in DWORD /*mshlflags*/,
553 + __out DWORD *pSize
554 + )
555 + {
556 + HRESULT hr = S_OK;
557 +
558 + // We only support marshaling the IBootstrapperEngine interface in-proc.
559 + if (__uuidof(IBootstrapperEngine) != riid)
560 + {
561 + // Skip logging the following message since it appears way too often in the log.
562 + // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface."
563 + ExitFunction1(hr = E_NOINTERFACE);
564 + }
565 + else if (0 == (MSHCTX_INPROC & dwDestContext))
566 + {
567 + hr = E_FAIL;
568 + ExitOnRootFailure(hr, "Cannot marshal IBootstrapperEngine interface out of proc.");
569 + }
570 +
571 + // E_FAIL is used because E_INVALIDARG is not a supported return value.
572 + ExitOnNull(pSize, hr, E_FAIL, "Invalid size output parameter is NULL.");
573 +
574 + // Specify enough size to marshal just the interface pointer across threads.
575 + *pSize = sizeof(LPVOID);
576 +
577 + LExit:
578 + return hr;
579 + }
580 +
581 + virtual STDMETHODIMP MarshalInterface(
582 + __in IStream* pStm,
583 + __in REFIID riid,
584 + __in_opt LPVOID pv,
585 + __in DWORD dwDestContext,
586 + __reserved LPVOID /*pvDestContext*/,
587 + __in DWORD /*mshlflags*/
588 + )
589 + {
590 + HRESULT hr = S_OK;
591 + IBootstrapperEngine *pThis = NULL;
592 + ULONG ulWritten = 0;
593 +
594 + // We only support marshaling the IBootstrapperEngine interface in-proc.
595 + if (__uuidof(IBootstrapperEngine) != riid)
596 + {
597 + // Skip logging the following message since it appears way too often in the log.
598 + // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface."
599 + ExitFunction1(hr = E_NOINTERFACE);
600 + }
601 + else if (0 == (MSHCTX_INPROC & dwDestContext))
602 + {
603 + hr = E_FAIL;
604 + ExitOnRootFailure(hr, "Cannot marshal IBootstrapperEngine interface out of proc.");
605 + }
606 +
607 + // "pv" may not be set, so we should us "this" otherwise.
608 + if (pv)
609 + {
610 + pThis = reinterpret_cast<IBootstrapperEngine*>(pv);
611 + }
612 + else
613 + {
614 + pThis = static_cast<IBootstrapperEngine*>(this);
615 + }
616 +
617 + // E_INVALIDARG is not a supported return value.
618 + ExitOnNull(pStm, hr, E_FAIL, "The marshaling stream parameter is NULL.");
619 +
620 + // Marshal the interface pointer in-proc as is.
621 + hr = pStm->Write(pThis, sizeof(pThis), &ulWritten);
622 + if (STG_E_MEDIUMFULL == hr)
623 + {
624 + ExitOnFailure(hr, "Failed to write the stream because the stream is full.");
625 + }
626 + else if (FAILED(hr))
627 + {
628 + // All other STG error must be converted into E_FAIL based on IMarshal documentation.
629 + hr = E_FAIL;
630 + ExitOnFailure(hr, "Failed to write the IBootstrapperEngine interface pointer to the marshaling stream.");
631 + }
632 +
633 + LExit:
634 + return hr;
635 + }
636 +
637 + virtual STDMETHODIMP UnmarshalInterface(
638 + __in IStream* pStm,
639 + __in REFIID riid,
640 + __deref_out LPVOID* ppv
641 + )
642 + {
643 + HRESULT hr = S_OK;
644 + ULONG ulRead = 0;
645 +
646 + // We only support marshaling the engine in-proc.
647 + if (__uuidof(IBootstrapperEngine) != riid)
648 + {
649 + // Skip logging the following message since it appears way too often in the log.
650 + // "Unexpected IID requested to be marshalled. BootstrapperEngineForApplication can only marshal the IBootstrapperEngine interface."
651 + ExitFunction1(hr = E_NOINTERFACE);
652 + }
653 +
654 + // E_FAIL is used because E_INVALIDARG is not a supported return value.
655 + ExitOnNull(pStm, hr, E_FAIL, "The marshaling stream parameter is NULL.");
656 + ExitOnNull(ppv, hr, E_FAIL, "The interface output parameter is NULL.");
657 +
658 + // Unmarshal the interface pointer in-proc as is.
659 + hr = pStm->Read(*ppv, sizeof(LPVOID), &ulRead);
660 + if (FAILED(hr))
661 + {
662 + // All STG errors must be converted into E_FAIL based on IMarshal documentation.
663 + hr = E_FAIL;
664 + ExitOnFailure(hr, "Failed to read the IBootstrapperEngine interface pointer from the marshaling stream.");
665 + }
666 +
667 + LExit:
668 + return hr;
669 + }
670 +
671 + virtual STDMETHODIMP ReleaseMarshalData(
672 + __in IStream* /*pStm*/
673 + )
674 + {
675 + return E_NOTIMPL;
676 + }
677 +
678 + virtual STDMETHODIMP DisconnectObject(
679 + __in DWORD /*dwReserved*/
680 + )
681 + {
682 + return E_NOTIMPL;
683 + }
684 +
685 +public:
686 + CBalBootstrapperEngine(
687 + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc,
688 + __in_opt LPVOID pvBAEngineProcContext
689 + )
690 + {
691 + m_cReferences = 1;
692 + m_pfnBAEngineProc = pfnBAEngineProc;
693 + m_pvBAEngineProcContext = pvBAEngineProcContext;
694 + }
695 +
696 +private:
697 + long m_cReferences;
698 + PFN_BOOTSTRAPPER_ENGINE_PROC m_pfnBAEngineProc;
699 + LPVOID m_pvBAEngineProcContext;
700 +};
701 +
702 +HRESULT BalBootstrapperEngineCreate(
703 + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc,
704 + __in_opt LPVOID pvBAEngineProcContext,
705 + __out IBootstrapperEngine** ppBootstrapperEngine
706 + )
707 +{
708 + HRESULT hr = S_OK;
709 + CBalBootstrapperEngine* pBootstrapperEngine = NULL;
710 +
711 + pBootstrapperEngine = new CBalBootstrapperEngine(pfnBAEngineProc, pvBAEngineProcContext);
712 + ExitOnNull(pBootstrapperEngine, hr, E_OUTOFMEMORY, "Failed to allocate new BalBootstrapperEngine object.");
713 +
714 + hr = pBootstrapperEngine->QueryInterface(IID_PPV_ARGS(ppBootstrapperEngine));
715 + ExitOnFailure(hr, "Failed to QI for IBootstrapperEngine from BalBootstrapperEngine object.");
716 +
717 +LExit:
718 + ReleaseObject(pBootstrapperEngine);
719 + return hr;
720 +}
src/balutil/balcondition.cpp new
+124
@@ -0,0 +1,124 @@
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 +// prototypes
6 +
7 +
8 +DAPI_(HRESULT) BalConditionsParseFromXml(
9 + __in BAL_CONDITIONS* pConditions,
10 + __in IXMLDOMDocument* pixdManifest,
11 + __in_opt WIX_LOCALIZATION* pWixLoc
12 + )
13 +{
14 + HRESULT hr = S_OK;
15 + IXMLDOMNodeList* pNodeList = NULL;
16 + IXMLDOMNode* pNode = NULL;
17 + BAL_CONDITION* prgConditions = NULL;
18 + DWORD cConditions = 0;
19 +
20 + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalCondition", &pNodeList);
21 + ExitOnFailure(hr, "Failed to select all conditions.");
22 +
23 + hr = pNodeList->get_length(reinterpret_cast<long*>(&cConditions));
24 + ExitOnFailure(hr, "Failed to get the condition count.");
25 +
26 + if (!cConditions)
27 + {
28 + ExitFunction();
29 + }
30 +
31 + prgConditions = static_cast<BAL_CONDITION*>(MemAlloc(sizeof(BAL_CONDITION) * cConditions, TRUE));
32 + ExitOnNull(prgConditions, hr, E_OUTOFMEMORY, "Failed to allocate memory for conditions.");
33 +
34 + DWORD iCondition = 0;
35 + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
36 + {
37 + hr = XmlGetAttributeEx(pNode, L"Condition", &prgConditions[iCondition].sczCondition);
38 + ExitOnFailure(hr, "Failed to get condition for condition.");
39 +
40 + hr = XmlGetAttributeEx(pNode, L"Message", &prgConditions[iCondition].sczMessage);
41 + ExitOnFailure(hr, "Failed to get message for condition.");
42 +
43 + if (pWixLoc && prgConditions[iCondition].sczMessage && *prgConditions[iCondition].sczMessage)
44 + {
45 + hr = LocLocalizeString(pWixLoc, &prgConditions[iCondition].sczMessage);
46 + ExitOnFailure(hr, "Failed to localize condition message.");
47 + }
48 +
49 + ++iCondition;
50 + ReleaseNullObject(pNode);
51 + }
52 + ExitOnFailure(hr, "Failed to parse all condition elements.");
53 +
54 + if (S_FALSE == hr)
55 + {
56 + hr = S_OK;
57 + }
58 +
59 + pConditions->cConditions = cConditions;
60 + pConditions->rgConditions = prgConditions;
61 + prgConditions = NULL;
62 +
63 +LExit:
64 + ReleaseMem(prgConditions);
65 + ReleaseObject(pNode);
66 + ReleaseObject(pNodeList);
67 +
68 + return hr;
69 +}
70 +
71 +
72 +//the contents of psczMessage may be sensitive, should keep encrypted and SecureZeroFree
73 +DAPI_(HRESULT) BalConditionEvaluate(
74 + __in BAL_CONDITION* pCondition,
75 + __in IBootstrapperEngine* pEngine,
76 + __out BOOL* pfResult,
77 + __out_z_opt LPWSTR* psczMessage
78 + )
79 +{
80 + HRESULT hr = S_OK;
81 + DWORD_PTR cchMessage = 0;
82 +
83 + hr = pEngine->EvaluateCondition(pCondition->sczCondition, pfResult);
84 + ExitOnFailure(hr, "Failed to evaluate condition with bootstrapper engine.");
85 +
86 + if (psczMessage)
87 + {
88 + if (*psczMessage)
89 + {
90 + hr = StrMaxLength(*psczMessage, &cchMessage);
91 + ExitOnFailure(hr, "Failed to get length of message.");
92 + }
93 +
94 + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, reinterpret_cast<DWORD*>(&cchMessage));
95 + if (E_MOREDATA == hr)
96 + {
97 + ++cchMessage;
98 +
99 + hr = StrAllocSecure(psczMessage, cchMessage);
100 + ExitOnFailure(hr, "Failed to allocate string for condition's formatted message.");
101 +
102 + hr = pEngine->FormatString(pCondition->sczMessage, *psczMessage, reinterpret_cast<DWORD*>(&cchMessage));
103 + }
104 + ExitOnFailure(hr, "Failed to format condition's message.");
105 + }
106 +
107 +LExit:
108 + return hr;
109 +}
110 +
111 +
112 +DAPI_(void) BalConditionsUninitialize(
113 + __in BAL_CONDITIONS* pConditions
114 + )
115 +{
116 + for (DWORD i = 0; i < pConditions->cConditions; ++i)
117 + {
118 + ReleaseStr(pConditions->rgConditions[i].sczMessage);
119 + ReleaseStr(pConditions->rgConditions[i].sczCondition);
120 + }
121 +
122 + ReleaseMem(pConditions->rgConditions);
123 + memset(pConditions, 0, sizeof(BAL_CONDITIONS));
124 +}
src/balutil/balinfo.cpp new
+288
@@ -0,0 +1,288 @@
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 +// prototypes
6 +static HRESULT ParsePackagesFromXml(
7 + __in BAL_INFO_PACKAGES* pPackages,
8 + __in IXMLDOMDocument* pixdManifest
9 + );
10 +
11 +
12 +DAPI_(HRESULT) BalInfoParseFromXml(
13 + __in BAL_INFO_BUNDLE* pBundle,
14 + __in IXMLDOMDocument* pixdManifest
15 + )
16 +{
17 + HRESULT hr = S_OK;
18 + IXMLDOMNode* pNode = NULL;
19 +
20 + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBundleProperties", &pNode);
21 + ExitOnFailure(hr, "Failed to select bundle information.");
22 +
23 + if (S_OK == hr)
24 + {
25 + hr = XmlGetYesNoAttribute(pNode, L"PerMachine", &pBundle->fPerMachine);
26 + if (E_NOTFOUND != hr)
27 + {
28 + ExitOnFailure(hr, "Failed to read bundle information per-machine.");
29 + }
30 +
31 + hr = XmlGetAttributeEx(pNode, L"DisplayName", &pBundle->sczName);
32 + if (E_NOTFOUND != hr)
33 + {
34 + ExitOnFailure(hr, "Failed to read bundle information display name.");
35 + }
36 +
37 + hr = XmlGetAttributeEx(pNode, L"LogPathVariable", &pBundle->sczLogVariable);
38 + if (E_NOTFOUND != hr)
39 + {
40 + ExitOnFailure(hr, "Failed to read bundle information log path variable.");
41 + }
42 + }
43 +
44 + hr = ParsePackagesFromXml(&pBundle->packages, pixdManifest);
45 + BalExitOnFailure(hr, "Failed to parse package information from bootstrapper application data.");
46 +
47 +LExit:
48 + ReleaseObject(pNode);
49 +
50 + return hr;
51 +}
52 +
53 +
54 +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage(
55 + __in BAL_INFO_PACKAGES* pPackages,
56 + __in LPCWSTR wzId,
57 + __in BOOTSTRAPPER_RELATION_TYPE relationType,
58 + __in BOOL /*fPerMachine*/
59 + )
60 +{
61 + HRESULT hr = S_OK;
62 + BAL_INFO_PACKAGE_TYPE type = BAL_INFO_PACKAGE_TYPE_UNKNOWN;
63 + BAL_INFO_PACKAGE* pPackage = NULL;
64 +
65 + // Ensure we have a supported relation type.
66 + switch (relationType)
67 + {
68 + case BOOTSTRAPPER_RELATION_ADDON:
69 + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON;
70 + break;
71 +
72 + case BOOTSTRAPPER_RELATION_PATCH:
73 + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH;
74 + break;
75 +
76 + case BOOTSTRAPPER_RELATION_UPGRADE:
77 + type = BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE;
78 + break;
79 +
80 + default:
81 + ExitOnFailure(hr = E_INVALIDARG, "Unknown related bundle type: %u", relationType);
82 + }
83 +
84 + // Check to see if the bundle is already in the list of packages.
85 + for (DWORD i = 0; i < pPackages->cPackages; ++i)
86 + {
87 + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1))
88 + {
89 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS));
90 + }
91 + }
92 +
93 + // Add the related bundle as a package.
94 + hr = MemEnsureArraySize(reinterpret_cast<LPVOID*>(&pPackages->rgPackages), pPackages->cPackages + 1, sizeof(BAL_INFO_PACKAGE), 2);
95 + ExitOnFailure(hr, "Failed to allocate memory for related bundle package information.");
96 +
97 + pPackage = pPackages->rgPackages + pPackages->cPackages;
98 + ++pPackages->cPackages;
99 +
100 + hr = StrAllocString(&pPackage->sczId, wzId, 0);
101 + ExitOnFailure(hr, "Failed to copy related bundle package id.");
102 +
103 + pPackage->type = type;
104 +
105 + // TODO: try to look up the DisplayName and Description in Add/Remove Programs with the wzId.
106 +
107 +LExit:
108 + return hr;
109 +}
110 +
111 +
112 +DAPI_(HRESULT) BalInfoFindPackageById(
113 + __in BAL_INFO_PACKAGES* pPackages,
114 + __in LPCWSTR wzId,
115 + __out BAL_INFO_PACKAGE** ppPackage
116 + )
117 +{
118 + *ppPackage = NULL;
119 +
120 + for (DWORD i = 0; i < pPackages->cPackages; ++i)
121 + {
122 + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzId, -1, pPackages->rgPackages[i].sczId, -1))
123 + {
124 + *ppPackage = pPackages->rgPackages + i;
125 + break;
126 + }
127 + }
128 +
129 + return *ppPackage ? S_OK : E_NOTFOUND;
130 +}
131 +
132 +
133 +DAPI_(void) BalInfoUninitialize(
134 + __in BAL_INFO_BUNDLE* pBundle
135 + )
136 +{
137 + for (DWORD i = 0; i < pBundle->packages.cPackages; ++i)
138 + {
139 + ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayName);
140 + ReleaseStr(pBundle->packages.rgPackages[i].sczDescription);
141 + ReleaseStr(pBundle->packages.rgPackages[i].sczId);
142 + ReleaseStr(pBundle->packages.rgPackages[i].sczProductCode);
143 + ReleaseStr(pBundle->packages.rgPackages[i].sczUpgradeCode);
144 + ReleaseStr(pBundle->packages.rgPackages[i].sczVersion);
145 + ReleaseStr(pBundle->packages.rgPackages[i].sczInstallCondition);
146 + }
147 +
148 + ReleaseMem(pBundle->packages.rgPackages);
149 +
150 + ReleaseStr(pBundle->sczName);
151 + ReleaseStr(pBundle->sczLogVariable);
152 + memset(pBundle, 0, sizeof(BAL_INFO_BUNDLE));
153 +}
154 +
155 +
156 +static HRESULT ParsePackagesFromXml(
157 + __in BAL_INFO_PACKAGES* pPackages,
158 + __in IXMLDOMDocument* pixdManifest
159 + )
160 +{
161 + HRESULT hr = S_OK;
162 + IXMLDOMNodeList* pNodeList = NULL;
163 + IXMLDOMNode* pNode = NULL;
164 + BAL_INFO_PACKAGE* prgPackages = NULL;
165 + DWORD cPackages = 0;
166 + LPWSTR scz = NULL;
167 +
168 + hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPackageProperties", &pNodeList);
169 + ExitOnFailure(hr, "Failed to select all packages.");
170 +
171 + hr = pNodeList->get_length(reinterpret_cast<long*>(&cPackages));
172 + ExitOnFailure(hr, "Failed to get the package count.");
173 +
174 + prgPackages = static_cast<BAL_INFO_PACKAGE*>(MemAlloc(sizeof(BAL_INFO_PACKAGE) * cPackages, TRUE));
175 + ExitOnNull(prgPackages, hr, E_OUTOFMEMORY, "Failed to allocate memory for packages.");
176 +
177 + DWORD iPackage = 0;
178 + while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
179 + {
180 + hr = XmlGetAttributeEx(pNode, L"Package", &prgPackages[iPackage].sczId);
181 + ExitOnFailure(hr, "Failed to get package identifier for package.");
182 +
183 + hr = XmlGetAttributeEx(pNode, L"DisplayName", &prgPackages[iPackage].sczDisplayName);
184 + if (E_NOTFOUND != hr)
185 + {
186 + ExitOnFailure(hr, "Failed to get display name for package.");
187 + }
188 +
189 + hr = XmlGetAttributeEx(pNode, L"Description", &prgPackages[iPackage].sczDescription);
190 + if (E_NOTFOUND != hr)
191 + {
192 + ExitOnFailure(hr, "Failed to get description for package.");
193 + }
194 +
195 + hr = XmlGetAttributeEx(pNode, L"PackageType", &scz);
196 + ExitOnFailure(hr, "Failed to get package type for package.");
197 +
198 + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Exe", -1, scz, -1))
199 + {
200 + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_EXE;
201 + }
202 + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msi", -1, scz, -1))
203 + {
204 + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSI;
205 + }
206 + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msp", -1, scz, -1))
207 + {
208 + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSP;
209 + }
210 + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msu", -1, scz, -1))
211 + {
212 + prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSU;
213 + }
214 +
215 + hr = XmlGetYesNoAttribute(pNode, L"Permanent", &prgPackages[iPackage].fPermanent);
216 + ExitOnFailure(hr, "Failed to get permanent setting for package.");
217 +
218 + hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital);
219 + ExitOnFailure(hr, "Failed to get vital setting for package.");
220 +
221 + hr = XmlGetYesNoAttribute(pNode, L"DisplayInternalUI", &prgPackages[iPackage].fDisplayInternalUI);
222 + if (E_NOTFOUND != hr)
223 + {
224 + ExitOnFailure(hr, "Failed to get DisplayInternalUI setting for package.");
225 + }
226 +
227 + hr = XmlGetAttributeEx(pNode, L"ProductCode", &prgPackages[iPackage].sczProductCode);
228 + if (E_NOTFOUND != hr)
229 + {
230 + ExitOnFailure(hr, "Failed to get product code for package.");
231 + }
232 +
233 + hr = XmlGetAttributeEx(pNode, L"UpgradeCode", &prgPackages[iPackage].sczUpgradeCode);
234 + if (E_NOTFOUND != hr)
235 + {
236 + ExitOnFailure(hr, "Failed to get upgrade code for package.");
237 + }
238 +
239 + hr = XmlGetAttributeEx(pNode, L"Version", &prgPackages[iPackage].sczVersion);
240 + if (E_NOTFOUND != hr)
241 + {
242 + ExitOnFailure(hr, "Failed to get version for package.");
243 + }
244 +
245 + hr = XmlGetAttributeEx(pNode, L"InstallCondition", &prgPackages[iPackage].sczInstallCondition);
246 + if (E_NOTFOUND != hr)
247 + {
248 + ExitOnFailure(hr, "Failed to get install condition for package.");
249 + }
250 +
251 + hr = XmlGetAttributeEx(pNode, L"Cache", &scz);
252 + ExitOnFailure(hr, "Failed to get cache type for package.");
253 +
254 + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"no", -1))
255 + {
256 + prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_NO;
257 + }
258 + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"yes", -1))
259 + {
260 + prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_YES;
261 + }
262 + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"always", -1))
263 + {
264 + prgPackages[iPackage].cacheType = BAL_INFO_CACHE_TYPE_ALWAYS;
265 + }
266 +
267 + ++iPackage;
268 + ReleaseNullObject(pNode);
269 + }
270 + ExitOnFailure(hr, "Failed to parse all package property elements.");
271 +
272 + if (S_FALSE == hr)
273 + {
274 + hr = S_OK;
275 + }
276 +
277 + pPackages->cPackages = cPackages;
278 + pPackages->rgPackages = prgPackages;
279 + prgPackages = NULL;
280 +
281 +LExit:
282 + ReleaseStr(scz);
283 + ReleaseMem(prgPackages);
284 + ReleaseObject(pNode);
285 + ReleaseObject(pNodeList);
286 +
287 + return hr;
288 +}
src/balutil/balretry.cpp new
+191
@@ -0,0 +1,191 @@
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 +struct BALRETRY_INFO
6 +{
7 + LPWSTR sczId; // package or container id.
8 + LPWSTR sczPayloadId; // optional payload id.
9 + DWORD cRetries;
10 + DWORD dwLastError;
11 +};
12 +
13 +static DWORD vdwMaxRetries = 0;
14 +static DWORD vdwTimeout = 0;
15 +static BALRETRY_INFO vrgRetryInfo[2];
16 +
17 +// prototypes
18 +static BOOL IsActiveRetryEntry(
19 + __in BALRETRY_TYPE type,
20 + __in_z LPCWSTR wzPackageId,
21 + __in_z_opt LPCWSTR wzPayloadId
22 + );
23 +
24 +
25 +DAPI_(void) BalRetryInitialize(
26 + __in DWORD dwMaxRetries,
27 + __in DWORD dwTimeout
28 + )
29 +{
30 + BalRetryUninitialize(); // clean everything out.
31 +
32 + vdwMaxRetries = dwMaxRetries;
33 + vdwTimeout = dwTimeout;
34 +}
35 +
36 +
37 +DAPI_(void) BalRetryUninitialize()
38 +{
39 + for (DWORD i = 0; i < countof(vrgRetryInfo); ++i)
40 + {
41 + ReleaseStr(vrgRetryInfo[i].sczId);
42 + ReleaseStr(vrgRetryInfo[i].sczPayloadId);
43 + memset(vrgRetryInfo + i, 0, sizeof(BALRETRY_INFO));
44 + }
45 +
46 + vdwMaxRetries = 0;
47 + vdwTimeout = 0;
48 +}
49 +
50 +
51 +DAPI_(void) BalRetryStartPackage(
52 + __in BALRETRY_TYPE type,
53 + __in_z_opt LPCWSTR wzPackageId,
54 + __in_z_opt LPCWSTR wzPayloadId
55 + )
56 +{
57 + if (!wzPackageId || !*wzPackageId)
58 + {
59 + ReleaseNullStr(vrgRetryInfo[type].sczId);
60 + ReleaseNullStr(vrgRetryInfo[type].sczPayloadId);
61 + }
62 + else if (IsActiveRetryEntry(type, wzPackageId, wzPayloadId))
63 + {
64 + ++vrgRetryInfo[type].cRetries;
65 + ::Sleep(vdwTimeout);
66 + }
67 + else
68 + {
69 + StrAllocString(&vrgRetryInfo[type].sczId, wzPackageId, 0);
70 + if (wzPayloadId)
71 + {
72 + StrAllocString(&vrgRetryInfo[type].sczPayloadId, wzPayloadId, 0);
73 + }
74 +
75 + vrgRetryInfo[type].cRetries = 0;
76 + }
77 +
78 + vrgRetryInfo[type].dwLastError = ERROR_SUCCESS;
79 +}
80 +
81 +
82 +DAPI_(void) BalRetryErrorOccurred(
83 + __in_z LPCWSTR wzPackageId,
84 + __in DWORD dwError
85 + )
86 +{
87 + if (IsActiveRetryEntry(BALRETRY_TYPE_CACHE, wzPackageId, NULL))
88 + {
89 + vrgRetryInfo[BALRETRY_TYPE_CACHE].dwLastError = dwError;
90 + }
91 + else if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL))
92 + {
93 + vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError;
94 + }
95 +}
96 +
97 +
98 +DAPI_(HRESULT) BalRetryEndPackage(
99 + __in BALRETRY_TYPE type,
100 + __in_z_opt LPCWSTR wzPackageId,
101 + __in_z_opt LPCWSTR wzPayloadId,
102 + __in HRESULT hrError,
103 + __inout BOOL* pfRetry
104 + )
105 +{
106 + HRESULT hr = S_OK;
107 +
108 + if (!wzPackageId || !*wzPackageId)
109 + {
110 + ReleaseNullStr(vrgRetryInfo[type].sczId);
111 + ReleaseNullStr(vrgRetryInfo[type].sczPayloadId);
112 + }
113 + else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId, wzPayloadId))
114 + {
115 + if (BALRETRY_TYPE_CACHE == type)
116 + {
117 + // Retry on all errors except the following.
118 + if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError &&
119 + BG_E_NETWORK_DISCONNECTED != hrError &&
120 + HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError &&
121 + HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError)
122 + {
123 + *pfRetry = TRUE;
124 + }
125 + }
126 + else if (BALRETRY_TYPE_EXECUTE == type)
127 + {
128 + // If the service is out of whack, just try again.
129 + if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError)
130 + {
131 + *pfRetry = TRUE;
132 + }
133 + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError)
134 + {
135 + DWORD dwError = vrgRetryInfo[type].dwLastError;
136 +
137 + // If we failed with one of these specific error codes, then retry since
138 + // we've seen these have a high success of succeeding on retry.
139 + if (1303 == dwError ||
140 + 1304 == dwError ||
141 + 1306 == dwError ||
142 + 1307 == dwError ||
143 + 1309 == dwError ||
144 + 1310 == dwError ||
145 + 1311 == dwError ||
146 + 1312 == dwError ||
147 + 1316 == dwError ||
148 + 1317 == dwError ||
149 + 1321 == dwError ||
150 + 1335 == dwError ||
151 + 1402 == dwError ||
152 + 1406 == dwError ||
153 + 1606 == dwError ||
154 + 1706 == dwError ||
155 + 1719 == dwError ||
156 + 1723 == dwError ||
157 + 1923 == dwError ||
158 + 1931 == dwError)
159 + {
160 + *pfRetry = TRUE;
161 + }
162 + }
163 + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError)
164 + {
165 + *pfRetry = TRUE;
166 + }
167 + }
168 + }
169 +
170 + return hr;
171 +}
172 +
173 +
174 +// Internal functions.
175 +
176 +static BOOL IsActiveRetryEntry(
177 + __in BALRETRY_TYPE type,
178 + __in_z LPCWSTR wzPackageId,
179 + __in_z_opt LPCWSTR wzPayloadId
180 + )
181 +{
182 + BOOL fActive = FALSE;
183 +
184 + fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, vrgRetryInfo[type].sczId, -1);
185 + if (fActive && wzPayloadId) // if a payload id was provided ensure it matches.
186 + {
187 + fActive = vrgRetryInfo[type].sczPayloadId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPayloadId, -1, vrgRetryInfo[type].sczPayloadId, -1);
188 + }
189 +
190 + return fActive;
191 +}
src/balutil/balutil.cpp new
+382
@@ -0,0 +1,382 @@
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 +const DWORD VARIABLE_GROW_FACTOR = 80;
6 +static IBootstrapperEngine* vpEngine = NULL;
7 +
8 +// prototypes
9 +
10 +DAPI_(void) BalInitialize(
11 + __in IBootstrapperEngine* pEngine
12 + )
13 +{
14 + pEngine->AddRef();
15 +
16 + ReleaseObject(vpEngine);
17 + vpEngine = pEngine;
18 +}
19 +
20 +DAPI_(HRESULT) BalInitializeFromCreateArgs(
21 + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
22 + __out_opt IBootstrapperEngine** ppEngine
23 + )
24 +{
25 + HRESULT hr = S_OK;
26 + IBootstrapperEngine* pEngine = NULL;
27 +
28 + hr = BalBootstrapperEngineCreate(pArgs->pfnBootstrapperEngineProc, pArgs->pvBootstrapperEngineProcContext, &pEngine);
29 + ExitOnFailure(hr, "Failed to create BalBootstrapperEngine.");
30 +
31 + BalInitialize(pEngine);
32 +
33 + if (ppEngine)
34 + {
35 + *ppEngine = pEngine;
36 + }
37 + pEngine = NULL;
38 +
39 +LExit:
40 + ReleaseObject(pEngine);
41 +
42 + return hr;
43 +}
44 +
45 +
46 +DAPI_(void) BalUninitialize()
47 +{
48 + ReleaseNullObject(vpEngine);
49 +}
50 +
51 +
52 +DAPI_(HRESULT) BalManifestLoad(
53 + __in HMODULE hBootstrapperApplicationModule,
54 + __out IXMLDOMDocument** ppixdManifest
55 + )
56 +{
57 + HRESULT hr = S_OK;
58 + LPWSTR sczPath = NULL;
59 +
60 + hr = PathRelativeToModule(&sczPath, BAL_MANIFEST_FILENAME, hBootstrapperApplicationModule);
61 + ExitOnFailure(hr, "Failed to get path to bootstrapper application manifest: %ls", BAL_MANIFEST_FILENAME);
62 +
63 + hr = XmlLoadDocumentFromFile(sczPath, ppixdManifest);
64 + ExitOnFailure(hr, "Failed to load bootstrapper application manifest '%ls' from path: %ls", BAL_MANIFEST_FILENAME, sczPath);
65 +
66 +LExit:
67 + ReleaseStr(sczPath);
68 + return hr;
69 +}
70 +
71 +
72 +DAPI_(HRESULT) BalEvaluateCondition(
73 + __in_z LPCWSTR wzCondition,
74 + __out BOOL* pf
75 + )
76 +{
77 + HRESULT hr = S_OK;
78 +
79 + if (!vpEngine)
80 + {
81 + hr = E_POINTER;
82 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
83 + }
84 +
85 + hr = vpEngine->EvaluateCondition(wzCondition, pf);
86 +
87 +LExit:
88 + return hr;
89 +}
90 +
91 +
92 +// The contents of psczOut may be sensitive, should keep encrypted and SecureZeroFree.
93 +DAPI_(HRESULT) BalFormatString(
94 + __in_z LPCWSTR wzFormat,
95 + __inout LPWSTR* psczOut
96 + )
97 +{
98 + HRESULT hr = S_OK;
99 + DWORD cch = 0;
100 +
101 + if (!vpEngine)
102 + {
103 + hr = E_POINTER;
104 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
105 + }
106 +
107 + if (*psczOut)
108 + {
109 + hr = StrMaxLength(*psczOut, reinterpret_cast<DWORD_PTR*>(&cch));
110 + ExitOnFailure(hr, "Failed to determine length of value.");
111 + }
112 +
113 + hr = vpEngine->FormatString(wzFormat, *psczOut, &cch);
114 + if (E_MOREDATA == hr)
115 + {
116 + ++cch;
117 +
118 + hr = StrAllocSecure(psczOut, cch);
119 + ExitOnFailure(hr, "Failed to allocate value.");
120 +
121 + hr = vpEngine->FormatString(wzFormat, *psczOut, &cch);
122 + }
123 +
124 +LExit:
125 + return hr;
126 +}
127 +
128 +
129 +// The contents of pllValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroMemory.
130 +DAPI_(HRESULT) BalGetNumericVariable(
131 + __in_z LPCWSTR wzVariable,
132 + __out LONGLONG* pllValue
133 + )
134 +{
135 + HRESULT hr = S_OK;
136 +
137 + if (!vpEngine)
138 + {
139 + hr = E_POINTER;
140 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
141 + }
142 +
143 + hr = vpEngine->GetVariableNumeric(wzVariable, pllValue);
144 +
145 +LExit:
146 + return hr;
147 +}
148 +
149 +
150 +DAPI_(HRESULT) BalSetNumericVariable(
151 + __in_z LPCWSTR wzVariable,
152 + __in LONGLONG llValue
153 + )
154 +{
155 + HRESULT hr = S_OK;
156 +
157 + if (!vpEngine)
158 + {
159 + hr = E_POINTER;
160 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
161 + }
162 +
163 + hr = vpEngine->SetVariableNumeric(wzVariable, llValue);
164 +
165 +LExit:
166 + return hr;
167 +}
168 +
169 +
170 +DAPI_(BOOL) BalStringVariableExists(
171 + __in_z LPCWSTR wzVariable
172 + )
173 +{
174 + HRESULT hr = S_OK;
175 + DWORD cch = 0;
176 +
177 + if (!vpEngine)
178 + {
179 + hr = E_POINTER;
180 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
181 + }
182 +
183 + hr = vpEngine->GetVariableString(wzVariable, NULL, &cch);
184 +
185 +LExit:
186 + return E_MOREDATA == hr; // string exists only if there are more than zero characters in the variable.
187 +}
188 +
189 +
190 +// The contents of psczValue may be sensitive, if variable is hidden should keep value encrypted and SecureZeroFree.
191 +DAPI_(HRESULT) BalGetStringVariable(
192 + __in_z LPCWSTR wzVariable,
193 + __inout LPWSTR* psczValue
194 + )
195 +{
196 + HRESULT hr = S_OK;
197 + DWORD cch = 0;
198 +
199 + if (!vpEngine)
200 + {
201 + hr = E_POINTER;
202 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
203 + }
204 +
205 + if (*psczValue)
206 + {
207 + hr = StrMaxLength(*psczValue, reinterpret_cast<DWORD_PTR*>(&cch));
208 + ExitOnFailure(hr, "Failed to determine length of value.");
209 + }
210 +
211 + hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch);
212 + if (E_MOREDATA == hr)
213 + {
214 + ++cch;
215 +
216 + hr = StrAllocSecure(psczValue, cch);
217 + ExitOnFailure(hr, "Failed to allocate value.");
218 +
219 + hr = vpEngine->GetVariableString(wzVariable, *psczValue, &cch);
220 + }
221 +
222 +LExit:
223 + return hr;
224 +}
225 +
226 +DAPI_(HRESULT) BalSetStringVariable(
227 + __in_z LPCWSTR wzVariable,
228 + __in_z_opt LPCWSTR wzValue
229 + )
230 +{
231 + HRESULT hr = S_OK;
232 +
233 + if (!vpEngine)
234 + {
235 + hr = E_POINTER;
236 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
237 + }
238 +
239 + hr = vpEngine->SetVariableString(wzVariable, wzValue);
240 +
241 +LExit:
242 + return hr;
243 +}
244 +
245 +
246 +DAPIV_(HRESULT) BalLog(
247 + __in BOOTSTRAPPER_LOG_LEVEL level,
248 + __in_z __format_string LPCSTR szFormat,
249 + ...
250 + )
251 +{
252 + HRESULT hr = S_OK;
253 + va_list args;
254 + LPSTR sczFormattedAnsi = NULL;
255 + LPWSTR sczMessage = NULL;
256 +
257 + if (!vpEngine)
258 + {
259 + hr = E_POINTER;
260 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
261 + }
262 +
263 + va_start(args, szFormat);
264 + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args);
265 + va_end(args);
266 + ExitOnFailure(hr, "Failed to format log string.");
267 +
268 + hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8);
269 + ExitOnFailure(hr, "Failed to convert log string to Unicode.");
270 +
271 + hr = vpEngine->Log(level, sczMessage);
272 +
273 +LExit:
274 + ReleaseStr(sczMessage);
275 + ReleaseStr(sczFormattedAnsi);
276 + return hr;
277 +}
278 +
279 +
280 +DAPIV_(HRESULT) BalLogError(
281 + __in HRESULT hrError,
282 + __in_z __format_string LPCSTR szFormat,
283 + ...
284 + )
285 +{
286 + HRESULT hr = S_OK;
287 + va_list args;
288 + LPSTR sczFormattedAnsi = NULL;
289 + LPWSTR sczMessage = NULL;
290 +
291 + if (!vpEngine)
292 + {
293 + hr = E_POINTER;
294 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
295 + }
296 +
297 + va_start(args, szFormat);
298 + hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args);
299 + va_end(args);
300 + ExitOnFailure(hr, "Failed to format error log string.");
301 +
302 + hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi);
303 + ExitOnFailure(hr, "Failed to prepend error number to error log string.");
304 +
305 + hr = vpEngine->Log(BOOTSTRAPPER_LOG_LEVEL_ERROR, sczMessage);
306 +
307 +LExit:
308 + ReleaseStr(sczMessage);
309 + ReleaseStr(sczFormattedAnsi);
310 + return hr;
311 +}
312 +
313 +DAPIV_(HRESULT) BalLogId(
314 + __in BOOTSTRAPPER_LOG_LEVEL level,
315 + __in DWORD dwLogId,
316 + __in HMODULE hModule,
317 + ...
318 + )
319 +{
320 + HRESULT hr = S_OK;
321 + va_list args;
322 +
323 + if (!vpEngine)
324 + {
325 + hr = E_POINTER;
326 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
327 + }
328 +
329 + va_start(args, hModule);
330 + hr = BalLogIdArgs(level, dwLogId, hModule, args);
331 + va_end(args);
332 +
333 +LExit:
334 + return hr;
335 +}
336 +
337 +DAPI_(HRESULT) BalLogIdArgs(
338 + __in BOOTSTRAPPER_LOG_LEVEL level,
339 + __in DWORD dwLogId,
340 + __in HMODULE hModule,
341 + __in va_list args
342 + )
343 +{
344 +
345 + HRESULT hr = S_OK;
346 + LPWSTR pwz = NULL;
347 + DWORD cch = 0;
348 +
349 + if (!vpEngine)
350 + {
351 + hr = E_POINTER;
352 + ExitOnRootFailure(hr, "BalInitialize() must be called first.");
353 + }
354 +
355 + // Get the string for the id.
356 +#pragma prefast(push)
357 +#pragma prefast(disable:25028)
358 +#pragma prefast(disable:25068)
359 + cch = ::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE,
360 + static_cast<LPCVOID>(hModule), dwLogId, 0, reinterpret_cast<LPWSTR>(&pwz), 0, &args);
361 +#pragma prefast(pop)
362 +
363 + if (0 == cch)
364 + {
365 + ExitOnLastError(hr, "Failed to log id: %d", dwLogId);
366 + }
367 +
368 + if (2 <= cch && L'\r' == pwz[cch - 2] && L'\n' == pwz[cch - 1])
369 + {
370 + pwz[cch - 2] = L'\0'; // remove newline from message table.
371 + }
372 +
373 + hr = vpEngine->Log(level, pwz);
374 +
375 +LExit:
376 + if (pwz)
377 + {
378 + ::LocalFree(pwz);
379 + }
380 +
381 + return hr;
382 +}
src/balutil/inc/BAFunctions.h new
+130
@@ -0,0 +1,130 @@
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 +#ifdef __cplusplus
6 +extern "C" {
7 +#endif
8 +
9 +// The first 1024 messages are reserved so that the BA messages have the same value here.
10 +enum BA_FUNCTIONS_MESSAGE
11 +{
12 + BA_FUNCTIONS_MESSAGE_ONDETECTBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN,
13 + BA_FUNCTIONS_MESSAGE_ONDETECTCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE,
14 + BA_FUNCTIONS_MESSAGE_ONPLANBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN,
15 + BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE,
16 + BA_FUNCTIONS_MESSAGE_ONSTARTUP = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP,
17 + BA_FUNCTIONS_MESSAGE_ONSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN,
18 + BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN,
19 + BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE,
20 + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN,
21 + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE,
22 + BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE,
23 + BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE,
24 + BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN,
25 + BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE,
26 + BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE,
27 + BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE,
28 + BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE,
29 + BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE,
30 + BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE,
31 + BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN,
32 + BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN,
33 + BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE,
34 + BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE,
35 + BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE,
36 + BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE,
37 + BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN,
38 + BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN,
39 + BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE,
40 + BA_FUNCTIONS_MESSAGE_ONPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS,
41 + BA_FUNCTIONS_MESSAGE_ONERROR = BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR,
42 + BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN,
43 + BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE,
44 + BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN,
45 + BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN,
46 + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN,
47 + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS,
48 + BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE,
49 + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE,
50 + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN,
51 + BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE,
52 + BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE,
53 + BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE,
54 + BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN,
55 + BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN,
56 + BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET,
57 + BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS,
58 + BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE,
59 + BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE,
60 + BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE,
61 + BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE,
62 + BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN,
63 + BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE,
64 + BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE,
65 + BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN,
66 + BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE,
67 +
68 + BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024,
69 + BA_FUNCTIONS_MESSAGE_WNDPROC,
70 +};
71 +
72 +typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_PROC)(
73 + __in BA_FUNCTIONS_MESSAGE message,
74 + __in const LPVOID pvArgs,
75 + __inout LPVOID pvResults,
76 + __in_opt LPVOID pvContext
77 + );
78 +
79 +struct BA_FUNCTIONS_CREATE_ARGS
80 +{
81 + DWORD cbSize;
82 + DWORD64 qwBAFunctionsAPIVersion;
83 + BOOTSTRAPPER_CREATE_ARGS* pBootstrapperCreateArgs;
84 +};
85 +
86 +struct BA_FUNCTIONS_CREATE_RESULTS
87 +{
88 + DWORD cbSize;
89 + PFN_BA_FUNCTIONS_PROC pfnBAFunctionsProc;
90 + LPVOID pvBAFunctionsProcContext;
91 +};
92 +
93 +struct BA_FUNCTIONS_ONTHEMELOADED_ARGS
94 +{
95 + DWORD cbSize;
96 + THEME* pTheme;
97 + WIX_LOCALIZATION* pWixLoc;
98 +};
99 +
100 +struct BA_FUNCTIONS_ONTHEMELOADED_RESULTS
101 +{
102 + DWORD cbSize;
103 +};
104 +
105 +struct BA_FUNCTIONS_WNDPROC_ARGS
106 +{
107 + DWORD cbSize;
108 + THEME* pTheme;
109 + HWND hWnd;
110 + UINT uMsg;
111 + WPARAM wParam;
112 + LPARAM lParam;
113 +};
114 +
115 +struct BA_FUNCTIONS_WNDPROC_RESULTS
116 +{
117 + DWORD cbSize;
118 + LRESULT lres;
119 +};
120 +
121 +typedef HRESULT(WINAPI *PFN_BA_FUNCTIONS_CREATE)(
122 + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
123 + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
124 + );
125 +
126 +typedef void (WINAPI *PFN_BA_FUNCTIONS_DESTROY)();
127 +
128 +#ifdef __cplusplus
129 +}
130 +#endif
src/balutil/inc/BalBaseBAFunctions.h new
+700
@@ -0,0 +1,700 @@
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 <msiquery.h>
7 +
8 +#include "dutil.h"
9 +#include "locutil.h"
10 +#include "thmutil.h"
11 +#include "BAFunctions.h"
12 +#include "IBAFunctions.h"
13 +#include "BootstrapperEngine.h"
14 +#include "BootstrapperApplication.h"
15 +#include "IBootstrapperEngine.h"
16 +#include "IBootstrapperApplication.h"
17 +
18 +class CBalBaseBAFunctions : public IBAFunctions
19 +{
20 +public: // IUnknown
21 + virtual STDMETHODIMP QueryInterface(
22 + __in REFIID riid,
23 + __out LPVOID *ppvObject
24 + )
25 + {
26 + if (!ppvObject)
27 + {
28 + return E_INVALIDARG;
29 + }
30 +
31 + *ppvObject = NULL;
32 +
33 + if (::IsEqualIID(__uuidof(IBAFunctions), riid))
34 + {
35 + *ppvObject = static_cast<IBAFunctions*>(this);
36 + }
37 + else if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid))
38 + {
39 + *ppvObject = static_cast<IBootstrapperApplication*>(this);
40 + }
41 + else if (::IsEqualIID(IID_IUnknown, riid))
42 + {
43 + *ppvObject = static_cast<IUnknown*>(this);
44 + }
45 + else // no interface for requested iid
46 + {
47 + return E_NOINTERFACE;
48 + }
49 +
50 + AddRef();
51 + return S_OK;
52 + }
53 +
54 + virtual STDMETHODIMP_(ULONG) AddRef()
55 + {
56 + return ::InterlockedIncrement(&this->m_cReferences);
57 + }
58 +
59 + virtual STDMETHODIMP_(ULONG) Release()
60 + {
61 + long l = ::InterlockedDecrement(&this->m_cReferences);
62 + if (0 < l)
63 + {
64 + return l;
65 + }
66 +
67 + delete this;
68 + return 0;
69 + }
70 +
71 +public: // IBootstrapperApplication
72 + virtual STDMETHODIMP OnStartup()
73 + {
74 + return S_OK;
75 + }
76 +
77 + virtual STDMETHODIMP OnShutdown(
78 + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/
79 + )
80 + {
81 + return S_OK;
82 + }
83 +
84 + virtual STDMETHODIMP OnSystemShutdown(
85 + __in DWORD /*dwEndSession*/,
86 + __inout BOOL* /*pfCancel*/
87 + )
88 + {
89 + return S_OK;
90 + }
91 +
92 + virtual STDMETHODIMP OnDetectBegin(
93 + __in BOOL /*fInstalled*/,
94 + __in DWORD /*cPackages*/,
95 + __inout BOOL* /*pfCancel*/
96 + )
97 + {
98 + return S_OK;
99 + }
100 +
101 + virtual STDMETHODIMP OnDetectForwardCompatibleBundle(
102 + __in_z LPCWSTR /*wzBundleId*/,
103 + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/,
104 + __in_z LPCWSTR /*wzBundleTag*/,
105 + __in BOOL /*fPerMachine*/,
106 + __in DWORD64 /*dw64Version*/,
107 + __inout BOOL* /*pfCancel*/,
108 + __inout BOOL* /*pfIgnoreBundle*/
109 + )
110 + {
111 + return S_OK;
112 + }
113 +
114 + virtual STDMETHODIMP OnDetectUpdateBegin(
115 + __in_z LPCWSTR /*wzUpdateLocation*/,
116 + __inout BOOL* /*pfCancel*/,
117 + __inout BOOL* /*pfSkip*/
118 + )
119 + {
120 + return S_OK;
121 + }
122 +
123 + virtual STDMETHODIMP OnDetectUpdate(
124 + __in_z LPCWSTR /*wzUpdateLocation*/,
125 + __in DWORD64 /*dw64Size*/,
126 + __in DWORD64 /*dw64Version*/,
127 + __in_z LPCWSTR /*wzTitle*/,
128 + __in_z LPCWSTR /*wzSummary*/,
129 + __in_z LPCWSTR /*wzContentType*/,
130 + __in_z LPCWSTR /*wzContent*/,
131 + __inout BOOL* /*pfCancel*/,
132 + __inout BOOL* /*pfStopProcessingUpdates*/
133 + )
134 + {
135 + return S_OK;
136 + }
137 +
138 + virtual STDMETHODIMP OnDetectUpdateComplete(
139 + __in HRESULT /*hrStatus*/,
140 + __inout BOOL* /*pfIgnoreError*/
141 + )
142 + {
143 + return S_OK;
144 + }
145 +
146 + virtual STDMETHODIMP OnDetectRelatedBundle(
147 + __in_z LPCWSTR /*wzBundleId*/,
148 + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/,
149 + __in_z LPCWSTR /*wzBundleTag*/,
150 + __in BOOL /*fPerMachine*/,
151 + __in DWORD64 /*dw64Version*/,
152 + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/,
153 + __inout BOOL* /*pfCancel*/
154 + )
155 + {
156 + return S_OK;
157 + }
158 +
159 + virtual STDMETHODIMP OnDetectPackageBegin(
160 + __in_z LPCWSTR /*wzPackageId*/,
161 + __inout BOOL* /*pfCancel*/
162 + )
163 + {
164 + return S_OK;
165 + }
166 +
167 + virtual STDMETHODIMP OnDetectCompatibleMsiPackage(
168 + __in_z LPCWSTR /*wzPackageId*/,
169 + __in_z LPCWSTR /*wzCompatiblePackageId*/,
170 + __in DWORD64 /*dw64CompatiblePackageVersion*/,
171 + __inout BOOL* /*pfCancel*/
172 + )
173 + {
174 + return S_OK;
175 + }
176 +
177 + virtual STDMETHODIMP OnDetectRelatedMsiPackage(
178 + __in_z LPCWSTR /*wzPackageId*/,
179 + __in_z LPCWSTR /*wzUpgradeCode*/,
180 + __in_z LPCWSTR /*wzProductCode*/,
181 + __in BOOL /*fPerMachine*/,
182 + __in DWORD64 /*dw64Version*/,
183 + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/,
184 + __inout BOOL* /*pfCancel*/
185 + )
186 + {
187 + return S_OK;
188 + }
189 +
190 + virtual STDMETHODIMP OnDetectTargetMsiPackage(
191 + __in_z LPCWSTR /*wzPackageId*/,
192 + __in_z LPCWSTR /*wzProductCode*/,
193 + __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/,
194 + __inout BOOL* /*pfCancel*/
195 + )
196 + {
197 + return S_OK;
198 + }
199 +
200 + virtual STDMETHODIMP OnDetectMsiFeature(
201 + __in_z LPCWSTR /*wzPackageId*/,
202 + __in_z LPCWSTR /*wzFeatureId*/,
203 + __in BOOTSTRAPPER_FEATURE_STATE /*state*/,
204 + __inout BOOL* /*pfCancel*/
205 + )
206 + {
207 + return S_OK;
208 + }
209 +
210 + virtual STDMETHODIMP OnDetectPackageComplete(
211 + __in_z LPCWSTR /*wzPackageId*/,
212 + __in HRESULT /*hrStatus*/,
213 + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/
214 + )
215 + {
216 + return S_OK;
217 + }
218 +
219 + virtual STDMETHODIMP OnDetectComplete(
220 + __in HRESULT /*hrStatus*/
221 + )
222 + {
223 + return S_OK;
224 + }
225 +
226 + virtual STDMETHODIMP OnPlanBegin(
227 + __in DWORD /*cPackages*/,
228 + __inout BOOL* /*pfCancel*/
229 + )
230 + {
231 + return S_OK;
232 + }
233 +
234 + virtual STDMETHODIMP OnPlanRelatedBundle(
235 + __in_z LPCWSTR /*wzBundleId*/,
236 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
237 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/,
238 + __inout BOOL* /*pfCancel*/
239 + )
240 + {
241 + return S_OK;
242 + }
243 +
244 + virtual STDMETHODIMP OnPlanPackageBegin(
245 + __in_z LPCWSTR /*wzPackageId*/,
246 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
247 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/,
248 + __inout BOOL* /*pfCancel*/
249 + )
250 + {
251 + return S_OK;
252 + }
253 +
254 + virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin(
255 + __in_z LPCWSTR /*wzPackageId*/,
256 + __in_z LPCWSTR /*wzCompatiblePackageId*/,
257 + __in DWORD64 /*dw64CompatiblePackageVersion*/,
258 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
259 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/,
260 + __inout BOOL* /*pfCancel*/
261 + )
262 + {
263 + return S_OK;
264 + }
265 +
266 + virtual STDMETHODIMP OnPlanCompatibleMsiPackageComplete(
267 + __in_z LPCWSTR /*wzPackageId*/,
268 + __in_z LPCWSTR /*wzCompatiblePackageId*/,
269 + __in HRESULT /*hrStatus*/,
270 + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/,
271 + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/,
272 + __in BOOTSTRAPPER_ACTION_STATE /*execute*/,
273 + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/
274 + )
275 + {
276 + return S_OK;
277 + }
278 +
279 + virtual STDMETHODIMP OnPlanTargetMsiPackage(
280 + __in_z LPCWSTR /*wzPackageId*/,
281 + __in_z LPCWSTR /*wzProductCode*/,
282 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
283 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/,
284 + __inout BOOL* /*pfCancel*/
285 + )
286 + {
287 + return S_OK;
288 + }
289 +
290 + virtual STDMETHODIMP OnPlanMsiFeature(
291 + __in_z LPCWSTR /*wzPackageId*/,
292 + __in_z LPCWSTR /*wzFeatureId*/,
293 + __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/,
294 + __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/,
295 + __inout BOOL* /*pfCancel*/
296 + )
297 + {
298 + return S_OK;
299 + }
300 +
301 + virtual STDMETHODIMP OnPlanPackageComplete(
302 + __in_z LPCWSTR /*wzPackageId*/,
303 + __in HRESULT /*hrStatus*/,
304 + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/,
305 + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/,
306 + __in BOOTSTRAPPER_ACTION_STATE /*execute*/,
307 + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/
308 + )
309 + {
310 + return S_OK;
311 + }
312 +
313 + virtual STDMETHODIMP OnPlanComplete(
314 + __in HRESULT /*hrStatus*/
315 + )
316 + {
317 + return S_OK;
318 + }
319 +
320 + virtual STDMETHODIMP OnApplyBegin(
321 + __in DWORD /*dwPhaseCount*/,
322 + __inout BOOL* /*pfCancel*/
323 + )
324 + {
325 + return S_OK;
326 + }
327 +
328 + virtual STDMETHODIMP OnElevateBegin(
329 + __inout BOOL* /*pfCancel*/
330 + )
331 + {
332 + return S_OK;
333 + }
334 +
335 + virtual STDMETHODIMP OnElevateComplete(
336 + __in HRESULT /*hrStatus*/
337 + )
338 + {
339 + return S_OK;
340 + }
341 +
342 + virtual STDMETHODIMP OnProgress(
343 + __in DWORD /*dwProgressPercentage*/,
344 + __in DWORD /*dwOverallProgressPercentage*/,
345 + __inout BOOL* /*pfCancel*/
346 + )
347 + {
348 + return IDNOACTION;
349 + }
350 +
351 + virtual STDMETHODIMP OnError(
352 + __in BOOTSTRAPPER_ERROR_TYPE /*errorType*/,
353 + __in_z LPCWSTR /*wzPackageId*/,
354 + __in DWORD /*dwCode*/,
355 + __in_z LPCWSTR /*wzError*/,
356 + __in DWORD /*dwUIHint*/,
357 + __in DWORD /*cData*/,
358 + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/,
359 + __in int /*nRecommendation*/,
360 + __inout int* /*pResult*/
361 + )
362 + {
363 + return S_OK;
364 + }
365 +
366 + virtual STDMETHODIMP OnRegisterBegin(
367 + __inout BOOL* /*pfCancel*/
368 + )
369 + {
370 + return S_OK;
371 + }
372 +
373 + virtual STDMETHODIMP OnRegisterComplete(
374 + __in HRESULT /*hrStatus*/
375 + )
376 + {
377 + return S_OK;
378 + }
379 +
380 + virtual STDMETHODIMP OnCacheBegin(
381 + __inout BOOL* /*pfCancel*/
382 + )
383 + {
384 + return S_OK;
385 + }
386 +
387 + virtual STDMETHODIMP OnCachePackageBegin(
388 + __in_z LPCWSTR /*wzPackageId*/,
389 + __in DWORD /*cCachePayloads*/,
390 + __in DWORD64 /*dw64PackageCacheSize*/,
391 + __inout BOOL* /*pfCancel*/
392 + )
393 + {
394 + return S_OK;
395 + }
396 +
397 + virtual STDMETHODIMP OnCacheAcquireBegin(
398 + __in_z LPCWSTR /*wzPackageOrContainerId*/,
399 + __in_z_opt LPCWSTR /*wzPayloadId*/,
400 + __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/,
401 + __in_z LPCWSTR /*wzSource*/,
402 + __inout BOOL* /*pfCancel*/
403 + )
404 + {
405 + return S_OK;
406 + }
407 +
408 + virtual STDMETHODIMP OnCacheAcquireProgress(
409 + __in_z LPCWSTR /*wzPackageOrContainerId*/,
410 + __in_z_opt LPCWSTR /*wzPayloadId*/,
411 + __in DWORD64 /*dw64Progress*/,
412 + __in DWORD64 /*dw64Total*/,
413 + __in DWORD /*dwOverallPercentage*/,
414 + __inout BOOL* /*pfCancel*/
415 + )
416 + {
417 + return S_OK;
418 + }
419 +
420 + virtual STDMETHODIMP OnResolveSource(
421 + __in_z LPCWSTR /*wzPackageOrContainerId*/,
422 + __in_z_opt LPCWSTR /*wzPayloadId*/,
423 + __in_z LPCWSTR /*wzLocalSource*/,
424 + __in_z_opt LPCWSTR /*wzDownloadSource*/,
425 + __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/,
426 + __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/,
427 + __inout BOOL* /*pfCancel*/
428 + )
429 + {
430 + return S_OK;
431 + }
432 +
433 + virtual STDMETHODIMP OnCacheAcquireComplete(
434 + __in_z LPCWSTR /*wzPackageOrContainerId*/,
435 + __in_z_opt LPCWSTR /*wzPayloadId*/,
436 + __in HRESULT /*hrStatus*/,
437 + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/,
438 + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* /*pAction*/
439 + )
440 + {
441 + return S_OK;
442 + }
443 +
444 + virtual STDMETHODIMP OnCacheVerifyBegin(
445 + __in_z LPCWSTR /*wzPackageId*/,
446 + __in_z LPCWSTR /*wzPayloadId*/,
447 + __inout BOOL* /*pfCancel*/
448 + )
449 + {
450 + return S_OK;
451 + }
452 +
453 + virtual STDMETHODIMP OnCacheVerifyComplete(
454 + __in_z LPCWSTR /*wzPackageId*/,
455 + __in_z LPCWSTR /*wzPayloadId*/,
456 + __in HRESULT /*hrStatus*/,
457 + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/,
458 + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* /*pAction*/
459 + )
460 + {
461 + return S_OK;
462 + }
463 +
464 + virtual STDMETHODIMP OnCachePackageComplete(
465 + __in_z LPCWSTR /*wzPackageId*/,
466 + __in HRESULT /*hrStatus*/,
467 + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/,
468 + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* /*pAction*/
469 + )
470 + {
471 + return S_OK;
472 + }
473 +
474 + virtual STDMETHODIMP OnCacheComplete(
475 + __in HRESULT /*hrStatus*/
476 + )
477 + {
478 + return S_OK;
479 + }
480 +
481 + virtual STDMETHODIMP OnExecuteBegin(
482 + __in DWORD /*cExecutingPackages*/,
483 + __inout BOOL* /*pfCancel*/
484 + )
485 + {
486 + return S_OK;
487 + }
488 +
489 + virtual STDMETHODIMP OnExecutePackageBegin(
490 + __in_z LPCWSTR /*wzPackageId*/,
491 + __in BOOL /*fExecute*/,
492 + __inout BOOL* /*pfCancel*/
493 + )
494 + {
495 + return S_OK;
496 + }
497 +
498 + virtual STDMETHODIMP OnExecutePatchTarget(
499 + __in_z LPCWSTR /*wzPackageId*/,
500 + __in_z LPCWSTR /*wzTargetProductCode*/,
501 + __inout BOOL* /*pfCancel*/
502 + )
503 + {
504 + return S_OK;
505 + }
506 +
507 + virtual STDMETHODIMP OnExecuteProgress(
508 + __in_z LPCWSTR /*wzPackageId*/,
509 + __in DWORD /*dwProgressPercentage*/,
510 + __in DWORD /*dwOverallProgressPercentage*/,
511 + __inout BOOL* /*pfCancel*/
512 + )
513 + {
514 + return S_OK;
515 + }
516 +
517 + virtual STDMETHODIMP OnExecuteMsiMessage(
518 + __in_z LPCWSTR /*wzPackageId*/,
519 + __in INSTALLMESSAGE /*messageType*/,
520 + __in DWORD /*dwUIHint*/,
521 + __in_z LPCWSTR /*wzMessage*/,
522 + __in DWORD /*cData*/,
523 + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/,
524 + __in int /*nRecommendation*/,
525 + __inout int* /*pResult*/
526 + )
527 + {
528 + return S_OK;
529 + }
530 +
531 + virtual STDMETHODIMP OnExecuteFilesInUse(
532 + __in_z LPCWSTR /*wzPackageId*/,
533 + __in DWORD /*cFiles*/,
534 + __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/,
535 + __in int /*nRecommendation*/,
536 + __inout int* /*pResult*/
537 + )
538 + {
539 + return S_OK;
540 + }
541 +
542 + virtual STDMETHODIMP OnExecutePackageComplete(
543 + __in_z LPCWSTR /*wzPackageId*/,
544 + __in HRESULT /*hrStatus*/,
545 + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
546 + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/,
547 + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* /*pAction*/
548 + )
549 + {
550 + return S_OK;
551 + }
552 +
553 + virtual STDMETHODIMP OnExecuteComplete(
554 + __in HRESULT /*hrStatus*/
555 + )
556 + {
557 + return S_OK;
558 + }
559 +
560 + virtual STDMETHODIMP OnUnregisterBegin(
561 + __inout BOOL* /*pfCancel*/
562 + )
563 + {
564 + return S_OK;
565 + }
566 +
567 + virtual STDMETHODIMP OnUnregisterComplete(
568 + __in HRESULT /*hrStatus*/
569 + )
570 + {
571 + return S_OK;
572 + }
573 +
574 + virtual STDMETHODIMP OnApplyComplete(
575 + __in HRESULT /*hrStatus*/,
576 + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
577 + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/,
578 + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* /*pAction*/
579 + )
580 + {
581 + return S_OK;
582 + }
583 +
584 + virtual STDMETHODIMP OnLaunchApprovedExeBegin(
585 + __inout BOOL* /*pfCancel*/
586 + )
587 + {
588 + return S_OK;
589 + }
590 +
591 + virtual STDMETHODIMP OnLaunchApprovedExeComplete(
592 + __in HRESULT /*hrStatus*/,
593 + __in DWORD /*dwProcessId*/
594 + )
595 + {
596 + return S_OK;
597 + }
598 +
599 + virtual STDMETHODIMP_(HRESULT) BAProc(
600 + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/,
601 + __in const LPVOID /*pvArgs*/,
602 + __inout LPVOID /*pvResults*/,
603 + __in_opt LPVOID /*pvContext*/
604 + )
605 + {
606 + return E_NOTIMPL;
607 + }
608 +
609 + virtual STDMETHODIMP_(void) BAProcFallback(
610 + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/,
611 + __in const LPVOID /*pvArgs*/,
612 + __inout LPVOID /*pvResults*/,
613 + __inout HRESULT* /*phr*/,
614 + __in_opt LPVOID /*pvContext*/
615 + )
616 + {
617 + }
618 +
619 +public: // IBAFunctions
620 + virtual STDMETHODIMP OnPlan(
621 + )
622 + {
623 + return S_OK;
624 + }
625 +
626 + virtual STDMETHODIMP OnThemeLoaded(
627 + THEME* pTheme,
628 + WIX_LOCALIZATION* pWixLoc
629 + )
630 + {
631 + HRESULT hr = S_OK;
632 +
633 + m_pTheme = pTheme;
634 + m_pWixLoc = pWixLoc;
635 +
636 + return hr;
637 + }
638 +
639 + virtual STDMETHODIMP WndProc(
640 + __in THEME* pTheme,
641 + __in HWND hWnd,
642 + __in UINT uMsg,
643 + __in WPARAM wParam,
644 + __in LPARAM lParam,
645 + __inout LRESULT* plRes
646 + )
647 + {
648 + HRESULT hr = S_OK;
649 +
650 + *plRes = ThemeDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam);
651 +
652 + return hr;
653 + }
654 +
655 + virtual STDMETHODIMP BAFunctionsProc(
656 + __in BA_FUNCTIONS_MESSAGE /*message*/,
657 + __in const LPVOID /*pvArgs*/,
658 + __inout LPVOID /*pvResults*/,
659 + __in_opt LPVOID /*pvContext*/
660 + )
661 + {
662 + return E_NOTIMPL;
663 + }
664 +
665 +protected:
666 + CBalBaseBAFunctions(
667 + __in HMODULE hModule,
668 + __in IBootstrapperEngine* pEngine,
669 + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs
670 + )
671 + {
672 + m_cReferences = 1;
673 + m_hModule = hModule;
674 + pEngine->AddRef();
675 + m_pEngine = pEngine;
676 +
677 + memcpy_s(&m_command, sizeof(m_command), pArgs->pBootstrapperCreateArgs->pCommand, sizeof(BOOTSTRAPPER_COMMAND));
678 + memcpy_s(&m_baCreateArgs, sizeof(m_baCreateArgs), pArgs->pBootstrapperCreateArgs, sizeof(BOOTSTRAPPER_CREATE_ARGS));
679 + memcpy_s(&m_bafCreateArgs, sizeof(m_bafCreateArgs), pArgs, sizeof(BA_FUNCTIONS_CREATE_ARGS));
680 + m_baCreateArgs.pCommand = &m_command;
681 + m_bafCreateArgs.pBootstrapperCreateArgs = &m_baCreateArgs;
682 + }
683 +
684 + virtual ~CBalBaseBAFunctions()
685 + {
686 + ReleaseNullObject(m_pEngine);
687 + }
688 +
689 +private:
690 + long m_cReferences;
691 +
692 +protected:
693 + IBootstrapperEngine* m_pEngine;
694 + HMODULE m_hModule;
695 + BA_FUNCTIONS_CREATE_ARGS m_bafCreateArgs;
696 + BOOTSTRAPPER_CREATE_ARGS m_baCreateArgs;
697 + BOOTSTRAPPER_COMMAND m_command;
698 + THEME* m_pTheme;
699 + WIX_LOCALIZATION* m_pWixLoc;
700 +};
src/balutil/inc/BalBaseBAFunctionsProc.h new
+114
@@ -0,0 +1,114 @@
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 "BalBaseBootstrapperApplicationProc.h"
6 +#include "BAFunctions.h"
7 +#include "IBAFunctions.h"
8 +
9 +static HRESULT BalBaseBAFunctionsProcOnThemeLoaded(
10 + __in IBAFunctions* pBAFunctions,
11 + __in BA_FUNCTIONS_ONTHEMELOADED_ARGS* pArgs,
12 + __inout BA_FUNCTIONS_ONTHEMELOADED_RESULTS* /*pResults*/
13 + )
14 +{
15 + return pBAFunctions->OnThemeLoaded(pArgs->pTheme, pArgs->pWixLoc);
16 +}
17 +
18 +static HRESULT BalBaseBAFunctionsProcWndProc(
19 + __in IBAFunctions* pBAFunctions,
20 + __in BA_FUNCTIONS_WNDPROC_ARGS* pArgs,
21 + __inout BA_FUNCTIONS_WNDPROC_RESULTS* pResults
22 + )
23 +{
24 + return pBAFunctions->WndProc(pArgs->pTheme, pArgs->hWnd, pArgs->uMsg, pArgs->wParam, pArgs->lParam, &pResults->lres);
25 +}
26 +
27 +/*******************************************************************
28 +BalBaseBAFunctionsProc - requires pvContext to be of type IBAFunctions.
29 +Provides a default mapping between the message based BAFunctions interface and
30 +the COM-based BAFunctions interface.
31 +
32 +*******************************************************************/
33 +static HRESULT WINAPI BalBaseBAFunctionsProc(
34 + __in BA_FUNCTIONS_MESSAGE message,
35 + __in const LPVOID pvArgs,
36 + __inout LPVOID pvResults,
37 + __in_opt LPVOID pvContext
38 + )
39 +{
40 + IBAFunctions* pBAFunctions = reinterpret_cast<IBAFunctions*>(pvContext);
41 + HRESULT hr = pBAFunctions->BAFunctionsProc(message, pvArgs, pvResults, pvContext);
42 +
43 + if (E_NOTIMPL == hr)
44 + {
45 + switch (message)
46 + {
47 + case BA_FUNCTIONS_MESSAGE_ONDETECTBEGIN:
48 + case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPLETE:
49 + case BA_FUNCTIONS_MESSAGE_ONPLANBEGIN:
50 + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPLETE:
51 + case BA_FUNCTIONS_MESSAGE_ONSTARTUP:
52 + case BA_FUNCTIONS_MESSAGE_ONSHUTDOWN:
53 + case BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN:
54 + case BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE:
55 + case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN:
56 + case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE:
57 + case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATECOMPLETE:
58 + case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDBUNDLE:
59 + case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGEBEGIN:
60 + case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE:
61 + case BA_FUNCTIONS_MESSAGE_ONDETECTRELATEDMSIPACKAGE:
62 + case BA_FUNCTIONS_MESSAGE_ONDETECTTARGETMSIPACKAGE:
63 + case BA_FUNCTIONS_MESSAGE_ONDETECTMSIFEATURE:
64 + case BA_FUNCTIONS_MESSAGE_ONDETECTPACKAGECOMPLETE:
65 + case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLE:
66 + case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGEBEGIN:
67 + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN:
68 + case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE:
69 + case BA_FUNCTIONS_MESSAGE_ONPLANTARGETMSIPACKAGE:
70 + case BA_FUNCTIONS_MESSAGE_ONPLANMSIFEATURE:
71 + case BA_FUNCTIONS_MESSAGE_ONPLANPACKAGECOMPLETE:
72 + case BA_FUNCTIONS_MESSAGE_ONAPPLYBEGIN:
73 + case BA_FUNCTIONS_MESSAGE_ONELEVATEBEGIN:
74 + case BA_FUNCTIONS_MESSAGE_ONELEVATECOMPLETE:
75 + case BA_FUNCTIONS_MESSAGE_ONPROGRESS:
76 + case BA_FUNCTIONS_MESSAGE_ONERROR:
77 + case BA_FUNCTIONS_MESSAGE_ONREGISTERBEGIN:
78 + case BA_FUNCTIONS_MESSAGE_ONREGISTERCOMPLETE:
79 + case BA_FUNCTIONS_MESSAGE_ONCACHEBEGIN:
80 + case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN:
81 + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN:
82 + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS:
83 + case BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE:
84 + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE:
85 + case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN:
86 + case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE:
87 + case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGECOMPLETE:
88 + case BA_FUNCTIONS_MESSAGE_ONCACHECOMPLETE:
89 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEBEGIN:
90 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGEBEGIN:
91 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPATCHTARGET:
92 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPROGRESS:
93 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEMSIMESSAGE:
94 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEFILESINUSE:
95 + case BA_FUNCTIONS_MESSAGE_ONEXECUTEPACKAGECOMPLETE:
96 + case BA_FUNCTIONS_MESSAGE_ONEXECUTECOMPLETE:
97 + case BA_FUNCTIONS_MESSAGE_ONUNREGISTERBEGIN:
98 + case BA_FUNCTIONS_MESSAGE_ONUNREGISTERCOMPLETE:
99 + case BA_FUNCTIONS_MESSAGE_ONAPPLYCOMPLETE:
100 + case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN:
101 + case BA_FUNCTIONS_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE:
102 + hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext);
103 + break;
104 + case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED:
105 + hr = BalBaseBAFunctionsProcOnThemeLoaded(pBAFunctions, reinterpret_cast<BA_FUNCTIONS_ONTHEMELOADED_ARGS*>(pvArgs), reinterpret_cast<BA_FUNCTIONS_ONTHEMELOADED_RESULTS*>(pvResults));
106 + break;
107 + case BA_FUNCTIONS_MESSAGE_WNDPROC:
108 + hr = BalBaseBAFunctionsProcWndProc(pBAFunctions, reinterpret_cast<BA_FUNCTIONS_WNDPROC_ARGS*>(pvArgs), reinterpret_cast<BA_FUNCTIONS_WNDPROC_RESULTS*>(pvResults));
109 + break;
110 + }
111 + }
112 +
113 + return hr;
114 +}
src/balutil/inc/BalBaseBootstrapperApplication.h new
+900
@@ -0,0 +1,900 @@
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 +#include <msiquery.h>
5 +
6 +#include "BootstrapperEngine.h"
7 +#include "BootstrapperApplication.h"
8 +#include "IBootstrapperEngine.h"
9 +#include "IBootstrapperApplication.h"
10 +
11 +#include "balutil.h"
12 +#include "balretry.h"
13 +
14 +class CBalBaseBootstrapperApplication : public IBootstrapperApplication
15 +{
16 +public: // IUnknown
17 + virtual STDMETHODIMP QueryInterface(
18 + __in REFIID riid,
19 + __out LPVOID *ppvObject
20 + )
21 + {
22 + if (!ppvObject)
23 + {
24 + return E_INVALIDARG;
25 + }
26 +
27 + *ppvObject = NULL;
28 +
29 + if (::IsEqualIID(__uuidof(IBootstrapperApplication), riid))
30 + {
31 + *ppvObject = static_cast<IBootstrapperApplication*>(this);
32 + }
33 + else if (::IsEqualIID(IID_IUnknown, riid))
34 + {
35 + *ppvObject = static_cast<IUnknown*>(this);
36 + }
37 + else // no interface for requested iid
38 + {
39 + return E_NOINTERFACE;
40 + }
41 +
42 + AddRef();
43 + return S_OK;
44 + }
45 +
46 + virtual STDMETHODIMP_(ULONG) AddRef()
47 + {
48 + return ::InterlockedIncrement(&this->m_cReferences);
49 + }
50 +
51 + virtual STDMETHODIMP_(ULONG) Release()
52 + {
53 + long l = ::InterlockedDecrement(&this->m_cReferences);
54 + if (0 < l)
55 + {
56 + return l;
57 + }
58 +
59 + delete this;
60 + return 0;
61 + }
62 +
63 +public: // IBootstrapperApplication
64 + virtual STDMETHODIMP OnStartup()
65 + {
66 + return S_OK;
67 + }
68 +
69 + virtual STDMETHODIMP OnShutdown(
70 + __inout BOOTSTRAPPER_SHUTDOWN_ACTION* /*pAction*/
71 + )
72 + {
73 + return S_OK;
74 + }
75 +
76 + virtual STDMETHODIMP OnSystemShutdown(
77 + __in DWORD dwEndSession,
78 + __inout BOOL* pfCancel
79 + )
80 + {
81 + HRESULT hr = S_OK;
82 +
83 + // Allow requests to shut down when critical or not applying.
84 + *pfCancel = !(ENDSESSION_CRITICAL & dwEndSession || !m_fApplying);
85 +
86 + return hr;
87 + }
88 +
89 + virtual STDMETHODIMP OnDetectBegin(
90 + __in BOOL /*fInstalled*/,
91 + __in DWORD /*cPackages*/,
92 + __inout BOOL* pfCancel
93 + )
94 + {
95 + *pfCancel |= CheckCanceled();
96 + return S_OK;
97 + }
98 +
99 + virtual STDMETHODIMP OnDetectForwardCompatibleBundle(
100 + __in_z LPCWSTR /*wzBundleId*/,
101 + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/,
102 + __in_z LPCWSTR /*wzBundleTag*/,
103 + __in BOOL /*fPerMachine*/,
104 + __in DWORD64 /*dw64Version*/,
105 + __inout BOOL* pfCancel,
106 + __inout BOOL* /*pfIgnoreBundle*/
107 + )
108 + {
109 + *pfCancel |= CheckCanceled();
110 + return S_OK;
111 + }
112 +
113 + virtual STDMETHODIMP OnDetectUpdateBegin(
114 + __in_z LPCWSTR /*wzUpdateLocation*/,
115 + __inout BOOL* pfCancel,
116 + __inout BOOL* /*pfSkip*/
117 + )
118 + {
119 + *pfCancel |= CheckCanceled();
120 + return S_OK;
121 + }
122 +
123 + virtual STDMETHODIMP OnDetectUpdate(
124 + __in_z LPCWSTR /*wzUpdateLocation*/,
125 + __in DWORD64 /*dw64Size*/,
126 + __in DWORD64 /*dw64Version*/,
127 + __in_z LPCWSTR /*wzTitle*/,
128 + __in_z LPCWSTR /*wzSummary*/,
129 + __in_z LPCWSTR /*wzContentType*/,
130 + __in_z LPCWSTR /*wzContent*/,
131 + __inout BOOL* pfCancel,
132 + __inout BOOL* /*pfStopProcessingUpdates*/
133 + )
134 + {
135 + *pfCancel |= CheckCanceled();
136 + return S_OK;
137 + }
138 +
139 + virtual STDMETHODIMP OnDetectUpdateComplete(
140 + __in HRESULT /*hrStatus*/,
141 + __inout BOOL* /*pfIgnoreError*/
142 + )
143 + {
144 + return S_OK;
145 + }
146 +
147 + virtual STDMETHODIMP OnDetectRelatedBundle(
148 + __in_z LPCWSTR /*wzBundleId*/,
149 + __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/,
150 + __in_z LPCWSTR /*wzBundleTag*/,
151 + __in BOOL /*fPerMachine*/,
152 + __in DWORD64 /*dw64Version*/,
153 + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/,
154 + __inout BOOL* pfCancel
155 + )
156 + {
157 + *pfCancel |= CheckCanceled();
158 + return S_OK;
159 + }
160 +
161 + virtual STDMETHODIMP OnDetectPackageBegin(
162 + __in_z LPCWSTR /*wzPackageId*/,
163 + __inout BOOL* pfCancel
164 + )
165 + {
166 + *pfCancel |= CheckCanceled();
167 + return S_OK;
168 + }
169 +
170 + virtual STDMETHODIMP OnDetectCompatibleMsiPackage(
171 + __in_z LPCWSTR /*wzPackageId*/,
172 + __in_z LPCWSTR /*wzCompatiblePackageId*/,
173 + __in DWORD64 /*dw64CompatiblePackageVersion*/,
174 + __inout BOOL* pfCancel
175 + )
176 + {
177 + *pfCancel |= CheckCanceled();
178 + return S_OK;
179 + }
180 +
181 + virtual STDMETHODIMP OnDetectRelatedMsiPackage(
182 + __in_z LPCWSTR /*wzPackageId*/,
183 + __in_z LPCWSTR /*wzUpgradeCode*/,
184 + __in_z LPCWSTR /*wzProductCode*/,
185 + __in BOOL /*fPerMachine*/,
186 + __in DWORD64 /*dw64Version*/,
187 + __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/,
188 + __inout BOOL* pfCancel
189 + )
190 + {
191 + *pfCancel |= CheckCanceled();
192 + return S_OK;
193 + }
194 +
195 + virtual STDMETHODIMP OnDetectTargetMsiPackage(
196 + __in_z LPCWSTR /*wzPackageId*/,
197 + __in_z LPCWSTR /*wzProductCode*/,
198 + __in BOOTSTRAPPER_PACKAGE_STATE /*patchState*/,
199 + __inout BOOL* pfCancel
200 + )
201 + {
202 + *pfCancel |= CheckCanceled();
203 + return S_OK;
204 + }
205 +
206 + virtual STDMETHODIMP OnDetectMsiFeature(
207 + __in_z LPCWSTR /*wzPackageId*/,
208 + __in_z LPCWSTR /*wzFeatureId*/,
209 + __in BOOTSTRAPPER_FEATURE_STATE /*state*/,
210 + __inout BOOL* pfCancel
211 + )
212 + {
213 + *pfCancel |= CheckCanceled();
214 + return S_OK;
215 + }
216 +
217 + virtual STDMETHODIMP OnDetectPackageComplete(
218 + __in_z LPCWSTR /*wzPackageId*/,
219 + __in HRESULT /*hrStatus*/,
220 + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/
221 + )
222 + {
223 + return S_OK;
224 + }
225 +
226 + virtual STDMETHODIMP OnDetectComplete(
227 + __in HRESULT /*hrStatus*/
228 + )
229 + {
230 + return S_OK;
231 + }
232 +
233 + virtual STDMETHODIMP OnPlanBegin(
234 + __in DWORD /*cPackages*/,
235 + __inout BOOL* pfCancel
236 + )
237 + {
238 + *pfCancel |= CheckCanceled();
239 + return S_OK;
240 + }
241 +
242 + virtual STDMETHODIMP OnPlanRelatedBundle(
243 + __in_z LPCWSTR /*wzBundleId*/,
244 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
245 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/,
246 + __inout BOOL* pfCancel
247 + )
248 + {
249 + *pfCancel |= CheckCanceled();
250 + return S_OK;
251 + }
252 +
253 + virtual STDMETHODIMP OnPlanPackageBegin(
254 + __in_z LPCWSTR /*wzPackageId*/,
255 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
256 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestState*/,
257 + __inout BOOL* pfCancel
258 + )
259 + {
260 + *pfCancel |= CheckCanceled();
261 + return S_OK;
262 + }
263 +
264 + virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin(
265 + __in_z LPCWSTR /*wzPackageId*/,
266 + __in_z LPCWSTR /*wzCompatiblePackageId*/,
267 + __in DWORD64 /*dw64CompatiblePackageVersion*/,
268 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
269 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/,
270 + __inout BOOL* pfCancel
271 + )
272 + {
273 + *pfCancel |= CheckCanceled();
274 + return S_OK;
275 + }
276 +
277 + virtual STDMETHODIMP OnPlanCompatibleMsiPackageComplete(
278 + __in_z LPCWSTR /*wzPackageId*/,
279 + __in_z LPCWSTR /*wzCompatiblePackageId*/,
280 + __in HRESULT /*hrStatus*/,
281 + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/,
282 + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/,
283 + __in BOOTSTRAPPER_ACTION_STATE /*execute*/,
284 + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/
285 + )
286 + {
287 + return S_OK;
288 + }
289 +
290 + virtual STDMETHODIMP OnPlanTargetMsiPackage(
291 + __in_z LPCWSTR /*wzPackageId*/,
292 + __in_z LPCWSTR /*wzProductCode*/,
293 + __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/,
294 + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/,
295 + __inout BOOL* pfCancel
296 + )
297 + {
298 + *pfCancel |= CheckCanceled();
299 + return S_OK;
300 + }
301 +
302 + virtual STDMETHODIMP OnPlanMsiFeature(
303 + __in_z LPCWSTR /*wzPackageId*/,
304 + __in_z LPCWSTR /*wzFeatureId*/,
305 + __in BOOTSTRAPPER_FEATURE_STATE /*recommendedState*/,
306 + __inout BOOTSTRAPPER_FEATURE_STATE* /*pRequestedState*/,
307 + __inout BOOL* pfCancel
308 + )
309 + {
310 + *pfCancel |= CheckCanceled();
311 + return S_OK;
312 + }
313 +
314 + virtual STDMETHODIMP OnPlanPackageComplete(
315 + __in_z LPCWSTR /*wzPackageId*/,
316 + __in HRESULT /*hrStatus*/,
317 + __in BOOTSTRAPPER_PACKAGE_STATE /*state*/,
318 + __in BOOTSTRAPPER_REQUEST_STATE /*requested*/,
319 + __in BOOTSTRAPPER_ACTION_STATE /*execute*/,
320 + __in BOOTSTRAPPER_ACTION_STATE /*rollback*/
321 + )
322 + {
323 + return S_OK;
324 + }
325 +
326 + virtual STDMETHODIMP OnPlanComplete(
327 + __in HRESULT /*hrStatus*/
328 + )
329 + {
330 + return S_OK;
331 + }
332 +
333 + virtual STDMETHODIMP OnApplyBegin(
334 + __in DWORD /*dwPhaseCount*/,
335 + __inout BOOL* pfCancel
336 + )
337 + {
338 + m_fApplying = TRUE;
339 +
340 + m_dwProgressPercentage = 0;
341 + m_dwOverallProgressPercentage = 0;
342 +
343 + *pfCancel |= CheckCanceled();
344 + return S_OK;
345 + }
346 +
347 + virtual STDMETHODIMP OnElevateBegin(
348 + __inout BOOL* pfCancel
349 + )
350 + {
351 + *pfCancel |= CheckCanceled();
352 + return S_OK;
353 + }
354 +
355 + virtual STDMETHODIMP OnElevateComplete(
356 + __in HRESULT /*hrStatus*/
357 + )
358 + {
359 + return S_OK;
360 + }
361 +
362 + virtual STDMETHODIMP OnProgress(
363 + __in DWORD dwProgressPercentage,
364 + __in DWORD dwOverallProgressPercentage,
365 + __inout BOOL* pfCancel
366 + )
367 + {
368 + HRESULT hr = S_OK;
369 + int nResult = IDNOACTION;
370 +
371 + m_dwProgressPercentage = dwProgressPercentage;
372 + m_dwOverallProgressPercentage = dwOverallProgressPercentage;
373 +
374 + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display)
375 + {
376 + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult);
377 + BalExitOnFailure(hr, "Failed to send embedded overall progress.");
378 +
379 + if (IDERROR == nResult)
380 + {
381 + hr = E_FAIL;
382 + }
383 + else if (IDCANCEL == nResult)
384 + {
385 + *pfCancel = TRUE;
386 + }
387 + }
388 +
389 + LExit:
390 + *pfCancel |= CheckCanceled();
391 + return hr;
392 + }
393 +
394 + virtual STDMETHODIMP OnError(
395 + __in BOOTSTRAPPER_ERROR_TYPE errorType,
396 + __in_z LPCWSTR wzPackageId,
397 + __in DWORD dwCode,
398 + __in_z LPCWSTR /*wzError*/,
399 + __in DWORD /*dwUIHint*/,
400 + __in DWORD /*cData*/,
401 + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/,
402 + __in int /*nRecommendation*/,
403 + __inout int* pResult
404 + )
405 + {
406 + BalRetryErrorOccurred(wzPackageId, dwCode);
407 +
408 + if (CheckCanceled())
409 + {
410 + *pResult = IDCANCEL;
411 + }
412 + else if (BOOTSTRAPPER_DISPLAY_FULL == m_display)
413 + {
414 + if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType)
415 + {
416 + *pResult = IDTRYAGAIN;
417 + }
418 + }
419 +
420 + return S_OK;
421 + }
422 +
423 + virtual STDMETHODIMP OnRegisterBegin(
424 + __inout BOOL* pfCancel
425 + )
426 + {
427 + *pfCancel |= CheckCanceled();
428 + return S_OK;
429 + }
430 +
431 + virtual STDMETHODIMP OnRegisterComplete(
432 + __in HRESULT /*hrStatus*/
433 + )
434 + {
435 + return S_OK;
436 + }
437 +
438 + virtual STDMETHODIMP OnCacheBegin(
439 + __inout BOOL* pfCancel
440 + )
441 + {
442 + *pfCancel |= CheckCanceled();
443 + return S_OK;
444 + }
445 +
446 + virtual STDMETHODIMP OnCachePackageBegin(
447 + __in_z LPCWSTR /*wzPackageId*/,
448 + __in DWORD /*cCachePayloads*/,
449 + __in DWORD64 /*dw64PackageCacheSize*/,
450 + __inout BOOL* pfCancel
451 + )
452 + {
453 + *pfCancel |= CheckCanceled();
454 + return S_OK;
455 + }
456 +
457 + virtual STDMETHODIMP OnCacheAcquireBegin(
458 + __in_z LPCWSTR wzPackageOrContainerId,
459 + __in_z_opt LPCWSTR wzPayloadId,
460 + __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/,
461 + __in_z LPCWSTR /*wzSource*/,
462 + __inout BOOL* pfCancel
463 + )
464 + {
465 + BalRetryStartPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId);
466 + *pfCancel |= CheckCanceled();
467 + return S_OK;
468 + }
469 +
470 + virtual STDMETHODIMP OnCacheAcquireProgress(
471 + __in_z LPCWSTR /*wzPackageOrContainerId*/,
472 + __in_z_opt LPCWSTR /*wzPayloadId*/,
473 + __in DWORD64 /*dw64Progress*/,
474 + __in DWORD64 /*dw64Total*/,
475 + __in DWORD /*dwOverallPercentage*/,
476 + __inout BOOL* pfCancel
477 + )
478 + {
479 + HRESULT hr = S_OK;
480 + int nResult = IDNOACTION;
481 +
482 + // Send progress even though we don't update the numbers to at least give the caller an opportunity
483 + // to cancel.
484 + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display)
485 + {
486 + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult);
487 + BalExitOnFailure(hr, "Failed to send embedded cache progress.");
488 +
489 + if (IDERROR == nResult)
490 + {
491 + hr = E_FAIL;
492 + }
493 + else if (IDCANCEL == nResult)
494 + {
495 + *pfCancel = TRUE;
496 + }
497 + }
498 +
499 + LExit:
500 + *pfCancel |= CheckCanceled();
501 + return hr;
502 + }
503 +
504 + virtual STDMETHODIMP OnResolveSource(
505 + __in_z LPCWSTR /*wzPackageOrContainerId*/,
506 + __in_z_opt LPCWSTR /*wzPayloadId*/,
507 + __in_z LPCWSTR /*wzLocalSource*/,
508 + __in_z_opt LPCWSTR /*wzDownloadSource*/,
509 + __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/,
510 + __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/,
511 + __inout BOOL* pfCancel
512 + )
513 + {
514 + *pfCancel |= CheckCanceled();
515 + return S_OK;
516 + }
517 +
518 + virtual STDMETHODIMP OnCacheAcquireComplete(
519 + __in_z LPCWSTR wzPackageOrContainerId,
520 + __in_z_opt LPCWSTR wzPayloadId,
521 + __in HRESULT hrStatus,
522 + __in BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION /*recommendation*/,
523 + __inout BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION* pAction
524 + )
525 + {
526 + HRESULT hr = S_OK;
527 + BOOL fRetry = FALSE;
528 +
529 + if (CheckCanceled())
530 + {
531 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT));
532 + }
533 +
534 + hr = BalRetryEndPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry);
535 + ExitOnFailure(hr, "BalRetryEndPackage for cache failed");
536 +
537 + if (fRetry)
538 + {
539 + *pAction = BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY;
540 + }
541 +
542 + LExit:
543 + return hr;
544 + }
545 +
546 + virtual STDMETHODIMP OnCacheVerifyBegin(
547 + __in_z LPCWSTR /*wzPackageId*/,
548 + __in_z LPCWSTR /*wzPayloadId*/,
549 + __inout BOOL* pfCancel
550 + )
551 + {
552 + *pfCancel |= CheckCanceled();
553 + return S_OK;
554 + }
555 +
556 + virtual STDMETHODIMP OnCacheVerifyComplete(
557 + __in_z LPCWSTR /*wzPackageId*/,
558 + __in_z LPCWSTR /*wzPayloadId*/,
559 + __in HRESULT /*hrStatus*/,
560 + __in BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION /*recommendation*/,
561 + __inout BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION* pAction
562 + )
563 + {
564 + if (CheckCanceled())
565 + {
566 + *pAction = BOOTSTRAPPER_CACHEVERIFYCOMPLETE_ACTION_NONE;
567 + }
568 +
569 + return S_OK;
570 + }
571 +
572 + virtual STDMETHODIMP OnCachePackageComplete(
573 + __in_z LPCWSTR /*wzPackageId*/,
574 + __in HRESULT /*hrStatus*/,
575 + __in BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION /*recommendation*/,
576 + __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction
577 + )
578 + {
579 + if (CheckCanceled())
580 + {
581 + *pAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE;
582 + }
583 +
584 + return S_OK;
585 + }
586 +
587 + virtual STDMETHODIMP OnCacheComplete(
588 + __in HRESULT /*hrStatus*/
589 + )
590 + {
591 + return S_OK;
592 + }
593 +
594 + virtual STDMETHODIMP OnExecuteBegin(
595 + __in DWORD /*cExecutingPackages*/,
596 + __inout BOOL* pfCancel
597 + )
598 + {
599 + *pfCancel |= CheckCanceled();
600 + return S_OK;
601 + }
602 +
603 + virtual STDMETHODIMP OnExecutePackageBegin(
604 + __in_z LPCWSTR wzPackageId,
605 + __in BOOL fExecute,
606 + __inout BOOL* pfCancel
607 + )
608 + {
609 + // Only track retry on execution (not rollback).
610 + if (fExecute)
611 + {
612 + BalRetryStartPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL);
613 + }
614 +
615 + m_fRollingBack = !fExecute;
616 + *pfCancel |= CheckCanceled();
617 + return S_OK;
618 + }
619 +
620 + virtual STDMETHODIMP OnExecutePatchTarget(
621 + __in_z LPCWSTR /*wzPackageId*/,
622 + __in_z LPCWSTR /*wzTargetProductCode*/,
623 + __inout BOOL* pfCancel
624 + )
625 + {
626 + *pfCancel |= CheckCanceled();
627 + return S_OK;
628 + }
629 +
630 + virtual STDMETHODIMP OnExecuteProgress(
631 + __in_z LPCWSTR /*wzPackageId*/,
632 + __in DWORD /*dwProgressPercentage*/,
633 + __in DWORD /*dwOverallProgressPercentage*/,
634 + __inout BOOL* pfCancel
635 + )
636 + {
637 + HRESULT hr = S_OK;
638 + int nResult = IDNOACTION;
639 +
640 + // Send progress even though we don't update the numbers to at least give the caller an opportunity
641 + // to cancel.
642 + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display)
643 + {
644 + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult);
645 + BalExitOnFailure(hr, "Failed to send embedded execute progress.");
646 +
647 + if (IDERROR == nResult)
648 + {
649 + hr = E_FAIL;
650 + }
651 + else if (IDCANCEL == nResult)
652 + {
653 + *pfCancel = TRUE;
654 + }
655 + }
656 +
657 + LExit:
658 + *pfCancel |= CheckCanceled();
659 + return hr;
660 + }
661 +
662 + virtual STDMETHODIMP OnExecuteMsiMessage(
663 + __in_z LPCWSTR /*wzPackageId*/,
664 + __in INSTALLMESSAGE /*messageType*/,
665 + __in DWORD /*dwUIHint*/,
666 + __in_z LPCWSTR /*wzMessage*/,
667 + __in DWORD /*cData*/,
668 + __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/,
669 + __in int /*nRecommendation*/,
670 + __inout int* pResult
671 + )
672 + {
673 + if (CheckCanceled())
674 + {
675 + *pResult = IDCANCEL;
676 + }
677 +
678 + return S_OK;
679 + }
680 +
681 + virtual STDMETHODIMP OnExecuteFilesInUse(
682 + __in_z LPCWSTR /*wzPackageId*/,
683 + __in DWORD /*cFiles*/,
684 + __in_ecount_z(cFiles) LPCWSTR* /*rgwzFiles*/,
685 + __in int /*nRecommendation*/,
686 + __inout int* pResult
687 + )
688 + {
689 + if (CheckCanceled())
690 + {
691 + *pResult = IDCANCEL;
692 + }
693 +
694 + return S_OK;
695 + }
696 +
697 + virtual STDMETHODIMP OnExecutePackageComplete(
698 + __in_z LPCWSTR wzPackageId,
699 + __in HRESULT hrStatus,
700 + __in BOOTSTRAPPER_APPLY_RESTART /*restart*/,
701 + __in BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION /*recommendation*/,
702 + __inout BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION* pAction
703 + )
704 + {
705 + HRESULT hr = S_OK;
706 + BOOL fRetry = FALSE;
707 +
708 + if (CheckCanceled())
709 + {
710 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT));
711 + }
712 +
713 + hr = BalRetryEndPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL, hrStatus, &fRetry);
714 + ExitOnFailure(hr, "BalRetryEndPackage for execute failed");
715 +
716 + if (fRetry)
717 + {
718 + *pAction = BOOTSTRAPPER_EXECUTEPACKAGECOMPLETE_ACTION_RETRY;
719 + }
720 +
721 + LExit:
722 + return hr;
723 + }
724 +
725 + virtual STDMETHODIMP OnExecuteComplete(
726 + __in HRESULT /*hrStatus*/
727 + )
728 + {
729 + return S_OK;
730 + }
731 +
732 + virtual STDMETHODIMP OnUnregisterBegin(
733 + __inout BOOL* pfCancel
734 + )
735 + {
736 + *pfCancel |= CheckCanceled();
737 + return S_OK;
738 + }
739 +
740 + virtual STDMETHODIMP OnUnregisterComplete(
741 + __in HRESULT /*hrStatus*/
742 + )
743 + {
744 + return S_OK;
745 + }
746 +
747 + virtual STDMETHODIMP OnApplyComplete(
748 + __in HRESULT /*hrStatus*/,
749 + __in BOOTSTRAPPER_APPLY_RESTART restart,
750 + __in BOOTSTRAPPER_APPLYCOMPLETE_ACTION /*recommendation*/,
751 + __inout BOOTSTRAPPER_APPLYCOMPLETE_ACTION* pAction
752 + )
753 + {
754 + HRESULT hr = S_OK;
755 + BOOL fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_REQUIRED == restart;
756 + BOOL fShouldBlockRestart = BOOTSTRAPPER_DISPLAY_FULL <= m_display && BOOTSTRAPPER_RESTART_PROMPT >= m_restart;
757 +
758 + if (fRestartRequired && !fShouldBlockRestart)
759 + {
760 + *pAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_RESTART;
761 + }
762 +
763 + m_fApplying = FALSE;
764 +
765 + return hr;
766 + }
767 +
768 + virtual STDMETHODIMP OnLaunchApprovedExeBegin(
769 + __inout BOOL* pfCancel
770 + )
771 + {
772 + *pfCancel |= CheckCanceled();
773 + return S_OK;
774 + }
775 +
776 + virtual STDMETHODIMP OnLaunchApprovedExeComplete(
777 + __in HRESULT /*hrStatus*/,
778 + __in DWORD /*dwProcessId*/
779 + )
780 + {
781 + return S_OK;
782 + }
783 +
784 + virtual STDMETHODIMP_(HRESULT) BAProc(
785 + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/,
786 + __in const LPVOID /*pvArgs*/,
787 + __inout LPVOID /*pvResults*/,
788 + __in_opt LPVOID /*pvContext*/
789 + )
790 + {
791 + return E_NOTIMPL;
792 + }
793 +
794 + virtual STDMETHODIMP_(void) BAProcFallback(
795 + __in BOOTSTRAPPER_APPLICATION_MESSAGE /*message*/,
796 + __in const LPVOID /*pvArgs*/,
797 + __inout LPVOID /*pvResults*/,
798 + __inout HRESULT* /*phr*/,
799 + __in_opt LPVOID /*pvContext*/
800 + )
801 + {
802 + }
803 +
804 +protected:
805 + //
806 + // PromptCancel - prompts the user to close (if not forced).
807 + //
808 + virtual BOOL PromptCancel(
809 + __in HWND hWnd,
810 + __in BOOL fForceCancel,
811 + __in_z_opt LPCWSTR wzMessage,
812 + __in_z_opt LPCWSTR wzCaption
813 + )
814 + {
815 + ::EnterCriticalSection(&m_csCanceled);
816 +
817 + // Only prompt the user to close if we have not canceled already.
818 + if (!m_fCanceled)
819 + {
820 + if (fForceCancel)
821 + {
822 + m_fCanceled = TRUE;
823 + }
824 + else
825 + {
826 + m_fCanceled = (IDYES == ::MessageBoxW(hWnd, wzMessage, wzCaption, MB_YESNO | MB_ICONEXCLAMATION));
827 + }
828 + }
829 +
830 + ::LeaveCriticalSection(&m_csCanceled);
831 +
832 + return m_fCanceled;
833 + }
834 +
835 + //
836 + // CheckCanceled - waits if the cancel dialog is up and checks to see if the user canceled the operation.
837 + //
838 + BOOL CheckCanceled()
839 + {
840 + ::EnterCriticalSection(&m_csCanceled);
841 + ::LeaveCriticalSection(&m_csCanceled);
842 + return m_fRollingBack ? FALSE : m_fCanceled;
843 + }
844 +
845 + BOOL IsRollingBack()
846 + {
847 + return m_fRollingBack;
848 + }
849 +
850 + BOOL IsCanceled()
851 + {
852 + return m_fCanceled;
853 + }
854 +
855 + CBalBaseBootstrapperApplication(
856 + __in IBootstrapperEngine* pEngine,
857 + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
858 + __in DWORD dwRetryCount = 0,
859 + __in DWORD dwRetryTimeout = 1000
860 + )
861 + {
862 + m_cReferences = 1;
863 + m_display = pArgs->pCommand->display;
864 + m_restart = pArgs->pCommand->restart;
865 +
866 + pEngine->AddRef();
867 + m_pEngine = pEngine;
868 +
869 + ::InitializeCriticalSection(&m_csCanceled);
870 + m_fCanceled = FALSE;
871 + m_fApplying = FALSE;
872 + m_fRollingBack = FALSE;
873 +
874 + BalRetryInitialize(dwRetryCount, dwRetryTimeout);
875 + }
876 +
877 + virtual ~CBalBaseBootstrapperApplication()
878 + {
879 + BalRetryUninitialize();
880 + ::DeleteCriticalSection(&m_csCanceled);
881 +
882 + ReleaseNullObject(m_pEngine);
883 + }
884 +
885 +protected:
886 + CRITICAL_SECTION m_csCanceled;
887 + BOOL m_fCanceled;
888 +
889 +private:
890 + long m_cReferences;
891 + BOOTSTRAPPER_DISPLAY m_display;
892 + BOOTSTRAPPER_RESTART m_restart;
893 + IBootstrapperEngine* m_pEngine;
894 +
895 + BOOL m_fApplying;
896 + BOOL m_fRollingBack;
897 +
898 + DWORD m_dwProgressPercentage;
899 + DWORD m_dwOverallProgressPercentage;
900 +};
src/balutil/inc/BalBaseBootstrapperApplicationProc.h new
+698
@@ -0,0 +1,698 @@
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 "BootstrapperEngine.h"
8 +#include "BootstrapperApplication.h"
9 +#include "IBootstrapperEngine.h"
10 +#include "IBootstrapperApplication.h"
11 +
12 +static HRESULT BalBaseBAProcOnDetectBegin(
13 + __in IBootstrapperApplication* pBA,
14 + __in BA_ONDETECTBEGIN_ARGS* pArgs,
15 + __inout BA_ONDETECTBEGIN_RESULTS* pResults
16 + )
17 +{
18 + return pBA->OnDetectBegin(pArgs->fInstalled, pArgs->cPackages, &pResults->fCancel);
19 +}
20 +
21 +static HRESULT BalBaseBAProcOnDetectComplete(
22 + __in IBootstrapperApplication* pBA,
23 + __in BA_ONDETECTCOMPLETE_ARGS* pArgs,
24 + __inout BA_ONDETECTCOMPLETE_RESULTS* /*pResults*/
25 + )
26 +{
27 + return pBA->OnDetectComplete(pArgs->hrStatus);
28 +}
29 +
30 +static HRESULT BalBaseBAProcOnPlanBegin(
31 + __in IBootstrapperApplication* pBA,
32 + __in BA_ONPLANBEGIN_ARGS* pArgs,
33 + __inout BA_ONPLANBEGIN_RESULTS* pResults
34 + )
35 +{
36 + return pBA->OnPlanBegin(pArgs->cPackages, &pResults->fCancel);
37 +}
38 +
39 +static HRESULT BalBaseBAProcOnPlanComplete(
40 + __in IBootstrapperApplication* pBA,
41 + __in BA_ONPLANCOMPLETE_ARGS* pArgs,
42 + __inout BA_ONPLANCOMPLETE_RESULTS* /*pResults*/
43 + )
44 +{
45 + return pBA->OnPlanComplete(pArgs->hrStatus);
46 +}
47 +
48 +static HRESULT BalBaseBAProcOnStartup(
49 + __in IBootstrapperApplication* pBA,
50 + __in BA_ONSTARTUP_ARGS* /*pArgs*/,
51 + __inout BA_ONSTARTUP_RESULTS* /*pResults*/
52 + )
53 +{
54 + return pBA->OnStartup();
55 +}
56 +
57 +static HRESULT BalBaseBAProcOnShutdown(
58 + __in IBootstrapperApplication* pBA,
59 + __in BA_ONSHUTDOWN_ARGS* /*pArgs*/,
60 + __inout BA_ONSHUTDOWN_RESULTS* pResults
61 + )
62 +{
63 + return pBA->OnShutdown(&pResults->action);
64 +}
65 +
66 +static HRESULT BalBaseBAProcOnSystemShutdown(
67 + __in IBootstrapperApplication* pBA,
68 + __in BA_ONSYSTEMSHUTDOWN_ARGS* pArgs,
69 + __inout BA_ONSYSTEMSHUTDOWN_RESULTS* pResults
70 + )
71 +{
72 + return pBA->OnSystemShutdown(pArgs->dwEndSession, &pResults->fCancel);
73 +}
74 +
75 +static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle(
76 + __in IBootstrapperApplication* pBA,
77 + __in BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS* pArgs,
78 + __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults
79 + )
80 +{
81 + return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, &pResults->fCancel, &pResults->fIgnoreBundle);
82 +}
83 +
84 +static HRESULT BalBaseBAProcOnDetectUpdateBegin(
85 + __in IBootstrapperApplication* pBA,
86 + __in BA_ONDETECTUPDATEBEGIN_ARGS* pArgs,
87 + __inout BA_ONDETECTUPDATEBEGIN_RESULTS* pResults
88 + )
89 +{
90 + return pBA->OnDetectUpdateBegin(pArgs->wzUpdateLocation, &pResults->fCancel, &pResults->fSkip);
91 +}
92 +
93 +static HRESULT BalBaseBAProcOnDetectUpdate(
94 + __in IBootstrapperApplication* pBA,
95 + __in BA_ONDETECTUPDATE_ARGS* pArgs,
96 + __inout BA_ONDETECTUPDATE_RESULTS* pResults
97 + )
98 +{
99 + return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->dw64Version, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates);
100 +}
101 +
102 +static HRESULT BalBaseBAProcOnDetectUpdateComplete(
103 + __in IBootstrapperApplication* pBA,
104 + __in BA_ONDETECTUPDATECOMPLETE_ARGS* pArgs,
105 + __inout BA_ONDETECTUPDATECOMPLETE_RESULTS* pResults
106 + )
107 +{
108 + return pBA->OnDetectUpdateComplete(pArgs->hrStatus, &pResults->fIgnoreError);
109 +}
110 +
111 +static HRESULT BalBaseBAProcOnDetectRelatedBundle(
112 + __in IBootstrapperApplication* pBA,
113 + __in BA_ONDETECTRELATEDBUNDLE_ARGS* pArgs,
114 + __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults
115 + )
116 +{
117 + return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, pArgs->operation, &pResults->fCancel);
118 +}
119 +
120 +static HRESULT BalBaseBAProcOnDetectPackageBegin(
121 + __in IBootstrapperApplication* pBA,
122 + __in BA_ONDETECTPACKAGEBEGIN_ARGS* pArgs,
123 + __inout BA_ONDETECTPACKAGEBEGIN_RESULTS* pResults
124 + )
125 +{
126 + return pBA->OnDetectPackageBegin(pArgs->wzPackageId, &pResults->fCancel);
127 +}
128 +
129 +static HRESULT BalBaseBAProcOnDetectCompatiblePackage(
130 + __in IBootstrapperApplication* pBA,
131 + __in BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS* pArgs,
132 + __inout BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS* pResults
133 + )
134 +{
135 + return pBA->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->dw64CompatiblePackageVersion, &pResults->fCancel);
136 +}
137 +
138 +static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage(
139 + __in IBootstrapperApplication* pBA,
140 + __in BA_ONDETECTRELATEDMSIPACKAGE_ARGS* pArgs,
141 + __inout BA_ONDETECTRELATEDMSIPACKAGE_RESULTS* pResults
142 + )
143 +{
144 + return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->dw64Version, pArgs->operation, &pResults->fCancel);
145 +}
146 +
147 +static HRESULT BalBaseBAProcOnDetectTargetMsiPackage(
148 + __in IBootstrapperApplication* pBA,
149 + __in BA_ONDETECTTARGETMSIPACKAGE_ARGS* pArgs,
150 + __inout BA_ONDETECTTARGETMSIPACKAGE_RESULTS* pResults
151 + )
152 +{
153 + return pBA->OnDetectTargetMsiPackage(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->patchState, &pResults->fCancel);
154 +}
155 +
156 +static HRESULT BalBaseBAProcOnDetectMsiFeature(
157 + __in IBootstrapperApplication* pBA,
158 + __in BA_ONDETECTMSIFEATURE_ARGS* pArgs,
159 + __inout BA_ONDETECTMSIFEATURE_RESULTS* pResults
160 + )
161 +{
162 + return pBA->OnDetectMsiFeature(pArgs->wzPackageId, pArgs->wzFeatureId, pArgs->state, &pResults->fCancel);
163 +}
164 +
165 +static HRESULT BalBaseBAProcOnDetectPackageComplete(
166 + __in IBootstrapperApplication* pBA,
167 + __in BA_ONDETECTPACKAGECOMPLETE_ARGS* pArgs,
168 + __inout BA_ONDETECTPACKAGECOMPLETE_RESULTS* /*pResults*/
169 + )
170 +{
171 + return pBA->OnDetectPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state);
172 +}
173 +
174 +static HRESULT BalBaseBAProcOnPlanRelatedBundle(
175 + __in IBootstrapperApplication* pBA,
176 + __in BA_ONPLANRELATEDBUNDLE_ARGS* pArgs,
177 + __inout BA_ONPLANRELATEDBUNDLE_RESULTS* pResults
178 + )
179 +{
180 + return pBA->OnPlanRelatedBundle(pArgs->wzBundleId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel);
181 +}
182 +
183 +static HRESULT BalBaseBAProcOnPlanPackageBegin(
184 + __in IBootstrapperApplication* pBA,
185 + __in BA_ONPLANPACKAGEBEGIN_ARGS* pArgs,
186 + __inout BA_ONPLANPACKAGEBEGIN_RESULTS* pResults
187 + )
188 +{
189 + return pBA->OnPlanPackageBegin(pArgs->wzPackageId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel);
190 +}
191 +
192 +static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageBegin(
193 + __in IBootstrapperApplication* pBA,
194 + __in BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS* pArgs,
195 + __inout BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS* pResults
196 + )
197 +{
198 + return pBA->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->dw64CompatiblePackageVersion, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel);
199 +}
200 +
201 +static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageComplete(
202 + __in IBootstrapperApplication* pBA,
203 + __in BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS* pArgs,
204 + __inout BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS* /*pResults*/
205 + )
206 +{
207 + return pBA->OnPlanCompatibleMsiPackageComplete(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->hrStatus, pArgs->state, pArgs->requested, pArgs->execute, pArgs->rollback);
208 +}
209 +
210 +static HRESULT BalBaseBAProcOnPlanTargetMsiPackage(
211 + __in IBootstrapperApplication* pBA,
212 + __in BA_ONPLANTARGETMSIPACKAGE_ARGS* pArgs,
213 + __inout BA_ONPLANTARGETMSIPACKAGE_RESULTS* pResults
214 + )
215 +{
216 + return pBA->OnPlanTargetMsiPackage(pArgs->wzPackageId, pArgs->wzProductCode, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel);
217 +}
218 +
219 +static HRESULT BalBaseBAProcOnPlanMsiFeature(
220 + __in IBootstrapperApplication* pBA,
221 + __in BA_ONPLANMSIFEATURE_ARGS* pArgs,
222 + __inout BA_ONPLANMSIFEATURE_RESULTS* pResults
223 + )
224 +{
225 + return pBA->OnPlanMsiFeature(pArgs->wzPackageId, pArgs->wzFeatureId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel);
226 +}
227 +
228 +static HRESULT BalBaseBAProcOnPlanPackageComplete(
229 + __in IBootstrapperApplication* pBA,
230 + __in BA_ONPLANPACKAGECOMPLETE_ARGS* pArgs,
231 + __inout BA_ONPLANPACKAGECOMPLETE_RESULTS* /*pResults*/
232 + )
233 +{
234 + return pBA->OnPlanPackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->state, pArgs->requested, pArgs->execute, pArgs->rollback);
235 +}
236 +
237 +static HRESULT BalBaseBAProcOnApplyBegin(
238 + __in IBootstrapperApplication* pBA,
239 + __in BA_ONAPPLYBEGIN_ARGS* pArgs,
240 + __inout BA_ONAPPLYBEGIN_RESULTS* pResults
241 + )
242 +{
243 + return pBA->OnApplyBegin(pArgs->dwPhaseCount, &pResults->fCancel);
244 +}
245 +
246 +static HRESULT BalBaseBAProcOnElevateBegin(
247 + __in IBootstrapperApplication* pBA,
248 + __in BA_ONELEVATEBEGIN_ARGS* /*pArgs*/,
249 + __inout BA_ONELEVATEBEGIN_RESULTS* pResults
250 + )
251 +{
252 + return pBA->OnElevateBegin(&pResults->fCancel);
253 +}
254 +
255 +static HRESULT BalBaseBAProcOnElevateComplete(
256 + __in IBootstrapperApplication* pBA,
257 + __in BA_ONELEVATECOMPLETE_ARGS* pArgs,
258 + __inout BA_ONELEVATECOMPLETE_RESULTS* /*pResults*/
259 + )
260 +{
261 + return pBA->OnElevateComplete(pArgs->hrStatus);
262 +}
263 +
264 +static HRESULT BalBaseBAProcOnProgress(
265 + __in IBootstrapperApplication* pBA,
266 + __in BA_ONPROGRESS_ARGS* pArgs,
267 + __inout BA_ONPROGRESS_RESULTS* pResults
268 + )
269 +{
270 + return pBA->OnProgress(pArgs->dwProgressPercentage, pArgs->dwOverallPercentage, &pResults->fCancel);
271 +}
272 +
273 +static HRESULT BalBaseBAProcOnError(
274 + __in IBootstrapperApplication* pBA,
275 + __in BA_ONERROR_ARGS* pArgs,
276 + __inout BA_ONERROR_RESULTS* pResults
277 + )
278 +{
279 + return pBA->OnError(pArgs->errorType, pArgs->wzPackageId, pArgs->dwCode, pArgs->wzError, pArgs->dwUIHint, pArgs->cData, pArgs->rgwzData, pArgs->nRecommendation, &pResults->nResult);
280 +}
281 +
282 +static HRESULT BalBaseBAProcOnRegisterBegin(
283 + __in IBootstrapperApplication* pBA,
284 + __in BA_ONREGISTERBEGIN_ARGS* /*pArgs*/,
285 + __inout BA_ONREGISTERBEGIN_RESULTS* pResults
286 + )
287 +{
288 + return pBA->OnRegisterBegin(&pResults->fCancel);
289 +}
290 +
291 +static HRESULT BalBaseBAProcOnRegisterComplete(
292 + __in IBootstrapperApplication* pBA,
293 + __in BA_ONREGISTERCOMPLETE_ARGS* pArgs,
294 + __inout BA_ONREGISTERCOMPLETE_RESULTS* /*pResults*/
295 + )
296 +{
297 + return pBA->OnRegisterComplete(pArgs->hrStatus);
298 +}
299 +
300 +static HRESULT BalBaseBAProcOnCacheBegin(
301 + __in IBootstrapperApplication* pBA,
302 + __in BA_ONCACHEBEGIN_ARGS* /*pArgs*/,
303 + __inout BA_ONCACHEBEGIN_RESULTS* pResults
304 + )
305 +{
306 + return pBA->OnCacheBegin(&pResults->fCancel);
307 +}
308 +
309 +static HRESULT BalBaseBAProcOnCachePackageBegin(
310 + __in IBootstrapperApplication* pBA,
311 + __in BA_ONCACHEPACKAGEBEGIN_ARGS* pArgs,
312 + __inout BA_ONCACHEPACKAGEBEGIN_RESULTS* pResults
313 + )
314 +{
315 + return pBA->OnCachePackageBegin(pArgs->wzPackageId, pArgs->cCachePayloads, pArgs->dw64PackageCacheSize, &pResults->fCancel);
316 +}
317 +
318 +static HRESULT BalBaseBAProcOnCacheAcquireBegin(
319 + __in IBootstrapperApplication* pBA,
320 + __in BA_ONCACHEACQUIREBEGIN_ARGS* pArgs,
321 + __inout BA_ONCACHEACQUIREBEGIN_RESULTS* pResults
322 + )
323 +{
324 + return pBA->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->operation, pArgs->wzSource, &pResults->fCancel);
325 +}
326 +
327 +static HRESULT BalBaseBAProcOnCacheAcquireProgress(
328 + __in IBootstrapperApplication* pBA,
329 + __in BA_ONCACHEACQUIREPROGRESS_ARGS* pArgs,
330 + __inout BA_ONCACHEACQUIREPROGRESS_RESULTS* pResults
331 + )
332 +{
333 + return pBA->OnCacheAcquireProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel);
334 +}
335 +
336 +static HRESULT BalBaseBAProcOnResolveSource(
337 + __in IBootstrapperApplication* pBA,
338 + __in BA_ONRESOLVESOURCE_ARGS* pArgs,
339 + __inout BA_ONRESOLVESOURCE_RESULTS* pResults
340 + )
341 +{
342 + return pBA->OnResolveSource(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->recommendation, &pResults->action, &pResults->fCancel);
343 +}
344 +
345 +static HRESULT BalBaseBAProcOnCacheAcquireComplete(
346 + __in IBootstrapperApplication* pBA,
347 + __in BA_ONCACHEACQUIRECOMPLETE_ARGS* pArgs,
348 + __inout BA_ONCACHEACQUIRECOMPLETE_RESULTS* pResults
349 + )
350 +{
351 + return pBA->OnCacheAcquireComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus, pArgs->recommendation, &pResults->action);
352 +}
353 +
354 +static HRESULT BalBaseBAProcOnCacheVerifyBegin(
355 + __in IBootstrapperApplication* pBA,
356 + __in BA_ONCACHEVERIFYBEGIN_ARGS* pArgs,
357 + __inout BA_ONCACHEVERIFYBEGIN_RESULTS* pResults
358 + )
359 +{
360 + return pBA->OnCacheVerifyBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, &pResults->fCancel);
361 +}
362 +
363 +static HRESULT BalBaseBAProcOnCacheVerifyComplete(
364 + __in IBootstrapperApplication* pBA,
365 + __in BA_ONCACHEVERIFYCOMPLETE_ARGS* pArgs,
366 + __inout BA_ONCACHEVERIFYCOMPLETE_RESULTS* pResults
367 + )
368 +{
369 + return pBA->OnCacheVerifyComplete(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->hrStatus, pArgs->recommendation, &pResults->action);
370 +}
371 +
372 +static HRESULT BalBaseBAProcOnCachePackageComplete(
373 + __in IBootstrapperApplication* pBA,
374 + __in BA_ONCACHEPACKAGECOMPLETE_ARGS* pArgs,
375 + __inout BA_ONCACHEPACKAGECOMPLETE_RESULTS* pResults
376 + )
377 +{
378 + return pBA->OnCachePackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->recommendation, &pResults->action);
379 +}
380 +
381 +static HRESULT BalBaseBAProcOnCacheComplete(
382 + __in IBootstrapperApplication* pBA,
383 + __in BA_ONCACHECOMPLETE_ARGS* pArgs,
384 + __inout BA_ONCACHECOMPLETE_RESULTS* /*pResults*/
385 + )
386 +{
387 + return pBA->OnCacheComplete(pArgs->hrStatus);
388 +}
389 +
390 +static HRESULT BalBaseBAProcOnExecuteBegin(
391 + __in IBootstrapperApplication* pBA,
392 + __in BA_ONEXECUTEBEGIN_ARGS* pArgs,
393 + __inout BA_ONEXECUTEBEGIN_RESULTS* pResults
394 + )
395 +{
396 + return pBA->OnExecuteBegin(pArgs->cExecutingPackages, &pResults->fCancel);
397 +}
398 +
399 +static HRESULT BalBaseBAProcOnExecutePackageBegin(
400 + __in IBootstrapperApplication* pBA,
401 + __in BA_ONEXECUTEPACKAGEBEGIN_ARGS* pArgs,
402 + __inout BA_ONEXECUTEPACKAGEBEGIN_RESULTS* pResults
403 + )
404 +{
405 + return pBA->OnExecutePackageBegin(pArgs->wzPackageId, pArgs->fExecute, &pResults->fCancel);
406 +}
407 +
408 +static HRESULT BalBaseBAProcOnExecutePatchTarget(
409 + __in IBootstrapperApplication* pBA,
410 + __in BA_ONEXECUTEPATCHTARGET_ARGS* pArgs,
411 + __inout BA_ONEXECUTEPATCHTARGET_RESULTS* pResults
412 + )
413 +{
414 + return pBA->OnExecutePatchTarget(pArgs->wzPackageId, pArgs->wzTargetProductCode, &pResults->fCancel);
415 +}
416 +
417 +static HRESULT BalBaseBAProcOnExecuteProgress(
418 + __in IBootstrapperApplication* pBA,
419 + __in BA_ONEXECUTEPROGRESS_ARGS* pArgs,
420 + __inout BA_ONEXECUTEPROGRESS_RESULTS* pResults
421 + )
422 +{
423 + return pBA->OnExecuteProgress(pArgs->wzPackageId, pArgs->dwProgressPercentage, pArgs->dwOverallPercentage, &pResults->fCancel);
424 +}
425 +
426 +static HRESULT BalBaseBAProcOnExecuteMsiMessage(
427 + __in IBootstrapperApplication* pBA,
428 + __in BA_ONEXECUTEMSIMESSAGE_ARGS* pArgs,
429 + __inout BA_ONEXECUTEMSIMESSAGE_RESULTS* pResults
430 + )
431 +{
432 + return pBA->OnExecuteMsiMessage(pArgs->wzPackageId, pArgs->messageType, pArgs->dwUIHint, pArgs->wzMessage, pArgs->cData, pArgs->rgwzData, pArgs->nRecommendation, &pResults->nResult);
433 +}
434 +
435 +static HRESULT BalBaseBAProcOnExecuteFilesInUse(
436 + __in IBootstrapperApplication* pBA,
437 + __in BA_ONEXECUTEFILESINUSE_ARGS* pArgs,
438 + __inout BA_ONEXECUTEFILESINUSE_RESULTS* pResults
439 + )
440 +{
441 + return pBA->OnExecuteFilesInUse(pArgs->wzPackageId, pArgs->cFiles, pArgs->rgwzFiles, pArgs->nRecommendation, &pResults->nResult);
442 +}
443 +
444 +static HRESULT BalBaseBAProcOnExecutePackageComplete(
445 + __in IBootstrapperApplication* pBA,
446 + __in BA_ONEXECUTEPACKAGECOMPLETE_ARGS* pArgs,
447 + __inout BA_ONEXECUTEPACKAGECOMPLETE_RESULTS* pResults
448 + )
449 +{
450 + return pBA->OnExecutePackageComplete(pArgs->wzPackageId, pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action);
451 +}
452 +
453 +static HRESULT BalBaseBAProcOnExecuteComplete(
454 + __in IBootstrapperApplication* pBA,
455 + __in BA_ONEXECUTECOMPLETE_ARGS* pArgs,
456 + __inout BA_ONEXECUTECOMPLETE_RESULTS* /*pResults*/
457 + )
458 +{
459 + return pBA->OnExecuteComplete(pArgs->hrStatus);
460 +}
461 +
462 +static HRESULT BalBaseBAProcOnUnregisterBegin(
463 + __in IBootstrapperApplication* pBA,
464 + __in BA_ONUNREGISTERBEGIN_ARGS* /*pArgs*/,
465 + __inout BA_ONUNREGISTERBEGIN_RESULTS* pResults
466 + )
467 +{
468 + return pBA->OnUnregisterBegin(&pResults->fCancel);
469 +}
470 +
471 +static HRESULT BalBaseBAProcOnUnregisterComplete(
472 + __in IBootstrapperApplication* pBA,
473 + __in BA_ONUNREGISTERCOMPLETE_ARGS* pArgs,
474 + __inout BA_ONUNREGISTERCOMPLETE_RESULTS* /*pResults*/
475 + )
476 +{
477 + return pBA->OnUnregisterComplete(pArgs->hrStatus);
478 +}
479 +
480 +static HRESULT BalBaseBAProcOnApplyComplete(
481 + __in IBootstrapperApplication* pBA,
482 + __in BA_ONAPPLYCOMPLETE_ARGS* pArgs,
483 + __inout BA_ONAPPLYCOMPLETE_RESULTS* pResults
484 + )
485 +{
486 + return pBA->OnApplyComplete(pArgs->hrStatus, pArgs->restart, pArgs->recommendation, &pResults->action);
487 +}
488 +
489 +static HRESULT BalBaseBAProcOnLaunchApprovedExeBegin(
490 + __in IBootstrapperApplication* pBA,
491 + __in BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS* /*pArgs*/,
492 + __inout BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS* pResults
493 + )
494 +{
495 + return pBA->OnLaunchApprovedExeBegin(&pResults->fCancel);
496 +}
497 +
498 +static HRESULT BalBaseBAProcOnLaunchApprovedExeComplete(
499 + __in IBootstrapperApplication* pBA,
500 + __in BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS* pArgs,
501 + __inout BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS* /*pResults*/
502 + )
503 +{
504 + return pBA->OnLaunchApprovedExeComplete(pArgs->hrStatus, pArgs->dwProcessId);
505 +}
506 +
507 +/*******************************************************************
508 +BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication.
509 + Provides a default mapping between the new message based BA interface and
510 + the old COM-based BA interface.
511 +
512 +*******************************************************************/
513 +static HRESULT WINAPI BalBaseBootstrapperApplicationProc(
514 + __in BOOTSTRAPPER_APPLICATION_MESSAGE message,
515 + __in const LPVOID pvArgs,
516 + __inout LPVOID pvResults,
517 + __in_opt LPVOID pvContext
518 + )
519 +{
520 + IBootstrapperApplication* pBA = reinterpret_cast<IBootstrapperApplication*>(pvContext);
521 + HRESULT hr = pBA->BAProc(message, pvArgs, pvResults, pvContext);
522 +
523 + if (E_NOTIMPL == hr)
524 + {
525 + switch (message)
526 + {
527 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN:
528 + hr = BalBaseBAProcOnDetectBegin(pBA, reinterpret_cast<BA_ONDETECTBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTBEGIN_RESULTS*>(pvResults));
529 + break;
530 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE:
531 + hr = BalBaseBAProcOnDetectComplete(pBA, reinterpret_cast<BA_ONDETECTCOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTCOMPLETE_RESULTS*>(pvResults));
532 + break;
533 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN:
534 + hr = BalBaseBAProcOnPlanBegin(pBA, reinterpret_cast<BA_ONPLANBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANBEGIN_RESULTS*>(pvResults));
535 + break;
536 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE:
537 + hr = BalBaseBAProcOnPlanComplete(pBA, reinterpret_cast<BA_ONPLANCOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANCOMPLETE_RESULTS*>(pvResults));
538 + break;
539 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP:
540 + hr = BalBaseBAProcOnStartup(pBA, reinterpret_cast<BA_ONSTARTUP_ARGS*>(pvArgs), reinterpret_cast<BA_ONSTARTUP_RESULTS*>(pvResults));
541 + break;
542 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN:
543 + hr = BalBaseBAProcOnShutdown(pBA, reinterpret_cast<BA_ONSHUTDOWN_ARGS*>(pvArgs), reinterpret_cast<BA_ONSHUTDOWN_RESULTS*>(pvResults));
544 + break;
545 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN:
546 + hr = BalBaseBAProcOnSystemShutdown(pBA, reinterpret_cast<BA_ONSYSTEMSHUTDOWN_ARGS*>(pvArgs), reinterpret_cast<BA_ONSYSTEMSHUTDOWN_RESULTS*>(pvResults));
547 + break;
548 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE:
549 + hr = BalBaseBAProcOnDetectForwardCompatibleBundle(pBA, reinterpret_cast<BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS*>(pvResults));
550 + break;
551 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN:
552 + hr = BalBaseBAProcOnDetectUpdateBegin(pBA, reinterpret_cast<BA_ONDETECTUPDATEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATEBEGIN_RESULTS*>(pvResults));
553 + break;
554 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE:
555 + hr = BalBaseBAProcOnDetectUpdate(pBA, reinterpret_cast<BA_ONDETECTUPDATE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATE_RESULTS*>(pvResults));
556 + break;
557 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE:
558 + hr = BalBaseBAProcOnDetectUpdateComplete(pBA, reinterpret_cast<BA_ONDETECTUPDATECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATECOMPLETE_RESULTS*>(pvResults));
559 + break;
560 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE:
561 + hr = BalBaseBAProcOnDetectRelatedBundle(pBA, reinterpret_cast<BA_ONDETECTRELATEDBUNDLE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTRELATEDBUNDLE_RESULTS*>(pvResults));
562 + break;
563 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN:
564 + hr = BalBaseBAProcOnDetectPackageBegin(pBA, reinterpret_cast<BA_ONDETECTPACKAGEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTPACKAGEBEGIN_RESULTS*>(pvResults));
565 + break;
566 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE:
567 + hr = BalBaseBAProcOnDetectCompatiblePackage(pBA, reinterpret_cast<BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS*>(pvResults));
568 + break;
569 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE:
570 + hr = BalBaseBAProcOnDetectRelatedMsiPackage(pBA, reinterpret_cast<BA_ONDETECTRELATEDMSIPACKAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTRELATEDMSIPACKAGE_RESULTS*>(pvResults));
571 + break;
572 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTTARGETMSIPACKAGE:
573 + hr = BalBaseBAProcOnDetectTargetMsiPackage(pBA, reinterpret_cast<BA_ONDETECTTARGETMSIPACKAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTTARGETMSIPACKAGE_RESULTS*>(pvResults));
574 + break;
575 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE:
576 + hr = BalBaseBAProcOnDetectMsiFeature(pBA, reinterpret_cast<BA_ONDETECTMSIFEATURE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTMSIFEATURE_RESULTS*>(pvResults));
577 + break;
578 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE:
579 + hr = BalBaseBAProcOnDetectPackageComplete(pBA, reinterpret_cast<BA_ONDETECTPACKAGECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTPACKAGECOMPLETE_RESULTS*>(pvResults));
580 + break;
581 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE:
582 + hr = BalBaseBAProcOnPlanRelatedBundle(pBA, reinterpret_cast<BA_ONPLANRELATEDBUNDLE_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANRELATEDBUNDLE_RESULTS*>(pvResults));
583 + break;
584 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN:
585 + hr = BalBaseBAProcOnPlanPackageBegin(pBA, reinterpret_cast<BA_ONPLANPACKAGEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANPACKAGEBEGIN_RESULTS*>(pvResults));
586 + break;
587 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN:
588 + hr = BalBaseBAProcOnPlanCompatibleMsiPackageBegin(pBA, reinterpret_cast<BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS*>(pvResults));
589 + break;
590 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE:
591 + hr = BalBaseBAProcOnPlanCompatibleMsiPackageComplete(pBA, reinterpret_cast<BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS*>(pvResults));
592 + break;
593 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANTARGETMSIPACKAGE:
594 + hr = BalBaseBAProcOnPlanTargetMsiPackage(pBA, reinterpret_cast<BA_ONPLANTARGETMSIPACKAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANTARGETMSIPACKAGE_RESULTS*>(pvResults));
595 + break;
596 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE:
597 + hr = BalBaseBAProcOnPlanMsiFeature(pBA, reinterpret_cast<BA_ONPLANMSIFEATURE_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANMSIFEATURE_RESULTS*>(pvResults));
598 + break;
599 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE:
600 + hr = BalBaseBAProcOnPlanPackageComplete(pBA, reinterpret_cast<BA_ONPLANPACKAGECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANPACKAGECOMPLETE_RESULTS*>(pvResults));
601 + break;
602 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN:
603 + hr = BalBaseBAProcOnApplyBegin(pBA, reinterpret_cast<BA_ONAPPLYBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONAPPLYBEGIN_RESULTS*>(pvResults));
604 + break;
605 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN:
606 + hr = BalBaseBAProcOnElevateBegin(pBA, reinterpret_cast<BA_ONELEVATEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONELEVATEBEGIN_RESULTS*>(pvResults));
607 + break;
608 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE:
609 + hr = BalBaseBAProcOnElevateComplete(pBA, reinterpret_cast<BA_ONELEVATECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONELEVATECOMPLETE_RESULTS*>(pvResults));
610 + break;
611 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS:
612 + hr = BalBaseBAProcOnProgress(pBA, reinterpret_cast<BA_ONPROGRESS_ARGS*>(pvArgs), reinterpret_cast<BA_ONPROGRESS_RESULTS*>(pvResults));
613 + break;
614 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR:
615 + hr = BalBaseBAProcOnError(pBA, reinterpret_cast<BA_ONERROR_ARGS*>(pvArgs), reinterpret_cast<BA_ONERROR_RESULTS*>(pvResults));
616 + break;
617 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN:
618 + hr = BalBaseBAProcOnRegisterBegin(pBA, reinterpret_cast<BA_ONREGISTERBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONREGISTERBEGIN_RESULTS*>(pvResults));
619 + break;
620 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE:
621 + hr = BalBaseBAProcOnRegisterComplete(pBA, reinterpret_cast<BA_ONREGISTERCOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONREGISTERCOMPLETE_RESULTS*>(pvResults));
622 + break;
623 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN:
624 + hr = BalBaseBAProcOnCacheBegin(pBA, reinterpret_cast<BA_ONCACHEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEBEGIN_RESULTS*>(pvResults));
625 + break;
626 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN:
627 + hr = BalBaseBAProcOnCachePackageBegin(pBA, reinterpret_cast<BA_ONCACHEPACKAGEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEPACKAGEBEGIN_RESULTS*>(pvResults));
628 + break;
629 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN:
630 + hr = BalBaseBAProcOnCacheAcquireBegin(pBA, reinterpret_cast<BA_ONCACHEACQUIREBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEACQUIREBEGIN_RESULTS*>(pvResults));
631 + break;
632 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS:
633 + hr = BalBaseBAProcOnCacheAcquireProgress(pBA, reinterpret_cast<BA_ONCACHEACQUIREPROGRESS_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEACQUIREPROGRESS_RESULTS*>(pvResults));
634 + break;
635 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE:
636 + hr = BalBaseBAProcOnResolveSource(pBA, reinterpret_cast<BA_ONRESOLVESOURCE_ARGS*>(pvArgs), reinterpret_cast<BA_ONRESOLVESOURCE_RESULTS*>(pvResults));
637 + break;
638 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE:
639 + hr = BalBaseBAProcOnCacheAcquireComplete(pBA, reinterpret_cast<BA_ONCACHEACQUIRECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEACQUIRECOMPLETE_RESULTS*>(pvResults));
640 + break;
641 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN:
642 + hr = BalBaseBAProcOnCacheVerifyBegin(pBA, reinterpret_cast<BA_ONCACHEVERIFYBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEVERIFYBEGIN_RESULTS*>(pvResults));
643 + break;
644 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE:
645 + hr = BalBaseBAProcOnCacheVerifyComplete(pBA, reinterpret_cast<BA_ONCACHEVERIFYCOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEVERIFYCOMPLETE_RESULTS*>(pvResults));
646 + break;
647 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE:
648 + hr = BalBaseBAProcOnCachePackageComplete(pBA, reinterpret_cast<BA_ONCACHEPACKAGECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHEPACKAGECOMPLETE_RESULTS*>(pvResults));
649 + break;
650 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE:
651 + hr = BalBaseBAProcOnCacheComplete(pBA, reinterpret_cast<BA_ONCACHECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONCACHECOMPLETE_RESULTS*>(pvResults));
652 + break;
653 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN:
654 + hr = BalBaseBAProcOnExecuteBegin(pBA, reinterpret_cast<BA_ONEXECUTEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEBEGIN_RESULTS*>(pvResults));
655 + break;
656 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN:
657 + hr = BalBaseBAProcOnExecutePackageBegin(pBA, reinterpret_cast<BA_ONEXECUTEPACKAGEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEPACKAGEBEGIN_RESULTS*>(pvResults));
658 + break;
659 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET:
660 + hr = BalBaseBAProcOnExecutePatchTarget(pBA, reinterpret_cast<BA_ONEXECUTEPATCHTARGET_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEPATCHTARGET_RESULTS*>(pvResults));
661 + break;
662 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS:
663 + hr = BalBaseBAProcOnExecuteProgress(pBA, reinterpret_cast<BA_ONEXECUTEPROGRESS_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEPROGRESS_RESULTS*>(pvResults));
664 + break;
665 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE:
666 + hr = BalBaseBAProcOnExecuteMsiMessage(pBA, reinterpret_cast<BA_ONEXECUTEMSIMESSAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEMSIMESSAGE_RESULTS*>(pvResults));
667 + break;
668 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE:
669 + hr = BalBaseBAProcOnExecuteFilesInUse(pBA, reinterpret_cast<BA_ONEXECUTEFILESINUSE_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEFILESINUSE_RESULTS*>(pvResults));
670 + break;
671 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE:
672 + hr = BalBaseBAProcOnExecutePackageComplete(pBA, reinterpret_cast<BA_ONEXECUTEPACKAGECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTEPACKAGECOMPLETE_RESULTS*>(pvResults));
673 + break;
674 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE:
675 + hr = BalBaseBAProcOnExecuteComplete(pBA, reinterpret_cast<BA_ONEXECUTECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONEXECUTECOMPLETE_RESULTS*>(pvResults));
676 + break;
677 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN:
678 + hr = BalBaseBAProcOnUnregisterBegin(pBA, reinterpret_cast<BA_ONUNREGISTERBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONUNREGISTERBEGIN_RESULTS*>(pvResults));
679 + break;
680 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE:
681 + hr = BalBaseBAProcOnUnregisterComplete(pBA, reinterpret_cast<BA_ONUNREGISTERCOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONUNREGISTERCOMPLETE_RESULTS*>(pvResults));
682 + break;
683 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE:
684 + hr = BalBaseBAProcOnApplyComplete(pBA, reinterpret_cast<BA_ONAPPLYCOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONAPPLYCOMPLETE_RESULTS*>(pvResults));
685 + break;
686 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN:
687 + hr = BalBaseBAProcOnLaunchApprovedExeBegin(pBA, reinterpret_cast<BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS*>(pvResults));
688 + break;
689 + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE:
690 + hr = BalBaseBAProcOnLaunchApprovedExeComplete(pBA, reinterpret_cast<BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS*>(pvResults));
691 + break;
692 + }
693 + }
694 +
695 + pBA->BAProcFallback(message, pvArgs, pvResults, &hr, pvContext);
696 +
697 + return hr;
698 +}
src/balutil/inc/BalBootstrapperEngine.h new
+17
@@ -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 BalBootstrapperEngineCreate(
10 + __in PFN_BOOTSTRAPPER_ENGINE_PROC pfnBAEngineProc,
11 + __in_opt LPVOID pvBAEngineProcContext,
12 + __out IBootstrapperEngine** ppEngineForApplication
13 + );
14 +
15 +#ifdef __cplusplus
16 +}
17 +#endif
src/balutil/inc/IBAFunctions.h new
+34
@@ -0,0 +1,34 @@
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_(IBAFunctions, IBootstrapperApplication, "0FB445ED-17BD-49C7-BE19-479776F8AE96")
6 +{
7 + // OnThemeLoaded - Called after the BA finished loading all the controls for the theme.
8 + //
9 + STDMETHOD(OnThemeLoaded)(
10 + THEME* pTheme,
11 + WIX_LOCALIZATION* pWixLoc
12 + ) = 0;
13 +
14 + // WndProc - Called if the BA hasn't handled the message.
15 + // The implementation must either return E_NOTIMPL or call ThemeDefWindowProc for unhandled messages.
16 + //
17 + STDMETHOD(WndProc)(
18 + __in THEME* pTheme,
19 + __in HWND hWnd,
20 + __in UINT uMsg,
21 + __in WPARAM wParam,
22 + __in LPARAM lParam,
23 + __inout LRESULT* plRes
24 + ) = 0;
25 +
26 + // BAFunctionsProc - The PFN_BA_FUNCTIONS_PROC can call this method to give the BAFunctions raw access to the callback from WixStdBA.
27 + // This might be used to help the BAFunctions support more than one version of the engine/WixStdBA.
28 + STDMETHOD(BAFunctionsProc)(
29 + __in BA_FUNCTIONS_MESSAGE message,
30 + __in const LPVOID pvArgs,
31 + __inout LPVOID pvResults,
32 + __in_opt LPVOID pvContext
33 + ) = 0;
34 +};
src/balutil/inc/balcondition.h new
+58
@@ -0,0 +1,58 @@
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 +#ifdef __cplusplus
6 +extern "C" {
7 +#endif
8 +
9 +typedef struct _BAL_CONDITION
10 +{
11 + LPWSTR sczCondition;
12 + LPWSTR sczMessage;
13 +} BAL_CONDITION;
14 +
15 +
16 +typedef struct _BAL_CONDITIONS
17 +{
18 + BAL_CONDITION* rgConditions;
19 + DWORD cConditions;
20 +} BAL_CONDITIONS;
21 +
22 +
23 +/*******************************************************************
24 + BalConditionsParseFromXml - loads the conditions from the UX manifest.
25 +
26 +********************************************************************/
27 +DAPI_(HRESULT) BalConditionsParseFromXml(
28 + __in BAL_CONDITIONS* pConditions,
29 + __in IXMLDOMDocument* pixdManifest,
30 + __in_opt WIX_LOCALIZATION* pWixLoc
31 + );
32 +
33 +
34 +/*******************************************************************
35 + BalConditionEvaluate - evaluates condition against the provided IBurnCore.
36 +
37 + NOTE: psczMessage is optional.
38 +********************************************************************/
39 +DAPI_(HRESULT) BalConditionEvaluate(
40 + __in BAL_CONDITION* pCondition,
41 + __in IBootstrapperEngine* pEngine,
42 + __out BOOL* pfResult,
43 + __out_z_opt LPWSTR* psczMessage
44 + );
45 +
46 +
47 +/*******************************************************************
48 + BalConditionsUninitialize - uninitializes any conditions previously loaded.
49 +
50 +********************************************************************/
51 +DAPI_(void) BalConditionsUninitialize(
52 + __in BAL_CONDITIONS* pConditions
53 + );
54 +
55 +
56 +#ifdef __cplusplus
57 +}
58 +#endif
src/balutil/inc/balinfo.h new
+107
@@ -0,0 +1,107 @@
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 +#ifdef __cplusplus
6 +extern "C" {
7 +#endif
8 +
9 +typedef enum BAL_INFO_PACKAGE_TYPE
10 +{
11 + BAL_INFO_PACKAGE_TYPE_UNKNOWN,
12 + BAL_INFO_PACKAGE_TYPE_EXE,
13 + BAL_INFO_PACKAGE_TYPE_MSI,
14 + BAL_INFO_PACKAGE_TYPE_MSP,
15 + BAL_INFO_PACKAGE_TYPE_MSU,
16 + BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE,
17 + BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON,
18 + BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH,
19 +} BAL_INFO_PACKAGE_TYPE;
20 +
21 +typedef enum BAL_INFO_CACHE_TYPE
22 +{
23 + BAL_INFO_CACHE_TYPE_NO,
24 + BAL_INFO_CACHE_TYPE_YES,
25 + BAL_INFO_CACHE_TYPE_ALWAYS,
26 +} BAL_INFO_CACHE_TYPE;
27 +
28 +
29 +typedef struct _BAL_INFO_PACKAGE
30 +{
31 + LPWSTR sczId;
32 + LPWSTR sczDisplayName;
33 + LPWSTR sczDescription;
34 + BAL_INFO_PACKAGE_TYPE type;
35 + BOOL fPermanent;
36 + BOOL fVital;
37 + BOOL fDisplayInternalUI;
38 + LPWSTR sczProductCode;
39 + LPWSTR sczUpgradeCode;
40 + LPWSTR sczVersion;
41 + LPWSTR sczInstallCondition;
42 + BAL_INFO_CACHE_TYPE cacheType;
43 +} BAL_INFO_PACKAGE;
44 +
45 +
46 +typedef struct _BAL_INFO_PACKAGES
47 +{
48 + BAL_INFO_PACKAGE* rgPackages;
49 + DWORD cPackages;
50 +} BAL_INFO_PACKAGES;
51 +
52 +
53 +typedef struct _BAL_INFO_BUNDLE
54 +{
55 + BOOL fPerMachine;
56 + LPWSTR sczName;
57 + LPWSTR sczLogVariable;
58 + BAL_INFO_PACKAGES packages;
59 +} BAL_INFO_BUNDLE;
60 +
61 +
62 +/*******************************************************************
63 + BalInfoParseFromXml - loads the bundle and package info from the UX
64 + manifest.
65 +
66 +********************************************************************/
67 +DAPI_(HRESULT) BalInfoParseFromXml(
68 + __in BAL_INFO_BUNDLE* pBundle,
69 + __in IXMLDOMDocument* pixdManifest
70 + );
71 +
72 +
73 +/*******************************************************************
74 + BalInfoAddRelatedBundleAsPackage - adds a related bundle as a package.
75 +
76 + ********************************************************************/
77 +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage(
78 + __in BAL_INFO_PACKAGES* pPackages,
79 + __in LPCWSTR wzId,
80 + __in BOOTSTRAPPER_RELATION_TYPE relationType,
81 + __in BOOL fPerMachine
82 + );
83 +
84 +
85 +/*******************************************************************
86 + BalInfoFindPackageById - finds a package by its id.
87 +
88 + ********************************************************************/
89 +DAPI_(HRESULT) BalInfoFindPackageById(
90 + __in BAL_INFO_PACKAGES* pPackages,
91 + __in LPCWSTR wzId,
92 + __out BAL_INFO_PACKAGE** ppPackage
93 + );
94 +
95 +
96 +/*******************************************************************
97 + BalInfoUninitialize - uninitializes any info previously loaded.
98 +
99 +********************************************************************/
100 +DAPI_(void) BalInfoUninitialize(
101 + __in BAL_INFO_BUNDLE* pBundle
102 + );
103 +
104 +
105 +#ifdef __cplusplus
106 +}
107 +#endif
src/balutil/inc/balretry.h new
+65
@@ -0,0 +1,65 @@
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 +#ifdef __cplusplus
6 +extern "C" {
7 +#endif
8 +
9 +typedef enum BALRETRY_TYPE
10 +{
11 + BALRETRY_TYPE_CACHE,
12 + BALRETRY_TYPE_EXECUTE,
13 +} BALRETRY_TYPE;
14 +
15 +/*******************************************************************
16 + BalRetryInitialize - initialize the retry count and timeout between
17 + retries (in milliseconds).
18 +********************************************************************/
19 +DAPI_(void) BalRetryInitialize(
20 + __in DWORD dwMaxRetries,
21 + __in DWORD dwTimeout
22 + );
23 +
24 +/*******************************************************************
25 + BalRetryUninitialize - call to cleanup any memory allocated during
26 + use of the retry utility.
27 +********************************************************************/
28 +DAPI_(void) BalRetryUninitialize();
29 +
30 +/*******************************************************************
31 + BalRetryStartPackage - call when a package begins to be modified. If
32 + the package is being retried, the function will
33 + wait the specified timeout.
34 +********************************************************************/
35 +DAPI_(void) BalRetryStartPackage(
36 + __in BALRETRY_TYPE type,
37 + __in_z_opt LPCWSTR wzPackageId,
38 + __in_z_opt LPCWSTR wzPayloadId
39 + );
40 +
41 +/*******************************************************************
42 + BalRetryErrorOccured - call when an error occurs for the retry utility
43 + to consider.
44 +********************************************************************/
45 +DAPI_(void) BalRetryErrorOccurred(
46 + __in_z_opt LPCWSTR wzPackageId,
47 + __in DWORD dwError
48 + );
49 +
50 +/*******************************************************************
51 + BalRetryEndPackage - returns IDRETRY is a retry is recommended or
52 + IDNOACTION if a retry is not recommended.
53 +********************************************************************/
54 +DAPI_(HRESULT) BalRetryEndPackage(
55 + __in BALRETRY_TYPE type,
56 + __in_z_opt LPCWSTR wzPackageId,
57 + __in_z_opt LPCWSTR wzPayloadId,
58 + __in HRESULT hrError,
59 + __inout BOOL* pfRetry
60 + );
61 +
62 +
63 +#ifdef __cplusplus
64 +}
65 +#endif
src/balutil/inc/balutil.h new
+165
@@ -0,0 +1,165 @@
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 BalExitOnFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
13 +#define BalExitOnRootFailure(x, f, ...) if (FAILED(x)) { BalLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
14 +#define BalExitOnNullWithLastError(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__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
15 +
16 +#define FACILITY_WIX 500
17 +
18 +const LPCWSTR BAL_MANIFEST_FILENAME = L"BootstrapperApplicationData.xml";
19 +
20 +static const HRESULT E_WIXSTDBA_CONDITION_FAILED = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1);
21 +
22 +static const HRESULT E_MBAHOST_NET452_ON_WIN7RTM = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1000);
23 +
24 +
25 +/*******************************************************************
26 + BalInitialize - remembers the engine interface to enable logging and
27 + other functions.
28 +
29 +********************************************************************/
30 +DAPI_(void) BalInitialize(
31 + __in IBootstrapperEngine* pEngine
32 + );
33 +
34 +/*******************************************************************
35 + BalInitializeFromCreateArgs - convenience function to call BalBootstrapperEngineCreate
36 + then pass it along to BalInitialize.
37 +
38 +********************************************************************/
39 +DAPI_(HRESULT) BalInitializeFromCreateArgs(
40 + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
41 + __out IBootstrapperEngine** ppEngine
42 + );
43 +
44 +/*******************************************************************
45 + BalUninitialize - cleans up utility layer internals.
46 +
47 +********************************************************************/
48 +DAPI_(void) BalUninitialize();
49 +
50 +/*******************************************************************
51 + BalManifestLoad - loads the Application manifest into an XML document.
52 +
53 +********************************************************************/
54 +DAPI_(HRESULT) BalManifestLoad(
55 + __in HMODULE hUXModule,
56 + __out IXMLDOMDocument** ppixdManifest
57 + );
58 +
59 +/*******************************************************************
60 +BalEvaluateCondition - evaluates a condition using variables in the engine.
61 +
62 +********************************************************************/
63 +DAPI_(HRESULT) BalEvaluateCondition(
64 + __in_z LPCWSTR wzCondition,
65 + __out BOOL* pf
66 + );
67 +
68 +/*******************************************************************
69 +BalFormatString - formats a string using variables in the engine.
70 +
71 + Note: Use StrFree() to release psczOut.
72 +********************************************************************/
73 +DAPI_(HRESULT) BalFormatString(
74 + __in_z LPCWSTR wzFormat,
75 + __inout LPWSTR* psczOut
76 + );
77 +
78 +/*******************************************************************
79 +BalGetNumericVariable - gets a number from a variable in the engine.
80 +
81 + Note: Returns E_NOTFOUND if variable does not exist.
82 +********************************************************************/
83 +DAPI_(HRESULT) BalGetNumericVariable(
84 + __in_z LPCWSTR wzVariable,
85 + __out LONGLONG* pllValue
86 + );
87 +
88 +/*******************************************************************
89 +BalSetNumericVariable - sets a numeric variable in the engine.
90 +
91 +********************************************************************/
92 +DAPI_(HRESULT) BalSetNumericVariable(
93 + __in_z LPCWSTR wzVariable,
94 + __in LONGLONG llValue
95 + );
96 +
97 +/*******************************************************************
98 +BalStringVariableExists - checks if a string variable exists in the engine.
99 +
100 +********************************************************************/
101 +DAPI_(BOOL) BalStringVariableExists(
102 + __in_z LPCWSTR wzVariable
103 + );
104 +
105 +/*******************************************************************
106 +BalGetStringVariable - gets a string from a variable in the engine.
107 +
108 + Note: Use StrFree() to release psczValue.
109 +********************************************************************/
110 +DAPI_(HRESULT) BalGetStringVariable(
111 + __in_z LPCWSTR wzVariable,
112 + __inout LPWSTR* psczValue
113 + );
114 +
115 +/*******************************************************************
116 +BalSetStringVariable - sets a string variable in the engine.
117 +
118 +********************************************************************/
119 +DAPI_(HRESULT) BalSetStringVariable(
120 + __in_z LPCWSTR wzVariable,
121 + __in_z_opt LPCWSTR wzValue
122 + );
123 +
124 +/*******************************************************************
125 + BalLog - logs a message with the engine.
126 +
127 +********************************************************************/
128 +DAPIV_(HRESULT) BalLog(
129 + __in BOOTSTRAPPER_LOG_LEVEL level,
130 + __in_z __format_string LPCSTR szFormat,
131 + ...
132 + );
133 +
134 +/*******************************************************************
135 + BalLogError - logs an error message with the engine.
136 +
137 +********************************************************************/
138 +DAPIV_(HRESULT) BalLogError(
139 + __in HRESULT hr,
140 + __in_z __format_string LPCSTR szFormat,
141 + ...
142 + );
143 +
144 +/*******************************************************************
145 +BalLogId - logs a message with the engine with a string embedded in a
146 + MESSAGETABLE resource.
147 +
148 +********************************************************************/
149 +DAPIV_(HRESULT) BalLogId(
150 + __in BOOTSTRAPPER_LOG_LEVEL level,
151 + __in DWORD dwLogId,
152 + __in HMODULE hModule,
153 + ...
154 + );
155 +
156 +DAPI_(HRESULT) BalLogIdArgs(
157 + __in BOOTSTRAPPER_LOG_LEVEL level,
158 + __in DWORD dwLogId,
159 + __in HMODULE hModule,
160 + __in va_list args
161 + );
162 +
163 +#ifdef __cplusplus
164 +}
165 +#endif
src/balutil/precomp.h new
+31
@@ -0,0 +1,31 @@
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 <bitsmsg.h>
7 +#include <msi.h>
8 +#include <wininet.h>
9 +#include <CommCtrl.h>
10 +
11 +#include <dutil.h>
12 +#include <pathutil.h>
13 +#include <locutil.h>
14 +#include <memutil.h>
15 +#include <strutil.h>
16 +#include <thmutil.h>
17 +#include <xmlutil.h>
18 +
19 +#include "BootstrapperEngine.h"
20 +#include "BootstrapperApplication.h"
21 +#include "IBootstrapperEngine.h"
22 +#include "IBootstrapperApplication.h"
23 +
24 +#include "BAFunctions.h"
25 +#include "IBAFunctions.h"
26 +
27 +#include "balutil.h"
28 +#include "BalBootstrapperEngine.h"
29 +#include "balcondition.h"
30 +#include "balinfo.h"
31 +#include "balretry.h"