summaryrefslogtreecommitdiff
path: root/src/burn/engine/externalengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/burn/engine/externalengine.cpp')
-rw-r--r--src/burn/engine/externalengine.cpp163
1 files changed, 103 insertions, 60 deletions
diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp
index df01d53b..1c775e23 100644
--- a/src/burn/engine/externalengine.cpp
+++ b/src/burn/engine/externalengine.cpp
@@ -14,8 +14,8 @@ static HRESULT ProcessUnknownEmbeddedMessages(
14 __out DWORD* pdwResult 14 __out DWORD* pdwResult
15 ); 15 );
16static HRESULT EnqueueAction( 16static HRESULT EnqueueAction(
17 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 17 __in BAENGINE_CONTEXT* pEngineContext,
18 __inout BOOTSTRAPPER_ENGINE_ACTION** ppAction 18 __inout BAENGINE_ACTION** ppAction
19 ); 19 );
20 20
21// function definitions 21// function definitions
@@ -227,7 +227,7 @@ HRESULT ExternalEngineSendEmbeddedError(
227 *pnResult = static_cast<int>(dwResult); 227 *pnResult = static_cast<int>(dwResult);
228 228
229LExit: 229LExit:
230 ReleaseBuffer(pbData); 230 ReleaseMem(pbData);
231 231
232 return hr; 232 return hr;
233} 233}
@@ -262,7 +262,7 @@ HRESULT ExternalEngineSendEmbeddedProgress(
262 *pnResult = static_cast<int>(dwResult); 262 *pnResult = static_cast<int>(dwResult);
263 263
264LExit: 264LExit:
265 ReleaseBuffer(pbData); 265 ReleaseMem(pbData);
266 266
267 return hr; 267 return hr;
268} 268}
@@ -273,25 +273,25 @@ HRESULT ExternalEngineSetUpdate(
273 __in_z_opt LPCWSTR wzDownloadSource, 273 __in_z_opt LPCWSTR wzDownloadSource,
274 __in const DWORD64 qwSize, 274 __in const DWORD64 qwSize,
275 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, 275 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
276 __in_opt LPCWSTR wzHash 276 __in_opt LPCWSTR wzHash,
277 __in_z_opt LPCWSTR wzUpdatePackageId
277 ) 278 )
278{ 279{
279 HRESULT hr = S_OK; 280 HRESULT hr = S_OK;
280 BOOL fLeaveCriticalSection = FALSE; 281 BOOL fLeaveCriticalSection = FALSE;
281 LPWSTR sczFilePath = NULL; 282 LPWSTR sczFileRelativePath = NULL;
282 LPWSTR sczCommandline = NULL; 283 LPWSTR sczCommandline = NULL;
283 LPWSTR sczPreviousId = NULL;
284 LPCWSTR wzNewId = NULL;
285 UUID guid = { }; 284 UUID guid = { };
286 WCHAR wzGuid[39]; 285 WCHAR wzCacheId[39];
287 RPC_STATUS rs = RPC_S_OK; 286 RPC_STATUS rs = RPC_S_OK;
288 BOOL fRemove = (!wzLocalSource || !*wzLocalSource) && (!wzDownloadSource || !*wzDownloadSource); 287 BOOL fRemove = (!wzLocalSource || !*wzLocalSource) && (!wzDownloadSource || !*wzDownloadSource);
289 288
290 UserExperienceOnSetUpdateBegin(&pEngineState->userExperience); 289 // Consider allowing the BA to pass this name in, like the UpdatePackageId can be passed in.
290 LPCWSTR wzFileName = NULL;
291 291
292 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive); 292 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive);
293 fLeaveCriticalSection = TRUE; 293 fLeaveCriticalSection = TRUE;
294 hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience); 294 hr = BootstrapperApplicationEnsureEngineInactive(&pEngineState->userExperience);
295 ExitOnFailure(hr, "Engine is active, cannot change engine state."); 295 ExitOnFailure(hr, "Engine is active, cannot change engine state.");
296 296
297 if (!fRemove) 297 if (!fRemove)
@@ -306,8 +306,6 @@ HRESULT ExternalEngineSetUpdate(
306 } 306 }
307 } 307 }
308 308
309 sczPreviousId = pEngineState->update.package.sczId;
310 pEngineState->update.package.sczId = NULL;
311 UpdateUninitialize(&pEngineState->update); 309 UpdateUninitialize(&pEngineState->update);
312 310
313 if (fRemove) 311 if (fRemove)
@@ -318,31 +316,46 @@ HRESULT ExternalEngineSetUpdate(
318 hr = CoreCreateUpdateBundleCommandLine(&sczCommandline, &pEngineState->internalCommand, &pEngineState->command); 316 hr = CoreCreateUpdateBundleCommandLine(&sczCommandline, &pEngineState->internalCommand, &pEngineState->command);
319 ExitOnFailure(hr, "Failed to create command-line for update bundle."); 317 ExitOnFailure(hr, "Failed to create command-line for update bundle.");
320 318
321 // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths. 319 // Always generate a new CacheId for a location to where we can download then cache the update bundle. This running
322 // Here I am generating a random guid, but in the future it would be nice if the feed would provide the ID of the update. 320 // bundle will clean that cached location when it is done while the update bundle caches itself in its official cache
321 // location during its execution.
323 rs = ::UuidCreate(&guid); 322 rs = ::UuidCreate(&guid);
324 hr = HRESULT_FROM_RPC(rs); 323 hr = HRESULT_FROM_RPC(rs);
325 ExitOnFailure(hr, "Failed to create bundle update guid."); 324 ExitOnFailure(hr, "Failed to create bundle update guid.");
326 325
327 if (!::StringFromGUID2(guid, wzGuid, countof(wzGuid))) 326 if (!::StringFromGUID2(guid, wzCacheId, countof(wzCacheId)))
328 { 327 {
329 hr = E_OUTOFMEMORY; 328 hr = E_INSUFFICIENT_BUFFER;
330 ExitOnRootFailure(hr, "Failed to convert bundle update guid into string."); 329 ExitOnRootFailure(hr, "Failed to convert bundle update guid into string.");
331 } 330 }
332 331
333 hr = StrAllocFormatted(&sczFilePath, L"%ls\\%ls", wzGuid, pEngineState->registration.sczExecutableName); 332 // If the update package id is not provided, use the cache id.
333 if (!wzUpdatePackageId || !*wzUpdatePackageId)
334 {
335 wzUpdatePackageId = wzCacheId;
336 }
337
338 // If the file name is not provided, use the current bundle's name. Not a great option but it is the best we have.
339 if (!wzFileName || !*wzFileName)
340 {
341 wzFileName = pEngineState->registration.sczExecutableName;
342 }
343
344 // Download the update bundle into a relative folder using the update package id. Ths is important because this running bundle is
345 // in the root of one of search paths used in source resolution. Thus, if when wzFileName is the same as the running bundle, the
346 // running bundle will be found first and the updated bundle will not actually be downloaded.
347 hr = StrAllocFormatted(&sczFileRelativePath, L"%ls\\%ls", wzUpdatePackageId, wzFileName);
334 ExitOnFailure(hr, "Failed to build bundle update file path."); 348 ExitOnFailure(hr, "Failed to build bundle update file path.");
335 349
336 if (!wzLocalSource || !*wzLocalSource) 350 if (!wzLocalSource || !*wzLocalSource)
337 { 351 {
338 wzLocalSource = sczFilePath; 352 wzLocalSource = sczFileRelativePath;
339 } 353 }
340 354
341 hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, wzHash); 355 hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzUpdatePackageId, wzCacheId, sczFileRelativePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, wzHash);
342 ExitOnFailure(hr, "Failed to set update bundle."); 356 ExitOnFailure(hr, "Failed to set update bundle.");
343 357
344 pEngineState->update.fUpdateAvailable = TRUE; 358 pEngineState->update.fUpdateAvailable = TRUE;
345 wzNewId = wzGuid;
346 359
347LExit: 360LExit:
348 if (fLeaveCriticalSection) 361 if (fLeaveCriticalSection)
@@ -350,11 +363,8 @@ LExit:
350 ::LeaveCriticalSection(&pEngineState->userExperience.csEngineActive); 363 ::LeaveCriticalSection(&pEngineState->userExperience.csEngineActive);
351 } 364 }
352 365
353 UserExperienceOnSetUpdateComplete(&pEngineState->userExperience, hr, sczPreviousId, wzNewId);
354
355 ReleaseStr(sczPreviousId);
356 ReleaseStr(sczCommandline); 366 ReleaseStr(sczCommandline);
357 ReleaseStr(sczFilePath); 367 ReleaseStr(sczFileRelativePath);
358 368
359 return hr; 369 return hr;
360} 370}
@@ -371,7 +381,7 @@ HRESULT ExternalEngineSetLocalSource(
371 BURN_PAYLOAD* pPayload = NULL; 381 BURN_PAYLOAD* pPayload = NULL;
372 382
373 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive); 383 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive);
374 hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience); 384 hr = BootstrapperApplicationEnsureEngineInactive(&pEngineState->userExperience);
375 ExitOnFailure(hr, "Engine is active, cannot change engine state."); 385 ExitOnFailure(hr, "Engine is active, cannot change engine state.");
376 386
377 if (!wzPath || !*wzPath) 387 if (!wzPath || !*wzPath)
@@ -411,7 +421,8 @@ HRESULT ExternalEngineSetDownloadSource(
411 __in_z_opt LPCWSTR wzPayloadId, 421 __in_z_opt LPCWSTR wzPayloadId,
412 __in_z_opt LPCWSTR wzUrl, 422 __in_z_opt LPCWSTR wzUrl,
413 __in_z_opt LPCWSTR wzUser, 423 __in_z_opt LPCWSTR wzUser,
414 __in_z_opt LPCWSTR wzPassword 424 __in_z_opt LPCWSTR wzPassword,
425 __in_z_opt LPCWSTR wzAuthorizationHeader
415 ) 426 )
416{ 427{
417 HRESULT hr = S_OK; 428 HRESULT hr = S_OK;
@@ -420,7 +431,7 @@ HRESULT ExternalEngineSetDownloadSource(
420 DOWNLOAD_SOURCE* pDownloadSource = NULL; 431 DOWNLOAD_SOURCE* pDownloadSource = NULL;
421 432
422 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive); 433 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive);
423 hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience); 434 hr = BootstrapperApplicationEnsureEngineInactive(&pEngineState->userExperience);
424 ExitOnFailure(hr, "Engine is active, cannot change engine state."); 435 ExitOnFailure(hr, "Engine is active, cannot change engine state.");
425 436
426 if (wzPayloadId && *wzPayloadId) 437 if (wzPayloadId && *wzPayloadId)
@@ -443,7 +454,16 @@ HRESULT ExternalEngineSetDownloadSource(
443 ExitOnFailure(hr, "BA did not provide container or payload id."); 454 ExitOnFailure(hr, "BA did not provide container or payload id.");
444 } 455 }
445 456
446 if (wzUrl && *wzUrl) 457 if (wzAuthorizationHeader && *wzAuthorizationHeader)
458 {
459 hr = StrAllocString(&pDownloadSource->sczAuthorizationHeader, wzAuthorizationHeader, 0);
460 ExitOnFailure(hr, "Failed to set download authorization header.");
461
462 // Authorization header means no user.
463 ReleaseNullStr(pDownloadSource->sczUser);
464 ReleaseNullStr(pDownloadSource->sczPassword);
465 }
466 else if (wzUrl && *wzUrl)
447 { 467 {
448 hr = StrAllocString(&pDownloadSource->sczUrl, wzUrl, 0); 468 hr = StrAllocString(&pDownloadSource->sczUrl, wzUrl, 0);
449 ExitOnFailure(hr, "Failed to set download URL."); 469 ExitOnFailure(hr, "Failed to set download URL.");
@@ -462,6 +482,9 @@ HRESULT ExternalEngineSetDownloadSource(
462 { 482 {
463 ReleaseNullStr(pDownloadSource->sczPassword); 483 ReleaseNullStr(pDownloadSource->sczPassword);
464 } 484 }
485
486 // User means no authorization header.
487 ReleaseNullStr(pDownloadSource->sczAuthorizationHeader);
465 } 488 }
466 else // no user means no password either. 489 else // no user means no password either.
467 { 490 {
@@ -586,15 +609,15 @@ HRESULT ExternalEngineCompareVersions(
586} 609}
587 610
588HRESULT ExternalEngineDetect( 611HRESULT ExternalEngineDetect(
589 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 612 __in BAENGINE_CONTEXT* pEngineContext,
590 __in_opt const HWND hwndParent 613 __in_opt const HWND hwndParent
591 ) 614 )
592{ 615{
593 HRESULT hr = S_OK; 616 HRESULT hr = S_OK;
594 BOOTSTRAPPER_ENGINE_ACTION* pAction = NULL; 617 BAENGINE_ACTION* pAction = NULL;
595 618
596 pAction = (BOOTSTRAPPER_ENGINE_ACTION*)MemAlloc(sizeof(BOOTSTRAPPER_ENGINE_ACTION), TRUE); 619 pAction = (BAENGINE_ACTION*)MemAlloc(sizeof(BAENGINE_ACTION), TRUE);
597 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BOOTSTRAPPER_ENGINE_ACTION"); 620 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BAENGINE_ACTION");
598 621
599 pAction->dwMessage = WM_BURN_DETECT; 622 pAction->dwMessage = WM_BURN_DETECT;
600 pAction->detect.hwndParent = hwndParent; 623 pAction->detect.hwndParent = hwndParent;
@@ -609,20 +632,20 @@ LExit:
609} 632}
610 633
611HRESULT ExternalEnginePlan( 634HRESULT ExternalEnginePlan(
612 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 635 __in BAENGINE_CONTEXT* pEngineContext,
613 __in const BOOTSTRAPPER_ACTION action 636 __in const BOOTSTRAPPER_ACTION action
614 ) 637 )
615{ 638{
616 HRESULT hr = S_OK; 639 HRESULT hr = S_OK;
617 BOOTSTRAPPER_ENGINE_ACTION* pAction = NULL; 640 BAENGINE_ACTION* pAction = NULL;
618 641
619 if (BOOTSTRAPPER_ACTION_LAYOUT > action || BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED < action) 642 if (BOOTSTRAPPER_ACTION_LAYOUT > action || BOOTSTRAPPER_ACTION_UPDATE_REPLACE_EMBEDDED < action)
620 { 643 {
621 ExitOnRootFailure(hr = E_INVALIDARG, "BA passed invalid action to Plan: %u.", action); 644 ExitOnRootFailure(hr = E_INVALIDARG, "BA passed invalid action to Plan: %u.", action);
622 } 645 }
623 646
624 pAction = (BOOTSTRAPPER_ENGINE_ACTION*)MemAlloc(sizeof(BOOTSTRAPPER_ENGINE_ACTION), TRUE); 647 pAction = (BAENGINE_ACTION*)MemAlloc(sizeof(BAENGINE_ACTION), TRUE);
625 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BOOTSTRAPPER_ENGINE_ACTION"); 648 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BAENGINE_ACTION");
626 649
627 pAction->dwMessage = WM_BURN_PLAN; 650 pAction->dwMessage = WM_BURN_PLAN;
628 pAction->plan.action = action; 651 pAction->plan.action = action;
@@ -637,20 +660,20 @@ LExit:
637} 660}
638 661
639HRESULT ExternalEngineElevate( 662HRESULT ExternalEngineElevate(
640 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 663 __in BAENGINE_CONTEXT* pEngineContext,
641 __in_opt const HWND hwndParent 664 __in_opt const HWND hwndParent
642 ) 665 )
643{ 666{
644 HRESULT hr = S_OK; 667 HRESULT hr = S_OK;
645 BOOTSTRAPPER_ENGINE_ACTION* pAction = NULL; 668 BAENGINE_ACTION* pAction = NULL;
646 669
647 if (INVALID_HANDLE_VALUE != pEngineContext->pEngineState->companionConnection.hPipe) 670 if (INVALID_HANDLE_VALUE != pEngineContext->pEngineState->companionConnection.hPipe)
648 { 671 {
649 ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)); 672 ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED));
650 } 673 }
651 674
652 pAction = (BOOTSTRAPPER_ENGINE_ACTION*)MemAlloc(sizeof(BOOTSTRAPPER_ENGINE_ACTION), TRUE); 675 pAction = (BAENGINE_ACTION*)MemAlloc(sizeof(BAENGINE_ACTION), TRUE);
653 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BOOTSTRAPPER_ENGINE_ACTION"); 676 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BAENGINE_ACTION");
654 677
655 pAction->dwMessage = WM_BURN_ELEVATE; 678 pAction->dwMessage = WM_BURN_ELEVATE;
656 pAction->elevate.hwndParent = hwndParent; 679 pAction->elevate.hwndParent = hwndParent;
@@ -665,12 +688,12 @@ LExit:
665} 688}
666 689
667HRESULT ExternalEngineApply( 690HRESULT ExternalEngineApply(
668 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 691 __in BAENGINE_CONTEXT* pEngineContext,
669 __in_opt const HWND hwndParent 692 __in_opt const HWND hwndParent
670 ) 693 )
671{ 694{
672 HRESULT hr = S_OK; 695 HRESULT hr = S_OK;
673 BOOTSTRAPPER_ENGINE_ACTION* pAction = NULL; 696 BAENGINE_ACTION* pAction = NULL;
674 697
675 ExitOnNull(hwndParent, hr, E_INVALIDARG, "BA passed NULL hwndParent to Apply."); 698 ExitOnNull(hwndParent, hr, E_INVALIDARG, "BA passed NULL hwndParent to Apply.");
676 if (!::IsWindow(hwndParent)) 699 if (!::IsWindow(hwndParent))
@@ -678,8 +701,8 @@ HRESULT ExternalEngineApply(
678 ExitOnRootFailure(hr = E_INVALIDARG, "BA passed invalid hwndParent to Apply."); 701 ExitOnRootFailure(hr = E_INVALIDARG, "BA passed invalid hwndParent to Apply.");
679 } 702 }
680 703
681 pAction = (BOOTSTRAPPER_ENGINE_ACTION*)MemAlloc(sizeof(BOOTSTRAPPER_ENGINE_ACTION), TRUE); 704 pAction = (BAENGINE_ACTION*)MemAlloc(sizeof(BAENGINE_ACTION), TRUE);
682 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BOOTSTRAPPER_ENGINE_ACTION"); 705 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BAENGINE_ACTION");
683 706
684 pAction->dwMessage = WM_BURN_APPLY; 707 pAction->dwMessage = WM_BURN_APPLY;
685 pAction->apply.hwndParent = hwndParent; 708 pAction->apply.hwndParent = hwndParent;
@@ -694,15 +717,15 @@ LExit:
694} 717}
695 718
696HRESULT ExternalEngineQuit( 719HRESULT ExternalEngineQuit(
697 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 720 __in BAENGINE_CONTEXT* pEngineContext,
698 __in const DWORD dwExitCode 721 __in const DWORD dwExitCode
699 ) 722 )
700{ 723{
701 HRESULT hr = S_OK; 724 HRESULT hr = S_OK;
702 BOOTSTRAPPER_ENGINE_ACTION* pAction = NULL; 725 BAENGINE_ACTION* pAction = NULL;
703 726
704 pAction = (BOOTSTRAPPER_ENGINE_ACTION*)MemAlloc(sizeof(BOOTSTRAPPER_ENGINE_ACTION), TRUE); 727 pAction = (BAENGINE_ACTION*)MemAlloc(sizeof(BAENGINE_ACTION), TRUE);
705 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BOOTSTRAPPER_ENGINE_ACTION"); 728 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BAENGINE_ACTION");
706 729
707 pAction->dwMessage = WM_BURN_QUIT; 730 pAction->dwMessage = WM_BURN_QUIT;
708 pAction->quit.dwExitCode = dwExitCode; 731 pAction->quit.dwExitCode = dwExitCode;
@@ -717,7 +740,7 @@ LExit:
717} 740}
718 741
719HRESULT ExternalEngineLaunchApprovedExe( 742HRESULT ExternalEngineLaunchApprovedExe(
720 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 743 __in BAENGINE_CONTEXT* pEngineContext,
721 __in_opt const HWND hwndParent, 744 __in_opt const HWND hwndParent,
722 __in_z LPCWSTR wzApprovedExeForElevationId, 745 __in_z LPCWSTR wzApprovedExeForElevationId,
723 __in_z_opt LPCWSTR wzArguments, 746 __in_z_opt LPCWSTR wzArguments,
@@ -727,7 +750,7 @@ HRESULT ExternalEngineLaunchApprovedExe(
727 HRESULT hr = S_OK; 750 HRESULT hr = S_OK;
728 BURN_APPROVED_EXE* pApprovedExe = NULL; 751 BURN_APPROVED_EXE* pApprovedExe = NULL;
729 BURN_LAUNCH_APPROVED_EXE* pLaunchApprovedExe = NULL; 752 BURN_LAUNCH_APPROVED_EXE* pLaunchApprovedExe = NULL;
730 BOOTSTRAPPER_ENGINE_ACTION* pAction = NULL; 753 BAENGINE_ACTION* pAction = NULL;
731 754
732 if (!wzApprovedExeForElevationId || !*wzApprovedExeForElevationId) 755 if (!wzApprovedExeForElevationId || !*wzApprovedExeForElevationId)
733 { 756 {
@@ -737,8 +760,8 @@ HRESULT ExternalEngineLaunchApprovedExe(
737 hr = ApprovedExesFindById(&pEngineContext->pEngineState->approvedExes, wzApprovedExeForElevationId, &pApprovedExe); 760 hr = ApprovedExesFindById(&pEngineContext->pEngineState->approvedExes, wzApprovedExeForElevationId, &pApprovedExe);
738 ExitOnFailure(hr, "BA requested unknown approved exe with id: %ls", wzApprovedExeForElevationId); 761 ExitOnFailure(hr, "BA requested unknown approved exe with id: %ls", wzApprovedExeForElevationId);
739 762
740 pAction = (BOOTSTRAPPER_ENGINE_ACTION*)MemAlloc(sizeof(BOOTSTRAPPER_ENGINE_ACTION), TRUE); 763 pAction = (BAENGINE_ACTION*)MemAlloc(sizeof(BAENGINE_ACTION), TRUE);
741 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BOOTSTRAPPER_ENGINE_ACTION"); 764 ExitOnNull(pAction, hr, E_OUTOFMEMORY, "Failed to alloc BAENGINE_ACTION");
742 765
743 pAction->dwMessage = WM_BURN_LAUNCH_APPROVED_EXE; 766 pAction->dwMessage = WM_BURN_LAUNCH_APPROVED_EXE;
744 pLaunchApprovedExe = &pAction->launchApprovedExe; 767 pLaunchApprovedExe = &pAction->launchApprovedExe;
@@ -762,8 +785,7 @@ HRESULT ExternalEngineLaunchApprovedExe(
762LExit: 785LExit:
763 if (pAction) 786 if (pAction)
764 { 787 {
765 CoreBootstrapperEngineActionUninitialize(pAction); 788 BAEngineFreeAction(pAction);
766 MemFree(pAction);
767 } 789 }
768 790
769 return hr; 791 return hr;
@@ -771,7 +793,8 @@ LExit:
771 793
772HRESULT ExternalEngineSetUpdateSource( 794HRESULT ExternalEngineSetUpdateSource(
773 __in BURN_ENGINE_STATE* pEngineState, 795 __in BURN_ENGINE_STATE* pEngineState,
774 __in_z LPCWSTR wzUrl 796 __in_z LPCWSTR wzUrl,
797 __in_z_opt LPCWSTR wzAuthorizationHeader
775 ) 798 )
776{ 799{
777 HRESULT hr = S_OK; 800 HRESULT hr = S_OK;
@@ -779,16 +802,27 @@ HRESULT ExternalEngineSetUpdateSource(
779 802
780 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive); 803 ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive);
781 fLeaveCriticalSection = TRUE; 804 fLeaveCriticalSection = TRUE;
782 hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience); 805 hr = BootstrapperApplicationEnsureEngineInactive(&pEngineState->userExperience);
783 ExitOnFailure(hr, "Engine is active, cannot change engine state."); 806 ExitOnFailure(hr, "Engine is active, cannot change engine state.");
784 807
785 if (wzUrl && *wzUrl) 808 if (wzUrl && *wzUrl)
786 { 809 {
787 hr = StrAllocString(&pEngineState->update.sczUpdateSource, wzUrl, 0); 810 hr = StrAllocString(&pEngineState->update.sczUpdateSource, wzUrl, 0);
788 ExitOnFailure(hr, "Failed to set feed download URL."); 811 ExitOnFailure(hr, "Failed to set feed download URL.");
812
813 if (wzAuthorizationHeader && *wzAuthorizationHeader)
814 {
815 hr = StrAllocString(&pEngineState->update.sczAuthorizationHeader, wzAuthorizationHeader, 0);
816 ExitOnFailure(hr, "Failed to set feed authorization header.");
817 }
818 else
819 {
820 ReleaseNullStr(pEngineState->update.sczAuthorizationHeader);
821 }
789 } 822 }
790 else // no URL provided means clear out the whole download source. 823 else // no URL provided means clear out the whole download source.
791 { 824 {
825 ReleaseNullStr(pEngineState->update.sczAuthorizationHeader);
792 ReleaseNullStr(pEngineState->update.sczUpdateSource); 826 ReleaseNullStr(pEngineState->update.sczUpdateSource);
793 } 827 }
794 828
@@ -810,14 +844,23 @@ HRESULT ExternalEngineGetRelatedBundleVariable(
810 ) 844 )
811{ 845{
812 HRESULT hr = S_OK; 846 HRESULT hr = S_OK;
847 LPWSTR sczValue = NULL;
848
813 if (wzVariable && *wzVariable && pcchValue) 849 if (wzVariable && *wzVariable && pcchValue)
814 { 850 {
815 hr = BundleGetBundleVariableFixed(wzBundleId, wzVariable, wzValue, pcchValue); 851 hr = BundleGetBundleVariable(wzBundleId, wzVariable, &sczValue);
852 if (SUCCEEDED(hr))
853 {
854 hr = CopyStringToExternal(sczValue, wzValue, pcchValue);
855 }
816 } 856 }
817 else 857 else
818 { 858 {
819 hr = E_INVALIDARG; 859 hr = E_INVALIDARG;
820 } 860 }
861
862 StrSecureZeroFreeString(sczValue);
863
821 return hr; 864 return hr;
822} 865}
823 866
@@ -888,8 +931,8 @@ static HRESULT ProcessUnknownEmbeddedMessages(
888} 931}
889 932
890static HRESULT EnqueueAction( 933static HRESULT EnqueueAction(
891 __in BOOTSTRAPPER_ENGINE_CONTEXT* pEngineContext, 934 __in BAENGINE_CONTEXT* pEngineContext,
892 __inout BOOTSTRAPPER_ENGINE_ACTION** ppAction 935 __inout BAENGINE_ACTION** ppAction
893 ) 936 )
894{ 937{
895 HRESULT hr = S_OK; 938 HRESULT hr = S_OK;