From 5fc93f9399795156b4a1fbde5f410ca01d94d609 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 6 Feb 2021 17:09:47 -0600 Subject: Cleanup should always be attempted, and add some logging for it. Continuation of #6297 --- src/engine/core.cpp | 23 +++++++++++++++-------- src/engine/core.h | 2 +- src/engine/engine.cpp | 5 ++--- src/engine/engine.mc | 30 +++++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/engine/core.cpp b/src/engine/core.cpp index 644752ff..6b32931d 100644 --- a/src/engine/core.cpp +++ b/src/engine/core.cpp @@ -1061,7 +1061,7 @@ LExit: return hr; } -extern "C" HRESULT CoreCleanup( +extern "C" void CoreCleanup( __in BURN_ENGINE_STATE* pEngineState ) { @@ -1069,6 +1069,14 @@ extern "C" HRESULT CoreCleanup( LONGLONG llValue = 0; BOOL fNeedsElevation = pEngineState->registration.fPerMachine && INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe; + LogId(REPORT_STANDARD, MSG_CLEANUP_BEGIN); + + if (pEngineState->fApplied && BOOTSTRAPPER_ACTION_LAYOUT < pEngineState->plan.action && BOOTSTRAPPER_ACTION_UPDATE_REPLACE > pEngineState->plan.action) + { + LogId(REPORT_STANDARD, MSG_CLEANUP_SKIPPED_APPLY); + ExitFunction(); + } + if (fNeedsElevation) { hr = VariableGetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, &llValue); @@ -1078,12 +1086,11 @@ extern "C" HRESULT CoreCleanup( { fNeedsElevation = FALSE; } - } - - if (pEngineState->fApplied && BOOTSTRAPPER_ACTION_LAYOUT < pEngineState->plan.action && BOOTSTRAPPER_ACTION_UPDATE_REPLACE > pEngineState->plan.action || - fNeedsElevation) - { - ExitFunction(); + else + { + LogId(REPORT_STANDARD, MSG_CLEANUP_SKIPPED_ELEVATION_REQUIRED); + ExitFunction(); + } } if (!pEngineState->fDetected) @@ -1104,7 +1111,7 @@ extern "C" HRESULT CoreCleanup( ExitOnFailure(hr, "Apply during cleanup failed"); LExit: - return hr; + LogId(REPORT_STANDARD, MSG_CLEANUP_COMPLETE, hr); } // internal helper functions diff --git a/src/engine/core.h b/src/engine/core.h index 47cfd559..f23738c3 100644 --- a/src/engine/core.h +++ b/src/engine/core.h @@ -204,7 +204,7 @@ HRESULT CoreAppendFileHandleSelfToCommandLine( __deref_inout_z LPWSTR* psczCommandLine, __deref_inout_z_opt LPWSTR* psczObfuscatedCommandLine ); -HRESULT CoreCleanup( +void CoreCleanup( __in BURN_ENGINE_STATE* pEngineState ); diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 98c98661..7e6e2922 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -592,13 +592,12 @@ static HRESULT RunNormal( ExitOnFailure(hr, "Failed while running "); } while (fReloadApp); +LExit: if (!fSkipCleanup) { - hr = CoreCleanup(pEngineState); - ExitOnFailure(hr, "Failed to cleanup before shutting down"); + CoreCleanup(pEngineState); } -LExit: BurnExtensionUnload(&pEngineState->extensions); // If the message window is still around, close it. diff --git a/src/engine/engine.mc b/src/engine/engine.mc index c90f08e3..8e0a8a66 100644 --- a/src/engine/engine.mc +++ b/src/engine/engine.mc @@ -967,7 +967,35 @@ MessageId=501 Severity=Warning SymbolicName=MSG_STATE_NOT_SAVED Language=English -The state file could not be saved. Continuing... +The state file could not be saved, error: %1!ls!. Continuing... +. + +MessageId=502 +Severity=Success +SymbolicName=MSG_CLEANUP_BEGIN +Language=English +Cleanup begin. +. + +MessageId=503 +Severity=Success +SymbolicName=MSG_CLEANUP_SKIPPED_APPLY +Language=English +Cleanup not required due to running Apply. +. + +MessageId=504 +Severity=Success +SymbolicName=MSG_CLEANUP_SKIPPED_ELEVATION_REQUIRED +Language=English +Cleanup check skipped since this per-machine bundle would require elevation. +. + +MessageId=599 +Severity=Success +SymbolicName=MSG_CLEANUP_COMPLETE +Language=English +Cleanup complete, result: 0x%1!x! . MessageId=600 -- cgit v1.2.3-55-g6feb