From 9ae1c04d5fa02ac020885cdad7c592f7bb43d83e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 Aug 2021 15:41:53 -0500 Subject: Parse most of Burn command line parameters into BURN_ENGINE_COMMAND. --- src/burn/engine/core.cpp | 132 +++++++++++------------- src/burn/engine/core.h | 47 +++------ src/burn/engine/elevation.cpp | 12 +-- src/burn/engine/elevation.h | 4 +- src/burn/engine/engine.cpp | 25 +++-- src/burn/engine/externalengine.cpp | 6 +- src/burn/engine/logging.cpp | 39 +++++-- src/burn/engine/logging.h | 3 +- src/burn/engine/manifest.cpp | 2 +- src/burn/engine/plan.cpp | 15 ++- src/burn/engine/plan.h | 6 +- src/burn/engine/pseudobundle.cpp | 3 +- src/burn/engine/pseudobundle.h | 1 - src/burn/engine/registration.cpp | 1 - src/burn/engine/registration.h | 1 - src/burn/engine/uithread.cpp | 2 +- src/burn/test/BurnUnitTest/PlanTest.cpp | 5 +- src/burn/test/BurnUnitTest/RegistrationTest.cpp | 18 ++-- 18 files changed, 161 insertions(+), 161 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index bccdfa9f..ea7f34d1 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -15,12 +15,9 @@ struct BURN_CACHE_THREAD_CONTEXT // internal function declarations static HRESULT GetSanitizedCommandLine( - __in int argc, - __in LPWSTR* argv, + __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_VARIABLES* pVariables, - __in DWORD cUnknownArgs, - __in int* rgUnknownArgs, __inout_z LPWSTR* psczSanitizedCommandLine ); static HRESULT ParsePipeConnection( @@ -89,7 +86,7 @@ extern "C" HRESULT CoreInitialize( hr = ContainersInitialize(&pEngineState->containers, &pEngineState->section); ExitOnFailure(hr, "Failed to initialize containers."); - hr = GetSanitizedCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->variables, pEngineState->cUnknownArgs, pEngineState->rgUnknownArgs, &sczSanitizedCommandLine); + hr = GetSanitizedCommandLine(&pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, &sczSanitizedCommandLine); ExitOnFailure(hr, "Fatal error while sanitizing command line."); LogId(REPORT_STANDARD, MSG_BURN_COMMAND_LINE, sczSanitizedCommandLine ? sczSanitizedCommandLine : L""); @@ -97,7 +94,7 @@ extern "C" HRESULT CoreInitialize( // The command line wasn't logged immediately so that hidden variables set on the command line can be obscured in the log. // This delay creates issues when troubleshooting parsing errors because the original command line is not in the log. // The code does its best to process the entire command line and keep track if the command line was invalid so that it can log the sanitized command line before erroring out. - if (pEngineState->fInvalidCommandLine) + if (pEngineState->internalCommand.fInvalidCommandLine) { LogExitOnRootFailure(hr = E_INVALIDARG, MSG_FAILED_PARSE_COMMAND_LINE, "Failed to parse command line."); } @@ -137,7 +134,7 @@ extern "C" HRESULT CoreInitialize( ExitOnFailure(hr, "Failed to set original source variable."); } - if (BURN_MODE_UNTRUSTED == pEngineState->mode || BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) + if (BURN_MODE_UNTRUSTED == pEngineState->internalCommand.mode || BURN_MODE_NORMAL == pEngineState->internalCommand.mode || BURN_MODE_EMBEDDED == pEngineState->internalCommand.mode) { hr = CacheInitializeSources(&pEngineState->cache, &pEngineState->registration, &pEngineState->variables, &pEngineState->internalCommand); ExitOnFailure(hr, "Failed to initialize internal cache source functionality."); @@ -145,7 +142,7 @@ extern "C" HRESULT CoreInitialize( // If we're not elevated then we'll be loading the bootstrapper application, so extract // the payloads from the BA container. - if (BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) + if (BURN_MODE_NORMAL == pEngineState->internalCommand.mode || BURN_MODE_EMBEDDED == pEngineState->internalCommand.mode) { // Extract all UX payloads to working folder. hr = UserExperienceEnsureWorkingFolder(&pEngineState->cache, &pEngineState->userExperience.sczTempDirectory); @@ -176,15 +173,16 @@ extern "C" HRESULT CoreInitializeConstants( ) { HRESULT hr = S_OK; + BURN_ENGINE_COMMAND* pInternalCommand = &pEngineState->internalCommand; BURN_REGISTRATION* pRegistration = &pEngineState->registration; - hr = DependencyInitialize(&pEngineState->internalCommand, &pEngineState->dependencies, pRegistration); + hr = DependencyInitialize(pInternalCommand, &pEngineState->dependencies, pRegistration); ExitOnFailure(hr, "Failed to initialize dependency data."); // Support passing Ancestors to embedded burn bundles. - if (pRegistration->sczAncestors && *pRegistration->sczAncestors) + if (pInternalCommand->sczAncestors && *pInternalCommand->sczAncestors) { - hr = StrAllocFormatted(&pRegistration->sczBundlePackageAncestors, L"%ls;%ls", pRegistration->sczAncestors, pRegistration->sczId); + hr = StrAllocFormatted(&pRegistration->sczBundlePackageAncestors, L"%ls;%ls", pInternalCommand->sczAncestors, pRegistration->sczId); ExitOnFailure(hr, "Failed to copy ancestors and self to bundle package ancestors."); } else @@ -459,6 +457,7 @@ extern "C" HRESULT CorePlan( // we make everywhere. pEngineState->plan.action = action; pEngineState->plan.pCache = &pEngineState->cache; + pEngineState->plan.pCommand = &pEngineState->command; pEngineState->plan.pInternalCommand = &pEngineState->internalCommand; pEngineState->plan.pPayloads = &pEngineState->payloads; pEngineState->plan.wzBundleId = pEngineState->registration.sczId; @@ -470,7 +469,7 @@ extern "C" HRESULT CorePlan( ExitOnFailure(hr, "Failed to update action."); // Set resume commandline - hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->command, &pEngineState->log); + hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->log); ExitOnFailure(hr, "Failed to set resume command"); hr = DependencyPlanInitialize(&pEngineState->dependencies, &pEngineState->plan); @@ -499,7 +498,7 @@ extern "C" HRESULT CorePlan( } else { - hr = PlanForwardCompatibleBundles(&pEngineState->userExperience, &pEngineState->command, &pEngineState->plan, &pEngineState->registration, action); + hr = PlanForwardCompatibleBundles(&pEngineState->userExperience, &pEngineState->plan, &pEngineState->registration); ExitOnFailure(hr, "Failed to plan forward compatible bundles."); if (pEngineState->plan.fEnabledForwardCompatibleBundle) @@ -688,7 +687,7 @@ extern "C" HRESULT CoreApply( hr = CoreElevate(pEngineState, pEngineState->userExperience.hwndApply); ExitOnFailure(hr, "Failed to elevate."); - hr = ElevationApplyInitialize(pEngineState->companionConnection.hPipe, &pEngineState->userExperience, &pEngineState->variables, pEngineState->plan.action, pEngineState->automaticUpdates, !pEngineState->fDisableSystemRestore); + hr = ElevationApplyInitialize(pEngineState->companionConnection.hPipe, &pEngineState->userExperience, &pEngineState->variables, &pEngineState->plan); ExitOnFailure(hr, "Failed to initialize apply in elevated process."); fElevated = TRUE; @@ -932,9 +931,7 @@ extern "C" HRESULT CoreRecreateCommandLine( __in BOOTSTRAPPER_COMMAND* pCommand, __in BOOTSTRAPPER_RELATION_TYPE relationType, __in BOOL fPassthrough, - __in_z_opt LPCWSTR wzAncestors, - __in_z_opt LPCWSTR wzAppendLogPath, - __in_z_opt LPCWSTR wzAdditionalCommandLineArguments + __in_z_opt LPCWSTR wzAppendLogPath ) { HRESULT hr = S_OK; @@ -986,9 +983,9 @@ extern "C" HRESULT CoreRecreateCommandLine( ExitOnFailure(hr, "Failed to append active parent command-line to command-line."); } - if (wzAncestors) + if (pInternalCommand->sczAncestors) { - hr = StrAllocFormatted(&scz, L" /%ls=%ls", BURN_COMMANDLINE_SWITCH_ANCESTORS, wzAncestors); + hr = StrAllocFormatted(&scz, L" /%ls=%ls", BURN_COMMANDLINE_SWITCH_ANCESTORS, pInternalCommand->sczAncestors); ExitOnFailure(hr, "Failed to format ancestors for command-line."); hr = StrAllocConcat(psczCommandLine, scz, 0); @@ -1022,12 +1019,12 @@ extern "C" HRESULT CoreRecreateCommandLine( ExitOnFailure(hr, "Failed to append log command-line to command-line"); } - if (wzAdditionalCommandLineArguments && *wzAdditionalCommandLineArguments) + if (pCommand->wzCommandLine && *pCommand->wzCommandLine) { hr = StrAllocConcat(psczCommandLine, L" ", 0); ExitOnFailure(hr, "Failed to append space to command-line."); - hr = StrAllocConcat(psczCommandLine, wzAdditionalCommandLineArguments, 0); + hr = StrAllocConcat(psczCommandLine, pCommand->wzCommandLine, 0); ExitOnFailure(hr, "Failed to append command-line to command-line."); } @@ -1171,33 +1168,20 @@ LExit: } extern "C" HRESULT CoreParseCommandLine( - __in int argc, - __in LPWSTR* argv, + __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_PIPE_CONNECTION* pCompanionConnection, __in BURN_PIPE_CONNECTION* pEmbeddedConnection, - __inout BURN_MODE* pMode, - __inout BURN_AU_PAUSE_ACTION* pAutomaticUpdates, - __inout BOOL* pfDisableSystemRestore, - __inout_z LPWSTR* psczSourceProcessPath, - __inout_z LPWSTR* psczOriginalSource, __inout HANDLE* phSectionFile, - __inout HANDLE* phSourceEngineFile, - __inout BOOL* pfDisableUnelevate, - __inout DWORD* pdwLoggingAttributes, - __inout_z LPWSTR* psczLogFile, - __inout_z LPWSTR* psczActiveParent, - __inout_z LPWSTR* psczIgnoreDependencies, - __inout_z LPWSTR* psczAncestors, - __inout BOOL* pfInvalidCommandLine, - __inout DWORD* pcUnknownArgs, - __inout int** prgUnknownArgs + __inout HANDLE* phSourceEngineFile ) { HRESULT hr = S_OK; BOOL fUnknownArg = FALSE; BOOL fInvalidCommandLine = FALSE; DWORD64 qw = 0; + int argc = pInternalCommand->argc; + LPWSTR* argv = pInternalCommand->argv; for (int i = 0; i < argc; ++i) { @@ -1209,11 +1193,11 @@ extern "C" HRESULT CoreParseCommandLine( CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"log", -1) || CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"xlog", -1)) { - *pdwLoggingAttributes &= ~BURN_LOGGING_ATTRIBUTE_APPEND; + pInternalCommand->dwLoggingAttributes &= ~BURN_LOGGING_ATTRIBUTE_APPEND; if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], 1, L"x", 1)) { - *pdwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE | BURN_LOGGING_ATTRIBUTE_EXTRADEBUG; + pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE | BURN_LOGGING_ATTRIBUTE_EXTRADEBUG; } if (i + 1 >= argc) @@ -1224,7 +1208,7 @@ extern "C" HRESULT CoreParseCommandLine( ++i; - hr = StrAllocString(psczLogFile, argv[i], 0); + hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0); ExitOnFailure(hr, "Failed to copy log file path."); } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"?", -1) || @@ -1291,19 +1275,19 @@ extern "C" HRESULT CoreParseCommandLine( } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"noaupause", -1)) { - *pAutomaticUpdates = BURN_AU_PAUSE_ACTION_NONE; + pInternalCommand->automaticUpdates = BURN_AU_PAUSE_ACTION_NONE; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"keepaupaused", -1)) { // Switch /noaupause takes precedence. - if (BURN_AU_PAUSE_ACTION_NONE != *pAutomaticUpdates) + if (BURN_AU_PAUSE_ACTION_NONE != pInternalCommand->automaticUpdates) { - *pAutomaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME; + pInternalCommand->automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME; } } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"disablesystemrestore", -1)) { - *pfDisableSystemRestore = TRUE; + pInternalCommand->fDisableSystemRestore = TRUE; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"originalsource", -1)) { @@ -1314,7 +1298,7 @@ extern "C" HRESULT CoreParseCommandLine( } ++i; - hr = StrAllocString(psczOriginalSource, argv[i], 0); + hr = StrAllocString(&pInternalCommand->sczOriginalSource, argv[i], 0); ExitOnFailure(hr, "Failed to copy last used source."); } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT, -1)) @@ -1327,12 +1311,12 @@ extern "C" HRESULT CoreParseCommandLine( ++i; - hr = StrAllocString(psczActiveParent, argv[i], 0); + hr = StrAllocString(&pInternalCommand->sczActiveParent, argv[i], 0); ExitOnFailure(hr, "Failed to copy parent."); } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT_NONE, -1)) { - hr = StrAllocString(psczActiveParent, L"", 0); + hr = StrAllocString(&pInternalCommand->sczActiveParent, L"", 0); ExitOnFailure(hr, "Failed to initialize parent to none."); } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_LOG_APPEND, -1)) @@ -1345,10 +1329,10 @@ extern "C" HRESULT CoreParseCommandLine( ++i; - hr = StrAllocString(psczLogFile, argv[i], 0); + hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0); ExitOnFailure(hr, "Failed to copy append log file path."); - *pdwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND; + pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_ELEVATED, -1)) { @@ -1358,13 +1342,13 @@ extern "C" HRESULT CoreParseCommandLine( ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the elevated name, token and parent process id."); } - if (BURN_MODE_UNTRUSTED != *pMode) + if (BURN_MODE_UNTRUSTED != pInternalCommand->mode) { fInvalidCommandLine = TRUE; TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided."); } - *pMode = BURN_MODE_ELEVATED; + pInternalCommand->mode = BURN_MODE_ELEVATED; ++i; @@ -1380,9 +1364,9 @@ extern "C" HRESULT CoreParseCommandLine( } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM), BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM))) { - if (BURN_MODE_UNTRUSTED == *pMode) + if (BURN_MODE_UNTRUSTED == pInternalCommand->mode) { - *pMode = BURN_MODE_NORMAL; + pInternalCommand->mode = BURN_MODE_NORMAL; } else { @@ -1401,7 +1385,7 @@ extern "C" HRESULT CoreParseCommandLine( } else if (L'\0' != wzParam[1]) { - hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0); + hr = StrAllocString(&pInternalCommand->sczSourceProcessPath, wzParam + 1, 0); ExitOnFailure(hr, "Failed to copy source process path."); } } @@ -1414,7 +1398,7 @@ extern "C" HRESULT CoreParseCommandLine( ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the embedded name, token and parent process id."); } - switch (*pMode) + switch (pInternalCommand->mode) { case BURN_MODE_UNTRUSTED: // Leave mode as UNTRUSTED to launch the clean room process. @@ -1423,7 +1407,7 @@ extern "C" HRESULT CoreParseCommandLine( // The initialization code already assumes that the // clean room switch is at the beginning of the command line, // so it's safe to assume that the mode is NORMAL in the clean room. - *pMode = BURN_MODE_EMBEDDED; + pInternalCommand->mode = BURN_MODE_EMBEDDED; break; default: fInvalidCommandLine = TRUE; @@ -1478,17 +1462,17 @@ extern "C" HRESULT CoreParseCommandLine( } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_DISABLE_UNELEVATE, -1)) { - *pfDisableUnelevate = TRUE; + pInternalCommand->fDisableUnelevate = TRUE; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1)) { - if (BURN_MODE_UNTRUSTED != *pMode) + if (BURN_MODE_UNTRUSTED != pInternalCommand->mode) { fInvalidCommandLine = TRUE; TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided."); } - *pMode = BURN_MODE_RUNONCE; + 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))) { @@ -1501,7 +1485,7 @@ extern "C" HRESULT CoreParseCommandLine( } else { - hr = StrAllocString(psczIgnoreDependencies, &wzParam[1], 0); + hr = StrAllocString(&pInternalCommand->sczIgnoreDependencies, &wzParam[1], 0); ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); } } @@ -1516,7 +1500,7 @@ extern "C" HRESULT CoreParseCommandLine( } else { - hr = StrAllocString(psczAncestors, &wzParam[1], 0); + hr = StrAllocString(&pInternalCommand->sczAncestors, &wzParam[1], 0); ExitOnFailure(hr, "Failed to allocate the list of ancestors."); } } @@ -1604,18 +1588,21 @@ extern "C" HRESULT CoreParseCommandLine( if (fUnknownArg) { - hr = MemEnsureArraySizeForNewItems(reinterpret_cast(prgUnknownArgs), *pcUnknownArgs, 1, sizeof(int), 5); + hr = MemEnsureArraySizeForNewItems(reinterpret_cast(&pInternalCommand->rgUnknownArgs), pInternalCommand->cUnknownArgs, 1, sizeof(int), 5); ExitOnFailure(hr, "Failed to ensure size for unknown args."); - (*prgUnknownArgs)[*pcUnknownArgs] = i; - *pcUnknownArgs += 1; + pInternalCommand->rgUnknownArgs[pInternalCommand->cUnknownArgs] = i; + pInternalCommand->cUnknownArgs += 1; } } - // If embedded, ensure the display goes embedded as well. - if (BURN_MODE_EMBEDDED == *pMode) + if (BURN_MODE_EMBEDDED == pInternalCommand->mode) { + // Ensure the display goes embedded as well. pCommand->display = BOOTSTRAPPER_DISPLAY_EMBEDDED; + + // Disable system restore since the parent bundle may have done it. + pInternalCommand->fDisableSystemRestore = TRUE; } // Set the defaults if nothing was set above. @@ -1633,7 +1620,7 @@ LExit: if (fInvalidCommandLine) { hr = S_OK; - *pfInvalidCommandLine = TRUE; + pInternalCommand->fInvalidCommandLine = TRUE; } return hr; @@ -1642,12 +1629,9 @@ LExit: // internal helper functions static HRESULT GetSanitizedCommandLine( - __in int argc, - __in LPWSTR* argv, + __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_VARIABLES* pVariables, - __in DWORD cUnknownArgs, - __in int* rgUnknownArgs, __inout_z LPWSTR* psczSanitizedCommandLine ) { @@ -1656,6 +1640,10 @@ static HRESULT GetSanitizedCommandLine( BOOL fHidden = FALSE; LPWSTR sczSanitizedArgument = NULL; LPWSTR sczVariableName = NULL; + int argc = pInternalCommand->argc; + LPWSTR* argv = pInternalCommand->argv; + DWORD cUnknownArgs = pInternalCommand->cUnknownArgs; + int* rgUnknownArgs = pInternalCommand->rgUnknownArgs; for (int i = 0; i < argc; ++i) { diff --git a/src/burn/engine/core.h b/src/burn/engine/core.h index 9a6305d3..ec557d48 100644 --- a/src/burn/engine/core.h +++ b/src/burn/engine/core.h @@ -80,13 +80,27 @@ enum BURN_AU_PAUSE_ACTION typedef struct _BURN_ENGINE_COMMAND { + int argc; + LPWSTR* argv; + DWORD cUnknownArgs; + int* rgUnknownArgs; + BOOL fInvalidCommandLine; + + BURN_MODE mode; + BURN_AU_PAUSE_ACTION automaticUpdates; + BOOL fDisableSystemRestore; + BOOL fDisableUnelevate; BOOL fInitiallyElevated; LPWSTR sczActiveParent; + LPWSTR sczAncestors; LPWSTR sczIgnoreDependencies; LPWSTR sczSourceProcessPath; LPWSTR sczOriginalSource; + + DWORD dwLoggingAttributes; + LPWSTR sczLogFile; } BURN_ENGINE_COMMAND; typedef struct _BURN_ENGINE_STATE @@ -122,7 +136,6 @@ typedef struct _BURN_ENGINE_STATE HANDLE hMessageWindowThread; BOOL fDisableRollback; - BOOL fDisableSystemRestore; BOOL fParallelCacheAndExecute; BURN_LOGGING log; @@ -131,9 +144,6 @@ typedef struct _BURN_ENGINE_STATE BURN_PLAN plan; - BURN_MODE mode; - BURN_AU_PAUSE_ACTION automaticUpdates; - DWORD dwElevatedLoggingTlsId; LPWSTR sczBundleEngineWorkingPath; @@ -141,14 +151,8 @@ typedef struct _BURN_ENGINE_STATE BURN_PIPE_CONNECTION embeddedConnection; BURN_RESUME_MODE resumeMode; - BOOL fDisableUnelevate; - int argc; - LPWSTR* argv; - BOOL fInvalidCommandLine; BURN_ENGINE_COMMAND internalCommand; - DWORD cUnknownArgs; - int* rgUnknownArgs; } BURN_ENGINE_STATE; typedef struct _BURN_APPLY_CONTEXT @@ -218,9 +222,7 @@ HRESULT CoreRecreateCommandLine( __in BOOTSTRAPPER_COMMAND* pCommand, __in BOOTSTRAPPER_RELATION_TYPE relationType, __in BOOL fPassthrough, - __in_z_opt LPCWSTR wzAncestors, - __in_z_opt LPCWSTR wzAppendLogPath, - __in_z_opt LPCWSTR wzAdditionalCommandLineArguments + __in_z_opt LPCWSTR wzAppendLogPath ); HRESULT CoreAppendFileHandleAttachedToCommandLine( __in HANDLE hFileWithAttachedContainer, @@ -241,27 +243,12 @@ void CoreCleanup( __in BURN_ENGINE_STATE* pEngineState ); HRESULT CoreParseCommandLine( - __in int argc, - __in LPWSTR* argv, + __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_PIPE_CONNECTION* pCompanionConnection, __in BURN_PIPE_CONNECTION* pEmbeddedConnection, - __inout BURN_MODE* pMode, - __inout BURN_AU_PAUSE_ACTION* pAutomaticUpdates, - __inout BOOL* pfDisableSystemRestore, - __inout_z LPWSTR* psczSourceProcessPath, - __inout_z LPWSTR* psczOriginalSource, __inout HANDLE* phSectionFile, - __inout HANDLE* phSourceEngineFile, - __inout BOOL* pfDisableUnelevate, - __inout DWORD* pdwLoggingAttributes, - __inout_z LPWSTR* psczLogFile, - __inout_z LPWSTR* psczActiveParent, - __inout_z LPWSTR* psczIgnoreDependencies, - __inout_z LPWSTR* psczAncestors, - __inout BOOL* pfInvalidCommandLine, - __inout DWORD* pcUnknownArgs, - __inout int** prgUnknownArgs + __inout HANDLE* phSourceEngineFile ); #if defined(__cplusplus) diff --git a/src/burn/engine/elevation.cpp b/src/burn/engine/elevation.cpp index a0ad6685..03674f0b 100644 --- a/src/burn/engine/elevation.cpp +++ b/src/burn/engine/elevation.cpp @@ -339,7 +339,7 @@ extern "C" HRESULT ElevationElevate( __in_opt HWND hwndParent ) { - Assert(BURN_MODE_ELEVATED != pEngineState->mode); + Assert(BURN_MODE_ELEVATED != pEngineState->internalCommand.mode); Assert(!pEngineState->companionConnection.sczName); Assert(!pEngineState->companionConnection.sczSecret); Assert(!pEngineState->companionConnection.hProcess); @@ -407,9 +407,7 @@ extern "C" HRESULT ElevationApplyInitialize( __in HANDLE hPipe, __in BURN_USER_EXPERIENCE* pBA, __in BURN_VARIABLES* pVariables, - __in BOOTSTRAPPER_ACTION action, - __in BURN_AU_PAUSE_ACTION auAction, - __in BOOL fTakeSystemRestorePoint + __in BURN_PLAN* pPlan ) { HRESULT hr = S_OK; @@ -421,13 +419,13 @@ extern "C" HRESULT ElevationApplyInitialize( context.pBA = pBA; // serialize message data - hr = BuffWriteNumber(&pbData, &cbData, (DWORD)action); + hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pPlan->action); ExitOnFailure(hr, "Failed to write action to message buffer."); - hr = BuffWriteNumber(&pbData, &cbData, (DWORD)auAction); + hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pPlan->pInternalCommand->automaticUpdates); ExitOnFailure(hr, "Failed to write update action to message buffer."); - hr = BuffWriteNumber(&pbData, &cbData, (DWORD)fTakeSystemRestorePoint); + hr = BuffWriteNumber(&pbData, &cbData, (DWORD)!pPlan->pInternalCommand->fDisableSystemRestore); ExitOnFailure(hr, "Failed to write system restore point action to message buffer."); hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); diff --git a/src/burn/engine/elevation.h b/src/burn/engine/elevation.h index fb2e9cb4..ad1141bb 100644 --- a/src/burn/engine/elevation.h +++ b/src/burn/engine/elevation.h @@ -16,9 +16,7 @@ HRESULT ElevationApplyInitialize( __in HANDLE hPipe, __in BURN_USER_EXPERIENCE* pBA, __in BURN_VARIABLES* pVariables, - __in BOOTSTRAPPER_ACTION action, - __in BURN_AU_PAUSE_ACTION auAction, - __in BOOL fTakeSystemRestorePoint + __in BURN_PLAN* pPlan ); HRESULT ElevationApplyUninitialize( __in HANDLE hPipe diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp index 66eee27e..e65600b5 100644 --- a/src/burn/engine/engine.cpp +++ b/src/burn/engine/engine.cpp @@ -113,7 +113,7 @@ extern "C" HRESULT EngineRun( LogSetLevel(REPORT_VERBOSE, FALSE); // FALSE means don't write an additional text line to the log saying the level changed #endif - hr = AppParseCommandLine(wzCommandLine, &engineState.argc, &engineState.argv); + hr = AppParseCommandLine(wzCommandLine, &engineState.internalCommand.argc, &engineState.internalCommand.argv); ExitOnFailure(hr, "Failed to parse command line."); hr = InitializeEngineState(&engineState, hEngineFile); @@ -121,7 +121,7 @@ extern "C" HRESULT EngineRun( engineState.command.nCmdShow = nCmdShow; - if (BURN_MODE_ELEVATED != engineState.mode && BOOTSTRAPPER_DISPLAY_NONE < engineState.command.display && !engineState.command.hwndSplashScreen) + if (BURN_MODE_ELEVATED != engineState.internalCommand.mode && BOOTSTRAPPER_DISPLAY_NONE < engineState.command.display && !engineState.command.hwndSplashScreen) { SplashScreenCreate(hInstance, NULL, &engineState.command.hwndSplashScreen); } @@ -192,7 +192,7 @@ extern "C" HRESULT EngineRun( ExitOnFailure(hr, "Failed to initialize core."); // Select run mode. - switch (engineState.mode) + switch (engineState.internalCommand.mode) { case BURN_MODE_UNTRUSTED: hr = RunUntrusted(wzCommandLine, &engineState); @@ -328,7 +328,7 @@ static HRESULT InitializeEngineState( HANDLE hSectionFile = hEngineFile; HANDLE hSourceEngineFile = INVALID_HANDLE_VALUE; - pEngineState->automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED; + pEngineState->internalCommand.automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED; pEngineState->dwElevatedLoggingTlsId = TLS_OUT_OF_INDEXES; ::InitializeCriticalSection(&pEngineState->userExperience.csEngineActive); PipeConnectionInitialize(&pEngineState->companionConnection); @@ -338,7 +338,7 @@ static HRESULT InitializeEngineState( ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated); // Parse command line. - hr = CoreParseCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &pEngineState->mode, &pEngineState->automaticUpdates, &pEngineState->fDisableSystemRestore, &pEngineState->internalCommand.sczSourceProcessPath, &pEngineState->internalCommand.sczOriginalSource, &hSectionFile, &hSourceEngineFile, &pEngineState->fDisableUnelevate, &pEngineState->log.dwAttributes, &pEngineState->log.sczPath, &pEngineState->internalCommand.sczActiveParent, &pEngineState->internalCommand.sczIgnoreDependencies, &pEngineState->registration.sczAncestors, &pEngineState->fInvalidCommandLine, &pEngineState->cUnknownArgs, &pEngineState->rgUnknownArgs); + hr = CoreParseCommandLine(&pEngineState->internalCommand, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &hSectionFile, &hSourceEngineFile); ExitOnFailure(hr, "Fatal error while parsing command line."); hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile); @@ -355,12 +355,12 @@ static void UninitializeEngineState( __in BURN_ENGINE_STATE* pEngineState ) { - if (pEngineState->argv) + if (pEngineState->internalCommand.argv) { - AppFreeCommandLineArgs(pEngineState->argv); + AppFreeCommandLineArgs(pEngineState->internalCommand.argv); } - ReleaseMem(pEngineState->rgUnknownArgs); + ReleaseMem(pEngineState->internalCommand.rgUnknownArgs); PipeConnectionUninitialize(&pEngineState->embeddedConnection); PipeConnectionUninitialize(&pEngineState->companionConnection); @@ -390,7 +390,9 @@ static void UninitializeEngineState( ReleaseStr(pEngineState->command.wzCommandLine); ReleaseStr(pEngineState->internalCommand.sczActiveParent); + ReleaseStr(pEngineState->internalCommand.sczAncestors); ReleaseStr(pEngineState->internalCommand.sczIgnoreDependencies); + ReleaseStr(pEngineState->internalCommand.sczLogFile); ReleaseStr(pEngineState->internalCommand.sczOriginalSource); ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath); @@ -469,7 +471,7 @@ static HRESULT RunUntrusted( #ifdef ENABLE_UNELEVATE // TODO: Pass file handle to unelevated process if this ever gets reenabled. - if (!pEngineState->fDisableUnelevate) + if (!pEngineState->internalCommand.fDisableUnelevate) { // Try to launch unelevated and if that fails for any reason, we'll launch our process normally (even though that may make it elevated). hr = ProcExecuteAsInteractiveUser(wzCleanRoomBundlePath, sczParameters, &hProcess); @@ -522,7 +524,7 @@ static HRESULT RunNormal( BURN_EXTENSION_ENGINE_CONTEXT extensionEngineContext = { }; // Initialize logging. - hr = LoggingOpen(&pEngineState->log, &pEngineState->variables, pEngineState->command.display, pEngineState->registration.sczDisplayName); + hr = LoggingOpen(&pEngineState->log, &pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, pEngineState->registration.sczDisplayName); ExitOnFailure(hr, "Failed to open log."); // Ensure we're on a supported operating system. @@ -694,9 +696,6 @@ static HRESULT RunEmbedded( { HRESULT hr = S_OK; - // Disable system restore since the parent bundle may have done it. - pEngineState->fDisableSystemRestore = TRUE; - // Connect to parent process. hr = PipeChildConnect(&pEngineState->embeddedConnection, FALSE); ExitOnFailure(hr, "Failed to connect to parent of embedded process."); diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index 60497640..27db35cc 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp @@ -197,7 +197,7 @@ HRESULT ExternalEngineSendEmbeddedError( SIZE_T cbData = 0; DWORD dwResult = *pnResult = 0; - if (BURN_MODE_EMBEDDED != pEngineState->mode) + if (BURN_MODE_EMBEDDED != pEngineState->internalCommand.mode) { hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE); ExitOnRootFailure(hr, "BA requested to send embedded message when not in embedded mode."); @@ -235,7 +235,7 @@ HRESULT ExternalEngineSendEmbeddedProgress( SIZE_T cbData = 0; DWORD dwResult = *pnResult = 0; - if (BURN_MODE_EMBEDDED != pEngineState->mode) + if (BURN_MODE_EMBEDDED != pEngineState->internalCommand.mode) { hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE); ExitOnRootFailure(hr, "BA requested to send embedded progress message when not in embedded mode."); @@ -295,7 +295,7 @@ HRESULT ExternalEngineSetUpdate( { UpdateUninitialize(&pEngineState->update); - hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, &pEngineState->internalCommand, &pEngineState->command, BOOTSTRAPPER_RELATION_NONE, FALSE, pEngineState->registration.sczAncestors, NULL, pEngineState->command.wzCommandLine); + hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, &pEngineState->internalCommand, &pEngineState->command, BOOTSTRAPPER_RELATION_NONE, FALSE, NULL); ExitOnFailure(hr, "Failed to recreate command-line for update bundle."); // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths. diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp index 2db7defd..6b19cc8a 100644 --- a/src/burn/engine/logging.cpp +++ b/src/burn/engine/logging.cpp @@ -15,7 +15,11 @@ static CONST LPWSTR LOG_FAILED_EVENT_LOG_MESSAGE = L"Burn Engine Fatal Error: fa // internal function declarations static void CheckLoggingPolicy( - __out DWORD *pdwAttributes + __inout DWORD* pdwAttributes + ); +static HRESULT InitializeLogging( + __in BURN_LOGGING* pLog, + __in BURN_ENGINE_COMMAND* pInternalCommand ); static HRESULT GetNonSessionSpecificTempFolder( __deref_out_z LPWSTR* psczNonSessionTempFolder @@ -26,8 +30,9 @@ static HRESULT GetNonSessionSpecificTempFolder( extern "C" HRESULT LoggingOpen( __in BURN_LOGGING* pLog, + __in BURN_ENGINE_COMMAND* pInternalCommand, + __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_VARIABLES* pVariables, - __in BOOTSTRAPPER_DISPLAY display, __in_z LPCWSTR wzBundleName ) { @@ -35,8 +40,8 @@ extern "C" HRESULT LoggingOpen( LPWSTR sczLoggingBaseFolder = NULL; LPWSTR sczPrefixFormatted = NULL; - // Check if the logging policy is set and configure the logging appropriately. - CheckLoggingPolicy(&pLog->dwAttributes); + hr = InitializeLogging(pLog, pInternalCommand); + ExitOnFailure(hr, "Failed to initialize logging."); if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_VERBOSE || pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG) { @@ -94,7 +99,7 @@ extern "C" HRESULT LoggingOpen( HRESULT hrOriginal = hr; hr = HRESULT_FROM_WIN32(ERROR_INSTALL_LOG_FAILURE); - SplashScreenDisplayError(display, wzBundleName, hr); + SplashScreenDisplayError(pCommand->display, wzBundleName, hr); ExitOnFailure(hrOriginal, "Failed to open log: %ls", pLog->sczPath); } @@ -709,7 +714,7 @@ extern "C" LPWSTR LoggingStringOrUnknownIfNull( // internal function declarations static void CheckLoggingPolicy( - __out DWORD *pdwAttributes + __inout DWORD *pdwAttributes ) { HRESULT hr = S_OK; @@ -743,6 +748,28 @@ static void CheckLoggingPolicy( ReleaseRegKey(hk); } +static HRESULT InitializeLogging( + __in BURN_LOGGING* pLog, + __in BURN_ENGINE_COMMAND* pInternalCommand + ) +{ + HRESULT hr = S_OK; + + // Check if the logging policy is set and configure the logging appropriately. + CheckLoggingPolicy(&pLog->dwAttributes); + + pLog->dwAttributes |= pInternalCommand->dwLoggingAttributes; + + if (pInternalCommand->sczLogFile) + { + hr = StrAllocString(&pLog->sczPath, pInternalCommand->sczLogFile, 0); + ExitOnFailure(hr, "Failed to copy log file path from command line."); + } + +LExit: + return hr; +} + static HRESULT GetNonSessionSpecificTempFolder( __deref_out_z LPWSTR* psczNonSessionTempFolder ) diff --git a/src/burn/engine/logging.h b/src/burn/engine/logging.h index 21ea6297..492e14b6 100644 --- a/src/burn/engine/logging.h +++ b/src/burn/engine/logging.h @@ -43,8 +43,9 @@ typedef struct _BURN_LOGGING HRESULT LoggingOpen( __in BURN_LOGGING* pLog, + __in BURN_ENGINE_COMMAND* pInternalCommand, + __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_VARIABLES* pVariables, - __in BOOTSTRAPPER_DISPLAY display, __in_z LPCWSTR wzBundleName ); diff --git a/src/burn/engine/manifest.cpp b/src/burn/engine/manifest.cpp index 1ef8e610..7e16de13 100644 --- a/src/burn/engine/manifest.cpp +++ b/src/burn/engine/manifest.cpp @@ -98,7 +98,7 @@ static HRESULT ParseFromXml( } // parse disable system restore - hr = XmlGetYesNoAttribute(pixnChain, L"DisableSystemRestore", &pEngineState->fDisableSystemRestore); + hr = XmlGetYesNoAttribute(pixnChain, L"DisableSystemRestore", &pEngineState->internalCommand.fDisableSystemRestore); if (E_NOTFOUND != hr) { ExitOnFailure(hr, "Failed to get Chain/@DisableSystemRestore"); diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp index 8c5b7051..f3d37978 100644 --- a/src/burn/engine/plan.cpp +++ b/src/burn/engine/plan.cpp @@ -428,15 +428,14 @@ LExit: extern "C" HRESULT PlanForwardCompatibleBundles( __in BURN_USER_EXPERIENCE* pUX, - __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_PLAN* pPlan, - __in BURN_REGISTRATION* pRegistration, - __in BOOTSTRAPPER_ACTION action + __in BURN_REGISTRATION* pRegistration ) { HRESULT hr = S_OK; BOOL fRecommendIgnore = TRUE; BOOL fIgnoreBundle = FALSE; + BOOTSTRAPPER_ACTION action = pPlan->action; if (!pRegistration->fForwardCompatibleBundleExists) { @@ -480,7 +479,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles( if (!fIgnoreBundle) { - hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pPlan->pInternalCommand, pCommand, NULL, pRegistration->sczAncestors, &pRelatedBundle->package); + hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pPlan->pInternalCommand, pPlan->pCommand, NULL, &pRelatedBundle->package); ExitOnFailure(hr, "Failed to initialize pass through bundle."); pPlan->fEnabledForwardCompatibleBundle = TRUE; @@ -1239,9 +1238,9 @@ extern "C" HRESULT PlanRelatedBundlesBegin( UINT cAncestors = 0; STRINGDICT_HANDLE sdAncestors = NULL; - if (pRegistration->sczAncestors) + if (pPlan->pInternalCommand->sczAncestors) { - hr = StrSplitAllocArray(&rgsczAncestors, &cAncestors, pRegistration->sczAncestors, L";"); + hr = StrSplitAllocArray(&rgsczAncestors, &cAncestors, pPlan->pInternalCommand->sczAncestors, L";"); ExitOnFailure(hr, "Failed to create string array from ancestors."); hr = DictCreateStringListFromArray(&sdAncestors, rgsczAncestors, cAncestors, DICT_FLAG_CASEINSENSITIVE); @@ -1777,14 +1776,14 @@ LExit: extern "C" HRESULT PlanSetResumeCommand( __in BURN_PLAN* pPlan, __in BURN_REGISTRATION* pRegistration, - __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_LOGGING* pLog ) { HRESULT hr = S_OK; + BOOTSTRAPPER_COMMAND* pCommand = pPlan->pCommand; // build the resume command-line. - hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, pPlan->action, pPlan->pInternalCommand, pCommand, pCommand->relationType, pCommand->fPassthrough, pRegistration->sczAncestors, pLog->sczPath, pCommand->wzCommandLine); + hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, pPlan->action, pPlan->pInternalCommand, pCommand, pCommand->relationType, pCommand->fPassthrough, pLog->sczPath); ExitOnFailure(hr, "Failed to recreate resume command-line."); LExit: diff --git a/src/burn/engine/plan.h b/src/burn/engine/plan.h index 00a5bf0d..224f3806 100644 --- a/src/burn/engine/plan.h +++ b/src/burn/engine/plan.h @@ -230,6 +230,7 @@ typedef struct _BURN_PLAN { BOOTSTRAPPER_ACTION action; BURN_CACHE* pCache; + BOOTSTRAPPER_COMMAND* pCommand; BURN_ENGINE_COMMAND* pInternalCommand; BURN_PAYLOADS* pPayloads; LPWSTR wzBundleId; // points directly into parent the ENGINE_STATE. @@ -326,10 +327,8 @@ HRESULT PlanLayoutBundle( ); HRESULT PlanForwardCompatibleBundles( __in BURN_USER_EXPERIENCE* pUX, - __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_PLAN* pPlan, - __in BURN_REGISTRATION* pRegistration, - __in BOOTSTRAPPER_ACTION action + __in BURN_REGISTRATION* pRegistration ); HRESULT PlanPackages( __in BURN_USER_EXPERIENCE* pUX, @@ -446,7 +445,6 @@ HRESULT PlanRollbackBoundaryComplete( HRESULT PlanSetResumeCommand( __in BURN_PLAN* pPlan, __in BURN_REGISTRATION* pRegistration, - __in BOOTSTRAPPER_COMMAND* pCommand, __in BURN_LOGGING* pLog ); void PlanDump( diff --git a/src/burn/engine/pseudobundle.cpp b/src/burn/engine/pseudobundle.cpp index df3edef6..00007247 100644 --- a/src/burn/engine/pseudobundle.cpp +++ b/src/burn/engine/pseudobundle.cpp @@ -166,7 +166,6 @@ extern "C" HRESULT PseudoBundleInitializePassthrough( __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in_z_opt LPCWSTR wzAppendLogPath, - __in_z_opt LPCWSTR wzAncestors, __in BURN_PACKAGE* pPackage ) { @@ -205,7 +204,7 @@ extern "C" HRESULT PseudoBundleInitializePassthrough( // No matter the operation, we're passing the same command-line. That's what makes // this a passthrough bundle. - hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pInternalCommand, pCommand, pCommand->relationType, TRUE, wzAncestors, wzAppendLogPath, pCommand->wzCommandLine); + hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pInternalCommand, pCommand, pCommand->relationType, TRUE, wzAppendLogPath); ExitOnFailure(hr, "Failed to recreate command-line arguments."); hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0); diff --git a/src/burn/engine/pseudobundle.h b/src/burn/engine/pseudobundle.h index 75ad08d2..5c4ca836 100644 --- a/src/burn/engine/pseudobundle.h +++ b/src/burn/engine/pseudobundle.h @@ -31,7 +31,6 @@ HRESULT PseudoBundleInitializePassthrough( __in BURN_ENGINE_COMMAND* pInternalCommand, __in BOOTSTRAPPER_COMMAND* pCommand, __in_z_opt LPCWSTR wzAppendLogPath, - __in_z_opt LPCWSTR wzAncestors, __in BURN_PACKAGE* pPackage ); diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index 51e75b78..0fb9da5b 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp @@ -424,7 +424,6 @@ extern "C" void RegistrationUninitialize( } ReleaseStr(pRegistration->sczDetectedProviderKeyBundleId); - ReleaseStr(pRegistration->sczAncestors); ReleaseStr(pRegistration->sczBundlePackageAncestors); RelatedBundlesUninitialize(&pRegistration->relatedBundles); diff --git a/src/burn/engine/registration.h b/src/burn/engine/registration.h index 4da792d3..f9411636 100644 --- a/src/burn/engine/registration.h +++ b/src/burn/engine/registration.h @@ -152,7 +152,6 @@ typedef struct _BURN_REGISTRATION BOOL fEligibleForCleanup; // Only valid after detect. LPWSTR sczDetectedProviderKeyBundleId; - LPWSTR sczAncestors; LPWSTR sczBundlePackageAncestors; } BURN_REGISTRATION; diff --git a/src/burn/engine/uithread.cpp b/src/burn/engine/uithread.cpp index 986342b2..187f3349 100644 --- a/src/burn/engine/uithread.cpp +++ b/src/burn/engine/uithread.cpp @@ -105,7 +105,7 @@ static DWORD WINAPI ThreadProc( MSG msg = { }; BURN_ENGINE_STATE* pEngineState = pContext->pEngineState; - BOOL fElevatedEngine = BURN_MODE_ELEVATED == pContext->pEngineState->mode; + BOOL fElevatedEngine = BURN_MODE_ELEVATED == pContext->pEngineState->internalCommand.mode; // If elevated, set up the thread local storage to store the correct pipe to communicate logging. if (fElevatedEngine) diff --git a/src/burn/test/BurnUnitTest/PlanTest.cpp b/src/burn/test/BurnUnitTest/PlanTest.cpp index c7f2037d..ee3dcf3a 100644 --- a/src/burn/test/BurnUnitTest/PlanTest.cpp +++ b/src/burn/test/BurnUnitTest/PlanTest.cpp @@ -1144,9 +1144,12 @@ namespace Bootstrapper __in LPCWSTR wzVersion ) { - HRESULT hr = StrAllocString(&pEngineState->registration.sczAncestors, wzId, 0); + HRESULT hr = StrAllocString(&pEngineState->internalCommand.sczAncestors, wzId, 0); NativeAssert::Succeeded(hr, "Failed to set registration's ancestors"); + hr = StrAllocFormatted(&pEngineState->registration.sczBundlePackageAncestors, L"%ls;%ls", wzId, pEngineState->registration.sczId); + NativeAssert::Succeeded(hr, "Failed to set registration's package ancestors"); + pEngineState->command.relationType = BOOTSTRAPPER_RELATION_UPGRADE; DetectPackagesAsPresentAndCached(pEngineState); diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp index af52e893..32ff9ea2 100644 --- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp +++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp @@ -115,9 +115,10 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to parse registration from XML."); plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pCommand = &command; plan.pInternalCommand = &internalCommand; - hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); + hr = PlanSetResumeCommand(&plan, ®istration, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -213,9 +214,10 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to parse registration from XML."); plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pCommand = &command; plan.pInternalCommand = &internalCommand; - hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); + hr = PlanSetResumeCommand(&plan, ®istration, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -334,9 +336,10 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to parse registration from XML."); plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pCommand = &command; plan.pInternalCommand = &internalCommand; - hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); + hr = PlanSetResumeCommand(&plan, ®istration, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -455,9 +458,10 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to parse registration from XML."); plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pCommand = &command; plan.pInternalCommand = &internalCommand; - hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); + hr = PlanSetResumeCommand(&plan, ®istration, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -601,9 +605,10 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to parse registration from XML."); plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pCommand = &command; plan.pInternalCommand = &internalCommand; - hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); + hr = PlanSetResumeCommand(&plan, ®istration, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); @@ -738,9 +743,10 @@ namespace Bootstrapper TestThrowOnFailure(hr, L"Failed to parse registration from XML."); plan.action = BOOTSTRAPPER_ACTION_INSTALL; + plan.pCommand = &command; plan.pInternalCommand = &internalCommand; - hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging); + hr = PlanSetResumeCommand(&plan, ®istration, &logging); TestThrowOnFailure(hr, L"Failed to set registration resume command."); hr = PathForCurrentProcess(&sczCurrentProcess, NULL); -- cgit v1.2.3-55-g6feb