summaryrefslogtreecommitdiff
path: root/src/api/burn/balutil/msg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/burn/balutil/msg.cpp')
-rw-r--r--src/api/burn/balutil/msg.cpp5263
1 files changed, 5263 insertions, 0 deletions
diff --git a/src/api/burn/balutil/msg.cpp b/src/api/burn/balutil/msg.cpp
new file mode 100644
index 00000000..690108a5
--- /dev/null
+++ b/src/api/burn/balutil/msg.cpp
@@ -0,0 +1,5263 @@
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
5static HRESULT OnApplyBegin(
6 __in IBootstrapperApplication* pApplication,
7 __in BUFF_READER* pReaderArgs,
8 __in BUFF_READER* pReaderResults,
9 __in BUFF_BUFFER* pBuffer
10 )
11{
12 HRESULT hr = S_OK;
13 BA_ONAPPLYBEGIN_ARGS args = { };
14 BA_ONAPPLYBEGIN_RESULTS results = { };
15
16 // Read args.
17 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
18 ExitOnFailure(hr, "Failed to read API version of OnApplyBegin args.");
19
20 hr = BuffReaderReadNumber(pReaderArgs, &args.dwPhaseCount);
21 ExitOnFailure(hr, "Failed to read phase count of OnApplyBegin args.");
22
23 // Read results.
24 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
25 ExitOnFailure(hr, "Failed to read API version of OnApplyBegin results.");
26
27 // Callback.
28 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, &args, &results);
29
30 if (E_NOTIMPL == hr)
31 {
32 hr = pApplication->OnApplyBegin(args.dwPhaseCount, &results.fCancel);
33 }
34
35 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN, &args, &results, &hr);
36 BalExitOnFailure(hr, "BA OnApplyBegin failed.");
37
38 // Write results.
39 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
40 ExitOnFailure(hr, "Failed to write size of OnApplyBegin struct.");
41
42 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
43 ExitOnFailure(hr, "Failed to write cancel of OnApplyBegin struct.");
44
45LExit:
46 return hr;
47}
48
49static HRESULT OnApplyComplete(
50 __in IBootstrapperApplication* pApplication,
51 __in BUFF_READER* pReaderArgs,
52 __in BUFF_READER* pReaderResults,
53 __in BUFF_BUFFER* pBuffer
54 )
55{
56 HRESULT hr = S_OK;
57 BA_ONAPPLYCOMPLETE_ARGS args = { };
58 BA_ONAPPLYCOMPLETE_RESULTS results = { };
59
60 // Read args.
61 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
62 ExitOnFailure(hr, "Failed to read API version of OnApplyComplete args.");
63
64 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
65 ExitOnFailure(hr, "Failed to read status of OnApplyComplete args.");
66
67 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.restart));
68 ExitOnFailure(hr, "Failed to read restart of OnApplyComplete args.");
69
70 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
71 ExitOnFailure(hr, "Failed to read recommendation of OnApplyComplete args.");
72
73 // Read results.
74 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
75 ExitOnFailure(hr, "Failed to read API version of OnApplyComplete results.");
76
77 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
78 ExitOnFailure(hr, "Failed to read action of OnApplyComplete results.");
79
80 // Callback.
81 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, &args, &results);
82
83 if (E_NOTIMPL == hr)
84 {
85 hr = pApplication->OnApplyComplete(args.hrStatus, args.restart, args.recommendation, &results.action);
86 }
87
88 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE, &args, &results, &hr);
89 BalExitOnFailure(hr, "BA OnApplyComplete failed.");
90
91 // Write results.
92 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
93 ExitOnFailure(hr, "Failed to write size of OnApplyComplete struct.");
94
95 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
96 ExitOnFailure(hr, "Failed to write action of OnApplyComplete struct.");
97
98LExit:
99 return hr;
100}
101
102static HRESULT OnApplyDowngrade(
103 __in IBootstrapperApplication* pApplication,
104 __in BUFF_READER* pReaderArgs,
105 __in BUFF_READER* pReaderResults,
106 __in BUFF_BUFFER* pBuffer
107 )
108{
109 HRESULT hr = S_OK;
110 BA_ONAPPLYDOWNGRADE_ARGS args = { };
111 BA_ONAPPLYDOWNGRADE_RESULTS results = { };
112
113 // Read args.
114 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
115 ExitOnFailure(hr, "Failed to read API version of OnApplyDowngrade args.");
116
117 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrRecommended));
118 ExitOnFailure(hr, "Failed to read recommended of OnApplyDowngrade args.");
119
120 // Read results.
121 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
122 ExitOnFailure(hr, "Failed to read API version of OnApplyDowngrade results.");
123
124 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.hrStatus));
125 ExitOnFailure(hr, "Failed to read status of OnApplyDowngrade results.");
126
127 // Callback.
128 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &args, &results);
129
130 if (E_NOTIMPL == hr)
131 {
132 hr = pApplication->OnApplyDowngrade(args.hrRecommended, &results.hrStatus);
133 }
134
135 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE, &args, &results, &hr);
136 BalExitOnFailure(hr, "BA OnApplyDowngrade failed.");
137
138 // Write results.
139 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
140 ExitOnFailure(hr, "Failed to write size of OnApplyDowngrade struct.");
141
142 hr = BuffWriteNumberToBuffer(pBuffer, results.hrStatus);
143 ExitOnFailure(hr, "Failed to write status of OnApplyDowngrade struct.");
144
145LExit:
146 return hr;
147}
148
149static HRESULT OnBeginMsiTransactionBegin(
150 __in IBootstrapperApplication* pApplication,
151 __in BUFF_READER* pReaderArgs,
152 __in BUFF_READER* pReaderResults,
153 __in BUFF_BUFFER* pBuffer
154 )
155{
156 HRESULT hr = S_OK;
157 BA_ONBEGINMSITRANSACTIONBEGIN_ARGS args = { };
158 BA_ONBEGINMSITRANSACTIONBEGIN_RESULTS results = { };
159 LPWSTR sczTransactionId = NULL;
160
161 // Read args.
162 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
163 ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionBegin args.");
164
165 hr = BuffReaderReadString(pReaderArgs, &sczTransactionId);
166 ExitOnFailure(hr, "Failed to read recommended of OnBeginMsiTransactionBegin args.");
167
168 args.wzTransactionId = sczTransactionId;
169
170 // Read results.
171 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
172 ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionBegin results.");
173
174 // Callback.
175 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &args, &results);
176
177 if (E_NOTIMPL == hr)
178 {
179 hr = pApplication->OnBeginMsiTransactionBegin(args.wzTransactionId, &results.fCancel);
180 }
181
182 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN, &args, &results, &hr);
183 BalExitOnFailure(hr, "BA OnBeginMsiTransactionBegin failed.");
184
185 // Write results.
186 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
187 ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionBegin struct.");
188
189 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
190 ExitOnFailure(hr, "Failed to write cancel of OnBeginMsiTransactionBegin struct.");
191
192LExit:
193 ReleaseStr(sczTransactionId);
194 return hr;
195}
196
197static HRESULT OnBeginMsiTransactionComplete(
198 __in IBootstrapperApplication* pApplication,
199 __in BUFF_READER* pReaderArgs,
200 __in BUFF_READER* pReaderResults,
201 __in BUFF_BUFFER* pBuffer
202 )
203{
204 HRESULT hr = S_OK;
205 BA_ONBEGINMSITRANSACTIONCOMPLETE_ARGS args = { };
206 BA_ONBEGINMSITRANSACTIONCOMPLETE_RESULTS results = { };
207 LPWSTR sczTransactionId = NULL;
208
209 // Read args.
210 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
211 ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionComplete args.");
212
213 hr = BuffReaderReadString(pReaderArgs, &sczTransactionId);
214 ExitOnFailure(hr, "Failed to read transaction id of OnBeginMsiTransactionComplete args.");
215
216 args.wzTransactionId = sczTransactionId;
217
218 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
219 ExitOnFailure(hr, "Failed to read status of OnBeginMsiTransactionComplete args.");
220
221 // Read results.
222 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
223 ExitOnFailure(hr, "Failed to read API version of OnBeginMsiTransactionComplete results.");
224
225 // Callback.
226 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &args, &results);
227
228 if (E_NOTIMPL == hr)
229 {
230 hr = pApplication->OnBeginMsiTransactionComplete(args.wzTransactionId, args.hrStatus);
231 }
232
233 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE, &args, &results, &hr);
234 BalExitOnFailure(hr, "BA OnBeginMsiTransactionComplete failed.");
235
236 // Write results.
237 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
238 ExitOnFailure(hr, "Failed to write size of OnBeginMsiTransactionComplete struct.");
239
240LExit:
241 ReleaseStr(sczTransactionId);
242 return hr;
243}
244
245static HRESULT OnCacheAcquireBegin(
246 __in IBootstrapperApplication* pApplication,
247 __in BUFF_READER* pReaderArgs,
248 __in BUFF_READER* pReaderResults,
249 __in BUFF_BUFFER* pBuffer
250 )
251{
252 HRESULT hr = S_OK;
253 BA_ONCACHEACQUIREBEGIN_ARGS args = { };
254 BA_ONCACHEACQUIREBEGIN_RESULTS results = { };
255 LPWSTR sczPackageOrContainerId = NULL;
256 LPWSTR sczPayloadId = NULL;
257 LPWSTR sczSource = NULL;
258 LPWSTR sczDownloadUrl = NULL;
259 LPWSTR sczPayloadContainerId = NULL;
260
261 // Read args.
262 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
263 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireBegin args.");
264
265 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
266 ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireBegin args.");
267
268 args.wzPackageOrContainerId = sczPackageOrContainerId;
269
270 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
271 ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireBegin args.");
272
273 args.wzPayloadId = sczPayloadId;
274
275 hr = BuffReaderReadString(pReaderArgs, &sczSource);
276 ExitOnFailure(hr, "Failed to read source of OnCacheAcquireBegin args.");
277
278 args.wzSource = sczSource;
279
280 hr = BuffReaderReadString(pReaderArgs, &sczDownloadUrl);
281 ExitOnFailure(hr, "Failed to read download url of OnCacheAcquireBegin args.");
282
283 args.wzDownloadUrl = sczDownloadUrl;
284
285 hr = BuffReaderReadString(pReaderArgs, &sczPayloadContainerId);
286 ExitOnFailure(hr, "Failed to read payload container id of OnCacheAcquireBegin args.");
287
288 args.wzPayloadContainerId = sczPayloadContainerId;
289
290 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
291 ExitOnFailure(hr, "Failed to read recommendation of OnCacheAcquireBegin args.");
292
293 // Read results.
294 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
295 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireBegin results.");
296
297 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
298 ExitOnFailure(hr, "Failed to read action of OnCacheAcquireBegin results.");
299
300 // Callback.
301 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, &args, &results);
302
303 if (E_NOTIMPL == hr)
304 {
305 hr = pApplication->OnCacheAcquireBegin(args.wzPackageOrContainerId, args.wzPayloadId, args.wzSource, args.wzDownloadUrl, args.wzPayloadContainerId, args.recommendation, &results.action, &results.fCancel);
306 }
307
308 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, &args, &results, &hr);
309 BalExitOnFailure(hr, "BA OnCacheAcquireBegin failed.");
310
311 // Write results.
312 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
313 ExitOnFailure(hr, "Failed to write size of OnCacheAcquireBegin struct.");
314
315 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
316 ExitOnFailure(hr, "Failed to write cancel of OnCacheAcquireBegin struct.");
317
318 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
319 ExitOnFailure(hr, "Failed to write action of OnCacheAcquireBegin struct.");
320
321LExit:
322 ReleaseStr(sczPayloadContainerId);
323 ReleaseStr(sczDownloadUrl);
324 ReleaseStr(sczSource);
325 ReleaseStr(sczPayloadId);
326 ReleaseStr(sczPackageOrContainerId);
327 return hr;
328}
329
330static HRESULT OnCacheAcquireComplete(
331 __in IBootstrapperApplication* pApplication,
332 __in BUFF_READER* pReaderArgs,
333 __in BUFF_READER* pReaderResults,
334 __in BUFF_BUFFER* pBuffer
335 )
336{
337 HRESULT hr = S_OK;
338 BA_ONCACHEACQUIRECOMPLETE_ARGS args = { };
339 BA_ONCACHEACQUIRECOMPLETE_RESULTS results = { };
340 LPWSTR sczPackageOrContainerId = NULL;
341 LPWSTR sczPayloadId = NULL;
342
343 // Read args.
344 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
345 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireComplete args.");
346
347 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
348 ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireComplete args.");
349
350 args.wzPackageOrContainerId = sczPackageOrContainerId;
351
352 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
353 ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireComplete args.");
354
355 args.wzPayloadId = sczPayloadId;
356
357 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
358 ExitOnFailure(hr, "Failed to read status of OnCacheAcquireComplete args.");
359
360 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
361 ExitOnFailure(hr, "Failed to read recommendation of OnCacheAcquireComplete args.");
362
363 // Read results.
364 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
365 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireComplete results.");
366
367 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
368 ExitOnFailure(hr, "Failed to read action of OnCacheAcquireComplete results.");
369
370 // Callback.
371 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, &args, &results);
372
373 if (E_NOTIMPL == hr)
374 {
375 hr = pApplication->OnCacheAcquireComplete(args.wzPackageOrContainerId, args.wzPayloadId, args.hrStatus, args.recommendation, &results.action);
376 }
377
378 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, &args, &results, &hr);
379 BalExitOnFailure(hr, "BA OnCacheAcquireComplete failed.");
380
381 // Write results.
382 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
383 ExitOnFailure(hr, "Failed to write size of OnCacheAcquireComplete struct.");
384
385 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
386 ExitOnFailure(hr, "Failed to write action of OnCacheAcquireComplete struct.");
387
388LExit:
389 ReleaseStr(sczPayloadId);
390 ReleaseStr(sczPackageOrContainerId);
391 return hr;
392}
393
394static HRESULT OnCacheAcquireProgress(
395 __in IBootstrapperApplication* pApplication,
396 __in BUFF_READER* pReaderArgs,
397 __in BUFF_READER* pReaderResults,
398 __in BUFF_BUFFER* pBuffer
399 )
400{
401 HRESULT hr = S_OK;
402 BA_ONCACHEACQUIREPROGRESS_ARGS args = { };
403 BA_ONCACHEACQUIREPROGRESS_RESULTS results = { };
404 LPWSTR sczPackageOrContainerId = NULL;
405 LPWSTR sczPayloadId = NULL;
406
407 // Read args.
408 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
409 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireProgress args.");
410
411 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
412 ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireProgress args.");
413
414 args.wzPackageOrContainerId = sczPackageOrContainerId;
415
416 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
417 ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireProgress args.");
418
419 args.wzPayloadId = sczPayloadId;
420
421 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress);
422 ExitOnFailure(hr, "Failed to read progress of OnCacheAcquireProgress args.");
423
424 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total);
425 ExitOnFailure(hr, "Failed to read total progress of OnCacheAcquireProgress args.");
426
427 hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage);
428 ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireProgress args.");
429
430 // Read results.
431 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
432 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireProgress results.");
433
434 // Callback.
435 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, &args, &results);
436
437 if (E_NOTIMPL == hr)
438 {
439 hr = pApplication->OnCacheAcquireProgress(args.wzPackageOrContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, &results.fCancel);
440 }
441
442 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, &args, &results, &hr);
443 BalExitOnFailure(hr, "BA OnCacheAcquireProgress failed.");
444
445 // Write results.
446 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
447 ExitOnFailure(hr, "Failed to write size of OnCacheAcquireProgress struct.");
448
449 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
450 ExitOnFailure(hr, "Failed to write cancel of OnCacheAcquireProgress struct.");
451
452LExit:
453 ReleaseStr(sczPayloadId);
454 ReleaseStr(sczPackageOrContainerId);
455 return hr;
456}
457
458static HRESULT OnCacheAcquireResolving(
459 __in IBootstrapperApplication* pApplication,
460 __in BUFF_READER* pReaderArgs,
461 __in BUFF_READER* pReaderResults,
462 __in BUFF_BUFFER* pBuffer
463 )
464{
465 HRESULT hr = S_OK;
466 BA_ONCACHEACQUIRERESOLVING_ARGS args = { };
467 BA_ONCACHEACQUIRERESOLVING_RESULTS results = { };
468 LPWSTR sczPackageOrContainerId = NULL;
469 LPWSTR sczPayloadId = NULL;
470 DWORD cSearchPaths = 0;
471 LPWSTR* rgsczSearchPaths = NULL;
472 LPWSTR sczDownloadUrl = NULL;
473 LPWSTR sczPayloadContainerId = NULL;
474
475 // Read args.
476 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
477 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireResolving args.");
478
479 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
480 ExitOnFailure(hr, "Failed to read package or container id of OnCacheAcquireResolving args.");
481
482 args.wzPackageOrContainerId = sczPackageOrContainerId;
483
484 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
485 ExitOnFailure(hr, "Failed to read payload id of OnCacheAcquireResolving args.");
486
487 args.wzPayloadId = sczPayloadId;
488
489 hr = BuffReaderReadNumber(pReaderArgs, &cSearchPaths);
490 ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireResolving args.");
491
492 if (cSearchPaths)
493 {
494 rgsczSearchPaths = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cSearchPaths, TRUE));
495 ExitOnNull(rgsczSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths of OnCacheAcquireResolving args.");
496
497 for (DWORD i = 0; i < cSearchPaths; ++i)
498 {
499 hr = BuffReaderReadString(pReaderArgs, &rgsczSearchPaths[i]);
500 ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i);
501 }
502 }
503
504 args.cSearchPaths = cSearchPaths;
505 args.rgSearchPaths = const_cast<LPCWSTR*>(rgsczSearchPaths);
506
507 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fFoundLocal));
508 ExitOnFailure(hr, "Failed to read found local of OnCacheAcquireResolving args.");
509
510 hr = BuffReaderReadNumber(pReaderArgs, &args.dwRecommendedSearchPath);
511 ExitOnFailure(hr, "Failed to read recommended search path of OnCacheAcquireResolving args.");
512
513 hr = BuffReaderReadString(pReaderArgs, &sczDownloadUrl);
514 ExitOnFailure(hr, "Failed to read download url of OnCacheAcquireResolving args.");
515
516 hr = BuffReaderReadString(pReaderArgs, &sczPayloadContainerId);
517 ExitOnFailure(hr, "Failed to read payload container id of OnCacheAcquireResolving args.");
518
519 args.wzPayloadContainerId = sczPayloadContainerId;
520
521 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
522 ExitOnFailure(hr, "Failed to read recommendedation of OnCacheAcquireResolving args.");
523
524 // Read results.
525 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
526 ExitOnFailure(hr, "Failed to read API version of OnCacheAcquireResolving results.");
527
528 hr = BuffReaderReadNumber(pReaderResults, &results.dwChosenSearchPath);
529 ExitOnFailure(hr, "Failed to read chosen search path of OnCacheAcquireResolving results.");
530
531 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
532 ExitOnFailure(hr, "Failed to read action of OnCacheAcquireResolving results.");
533
534 // Callback.
535 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, &args, &results);
536
537 if (E_NOTIMPL == hr)
538 {
539 hr = pApplication->OnCacheAcquireResolving(args.wzPackageOrContainerId, args.wzPayloadId, args.rgSearchPaths, args.cSearchPaths, args.fFoundLocal, args.dwRecommendedSearchPath, args.wzDownloadUrl, args.wzPayloadContainerId, args.recommendation, &results.dwChosenSearchPath, &results.action, &results.fCancel);
540 }
541
542 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, &args, &results, &hr);
543 BalExitOnFailure(hr, "BA OnCacheAcquireResolving failed.");
544
545 // Write results.
546 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
547 ExitOnFailure(hr, "Failed to write size of OnCacheAcquireResolving struct.");
548
549 hr = BuffWriteNumberToBuffer(pBuffer, results.dwChosenSearchPath);
550 ExitOnFailure(hr, "Failed to write chosen search path of OnCacheAcquireResolving struct.");
551
552 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
553 ExitOnFailure(hr, "Failed to write action of OnCacheAcquireResolving struct.");
554
555 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
556 ExitOnFailure(hr, "Failed to write cancel of OnCacheAcquireResolving struct.");
557
558LExit:
559 for (DWORD i = 0; rgsczSearchPaths && i < cSearchPaths; ++i)
560 {
561 ReleaseStr(rgsczSearchPaths[i]);
562 }
563 ReleaseMem(rgsczSearchPaths);
564
565 ReleaseStr(sczPayloadContainerId);
566 ReleaseStr(sczDownloadUrl);
567 ReleaseStr(sczPayloadId);
568 ReleaseStr(sczPackageOrContainerId);
569
570 return hr;
571}
572
573static HRESULT OnCacheBegin(
574 __in IBootstrapperApplication* pApplication,
575 __in BUFF_READER* pReaderArgs,
576 __in BUFF_READER* pReaderResults,
577 __in BUFF_BUFFER* pBuffer
578 )
579{
580 HRESULT hr = S_OK;
581 BA_ONCACHEBEGIN_ARGS args = { };
582 BA_ONCACHEBEGIN_RESULTS results = { };
583
584 // Read args.
585 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
586 ExitOnFailure(hr, "Failed to read API version of OnCacheBegin args.");
587
588 // Read results.
589 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
590 ExitOnFailure(hr, "Failed to read API version of OnCacheBegin results.");
591
592 // Callback.
593 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, &args, &results);
594
595 if (E_NOTIMPL == hr)
596 {
597 hr = pApplication->OnCacheBegin(&results.fCancel);
598 }
599
600 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN, &args, &results, &hr);
601 BalExitOnFailure(hr, "BA OnCacheBegin failed.");
602
603 // Write results.
604 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
605 ExitOnFailure(hr, "Failed to write size of OnCacheBegin struct.");
606
607 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
608 ExitOnFailure(hr, "Failed to write cancel of OnCacheBegin struct.");
609
610LExit:
611 return hr;
612}
613
614static HRESULT OnCacheComplete(
615 __in IBootstrapperApplication* pApplication,
616 __in BUFF_READER* pReaderArgs,
617 __in BUFF_READER* pReaderResults,
618 __in BUFF_BUFFER* pBuffer
619 )
620{
621 HRESULT hr = S_OK;
622 BA_ONCACHECOMPLETE_ARGS args = { };
623 BA_ONCACHECOMPLETE_RESULTS results = { };
624
625 // Read args.
626 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
627 ExitOnFailure(hr, "Failed to read API version of OnCacheComplete args.");
628
629 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
630 ExitOnFailure(hr, "Failed to read status of OnCacheComplete args.");
631
632 // Read results.
633 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
634 ExitOnFailure(hr, "Failed to read API version of OnCacheComplete results.");
635
636 // Callback.
637 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, &args, &results);
638
639 if (E_NOTIMPL == hr)
640 {
641 hr = pApplication->OnCacheComplete(args.hrStatus);
642 }
643
644 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE, &args, &results, &hr);
645 BalExitOnFailure(hr, "BA OnCacheComplete failed.");
646
647 // Write results.
648 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
649 ExitOnFailure(hr, "Failed to write size of OnCacheComplete struct.");
650
651LExit:
652 return hr;
653}
654
655static HRESULT OnCacheContainerOrPayloadVerifyBegin(
656 __in IBootstrapperApplication* pApplication,
657 __in BUFF_READER* pReaderArgs,
658 __in BUFF_READER* pReaderResults,
659 __in BUFF_BUFFER* pBuffer
660 )
661{
662 HRESULT hr = S_OK;
663 BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_ARGS args = { };
664 BA_ONCACHECONTAINERORPAYLOADVERIFYBEGIN_RESULTS results = { };
665 LPWSTR sczPackageOrContainerId = NULL;
666 LPWSTR sczPayloadId = NULL;
667
668 // Read args.
669 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
670 ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyBegin args.");
671
672 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
673 ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyBegin args.");
674
675 args.wzPackageOrContainerId = sczPackageOrContainerId;
676
677 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
678 ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyBegin args.");
679
680 args.wzPayloadId = sczPayloadId;
681
682 // Read results.
683 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
684 ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyBegin results.");
685
686 // Callback.
687 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, &args, &results);
688
689 if (E_NOTIMPL == hr)
690 {
691 hr = pApplication->OnCacheContainerOrPayloadVerifyBegin(args.wzPackageOrContainerId, args.wzPayloadId, &results.fCancel);
692 }
693
694 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, &args, &results, &hr);
695 BalExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyBegin failed.");
696
697 // Write results.
698 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
699 ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyBegin struct.");
700
701 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
702 ExitOnFailure(hr, "Failed to write cancel of OnCacheContainerOrPayloadVerifyBegin struct.");
703
704LExit:
705 ReleaseStr(sczPayloadId);
706 ReleaseStr(sczPackageOrContainerId);
707 return hr;
708}
709
710static HRESULT OnCacheContainerOrPayloadVerifyComplete(
711 __in IBootstrapperApplication* pApplication,
712 __in BUFF_READER* pReaderArgs,
713 __in BUFF_READER* pReaderResults,
714 __in BUFF_BUFFER* pBuffer
715 )
716{
717 HRESULT hr = S_OK;
718 BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_ARGS args = { };
719 BA_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE_RESULTS results = { };
720 LPWSTR sczPackageOrContainerId = NULL;
721 LPWSTR sczPayloadId = NULL;
722
723 // Read args.
724 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
725 ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyComplete args.");
726
727 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
728 ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyComplete args.");
729
730 args.wzPackageOrContainerId = sczPackageOrContainerId;
731
732 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
733 ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyComplete args.");
734
735 args.wzPayloadId = sczPayloadId;
736
737 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
738 ExitOnFailure(hr, "Failed to read status of OnCacheContainerOrPayloadVerifyComplete args.");
739
740 // Read results.
741 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
742 ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyComplete results.");
743
744 // Callback.
745 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, &args, &results);
746
747 if (E_NOTIMPL == hr)
748 {
749 hr = pApplication->OnCacheContainerOrPayloadVerifyComplete(args.wzPackageOrContainerId, args.wzPayloadId, args.hrStatus);
750 }
751
752 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, &args, &results, &hr);
753 BalExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyComplete failed.");
754
755 // Write results.
756 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
757 ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyComplete struct.");
758
759LExit:
760 ReleaseStr(sczPayloadId);
761 ReleaseStr(sczPackageOrContainerId);
762 return hr;
763}
764
765static HRESULT OnCacheContainerOrPayloadVerifyProgress(
766 __in IBootstrapperApplication* pApplication,
767 __in BUFF_READER* pReaderArgs,
768 __in BUFF_READER* pReaderResults,
769 __in BUFF_BUFFER* pBuffer
770 )
771{
772 HRESULT hr = S_OK;
773 BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_ARGS args = { };
774 BA_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS_RESULTS results = { };
775 LPWSTR sczPackageOrContainerId = NULL;
776 LPWSTR sczPayloadId = NULL;
777
778 // Read args.
779 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
780 ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyProgress args.");
781
782 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
783 ExitOnFailure(hr, "Failed to read package or container id of OnCacheContainerOrPayloadVerifyProgress args.");
784
785 args.wzPackageOrContainerId = sczPackageOrContainerId;
786
787 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
788 ExitOnFailure(hr, "Failed to read payload id of OnCacheContainerOrPayloadVerifyProgress args.");
789
790 args.wzPayloadId = sczPayloadId;
791
792 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress);
793 ExitOnFailure(hr, "Failed to read progress of OnCacheContainerOrPayloadVerifyProgress args.");
794
795 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total);
796 ExitOnFailure(hr, "Failed to read total progress of OnCacheContainerOrPayloadVerifyProgress args.");
797
798 hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage);
799 ExitOnFailure(hr, "Failed to read overall percentage of OnCacheContainerOrPayloadVerifyProgress args.");
800
801 // Read results.
802 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
803 ExitOnFailure(hr, "Failed to read API version of OnCacheContainerOrPayloadVerifyProgress results.");
804
805 // Callback.
806 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, &args, &results);
807
808 if (E_NOTIMPL == hr)
809 {
810 hr = pApplication->OnCacheContainerOrPayloadVerifyProgress(args.wzPackageOrContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, &results.fCancel);
811 }
812
813 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, &args, &results, &hr);
814 BalExitOnFailure(hr, "BA OnCacheContainerOrPayloadVerifyProgress failed.");
815
816 // Write results.
817 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
818 ExitOnFailure(hr, "Failed to write size of OnCacheContainerOrPayloadVerifyProgress struct.");
819
820 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
821 ExitOnFailure(hr, "Failed to write cancel of OnCacheContainerOrPayloadVerifyProgress struct.");
822
823LExit:
824 ReleaseStr(sczPayloadId);
825 ReleaseStr(sczPackageOrContainerId);
826 return hr;
827}
828
829static HRESULT OnCachePackageBegin(
830 __in IBootstrapperApplication* pApplication,
831 __in BUFF_READER* pReaderArgs,
832 __in BUFF_READER* pReaderResults,
833 __in BUFF_BUFFER* pBuffer
834 )
835{
836 HRESULT hr = S_OK;
837 BA_ONCACHEPACKAGEBEGIN_ARGS args = { };
838 BA_ONCACHEPACKAGEBEGIN_RESULTS results = { };
839 LPWSTR sczPackageId = NULL;
840
841 // Read args.
842 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
843 ExitOnFailure(hr, "Failed to read API version of OnCachePackageBegin args.");
844
845 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
846 ExitOnFailure(hr, "Failed to read package id of OnCachePackageBegin args.");
847
848 args.wzPackageId = sczPackageId;
849
850 hr = BuffReaderReadNumber(pReaderArgs, &args.cCachePayloads);
851 ExitOnFailure(hr, "Failed to read count of cached payloads of OnCachePackageBegin args.");
852
853 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64PackageCacheSize);
854 ExitOnFailure(hr, "Failed to read package cache size of OnCachePackageBegin args.");
855
856 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fVital));
857 ExitOnFailure(hr, "Failed to read vital of OnCachePackageBegin args.");
858
859 // Read results.
860 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
861 ExitOnFailure(hr, "Failed to read API version of OnCachePackageBegin results.");
862
863 // Callback.
864 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, &args, &results);
865
866 if (E_NOTIMPL == hr)
867 {
868 hr = pApplication->OnCachePackageBegin(args.wzPackageId, args.cCachePayloads, args.dw64PackageCacheSize, args.fVital, &results.fCancel);
869 }
870
871 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, &args, &results, &hr);
872 BalExitOnFailure(hr, "BA OnCachePackageBegin failed.");
873
874 // Write results.
875 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
876 ExitOnFailure(hr, "Failed to write size of OnCachePackageBegin struct.");
877
878 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
879 ExitOnFailure(hr, "Failed to write cancel of OnCachePackageBegin struct.");
880
881LExit:
882 ReleaseStr(sczPackageId);
883 return hr;
884}
885
886static HRESULT OnCachePackageComplete(
887 __in IBootstrapperApplication* pApplication,
888 __in BUFF_READER* pReaderArgs,
889 __in BUFF_READER* pReaderResults,
890 __in BUFF_BUFFER* pBuffer
891 )
892{
893 HRESULT hr = S_OK;
894 BA_ONCACHEPACKAGECOMPLETE_ARGS args = { };
895 BA_ONCACHEPACKAGECOMPLETE_RESULTS results = { };
896 LPWSTR sczPackageId = NULL;
897
898 // Read args.
899 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
900 ExitOnFailure(hr, "Failed to read API version of OnCachePackageComplete args.");
901
902 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
903 ExitOnFailure(hr, "Failed to read package id of OnCachePackageComplete args.");
904
905 args.wzPackageId = sczPackageId;
906
907 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
908 ExitOnFailure(hr, "Failed to read status of OnCachePackageComplete args.");
909
910 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
911 ExitOnFailure(hr, "Failed to read recommendation of OnCachePackageComplete args.");
912
913 // Read results.
914 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
915 ExitOnFailure(hr, "Failed to read API version of OnCachePackageComplete results.");
916
917 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
918 ExitOnFailure(hr, "Failed to read action of OnCachePackageComplete results.");
919
920 // Callback.
921 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &args, &results);
922
923 if (E_NOTIMPL == hr)
924 {
925 hr = pApplication->OnCachePackageComplete(args.wzPackageId, args.hrStatus, args.recommendation, &results.action);
926 }
927
928 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &args, &results, &hr);
929 BalExitOnFailure(hr, "BA OnCachePackageComplete failed.");
930
931 // Write results.
932 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
933 ExitOnFailure(hr, "Failed to write size of OnCachePackageComplete struct.");
934
935 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
936 ExitOnFailure(hr, "Failed to write action of OnCachePackageComplete struct.");
937
938LExit:
939 ReleaseStr(sczPackageId);
940 return hr;
941}
942
943static HRESULT OnCachePackageNonVitalValidationFailure(
944 __in IBootstrapperApplication* pApplication,
945 __in BUFF_READER* pReaderArgs,
946 __in BUFF_READER* pReaderResults,
947 __in BUFF_BUFFER* pBuffer
948 )
949{
950 HRESULT hr = S_OK;
951 BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_ARGS args = { };
952 BA_ONCACHEPACKAGENONVITALVALIDATIONFAILURE_RESULTS results = { };
953 LPWSTR sczPackageId = NULL;
954
955 // Read args.
956 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
957 ExitOnFailure(hr, "Failed to read API version of OnCachePackageNonVitalValidationFailure args.");
958
959 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
960 ExitOnFailure(hr, "Failed to read package id of OnCachePackageNonVitalValidationFailure args.");
961
962 args.wzPackageId = sczPackageId;
963
964 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
965 ExitOnFailure(hr, "Failed to read status of OnCachePackageNonVitalValidationFailure args.");
966
967 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
968 ExitOnFailure(hr, "Failed to read recommendation of OnCachePackageNonVitalValidationFailure args.");
969
970 // Read results.
971 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
972 ExitOnFailure(hr, "Failed to read API version of OnCachePackageNonVitalValidationFailure results.");
973
974 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
975 ExitOnFailure(hr, "Failed to read action of OnCachePackageNonVitalValidationFailure results.");
976
977 // Callback.
978 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, &args, &results);
979
980 if (E_NOTIMPL == hr)
981 {
982 hr = pApplication->OnCachePackageNonVitalValidationFailure(args.wzPackageId, args.hrStatus, args.recommendation, &results.action);
983 }
984
985 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE, &args, &results, &hr);
986 BalExitOnFailure(hr, "BA OnCachePackageNonVitalValidationFailure failed.");
987
988 // Write results.
989 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
990 ExitOnFailure(hr, "Failed to write size of OnCachePackageNonVitalValidationFailure struct.");
991
992 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
993 ExitOnFailure(hr, "Failed to write action of OnCachePackageNonVitalValidationFailure struct.");
994
995LExit:
996 ReleaseStr(sczPackageId);
997 return hr;
998}
999
1000static HRESULT OnCachePayloadExtractBegin(
1001 __in IBootstrapperApplication* pApplication,
1002 __in BUFF_READER* pReaderArgs,
1003 __in BUFF_READER* pReaderResults,
1004 __in BUFF_BUFFER* pBuffer
1005 )
1006{
1007 HRESULT hr = S_OK;
1008 BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS args = { };
1009 BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS results = { };
1010 LPWSTR sczContainerId = NULL;
1011 LPWSTR sczPayloadId = NULL;
1012
1013 // Read args.
1014 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1015 ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractBegin args.");
1016
1017 hr = BuffReaderReadString(pReaderArgs, &sczContainerId);
1018 ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractBegin args.");
1019
1020 args.wzContainerId = sczContainerId;
1021
1022 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
1023 ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractBegin args.");
1024
1025 args.wzPayloadId = sczPayloadId;
1026
1027 // Read results.
1028 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1029 ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractBegin results.");
1030
1031 // Callback.
1032 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &args, &results);
1033
1034 if (E_NOTIMPL == hr)
1035 {
1036 hr = pApplication->OnCachePayloadExtractBegin(args.wzContainerId, args.wzPayloadId, &results.fCancel);
1037 }
1038
1039 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &args, &results, &hr);
1040 BalExitOnFailure(hr, "BA OnCachePayloadExtractBegin failed.");
1041
1042 // Write results.
1043 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1044 ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractBegin struct.");
1045
1046 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1047 ExitOnFailure(hr, "Failed to write cancel of OnCachePayloadExtractBegin struct.");
1048
1049LExit:
1050 ReleaseStr(sczPayloadId);
1051 ReleaseStr(sczContainerId);
1052 return hr;
1053}
1054
1055static HRESULT OnCachePayloadExtractComplete(
1056 __in IBootstrapperApplication* pApplication,
1057 __in BUFF_READER* pReaderArgs,
1058 __in BUFF_READER* pReaderResults,
1059 __in BUFF_BUFFER* pBuffer
1060 )
1061{
1062 HRESULT hr = S_OK;
1063 BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS args = { };
1064 BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS results = { };
1065 LPWSTR sczContainerId = NULL;
1066 LPWSTR sczPayloadId = NULL;
1067
1068 // Read args.
1069 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1070 ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractComplete args.");
1071
1072 hr = BuffReaderReadString(pReaderArgs, &sczContainerId);
1073 ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractComplete args.");
1074
1075 args.wzContainerId = sczContainerId;
1076
1077 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
1078 ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractComplete args.");
1079
1080 args.wzPayloadId = sczPayloadId;
1081
1082 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
1083 ExitOnFailure(hr, "Failed to read status of OnCachePayloadExtractComplete args.");
1084
1085 // Read results.
1086 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1087 ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractComplete results.");
1088
1089 // Callback.
1090 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &args, &results);
1091
1092 if (E_NOTIMPL == hr)
1093 {
1094 hr = pApplication->OnCachePayloadExtractComplete(args.wzContainerId, args.wzPayloadId, args.hrStatus);
1095 }
1096
1097 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &args, &results, &hr);
1098 BalExitOnFailure(hr, "BA OnCachePayloadExtractComplete failed.");
1099
1100 // Write results.
1101 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1102 ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractComplete struct.");
1103
1104LExit:
1105 ReleaseStr(sczPayloadId);
1106 ReleaseStr(sczContainerId);
1107 return hr;
1108}
1109
1110static HRESULT OnCachePayloadExtractProgress(
1111 __in IBootstrapperApplication* pApplication,
1112 __in BUFF_READER* pReaderArgs,
1113 __in BUFF_READER* pReaderResults,
1114 __in BUFF_BUFFER* pBuffer
1115 )
1116{
1117 HRESULT hr = S_OK;
1118 BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS args = { };
1119 BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS results = { };
1120 LPWSTR sczContainerId = NULL;
1121 LPWSTR sczPayloadId = NULL;
1122
1123 // Read args.
1124 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1125 ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractProgress args.");
1126
1127 hr = BuffReaderReadString(pReaderArgs, &sczContainerId);
1128 ExitOnFailure(hr, "Failed to read container id of OnCachePayloadExtractProgress args.");
1129
1130 args.wzContainerId = sczContainerId;
1131
1132 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
1133 ExitOnFailure(hr, "Failed to read payload id of OnCachePayloadExtractProgress args.");
1134
1135 args.wzPayloadId = sczPayloadId;
1136
1137 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress);
1138 ExitOnFailure(hr, "Failed to read progress of OnCachePayloadExtractProgress args.");
1139
1140 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total);
1141 ExitOnFailure(hr, "Failed to read total progress of OnCachePayloadExtractProgress args.");
1142
1143 hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage);
1144 ExitOnFailure(hr, "Failed to read overall percentage of OnCachePayloadExtractProgress args.");
1145
1146 // Read results.
1147 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1148 ExitOnFailure(hr, "Failed to read API version of OnCachePayloadExtractProgress results.");
1149
1150 // Callback.
1151 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &args, &results);
1152
1153 if (E_NOTIMPL == hr)
1154 {
1155 hr = pApplication->OnCachePayloadExtractProgress(args.wzContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, &results.fCancel);
1156 }
1157
1158 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &args, &results, &hr);
1159 BalExitOnFailure(hr, "BA OnCachePayloadExtractProgress failed.");
1160
1161 // Write results.
1162 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1163 ExitOnFailure(hr, "Failed to write size of OnCachePayloadExtractProgress struct.");
1164
1165 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1166 ExitOnFailure(hr, "Failed to write cancel of OnCachePayloadExtractProgress struct.");
1167
1168LExit:
1169 ReleaseStr(sczPayloadId);
1170 ReleaseStr(sczContainerId);
1171 return hr;
1172}
1173
1174static HRESULT OnCacheVerifyBegin(
1175 __in IBootstrapperApplication* pApplication,
1176 __in BUFF_READER* pReaderArgs,
1177 __in BUFF_READER* pReaderResults,
1178 __in BUFF_BUFFER* pBuffer
1179 )
1180{
1181 HRESULT hr = S_OK;
1182 BA_ONCACHEVERIFYBEGIN_ARGS args = { };
1183 BA_ONCACHEVERIFYBEGIN_RESULTS results = { };
1184 LPWSTR sczPackageOrContainerId = NULL;
1185 LPWSTR sczPayloadId = NULL;
1186
1187 // Read args.
1188 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1189 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyBegin args.");
1190
1191 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
1192 ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyBegin args.");
1193
1194 args.wzPackageOrContainerId = sczPackageOrContainerId;
1195
1196 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
1197 ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyBegin args.");
1198
1199 args.wzPayloadId = sczPayloadId;
1200
1201 // Read results.
1202 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1203 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyBegin results.");
1204
1205 // Callback.
1206 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, &args, &results);
1207
1208 if (E_NOTIMPL == hr)
1209 {
1210 hr = pApplication->OnCacheVerifyBegin(args.wzPackageOrContainerId, args.wzPayloadId, &results.fCancel);
1211 }
1212
1213 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, &args, &results, &hr);
1214 BalExitOnFailure(hr, "BA OnCacheVerifyBegin failed.");
1215
1216 // Write results.
1217 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1218 ExitOnFailure(hr, "Failed to write size of OnCacheVerifyBegin struct.");
1219
1220 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1221 ExitOnFailure(hr, "Failed to write cancel of OnCacheVerifyBegin struct.");
1222
1223LExit:
1224 ReleaseStr(sczPayloadId);
1225 ReleaseStr(sczPackageOrContainerId);
1226 return hr;
1227}
1228
1229static HRESULT OnCacheVerifyComplete(
1230 __in IBootstrapperApplication* pApplication,
1231 __in BUFF_READER* pReaderArgs,
1232 __in BUFF_READER* pReaderResults,
1233 __in BUFF_BUFFER* pBuffer
1234 )
1235{
1236 HRESULT hr = S_OK;
1237 BA_ONCACHEVERIFYCOMPLETE_ARGS args = { };
1238 BA_ONCACHEVERIFYCOMPLETE_RESULTS results = { };
1239 LPWSTR sczPackageOrContainerId = NULL;
1240 LPWSTR sczPayloadId = NULL;
1241
1242 // Read args.
1243 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1244 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyComplete args.");
1245
1246 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
1247 ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyComplete args.");
1248
1249 args.wzPackageOrContainerId = sczPackageOrContainerId;
1250
1251 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
1252 ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyComplete args.");
1253
1254 args.wzPayloadId = sczPayloadId;
1255
1256 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
1257 ExitOnFailure(hr, "Failed to read status of OnCacheVerifyComplete args.");
1258
1259 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
1260 ExitOnFailure(hr, "Failed to read recommendation of OnCacheVerifyComplete args.");
1261
1262 // Read results.
1263 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1264 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyComplete results.");
1265
1266 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
1267 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyComplete results.");
1268
1269 // Callback.
1270 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, &args, &results);
1271
1272 if (E_NOTIMPL == hr)
1273 {
1274 hr = pApplication->OnCacheVerifyComplete(args.wzPackageOrContainerId, args.wzPayloadId, args.hrStatus, args.recommendation, &results.action);
1275 }
1276
1277 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, &args, &results, &hr);
1278 BalExitOnFailure(hr, "BA OnCacheVerifyComplete failed.");
1279
1280 // Write results.
1281 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1282 ExitOnFailure(hr, "Failed to write size of OnCacheVerifyComplete struct.");
1283
1284 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
1285 ExitOnFailure(hr, "Failed to write action of OnCacheVerifyComplete struct.");
1286
1287LExit:
1288 ReleaseStr(sczPayloadId);
1289 ReleaseStr(sczPackageOrContainerId);
1290 return hr;
1291}
1292
1293static HRESULT OnCacheVerifyProgress(
1294 __in IBootstrapperApplication* pApplication,
1295 __in BUFF_READER* pReaderArgs,
1296 __in BUFF_READER* pReaderResults,
1297 __in BUFF_BUFFER* pBuffer
1298 )
1299{
1300 HRESULT hr = S_OK;
1301 BA_ONCACHEVERIFYPROGRESS_ARGS args = { };
1302 BA_ONCACHEVERIFYPROGRESS_RESULTS results = { };
1303 LPWSTR sczPackageOrContainerId = NULL;
1304 LPWSTR sczPayloadId = NULL;
1305
1306 // Read args.
1307 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1308 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyProgress args.");
1309
1310 hr = BuffReaderReadString(pReaderArgs, &sczPackageOrContainerId);
1311 ExitOnFailure(hr, "Failed to read package or container id of OnCacheVerifyProgress args.");
1312
1313 args.wzPackageOrContainerId = sczPackageOrContainerId;
1314
1315 hr = BuffReaderReadString(pReaderArgs, &sczPayloadId);
1316 ExitOnFailure(hr, "Failed to read payload id of OnCacheVerifyProgress args.");
1317
1318 args.wzPayloadId = sczPayloadId;
1319
1320 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Progress);
1321 ExitOnFailure(hr, "Failed to read progress of OnCacheVerifyProgress args.");
1322
1323 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Total);
1324 ExitOnFailure(hr, "Failed to read total progress of OnCacheVerifyProgress args.");
1325
1326 hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage);
1327 ExitOnFailure(hr, "Failed to read overall percentage of OnCacheVerifyProgress args.");
1328
1329 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.verifyStep));
1330 ExitOnFailure(hr, "Failed to read verify step of OnCacheVerifyProgress args.");
1331
1332 // Read results.
1333 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1334 ExitOnFailure(hr, "Failed to read API version of OnCacheVerifyProgress results.");
1335
1336 // Callback.
1337 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, &args, &results);
1338
1339 if (E_NOTIMPL == hr)
1340 {
1341 hr = pApplication->OnCacheVerifyProgress(args.wzPackageOrContainerId, args.wzPayloadId, args.dw64Progress, args.dw64Total, args.dwOverallPercentage, args.verifyStep, &results.fCancel);
1342 }
1343
1344 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS, &args, &results, &hr);
1345 BalExitOnFailure(hr, "BA OnCacheVerifyProgress failed.");
1346
1347 // Write results.
1348 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1349 ExitOnFailure(hr, "Failed to write size of OnCacheVerifyProgress struct.");
1350
1351 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1352 ExitOnFailure(hr, "Failed to write cancel of OnCacheVerifyProgress struct.");
1353
1354LExit:
1355 ReleaseStr(sczPayloadId);
1356 ReleaseStr(sczPackageOrContainerId);
1357 return hr;
1358}
1359
1360static HRESULT OnCommitMsiTransactionBegin(
1361 __in IBootstrapperApplication* pApplication,
1362 __in BUFF_READER* pReaderArgs,
1363 __in BUFF_READER* pReaderResults,
1364 __in BUFF_BUFFER* pBuffer
1365 )
1366{
1367 HRESULT hr = S_OK;
1368 BA_ONCOMMITMSITRANSACTIONBEGIN_ARGS args = { };
1369 BA_ONCOMMITMSITRANSACTIONBEGIN_RESULTS results = { };
1370 LPWSTR sczTransactionId = NULL;
1371
1372 // Read args.
1373 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1374 ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionBegin args.");
1375
1376 hr = BuffReaderReadString(pReaderArgs, &sczTransactionId);
1377 ExitOnFailure(hr, "Failed to read transaction id of OnCommitMsiTransactionBegin args.");
1378
1379 args.wzTransactionId = sczTransactionId;
1380
1381 // Read results.
1382 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1383 ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionBegin results.");
1384
1385 // Callback.
1386 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &args, &results);
1387
1388 if (E_NOTIMPL == hr)
1389 {
1390 hr = pApplication->OnCommitMsiTransactionBegin(args.wzTransactionId, &results.fCancel);
1391 }
1392
1393 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN, &args, &results, &hr);
1394 BalExitOnFailure(hr, "BA OnCommitMsiTransactionBegin failed.");
1395
1396 // Write results.
1397 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1398 ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionBegin struct.");
1399
1400 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1401 ExitOnFailure(hr, "Failed to write cancel of OnCommitMsiTransactionBegin struct.");
1402
1403LExit:
1404 ReleaseStr(sczTransactionId);
1405 return hr;
1406}
1407
1408static HRESULT OnCommitMsiTransactionComplete(
1409 __in IBootstrapperApplication* pApplication,
1410 __in BUFF_READER* pReaderArgs,
1411 __in BUFF_READER* pReaderResults,
1412 __in BUFF_BUFFER* pBuffer
1413 )
1414{
1415 HRESULT hr = S_OK;
1416 BA_ONCOMMITMSITRANSACTIONCOMPLETE_ARGS args = { };
1417 BA_ONCOMMITMSITRANSACTIONCOMPLETE_RESULTS results = { };
1418 LPWSTR sczTransactionId = NULL;
1419
1420 // Read args.
1421 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1422 ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionComplete args.");
1423
1424 hr = BuffReaderReadString(pReaderArgs, &sczTransactionId);
1425 ExitOnFailure(hr, "Failed to read transaction id of OnCommitMsiTransactionComplete args.");
1426
1427 args.wzTransactionId = sczTransactionId;
1428
1429 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
1430 ExitOnFailure(hr, "Failed to read status of OnCommitMsiTransactionComplete args.");
1431
1432 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.restart));
1433 ExitOnFailure(hr, "Failed to read restart of OnCommitMsiTransactionComplete args.");
1434
1435 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
1436 ExitOnFailure(hr, "Failed to read recommendation of OnCommitMsiTransactionComplete args.");
1437
1438 // Read results.
1439 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1440 ExitOnFailure(hr, "Failed to read API version of OnCommitMsiTransactionComplete results.");
1441
1442 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
1443 ExitOnFailure(hr, "Failed to read action of OnCommitMsiTransactionComplete results.");
1444
1445 // Callback.
1446 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &args, &results);
1447
1448 if (E_NOTIMPL == hr)
1449 {
1450 hr = pApplication->OnCommitMsiTransactionComplete(args.wzTransactionId, args.hrStatus, args.restart, args.recommendation, &results.action);
1451 }
1452
1453 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE, &args, &results, &hr);
1454 BalExitOnFailure(hr, "BA OnCommitMsiTransactionComplete failed.");
1455
1456 // Write results.
1457 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1458 ExitOnFailure(hr, "Failed to write size of OnCommitMsiTransactionComplete struct.");
1459
1460 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
1461 ExitOnFailure(hr, "Failed to write action of OnCommitMsiTransactionComplete struct.");
1462
1463LExit:
1464 ReleaseStr(sczTransactionId);
1465 return hr;
1466}
1467
1468static HRESULT OnCreate(
1469 __in IBootstrapperApplication* pApplication,
1470 __in IBootstrapperEngine* pEngine,
1471 __in BUFF_READER* pReaderArgs,
1472 __in BUFF_READER* pReaderResults,
1473 __in BUFF_BUFFER* pBuffer
1474 )
1475{
1476 HRESULT hr = S_OK;
1477 BA_ONCREATE_ARGS args = { };
1478 BA_ONCREATE_RESULTS results = { };
1479 LPWSTR sczCommandLine = NULL;
1480 LPWSTR sczLayoutDirectory = NULL;
1481 LPWSTR sczBootstrapperWorkingFolder = NULL;
1482 LPWSTR sczBootstrapperApplicationDataPath = NULL;
1483 DWORD64 dw64 = 0;
1484
1485 // Read args.
1486 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1487 ExitOnFailure(hr, "Failed to read API version of OnCreate args.");
1488
1489 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.cbSize));
1490 ExitOnFailure(hr, "Failed to size of of OnCreate args command.");
1491
1492 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.action));
1493 ExitOnFailure(hr, "Failed to read action of OnCreate args command.");
1494
1495 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.display));
1496 ExitOnFailure(hr, "Failed to read action of OnCreate args command.");
1497
1498 hr = BuffReaderReadString(pReaderArgs, &sczCommandLine);
1499 ExitOnFailure(hr, "Failed to read command-line of OnCreate args command.");
1500
1501 args.command.wzCommandLine = sczCommandLine;
1502
1503 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.nCmdShow));
1504 ExitOnFailure(hr, "Failed to read show command of OnCreate args command.");
1505
1506 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.resumeType));
1507 ExitOnFailure(hr, "Failed to read resume type of OnCreate args command.");
1508
1509 hr = BuffReaderReadNumber64(pReaderArgs, &dw64);
1510 ExitOnFailure(hr, "Failed to read splash screen handle of OnCreate args command.");
1511
1512 args.command.hwndSplashScreen = reinterpret_cast<HWND>(dw64);
1513
1514 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.relationType));
1515 ExitOnFailure(hr, "Failed to read relation type of OnCreate args command.");
1516
1517 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.command.fPassthrough));
1518 ExitOnFailure(hr, "Failed to read passthrough of OnCreate args command.");
1519
1520 hr = BuffReaderReadString(pReaderArgs, &sczLayoutDirectory);
1521 ExitOnFailure(hr, "Failed to read command-line of OnCreate args command.");
1522
1523 args.command.wzLayoutDirectory = sczLayoutDirectory;
1524
1525 hr = BuffReaderReadString(pReaderArgs, &sczBootstrapperWorkingFolder);
1526 ExitOnFailure(hr, "Failed to read command-line of OnCreate args command.");
1527
1528 args.command.wzBootstrapperWorkingFolder = sczBootstrapperWorkingFolder;
1529
1530 hr = BuffReaderReadString(pReaderArgs, &sczBootstrapperApplicationDataPath);
1531 ExitOnFailure(hr, "Failed to read command-line of OnCreate args command.");
1532
1533 args.command.wzBootstrapperApplicationDataPath = sczBootstrapperApplicationDataPath;
1534
1535 // Read results.
1536 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1537 ExitOnFailure(hr, "Failed to read API version of OnCreate results.");
1538
1539 // Callback.
1540 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, &args, &results);
1541
1542 if (E_NOTIMPL == hr)
1543 {
1544 hr = pApplication->OnCreate(pEngine, &args.command);
1545 }
1546
1547 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE, &args, &results, &hr);
1548 BalExitOnFailure(hr, "BA OnCreate failed.");
1549
1550 // Write results.
1551 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1552 ExitOnFailure(hr, "Failed to write size of BA_ONCREATE_RESULTS struct.");
1553
1554LExit:
1555 ReleaseStr(sczBootstrapperApplicationDataPath);
1556 ReleaseStr(sczBootstrapperWorkingFolder);
1557 ReleaseStr(sczLayoutDirectory);
1558 ReleaseStr(sczCommandLine);
1559
1560 return hr;
1561}
1562
1563static HRESULT OnDestroy(
1564 __in IBootstrapperApplication* pApplication,
1565 __in BUFF_READER* pReaderArgs,
1566 __in BUFF_READER* pReaderResults,
1567 __in BUFF_BUFFER* pBuffer
1568 )
1569{
1570 HRESULT hr = S_OK;
1571 BA_ONDESTROY_ARGS args = { };
1572 BA_ONDESTROY_RESULTS results = { };
1573
1574 // Read args.
1575 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1576 ExitOnFailure(hr, "Failed to read API version of OnDestroy args.");
1577
1578 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fReload));
1579 ExitOnFailure(hr, "Failed to read reload of OnDestroy args.");
1580
1581 // Read results.
1582 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1583 ExitOnFailure(hr, "Failed to read API version of OnDestroy results.");
1584
1585 // Callback.
1586 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, &args, &results);
1587
1588 if (E_NOTIMPL == hr)
1589 {
1590 hr = pApplication->OnDestroy(args.fReload);
1591 }
1592
1593 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY, &args, &results, &hr);
1594 BalExitOnFailure(hr, "BA OnDestroy failed.");
1595
1596 // Write results.
1597 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1598 ExitOnFailure(hr, "Failed to write size of OnDestroy struct.");
1599
1600LExit:
1601 return hr;
1602}
1603
1604static HRESULT OnDetectBegin(
1605 __in IBootstrapperApplication* pApplication,
1606 __in BUFF_READER* pReaderArgs,
1607 __in BUFF_READER* pReaderResults,
1608 __in BUFF_BUFFER* pBuffer
1609 )
1610{
1611 HRESULT hr = S_OK;
1612 BA_ONDETECTBEGIN_ARGS args = { };
1613 BA_ONDETECTBEGIN_RESULTS results = { };
1614
1615 // Read args.
1616 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1617 ExitOnFailure(hr, "Failed to read API version of OnDetectBegin args.");
1618
1619 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.registrationType));
1620 ExitOnFailure(hr, "Failed to read registration type of OnDetectBegin args.");
1621
1622 hr = BuffReaderReadNumber(pReaderArgs, &args.cPackages);
1623 ExitOnFailure(hr, "Failed to read package count of OnDetectBegin args.");
1624
1625 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fCached));
1626 ExitOnFailure(hr, "Failed to read cached of OnDetectBegin args.");
1627
1628
1629 // Read results.
1630 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1631 ExitOnFailure(hr, "Failed to read API version of OnDetectBegin results.");
1632
1633 // Callback.
1634 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, &args, &results);
1635
1636 if (E_NOTIMPL == hr)
1637 {
1638 hr = pApplication->OnDetectBegin(args.fCached, args.registrationType, args.cPackages, &results.fCancel);
1639 }
1640
1641 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN, &args, &results, &hr);
1642 BalExitOnFailure(hr, "BA OnDetectBegin failed.");
1643
1644 // Write results.
1645 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1646 ExitOnFailure(hr, "Failed to write size of OnDetectBegin struct.");
1647
1648 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1649 ExitOnFailure(hr, "Failed to write cancel of OnDetectBegin struct.");
1650
1651LExit:
1652 return hr;
1653}
1654
1655static HRESULT OnDetectCompatibleMsiPackage(
1656 __in IBootstrapperApplication* pApplication,
1657 __in BUFF_READER* pReaderArgs,
1658 __in BUFF_READER* pReaderResults,
1659 __in BUFF_BUFFER* pBuffer
1660 )
1661{
1662 HRESULT hr = S_OK;
1663 BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS args = { };
1664 BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS results = { };
1665 LPWSTR sczPackageId = NULL;
1666 LPWSTR sczCompatiblePackageId = NULL;
1667 LPWSTR sczCompatiblePackageVersion = NULL;
1668
1669 // Read args.
1670 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1671 ExitOnFailure(hr, "Failed to read API version of OnDetectCompatibleMsiPackage args.");
1672
1673 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
1674 ExitOnFailure(hr, "Failed to read package id of OnDetectCompatibleMsiPackage args.");
1675
1676 args.wzPackageId = sczPackageId;
1677
1678 hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId);
1679 ExitOnFailure(hr, "Failed to read compatible package id of OnDetectCompatibleMsiPackage args.");
1680
1681 args.wzCompatiblePackageId = sczCompatiblePackageId;
1682
1683 hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageVersion);
1684 ExitOnFailure(hr, "Failed to read compatible package version of OnDetectCompatibleMsiPackage args.");
1685
1686 args.wzCompatiblePackageVersion = sczCompatiblePackageVersion;
1687
1688 // Read results.
1689 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1690 ExitOnFailure(hr, "Failed to read API version of OnDetectCompatibleMsiPackage results.");
1691
1692 // Callback.
1693 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, &args, &results);
1694
1695 if (E_NOTIMPL == hr)
1696 {
1697 hr = pApplication->OnDetectCompatibleMsiPackage(args.wzPackageId, args.wzCompatiblePackageId, args.wzCompatiblePackageVersion, &results.fCancel);
1698 }
1699
1700 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE, &args, &results, &hr);
1701 BalExitOnFailure(hr, "BA OnDetectCompatibleMsiPackage failed.");
1702
1703 // Write results.
1704 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1705 ExitOnFailure(hr, "Failed to write size of OnDetectCompatibleMsiPackage struct.");
1706
1707 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1708 ExitOnFailure(hr, "Failed to write cancel of OnDetectCompatibleMsiPackage struct.");
1709
1710LExit:
1711 ReleaseStr(sczCompatiblePackageVersion);
1712 ReleaseStr(sczCompatiblePackageId);
1713 ReleaseStr(sczPackageId);
1714 return hr;
1715}
1716
1717static HRESULT OnDetectComplete(
1718 __in IBootstrapperApplication* pApplication,
1719 __in BUFF_READER* pReaderArgs,
1720 __in BUFF_READER* pReaderResults,
1721 __in BUFF_BUFFER* pBuffer
1722 )
1723{
1724 HRESULT hr = S_OK;
1725 BA_ONDETECTCOMPLETE_ARGS args = { };
1726 BA_ONDETECTCOMPLETE_RESULTS results = { };
1727
1728 // Read args.
1729 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1730 ExitOnFailure(hr, "Failed to read API version of OnDetectComplete args.");
1731
1732 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
1733 ExitOnFailure(hr, "Failed to read status of OnDetectComplete args.");
1734
1735 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fEligibleForCleanup));
1736 ExitOnFailure(hr, "Failed to read eligible for cleanup of OnDetectComplete args.");
1737
1738 // Read results.
1739 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1740 ExitOnFailure(hr, "Failed to read API version of OnDetectComplete results.");
1741
1742 // Callback.
1743 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, &args, &results);
1744
1745 if (E_NOTIMPL == hr)
1746 {
1747 hr = pApplication->OnDetectComplete(args.hrStatus, args.fEligibleForCleanup);
1748 }
1749
1750 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE, &args, &results, &hr);
1751 BalExitOnFailure(hr, "BA OnDetectComplete failed.");
1752
1753 // Write results.
1754 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1755 ExitOnFailure(hr, "Failed to write size of OnDetectComplete struct.");
1756
1757LExit:
1758 return hr;
1759}
1760
1761static HRESULT OnDetectForwardCompatibleBundle(
1762 __in IBootstrapperApplication* pApplication,
1763 __in BUFF_READER* pReaderArgs,
1764 __in BUFF_READER* pReaderResults,
1765 __in BUFF_BUFFER* pBuffer
1766 )
1767{
1768 HRESULT hr = S_OK;
1769 BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_ARGS args = { };
1770 BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS results = { };
1771 LPWSTR sczBundleId = NULL;
1772 LPWSTR sczBundleTag = NULL;
1773 LPWSTR sczVersion = NULL;
1774
1775 // Read args.
1776 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1777 ExitOnFailure(hr, "Failed to read API version of OnDetectForwardCompatibleBundle args.");
1778
1779 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
1780 ExitOnFailure(hr, "Failed to read bundle id of OnDetectForwardCompatibleBundle args.");
1781
1782 args.wzBundleId = sczBundleId;
1783
1784 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.relationType));
1785 ExitOnFailure(hr, "Failed to read relation type of OnDetectForwardCompatibleBundle args.");
1786
1787 hr = BuffReaderReadString(pReaderArgs, &sczBundleTag);
1788 ExitOnFailure(hr, "Failed to read bundle tag of OnDetectForwardCompatibleBundle args.");
1789
1790 args.wzBundleTag = sczBundleTag;
1791
1792 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPerMachine));
1793 ExitOnFailure(hr, "Failed to read per-machine of OnDetectForwardCompatibleBundle args.");
1794
1795 hr = BuffReaderReadString(pReaderArgs, &sczVersion);
1796 ExitOnFailure(hr, "Failed to read version of OnDetectForwardCompatibleBundle args.");
1797
1798 args.wzVersion = sczVersion;
1799
1800 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fMissingFromCache));
1801 ExitOnFailure(hr, "Failed to read missing from cache of OnDetectForwardCompatibleBundle args.");
1802
1803 // Read results.
1804 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1805 ExitOnFailure(hr, "Failed to read API version of OnDetectForwardCompatibleBundle results.");
1806
1807 // Callback.
1808 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, &args, &results);
1809
1810 if (E_NOTIMPL == hr)
1811 {
1812 hr = pApplication->OnDetectForwardCompatibleBundle(args.wzBundleId, args.relationType, args.wzBundleTag, args.fPerMachine, args.wzVersion, args.fMissingFromCache, &results.fCancel);
1813 }
1814
1815 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE, &args, &results, &hr);
1816 BalExitOnFailure(hr, "BA OnDetectForwardCompatibleBundle failed.");
1817
1818 // Write results.
1819 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1820 ExitOnFailure(hr, "Failed to write size of OnDetectForwardCompatibleBundle struct.");
1821
1822 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1823 ExitOnFailure(hr, "Failed to write cancel of OnDetectForwardCompatibleBundle struct.");
1824
1825LExit:
1826 ReleaseStr(sczVersion);
1827 ReleaseStr(sczBundleTag);
1828 ReleaseStr(sczBundleId);
1829 return hr;
1830}
1831
1832static HRESULT OnDetectMsiFeature(
1833 __in IBootstrapperApplication* pApplication,
1834 __in BUFF_READER* pReaderArgs,
1835 __in BUFF_READER* pReaderResults,
1836 __in BUFF_BUFFER* pBuffer
1837 )
1838{
1839 HRESULT hr = S_OK;
1840 BA_ONDETECTMSIFEATURE_ARGS args = { };
1841 BA_ONDETECTMSIFEATURE_RESULTS results = { };
1842 LPWSTR sczPackageId = NULL;
1843 LPWSTR sczFeatureId = NULL;
1844
1845 // Read args.
1846 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1847 ExitOnFailure(hr, "Failed to read API version of OnDetectMsiFeature args.");
1848
1849 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
1850 ExitOnFailure(hr, "Failed to read package id of OnDetectMsiFeature args.");
1851
1852 args.wzPackageId = sczPackageId;
1853
1854 hr = BuffReaderReadString(pReaderArgs, &sczFeatureId);
1855 ExitOnFailure(hr, "Failed to read feature id of OnDetectMsiFeature args.");
1856
1857 args.wzFeatureId = sczFeatureId;
1858
1859 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.state));
1860 ExitOnFailure(hr, "Failed to read state of OnDetectMsiFeature args.");
1861
1862 // Read results.
1863 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1864 ExitOnFailure(hr, "Failed to read API version of OnDetectMsiFeature results.");
1865
1866 // Callback.
1867 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, &args, &results);
1868
1869 if (E_NOTIMPL == hr)
1870 {
1871 hr = pApplication->OnDetectMsiFeature(args.wzPackageId, args.wzFeatureId, args.state, &results.fCancel);
1872 }
1873
1874 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE, &args, &results, &hr);
1875 BalExitOnFailure(hr, "BA OnDetectMsiFeature failed.");
1876
1877 // Write results.
1878 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1879 ExitOnFailure(hr, "Failed to write size of OnDetectMsiFeature struct.");
1880
1881 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1882 ExitOnFailure(hr, "Failed to write cancel of OnDetectMsiFeature struct.");
1883
1884LExit:
1885 ReleaseStr(sczFeatureId);
1886 ReleaseStr(sczPackageId);
1887 return hr;
1888}
1889
1890static HRESULT OnDetectPackageBegin(
1891 __in IBootstrapperApplication* pApplication,
1892 __in BUFF_READER* pReaderArgs,
1893 __in BUFF_READER* pReaderResults,
1894 __in BUFF_BUFFER* pBuffer
1895 )
1896{
1897 HRESULT hr = S_OK;
1898 BA_ONDETECTPACKAGEBEGIN_ARGS args = { };
1899 BA_ONDETECTPACKAGEBEGIN_RESULTS results = { };
1900 LPWSTR sczPackageId = NULL;
1901
1902 // Read args.
1903 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1904 ExitOnFailure(hr, "Failed to read API version of OnDetectPackageBegin args.");
1905
1906 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
1907 ExitOnFailure(hr, "Failed to read package id of OnDetectPackageBegin args.");
1908
1909 args.wzPackageId = sczPackageId;
1910
1911 // Read results.
1912 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1913 ExitOnFailure(hr, "Failed to read API version of OnDetectPackageBegin results.");
1914
1915 // Callback.
1916 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, &args, &results);
1917
1918 if (E_NOTIMPL == hr)
1919 {
1920 hr = pApplication->OnDetectPackageBegin(args.wzPackageId, &results.fCancel);
1921 }
1922
1923 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN, &args, &results, &hr);
1924 BalExitOnFailure(hr, "BA OnDetectPackageBegin failed.");
1925
1926 // Write results.
1927 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1928 ExitOnFailure(hr, "Failed to write size of OnDetectPackageBegin struct.");
1929
1930 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
1931 ExitOnFailure(hr, "Failed to write cancel of OnDetectPackageBegin struct.");
1932
1933LExit:
1934 ReleaseStr(sczPackageId);
1935 return hr;
1936}
1937
1938static HRESULT OnDetectPackageComplete(
1939 __in IBootstrapperApplication* pApplication,
1940 __in BUFF_READER* pReaderArgs,
1941 __in BUFF_READER* pReaderResults,
1942 __in BUFF_BUFFER* pBuffer
1943 )
1944{
1945 HRESULT hr = S_OK;
1946 BA_ONDETECTPACKAGECOMPLETE_ARGS args = { };
1947 BA_ONDETECTPACKAGECOMPLETE_RESULTS results = { };
1948 LPWSTR sczPackageId = NULL;
1949
1950 // Read args.
1951 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
1952 ExitOnFailure(hr, "Failed to read API version of OnDetectPackageComplete args.");
1953
1954 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
1955 ExitOnFailure(hr, "Failed to read package id of OnDetectPackageComplete args.");
1956
1957 args.wzPackageId = sczPackageId;
1958
1959 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
1960 ExitOnFailure(hr, "Failed to read status of OnDetectPackageComplete args.");
1961
1962 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.state));
1963 ExitOnFailure(hr, "Failed to read state of OnDetectPackageComplete args.");
1964
1965 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fCached));
1966 ExitOnFailure(hr, "Failed to read cached of OnDetectPackageComplete args.");
1967
1968 // Read results.
1969 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
1970 ExitOnFailure(hr, "Failed to read API version of OnDetectPackageComplete results.");
1971
1972 // Callback.
1973 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, &args, &results);
1974
1975 if (E_NOTIMPL == hr)
1976 {
1977 hr = pApplication->OnDetectPackageComplete(args.wzPackageId, args.hrStatus, args.state, args.fCached);
1978 }
1979
1980 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE, &args, &results, &hr);
1981 BalExitOnFailure(hr, "BA OnDetectPackageComplete failed.");
1982
1983 // Write results.
1984 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
1985 ExitOnFailure(hr, "Failed to write size of OnDetectPackageComplete struct.");
1986
1987LExit:
1988 ReleaseStr(sczPackageId);
1989 return hr;
1990}
1991
1992static HRESULT OnDetectRelatedBundle(
1993 __in IBootstrapperApplication* pApplication,
1994 __in BUFF_READER* pReaderArgs,
1995 __in BUFF_READER* pReaderResults,
1996 __in BUFF_BUFFER* pBuffer
1997 )
1998{
1999 HRESULT hr = S_OK;
2000 BA_ONDETECTRELATEDBUNDLE_ARGS args = { };
2001 BA_ONDETECTRELATEDBUNDLE_RESULTS results = { };
2002 LPWSTR sczBundleId = NULL;
2003 LPWSTR sczBundleTag = NULL;
2004 LPWSTR sczVersion = NULL;
2005
2006 // Read args.
2007 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2008 ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundle args.");
2009
2010 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
2011 ExitOnFailure(hr, "Failed to read bundle id of OnDetectRelatedBundle args.");
2012
2013 args.wzBundleId = sczBundleId;
2014
2015 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.relationType));
2016 ExitOnFailure(hr, "Failed to read relation type of OnDetectRelatedBundle args.");
2017
2018 hr = BuffReaderReadString(pReaderArgs, &sczBundleTag);
2019 ExitOnFailure(hr, "Failed to read bundle tag of OnDetectRelatedBundle args.");
2020
2021 args.wzBundleTag = sczBundleTag;
2022
2023 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPerMachine));
2024 ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedBundle args.");
2025
2026 hr = BuffReaderReadString(pReaderArgs, &sczVersion);
2027 ExitOnFailure(hr, "Failed to read version of OnDetectRelatedBundle args.");
2028
2029 args.wzVersion = sczVersion;
2030
2031 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fMissingFromCache));
2032 ExitOnFailure(hr, "Failed to read missing from cache of OnDetectRelatedBundle args.");
2033
2034 // Read results.
2035 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2036 ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundle results.");
2037
2038 // Callback.
2039 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, &args, &results);
2040
2041 if (E_NOTIMPL == hr)
2042 {
2043 hr = pApplication->OnDetectRelatedBundle(args.wzBundleId, args.relationType, args.wzBundleTag, args.fPerMachine, args.wzVersion, args.fMissingFromCache, &results.fCancel);
2044 }
2045
2046 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE, &args, &results, &hr);
2047 BalExitOnFailure(hr, "BA OnDetectRelatedBundle failed.");
2048
2049 // Write results.
2050 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2051 ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundle struct.");
2052
2053 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2054 ExitOnFailure(hr, "Failed to write cancel of OnDetectRelatedBundle struct.");
2055
2056LExit:
2057 ReleaseStr(sczVersion);
2058 ReleaseStr(sczBundleTag);
2059 ReleaseStr(sczBundleId);
2060 return hr;
2061}
2062
2063static HRESULT OnDetectRelatedBundlePackage(
2064 __in IBootstrapperApplication* pApplication,
2065 __in BUFF_READER* pReaderArgs,
2066 __in BUFF_READER* pReaderResults,
2067 __in BUFF_BUFFER* pBuffer
2068 )
2069{
2070 HRESULT hr = S_OK;
2071 BA_ONDETECTRELATEDBUNDLEPACKAGE_ARGS args = { };
2072 BA_ONDETECTRELATEDBUNDLEPACKAGE_RESULTS results = { };
2073 LPWSTR sczPackageId = NULL;
2074 LPWSTR sczBundleId = NULL;
2075 LPWSTR sczVersion = NULL;
2076
2077 // Read args.
2078 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2079 ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundlePackage args.");
2080
2081 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2082 ExitOnFailure(hr, "Failed to read package id of OnDetectRelatedBundlePackage args.");
2083
2084 args.wzPackageId = sczPackageId;
2085
2086 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
2087 ExitOnFailure(hr, "Failed to read bundle id of OnDetectRelatedBundlePackage args.");
2088
2089 args.wzBundleId = sczBundleId;
2090
2091 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.relationType));
2092 ExitOnFailure(hr, "Failed to read relation type of OnDetectRelatedBundlePackage args.");
2093
2094 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPerMachine));
2095 ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedBundlePackage args.");
2096
2097 hr = BuffReaderReadString(pReaderArgs, &sczVersion);
2098 ExitOnFailure(hr, "Failed to read version of OnDetectRelatedBundlePackage args.");
2099
2100 args.wzVersion = sczVersion;
2101
2102 // Read results.
2103 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2104 ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedBundlePackage results.");
2105
2106 // Callback.
2107 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, &args, &results);
2108
2109 if (E_NOTIMPL == hr)
2110 {
2111 hr = pApplication->OnDetectRelatedBundlePackage(args.wzPackageId, args.wzBundleId, args.relationType, args.fPerMachine, args.wzVersion, &results.fCancel);
2112 }
2113
2114 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE, &args, &results, &hr);
2115 BalExitOnFailure(hr, "BA OnDetectRelatedBundlePackage failed.");
2116
2117 // Write results.
2118 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2119 ExitOnFailure(hr, "Failed to write size of OnDetectRelatedBundlePackage struct.");
2120
2121 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2122 ExitOnFailure(hr, "Failed to write cancel of OnDetectRelatedBundlePackage struct.");
2123
2124LExit:
2125 ReleaseStr(sczVersion);
2126 ReleaseStr(sczBundleId);
2127 ReleaseStr(sczPackageId);
2128 return hr;
2129}
2130
2131static HRESULT OnDetectRelatedMsiPackage(
2132 __in IBootstrapperApplication* pApplication,
2133 __in BUFF_READER* pReaderArgs,
2134 __in BUFF_READER* pReaderResults,
2135 __in BUFF_BUFFER* pBuffer
2136 )
2137{
2138 HRESULT hr = S_OK;
2139 BA_ONDETECTRELATEDMSIPACKAGE_ARGS args = { };
2140 BA_ONDETECTRELATEDMSIPACKAGE_RESULTS results = { };
2141 LPWSTR sczPackageId = NULL;
2142 LPWSTR sczUpgradeCode = NULL;
2143 LPWSTR sczProductCode = NULL;
2144 LPWSTR sczVersion = NULL;
2145
2146 // Read args.
2147 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2148 ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedMsiPackage args.");
2149
2150 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2151 ExitOnFailure(hr, "Failed to read package id of OnDetectRelatedMsiPackage args.");
2152
2153 args.wzPackageId = sczPackageId;
2154
2155 hr = BuffReaderReadString(pReaderArgs, &sczUpgradeCode);
2156 ExitOnFailure(hr, "Failed to read upgrade code of OnDetectRelatedMsiPackage args.");
2157
2158 args.wzUpgradeCode = sczUpgradeCode;
2159
2160 hr = BuffReaderReadString(pReaderArgs, &sczProductCode);
2161 ExitOnFailure(hr, "Failed to read product code of OnDetectRelatedMsiPackage args.");
2162
2163 args.wzProductCode = sczProductCode;
2164
2165 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPerMachine));
2166 ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedMsiPackage args.");
2167
2168 hr = BuffReaderReadString(pReaderArgs, &sczVersion);
2169 ExitOnFailure(hr, "Failed to read version of OnDetectRelatedMsiPackage args.");
2170
2171 args.wzVersion = sczVersion;
2172
2173 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.operation));
2174 ExitOnFailure(hr, "Failed to read per-machine of OnDetectRelatedMsiPackage args.");
2175
2176 // Read results.
2177 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2178 ExitOnFailure(hr, "Failed to read API version of OnDetectRelatedMsiPackage results.");
2179
2180 // Callback.
2181 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, &args, &results);
2182
2183 if (E_NOTIMPL == hr)
2184 {
2185 hr = pApplication->OnDetectRelatedMsiPackage(args.wzPackageId, args.wzUpgradeCode, args.wzProductCode, args.fPerMachine, args.wzVersion, args.operation, &results.fCancel);
2186 }
2187
2188 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE, &args, &results, &hr);
2189 BalExitOnFailure(hr, "BA OnDetectRelatedMsiPackage failed.");
2190
2191 // Write results.
2192 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2193 ExitOnFailure(hr, "Failed to write size of OnDetectRelatedMsiPackage struct.");
2194
2195 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2196 ExitOnFailure(hr, "Failed to write cancel of OnDetectRelatedMsiPackage struct.");
2197
2198LExit:
2199 ReleaseStr(sczVersion);
2200 ReleaseStr(sczProductCode);
2201 ReleaseStr(sczUpgradeCode);
2202 ReleaseStr(sczPackageId);
2203 return hr;
2204}
2205
2206static HRESULT OnDetectPatchTarget(
2207 __in IBootstrapperApplication* pApplication,
2208 __in BUFF_READER* pReaderArgs,
2209 __in BUFF_READER* pReaderResults,
2210 __in BUFF_BUFFER* pBuffer
2211 )
2212{
2213 HRESULT hr = S_OK;
2214 BA_ONDETECTPATCHTARGET_ARGS args = { };
2215 BA_ONDETECTPATCHTARGET_RESULTS results = { };
2216 LPWSTR sczPackageId = NULL;
2217 LPWSTR sczProductCode = NULL;
2218
2219 // Read args.
2220 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2221 ExitOnFailure(hr, "Failed to read API version of OnDetectPatchTarget args.");
2222
2223 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2224 ExitOnFailure(hr, "Failed to read package id of OnDetectPatchTarget args.");
2225
2226 args.wzPackageId = sczPackageId;
2227
2228 hr = BuffReaderReadString(pReaderArgs, &sczProductCode);
2229 ExitOnFailure(hr, "Failed to read product code of OnDetectPatchTarget args.");
2230
2231 args.wzProductCode = sczProductCode;
2232
2233 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.patchState));
2234 ExitOnFailure(hr, "Failed to read patch state of OnDetectPatchTarget args.");
2235
2236 // Read results.
2237 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2238 ExitOnFailure(hr, "Failed to read API version of OnDetectPatchTarget results.");
2239
2240 // Callback.
2241 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, &args, &results);
2242
2243 if (E_NOTIMPL == hr)
2244 {
2245 hr = pApplication->OnDetectPatchTarget(args.wzPackageId, args.wzProductCode, args.patchState, &results.fCancel);
2246 }
2247
2248 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET, &args, &results, &hr);
2249 BalExitOnFailure(hr, "BA OnDetectPatchTarget failed.");
2250
2251 // Write results.
2252 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2253 ExitOnFailure(hr, "Failed to write size of OnDetectPatchTarget struct.");
2254
2255 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2256 ExitOnFailure(hr, "Failed to write cancel of OnDetectPatchTarget struct.");
2257
2258LExit:
2259 ReleaseStr(sczProductCode);
2260 ReleaseStr(sczPackageId);
2261 return hr;
2262}
2263
2264static HRESULT OnDetectUpdate(
2265 __in IBootstrapperApplication* pApplication,
2266 __in BUFF_READER* pReaderArgs,
2267 __in BUFF_READER* pReaderResults,
2268 __in BUFF_BUFFER* pBuffer
2269 )
2270{
2271 HRESULT hr = S_OK;
2272 BA_ONDETECTUPDATE_ARGS args = { };
2273 BA_ONDETECTUPDATE_RESULTS results = { };
2274 LPWSTR sczUpdateLocation = NULL;
2275 LPWSTR sczHash = NULL;
2276 LPWSTR sczVersion = NULL;
2277 LPWSTR sczTitle = NULL;
2278 LPWSTR sczSummary = NULL;
2279 LPWSTR sczContentType = NULL;
2280 LPWSTR sczContent = NULL;
2281
2282 // Read args.
2283 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2284 ExitOnFailure(hr, "Failed to read API version of OnDetectUpdate args.");
2285
2286 hr = BuffReaderReadString(pReaderArgs, &sczUpdateLocation);
2287 ExitOnFailure(hr, "Failed to read update location of OnDetectUpdate args.");
2288
2289 args.wzUpdateLocation = sczUpdateLocation;
2290
2291 hr = BuffReaderReadNumber64(pReaderArgs, &args.dw64Size);
2292 ExitOnFailure(hr, "Failed to read update size of OnDetectUpdate args.");
2293
2294 hr = BuffReaderReadString(pReaderArgs, &sczHash);
2295 ExitOnFailure(hr, "Failed to read hash of OnDetectUpdate args.");
2296
2297 args.wzHash = sczHash;
2298
2299 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hashAlgorithm));
2300 ExitOnFailure(hr, "Failed to read hash algorithm of OnDetectUpdate args.");
2301
2302 hr = BuffReaderReadString(pReaderArgs, &sczVersion);
2303 ExitOnFailure(hr, "Failed to read version of OnDetectUpdate args.");
2304
2305 args.wzVersion = sczVersion;
2306
2307 hr = BuffReaderReadString(pReaderArgs, &sczTitle);
2308 ExitOnFailure(hr, "Failed to read title of OnDetectUpdate args.");
2309
2310 args.wzTitle = sczTitle;
2311
2312 hr = BuffReaderReadString(pReaderArgs, &sczSummary);
2313 ExitOnFailure(hr, "Failed to read summary of OnDetectUpdate args.");
2314
2315 args.wzSummary = sczSummary;
2316
2317 hr = BuffReaderReadString(pReaderArgs, &sczContentType);
2318 ExitOnFailure(hr, "Failed to read content type of OnDetectUpdate args.");
2319
2320 args.wzContentType = sczContentType;
2321
2322 hr = BuffReaderReadString(pReaderArgs, &sczContent);
2323 ExitOnFailure(hr, "Failed to read content of OnDetectUpdate args.");
2324
2325 args.wzContent = sczContent;
2326
2327 // Read results.
2328 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2329 ExitOnFailure(hr, "Failed to read API version of OnDetectUpdate results.");
2330
2331 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fStopProcessingUpdates));
2332 ExitOnFailure(hr, "Failed to read stop processing updates of OnDetectUpdate results.");
2333
2334 // Callback.
2335 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &args, &results);
2336
2337 if (E_NOTIMPL == hr)
2338 {
2339 hr = pApplication->OnDetectUpdate(args.wzUpdateLocation, args.dw64Size, args.wzHash, args.hashAlgorithm, args.wzVersion, args.wzTitle, args.wzSummary, args.wzContentType, args.wzContent, &results.fCancel, &results.fStopProcessingUpdates);
2340 }
2341
2342 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &args, &results, &hr);
2343 BalExitOnFailure(hr, "BA OnDetectUpdate failed.");
2344
2345 // Write results.
2346 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2347 ExitOnFailure(hr, "Failed to write size of OnDetectUpdate struct.");
2348
2349 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2350 ExitOnFailure(hr, "Failed to write cancel of OnDetectUpdate struct.");
2351
2352 hr = BuffWriteNumberToBuffer(pBuffer, results.fStopProcessingUpdates);
2353 ExitOnFailure(hr, "Failed to write stop processing updates of OnDetectUpdate struct.");
2354
2355LExit:
2356 ReleaseStr(sczContent);
2357 ReleaseStr(sczContentType);
2358 ReleaseStr(sczSummary);
2359 ReleaseStr(sczTitle);
2360 ReleaseStr(sczVersion);
2361 ReleaseStr(sczHash);
2362 ReleaseStr(sczUpdateLocation);
2363 return hr;
2364}
2365
2366static HRESULT OnDetectUpdateBegin(
2367 __in IBootstrapperApplication* pApplication,
2368 __in BUFF_READER* pReaderArgs,
2369 __in BUFF_READER* pReaderResults,
2370 __in BUFF_BUFFER* pBuffer
2371 )
2372{
2373 HRESULT hr = S_OK;
2374 BA_ONDETECTUPDATEBEGIN_ARGS args = { };
2375 BA_ONDETECTUPDATEBEGIN_RESULTS results = { };
2376 LPWSTR sczUpdateLocation = NULL;
2377
2378 // Read args.
2379 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2380 ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateBegin args.");
2381
2382 hr = BuffReaderReadString(pReaderArgs, &sczUpdateLocation);
2383 ExitOnFailure(hr, "Failed to read update location of OnDetectUpdateBegin args.");
2384
2385 args.wzUpdateLocation = sczUpdateLocation;
2386
2387 // Read results.
2388 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2389 ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateBegin results.");
2390
2391 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fSkip));
2392 ExitOnFailure(hr, "Failed to read skip of OnDetectUpdateBegin results.");
2393
2394 // Callback.
2395 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, &args, &results);
2396
2397 if (E_NOTIMPL == hr)
2398 {
2399 hr = pApplication->OnDetectUpdateBegin(args.wzUpdateLocation, &results.fCancel, &results.fSkip);
2400 }
2401
2402 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN, &args, &results, &hr);
2403 BalExitOnFailure(hr, "BA OnDetectUpdateBegin failed.");
2404
2405 // Write results.
2406 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2407 ExitOnFailure(hr, "Failed to write size of OnDetectUpdateBegin struct.");
2408
2409 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2410 ExitOnFailure(hr, "Failed to write cancel of OnDetectUpdateBegin struct.");
2411
2412 hr = BuffWriteNumberToBuffer(pBuffer, results.fSkip);
2413 ExitOnFailure(hr, "Failed to write skip processing updates of OnDetectUpdateBegin struct.");
2414
2415LExit:
2416 ReleaseStr(sczUpdateLocation);
2417 return hr;
2418}
2419
2420
2421static HRESULT OnDetectUpdateComplete(
2422 __in IBootstrapperApplication* pApplication,
2423 __in BUFF_READER* pReaderArgs,
2424 __in BUFF_READER* pReaderResults,
2425 __in BUFF_BUFFER* pBuffer
2426 )
2427{
2428 HRESULT hr = S_OK;
2429 BA_ONDETECTUPDATECOMPLETE_ARGS args = { };
2430 BA_ONDETECTUPDATECOMPLETE_RESULTS results = { };
2431 LPWSTR sczUpdateLocation = NULL;
2432
2433 // Read args.
2434 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2435 ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateComplete args.");
2436
2437 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
2438 ExitOnFailure(hr, "Failed to read status of OnDetectUpdateComplete args.");
2439
2440 // Read results.
2441 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2442 ExitOnFailure(hr, "Failed to read API version of OnDetectUpdateComplete results.");
2443
2444 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fIgnoreError));
2445 ExitOnFailure(hr, "Failed to read ignore error of OnDetectUpdateComplete results.");
2446
2447 // Callback.
2448 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, &args, &results);
2449
2450 if (E_NOTIMPL == hr)
2451 {
2452 hr = pApplication->OnDetectUpdateComplete(args.hrStatus, &results.fIgnoreError);
2453 }
2454
2455 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE, &args, &results, &hr);
2456 BalExitOnFailure(hr, "BA OnDetectUpdateComplete failed.");
2457
2458 // Write results.
2459 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2460 ExitOnFailure(hr, "Failed to write size of OnDetectUpdateComplete struct.");
2461
2462 hr = BuffWriteNumberToBuffer(pBuffer, results.fIgnoreError);
2463 ExitOnFailure(hr, "Failed to write ignore error of OnDetectUpdateComplete struct.");
2464
2465LExit:
2466 ReleaseStr(sczUpdateLocation);
2467 return hr;
2468}
2469
2470static HRESULT OnElevateBegin(
2471 __in IBootstrapperApplication* pApplication,
2472 __in BUFF_READER* pReaderArgs,
2473 __in BUFF_READER* pReaderResults,
2474 __in BUFF_BUFFER* pBuffer
2475 )
2476{
2477 HRESULT hr = S_OK;
2478 BA_ONELEVATEBEGIN_ARGS args = { };
2479 BA_ONELEVATEBEGIN_RESULTS results = { };
2480
2481 // Read args.
2482 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2483 ExitOnFailure(hr, "Failed to read API version of OnElevateBegin args.");
2484
2485 // Read results.
2486 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2487 ExitOnFailure(hr, "Failed to read API version of OnElevateBegin results.");
2488
2489 // Callback.
2490 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, &args, &results);
2491
2492 if (E_NOTIMPL == hr)
2493 {
2494 hr = pApplication->OnElevateBegin(&results.fCancel);
2495 }
2496
2497 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN, &args, &results, &hr);
2498 BalExitOnFailure(hr, "BA OnElevateBegin failed.");
2499
2500 // Write results.
2501 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2502 ExitOnFailure(hr, "Failed to write size of OnElevateBegin struct.");
2503
2504 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2505 ExitOnFailure(hr, "Failed to write cancel of OnElevateBegin struct.");
2506
2507LExit:
2508 return hr;
2509}
2510
2511static HRESULT OnElevateComplete(
2512 __in IBootstrapperApplication* pApplication,
2513 __in BUFF_READER* pReaderArgs,
2514 __in BUFF_READER* pReaderResults,
2515 __in BUFF_BUFFER* pBuffer
2516 )
2517{
2518 HRESULT hr = S_OK;
2519 BA_ONELEVATECOMPLETE_ARGS args = { };
2520 BA_ONELEVATECOMPLETE_RESULTS results = { };
2521
2522 // Read args.
2523 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2524 ExitOnFailure(hr, "Failed to read API version of OnElevateComplete args.");
2525
2526 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
2527 ExitOnFailure(hr, "Failed to read status of OnElevateComplete args.");
2528
2529 // Read results.
2530 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2531 ExitOnFailure(hr, "Failed to read API version of OnElevateComplete results.");
2532
2533 // Callback.
2534 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, &args, &results);
2535
2536 if (E_NOTIMPL == hr)
2537 {
2538 hr = pApplication->OnElevateComplete(args.hrStatus);
2539 }
2540
2541 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE, &args, &results, &hr);
2542 BalExitOnFailure(hr, "BA OnElevateComplete failed.");
2543
2544 // Write results.
2545 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2546 ExitOnFailure(hr, "Failed to write size of OnElevateComplete struct.");
2547
2548LExit:
2549 return hr;
2550}
2551
2552static HRESULT OnError(
2553 __in IBootstrapperApplication* pApplication,
2554 __in BUFF_READER* pReaderArgs,
2555 __in BUFF_READER* pReaderResults,
2556 __in BUFF_BUFFER* pBuffer
2557 )
2558{
2559 HRESULT hr = S_OK;
2560 BA_ONERROR_ARGS args = { };
2561 BA_ONERROR_RESULTS results = { };
2562 LPWSTR sczPackageId = NULL;
2563 LPWSTR sczError = NULL;
2564 DWORD cData = 0;
2565 LPWSTR* rgsczData = NULL;
2566
2567 // Read args.
2568 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2569 ExitOnFailure(hr, "Failed to read API version of OnError args.");
2570
2571 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.errorType));
2572 ExitOnFailure(hr, "Failed to read error type of OnError args.");
2573
2574 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2575 ExitOnFailure(hr, "Failed to read package id of OnError args.");
2576
2577 args.wzPackageId = sczPackageId;
2578
2579 hr = BuffReaderReadNumber(pReaderArgs, &args.dwCode);
2580 ExitOnFailure(hr, "Failed to read code of OnError args.");
2581
2582 hr = BuffReaderReadString(pReaderArgs, &sczError);
2583 ExitOnFailure(hr, "Failed to read error of OnError args.");
2584
2585 args.wzError = sczError;
2586
2587 hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint);
2588 ExitOnFailure(hr, "Failed to read UI hint of OnError args.");
2589
2590 hr = BuffReaderReadNumber(pReaderArgs, &cData);
2591 ExitOnFailure(hr, "Failed to read count of data of OnError args.");
2592
2593 if (cData)
2594 {
2595 rgsczData = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cData, TRUE));
2596 ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnError args.");
2597
2598 for (DWORD i = 0; i < cData; ++i)
2599 {
2600 hr = BuffReaderReadString(pReaderArgs, &rgsczData[i]);
2601 ExitOnFailure(hr, "Failed to read search path[%u] of OnError args.", i);
2602 }
2603 }
2604
2605 args.cData = cData;
2606 args.rgwzData = const_cast<LPCWSTR*>(rgsczData);
2607
2608 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.nRecommendation));
2609 ExitOnFailure(hr, "Failed to read recommendation of OnError args.");
2610
2611 // Read results.
2612 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2613 ExitOnFailure(hr, "Failed to read API version of OnError results.");
2614
2615 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.nResult));
2616 ExitOnFailure(hr, "Failed to read cancel of OnError results.");
2617
2618 // Callback.
2619 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, &args, &results);
2620
2621 if (E_NOTIMPL == hr)
2622 {
2623 hr = pApplication->OnError(args.errorType, args.wzPackageId, args.dwCode, args.wzError, args.dwUIHint, args.cData, args.rgwzData, args.nRecommendation, &results.nResult);
2624 }
2625
2626 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR, &args, &results, &hr);
2627 BalExitOnFailure(hr, "BA OnError failed.");
2628
2629 // Write results.
2630 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2631 ExitOnFailure(hr, "Failed to write size of OnError struct.");
2632
2633 hr = BuffWriteNumberToBuffer(pBuffer, results.nResult);
2634 ExitOnFailure(hr, "Failed to write result of OnError struct.");
2635
2636LExit:
2637 for (DWORD i = 0; rgsczData && i < cData; ++i)
2638 {
2639 ReleaseStr(rgsczData[i]);
2640 }
2641 ReleaseMem(rgsczData);
2642
2643 ReleaseStr(sczError);
2644 ReleaseStr(sczPackageId);
2645 return hr;
2646}
2647
2648static HRESULT OnExecuteBegin(
2649 __in IBootstrapperApplication* pApplication,
2650 __in BUFF_READER* pReaderArgs,
2651 __in BUFF_READER* pReaderResults,
2652 __in BUFF_BUFFER* pBuffer
2653 )
2654{
2655 HRESULT hr = S_OK;
2656 BA_ONEXECUTEBEGIN_ARGS args = { };
2657 BA_ONEXECUTEBEGIN_RESULTS results = { };
2658
2659 // Read args.
2660 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2661 ExitOnFailure(hr, "Failed to read API version of OnExecuteBegin args.");
2662
2663 hr = BuffReaderReadNumber(pReaderArgs, &args.cExecutingPackages);
2664 ExitOnFailure(hr, "Failed to executing packages of OnExecuteBegin args.");
2665
2666 // Read results.
2667 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2668 ExitOnFailure(hr, "Failed to read API version of OnExecuteBegin results.");
2669
2670 // Callback.
2671 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, &args, &results);
2672
2673 if (E_NOTIMPL == hr)
2674 {
2675 hr = pApplication->OnExecuteBegin(args.cExecutingPackages, &results.fCancel);
2676 }
2677
2678 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN, &args, &results, &hr);
2679 BalExitOnFailure(hr, "BA OnExecuteBegin failed.");
2680
2681 // Write results.
2682 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2683 ExitOnFailure(hr, "Failed to write size of OnExecuteBegin struct.");
2684
2685 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2686 ExitOnFailure(hr, "Failed to write cancel of OnExecuteBegin struct.");
2687
2688LExit:
2689 return hr;
2690}
2691
2692
2693static HRESULT OnExecuteComplete(
2694 __in IBootstrapperApplication* pApplication,
2695 __in BUFF_READER* pReaderArgs,
2696 __in BUFF_READER* pReaderResults,
2697 __in BUFF_BUFFER* pBuffer
2698 )
2699{
2700 HRESULT hr = S_OK;
2701 BA_ONEXECUTECOMPLETE_ARGS args = { };
2702 BA_ONEXECUTECOMPLETE_RESULTS results = { };
2703
2704 // Read args.
2705 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2706 ExitOnFailure(hr, "Failed to read API version of OnExecuteComplete args.");
2707
2708 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
2709 ExitOnFailure(hr, "Failed to status of OnExecuteComplete args.");
2710
2711 // Read results.
2712 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2713 ExitOnFailure(hr, "Failed to read API version of OnExecuteComplete results.");
2714
2715 // Callback.
2716 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, &args, &results);
2717
2718 if (E_NOTIMPL == hr)
2719 {
2720 hr = pApplication->OnExecuteComplete(args.hrStatus);
2721 }
2722
2723 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE, &args, &results, &hr);
2724 BalExitOnFailure(hr, "BA OnExecuteComplete failed.");
2725
2726 // Write results.
2727 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2728 ExitOnFailure(hr, "Failed to write size of OnExecuteComplete struct.");
2729
2730LExit:
2731 return hr;
2732}
2733
2734static HRESULT OnExecuteFilesInUse(
2735 __in IBootstrapperApplication* pApplication,
2736 __in BUFF_READER* pReaderArgs,
2737 __in BUFF_READER* pReaderResults,
2738 __in BUFF_BUFFER* pBuffer
2739 )
2740{
2741 HRESULT hr = S_OK;
2742 BA_ONEXECUTEFILESINUSE_ARGS args = { };
2743 BA_ONEXECUTEFILESINUSE_RESULTS results = { };
2744 LPWSTR sczPackageId = NULL;
2745 DWORD cFiles = 0;
2746 LPWSTR* rgsczFiles = NULL;
2747
2748 // Read args.
2749 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2750 ExitOnFailure(hr, "Failed to read API version of OnExecuteFilesInUse args.");
2751
2752 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2753 ExitOnFailure(hr, "Failed to read package id of OnExecuteFilesInUse args.");
2754
2755 args.wzPackageId = sczPackageId;
2756
2757 hr = BuffReaderReadNumber(pReaderArgs, &cFiles);
2758 ExitOnFailure(hr, "Failed to read count of files of OnExecuteFilesInUse args.");
2759
2760 if (cFiles)
2761 {
2762 rgsczFiles = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cFiles, TRUE));
2763 ExitOnNull(rgsczFiles, hr, E_OUTOFMEMORY, "Failed to allocate memory for files of OnExecuteFilesInUse args.");
2764
2765 for (DWORD i = 0; i < cFiles; ++i)
2766 {
2767 hr = BuffReaderReadString(pReaderArgs, &rgsczFiles[i]);
2768 ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i);
2769 }
2770 }
2771
2772 args.cFiles = cFiles;
2773 args.rgwzFiles = const_cast<LPCWSTR*>(rgsczFiles);
2774
2775 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.nRecommendation));
2776 ExitOnFailure(hr, "Failed to read recommendation of OnExecuteFilesInUse args.");
2777
2778 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.source));
2779 ExitOnFailure(hr, "Failed to read source of OnExecuteFilesInUse args.");
2780
2781 // Read results.
2782 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2783 ExitOnFailure(hr, "Failed to read API version of OnExecuteFilesInUse results.");
2784
2785 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.nResult));
2786 ExitOnFailure(hr, "Failed to read result of OnExecuteFilesInUse results.");
2787
2788 // Callback.
2789 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, &args, &results);
2790
2791 if (E_NOTIMPL == hr)
2792 {
2793 hr = pApplication->OnExecuteFilesInUse(args.wzPackageId, args.cFiles, args.rgwzFiles, args.nRecommendation, args.source, &results.nResult);
2794 }
2795
2796 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE, &args, &results, &hr);
2797 BalExitOnFailure(hr, "BA OnExecuteFilesInUse failed.");
2798
2799 // Write results.
2800 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2801 ExitOnFailure(hr, "Failed to write size of OnExecuteFilesInUse struct.");
2802
2803 hr = BuffWriteNumberToBuffer(pBuffer, results.nResult);
2804 ExitOnFailure(hr, "Failed to write result of OnExecuteFilesInUse struct.");
2805
2806LExit:
2807 for (DWORD i = 0; rgsczFiles && i < cFiles; ++i)
2808 {
2809 ReleaseStr(rgsczFiles[i]);
2810 }
2811 ReleaseMem(rgsczFiles);
2812
2813 ReleaseStr(sczPackageId);
2814 return hr;
2815}
2816
2817static HRESULT OnExecuteMsiMessage(
2818 __in IBootstrapperApplication* pApplication,
2819 __in BUFF_READER* pReaderArgs,
2820 __in BUFF_READER* pReaderResults,
2821 __in BUFF_BUFFER* pBuffer
2822 )
2823{
2824 HRESULT hr = S_OK;
2825 BA_ONEXECUTEMSIMESSAGE_ARGS args = { };
2826 BA_ONEXECUTEMSIMESSAGE_RESULTS results = { };
2827 LPWSTR sczPackageId = NULL;
2828 LPWSTR sczMessage = NULL;
2829 DWORD cData = 0;
2830 LPWSTR* rgsczData = NULL;
2831
2832 // Read args.
2833 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2834 ExitOnFailure(hr, "Failed to read API version of OnExecuteMsiMessage args.");
2835
2836 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2837 ExitOnFailure(hr, "Failed to read package id of OnExecuteMsiMessage args.");
2838
2839 args.wzPackageId = sczPackageId;
2840
2841 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.messageType));
2842 ExitOnFailure(hr, "Failed to read messageType of OnExecuteMsiMessage args.");
2843
2844 hr = BuffReaderReadNumber(pReaderArgs, &args.dwUIHint);
2845 ExitOnFailure(hr, "Failed to read UI hint of OnExecuteMsiMessage args.");
2846
2847 hr = BuffReaderReadString(pReaderArgs, &sczMessage);
2848 ExitOnFailure(hr, "Failed to read message of OnExecuteMsiMessage args.");
2849
2850 args.wzMessage = sczMessage;
2851
2852 hr = BuffReaderReadNumber(pReaderArgs, &cData);
2853 ExitOnFailure(hr, "Failed to read count of files of OnExecuteMsiMessage args.");
2854
2855 if (cData)
2856 {
2857 rgsczData = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cData, TRUE));
2858 ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnExecuteMsiMessage args.");
2859
2860 for (DWORD i = 0; i < cData; ++i)
2861 {
2862 hr = BuffReaderReadString(pReaderArgs, &rgsczData[i]);
2863 ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i);
2864 }
2865 }
2866
2867 args.cData = cData;
2868 args.rgwzData = const_cast<LPCWSTR*>(rgsczData);
2869
2870 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.nRecommendation));
2871 ExitOnFailure(hr, "Failed to read recommendation of OnExecuteMsiMessage args.");
2872
2873 // Read results.
2874 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2875 ExitOnFailure(hr, "Failed to read API version of OnExecuteMsiMessage results.");
2876
2877 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.nResult));
2878 ExitOnFailure(hr, "Failed to read result of OnExecuteMsiMessage results.");
2879
2880 // Callback.
2881 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, &args, &results);
2882
2883 if (E_NOTIMPL == hr)
2884 {
2885 hr = pApplication->OnExecuteMsiMessage(args.wzPackageId, args.messageType, args.dwUIHint, args.wzMessage, args.cData, args.rgwzData, args.nRecommendation, &results.nResult);
2886 }
2887
2888 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE, &args, &results, &hr);
2889 BalExitOnFailure(hr, "BA OnExecuteMsiMessage failed.");
2890
2891 // Write results.
2892 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2893 ExitOnFailure(hr, "Failed to write size of OnExecuteMsiMessage struct.");
2894
2895 hr = BuffWriteNumberToBuffer(pBuffer, results.nResult);
2896 ExitOnFailure(hr, "Failed to write result of OnExecuteMsiMessage struct.");
2897
2898LExit:
2899 for (DWORD i = 0; rgsczData && i < cData; ++i)
2900 {
2901 ReleaseStr(rgsczData[i]);
2902 }
2903 ReleaseMem(rgsczData);
2904
2905 ReleaseStr(sczMessage);
2906 ReleaseStr(sczPackageId);
2907 return hr;
2908}
2909
2910static HRESULT OnExecutePackageBegin(
2911 __in IBootstrapperApplication* pApplication,
2912 __in BUFF_READER* pReaderArgs,
2913 __in BUFF_READER* pReaderResults,
2914 __in BUFF_BUFFER* pBuffer
2915 )
2916{
2917 HRESULT hr = S_OK;
2918 BA_ONEXECUTEPACKAGEBEGIN_ARGS args = { };
2919 BA_ONEXECUTEPACKAGEBEGIN_RESULTS results = { };
2920 LPWSTR sczPackageId = NULL;
2921
2922 // Read args.
2923 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2924 ExitOnFailure(hr, "Failed to read API version of OnExecutePackageBegin args.");
2925
2926 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2927 ExitOnFailure(hr, "Failed to read package id of OnExecutePackageBegin args.");
2928
2929 args.wzPackageId = sczPackageId;
2930
2931 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fExecute));
2932 ExitOnFailure(hr, "Failed to read execute of OnExecutePackageBegin args.");
2933
2934 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.action));
2935 ExitOnFailure(hr, "Failed to read action of OnExecutePackageBegin args.");
2936
2937 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.uiLevel));
2938 ExitOnFailure(hr, "Failed to read UI level of OnExecutePackageBegin args.");
2939
2940 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fDisableExternalUiHandler));
2941 ExitOnFailure(hr, "Failed to read disable external UI handler of OnExecutePackageBegin args.");
2942
2943 // Read results.
2944 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
2945 ExitOnFailure(hr, "Failed to read API version of OnExecutePackageBegin results.");
2946
2947 // Callback.
2948 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, &args, &results);
2949
2950 if (E_NOTIMPL == hr)
2951 {
2952 hr = pApplication->OnExecutePackageBegin(args.wzPackageId, args.fExecute, args.action, args.uiLevel, args.fDisableExternalUiHandler, &results.fCancel);
2953 }
2954
2955 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN, &args, &results, &hr);
2956 BalExitOnFailure(hr, "BA OnExecutePackageBegin failed.");
2957
2958 // Write results.
2959 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
2960 ExitOnFailure(hr, "Failed to write size of OnExecutePackageBegin struct.");
2961
2962 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
2963 ExitOnFailure(hr, "Failed to write cancel of OnExecutePackageBegin struct.");
2964
2965LExit:
2966 ReleaseStr(sczPackageId);
2967 return hr;
2968}
2969
2970static HRESULT OnExecutePackageComplete(
2971 __in IBootstrapperApplication* pApplication,
2972 __in BUFF_READER* pReaderArgs,
2973 __in BUFF_READER* pReaderResults,
2974 __in BUFF_BUFFER* pBuffer
2975 )
2976{
2977 HRESULT hr = S_OK;
2978 BA_ONEXECUTEPACKAGECOMPLETE_ARGS args = { };
2979 BA_ONEXECUTEPACKAGECOMPLETE_RESULTS results = { };
2980 LPWSTR sczPackageId = NULL;
2981
2982 // Read args.
2983 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
2984 ExitOnFailure(hr, "Failed to read API version of OnExecutePackageComplete args.");
2985
2986 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
2987 ExitOnFailure(hr, "Failed to read package id of OnExecutePackageComplete args.");
2988
2989 args.wzPackageId = sczPackageId;
2990
2991 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
2992 ExitOnFailure(hr, "Failed to read status of OnExecutePackageComplete args.");
2993
2994 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.restart));
2995 ExitOnFailure(hr, "Failed to read restart of OnExecutePackageComplete args.");
2996
2997 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
2998 ExitOnFailure(hr, "Failed to read recommendation of OnExecutePackageComplete args.");
2999
3000 // Read results.
3001 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3002 ExitOnFailure(hr, "Failed to read API version of OnExecutePackageComplete results.");
3003
3004 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
3005 ExitOnFailure(hr, "Failed to read action of OnExecutePackageComplete results.");
3006
3007 // Callback.
3008 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, &args, &results);
3009
3010 if (E_NOTIMPL == hr)
3011 {
3012 hr = pApplication->OnExecutePackageComplete(args.wzPackageId, args.hrStatus, args.restart, args.recommendation, &results.action);
3013 }
3014
3015 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE, &args, &results, &hr);
3016 BalExitOnFailure(hr, "BA OnExecutePackageComplete failed.");
3017
3018 // Write results.
3019 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3020 ExitOnFailure(hr, "Failed to write size of OnExecutePackageComplete struct.");
3021
3022 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
3023 ExitOnFailure(hr, "Failed to write action of OnExecutePackageComplete struct.");
3024
3025LExit:
3026 ReleaseStr(sczPackageId);
3027 return hr;
3028}
3029
3030static HRESULT OnExecutePatchTarget(
3031 __in IBootstrapperApplication* pApplication,
3032 __in BUFF_READER* pReaderArgs,
3033 __in BUFF_READER* pReaderResults,
3034 __in BUFF_BUFFER* pBuffer
3035 )
3036{
3037 HRESULT hr = S_OK;
3038 BA_ONEXECUTEPATCHTARGET_ARGS args = { };
3039 BA_ONEXECUTEPATCHTARGET_RESULTS results = { };
3040 LPWSTR sczPackageId = NULL;
3041 LPWSTR sczTargetProductCode = NULL;
3042
3043 // Read args.
3044 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3045 ExitOnFailure(hr, "Failed to read API version of OnExecutePatchTarget args.");
3046
3047 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3048 ExitOnFailure(hr, "Failed to read package id of OnExecutePatchTarget args.");
3049
3050 args.wzPackageId = sczPackageId;
3051
3052 hr = BuffReaderReadString(pReaderArgs, &sczTargetProductCode);
3053 ExitOnFailure(hr, "Failed to read target product code of OnExecutePatchTarget args.");
3054
3055 args.wzTargetProductCode = sczTargetProductCode;
3056
3057
3058 // Read results.
3059 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3060 ExitOnFailure(hr, "Failed to read API version of OnExecutePatchTarget results.");
3061
3062 // Callback.
3063 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, &args, &results);
3064
3065 if (E_NOTIMPL == hr)
3066 {
3067 hr = pApplication->OnExecutePatchTarget(args.wzPackageId, args.wzTargetProductCode, &results.fCancel);
3068 }
3069
3070 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET, &args, &results, &hr);
3071 BalExitOnFailure(hr, "BA OnExecutePatchTarget failed.");
3072
3073 // Write results.
3074 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3075 ExitOnFailure(hr, "Failed to write size of OnExecutePatchTarget struct.");
3076
3077 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3078 ExitOnFailure(hr, "Failed to write cancel of OnExecutePatchTarget struct.");
3079
3080LExit:
3081 ReleaseStr(sczTargetProductCode);
3082 ReleaseStr(sczPackageId);
3083 return hr;
3084}
3085
3086static HRESULT OnExecuteProcessCancel(
3087 __in IBootstrapperApplication* pApplication,
3088 __in BUFF_READER* pReaderArgs,
3089 __in BUFF_READER* pReaderResults,
3090 __in BUFF_BUFFER* pBuffer
3091 )
3092{
3093 HRESULT hr = S_OK;
3094 BA_ONEXECUTEPROCESSCANCEL_ARGS args = { };
3095 BA_ONEXECUTEPROCESSCANCEL_RESULTS results = { };
3096 LPWSTR sczPackageId = NULL;
3097
3098 // Read args.
3099 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3100 ExitOnFailure(hr, "Failed to read API version of OnExecuteProcessCancel args.");
3101
3102 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3103 ExitOnFailure(hr, "Failed to read package id of OnExecuteProcessCancel args.");
3104
3105 args.wzPackageId = sczPackageId;
3106
3107 hr = BuffReaderReadNumber(pReaderArgs, &args.dwProcessId);
3108 ExitOnFailure(hr, "Failed to read process id of OnExecuteProcessCancel args.");
3109
3110 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
3111 ExitOnFailure(hr, "Failed to read recommendation of OnExecuteProcessCancel args.");
3112
3113 // Read results.
3114 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3115 ExitOnFailure(hr, "Failed to read API version of OnExecuteProcessCancel results.");
3116
3117 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
3118 ExitOnFailure(hr, "Failed to read action of OnExecuteProcessCancel results.");
3119
3120 // Callback.
3121 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, &args, &results);
3122
3123 if (E_NOTIMPL == hr)
3124 {
3125 hr = pApplication->OnExecuteProcessCancel(args.wzPackageId, args.dwProcessId, args.recommendation, &results.action);
3126 }
3127
3128 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL, &args, &results, &hr);
3129 BalExitOnFailure(hr, "BA OnExecuteProcessCancel failed.");
3130
3131 // Write results.
3132 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3133 ExitOnFailure(hr, "Failed to write size of OnExecuteProcessCancel struct.");
3134
3135 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
3136 ExitOnFailure(hr, "Failed to write action of OnExecuteProcessCancel struct.");
3137
3138LExit:
3139 ReleaseStr(sczPackageId);
3140 return hr;
3141}
3142
3143static HRESULT OnExecuteProgress(
3144 __in IBootstrapperApplication* pApplication,
3145 __in BUFF_READER* pReaderArgs,
3146 __in BUFF_READER* pReaderResults,
3147 __in BUFF_BUFFER* pBuffer
3148 )
3149{
3150 HRESULT hr = S_OK;
3151 BA_ONEXECUTEPROGRESS_ARGS args = { };
3152 BA_ONEXECUTEPROGRESS_RESULTS results = { };
3153 LPWSTR sczPackageId = NULL;
3154
3155 // Read args.
3156 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3157 ExitOnFailure(hr, "Failed to read API version of OnExecuteProgress args.");
3158
3159 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3160 ExitOnFailure(hr, "Failed to read package id of OnExecuteProgress args.");
3161
3162 args.wzPackageId = sczPackageId;
3163
3164 hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage);
3165 ExitOnFailure(hr, "Failed to read progress of OnExecuteProgress args.");
3166
3167 hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage);
3168 ExitOnFailure(hr, "Failed to read overall progress of OnExecuteProgress args.");
3169
3170 // Read results.
3171 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3172 ExitOnFailure(hr, "Failed to read API version of OnExecuteProgress results.");
3173
3174 // Callback.
3175 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, &args, &results);
3176
3177 if (E_NOTIMPL == hr)
3178 {
3179 hr = pApplication->OnExecuteProgress(args.wzPackageId, args.dwProgressPercentage, args.dwOverallPercentage, &results.fCancel);
3180 }
3181
3182 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS, &args, &results, &hr);
3183 BalExitOnFailure(hr, "BA OnExecuteProgress failed.");
3184
3185 // Write results.
3186 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3187 ExitOnFailure(hr, "Failed to write size of OnExecuteProgress struct.");
3188
3189 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3190 ExitOnFailure(hr, "Failed to write cancel of OnExecuteProgress struct.");
3191
3192LExit:
3193 ReleaseStr(sczPackageId);
3194 return hr;
3195}
3196
3197static HRESULT OnLaunchApprovedExeBegin(
3198 __in IBootstrapperApplication* pApplication,
3199 __in BUFF_READER* pReaderArgs,
3200 __in BUFF_READER* pReaderResults,
3201 __in BUFF_BUFFER* pBuffer
3202 )
3203{
3204 HRESULT hr = S_OK;
3205 BA_ONLAUNCHAPPROVEDEXEBEGIN_ARGS args = { };
3206 BA_ONLAUNCHAPPROVEDEXEBEGIN_RESULTS results = { };
3207
3208 // Read args.
3209 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3210 ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeBegin args.");
3211
3212 // Read results.
3213 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3214 ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeBegin results.");
3215
3216 // Callback.
3217 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, &args, &results);
3218
3219 if (E_NOTIMPL == hr)
3220 {
3221 hr = pApplication->OnLaunchApprovedExeBegin(&results.fCancel);
3222 }
3223
3224 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN, &args, &results, &hr);
3225 BalExitOnFailure(hr, "BA OnLaunchApprovedExeBegin failed.");
3226
3227 // Write results.
3228 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3229 ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeBegin struct.");
3230
3231 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3232 ExitOnFailure(hr, "Failed to write cancel of OnLaunchApprovedExeBegin struct.");
3233
3234LExit:
3235 return hr;
3236}
3237
3238static HRESULT OnLaunchApprovedExeComplete(
3239 __in IBootstrapperApplication* pApplication,
3240 __in BUFF_READER* pReaderArgs,
3241 __in BUFF_READER* pReaderResults,
3242 __in BUFF_BUFFER* pBuffer
3243 )
3244{
3245 HRESULT hr = S_OK;
3246 BA_ONLAUNCHAPPROVEDEXECOMPLETE_ARGS args = { };
3247 BA_ONLAUNCHAPPROVEDEXECOMPLETE_RESULTS results = { };
3248
3249 // Read args.
3250 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3251 ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeComplete args.");
3252
3253 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
3254 ExitOnFailure(hr, "Failed to read status of OnLaunchApprovedExeComplete args.");
3255
3256 hr = BuffReaderReadNumber(pReaderArgs, &args.dwProcessId);
3257 ExitOnFailure(hr, "Failed to read process id of OnLaunchApprovedExeComplete args.");
3258
3259 // Read results.
3260 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3261 ExitOnFailure(hr, "Failed to read API version of OnLaunchApprovedExeComplete results.");
3262
3263 // Callback.
3264 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, &args, &results);
3265
3266 if (E_NOTIMPL == hr)
3267 {
3268 hr = pApplication->OnLaunchApprovedExeComplete(args.hrStatus, args.dwProcessId);
3269 }
3270
3271 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE, &args, &results, &hr);
3272 BalExitOnFailure(hr, "BA OnLaunchApprovedExeComplete failed.");
3273
3274 // Write results.
3275 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3276 ExitOnFailure(hr, "Failed to write size of OnLaunchApprovedExeComplete struct.");
3277
3278LExit:
3279 return hr;
3280}
3281
3282static HRESULT OnPauseAutomaticUpdatesBegin(
3283 __in IBootstrapperApplication* pApplication,
3284 __in BUFF_READER* pReaderArgs,
3285 __in BUFF_READER* pReaderResults,
3286 __in BUFF_BUFFER* pBuffer
3287 )
3288{
3289 HRESULT hr = S_OK;
3290 BA_ONPAUSEAUTOMATICUPDATESBEGIN_ARGS args = { };
3291 BA_ONPAUSEAUTOMATICUPDATESBEGIN_RESULTS results = { };
3292
3293 // Read args.
3294 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3295 ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesBegin args.");
3296
3297 // Read results.
3298 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3299 ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesBegin results.");
3300
3301 // Callback.
3302 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &args, &results);
3303
3304 if (E_NOTIMPL == hr)
3305 {
3306 hr = pApplication->OnPauseAutomaticUpdatesBegin();
3307 }
3308
3309 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN, &args, &results, &hr);
3310 BalExitOnFailure(hr, "BA OnPauseAutomaticUpdatesBegin failed.");
3311
3312 // Write results.
3313 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3314 ExitOnFailure(hr, "Failed to write size of OnPauseAutomaticUpdatesBegin struct.");
3315
3316LExit:
3317 return hr;
3318}
3319
3320static HRESULT OnPauseAutomaticUpdatesComplete(
3321 __in IBootstrapperApplication* pApplication,
3322 __in BUFF_READER* pReaderArgs,
3323 __in BUFF_READER* pReaderResults,
3324 __in BUFF_BUFFER* pBuffer
3325 )
3326{
3327 HRESULT hr = S_OK;
3328 BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_ARGS args = { };
3329 BA_ONPAUSEAUTOMATICUPDATESCOMPLETE_RESULTS results = { };
3330
3331 // Read args.
3332 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3333 ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesComplete args.");
3334
3335 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
3336 ExitOnFailure(hr, "Failed to read status of OnPauseAutomaticUpdatesComplete args.");
3337
3338 // Read results.
3339 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3340 ExitOnFailure(hr, "Failed to read API version of OnPauseAutomaticUpdatesComplete results.");
3341
3342 // Callback.
3343 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, &args, &results);
3344
3345 if (E_NOTIMPL == hr)
3346 {
3347 hr = pApplication->OnPauseAutomaticUpdatesComplete(args.hrStatus);
3348 }
3349
3350 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE, &args, &results, &hr);
3351 BalExitOnFailure(hr, "BA OnPauseAutomaticUpdatesComplete failed.");
3352
3353 // Write results.
3354 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3355 ExitOnFailure(hr, "Failed to write size of OnPauseAutomaticUpdatesComplete struct.");
3356
3357LExit:
3358 return hr;
3359}
3360
3361static HRESULT OnPlanBegin(
3362 __in IBootstrapperApplication* pApplication,
3363 __in BUFF_READER* pReaderArgs,
3364 __in BUFF_READER* pReaderResults,
3365 __in BUFF_BUFFER* pBuffer
3366 )
3367{
3368 HRESULT hr = S_OK;
3369 BA_ONPLANBEGIN_ARGS args = { };
3370 BA_ONPLANBEGIN_RESULTS results = { };
3371
3372 // Read args.
3373 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3374 ExitOnFailure(hr, "Failed to read API version of OnPlanBegin args.");
3375
3376 hr = BuffReaderReadNumber(pReaderArgs, &args.cPackages);
3377 ExitOnFailure(hr, "Failed to read count of packages of OnPlanBegin args.");
3378
3379 // Read results.
3380 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3381 ExitOnFailure(hr, "Failed to read API version of OnPlanBegin results.");
3382
3383 // Callback.
3384 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, &args, &results);
3385
3386 if (E_NOTIMPL == hr)
3387 {
3388 hr = pApplication->OnPlanBegin(args.cPackages, &results.fCancel);
3389 }
3390
3391 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN, &args, &results, &hr);
3392 BalExitOnFailure(hr, "BA OnPlanBegin failed.");
3393
3394 // Write results.
3395 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3396 ExitOnFailure(hr, "Failed to write size of OnPlanBegin struct.");
3397
3398 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3399 ExitOnFailure(hr, "Failed to write cancel of OnPlanBegin struct.");
3400
3401LExit:
3402 return hr;
3403}
3404
3405static HRESULT OnPlanCompatibleMsiPackageBegin(
3406 __in IBootstrapperApplication* pApplication,
3407 __in BUFF_READER* pReaderArgs,
3408 __in BUFF_READER* pReaderResults,
3409 __in BUFF_BUFFER* pBuffer
3410 )
3411{
3412 HRESULT hr = S_OK;
3413 BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_ARGS args = { };
3414 BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS results = { };
3415 LPWSTR sczPackageId = NULL;
3416 LPWSTR sczCompatiblePackageId = NULL;
3417 LPWSTR sczCompatiblePackageVersion = NULL;
3418
3419 // Read args.
3420 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3421 ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageBegin args.");
3422
3423 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3424 ExitOnFailure(hr, "Failed to read package id of OnPlanCompatibleMsiPackageBegin args.");
3425
3426 args.wzPackageId = sczPackageId;
3427
3428 hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId);
3429 ExitOnFailure(hr, "Failed to read compatible package id of OnPlanCompatibleMsiPackageBegin args.");
3430
3431 args.wzCompatiblePackageId = sczCompatiblePackageId;
3432
3433 hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageVersion);
3434 ExitOnFailure(hr, "Failed to read compatible package version of OnPlanCompatibleMsiPackageBegin args.");
3435
3436 args.wzCompatiblePackageVersion = sczCompatiblePackageVersion;
3437
3438 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fRecommendedRemove));
3439 ExitOnFailure(hr, "Failed to read recommend remove of OnPlanCompatibleMsiPackageBegin args.");
3440
3441 // Read results.
3442 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3443 ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageBegin results.");
3444
3445 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fRequestRemove));
3446 ExitOnFailure(hr, "Failed to read request remove of OnPlanCompatibleMsiPackageBegin results.");
3447
3448 // Callback.
3449 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, &args, &results);
3450
3451 if (E_NOTIMPL == hr)
3452 {
3453 hr = pApplication->OnPlanCompatibleMsiPackageBegin(args.wzPackageId, args.wzCompatiblePackageId, args.wzCompatiblePackageVersion, args.fRecommendedRemove, &results.fCancel, &results.fRequestRemove);
3454 }
3455
3456 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN, &args, &results, &hr);
3457 BalExitOnFailure(hr, "BA OnPlanCompatibleMsiPackageBegin failed.");
3458
3459 // Write results.
3460 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3461 ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageBegin struct.");
3462
3463 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3464 ExitOnFailure(hr, "Failed to write cancel of OnPlanCompatibleMsiPackageBegin struct.");
3465
3466 hr = BuffWriteNumberToBuffer(pBuffer, results.fRequestRemove);
3467 ExitOnFailure(hr, "Failed to write requested remove of OnPlanCompatibleMsiPackageBegin struct.");
3468
3469LExit:
3470 ReleaseStr(sczCompatiblePackageVersion);
3471 ReleaseStr(sczCompatiblePackageId);
3472 ReleaseStr(sczPackageId);
3473
3474 return hr;
3475}
3476
3477static HRESULT OnPlanCompatibleMsiPackageComplete(
3478 __in IBootstrapperApplication* pApplication,
3479 __in BUFF_READER* pReaderArgs,
3480 __in BUFF_READER* pReaderResults,
3481 __in BUFF_BUFFER* pBuffer
3482 )
3483{
3484 HRESULT hr = S_OK;
3485 BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_ARGS args = { };
3486 BA_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE_RESULTS results = { };
3487 LPWSTR sczPackageId = NULL;
3488 LPWSTR sczCompatiblePackageId = NULL;
3489
3490 // Read args.
3491 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3492 ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageComplete args.");
3493
3494 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3495 ExitOnFailure(hr, "Failed to read package id of OnPlanCompatibleMsiPackageComplete args.");
3496
3497 args.wzPackageId = sczPackageId;
3498
3499 hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId);
3500 ExitOnFailure(hr, "Failed to read compatible package id of OnPlanCompatibleMsiPackageComplete args.");
3501
3502 args.wzCompatiblePackageId = sczCompatiblePackageId;
3503
3504 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
3505 ExitOnFailure(hr, "Failed to read status of OnPlanCompatibleMsiPackageComplete args.");
3506
3507 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fRequestedRemove));
3508 ExitOnFailure(hr, "Failed to read requested remove of OnPlanCompatibleMsiPackageComplete args.");
3509
3510 // Read results.
3511 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3512 ExitOnFailure(hr, "Failed to read API version of OnPlanCompatibleMsiPackageComplete results.");
3513
3514 // Callback.
3515 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, &args, &results);
3516
3517 if (E_NOTIMPL == hr)
3518 {
3519 hr = pApplication->OnPlanCompatibleMsiPackageComplete(args.wzPackageId, args.wzCompatiblePackageId, args.hrStatus, args.fRequestedRemove);
3520 }
3521
3522 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, &args, &results, &hr);
3523 BalExitOnFailure(hr, "BA OnPlanCompatibleMsiPackageComplete failed.");
3524
3525 // Write results.
3526 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3527 ExitOnFailure(hr, "Failed to write size of OnPlanCompatibleMsiPackageComplete struct.");
3528
3529
3530LExit:
3531 ReleaseStr(sczCompatiblePackageId);
3532 ReleaseStr(sczPackageId);
3533
3534 return hr;
3535}
3536
3537static HRESULT OnPlanMsiFeature(
3538 __in IBootstrapperApplication* pApplication,
3539 __in BUFF_READER* pReaderArgs,
3540 __in BUFF_READER* pReaderResults,
3541 __in BUFF_BUFFER* pBuffer
3542 )
3543{
3544 HRESULT hr = S_OK;
3545 BA_ONPLANMSIFEATURE_ARGS args = { };
3546 BA_ONPLANMSIFEATURE_RESULTS results = { };
3547 LPWSTR sczPackageId = NULL;
3548 LPWSTR sczFeatureId = NULL;
3549
3550 // Read args.
3551 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3552 ExitOnFailure(hr, "Failed to read API version of OnPlanMsiFeature args.");
3553
3554 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3555 ExitOnFailure(hr, "Failed to read package id of OnPlanMsiFeature args.");
3556
3557 args.wzPackageId = sczPackageId;
3558
3559 hr = BuffReaderReadString(pReaderArgs, &sczFeatureId);
3560 ExitOnFailure(hr, "Failed to read feature id of OnPlanMsiFeature args.");
3561
3562 args.wzFeatureId = sczFeatureId;
3563
3564 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedState));
3565 ExitOnFailure(hr, "Failed to read recommended state of OnPlanMsiFeature args.");
3566
3567 // Read results.
3568 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3569 ExitOnFailure(hr, "Failed to read API version of OnPlanMsiFeature results.");
3570
3571 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedState));
3572 ExitOnFailure(hr, "Failed to read requested state of OnPlanMsiFeature results.");
3573
3574 // Callback.
3575 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, &args, &results);
3576
3577 if (E_NOTIMPL == hr)
3578 {
3579 hr = pApplication->OnPlanMsiFeature(args.wzPackageId, args.wzFeatureId, args.recommendedState, &results.requestedState, &results.fCancel);
3580 }
3581
3582 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE, &args, &results, &hr);
3583 BalExitOnFailure(hr, "BA OnPlanMsiFeature failed.");
3584
3585 // Write results.
3586 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3587 ExitOnFailure(hr, "Failed to write size of OnPlanMsiFeature struct.");
3588
3589 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState);
3590 ExitOnFailure(hr, "Failed to write requested state of OnPlanMsiFeature struct.");
3591
3592 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3593 ExitOnFailure(hr, "Failed to write cancel of OnPlanMsiFeature struct.");
3594
3595LExit:
3596 ReleaseStr(sczFeatureId);
3597 ReleaseStr(sczPackageId);
3598
3599 return hr;
3600}
3601
3602static HRESULT OnPlanComplete(
3603 __in IBootstrapperApplication* pApplication,
3604 __in BUFF_READER* pReaderArgs,
3605 __in BUFF_READER* pReaderResults,
3606 __in BUFF_BUFFER* pBuffer
3607 )
3608{
3609 HRESULT hr = S_OK;
3610 BA_ONPLANCOMPLETE_ARGS args = { };
3611 BA_ONPLANCOMPLETE_RESULTS results = { };
3612
3613 // Read args.
3614 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3615 ExitOnFailure(hr, "Failed to read API version of OnPlanComplete args.");
3616
3617 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
3618 ExitOnFailure(hr, "Failed to read status of OnPlanComplete args.");
3619
3620 // Read results.
3621 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3622 ExitOnFailure(hr, "Failed to read API version of OnPlanComplete results.");
3623
3624 // Callback.
3625 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, &args, &results);
3626
3627 if (E_NOTIMPL == hr)
3628 {
3629 hr = pApplication->OnPlanComplete(args.hrStatus);
3630 }
3631
3632 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE, &args, &results, &hr);
3633 BalExitOnFailure(hr, "BA OnPlanComplete failed.");
3634
3635 // Write results.
3636 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3637 ExitOnFailure(hr, "Failed to write size of OnPlanComplete struct.");
3638
3639LExit:
3640 return hr;
3641}
3642
3643static HRESULT OnPlanForwardCompatibleBundle(
3644 __in IBootstrapperApplication* pApplication,
3645 __in BUFF_READER* pReaderArgs,
3646 __in BUFF_READER* pReaderResults,
3647 __in BUFF_BUFFER* pBuffer
3648 )
3649{
3650 HRESULT hr = S_OK;
3651 BA_ONPLANFORWARDCOMPATIBLEBUNDLE_ARGS args = { };
3652 BA_ONPLANFORWARDCOMPATIBLEBUNDLE_RESULTS results = { };
3653 LPWSTR sczBundleId = NULL;
3654 LPWSTR sczBundleTag = NULL;
3655 LPWSTR sczVersion = NULL;
3656
3657 // Read args.
3658 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3659 ExitOnFailure(hr, "Failed to read API version of OnPlanForwardCompatibleBundle args.");
3660
3661 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
3662 ExitOnFailure(hr, "Failed to read bundle id of OnPlanForwardCompatibleBundle args.");
3663
3664 args.wzBundleId = sczBundleId;
3665
3666 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.relationType));
3667 ExitOnFailure(hr, "Failed to read relation type of OnPlanForwardCompatibleBundle args.");
3668
3669 hr = BuffReaderReadString(pReaderArgs, &sczBundleTag);
3670 ExitOnFailure(hr, "Failed to read bundle tag of OnPlanForwardCompatibleBundle args.");
3671
3672 args.wzBundleTag = sczBundleTag;
3673
3674 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPerMachine));
3675 ExitOnFailure(hr, "Failed to read per-machine of OnPlanForwardCompatibleBundle args.");
3676
3677 hr = BuffReaderReadString(pReaderArgs, &sczVersion);
3678 ExitOnFailure(hr, "Failed to read version of OnPlanForwardCompatibleBundle args.");
3679
3680 args.wzVersion = sczVersion;
3681
3682 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fRecommendedIgnoreBundle));
3683 ExitOnFailure(hr, "Failed to read recommended ignore bundle of OnPlanForwardCompatibleBundle args.");
3684
3685 // Read results.
3686 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3687 ExitOnFailure(hr, "Failed to read API version of OnPlanForwardCompatibleBundle results.");
3688
3689 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fIgnoreBundle));
3690 ExitOnFailure(hr, "Failed to read requested ignore bundle of OnPlanForwardCompatibleBundle results.");
3691
3692 // Callback.
3693 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, &args, &results);
3694
3695 if (E_NOTIMPL == hr)
3696 {
3697 hr = pApplication->OnPlanForwardCompatibleBundle(args.wzBundleId, args.relationType, args.wzBundleTag, args.fPerMachine, args.wzVersion, args.fRecommendedIgnoreBundle, &results.fCancel, &results.fIgnoreBundle);
3698 }
3699
3700 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE, &args, &results, &hr);
3701 BalExitOnFailure(hr, "BA OnPlanForwardCompatibleBundle failed.");
3702
3703 // Write results.
3704 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3705 ExitOnFailure(hr, "Failed to write size of OnPlanForwardCompatibleBundle struct.");
3706
3707 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3708 ExitOnFailure(hr, "Failed to write cancel of OnPlanForwardCompatibleBundle struct.");
3709
3710 hr = BuffWriteNumberToBuffer(pBuffer, results.fIgnoreBundle);
3711 ExitOnFailure(hr, "Failed to write ignore bundle of OnPlanForwardCompatibleBundle struct.");
3712
3713LExit:
3714 ReleaseStr(sczVersion);
3715 ReleaseStr(sczBundleTag);
3716 ReleaseStr(sczBundleId);
3717 return hr;
3718}
3719
3720static HRESULT OnPlanMsiPackage(
3721 __in IBootstrapperApplication* pApplication,
3722 __in BUFF_READER* pReaderArgs,
3723 __in BUFF_READER* pReaderResults,
3724 __in BUFF_BUFFER* pBuffer
3725 )
3726{
3727 HRESULT hr = S_OK;
3728 BA_ONPLANMSIPACKAGE_ARGS args = { };
3729 BA_ONPLANMSIPACKAGE_RESULTS results = { };
3730 LPWSTR sczPackageId = NULL;
3731
3732 // Read args.
3733 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3734 ExitOnFailure(hr, "Failed to read API version of OnPlanMsiPackage args.");
3735
3736 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3737 ExitOnFailure(hr, "Failed to read package id of OnPlanMsiPackage args.");
3738
3739 args.wzPackageId = sczPackageId;
3740
3741 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fExecute));
3742 ExitOnFailure(hr, "Failed to read execute of OnPlanMsiPackage args.");
3743
3744 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.action));
3745 ExitOnFailure(hr, "Failed to read action of OnPlanMsiPackage args.");
3746
3747 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedFileVersioning));
3748 ExitOnFailure(hr, "Failed to read recommended file versioning of OnPlanMsiPackage args.");
3749
3750 // Read results.
3751 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3752 ExitOnFailure(hr, "Failed to read API version of OnPlanMsiPackage results.");
3753
3754 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.actionMsiProperty));
3755 ExitOnFailure(hr, "Failed to read action msi property of OnPlanMsiPackage results.");
3756
3757 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.uiLevel));
3758 ExitOnFailure(hr, "Failed to read UI level of OnPlanMsiPackage results.");
3759
3760 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fDisableExternalUiHandler));
3761 ExitOnFailure(hr, "Failed to read disable external UI handler of OnPlanMsiPackage results.");
3762
3763 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fileVersioning));
3764 ExitOnFailure(hr, "Failed to read file versioning of OnPlanMsiPackage results.");
3765
3766 // Callback.
3767 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, &args, &results);
3768
3769 if (E_NOTIMPL == hr)
3770 {
3771 hr = pApplication->OnPlanMsiPackage(args.wzPackageId, args.fExecute, args.action, args.recommendedFileVersioning, &results.fCancel, &results.actionMsiProperty, &results.uiLevel, &results.fDisableExternalUiHandler, &results.fileVersioning);
3772 }
3773
3774 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE, &args, &results, &hr);
3775 BalExitOnFailure(hr, "BA OnPlanMsiPackage failed.");
3776
3777 // Write results.
3778 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3779 ExitOnFailure(hr, "Failed to write size of OnPlanMsiPackage struct.");
3780
3781 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3782 ExitOnFailure(hr, "Failed to write cancel of OnPlanMsiPackage struct.");
3783
3784 hr = BuffWriteNumberToBuffer(pBuffer, results.actionMsiProperty);
3785 ExitOnFailure(hr, "Failed to write action MSI property of OnPlanMsiPackage struct.");
3786
3787 hr = BuffWriteNumberToBuffer(pBuffer, results.uiLevel);
3788 ExitOnFailure(hr, "Failed to write UI level of OnPlanMsiPackage struct.");
3789
3790 hr = BuffWriteNumberToBuffer(pBuffer, results.fDisableExternalUiHandler);
3791 ExitOnFailure(hr, "Failed to write external UI handler of OnPlanMsiPackage struct.");
3792
3793 hr = BuffWriteNumberToBuffer(pBuffer, results.fileVersioning);
3794 ExitOnFailure(hr, "Failed to write file versioning of OnPlanMsiPackage struct.");
3795
3796LExit:
3797 ReleaseStr(sczPackageId);
3798 return hr;
3799}
3800
3801static HRESULT OnPlannedCompatiblePackage(
3802 __in IBootstrapperApplication* pApplication,
3803 __in BUFF_READER* pReaderArgs,
3804 __in BUFF_READER* pReaderResults,
3805 __in BUFF_BUFFER* pBuffer
3806 )
3807{
3808 HRESULT hr = S_OK;
3809 BA_ONPLANNEDCOMPATIBLEPACKAGE_ARGS args = { };
3810 BA_ONPLANNEDCOMPATIBLEPACKAGE_RESULTS results = { };
3811 LPWSTR sczPackageId = NULL;
3812 LPWSTR sczCompatiblePackageId = NULL;
3813
3814 // Read args.
3815 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3816 ExitOnFailure(hr, "Failed to read API version of OnPlannedCompatiblePackage args.");
3817
3818 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3819 ExitOnFailure(hr, "Failed to read package id of OnPlannedCompatiblePackage args.");
3820
3821 args.wzPackageId = sczPackageId;
3822
3823 hr = BuffReaderReadString(pReaderArgs, &sczCompatiblePackageId);
3824 ExitOnFailure(hr, "Failed to read compatible package id of OnPlannedCompatiblePackage args.");
3825
3826 args.wzCompatiblePackageId = sczCompatiblePackageId;
3827
3828 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fRemove));
3829 ExitOnFailure(hr, "Failed to read remove of OnPlannedCompatiblePackage args.");
3830
3831 // Read results.
3832 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3833 ExitOnFailure(hr, "Failed to read API version of OnPlannedCompatiblePackage results.");
3834
3835 // Callback.
3836 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, &args, &results);
3837
3838 if (E_NOTIMPL == hr)
3839 {
3840 hr = pApplication->OnPlannedCompatiblePackage(args.wzPackageId, args.wzCompatiblePackageId, args.fRemove);
3841 }
3842
3843 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, &args, &results, &hr);
3844 BalExitOnFailure(hr, "BA OnPlannedCompatiblePackage failed.");
3845
3846 // Write results.
3847 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3848 ExitOnFailure(hr, "Failed to write size of OnPlannedCompatiblePackage struct.");
3849
3850LExit:
3851 ReleaseStr(sczCompatiblePackageId);
3852 ReleaseStr(sczPackageId);
3853 return hr;
3854}
3855
3856static HRESULT OnPlannedPackage(
3857 __in IBootstrapperApplication* pApplication,
3858 __in BUFF_READER* pReaderArgs,
3859 __in BUFF_READER* pReaderResults,
3860 __in BUFF_BUFFER* pBuffer
3861 )
3862{
3863 HRESULT hr = S_OK;
3864 BA_ONPLANNEDPACKAGE_ARGS args = { };
3865 BA_ONPLANNEDPACKAGE_RESULTS results = { };
3866 LPWSTR sczPackageId = NULL;
3867
3868 // Read args.
3869 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3870 ExitOnFailure(hr, "Failed to read API version of OnPlannedPackage args.");
3871
3872 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3873 ExitOnFailure(hr, "Failed to read package id of OnPlannedPackage args.");
3874
3875 args.wzPackageId = sczPackageId;
3876
3877 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.execute));
3878 ExitOnFailure(hr, "Failed to read execute of OnPlannedPackage args.");
3879
3880 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.rollback));
3881 ExitOnFailure(hr, "Failed to read rollback of OnPlannedPackage args.");
3882
3883 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPlannedCache));
3884 ExitOnFailure(hr, "Failed to read planned cache of OnPlannedPackage args.");
3885
3886 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fPlannedUncache));
3887 ExitOnFailure(hr, "Failed to read planned uncache of OnPlannedPackage args.");
3888
3889 // Read results.
3890 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3891 ExitOnFailure(hr, "Failed to read API version of OnPlannedPackage results.");
3892
3893 // Callback.
3894 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, &args, &results);
3895
3896 if (E_NOTIMPL == hr)
3897 {
3898 hr = pApplication->OnPlannedPackage(args.wzPackageId, args.execute, args.rollback, args.fPlannedCache, args.fPlannedUncache);
3899 }
3900
3901 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE, &args, &results, &hr);
3902 BalExitOnFailure(hr, "BA OnPlannedPackage failed.");
3903
3904 // Write results.
3905 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3906 ExitOnFailure(hr, "Failed to write size of OnPlannedPackage struct.");
3907
3908LExit:
3909 ReleaseStr(sczPackageId);
3910 return hr;
3911}
3912
3913static HRESULT OnPlanPackageBegin(
3914 __in IBootstrapperApplication* pApplication,
3915 __in BUFF_READER* pReaderArgs,
3916 __in BUFF_READER* pReaderResults,
3917 __in BUFF_BUFFER* pBuffer
3918 )
3919{
3920 HRESULT hr = S_OK;
3921 BA_ONPLANPACKAGEBEGIN_ARGS args = { };
3922 BA_ONPLANPACKAGEBEGIN_RESULTS results = { };
3923 LPWSTR sczPackageId = NULL;
3924
3925 // Read args.
3926 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
3927 ExitOnFailure(hr, "Failed to read API version of OnPlanPackageBegin args.");
3928
3929 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
3930 ExitOnFailure(hr, "Failed to read package id of OnPlanPackageBegin args.");
3931
3932 args.wzPackageId = sczPackageId;
3933
3934 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.state));
3935 ExitOnFailure(hr, "Failed to read state of OnPlanPackageBegin args.");
3936
3937 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fCached));
3938 ExitOnFailure(hr, "Failed to read cached of OnPlanPackageBegin args.");
3939
3940 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.installCondition));
3941 ExitOnFailure(hr, "Failed to read install condition of OnPlanPackageBegin args.");
3942
3943 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.repairCondition));
3944 ExitOnFailure(hr, "Failed to read repair condition of OnPlanPackageBegin args.");
3945
3946 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedState));
3947 ExitOnFailure(hr, "Failed to read recommended state of OnPlanPackageBegin args.");
3948
3949 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedCacheType));
3950 ExitOnFailure(hr, "Failed to read recommended cache type of OnPlanPackageBegin args.");
3951
3952 // Read results.
3953 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
3954 ExitOnFailure(hr, "Failed to read API version of OnPlanPackageBegin results.");
3955
3956 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedState));
3957 ExitOnFailure(hr, "Failed to read requested state of OnPlanPackageBegin results.");
3958
3959 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedCacheType));
3960 ExitOnFailure(hr, "Failed to read requested cache type of OnPlanPackageBegin results.");
3961
3962 // Callback.
3963 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, &args, &results);
3964
3965 if (E_NOTIMPL == hr)
3966 {
3967 hr = pApplication->OnPlanPackageBegin(args.wzPackageId, args.state, args.fCached, args.installCondition, args.repairCondition, args.recommendedState, args.recommendedCacheType, &results.requestedState, &results.requestedCacheType, &results.fCancel);
3968 }
3969
3970 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN, &args, &results, &hr);
3971 BalExitOnFailure(hr, "BA OnPlanPackageBegin failed.");
3972
3973 // Write results.
3974 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
3975 ExitOnFailure(hr, "Failed to write size of OnPlanPackageBegin struct.");
3976
3977 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
3978 ExitOnFailure(hr, "Failed to write cancel of OnPlanPackageBegin struct.");
3979
3980 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState);
3981 ExitOnFailure(hr, "Failed to write requested state of OnPlanPackageBegin struct.");
3982
3983 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedCacheType);
3984 ExitOnFailure(hr, "Failed to write requested cache type of OnPlanPackageBegin struct.");
3985
3986LExit:
3987 ReleaseStr(sczPackageId);
3988 return hr;
3989}
3990
3991static HRESULT OnPlanPackageComplete(
3992 __in IBootstrapperApplication* pApplication,
3993 __in BUFF_READER* pReaderArgs,
3994 __in BUFF_READER* pReaderResults,
3995 __in BUFF_BUFFER* pBuffer
3996 )
3997{
3998 HRESULT hr = S_OK;
3999 BA_ONPLANPACKAGECOMPLETE_ARGS args = { };
4000 BA_ONPLANPACKAGECOMPLETE_RESULTS results = { };
4001 LPWSTR sczPackageId = NULL;
4002
4003 // Read args.
4004 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4005 ExitOnFailure(hr, "Failed to read API version of OnPlanPackageComplete args.");
4006
4007 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
4008 ExitOnFailure(hr, "Failed to read package id of OnPlanPackageComplete args.");
4009
4010 args.wzPackageId = sczPackageId;
4011
4012 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
4013 ExitOnFailure(hr, "Failed to read status of OnPlanPackageComplete args.");
4014
4015 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.requested));
4016 ExitOnFailure(hr, "Failed to read requested of OnPlanPackageComplete args.");
4017
4018 // Read results.
4019 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4020 ExitOnFailure(hr, "Failed to read API version of OnPlanPackageComplete results.");
4021
4022 // Callback.
4023 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, &args, &results);
4024
4025 if (E_NOTIMPL == hr)
4026 {
4027 hr = pApplication->OnPlanPackageComplete(args.wzPackageId, args.hrStatus, args.requested);
4028 }
4029
4030 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE, &args, &results, &hr);
4031 BalExitOnFailure(hr, "BA OnPlanPackageComplete failed.");
4032
4033 // Write results.
4034 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4035 ExitOnFailure(hr, "Failed to write size of OnPlanPackageComplete struct.");
4036
4037LExit:
4038 ReleaseStr(sczPackageId);
4039 return hr;
4040}
4041
4042static HRESULT OnPlanRelatedBundle(
4043 __in IBootstrapperApplication* pApplication,
4044 __in BUFF_READER* pReaderArgs,
4045 __in BUFF_READER* pReaderResults,
4046 __in BUFF_BUFFER* pBuffer
4047 )
4048{
4049 HRESULT hr = S_OK;
4050 BA_ONPLANRELATEDBUNDLE_ARGS args = { };
4051 BA_ONPLANRELATEDBUNDLE_RESULTS results = { };
4052 LPWSTR sczBundleId = NULL;
4053
4054 // Read args.
4055 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4056 ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundle args.");
4057
4058 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
4059 ExitOnFailure(hr, "Failed to read package id of OnPlanRelatedBundle args.");
4060
4061 args.wzBundleId = sczBundleId;
4062
4063 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedState));
4064 ExitOnFailure(hr, "Failed to read recommended state of OnPlanRelatedBundle args.");
4065
4066 // Read results.
4067 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4068 ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundle results.");
4069
4070 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedState));
4071 ExitOnFailure(hr, "Failed to read requested state of OnPlanRelatedBundle results.");
4072
4073 // Callback.
4074 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, &args, &results);
4075
4076 if (E_NOTIMPL == hr)
4077 {
4078 hr = pApplication->OnPlanRelatedBundle(args.wzBundleId, args.recommendedState, &results.requestedState, &results.fCancel);
4079 }
4080
4081 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE, &args, &results, &hr);
4082 BalExitOnFailure(hr, "BA OnPlanRelatedBundle failed.");
4083
4084 // Write results.
4085 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4086 ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundle struct.");
4087
4088 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4089 ExitOnFailure(hr, "Failed to write cancel of OnPlanRelatedBundle struct.");
4090
4091 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState);
4092 ExitOnFailure(hr, "Failed to write requested state of OnPlanRelatedBundle struct.");
4093
4094LExit:
4095 ReleaseStr(sczBundleId);
4096 return hr;
4097}
4098
4099static HRESULT OnPlanRelatedBundleType(
4100 __in IBootstrapperApplication* pApplication,
4101 __in BUFF_READER* pReaderArgs,
4102 __in BUFF_READER* pReaderResults,
4103 __in BUFF_BUFFER* pBuffer
4104 )
4105{
4106 HRESULT hr = S_OK;
4107 BA_ONPLANRELATEDBUNDLETYPE_ARGS args = { };
4108 BA_ONPLANRELATEDBUNDLETYPE_RESULTS results = { };
4109 LPWSTR sczBundleId = NULL;
4110
4111 // Read args.
4112 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4113 ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundleType args.");
4114
4115 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
4116 ExitOnFailure(hr, "Failed to read package id of OnPlanRelatedBundleType args.");
4117
4118 args.wzBundleId = sczBundleId;
4119
4120 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedType));
4121 ExitOnFailure(hr, "Failed to read recommended type of OnPlanRelatedBundleType args.");
4122
4123 // Read results.
4124 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4125 ExitOnFailure(hr, "Failed to read API version of OnPlanRelatedBundleType results.");
4126
4127 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedType));
4128 ExitOnFailure(hr, "Failed to read requested type of OnPlanRelatedBundleType results.");
4129
4130 // Callback.
4131 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, &args, &results);
4132
4133 if (E_NOTIMPL == hr)
4134 {
4135 hr = pApplication->OnPlanRelatedBundleType(args.wzBundleId, args.recommendedType, &results.requestedType, &results.fCancel);
4136 }
4137
4138 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, &args, &results, &hr);
4139 BalExitOnFailure(hr, "BA OnPlanRelatedBundleType failed.");
4140
4141 // Write results.
4142 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4143 ExitOnFailure(hr, "Failed to write size of OnPlanRelatedBundleType struct.");
4144
4145 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4146 ExitOnFailure(hr, "Failed to write cancel of OnPlanRelatedBundleType struct.");
4147
4148 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedType);
4149 ExitOnFailure(hr, "Failed to write requested type of OnPlanRelatedBundleType struct.");
4150
4151LExit:
4152 ReleaseStr(sczBundleId);
4153 return hr;
4154}
4155
4156static HRESULT OnPlanRestoreRelatedBundle(
4157 __in IBootstrapperApplication* pApplication,
4158 __in BUFF_READER* pReaderArgs,
4159 __in BUFF_READER* pReaderResults,
4160 __in BUFF_BUFFER* pBuffer
4161 )
4162{
4163 HRESULT hr = S_OK;
4164 BA_ONPLANRESTORERELATEDBUNDLE_ARGS args = { };
4165 BA_ONPLANRESTORERELATEDBUNDLE_RESULTS results = { };
4166 LPWSTR sczBundleId = NULL;
4167
4168 // Read args.
4169 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4170 ExitOnFailure(hr, "Failed to read API version of OnPlanRestoreRelatedBundle args.");
4171
4172 hr = BuffReaderReadString(pReaderArgs, &sczBundleId);
4173 ExitOnFailure(hr, "Failed to read package id of OnPlanRestoreRelatedBundle args.");
4174
4175 args.wzBundleId = sczBundleId;
4176
4177 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedState));
4178 ExitOnFailure(hr, "Failed to read recommended state of OnPlanRestoreRelatedBundle args.");
4179
4180 // Read results.
4181 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4182 ExitOnFailure(hr, "Failed to read API version of OnPlanRestoreRelatedBundle results.");
4183
4184 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedState));
4185 ExitOnFailure(hr, "Failed to read requested state of OnPlanRestoreRelatedBundle results.");
4186
4187 // Callback.
4188 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, &args, &results);
4189
4190 if (E_NOTIMPL == hr)
4191 {
4192 hr = pApplication->OnPlanRestoreRelatedBundle(args.wzBundleId, args.recommendedState, &results.requestedState, &results.fCancel);
4193 }
4194
4195 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, &args, &results, &hr);
4196 BalExitOnFailure(hr, "BA OnPlanRestoreRelatedBundle failed.");
4197
4198 // Write results.
4199 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4200 ExitOnFailure(hr, "Failed to write size of OnPlanRestoreRelatedBundle struct.");
4201
4202 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4203 ExitOnFailure(hr, "Failed to write cancel of OnPlanRestoreRelatedBundle struct.");
4204
4205 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState);
4206 ExitOnFailure(hr, "Failed to write requested state of OnPlanRestoreRelatedBundle struct.");
4207
4208LExit:
4209 ReleaseStr(sczBundleId);
4210 return hr;
4211}
4212
4213static HRESULT OnPlanRollbackBoundary(
4214 __in IBootstrapperApplication* pApplication,
4215 __in BUFF_READER* pReaderArgs,
4216 __in BUFF_READER* pReaderResults,
4217 __in BUFF_BUFFER* pBuffer
4218 )
4219{
4220 HRESULT hr = S_OK;
4221 BA_ONPLANROLLBACKBOUNDARY_ARGS args = { };
4222 BA_ONPLANROLLBACKBOUNDARY_RESULTS results = { };
4223 LPWSTR sczRollbackBoundaryId = NULL;
4224
4225 // Read args.
4226 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4227 ExitOnFailure(hr, "Failed to read API version of OnPlanRollbackBoundary args.");
4228
4229 hr = BuffReaderReadString(pReaderArgs, &sczRollbackBoundaryId);
4230 ExitOnFailure(hr, "Failed to read rollback boundary id of OnPlanRollbackBoundary args.");
4231
4232 args.wzRollbackBoundaryId = sczRollbackBoundaryId;
4233
4234 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.fRecommendedTransaction));
4235 ExitOnFailure(hr, "Failed to read recommended transaction of OnPlanRollbackBoundary args.");
4236
4237 // Read results.
4238 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4239 ExitOnFailure(hr, "Failed to read API version of OnPlanRollbackBoundary results.");
4240
4241 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.fTransaction));
4242 ExitOnFailure(hr, "Failed to read transaction of OnPlanRollbackBoundary results.");
4243
4244 // Callback.
4245 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, &args, &results);
4246
4247 if (E_NOTIMPL == hr)
4248 {
4249 hr = pApplication->OnPlanRollbackBoundary(args.wzRollbackBoundaryId, args.fRecommendedTransaction, &results.fTransaction, &results.fCancel);
4250 }
4251
4252 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY, &args, &results, &hr);
4253 BalExitOnFailure(hr, "BA OnPlanRollbackBoundary failed.");
4254
4255 // Write results.
4256 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4257 ExitOnFailure(hr, "Failed to write size of OnPlanRollbackBoundary struct.");
4258
4259 hr = BuffWriteNumberToBuffer(pBuffer, results.fTransaction);
4260 ExitOnFailure(hr, "Failed to write transaction of OnPlanRollbackBoundary struct.");
4261
4262 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4263 ExitOnFailure(hr, "Failed to write cancel of OnPlanRollbackBoundary struct.");
4264
4265LExit:
4266 ReleaseStr(sczRollbackBoundaryId);
4267 return hr;
4268}
4269
4270static HRESULT OnPlanPatchTarget(
4271 __in IBootstrapperApplication* pApplication,
4272 __in BUFF_READER* pReaderArgs,
4273 __in BUFF_READER* pReaderResults,
4274 __in BUFF_BUFFER* pBuffer
4275 )
4276{
4277 HRESULT hr = S_OK;
4278 BA_ONPLANPATCHTARGET_ARGS args = { };
4279 BA_ONPLANPATCHTARGET_RESULTS results = { };
4280 LPWSTR sczPackageId = NULL;
4281 LPWSTR sczProductCode = NULL;
4282
4283 // Read args.
4284 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4285 ExitOnFailure(hr, "Failed to read API version of OnPlanPatchTarget args.");
4286
4287 hr = BuffReaderReadString(pReaderArgs, &sczPackageId);
4288 ExitOnFailure(hr, "Failed to read package id of OnPlanPatchTarget args.");
4289
4290 args.wzPackageId = sczPackageId;
4291
4292 hr = BuffReaderReadString(pReaderArgs, &sczProductCode);
4293 ExitOnFailure(hr, "Failed to read product code of OnPlanPatchTarget args.");
4294
4295 args.wzProductCode = sczProductCode;
4296
4297 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedState));
4298 ExitOnFailure(hr, "Failed to read recommended state transaction of OnPlanPatchTarget args.");
4299
4300 // Read results.
4301 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4302 ExitOnFailure(hr, "Failed to read API version of OnPlanPatchTarget results.");
4303
4304 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.requestedState));
4305 ExitOnFailure(hr, "Failed to read requested state of OnPlanPatchTarget results.");
4306
4307 // Callback.
4308 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, &args, &results);
4309
4310 if (E_NOTIMPL == hr)
4311 {
4312 hr = pApplication->OnPlanPatchTarget(args.wzPackageId, args.wzProductCode, args.recommendedState, &results.requestedState, &results.fCancel);
4313 }
4314
4315 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET, &args, &results, &hr);
4316 BalExitOnFailure(hr, "BA OnPlanPatchTarget failed.");
4317
4318 // Write results.
4319 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4320 ExitOnFailure(hr, "Failed to write size of OnPlanPatchTarget struct.");
4321
4322 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4323 ExitOnFailure(hr, "Failed to write cancel of OnPlanPatchTarget struct.");
4324
4325 hr = BuffWriteNumberToBuffer(pBuffer, results.requestedState);
4326 ExitOnFailure(hr, "Failed to write transaction of OnPlanPatchTarget struct.");
4327
4328LExit:
4329 ReleaseStr(sczProductCode);
4330 ReleaseStr(sczPackageId);
4331 return hr;
4332}
4333
4334static HRESULT OnProgress(
4335 __in IBootstrapperApplication* pApplication,
4336 __in BUFF_READER* pReaderArgs,
4337 __in BUFF_READER* pReaderResults,
4338 __in BUFF_BUFFER* pBuffer
4339 )
4340{
4341 HRESULT hr = S_OK;
4342 BA_ONPROGRESS_ARGS args = { };
4343 BA_ONPROGRESS_RESULTS results = { };
4344
4345 // Read args.
4346 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4347 ExitOnFailure(hr, "Failed to read API version of OnProgress args.");
4348
4349 hr = BuffReaderReadNumber(pReaderArgs, &args.dwProgressPercentage);
4350 ExitOnFailure(hr, "Failed to read progress of OnProgress args.");
4351
4352 hr = BuffReaderReadNumber(pReaderArgs, &args.dwOverallPercentage);
4353 ExitOnFailure(hr, "Failed to read overall progress of OnProgress args.");
4354
4355 // Read results.
4356 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4357 ExitOnFailure(hr, "Failed to read API version of OnProgress results.");
4358
4359 // Callback.
4360 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, &args, &results);
4361
4362 if (E_NOTIMPL == hr)
4363 {
4364 hr = pApplication->OnProgress(args.dwProgressPercentage, args.dwOverallPercentage, &results.fCancel);
4365 }
4366
4367 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS, &args, &results, &hr);
4368 BalExitOnFailure(hr, "BA OnProgress failed.");
4369
4370 // Write results.
4371 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4372 ExitOnFailure(hr, "Failed to write size of OnProgress struct.");
4373
4374 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4375 ExitOnFailure(hr, "Failed to write cancel of OnProgress struct.");
4376
4377LExit:
4378 return hr;
4379}
4380
4381static HRESULT OnRegisterBegin(
4382 __in IBootstrapperApplication* pApplication,
4383 __in BUFF_READER* pReaderArgs,
4384 __in BUFF_READER* pReaderResults,
4385 __in BUFF_BUFFER* pBuffer
4386 )
4387{
4388 HRESULT hr = S_OK;
4389 BA_ONREGISTERBEGIN_ARGS args = { };
4390 BA_ONREGISTERBEGIN_RESULTS results = { };
4391
4392 // Read args.
4393 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4394 ExitOnFailure(hr, "Failed to read API version of OnRegisterBegin args.");
4395
4396 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedRegistrationType));
4397 ExitOnFailure(hr, "Failed to read recommended registration type of OnRegisterBegin args.");
4398
4399 // Read results.
4400 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4401 ExitOnFailure(hr, "Failed to read API version of OnRegisterBegin results.");
4402
4403 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.registrationType));
4404 ExitOnFailure(hr, "Failed to read registration type of OnRegisterBegin results.");
4405
4406 // Callback.
4407 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, &args, &results);
4408
4409 if (E_NOTIMPL == hr)
4410 {
4411 hr = pApplication->OnRegisterBegin(args.recommendedRegistrationType, &results.fCancel, &results.registrationType);
4412 }
4413
4414 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN, &args, &results, &hr);
4415 BalExitOnFailure(hr, "BA OnRegisterBegin failed.");
4416
4417 // Write results.
4418 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4419 ExitOnFailure(hr, "Failed to write size of OnRegisterBegin struct.");
4420
4421 hr = BuffWriteNumberToBuffer(pBuffer, results.fCancel);
4422 ExitOnFailure(hr, "Failed to write cancel of OnRegisterBegin struct.");
4423
4424 hr = BuffWriteNumberToBuffer(pBuffer, results.registrationType);
4425 ExitOnFailure(hr, "Failed to write registration type of OnRegisterBegin struct.");
4426
4427LExit:
4428 return hr;
4429}
4430
4431static HRESULT OnRegisterComplete(
4432 __in IBootstrapperApplication* pApplication,
4433 __in BUFF_READER* pReaderArgs,
4434 __in BUFF_READER* pReaderResults,
4435 __in BUFF_BUFFER* pBuffer
4436 )
4437{
4438 HRESULT hr = S_OK;
4439 BA_ONREGISTERCOMPLETE_ARGS args = { };
4440 BA_ONREGISTERCOMPLETE_RESULTS results = { };
4441
4442 // Read args.
4443 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4444 ExitOnFailure(hr, "Failed to read API version of OnRegisterComplete args.");
4445
4446 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
4447 ExitOnFailure(hr, "Failed to read status of OnRegisterComplete args.");
4448
4449 // Read results.
4450 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4451 ExitOnFailure(hr, "Failed to read API version of OnRegisterComplete results.");
4452
4453 // Callback.
4454 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, &args, &results);
4455
4456 if (E_NOTIMPL == hr)
4457 {
4458 hr = pApplication->OnRegisterComplete(args.hrStatus);
4459 }
4460
4461 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE, &args, &results, &hr);
4462 BalExitOnFailure(hr, "BA OnRegisterComplete failed.");
4463
4464 // Write results.
4465 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4466 ExitOnFailure(hr, "Failed to write size of OnRegisterComplete struct.");
4467
4468LExit:
4469 return hr;
4470}
4471
4472static HRESULT OnRollbackMsiTransactionBegin(
4473 __in IBootstrapperApplication* pApplication,
4474 __in BUFF_READER* pReaderArgs,
4475 __in BUFF_READER* pReaderResults,
4476 __in BUFF_BUFFER* pBuffer
4477 )
4478{
4479 HRESULT hr = S_OK;
4480 BA_ONROLLBACKMSITRANSACTIONBEGIN_ARGS args = { };
4481 BA_ONROLLBACKMSITRANSACTIONBEGIN_RESULTS results = { };
4482 LPWSTR sczTransactionId = NULL;
4483
4484 // Read args.
4485 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4486 ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionBegin args.");
4487
4488 hr = BuffReaderReadString(pReaderArgs, &sczTransactionId);
4489 ExitOnFailure(hr, "Failed to read transaction id of OnRollbackMsiTransactionBegin args.");
4490
4491 args.wzTransactionId = sczTransactionId;
4492
4493 // Read results.
4494 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4495 ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionBegin results.");
4496
4497 // Callback.
4498 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &args, &results);
4499
4500 if (E_NOTIMPL == hr)
4501 {
4502 hr = pApplication->OnRollbackMsiTransactionBegin(args.wzTransactionId);
4503 }
4504
4505 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN, &args, &results, &hr);
4506 BalExitOnFailure(hr, "BA OnRollbackMsiTransactionBegin failed.");
4507
4508 // Write results.
4509 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4510 ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionBegin struct.");
4511
4512LExit:
4513 ReleaseStr(sczTransactionId);
4514 return hr;
4515}
4516
4517static HRESULT OnRollbackMsiTransactionComplete(
4518 __in IBootstrapperApplication* pApplication,
4519 __in BUFF_READER* pReaderArgs,
4520 __in BUFF_READER* pReaderResults,
4521 __in BUFF_BUFFER* pBuffer
4522 )
4523{
4524 HRESULT hr = S_OK;
4525 BA_ONROLLBACKMSITRANSACTIONCOMPLETE_ARGS args = { };
4526 BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS results = { };
4527 LPWSTR sczTransactionId = NULL;
4528
4529 // Read args.
4530 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4531 ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionComplete args.");
4532
4533 hr = BuffReaderReadString(pReaderArgs, &sczTransactionId);
4534 ExitOnFailure(hr, "Failed to read transaction id of OnRollbackMsiTransactionComplete args.");
4535
4536 args.wzTransactionId = sczTransactionId;
4537
4538 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
4539 ExitOnFailure(hr, "Failed to read status of OnRollbackMsiTransactionComplete args.");
4540
4541 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.restart));
4542 ExitOnFailure(hr, "Failed to read restart of OnRollbackMsiTransactionComplete args.");
4543
4544 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendation));
4545 ExitOnFailure(hr, "Failed to read recommendation of OnRollbackMsiTransactionComplete args.");
4546
4547 // Read results.
4548 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4549 ExitOnFailure(hr, "Failed to read API version of OnRollbackMsiTransactionComplete results.");
4550
4551 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
4552 ExitOnFailure(hr, "Failed to read action of OnRollbackMsiTransactionComplete results.");
4553
4554 // Callback.
4555 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &args, &results);
4556
4557 if (E_NOTIMPL == hr)
4558 {
4559 hr = pApplication->OnRollbackMsiTransactionComplete(args.wzTransactionId, args.hrStatus, args.restart, args.recommendation, &results.action);
4560 }
4561
4562 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE, &args, &results, &hr);
4563 BalExitOnFailure(hr, "BA OnRollbackMsiTransactionComplete failed.");
4564
4565 // Write results.
4566 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4567 ExitOnFailure(hr, "Failed to write size of OnRollbackMsiTransactionComplete struct.");
4568
4569 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
4570 ExitOnFailure(hr, "Failed to write action of OnRollbackMsiTransactionComplete struct.");
4571
4572LExit:
4573 ReleaseStr(sczTransactionId);
4574 return hr;
4575}
4576
4577static HRESULT OnShutdown(
4578 __in IBootstrapperApplication* pApplication,
4579 __in BUFF_READER* pReaderArgs,
4580 __in BUFF_READER* pReaderResults,
4581 __in BUFF_BUFFER* pBuffer
4582 )
4583{
4584 HRESULT hr = S_OK;
4585 BA_ONSHUTDOWN_ARGS args = { };
4586 BA_ONSHUTDOWN_RESULTS results = { };
4587
4588 // Read args.
4589 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4590 ExitOnFailure(hr, "Failed to read API version of OnShutdown args.");
4591
4592 // Read results.
4593 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4594 ExitOnFailure(hr, "Failed to read API version of OnShutdown results.");
4595
4596 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.action));
4597 ExitOnFailure(hr, "Failed to read action of OnShutdown results.");
4598
4599 // Callback.
4600 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &args, &results);
4601
4602 if (E_NOTIMPL == hr)
4603 {
4604 hr = pApplication->OnShutdown(&results.action);
4605 }
4606
4607 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &args, &results, &hr);
4608 BalExitOnFailure(hr, "BA OnStartup failed.");
4609
4610 // Write results.
4611 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4612 ExitOnFailure(hr, "Failed to write size of OnShutdown struct.");
4613
4614 hr = BuffWriteNumberToBuffer(pBuffer, results.action);
4615 ExitOnFailure(hr, "Failed to write action of OnShutdown struct.");
4616
4617LExit:
4618 return hr;
4619}
4620
4621static HRESULT OnStartup(
4622 __in IBootstrapperApplication* pApplication,
4623 __in BUFF_READER* pReaderArgs,
4624 __in BUFF_READER* pReaderResults,
4625 __in BUFF_BUFFER* pBuffer
4626 )
4627{
4628 HRESULT hr = S_OK;
4629 BA_ONSTARTUP_ARGS args = { };
4630 BA_ONSTARTUP_RESULTS results = { };
4631
4632 // Read args.
4633 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4634 ExitOnFailure(hr, "Failed to read API version of OnStartup args.");
4635
4636 // Read results.
4637 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4638 ExitOnFailure(hr, "Failed to read API version of OnStartup results.");
4639
4640 // Callback.
4641 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &args, &results);
4642
4643 if (E_NOTIMPL == hr)
4644 {
4645 hr = pApplication->OnStartup();
4646 }
4647
4648 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &args, &results, &hr);
4649 BalExitOnFailure(hr, "BA OnStartup failed.");
4650
4651 // Write results.
4652 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4653 ExitOnFailure(hr, "Failed to write size of OnStartup struct.");
4654
4655LExit:
4656 return hr;
4657}
4658
4659static HRESULT OnSystemRestorePointBegin(
4660 __in IBootstrapperApplication* pApplication,
4661 __in BUFF_READER* pReaderArgs,
4662 __in BUFF_READER* pReaderResults,
4663 __in BUFF_BUFFER* pBuffer
4664 )
4665{
4666 HRESULT hr = S_OK;
4667 BA_ONSYSTEMRESTOREPOINTBEGIN_ARGS args = { };
4668 BA_ONSYSTEMRESTOREPOINTBEGIN_RESULTS results = { };
4669
4670 // Read args.
4671 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4672 ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointBegin args.");
4673
4674 // Read results.
4675 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4676 ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointBegin results.");
4677
4678 // Callback.
4679 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &args, &results);
4680
4681 if (E_NOTIMPL == hr)
4682 {
4683 hr = pApplication->OnSystemRestorePointBegin();
4684 }
4685
4686 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN, &args, &results, &hr);
4687 BalExitOnFailure(hr, "BA OnSystemRestorePointBegin failed.");
4688
4689 // Write results.
4690 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4691 ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointBegin struct.");
4692
4693LExit:
4694 return hr;
4695}
4696
4697static HRESULT OnSystemRestorePointComplete(
4698 __in IBootstrapperApplication* pApplication,
4699 __in BUFF_READER* pReaderArgs,
4700 __in BUFF_READER* pReaderResults,
4701 __in BUFF_BUFFER* pBuffer
4702 )
4703{
4704 HRESULT hr = S_OK;
4705 BA_ONSYSTEMRESTOREPOINTCOMPLETE_ARGS args = { };
4706 BA_ONSYSTEMRESTOREPOINTCOMPLETE_RESULTS results = { };
4707
4708 // Read args.
4709 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4710 ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointComplete args.");
4711
4712 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
4713 ExitOnFailure(hr, "Failed to read status of OnSystemRestorePointComplete args.");
4714
4715 // Read results.
4716 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4717 ExitOnFailure(hr, "Failed to read API version of OnSystemRestorePointComplete results.");
4718
4719 // Callback.
4720 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, &args, &results);
4721
4722 if (E_NOTIMPL == hr)
4723 {
4724 hr = pApplication->OnSystemRestorePointComplete(args.hrStatus);
4725 }
4726
4727 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE, &args, &results, &hr);
4728 BalExitOnFailure(hr, "BA OnSystemRestorePointComplete failed.");
4729
4730 // Write results.
4731 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4732 ExitOnFailure(hr, "Failed to write size of OnSystemRestorePointComplete struct.");
4733
4734LExit:
4735 return hr;
4736}
4737
4738static HRESULT OnUnregisterBegin(
4739 __in IBootstrapperApplication* pApplication,
4740 __in BUFF_READER* pReaderArgs,
4741 __in BUFF_READER* pReaderResults,
4742 __in BUFF_BUFFER* pBuffer
4743 )
4744{
4745 HRESULT hr = S_OK;
4746 BA_ONUNREGISTERBEGIN_ARGS args = { };
4747 BA_ONUNREGISTERBEGIN_RESULTS results = { };
4748
4749 // Read args.
4750 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4751 ExitOnFailure(hr, "Failed to read API version of OnUnregisterBegin args.");
4752
4753 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.recommendedRegistrationType));
4754 ExitOnFailure(hr, "Failed to read recommended registration type of OnUnregisterBegin args.");
4755
4756 // Read results.
4757 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4758 ExitOnFailure(hr, "Failed to read API version of OnUnregisterBegin results.");
4759
4760 hr = BuffReaderReadNumber(pReaderResults, reinterpret_cast<DWORD*>(&results.registrationType));
4761 ExitOnFailure(hr, "Failed to read registration type of OnUnregisterBegin results.");
4762
4763 // Callback.
4764 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, &args, &results);
4765
4766 if (E_NOTIMPL == hr)
4767 {
4768 hr = pApplication->OnUnregisterBegin(args.recommendedRegistrationType, &results.registrationType);
4769 }
4770
4771 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN, &args, &results, &hr);
4772 BalExitOnFailure(hr, "BA OnUnregisterBegin failed.");
4773
4774 // Write results.
4775 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4776 ExitOnFailure(hr, "Failed to write size of OnUnregisterBegin struct.");
4777
4778 hr = BuffWriteNumberToBuffer(pBuffer, results.registrationType);
4779 ExitOnFailure(hr, "Failed to write registration type of OnUnregisterBegin struct.");
4780
4781LExit:
4782 return hr;
4783}
4784
4785static HRESULT OnUnregisterComplete(
4786 __in IBootstrapperApplication* pApplication,
4787 __in BUFF_READER* pReaderArgs,
4788 __in BUFF_READER* pReaderResults,
4789 __in BUFF_BUFFER* pBuffer
4790 )
4791{
4792 HRESULT hr = S_OK;
4793 BA_ONUNREGISTERCOMPLETE_ARGS args = { };
4794 BA_ONUNREGISTERCOMPLETE_RESULTS results = { };
4795
4796 // Read args.
4797 hr = BuffReaderReadNumber(pReaderArgs, &args.dwApiVersion);
4798 ExitOnFailure(hr, "Failed to read API version of OnUnregisterComplete args.");
4799
4800 hr = BuffReaderReadNumber(pReaderArgs, reinterpret_cast<DWORD*>(&args.hrStatus));
4801 ExitOnFailure(hr, "Failed to read status of OnUnregisterComplete args.");
4802
4803 // Read results.
4804 hr = BuffReaderReadNumber(pReaderResults, &results.dwApiVersion);
4805 ExitOnFailure(hr, "Failed to read API version of OnUnregisterComplete results.");
4806
4807 // Callback.
4808 hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, &args, &results);
4809
4810 if (E_NOTIMPL == hr)
4811 {
4812 hr = pApplication->OnUnregisterComplete(args.hrStatus);
4813 }
4814
4815 pApplication->BAProcFallback(BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE, &args, &results, &hr);
4816 BalExitOnFailure(hr, "BA OnUnregisterComplete failed.");
4817
4818 // Write results.
4819 hr = BuffWriteNumberToBuffer(pBuffer, sizeof(results));
4820 ExitOnFailure(hr, "Failed to write size of OnUnregisterComplete struct.");
4821
4822LExit:
4823 return hr;
4824}
4825
4826static HRESULT ParseArgsAndResults(
4827 __in_bcount(cbData) LPCBYTE pbData,
4828 __in SIZE_T cbData,
4829 __in BUFF_READER* pBufferArgs,
4830 __in BUFF_READER* pBufferResults
4831)
4832{
4833 HRESULT hr = S_OK;
4834 SIZE_T iData = 0;
4835 DWORD dw = 0;
4836
4837 // Get the args reader size and point to the data just after the size.
4838 hr = BuffReadNumber(pbData, cbData, &iData, &dw);
4839 ExitOnFailure(hr, "Failed to parse size of args");
4840
4841 pBufferArgs->pbData = pbData + iData;
4842 pBufferArgs->cbData = dw;
4843 pBufferArgs->iBuffer = 0;
4844
4845 // Get the results reader size and point to the data just after the size.
4846 hr = ::SIZETAdd(iData, dw, &iData);
4847 ExitOnFailure(hr, "Failed to advance index beyond args");
4848
4849 hr = BuffReadNumber(pbData, cbData, &iData, &dw);
4850 ExitOnFailure(hr, "Failed to parse size of results");
4851
4852 pBufferResults->pbData = pbData + iData;
4853 pBufferResults->cbData = dw;
4854 pBufferResults->iBuffer = 0;
4855
4856LExit:
4857 return hr;
4858}
4859
4860static HRESULT ProcessMessage(
4861 __in PIPE_RPC_HANDLE* phRpcPipe,
4862 __in IBootstrapperApplication* pApplication,
4863 __in IBootstrapperEngine* pEngine,
4864 __in BOOTSTRAPPER_APPLICATION_MESSAGE messageType,
4865 __in_bcount(cbData) LPCBYTE pbData,
4866 __in SIZE_T cbData
4867 )
4868{
4869 HRESULT hr = S_OK;
4870 BUFF_READER readerArgs = { };
4871 BUFF_READER readerResults = { };
4872 BUFF_BUFFER bufferResponse = { };
4873
4874 hr = ParseArgsAndResults(pbData, cbData, &readerArgs, &readerResults);
4875 if (SUCCEEDED(hr))
4876 {
4877 switch (messageType)
4878 {
4879 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCREATE:
4880 hr = OnCreate(pApplication, pEngine, &readerArgs, &readerResults, &bufferResponse);
4881 break;
4882
4883 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDESTROY:
4884 hr = OnDestroy(pApplication, &readerArgs, &readerResults, &bufferResponse);
4885 break;
4886
4887 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP:
4888 hr = OnStartup(pApplication, &readerArgs, &readerResults, &bufferResponse);
4889 break;
4890
4891 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN:
4892 hr = OnShutdown(pApplication, &readerArgs, &readerResults, &bufferResponse);
4893 break;
4894
4895 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTBEGIN:
4896 hr = OnDetectBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4897 break;
4898
4899 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPLETE:
4900 hr = OnDetectComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4901 break;
4902
4903 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE:
4904 hr = OnDetectForwardCompatibleBundle(pApplication, &readerArgs, &readerResults, &bufferResponse);
4905 break;
4906
4907 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTMSIFEATURE:
4908 hr = OnDetectMsiFeature(pApplication, &readerArgs, &readerResults, &bufferResponse);
4909 break;
4910
4911 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLE:
4912 hr = OnDetectRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse);
4913 break;
4914
4915 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGEBEGIN:
4916 hr = OnDetectPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4917 break;
4918
4919 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPACKAGECOMPLETE:
4920 hr = OnDetectPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4921 break;
4922
4923 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDMSIPACKAGE:
4924 hr = OnDetectRelatedMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse);
4925 break;
4926
4927 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTPATCHTARGET:
4928 hr = OnDetectPatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse);
4929 break;
4930
4931 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN:
4932 hr = OnDetectUpdateBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4933 break;
4934
4935 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE:
4936 hr = OnDetectUpdate(pApplication, &readerArgs, &readerResults, &bufferResponse);
4937 break;
4938
4939 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATECOMPLETE:
4940 hr = OnDetectUpdateComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4941 break;
4942
4943 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANBEGIN:
4944 hr = OnPlanBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4945 break;
4946
4947 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPLETE:
4948 hr = OnPlanComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4949 break;
4950
4951 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIFEATURE:
4952 hr = OnPlanMsiFeature(pApplication, &readerArgs, &readerResults, &bufferResponse);
4953 break;
4954
4955 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGEBEGIN:
4956 hr = OnPlanPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4957 break;
4958
4959 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPACKAGECOMPLETE:
4960 hr = OnPlanPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4961 break;
4962
4963 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANPATCHTARGET:
4964 hr = OnPlanPatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse);
4965 break;
4966
4967 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLE:
4968 hr = OnPlanRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse);
4969 break;
4970
4971 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYBEGIN:
4972 hr = OnApplyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4973 break;
4974
4975 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATEBEGIN:
4976 hr = OnElevateBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4977 break;
4978
4979 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONELEVATECOMPLETE:
4980 hr = OnElevateComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4981 break;
4982
4983 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPROGRESS:
4984 hr = OnProgress(pApplication, &readerArgs, &readerResults, &bufferResponse);
4985 break;
4986
4987 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONERROR:
4988 hr = OnError(pApplication, &readerArgs, &readerResults, &bufferResponse);
4989 break;
4990
4991 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERBEGIN:
4992 hr = OnRegisterBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
4993 break;
4994
4995 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONREGISTERCOMPLETE:
4996 hr = OnRegisterComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
4997 break;
4998
4999 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEBEGIN:
5000 hr = OnCacheBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5001 break;
5002
5003 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN:
5004 hr = OnCachePackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5005 break;
5006
5007 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN:
5008 hr = OnCacheAcquireBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5009 break;
5010
5011 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS:
5012 hr = OnCacheAcquireProgress(pApplication, &readerArgs, &readerResults, &bufferResponse);
5013 break;
5014
5015 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING:
5016 hr = OnCacheAcquireResolving(pApplication, &readerArgs, &readerResults, &bufferResponse);
5017 break;
5018
5019 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE:
5020 hr = OnCacheAcquireComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5021 break;
5022
5023 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN:
5024 hr = OnCacheVerifyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5025 break;
5026
5027 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE:
5028 hr = OnCacheVerifyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5029 break;
5030
5031 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE:
5032 hr = OnCachePackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5033 break;
5034
5035 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECOMPLETE:
5036 hr = OnCacheComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5037 break;
5038
5039 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEBEGIN:
5040 hr = OnExecuteBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5041 break;
5042
5043 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGEBEGIN:
5044 hr = OnExecutePackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5045 break;
5046
5047 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPATCHTARGET:
5048 hr = OnExecutePatchTarget(pApplication, &readerArgs, &readerResults, &bufferResponse);
5049 break;
5050
5051 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROGRESS:
5052 hr = OnExecuteProgress(pApplication, &readerArgs, &readerResults, &bufferResponse);
5053 break;
5054
5055 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEMSIMESSAGE:
5056 hr = OnExecuteMsiMessage(pApplication, &readerArgs, &readerResults, &bufferResponse);
5057 break;
5058
5059 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEFILESINUSE:
5060 hr = OnExecuteFilesInUse(pApplication, &readerArgs, &readerResults, &bufferResponse);
5061 break;
5062
5063 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPACKAGECOMPLETE:
5064 hr = OnExecutePackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5065 break;
5066
5067 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTECOMPLETE:
5068 hr = OnExecuteComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5069 break;
5070
5071 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERBEGIN:
5072 hr = OnUnregisterBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5073 break;
5074
5075 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONUNREGISTERCOMPLETE:
5076 hr = OnUnregisterComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5077 break;
5078
5079 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYCOMPLETE:
5080 hr = OnApplyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5081 break;
5082
5083 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXEBEGIN:
5084 hr = OnLaunchApprovedExeBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5085 break;
5086
5087 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONLAUNCHAPPROVEDEXECOMPLETE:
5088 hr = OnLaunchApprovedExeComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5089 break;
5090
5091 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANMSIPACKAGE:
5092 hr = OnPlanMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse);
5093 break;
5094
5095 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONBEGIN:
5096 hr = OnBeginMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5097 break;
5098
5099 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONBEGINMSITRANSACTIONCOMPLETE:
5100 hr = OnBeginMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5101 break;
5102
5103 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONBEGIN:
5104 hr = OnCommitMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5105 break;
5106
5107 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCOMMITMSITRANSACTIONCOMPLETE:
5108 hr = OnCommitMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5109 break;
5110
5111 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONBEGIN:
5112 hr = OnRollbackMsiTransactionBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5113 break;
5114
5115 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONROLLBACKMSITRANSACTIONCOMPLETE:
5116 hr = OnRollbackMsiTransactionComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5117 break;
5118
5119 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESBEGIN:
5120 hr = OnPauseAutomaticUpdatesBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5121 break;
5122
5123 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPAUSEAUTOMATICUPDATESCOMPLETE:
5124 hr = OnPauseAutomaticUpdatesComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5125 break;
5126
5127 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTBEGIN:
5128 hr = OnSystemRestorePointBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5129 break;
5130
5131 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMRESTOREPOINTCOMPLETE:
5132 hr = OnSystemRestorePointComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5133 break;
5134
5135 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDPACKAGE:
5136 hr = OnPlannedPackage(pApplication, &readerArgs, &readerResults, &bufferResponse);
5137 break;
5138
5139 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANFORWARDCOMPATIBLEBUNDLE:
5140 hr = OnPlanForwardCompatibleBundle(pApplication, &readerArgs, &readerResults, &bufferResponse);
5141 break;
5142
5143 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYPROGRESS:
5144 hr = OnCacheVerifyProgress(pApplication, &readerArgs, &readerResults, &bufferResponse);
5145 break;
5146
5147 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN:
5148 hr = OnCacheContainerOrPayloadVerifyBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5149 break;
5150
5151 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE:
5152 hr = OnCacheContainerOrPayloadVerifyComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5153 break;
5154
5155 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS:
5156 hr = OnCacheContainerOrPayloadVerifyProgress(pApplication, &readerArgs, &readerResults, &bufferResponse);
5157 break;
5158
5159 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN:
5160 hr = OnCachePayloadExtractBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5161 break;
5162
5163 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE:
5164 hr = OnCachePayloadExtractComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5165 break;
5166
5167 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS:
5168 hr = OnCachePayloadExtractProgress(pApplication, &readerArgs, &readerResults, &bufferResponse);
5169 break;
5170
5171 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY:
5172 hr = OnPlanRollbackBoundary(pApplication, &readerArgs, &readerResults, &bufferResponse);
5173 break;
5174
5175 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE:
5176 hr = OnDetectCompatibleMsiPackage(pApplication, &readerArgs, &readerResults, &bufferResponse);
5177 break;
5178
5179 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN:
5180 hr = OnPlanCompatibleMsiPackageBegin(pApplication, &readerArgs, &readerResults, &bufferResponse);
5181 break;
5182
5183 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE:
5184 hr = OnPlanCompatibleMsiPackageComplete(pApplication, &readerArgs, &readerResults, &bufferResponse);
5185 break;
5186
5187 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE:
5188 hr = OnPlannedCompatiblePackage(pApplication, &readerArgs, &readerResults, &bufferResponse);
5189 break;
5190
5191 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE:
5192 hr = OnPlanRestoreRelatedBundle(pApplication, &readerArgs, &readerResults, &bufferResponse);
5193 break;
5194
5195 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE:
5196 hr = OnPlanRelatedBundleType(pApplication, &readerArgs, &readerResults, &bufferResponse);
5197 break;
5198
5199 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONAPPLYDOWNGRADE:
5200 hr = OnApplyDowngrade(pApplication, &readerArgs, &readerResults, &bufferResponse);
5201 break;
5202
5203 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONEXECUTEPROCESSCANCEL:
5204 hr = OnExecuteProcessCancel(pApplication, &readerArgs, &readerResults, &bufferResponse);
5205 break;
5206
5207 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTRELATEDBUNDLEPACKAGE:
5208 hr = OnDetectRelatedBundlePackage(pApplication, &readerArgs, &readerResults, &bufferResponse);
5209 break;
5210
5211 case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGENONVITALVALIDATIONFAILURE:
5212 hr = OnCachePackageNonVitalValidationFailure(pApplication, &readerArgs, &readerResults, &bufferResponse);
5213 break;
5214
5215 default:
5216 hr = E_NOTIMPL;
5217 break;
5218 // BalExitWithRootFailure(hr, E_NOTIMPL, "Unknown message type %d sent to bootstrapper application.", messageType)
5219 }
5220 }
5221
5222 hr = PipeRpcResponse(phRpcPipe, messageType, hr, bufferResponse.pbData, bufferResponse.cbData);
5223 BalExitOnFailure(hr, "Failed to send bootstrapper application callback result to engine.");
5224
5225LExit:
5226 ReleaseBuffer(bufferResponse);
5227
5228 return hr;
5229}
5230
5231EXTERN_C HRESULT MsgPump(
5232 __in HANDLE hPipe,
5233 __in IBootstrapperApplication* pApplication,
5234 __in IBootstrapperEngine* pEngine
5235 )
5236{
5237 HRESULT hr = S_OK;
5238 PIPE_RPC_HANDLE hRpcPipe = { INVALID_HANDLE_VALUE };
5239 PIPE_MESSAGE msg = { };
5240
5241 PipeRpcInitialize(&hRpcPipe, hPipe, FALSE);
5242
5243 // Pump messages sent to bootstrapper application until the pipe is closed.
5244 while (S_OK == (hr = PipeRpcReadMessage(&hRpcPipe, &msg)))
5245 {
5246 ProcessMessage(&hRpcPipe, pApplication, pEngine, static_cast<BOOTSTRAPPER_APPLICATION_MESSAGE>(msg.dwMessageType), reinterpret_cast<LPCBYTE>(msg.pvData), msg.cbData);
5247
5248 ReleasePipeMessage(&msg);
5249 }
5250 BalExitOnFailure(hr, "Failed to get message over bootstrapper application pipe");
5251
5252 if (S_FALSE == hr)
5253 {
5254 hr = S_OK;
5255 }
5256
5257LExit:
5258 ReleasePipeMessage(&msg);
5259
5260 PipeRpcUninitiailize(&hRpcPipe);
5261
5262 return hr;
5263}