diff options
Diffstat (limited to 'src/burn/engine/apply.cpp')
-rw-r--r-- | src/burn/engine/apply.cpp | 87 |
1 files changed, 61 insertions, 26 deletions
diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp index aad9e6eb..c32f4c84 100644 --- a/src/burn/engine/apply.cpp +++ b/src/burn/engine/apply.cpp | |||
@@ -75,7 +75,8 @@ static HRESULT WINAPI AuthenticationRequired( | |||
75 | 75 | ||
76 | static void CalculateKeepRegistration( | 76 | static void CalculateKeepRegistration( |
77 | __in BURN_ENGINE_STATE* pEngineState, | 77 | __in BURN_ENGINE_STATE* pEngineState, |
78 | __inout BOOL* pfKeepRegistration | 78 | __in BOOL fLog, |
79 | __inout BOOTSTRAPPER_REGISTRATION_TYPE* pRegistrationType | ||
79 | ); | 80 | ); |
80 | static HRESULT ExecuteDependentRegistrationActions( | 81 | static HRESULT ExecuteDependentRegistrationActions( |
81 | __in HANDLE hPipe, | 82 | __in HANDLE hPipe, |
@@ -376,8 +377,11 @@ extern "C" HRESULT ApplyRegister( | |||
376 | { | 377 | { |
377 | HRESULT hr = S_OK; | 378 | HRESULT hr = S_OK; |
378 | LPWSTR sczEngineWorkingPath = NULL; | 379 | LPWSTR sczEngineWorkingPath = NULL; |
380 | BOOTSTRAPPER_REGISTRATION_TYPE registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS; | ||
379 | 381 | ||
380 | hr = UserExperienceOnRegisterBegin(&pEngineState->userExperience); | 382 | CalculateKeepRegistration(pEngineState, FALSE, ®istrationType); |
383 | |||
384 | hr = UserExperienceOnRegisterBegin(&pEngineState->userExperience, ®istrationType); | ||
381 | ExitOnRootFailure(hr, "BA aborted register begin."); | 385 | ExitOnRootFailure(hr, "BA aborted register begin."); |
382 | 386 | ||
383 | // If we have a resume mode that suggests the bundle is on the machine. | 387 | // If we have a resume mode that suggests the bundle is on the machine. |
@@ -386,12 +390,12 @@ extern "C" HRESULT ApplyRegister( | |||
386 | // resume previous session | 390 | // resume previous session |
387 | if (pEngineState->registration.fPerMachine) | 391 | if (pEngineState->registration.fPerMachine) |
388 | { | 392 | { |
389 | hr = ElevationSessionResume(pEngineState->companionConnection.hPipe, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables); | 393 | hr = ElevationSessionResume(pEngineState->companionConnection.hPipe, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, registrationType); |
390 | ExitOnFailure(hr, "Failed to resume registration session in per-machine process."); | 394 | ExitOnFailure(hr, "Failed to resume registration session in per-machine process."); |
391 | } | 395 | } |
392 | else | 396 | else |
393 | { | 397 | { |
394 | hr = RegistrationSessionResume(&pEngineState->registration, &pEngineState->variables); | 398 | hr = RegistrationSessionResume(&pEngineState->registration, &pEngineState->variables, registrationType); |
395 | ExitOnFailure(hr, "Failed to resume registration session."); | 399 | ExitOnFailure(hr, "Failed to resume registration session."); |
396 | } | 400 | } |
397 | } | 401 | } |
@@ -403,12 +407,12 @@ extern "C" HRESULT ApplyRegister( | |||
403 | // begin new session | 407 | // begin new session |
404 | if (pEngineState->registration.fPerMachine) | 408 | if (pEngineState->registration.fPerMachine) |
405 | { | 409 | { |
406 | hr = ElevationSessionBegin(pEngineState->companionConnection.hPipe, sczEngineWorkingPath, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.dependencyRegistrationAction, pEngineState->plan.qwEstimatedSize); | 410 | hr = ElevationSessionBegin(pEngineState->companionConnection.hPipe, sczEngineWorkingPath, pEngineState->registration.sczResumeCommandLine, pEngineState->registration.fDisableResume, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.dependencyRegistrationAction, pEngineState->plan.qwEstimatedSize, registrationType); |
407 | ExitOnFailure(hr, "Failed to begin registration session in per-machine process."); | 411 | ExitOnFailure(hr, "Failed to begin registration session in per-machine process."); |
408 | } | 412 | } |
409 | else | 413 | else |
410 | { | 414 | { |
411 | hr = RegistrationSessionBegin(sczEngineWorkingPath, &pEngineState->registration, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.dependencyRegistrationAction, pEngineState->plan.qwEstimatedSize); | 415 | hr = RegistrationSessionBegin(sczEngineWorkingPath, &pEngineState->registration, &pEngineState->variables, pEngineState->plan.dwRegistrationOperations, pEngineState->plan.dependencyRegistrationAction, pEngineState->plan.qwEstimatedSize, registrationType); |
412 | ExitOnFailure(hr, "Failed to begin registration session."); | 416 | ExitOnFailure(hr, "Failed to begin registration session."); |
413 | } | 417 | } |
414 | } | 418 | } |
@@ -441,17 +445,11 @@ extern "C" HRESULT ApplyUnregister( | |||
441 | { | 445 | { |
442 | HRESULT hr = S_OK; | 446 | HRESULT hr = S_OK; |
443 | BURN_RESUME_MODE resumeMode = BURN_RESUME_MODE_NONE; | 447 | BURN_RESUME_MODE resumeMode = BURN_RESUME_MODE_NONE; |
444 | BOOL fKeepRegistration = pEngineState->plan.fDisallowRemoval; | 448 | BOOTSTRAPPER_REGISTRATION_TYPE defaultRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; |
445 | 449 | BOOTSTRAPPER_REGISTRATION_TYPE registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE; | |
446 | CalculateKeepRegistration(pEngineState, &fKeepRegistration); | ||
447 | |||
448 | hr = UserExperienceOnUnregisterBegin(&pEngineState->userExperience, &fKeepRegistration); | ||
449 | ExitOnRootFailure(hr, "BA aborted unregister begin."); | ||
450 | 450 | ||
451 | // Calculate the correct resume mode. If a restart has been initiated, that trumps all other | 451 | // Calculate special cases for the resume mode. If a restart has been initiated, that trumps all other |
452 | // modes. If the user chose to suspend the install then we'll use that as the resume mode. | 452 | // modes. If the user chose to suspend the install then we'll use that as the resume mode. |
453 | // Barring those special cases, if it was determined that we should keep the registration then | ||
454 | // do that, otherwise the resume mode was initialized to none and registration will be removed. | ||
455 | if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == restart) | 453 | if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == restart) |
456 | { | 454 | { |
457 | resumeMode = BURN_RESUME_MODE_REBOOT_PENDING; | 455 | resumeMode = BURN_RESUME_MODE_REBOOT_PENDING; |
@@ -460,28 +458,50 @@ extern "C" HRESULT ApplyUnregister( | |||
460 | { | 458 | { |
461 | resumeMode = BURN_RESUME_MODE_SUSPEND; | 459 | resumeMode = BURN_RESUME_MODE_SUSPEND; |
462 | } | 460 | } |
463 | else if (fKeepRegistration) | 461 | else if (pEngineState->plan.fDisallowRemoval) |
462 | { | ||
463 | resumeMode = BURN_RESUME_MODE_ARP; | ||
464 | } | ||
465 | |||
466 | // If there was a special case, make sure the registration is kept. | ||
467 | if (BURN_RESUME_MODE_NONE < resumeMode) | ||
468 | { | ||
469 | defaultRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS; | ||
470 | } | ||
471 | |||
472 | CalculateKeepRegistration(pEngineState, TRUE, &defaultRegistrationType); | ||
473 | |||
474 | registrationType = defaultRegistrationType; | ||
475 | |||
476 | hr = UserExperienceOnUnregisterBegin(&pEngineState->userExperience, ®istrationType); | ||
477 | ExitOnRootFailure(hr, "BA aborted unregister begin."); | ||
478 | |||
479 | // Barring the special cases, if it was determined that we should keep the registration then | ||
480 | // do that, otherwise the resume mode is NONE and registration will be removed. | ||
481 | if (BURN_RESUME_MODE_NONE == resumeMode && BOOTSTRAPPER_REGISTRATION_TYPE_NONE < registrationType) | ||
464 | { | 482 | { |
465 | resumeMode = BURN_RESUME_MODE_ARP; | 483 | resumeMode = BURN_RESUME_MODE_ARP; |
466 | } | 484 | } |
467 | 485 | ||
468 | // If apply failed in any way and we're going to be keeping the bundle registered then | 486 | // If apply failed in any way and we're going to be keeping the bundle registered then |
469 | // execute any rollback dependency registration actions. | 487 | // execute any rollback dependency registration actions. |
470 | if (fFailed && fKeepRegistration) | 488 | if (fFailed && BURN_RESUME_MODE_NONE < resumeMode) |
471 | { | 489 | { |
472 | // Execute any rollback registration actions. | 490 | // Execute any rollback registration actions. |
473 | HRESULT hrRegistrationRollback = ExecuteDependentRegistrationActions(pEngineState->companionConnection.hPipe, &pEngineState->registration, pEngineState->plan.rgRollbackRegistrationActions, pEngineState->plan.cRollbackRegistrationActions); | 491 | HRESULT hrRegistrationRollback = ExecuteDependentRegistrationActions(pEngineState->companionConnection.hPipe, &pEngineState->registration, pEngineState->plan.rgRollbackRegistrationActions, pEngineState->plan.cRollbackRegistrationActions); |
474 | UNREFERENCED_PARAMETER(hrRegistrationRollback); | 492 | IgnoreRollbackError(hrRegistrationRollback, "Dependent registration actions failed"); |
475 | } | 493 | } |
476 | 494 | ||
495 | LogId(REPORT_STANDARD, MSG_SESSION_END, pEngineState->registration.sczRegistrationKey, LoggingResumeModeToString(resumeMode), LoggingRestartToString(restart), LoggingBoolToString(pEngineState->registration.fDisableResume), LoggingRegistrationTypeToString(defaultRegistrationType), LoggingRegistrationTypeToString(registrationType)); | ||
496 | |||
477 | if (pEngineState->registration.fPerMachine) | 497 | if (pEngineState->registration.fPerMachine) |
478 | { | 498 | { |
479 | hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction); | 499 | hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction, registrationType); |
480 | ExitOnFailure(hr, "Failed to end session in per-machine process."); | 500 | ExitOnFailure(hr, "Failed to end session in per-machine process."); |
481 | } | 501 | } |
482 | else | 502 | else |
483 | { | 503 | { |
484 | hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->variables, &pEngineState->packages, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction); | 504 | hr = RegistrationSessionEnd(&pEngineState->registration, &pEngineState->variables, &pEngineState->packages, resumeMode, restart, pEngineState->plan.dependencyRegistrationAction, registrationType); |
485 | ExitOnFailure(hr, "Failed to end session in per-user process."); | 505 | ExitOnFailure(hr, "Failed to end session in per-user process."); |
486 | } | 506 | } |
487 | 507 | ||
@@ -751,10 +771,14 @@ extern "C" void ApplyClean( | |||
751 | 771 | ||
752 | static void CalculateKeepRegistration( | 772 | static void CalculateKeepRegistration( |
753 | __in BURN_ENGINE_STATE* pEngineState, | 773 | __in BURN_ENGINE_STATE* pEngineState, |
754 | __inout BOOL* pfKeepRegistration | 774 | __in BOOL fLog, |
775 | __inout BOOTSTRAPPER_REGISTRATION_TYPE* pRegistrationType | ||
755 | ) | 776 | ) |
756 | { | 777 | { |
757 | LogId(REPORT_STANDARD, MSG_POST_APPLY_CALCULATE_REGISTRATION); | 778 | if (fLog) |
779 | { | ||
780 | LogId(REPORT_STANDARD, MSG_POST_APPLY_CALCULATE_REGISTRATION); | ||
781 | } | ||
758 | 782 | ||
759 | for (DWORD i = 0; i < pEngineState->packages.cPackages; ++i) | 783 | for (DWORD i = 0; i < pEngineState->packages.cPackages; ++i) |
760 | { | 784 | { |
@@ -765,17 +789,28 @@ static void CalculateKeepRegistration( | |||
765 | MspEngineFinalizeInstallRegistrationState(pPackage); | 789 | MspEngineFinalizeInstallRegistrationState(pPackage); |
766 | } | 790 | } |
767 | 791 | ||
768 | LogId(REPORT_STANDARD, MSG_POST_APPLY_PACKAGE, pPackage->sczId, LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->installRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->cacheRegistrationState)); | 792 | if (fLog) |
793 | { | ||
794 | LogId(REPORT_STANDARD, MSG_POST_APPLY_PACKAGE, pPackage->sczId, LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->installRegistrationState), LoggingPackageRegistrationStateToString(pPackage->fCanAffectRegistration, pPackage->cacheRegistrationState)); | ||
795 | } | ||
769 | 796 | ||
770 | if (!pPackage->fCanAffectRegistration) | 797 | if (!pPackage->fCanAffectRegistration) |
771 | { | 798 | { |
772 | continue; | 799 | continue; |
773 | } | 800 | } |
774 | 801 | ||
775 | if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->installRegistrationState || | 802 | if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->installRegistrationState) |
776 | BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState) | 803 | { |
804 | *pRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_FULL; | ||
805 | |||
806 | if (!fLog) | ||
807 | { | ||
808 | break; | ||
809 | } | ||
810 | } | ||
811 | else if (BURN_PACKAGE_REGISTRATION_STATE_PRESENT == pPackage->cacheRegistrationState && BOOTSTRAPPER_REGISTRATION_TYPE_NONE == *pRegistrationType) | ||
777 | { | 812 | { |
778 | *pfKeepRegistration = TRUE; | 813 | *pRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS; |
779 | } | 814 | } |
780 | } | 815 | } |
781 | } | 816 | } |