From e3671abae2f22c3ad7d205aa743bed73ff55e512 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 May 2022 15:26:07 -0500 Subject: Allow burn.runonce with burn.clean.room and create runonce log. --- src/burn/engine/core.cpp | 9 ++++++--- src/burn/engine/engine.cpp | 12 ++++++++---- src/burn/engine/logging.cpp | 12 +++++++++++- 3 files changed, 25 insertions(+), 8 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index be8c011f..ec996c4c 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -1753,13 +1753,16 @@ extern "C" HRESULT CoreParseCommandLine( } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1)) { - if (BURN_MODE_UNKNOWN != pInternalCommand->mode) + switch (pInternalCommand->mode) { + case BURN_MODE_UNKNOWN: __fallthrough; + case BURN_MODE_NORMAL: + pInternalCommand->mode = BURN_MODE_RUNONCE; + break; + default: fInvalidCommandLine = TRUE; TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided."); } - - pInternalCommand->mode = BURN_MODE_RUNONCE; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], lstrlenW(BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES), BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES, lstrlenW(BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES))) { diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp index 9b94552b..821626f8 100644 --- a/src/burn/engine/engine.cpp +++ b/src/burn/engine/engine.cpp @@ -33,7 +33,7 @@ static HRESULT RunEmbedded( __in BURN_ENGINE_STATE* pEngineState ); static HRESULT RunRunOnce( - __in const BURN_REGISTRATION* pRegistration, + __in BURN_ENGINE_STATE* pEngineState, __in int nCmdShow ); static HRESULT RunApplication( @@ -221,7 +221,7 @@ extern "C" HRESULT EngineRun( break; case BURN_MODE_RUNONCE: - hr = RunRunOnce(&engineState.registration, nCmdShow); + hr = RunRunOnce(&engineState, nCmdShow); ExitOnFailure(hr, "Failed to run RunOnce mode."); break; @@ -703,7 +703,7 @@ LExit: } static HRESULT RunRunOnce( - __in const BURN_REGISTRATION* pRegistration, + __in BURN_ENGINE_STATE* pEngineState, __in int nCmdShow ) { @@ -712,7 +712,11 @@ static HRESULT RunRunOnce( LPWSTR sczBurnPath = NULL; HANDLE hProcess = NULL; - hr = RegistrationGetResumeCommandLine(pRegistration, &sczNewCommandLine); + // Initialize logging. + hr = LoggingOpen(&pEngineState->log, &pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, pEngineState->registration.sczDisplayName); + ExitOnFailure(hr, "Failed to open run once log."); + + hr = RegistrationGetResumeCommandLine(&pEngineState->registration, &sczNewCommandLine); ExitOnFailure(hr, "Unable to get resume command line from the registry"); // and re-launch diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp index 0b510f3d..1b2bec1f 100644 --- a/src/burn/engine/logging.cpp +++ b/src/burn/engine/logging.cpp @@ -39,7 +39,17 @@ extern "C" HRESULT LoggingOpen( HRESULT hr = S_OK; LPWSTR sczLoggingBaseFolder = NULL; LPWSTR sczPrefixFormatted = NULL; - LPCWSTR wzPostfix = BURN_MODE_UNTRUSTED == pInternalCommand->mode ? L".cleanroom" : NULL; + LPCWSTR wzPostfix = NULL; + + switch (pInternalCommand->mode) + { + case BURN_MODE_UNTRUSTED: + wzPostfix = L".cleanroom"; + break; + case BURN_MODE_RUNONCE: + wzPostfix = L".runonce"; + break; + } hr = InitializeLogging(pLog, pInternalCommand); ExitOnFailure(hr, "Failed to initialize logging."); -- cgit v1.2.3-55-g6feb