aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-08-03 15:41:53 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-08-04 10:03:57 -0500
commit9ae1c04d5fa02ac020885cdad7c592f7bb43d83e (patch)
tree2832850289c8b703fa39e5d1c97666331e2310b1
parentce8acddf52bde840571535c3dfd56a2371d80684 (diff)
downloadwix-9ae1c04d5fa02ac020885cdad7c592f7bb43d83e.tar.gz
wix-9ae1c04d5fa02ac020885cdad7c592f7bb43d83e.tar.bz2
wix-9ae1c04d5fa02ac020885cdad7c592f7bb43d83e.zip
Parse most of Burn command line parameters into BURN_ENGINE_COMMAND.
-rw-r--r--src/burn/engine/core.cpp132
-rw-r--r--src/burn/engine/core.h47
-rw-r--r--src/burn/engine/elevation.cpp12
-rw-r--r--src/burn/engine/elevation.h4
-rw-r--r--src/burn/engine/engine.cpp25
-rw-r--r--src/burn/engine/externalengine.cpp6
-rw-r--r--src/burn/engine/logging.cpp39
-rw-r--r--src/burn/engine/logging.h3
-rw-r--r--src/burn/engine/manifest.cpp2
-rw-r--r--src/burn/engine/plan.cpp15
-rw-r--r--src/burn/engine/plan.h6
-rw-r--r--src/burn/engine/pseudobundle.cpp3
-rw-r--r--src/burn/engine/pseudobundle.h1
-rw-r--r--src/burn/engine/registration.cpp1
-rw-r--r--src/burn/engine/registration.h1
-rw-r--r--src/burn/engine/uithread.cpp2
-rw-r--r--src/burn/test/BurnUnitTest/PlanTest.cpp5
-rw-r--r--src/burn/test/BurnUnitTest/RegistrationTest.cpp18
18 files changed, 161 insertions, 161 deletions
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
15// internal function declarations 15// internal function declarations
16 16
17static HRESULT GetSanitizedCommandLine( 17static HRESULT GetSanitizedCommandLine(
18 __in int argc, 18 __in BURN_ENGINE_COMMAND* pInternalCommand,
19 __in LPWSTR* argv,
20 __in BOOTSTRAPPER_COMMAND* pCommand, 19 __in BOOTSTRAPPER_COMMAND* pCommand,
21 __in BURN_VARIABLES* pVariables, 20 __in BURN_VARIABLES* pVariables,
22 __in DWORD cUnknownArgs,
23 __in int* rgUnknownArgs,
24 __inout_z LPWSTR* psczSanitizedCommandLine 21 __inout_z LPWSTR* psczSanitizedCommandLine
25 ); 22 );
26static HRESULT ParsePipeConnection( 23static HRESULT ParsePipeConnection(
@@ -89,7 +86,7 @@ extern "C" HRESULT CoreInitialize(
89 hr = ContainersInitialize(&pEngineState->containers, &pEngineState->section); 86 hr = ContainersInitialize(&pEngineState->containers, &pEngineState->section);
90 ExitOnFailure(hr, "Failed to initialize containers."); 87 ExitOnFailure(hr, "Failed to initialize containers.");
91 88
92 hr = GetSanitizedCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->variables, pEngineState->cUnknownArgs, pEngineState->rgUnknownArgs, &sczSanitizedCommandLine); 89 hr = GetSanitizedCommandLine(&pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, &sczSanitizedCommandLine);
93 ExitOnFailure(hr, "Fatal error while sanitizing command line."); 90 ExitOnFailure(hr, "Fatal error while sanitizing command line.");
94 91
95 LogId(REPORT_STANDARD, MSG_BURN_COMMAND_LINE, sczSanitizedCommandLine ? sczSanitizedCommandLine : L""); 92 LogId(REPORT_STANDARD, MSG_BURN_COMMAND_LINE, sczSanitizedCommandLine ? sczSanitizedCommandLine : L"");
@@ -97,7 +94,7 @@ extern "C" HRESULT CoreInitialize(
97 // The command line wasn't logged immediately so that hidden variables set on the command line can be obscured in the log. 94 // The command line wasn't logged immediately so that hidden variables set on the command line can be obscured in the log.
98 // This delay creates issues when troubleshooting parsing errors because the original command line is not in the log. 95 // This delay creates issues when troubleshooting parsing errors because the original command line is not in the log.
99 // 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. 96 // 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.
100 if (pEngineState->fInvalidCommandLine) 97 if (pEngineState->internalCommand.fInvalidCommandLine)
101 { 98 {
102 LogExitOnRootFailure(hr = E_INVALIDARG, MSG_FAILED_PARSE_COMMAND_LINE, "Failed to parse command line."); 99 LogExitOnRootFailure(hr = E_INVALIDARG, MSG_FAILED_PARSE_COMMAND_LINE, "Failed to parse command line.");
103 } 100 }
@@ -137,7 +134,7 @@ extern "C" HRESULT CoreInitialize(
137 ExitOnFailure(hr, "Failed to set original source variable."); 134 ExitOnFailure(hr, "Failed to set original source variable.");
138 } 135 }
139 136
140 if (BURN_MODE_UNTRUSTED == pEngineState->mode || BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) 137 if (BURN_MODE_UNTRUSTED == pEngineState->internalCommand.mode || BURN_MODE_NORMAL == pEngineState->internalCommand.mode || BURN_MODE_EMBEDDED == pEngineState->internalCommand.mode)
141 { 138 {
142 hr = CacheInitializeSources(&pEngineState->cache, &pEngineState->registration, &pEngineState->variables, &pEngineState->internalCommand); 139 hr = CacheInitializeSources(&pEngineState->cache, &pEngineState->registration, &pEngineState->variables, &pEngineState->internalCommand);
143 ExitOnFailure(hr, "Failed to initialize internal cache source functionality."); 140 ExitOnFailure(hr, "Failed to initialize internal cache source functionality.");
@@ -145,7 +142,7 @@ extern "C" HRESULT CoreInitialize(
145 142
146 // If we're not elevated then we'll be loading the bootstrapper application, so extract 143 // If we're not elevated then we'll be loading the bootstrapper application, so extract
147 // the payloads from the BA container. 144 // the payloads from the BA container.
148 if (BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) 145 if (BURN_MODE_NORMAL == pEngineState->internalCommand.mode || BURN_MODE_EMBEDDED == pEngineState->internalCommand.mode)
149 { 146 {
150 // Extract all UX payloads to working folder. 147 // Extract all UX payloads to working folder.
151 hr = UserExperienceEnsureWorkingFolder(&pEngineState->cache, &pEngineState->userExperience.sczTempDirectory); 148 hr = UserExperienceEnsureWorkingFolder(&pEngineState->cache, &pEngineState->userExperience.sczTempDirectory);
@@ -176,15 +173,16 @@ extern "C" HRESULT CoreInitializeConstants(
176 ) 173 )
177{ 174{
178 HRESULT hr = S_OK; 175 HRESULT hr = S_OK;
176 BURN_ENGINE_COMMAND* pInternalCommand = &pEngineState->internalCommand;
179 BURN_REGISTRATION* pRegistration = &pEngineState->registration; 177 BURN_REGISTRATION* pRegistration = &pEngineState->registration;
180 178
181 hr = DependencyInitialize(&pEngineState->internalCommand, &pEngineState->dependencies, pRegistration); 179 hr = DependencyInitialize(pInternalCommand, &pEngineState->dependencies, pRegistration);
182 ExitOnFailure(hr, "Failed to initialize dependency data."); 180 ExitOnFailure(hr, "Failed to initialize dependency data.");
183 181
184 // Support passing Ancestors to embedded burn bundles. 182 // Support passing Ancestors to embedded burn bundles.
185 if (pRegistration->sczAncestors && *pRegistration->sczAncestors) 183 if (pInternalCommand->sczAncestors && *pInternalCommand->sczAncestors)
186 { 184 {
187 hr = StrAllocFormatted(&pRegistration->sczBundlePackageAncestors, L"%ls;%ls", pRegistration->sczAncestors, pRegistration->sczId); 185 hr = StrAllocFormatted(&pRegistration->sczBundlePackageAncestors, L"%ls;%ls", pInternalCommand->sczAncestors, pRegistration->sczId);
188 ExitOnFailure(hr, "Failed to copy ancestors and self to bundle package ancestors."); 186 ExitOnFailure(hr, "Failed to copy ancestors and self to bundle package ancestors.");
189 } 187 }
190 else 188 else
@@ -459,6 +457,7 @@ extern "C" HRESULT CorePlan(
459 // we make everywhere. 457 // we make everywhere.
460 pEngineState->plan.action = action; 458 pEngineState->plan.action = action;
461 pEngineState->plan.pCache = &pEngineState->cache; 459 pEngineState->plan.pCache = &pEngineState->cache;
460 pEngineState->plan.pCommand = &pEngineState->command;
462 pEngineState->plan.pInternalCommand = &pEngineState->internalCommand; 461 pEngineState->plan.pInternalCommand = &pEngineState->internalCommand;
463 pEngineState->plan.pPayloads = &pEngineState->payloads; 462 pEngineState->plan.pPayloads = &pEngineState->payloads;
464 pEngineState->plan.wzBundleId = pEngineState->registration.sczId; 463 pEngineState->plan.wzBundleId = pEngineState->registration.sczId;
@@ -470,7 +469,7 @@ extern "C" HRESULT CorePlan(
470 ExitOnFailure(hr, "Failed to update action."); 469 ExitOnFailure(hr, "Failed to update action.");
471 470
472 // Set resume commandline 471 // Set resume commandline
473 hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->command, &pEngineState->log); 472 hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->log);
474 ExitOnFailure(hr, "Failed to set resume command"); 473 ExitOnFailure(hr, "Failed to set resume command");
475 474
476 hr = DependencyPlanInitialize(&pEngineState->dependencies, &pEngineState->plan); 475 hr = DependencyPlanInitialize(&pEngineState->dependencies, &pEngineState->plan);
@@ -499,7 +498,7 @@ extern "C" HRESULT CorePlan(
499 } 498 }
500 else 499 else
501 { 500 {
502 hr = PlanForwardCompatibleBundles(&pEngineState->userExperience, &pEngineState->command, &pEngineState->plan, &pEngineState->registration, action); 501 hr = PlanForwardCompatibleBundles(&pEngineState->userExperience, &pEngineState->plan, &pEngineState->registration);
503 ExitOnFailure(hr, "Failed to plan forward compatible bundles."); 502 ExitOnFailure(hr, "Failed to plan forward compatible bundles.");
504 503
505 if (pEngineState->plan.fEnabledForwardCompatibleBundle) 504 if (pEngineState->plan.fEnabledForwardCompatibleBundle)
@@ -688,7 +687,7 @@ extern "C" HRESULT CoreApply(
688 hr = CoreElevate(pEngineState, pEngineState->userExperience.hwndApply); 687 hr = CoreElevate(pEngineState, pEngineState->userExperience.hwndApply);
689 ExitOnFailure(hr, "Failed to elevate."); 688 ExitOnFailure(hr, "Failed to elevate.");
690 689
691 hr = ElevationApplyInitialize(pEngineState->companionConnection.hPipe, &pEngineState->userExperience, &pEngineState->variables, pEngineState->plan.action, pEngineState->automaticUpdates, !pEngineState->fDisableSystemRestore); 690 hr = ElevationApplyInitialize(pEngineState->companionConnection.hPipe, &pEngineState->userExperience, &pEngineState->variables, &pEngineState->plan);
692 ExitOnFailure(hr, "Failed to initialize apply in elevated process."); 691 ExitOnFailure(hr, "Failed to initialize apply in elevated process.");
693 692
694 fElevated = TRUE; 693 fElevated = TRUE;
@@ -932,9 +931,7 @@ extern "C" HRESULT CoreRecreateCommandLine(
932 __in BOOTSTRAPPER_COMMAND* pCommand, 931 __in BOOTSTRAPPER_COMMAND* pCommand,
933 __in BOOTSTRAPPER_RELATION_TYPE relationType, 932 __in BOOTSTRAPPER_RELATION_TYPE relationType,
934 __in BOOL fPassthrough, 933 __in BOOL fPassthrough,
935 __in_z_opt LPCWSTR wzAncestors, 934 __in_z_opt LPCWSTR wzAppendLogPath
936 __in_z_opt LPCWSTR wzAppendLogPath,
937 __in_z_opt LPCWSTR wzAdditionalCommandLineArguments
938 ) 935 )
939{ 936{
940 HRESULT hr = S_OK; 937 HRESULT hr = S_OK;
@@ -986,9 +983,9 @@ extern "C" HRESULT CoreRecreateCommandLine(
986 ExitOnFailure(hr, "Failed to append active parent command-line to command-line."); 983 ExitOnFailure(hr, "Failed to append active parent command-line to command-line.");
987 } 984 }
988 985
989 if (wzAncestors) 986 if (pInternalCommand->sczAncestors)
990 { 987 {
991 hr = StrAllocFormatted(&scz, L" /%ls=%ls", BURN_COMMANDLINE_SWITCH_ANCESTORS, wzAncestors); 988 hr = StrAllocFormatted(&scz, L" /%ls=%ls", BURN_COMMANDLINE_SWITCH_ANCESTORS, pInternalCommand->sczAncestors);
992 ExitOnFailure(hr, "Failed to format ancestors for command-line."); 989 ExitOnFailure(hr, "Failed to format ancestors for command-line.");
993 990
994 hr = StrAllocConcat(psczCommandLine, scz, 0); 991 hr = StrAllocConcat(psczCommandLine, scz, 0);
@@ -1022,12 +1019,12 @@ extern "C" HRESULT CoreRecreateCommandLine(
1022 ExitOnFailure(hr, "Failed to append log command-line to command-line"); 1019 ExitOnFailure(hr, "Failed to append log command-line to command-line");
1023 } 1020 }
1024 1021
1025 if (wzAdditionalCommandLineArguments && *wzAdditionalCommandLineArguments) 1022 if (pCommand->wzCommandLine && *pCommand->wzCommandLine)
1026 { 1023 {
1027 hr = StrAllocConcat(psczCommandLine, L" ", 0); 1024 hr = StrAllocConcat(psczCommandLine, L" ", 0);
1028 ExitOnFailure(hr, "Failed to append space to command-line."); 1025 ExitOnFailure(hr, "Failed to append space to command-line.");
1029 1026
1030 hr = StrAllocConcat(psczCommandLine, wzAdditionalCommandLineArguments, 0); 1027 hr = StrAllocConcat(psczCommandLine, pCommand->wzCommandLine, 0);
1031 ExitOnFailure(hr, "Failed to append command-line to command-line."); 1028 ExitOnFailure(hr, "Failed to append command-line to command-line.");
1032 } 1029 }
1033 1030
@@ -1171,33 +1168,20 @@ LExit:
1171} 1168}
1172 1169
1173extern "C" HRESULT CoreParseCommandLine( 1170extern "C" HRESULT CoreParseCommandLine(
1174 __in int argc, 1171 __in BURN_ENGINE_COMMAND* pInternalCommand,
1175 __in LPWSTR* argv,
1176 __in BOOTSTRAPPER_COMMAND* pCommand, 1172 __in BOOTSTRAPPER_COMMAND* pCommand,
1177 __in BURN_PIPE_CONNECTION* pCompanionConnection, 1173 __in BURN_PIPE_CONNECTION* pCompanionConnection,
1178 __in BURN_PIPE_CONNECTION* pEmbeddedConnection, 1174 __in BURN_PIPE_CONNECTION* pEmbeddedConnection,
1179 __inout BURN_MODE* pMode,
1180 __inout BURN_AU_PAUSE_ACTION* pAutomaticUpdates,
1181 __inout BOOL* pfDisableSystemRestore,
1182 __inout_z LPWSTR* psczSourceProcessPath,
1183 __inout_z LPWSTR* psczOriginalSource,
1184 __inout HANDLE* phSectionFile, 1175 __inout HANDLE* phSectionFile,
1185 __inout HANDLE* phSourceEngineFile, 1176 __inout HANDLE* phSourceEngineFile
1186 __inout BOOL* pfDisableUnelevate,
1187 __inout DWORD* pdwLoggingAttributes,
1188 __inout_z LPWSTR* psczLogFile,
1189 __inout_z LPWSTR* psczActiveParent,
1190 __inout_z LPWSTR* psczIgnoreDependencies,
1191 __inout_z LPWSTR* psczAncestors,
1192 __inout BOOL* pfInvalidCommandLine,
1193 __inout DWORD* pcUnknownArgs,
1194 __inout int** prgUnknownArgs
1195 ) 1177 )
1196{ 1178{
1197 HRESULT hr = S_OK; 1179 HRESULT hr = S_OK;
1198 BOOL fUnknownArg = FALSE; 1180 BOOL fUnknownArg = FALSE;
1199 BOOL fInvalidCommandLine = FALSE; 1181 BOOL fInvalidCommandLine = FALSE;
1200 DWORD64 qw = 0; 1182 DWORD64 qw = 0;
1183 int argc = pInternalCommand->argc;
1184 LPWSTR* argv = pInternalCommand->argv;
1201 1185
1202 for (int i = 0; i < argc; ++i) 1186 for (int i = 0; i < argc; ++i)
1203 { 1187 {
@@ -1209,11 +1193,11 @@ extern "C" HRESULT CoreParseCommandLine(
1209 CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"log", -1) || 1193 CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"log", -1) ||
1210 CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"xlog", -1)) 1194 CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"xlog", -1))
1211 { 1195 {
1212 *pdwLoggingAttributes &= ~BURN_LOGGING_ATTRIBUTE_APPEND; 1196 pInternalCommand->dwLoggingAttributes &= ~BURN_LOGGING_ATTRIBUTE_APPEND;
1213 1197
1214 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], 1, L"x", 1)) 1198 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], 1, L"x", 1))
1215 { 1199 {
1216 *pdwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE | BURN_LOGGING_ATTRIBUTE_EXTRADEBUG; 1200 pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE | BURN_LOGGING_ATTRIBUTE_EXTRADEBUG;
1217 } 1201 }
1218 1202
1219 if (i + 1 >= argc) 1203 if (i + 1 >= argc)
@@ -1224,7 +1208,7 @@ extern "C" HRESULT CoreParseCommandLine(
1224 1208
1225 ++i; 1209 ++i;
1226 1210
1227 hr = StrAllocString(psczLogFile, argv[i], 0); 1211 hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0);
1228 ExitOnFailure(hr, "Failed to copy log file path."); 1212 ExitOnFailure(hr, "Failed to copy log file path.");
1229 } 1213 }
1230 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"?", -1) || 1214 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"?", -1) ||
@@ -1291,19 +1275,19 @@ extern "C" HRESULT CoreParseCommandLine(
1291 } 1275 }
1292 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"noaupause", -1)) 1276 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"noaupause", -1))
1293 { 1277 {
1294 *pAutomaticUpdates = BURN_AU_PAUSE_ACTION_NONE; 1278 pInternalCommand->automaticUpdates = BURN_AU_PAUSE_ACTION_NONE;
1295 } 1279 }
1296 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"keepaupaused", -1)) 1280 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"keepaupaused", -1))
1297 { 1281 {
1298 // Switch /noaupause takes precedence. 1282 // Switch /noaupause takes precedence.
1299 if (BURN_AU_PAUSE_ACTION_NONE != *pAutomaticUpdates) 1283 if (BURN_AU_PAUSE_ACTION_NONE != pInternalCommand->automaticUpdates)
1300 { 1284 {
1301 *pAutomaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME; 1285 pInternalCommand->automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME;
1302 } 1286 }
1303 } 1287 }
1304 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"disablesystemrestore", -1)) 1288 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"disablesystemrestore", -1))
1305 { 1289 {
1306 *pfDisableSystemRestore = TRUE; 1290 pInternalCommand->fDisableSystemRestore = TRUE;
1307 } 1291 }
1308 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"originalsource", -1)) 1292 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"originalsource", -1))
1309 { 1293 {
@@ -1314,7 +1298,7 @@ extern "C" HRESULT CoreParseCommandLine(
1314 } 1298 }
1315 1299
1316 ++i; 1300 ++i;
1317 hr = StrAllocString(psczOriginalSource, argv[i], 0); 1301 hr = StrAllocString(&pInternalCommand->sczOriginalSource, argv[i], 0);
1318 ExitOnFailure(hr, "Failed to copy last used source."); 1302 ExitOnFailure(hr, "Failed to copy last used source.");
1319 } 1303 }
1320 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT, -1)) 1304 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(
1327 1311
1328 ++i; 1312 ++i;
1329 1313
1330 hr = StrAllocString(psczActiveParent, argv[i], 0); 1314 hr = StrAllocString(&pInternalCommand->sczActiveParent, argv[i], 0);
1331 ExitOnFailure(hr, "Failed to copy parent."); 1315 ExitOnFailure(hr, "Failed to copy parent.");
1332 } 1316 }
1333 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT_NONE, -1)) 1317 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT_NONE, -1))
1334 { 1318 {
1335 hr = StrAllocString(psczActiveParent, L"", 0); 1319 hr = StrAllocString(&pInternalCommand->sczActiveParent, L"", 0);
1336 ExitOnFailure(hr, "Failed to initialize parent to none."); 1320 ExitOnFailure(hr, "Failed to initialize parent to none.");
1337 } 1321 }
1338 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_LOG_APPEND, -1)) 1322 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(
1345 1329
1346 ++i; 1330 ++i;
1347 1331
1348 hr = StrAllocString(psczLogFile, argv[i], 0); 1332 hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0);
1349 ExitOnFailure(hr, "Failed to copy append log file path."); 1333 ExitOnFailure(hr, "Failed to copy append log file path.");
1350 1334
1351 *pdwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND; 1335 pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND;
1352 } 1336 }
1353 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_ELEVATED, -1)) 1337 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_ELEVATED, -1))
1354 { 1338 {
@@ -1358,13 +1342,13 @@ extern "C" HRESULT CoreParseCommandLine(
1358 ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the elevated name, token and parent process id."); 1342 ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the elevated name, token and parent process id.");
1359 } 1343 }
1360 1344
1361 if (BURN_MODE_UNTRUSTED != *pMode) 1345 if (BURN_MODE_UNTRUSTED != pInternalCommand->mode)
1362 { 1346 {
1363 fInvalidCommandLine = TRUE; 1347 fInvalidCommandLine = TRUE;
1364 TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided."); 1348 TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
1365 } 1349 }
1366 1350
1367 *pMode = BURN_MODE_ELEVATED; 1351 pInternalCommand->mode = BURN_MODE_ELEVATED;
1368 1352
1369 ++i; 1353 ++i;
1370 1354
@@ -1380,9 +1364,9 @@ extern "C" HRESULT CoreParseCommandLine(
1380 } 1364 }
1381 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))) 1365 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)))
1382 { 1366 {
1383 if (BURN_MODE_UNTRUSTED == *pMode) 1367 if (BURN_MODE_UNTRUSTED == pInternalCommand->mode)
1384 { 1368 {
1385 *pMode = BURN_MODE_NORMAL; 1369 pInternalCommand->mode = BURN_MODE_NORMAL;
1386 } 1370 }
1387 else 1371 else
1388 { 1372 {
@@ -1401,7 +1385,7 @@ extern "C" HRESULT CoreParseCommandLine(
1401 } 1385 }
1402 else if (L'\0' != wzParam[1]) 1386 else if (L'\0' != wzParam[1])
1403 { 1387 {
1404 hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0); 1388 hr = StrAllocString(&pInternalCommand->sczSourceProcessPath, wzParam + 1, 0);
1405 ExitOnFailure(hr, "Failed to copy source process path."); 1389 ExitOnFailure(hr, "Failed to copy source process path.");
1406 } 1390 }
1407 } 1391 }
@@ -1414,7 +1398,7 @@ extern "C" HRESULT CoreParseCommandLine(
1414 ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the embedded name, token and parent process id."); 1398 ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the embedded name, token and parent process id.");
1415 } 1399 }
1416 1400
1417 switch (*pMode) 1401 switch (pInternalCommand->mode)
1418 { 1402 {
1419 case BURN_MODE_UNTRUSTED: 1403 case BURN_MODE_UNTRUSTED:
1420 // Leave mode as UNTRUSTED to launch the clean room process. 1404 // Leave mode as UNTRUSTED to launch the clean room process.
@@ -1423,7 +1407,7 @@ extern "C" HRESULT CoreParseCommandLine(
1423 // The initialization code already assumes that the 1407 // The initialization code already assumes that the
1424 // clean room switch is at the beginning of the command line, 1408 // clean room switch is at the beginning of the command line,
1425 // so it's safe to assume that the mode is NORMAL in the clean room. 1409 // so it's safe to assume that the mode is NORMAL in the clean room.
1426 *pMode = BURN_MODE_EMBEDDED; 1410 pInternalCommand->mode = BURN_MODE_EMBEDDED;
1427 break; 1411 break;
1428 default: 1412 default:
1429 fInvalidCommandLine = TRUE; 1413 fInvalidCommandLine = TRUE;
@@ -1478,17 +1462,17 @@ extern "C" HRESULT CoreParseCommandLine(
1478 } 1462 }
1479 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_DISABLE_UNELEVATE, -1)) 1463 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_DISABLE_UNELEVATE, -1))
1480 { 1464 {
1481 *pfDisableUnelevate = TRUE; 1465 pInternalCommand->fDisableUnelevate = TRUE;
1482 } 1466 }
1483 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1)) 1467 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1))
1484 { 1468 {
1485 if (BURN_MODE_UNTRUSTED != *pMode) 1469 if (BURN_MODE_UNTRUSTED != pInternalCommand->mode)
1486 { 1470 {
1487 fInvalidCommandLine = TRUE; 1471 fInvalidCommandLine = TRUE;
1488 TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided."); 1472 TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
1489 } 1473 }
1490 1474
1491 *pMode = BURN_MODE_RUNONCE; 1475 pInternalCommand->mode = BURN_MODE_RUNONCE;
1492 } 1476 }
1493 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))) 1477 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)))
1494 { 1478 {
@@ -1501,7 +1485,7 @@ extern "C" HRESULT CoreParseCommandLine(
1501 } 1485 }
1502 else 1486 else
1503 { 1487 {
1504 hr = StrAllocString(psczIgnoreDependencies, &wzParam[1], 0); 1488 hr = StrAllocString(&pInternalCommand->sczIgnoreDependencies, &wzParam[1], 0);
1505 ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore."); 1489 ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore.");
1506 } 1490 }
1507 } 1491 }
@@ -1516,7 +1500,7 @@ extern "C" HRESULT CoreParseCommandLine(
1516 } 1500 }
1517 else 1501 else
1518 { 1502 {
1519 hr = StrAllocString(psczAncestors, &wzParam[1], 0); 1503 hr = StrAllocString(&pInternalCommand->sczAncestors, &wzParam[1], 0);
1520 ExitOnFailure(hr, "Failed to allocate the list of ancestors."); 1504 ExitOnFailure(hr, "Failed to allocate the list of ancestors.");
1521 } 1505 }
1522 } 1506 }
@@ -1604,18 +1588,21 @@ extern "C" HRESULT CoreParseCommandLine(
1604 1588
1605 if (fUnknownArg) 1589 if (fUnknownArg)
1606 { 1590 {
1607 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgUnknownArgs), *pcUnknownArgs, 1, sizeof(int), 5); 1591 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(&pInternalCommand->rgUnknownArgs), pInternalCommand->cUnknownArgs, 1, sizeof(int), 5);
1608 ExitOnFailure(hr, "Failed to ensure size for unknown args."); 1592 ExitOnFailure(hr, "Failed to ensure size for unknown args.");
1609 1593
1610 (*prgUnknownArgs)[*pcUnknownArgs] = i; 1594 pInternalCommand->rgUnknownArgs[pInternalCommand->cUnknownArgs] = i;
1611 *pcUnknownArgs += 1; 1595 pInternalCommand->cUnknownArgs += 1;
1612 } 1596 }
1613 } 1597 }
1614 1598
1615 // If embedded, ensure the display goes embedded as well. 1599 if (BURN_MODE_EMBEDDED == pInternalCommand->mode)
1616 if (BURN_MODE_EMBEDDED == *pMode)
1617 { 1600 {
1601 // Ensure the display goes embedded as well.
1618 pCommand->display = BOOTSTRAPPER_DISPLAY_EMBEDDED; 1602 pCommand->display = BOOTSTRAPPER_DISPLAY_EMBEDDED;
1603
1604 // Disable system restore since the parent bundle may have done it.
1605 pInternalCommand->fDisableSystemRestore = TRUE;
1619 } 1606 }
1620 1607
1621 // Set the defaults if nothing was set above. 1608 // Set the defaults if nothing was set above.
@@ -1633,7 +1620,7 @@ LExit:
1633 if (fInvalidCommandLine) 1620 if (fInvalidCommandLine)
1634 { 1621 {
1635 hr = S_OK; 1622 hr = S_OK;
1636 *pfInvalidCommandLine = TRUE; 1623 pInternalCommand->fInvalidCommandLine = TRUE;
1637 } 1624 }
1638 1625
1639 return hr; 1626 return hr;
@@ -1642,12 +1629,9 @@ LExit:
1642// internal helper functions 1629// internal helper functions
1643 1630
1644static HRESULT GetSanitizedCommandLine( 1631static HRESULT GetSanitizedCommandLine(
1645 __in int argc, 1632 __in BURN_ENGINE_COMMAND* pInternalCommand,
1646 __in LPWSTR* argv,
1647 __in BOOTSTRAPPER_COMMAND* pCommand, 1633 __in BOOTSTRAPPER_COMMAND* pCommand,
1648 __in BURN_VARIABLES* pVariables, 1634 __in BURN_VARIABLES* pVariables,
1649 __in DWORD cUnknownArgs,
1650 __in int* rgUnknownArgs,
1651 __inout_z LPWSTR* psczSanitizedCommandLine 1635 __inout_z LPWSTR* psczSanitizedCommandLine
1652 ) 1636 )
1653{ 1637{
@@ -1656,6 +1640,10 @@ static HRESULT GetSanitizedCommandLine(
1656 BOOL fHidden = FALSE; 1640 BOOL fHidden = FALSE;
1657 LPWSTR sczSanitizedArgument = NULL; 1641 LPWSTR sczSanitizedArgument = NULL;
1658 LPWSTR sczVariableName = NULL; 1642 LPWSTR sczVariableName = NULL;
1643 int argc = pInternalCommand->argc;
1644 LPWSTR* argv = pInternalCommand->argv;
1645 DWORD cUnknownArgs = pInternalCommand->cUnknownArgs;
1646 int* rgUnknownArgs = pInternalCommand->rgUnknownArgs;
1659 1647
1660 for (int i = 0; i < argc; ++i) 1648 for (int i = 0; i < argc; ++i)
1661 { 1649 {
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
80 80
81typedef struct _BURN_ENGINE_COMMAND 81typedef struct _BURN_ENGINE_COMMAND
82{ 82{
83 int argc;
84 LPWSTR* argv;
85 DWORD cUnknownArgs;
86 int* rgUnknownArgs;
87 BOOL fInvalidCommandLine;
88
89 BURN_MODE mode;
90 BURN_AU_PAUSE_ACTION automaticUpdates;
91 BOOL fDisableSystemRestore;
92 BOOL fDisableUnelevate;
83 BOOL fInitiallyElevated; 93 BOOL fInitiallyElevated;
84 94
85 LPWSTR sczActiveParent; 95 LPWSTR sczActiveParent;
96 LPWSTR sczAncestors;
86 LPWSTR sczIgnoreDependencies; 97 LPWSTR sczIgnoreDependencies;
87 98
88 LPWSTR sczSourceProcessPath; 99 LPWSTR sczSourceProcessPath;
89 LPWSTR sczOriginalSource; 100 LPWSTR sczOriginalSource;
101
102 DWORD dwLoggingAttributes;
103 LPWSTR sczLogFile;
90} BURN_ENGINE_COMMAND; 104} BURN_ENGINE_COMMAND;
91 105
92typedef struct _BURN_ENGINE_STATE 106typedef struct _BURN_ENGINE_STATE
@@ -122,7 +136,6 @@ typedef struct _BURN_ENGINE_STATE
122 HANDLE hMessageWindowThread; 136 HANDLE hMessageWindowThread;
123 137
124 BOOL fDisableRollback; 138 BOOL fDisableRollback;
125 BOOL fDisableSystemRestore;
126 BOOL fParallelCacheAndExecute; 139 BOOL fParallelCacheAndExecute;
127 140
128 BURN_LOGGING log; 141 BURN_LOGGING log;
@@ -131,9 +144,6 @@ typedef struct _BURN_ENGINE_STATE
131 144
132 BURN_PLAN plan; 145 BURN_PLAN plan;
133 146
134 BURN_MODE mode;
135 BURN_AU_PAUSE_ACTION automaticUpdates;
136
137 DWORD dwElevatedLoggingTlsId; 147 DWORD dwElevatedLoggingTlsId;
138 148
139 LPWSTR sczBundleEngineWorkingPath; 149 LPWSTR sczBundleEngineWorkingPath;
@@ -141,14 +151,8 @@ typedef struct _BURN_ENGINE_STATE
141 BURN_PIPE_CONNECTION embeddedConnection; 151 BURN_PIPE_CONNECTION embeddedConnection;
142 152
143 BURN_RESUME_MODE resumeMode; 153 BURN_RESUME_MODE resumeMode;
144 BOOL fDisableUnelevate;
145 154
146 int argc;
147 LPWSTR* argv;
148 BOOL fInvalidCommandLine;
149 BURN_ENGINE_COMMAND internalCommand; 155 BURN_ENGINE_COMMAND internalCommand;
150 DWORD cUnknownArgs;
151 int* rgUnknownArgs;
152} BURN_ENGINE_STATE; 156} BURN_ENGINE_STATE;
153 157
154typedef struct _BURN_APPLY_CONTEXT 158typedef struct _BURN_APPLY_CONTEXT
@@ -218,9 +222,7 @@ HRESULT CoreRecreateCommandLine(
218 __in BOOTSTRAPPER_COMMAND* pCommand, 222 __in BOOTSTRAPPER_COMMAND* pCommand,
219 __in BOOTSTRAPPER_RELATION_TYPE relationType, 223 __in BOOTSTRAPPER_RELATION_TYPE relationType,
220 __in BOOL fPassthrough, 224 __in BOOL fPassthrough,
221 __in_z_opt LPCWSTR wzAncestors, 225 __in_z_opt LPCWSTR wzAppendLogPath
222 __in_z_opt LPCWSTR wzAppendLogPath,
223 __in_z_opt LPCWSTR wzAdditionalCommandLineArguments
224 ); 226 );
225HRESULT CoreAppendFileHandleAttachedToCommandLine( 227HRESULT CoreAppendFileHandleAttachedToCommandLine(
226 __in HANDLE hFileWithAttachedContainer, 228 __in HANDLE hFileWithAttachedContainer,
@@ -241,27 +243,12 @@ void CoreCleanup(
241 __in BURN_ENGINE_STATE* pEngineState 243 __in BURN_ENGINE_STATE* pEngineState
242 ); 244 );
243HRESULT CoreParseCommandLine( 245HRESULT CoreParseCommandLine(
244 __in int argc, 246 __in BURN_ENGINE_COMMAND* pInternalCommand,
245 __in LPWSTR* argv,
246 __in BOOTSTRAPPER_COMMAND* pCommand, 247 __in BOOTSTRAPPER_COMMAND* pCommand,
247 __in BURN_PIPE_CONNECTION* pCompanionConnection, 248 __in BURN_PIPE_CONNECTION* pCompanionConnection,
248 __in BURN_PIPE_CONNECTION* pEmbeddedConnection, 249 __in BURN_PIPE_CONNECTION* pEmbeddedConnection,
249 __inout BURN_MODE* pMode,
250 __inout BURN_AU_PAUSE_ACTION* pAutomaticUpdates,
251 __inout BOOL* pfDisableSystemRestore,
252 __inout_z LPWSTR* psczSourceProcessPath,
253 __inout_z LPWSTR* psczOriginalSource,
254 __inout HANDLE* phSectionFile, 250 __inout HANDLE* phSectionFile,
255 __inout HANDLE* phSourceEngineFile, 251 __inout HANDLE* phSourceEngineFile
256 __inout BOOL* pfDisableUnelevate,
257 __inout DWORD* pdwLoggingAttributes,
258 __inout_z LPWSTR* psczLogFile,
259 __inout_z LPWSTR* psczActiveParent,
260 __inout_z LPWSTR* psczIgnoreDependencies,
261 __inout_z LPWSTR* psczAncestors,
262 __inout BOOL* pfInvalidCommandLine,
263 __inout DWORD* pcUnknownArgs,
264 __inout int** prgUnknownArgs
265 ); 252 );
266 253
267#if defined(__cplusplus) 254#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(
339 __in_opt HWND hwndParent 339 __in_opt HWND hwndParent
340 ) 340 )
341{ 341{
342 Assert(BURN_MODE_ELEVATED != pEngineState->mode); 342 Assert(BURN_MODE_ELEVATED != pEngineState->internalCommand.mode);
343 Assert(!pEngineState->companionConnection.sczName); 343 Assert(!pEngineState->companionConnection.sczName);
344 Assert(!pEngineState->companionConnection.sczSecret); 344 Assert(!pEngineState->companionConnection.sczSecret);
345 Assert(!pEngineState->companionConnection.hProcess); 345 Assert(!pEngineState->companionConnection.hProcess);
@@ -407,9 +407,7 @@ extern "C" HRESULT ElevationApplyInitialize(
407 __in HANDLE hPipe, 407 __in HANDLE hPipe,
408 __in BURN_USER_EXPERIENCE* pBA, 408 __in BURN_USER_EXPERIENCE* pBA,
409 __in BURN_VARIABLES* pVariables, 409 __in BURN_VARIABLES* pVariables,
410 __in BOOTSTRAPPER_ACTION action, 410 __in BURN_PLAN* pPlan
411 __in BURN_AU_PAUSE_ACTION auAction,
412 __in BOOL fTakeSystemRestorePoint
413 ) 411 )
414{ 412{
415 HRESULT hr = S_OK; 413 HRESULT hr = S_OK;
@@ -421,13 +419,13 @@ extern "C" HRESULT ElevationApplyInitialize(
421 context.pBA = pBA; 419 context.pBA = pBA;
422 420
423 // serialize message data 421 // serialize message data
424 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)action); 422 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pPlan->action);
425 ExitOnFailure(hr, "Failed to write action to message buffer."); 423 ExitOnFailure(hr, "Failed to write action to message buffer.");
426 424
427 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)auAction); 425 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pPlan->pInternalCommand->automaticUpdates);
428 ExitOnFailure(hr, "Failed to write update action to message buffer."); 426 ExitOnFailure(hr, "Failed to write update action to message buffer.");
429 427
430 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)fTakeSystemRestorePoint); 428 hr = BuffWriteNumber(&pbData, &cbData, (DWORD)!pPlan->pInternalCommand->fDisableSystemRestore);
431 ExitOnFailure(hr, "Failed to write system restore point action to message buffer."); 429 ExitOnFailure(hr, "Failed to write system restore point action to message buffer.");
432 430
433 hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData); 431 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(
16 __in HANDLE hPipe, 16 __in HANDLE hPipe,
17 __in BURN_USER_EXPERIENCE* pBA, 17 __in BURN_USER_EXPERIENCE* pBA,
18 __in BURN_VARIABLES* pVariables, 18 __in BURN_VARIABLES* pVariables,
19 __in BOOTSTRAPPER_ACTION action, 19 __in BURN_PLAN* pPlan
20 __in BURN_AU_PAUSE_ACTION auAction,
21 __in BOOL fTakeSystemRestorePoint
22 ); 20 );
23HRESULT ElevationApplyUninitialize( 21HRESULT ElevationApplyUninitialize(
24 __in HANDLE hPipe 22 __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(
113 LogSetLevel(REPORT_VERBOSE, FALSE); // FALSE means don't write an additional text line to the log saying the level changed 113 LogSetLevel(REPORT_VERBOSE, FALSE); // FALSE means don't write an additional text line to the log saying the level changed
114#endif 114#endif
115 115
116 hr = AppParseCommandLine(wzCommandLine, &engineState.argc, &engineState.argv); 116 hr = AppParseCommandLine(wzCommandLine, &engineState.internalCommand.argc, &engineState.internalCommand.argv);
117 ExitOnFailure(hr, "Failed to parse command line."); 117 ExitOnFailure(hr, "Failed to parse command line.");
118 118
119 hr = InitializeEngineState(&engineState, hEngineFile); 119 hr = InitializeEngineState(&engineState, hEngineFile);
@@ -121,7 +121,7 @@ extern "C" HRESULT EngineRun(
121 121
122 engineState.command.nCmdShow = nCmdShow; 122 engineState.command.nCmdShow = nCmdShow;
123 123
124 if (BURN_MODE_ELEVATED != engineState.mode && BOOTSTRAPPER_DISPLAY_NONE < engineState.command.display && !engineState.command.hwndSplashScreen) 124 if (BURN_MODE_ELEVATED != engineState.internalCommand.mode && BOOTSTRAPPER_DISPLAY_NONE < engineState.command.display && !engineState.command.hwndSplashScreen)
125 { 125 {
126 SplashScreenCreate(hInstance, NULL, &engineState.command.hwndSplashScreen); 126 SplashScreenCreate(hInstance, NULL, &engineState.command.hwndSplashScreen);
127 } 127 }
@@ -192,7 +192,7 @@ extern "C" HRESULT EngineRun(
192 ExitOnFailure(hr, "Failed to initialize core."); 192 ExitOnFailure(hr, "Failed to initialize core.");
193 193
194 // Select run mode. 194 // Select run mode.
195 switch (engineState.mode) 195 switch (engineState.internalCommand.mode)
196 { 196 {
197 case BURN_MODE_UNTRUSTED: 197 case BURN_MODE_UNTRUSTED:
198 hr = RunUntrusted(wzCommandLine, &engineState); 198 hr = RunUntrusted(wzCommandLine, &engineState);
@@ -328,7 +328,7 @@ static HRESULT InitializeEngineState(
328 HANDLE hSectionFile = hEngineFile; 328 HANDLE hSectionFile = hEngineFile;
329 HANDLE hSourceEngineFile = INVALID_HANDLE_VALUE; 329 HANDLE hSourceEngineFile = INVALID_HANDLE_VALUE;
330 330
331 pEngineState->automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED; 331 pEngineState->internalCommand.automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED;
332 pEngineState->dwElevatedLoggingTlsId = TLS_OUT_OF_INDEXES; 332 pEngineState->dwElevatedLoggingTlsId = TLS_OUT_OF_INDEXES;
333 ::InitializeCriticalSection(&pEngineState->userExperience.csEngineActive); 333 ::InitializeCriticalSection(&pEngineState->userExperience.csEngineActive);
334 PipeConnectionInitialize(&pEngineState->companionConnection); 334 PipeConnectionInitialize(&pEngineState->companionConnection);
@@ -338,7 +338,7 @@ static HRESULT InitializeEngineState(
338 ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated); 338 ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated);
339 339
340 // Parse command line. 340 // Parse command line.
341 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); 341 hr = CoreParseCommandLine(&pEngineState->internalCommand, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &hSectionFile, &hSourceEngineFile);
342 ExitOnFailure(hr, "Fatal error while parsing command line."); 342 ExitOnFailure(hr, "Fatal error while parsing command line.");
343 343
344 hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile); 344 hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile);
@@ -355,12 +355,12 @@ static void UninitializeEngineState(
355 __in BURN_ENGINE_STATE* pEngineState 355 __in BURN_ENGINE_STATE* pEngineState
356 ) 356 )
357{ 357{
358 if (pEngineState->argv) 358 if (pEngineState->internalCommand.argv)
359 { 359 {
360 AppFreeCommandLineArgs(pEngineState->argv); 360 AppFreeCommandLineArgs(pEngineState->internalCommand.argv);
361 } 361 }
362 362
363 ReleaseMem(pEngineState->rgUnknownArgs); 363 ReleaseMem(pEngineState->internalCommand.rgUnknownArgs);
364 364
365 PipeConnectionUninitialize(&pEngineState->embeddedConnection); 365 PipeConnectionUninitialize(&pEngineState->embeddedConnection);
366 PipeConnectionUninitialize(&pEngineState->companionConnection); 366 PipeConnectionUninitialize(&pEngineState->companionConnection);
@@ -390,7 +390,9 @@ static void UninitializeEngineState(
390 ReleaseStr(pEngineState->command.wzCommandLine); 390 ReleaseStr(pEngineState->command.wzCommandLine);
391 391
392 ReleaseStr(pEngineState->internalCommand.sczActiveParent); 392 ReleaseStr(pEngineState->internalCommand.sczActiveParent);
393 ReleaseStr(pEngineState->internalCommand.sczAncestors);
393 ReleaseStr(pEngineState->internalCommand.sczIgnoreDependencies); 394 ReleaseStr(pEngineState->internalCommand.sczIgnoreDependencies);
395 ReleaseStr(pEngineState->internalCommand.sczLogFile);
394 ReleaseStr(pEngineState->internalCommand.sczOriginalSource); 396 ReleaseStr(pEngineState->internalCommand.sczOriginalSource);
395 ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath); 397 ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath);
396 398
@@ -469,7 +471,7 @@ static HRESULT RunUntrusted(
469 471
470#ifdef ENABLE_UNELEVATE 472#ifdef ENABLE_UNELEVATE
471 // TODO: Pass file handle to unelevated process if this ever gets reenabled. 473 // TODO: Pass file handle to unelevated process if this ever gets reenabled.
472 if (!pEngineState->fDisableUnelevate) 474 if (!pEngineState->internalCommand.fDisableUnelevate)
473 { 475 {
474 // Try to launch unelevated and if that fails for any reason, we'll launch our process normally (even though that may make it elevated). 476 // Try to launch unelevated and if that fails for any reason, we'll launch our process normally (even though that may make it elevated).
475 hr = ProcExecuteAsInteractiveUser(wzCleanRoomBundlePath, sczParameters, &hProcess); 477 hr = ProcExecuteAsInteractiveUser(wzCleanRoomBundlePath, sczParameters, &hProcess);
@@ -522,7 +524,7 @@ static HRESULT RunNormal(
522 BURN_EXTENSION_ENGINE_CONTEXT extensionEngineContext = { }; 524 BURN_EXTENSION_ENGINE_CONTEXT extensionEngineContext = { };
523 525
524 // Initialize logging. 526 // Initialize logging.
525 hr = LoggingOpen(&pEngineState->log, &pEngineState->variables, pEngineState->command.display, pEngineState->registration.sczDisplayName); 527 hr = LoggingOpen(&pEngineState->log, &pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, pEngineState->registration.sczDisplayName);
526 ExitOnFailure(hr, "Failed to open log."); 528 ExitOnFailure(hr, "Failed to open log.");
527 529
528 // Ensure we're on a supported operating system. 530 // Ensure we're on a supported operating system.
@@ -694,9 +696,6 @@ static HRESULT RunEmbedded(
694{ 696{
695 HRESULT hr = S_OK; 697 HRESULT hr = S_OK;
696 698
697 // Disable system restore since the parent bundle may have done it.
698 pEngineState->fDisableSystemRestore = TRUE;
699
700 // Connect to parent process. 699 // Connect to parent process.
701 hr = PipeChildConnect(&pEngineState->embeddedConnection, FALSE); 700 hr = PipeChildConnect(&pEngineState->embeddedConnection, FALSE);
702 ExitOnFailure(hr, "Failed to connect to parent of embedded process."); 701 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(
197 SIZE_T cbData = 0; 197 SIZE_T cbData = 0;
198 DWORD dwResult = *pnResult = 0; 198 DWORD dwResult = *pnResult = 0;
199 199
200 if (BURN_MODE_EMBEDDED != pEngineState->mode) 200 if (BURN_MODE_EMBEDDED != pEngineState->internalCommand.mode)
201 { 201 {
202 hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE); 202 hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE);
203 ExitOnRootFailure(hr, "BA requested to send embedded message when not in embedded mode."); 203 ExitOnRootFailure(hr, "BA requested to send embedded message when not in embedded mode.");
@@ -235,7 +235,7 @@ HRESULT ExternalEngineSendEmbeddedProgress(
235 SIZE_T cbData = 0; 235 SIZE_T cbData = 0;
236 DWORD dwResult = *pnResult = 0; 236 DWORD dwResult = *pnResult = 0;
237 237
238 if (BURN_MODE_EMBEDDED != pEngineState->mode) 238 if (BURN_MODE_EMBEDDED != pEngineState->internalCommand.mode)
239 { 239 {
240 hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE); 240 hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE);
241 ExitOnRootFailure(hr, "BA requested to send embedded progress message when not in embedded mode."); 241 ExitOnRootFailure(hr, "BA requested to send embedded progress message when not in embedded mode.");
@@ -295,7 +295,7 @@ HRESULT ExternalEngineSetUpdate(
295 { 295 {
296 UpdateUninitialize(&pEngineState->update); 296 UpdateUninitialize(&pEngineState->update);
297 297
298 hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, &pEngineState->internalCommand, &pEngineState->command, BOOTSTRAPPER_RELATION_NONE, FALSE, pEngineState->registration.sczAncestors, NULL, pEngineState->command.wzCommandLine); 298 hr = CoreRecreateCommandLine(&sczCommandline, BOOTSTRAPPER_ACTION_INSTALL, &pEngineState->internalCommand, &pEngineState->command, BOOTSTRAPPER_RELATION_NONE, FALSE, NULL);
299 ExitOnFailure(hr, "Failed to recreate command-line for update bundle."); 299 ExitOnFailure(hr, "Failed to recreate command-line for update bundle.");
300 300
301 // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths. 301 // 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
15// internal function declarations 15// internal function declarations
16 16
17static void CheckLoggingPolicy( 17static void CheckLoggingPolicy(
18 __out DWORD *pdwAttributes 18 __inout DWORD* pdwAttributes
19 );
20static HRESULT InitializeLogging(
21 __in BURN_LOGGING* pLog,
22 __in BURN_ENGINE_COMMAND* pInternalCommand
19 ); 23 );
20static HRESULT GetNonSessionSpecificTempFolder( 24static HRESULT GetNonSessionSpecificTempFolder(
21 __deref_out_z LPWSTR* psczNonSessionTempFolder 25 __deref_out_z LPWSTR* psczNonSessionTempFolder
@@ -26,8 +30,9 @@ static HRESULT GetNonSessionSpecificTempFolder(
26 30
27extern "C" HRESULT LoggingOpen( 31extern "C" HRESULT LoggingOpen(
28 __in BURN_LOGGING* pLog, 32 __in BURN_LOGGING* pLog,
33 __in BURN_ENGINE_COMMAND* pInternalCommand,
34 __in BOOTSTRAPPER_COMMAND* pCommand,
29 __in BURN_VARIABLES* pVariables, 35 __in BURN_VARIABLES* pVariables,
30 __in BOOTSTRAPPER_DISPLAY display,
31 __in_z LPCWSTR wzBundleName 36 __in_z LPCWSTR wzBundleName
32 ) 37 )
33{ 38{
@@ -35,8 +40,8 @@ extern "C" HRESULT LoggingOpen(
35 LPWSTR sczLoggingBaseFolder = NULL; 40 LPWSTR sczLoggingBaseFolder = NULL;
36 LPWSTR sczPrefixFormatted = NULL; 41 LPWSTR sczPrefixFormatted = NULL;
37 42
38 // Check if the logging policy is set and configure the logging appropriately. 43 hr = InitializeLogging(pLog, pInternalCommand);
39 CheckLoggingPolicy(&pLog->dwAttributes); 44 ExitOnFailure(hr, "Failed to initialize logging.");
40 45
41 if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_VERBOSE || pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG) 46 if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_VERBOSE || pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG)
42 { 47 {
@@ -94,7 +99,7 @@ extern "C" HRESULT LoggingOpen(
94 HRESULT hrOriginal = hr; 99 HRESULT hrOriginal = hr;
95 100
96 hr = HRESULT_FROM_WIN32(ERROR_INSTALL_LOG_FAILURE); 101 hr = HRESULT_FROM_WIN32(ERROR_INSTALL_LOG_FAILURE);
97 SplashScreenDisplayError(display, wzBundleName, hr); 102 SplashScreenDisplayError(pCommand->display, wzBundleName, hr);
98 103
99 ExitOnFailure(hrOriginal, "Failed to open log: %ls", pLog->sczPath); 104 ExitOnFailure(hrOriginal, "Failed to open log: %ls", pLog->sczPath);
100 } 105 }
@@ -709,7 +714,7 @@ extern "C" LPWSTR LoggingStringOrUnknownIfNull(
709// internal function declarations 714// internal function declarations
710 715
711static void CheckLoggingPolicy( 716static void CheckLoggingPolicy(
712 __out DWORD *pdwAttributes 717 __inout DWORD *pdwAttributes
713 ) 718 )
714{ 719{
715 HRESULT hr = S_OK; 720 HRESULT hr = S_OK;
@@ -743,6 +748,28 @@ static void CheckLoggingPolicy(
743 ReleaseRegKey(hk); 748 ReleaseRegKey(hk);
744} 749}
745 750
751static HRESULT InitializeLogging(
752 __in BURN_LOGGING* pLog,
753 __in BURN_ENGINE_COMMAND* pInternalCommand
754 )
755{
756 HRESULT hr = S_OK;
757
758 // Check if the logging policy is set and configure the logging appropriately.
759 CheckLoggingPolicy(&pLog->dwAttributes);
760
761 pLog->dwAttributes |= pInternalCommand->dwLoggingAttributes;
762
763 if (pInternalCommand->sczLogFile)
764 {
765 hr = StrAllocString(&pLog->sczPath, pInternalCommand->sczLogFile, 0);
766 ExitOnFailure(hr, "Failed to copy log file path from command line.");
767 }
768
769LExit:
770 return hr;
771}
772
746static HRESULT GetNonSessionSpecificTempFolder( 773static HRESULT GetNonSessionSpecificTempFolder(
747 __deref_out_z LPWSTR* psczNonSessionTempFolder 774 __deref_out_z LPWSTR* psczNonSessionTempFolder
748 ) 775 )
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
43 43
44HRESULT LoggingOpen( 44HRESULT LoggingOpen(
45 __in BURN_LOGGING* pLog, 45 __in BURN_LOGGING* pLog,
46 __in BURN_ENGINE_COMMAND* pInternalCommand,
47 __in BOOTSTRAPPER_COMMAND* pCommand,
46 __in BURN_VARIABLES* pVariables, 48 __in BURN_VARIABLES* pVariables,
47 __in BOOTSTRAPPER_DISPLAY display,
48 __in_z LPCWSTR wzBundleName 49 __in_z LPCWSTR wzBundleName
49 ); 50 );
50 51
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(
98 } 98 }
99 99
100 // parse disable system restore 100 // parse disable system restore
101 hr = XmlGetYesNoAttribute(pixnChain, L"DisableSystemRestore", &pEngineState->fDisableSystemRestore); 101 hr = XmlGetYesNoAttribute(pixnChain, L"DisableSystemRestore", &pEngineState->internalCommand.fDisableSystemRestore);
102 if (E_NOTFOUND != hr) 102 if (E_NOTFOUND != hr)
103 { 103 {
104 ExitOnFailure(hr, "Failed to get Chain/@DisableSystemRestore"); 104 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:
428 428
429extern "C" HRESULT PlanForwardCompatibleBundles( 429extern "C" HRESULT PlanForwardCompatibleBundles(
430 __in BURN_USER_EXPERIENCE* pUX, 430 __in BURN_USER_EXPERIENCE* pUX,
431 __in BOOTSTRAPPER_COMMAND* pCommand,
432 __in BURN_PLAN* pPlan, 431 __in BURN_PLAN* pPlan,
433 __in BURN_REGISTRATION* pRegistration, 432 __in BURN_REGISTRATION* pRegistration
434 __in BOOTSTRAPPER_ACTION action
435 ) 433 )
436{ 434{
437 HRESULT hr = S_OK; 435 HRESULT hr = S_OK;
438 BOOL fRecommendIgnore = TRUE; 436 BOOL fRecommendIgnore = TRUE;
439 BOOL fIgnoreBundle = FALSE; 437 BOOL fIgnoreBundle = FALSE;
438 BOOTSTRAPPER_ACTION action = pPlan->action;
440 439
441 if (!pRegistration->fForwardCompatibleBundleExists) 440 if (!pRegistration->fForwardCompatibleBundleExists)
442 { 441 {
@@ -480,7 +479,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles(
480 479
481 if (!fIgnoreBundle) 480 if (!fIgnoreBundle)
482 { 481 {
483 hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pPlan->pInternalCommand, pCommand, NULL, pRegistration->sczAncestors, &pRelatedBundle->package); 482 hr = PseudoBundleInitializePassthrough(&pPlan->forwardCompatibleBundle, pPlan->pInternalCommand, pPlan->pCommand, NULL, &pRelatedBundle->package);
484 ExitOnFailure(hr, "Failed to initialize pass through bundle."); 483 ExitOnFailure(hr, "Failed to initialize pass through bundle.");
485 484
486 pPlan->fEnabledForwardCompatibleBundle = TRUE; 485 pPlan->fEnabledForwardCompatibleBundle = TRUE;
@@ -1239,9 +1238,9 @@ extern "C" HRESULT PlanRelatedBundlesBegin(
1239 UINT cAncestors = 0; 1238 UINT cAncestors = 0;
1240 STRINGDICT_HANDLE sdAncestors = NULL; 1239 STRINGDICT_HANDLE sdAncestors = NULL;
1241 1240
1242 if (pRegistration->sczAncestors) 1241 if (pPlan->pInternalCommand->sczAncestors)
1243 { 1242 {
1244 hr = StrSplitAllocArray(&rgsczAncestors, &cAncestors, pRegistration->sczAncestors, L";"); 1243 hr = StrSplitAllocArray(&rgsczAncestors, &cAncestors, pPlan->pInternalCommand->sczAncestors, L";");
1245 ExitOnFailure(hr, "Failed to create string array from ancestors."); 1244 ExitOnFailure(hr, "Failed to create string array from ancestors.");
1246 1245
1247 hr = DictCreateStringListFromArray(&sdAncestors, rgsczAncestors, cAncestors, DICT_FLAG_CASEINSENSITIVE); 1246 hr = DictCreateStringListFromArray(&sdAncestors, rgsczAncestors, cAncestors, DICT_FLAG_CASEINSENSITIVE);
@@ -1777,14 +1776,14 @@ LExit:
1777extern "C" HRESULT PlanSetResumeCommand( 1776extern "C" HRESULT PlanSetResumeCommand(
1778 __in BURN_PLAN* pPlan, 1777 __in BURN_PLAN* pPlan,
1779 __in BURN_REGISTRATION* pRegistration, 1778 __in BURN_REGISTRATION* pRegistration,
1780 __in BOOTSTRAPPER_COMMAND* pCommand,
1781 __in BURN_LOGGING* pLog 1779 __in BURN_LOGGING* pLog
1782 ) 1780 )
1783{ 1781{
1784 HRESULT hr = S_OK; 1782 HRESULT hr = S_OK;
1783 BOOTSTRAPPER_COMMAND* pCommand = pPlan->pCommand;
1785 1784
1786 // build the resume command-line. 1785 // build the resume command-line.
1787 hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, pPlan->action, pPlan->pInternalCommand, pCommand, pCommand->relationType, pCommand->fPassthrough, pRegistration->sczAncestors, pLog->sczPath, pCommand->wzCommandLine); 1786 hr = CoreRecreateCommandLine(&pRegistration->sczResumeCommandLine, pPlan->action, pPlan->pInternalCommand, pCommand, pCommand->relationType, pCommand->fPassthrough, pLog->sczPath);
1788 ExitOnFailure(hr, "Failed to recreate resume command-line."); 1787 ExitOnFailure(hr, "Failed to recreate resume command-line.");
1789 1788
1790LExit: 1789LExit:
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
230{ 230{
231 BOOTSTRAPPER_ACTION action; 231 BOOTSTRAPPER_ACTION action;
232 BURN_CACHE* pCache; 232 BURN_CACHE* pCache;
233 BOOTSTRAPPER_COMMAND* pCommand;
233 BURN_ENGINE_COMMAND* pInternalCommand; 234 BURN_ENGINE_COMMAND* pInternalCommand;
234 BURN_PAYLOADS* pPayloads; 235 BURN_PAYLOADS* pPayloads;
235 LPWSTR wzBundleId; // points directly into parent the ENGINE_STATE. 236 LPWSTR wzBundleId; // points directly into parent the ENGINE_STATE.
@@ -326,10 +327,8 @@ HRESULT PlanLayoutBundle(
326 ); 327 );
327HRESULT PlanForwardCompatibleBundles( 328HRESULT PlanForwardCompatibleBundles(
328 __in BURN_USER_EXPERIENCE* pUX, 329 __in BURN_USER_EXPERIENCE* pUX,
329 __in BOOTSTRAPPER_COMMAND* pCommand,
330 __in BURN_PLAN* pPlan, 330 __in BURN_PLAN* pPlan,
331 __in BURN_REGISTRATION* pRegistration, 331 __in BURN_REGISTRATION* pRegistration
332 __in BOOTSTRAPPER_ACTION action
333 ); 332 );
334HRESULT PlanPackages( 333HRESULT PlanPackages(
335 __in BURN_USER_EXPERIENCE* pUX, 334 __in BURN_USER_EXPERIENCE* pUX,
@@ -446,7 +445,6 @@ HRESULT PlanRollbackBoundaryComplete(
446HRESULT PlanSetResumeCommand( 445HRESULT PlanSetResumeCommand(
447 __in BURN_PLAN* pPlan, 446 __in BURN_PLAN* pPlan,
448 __in BURN_REGISTRATION* pRegistration, 447 __in BURN_REGISTRATION* pRegistration,
449 __in BOOTSTRAPPER_COMMAND* pCommand,
450 __in BURN_LOGGING* pLog 448 __in BURN_LOGGING* pLog
451 ); 449 );
452void PlanDump( 450void 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(
166 __in BURN_ENGINE_COMMAND* pInternalCommand, 166 __in BURN_ENGINE_COMMAND* pInternalCommand,
167 __in BOOTSTRAPPER_COMMAND* pCommand, 167 __in BOOTSTRAPPER_COMMAND* pCommand,
168 __in_z_opt LPCWSTR wzAppendLogPath, 168 __in_z_opt LPCWSTR wzAppendLogPath,
169 __in_z_opt LPCWSTR wzAncestors,
170 __in BURN_PACKAGE* pPackage 169 __in BURN_PACKAGE* pPackage
171 ) 170 )
172{ 171{
@@ -205,7 +204,7 @@ extern "C" HRESULT PseudoBundleInitializePassthrough(
205 204
206 // No matter the operation, we're passing the same command-line. That's what makes 205 // No matter the operation, we're passing the same command-line. That's what makes
207 // this a passthrough bundle. 206 // this a passthrough bundle.
208 hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pInternalCommand, pCommand, pCommand->relationType, TRUE, wzAncestors, wzAppendLogPath, pCommand->wzCommandLine); 207 hr = CoreRecreateCommandLine(&sczArguments, pCommand->action, pInternalCommand, pCommand, pCommand->relationType, TRUE, wzAppendLogPath);
209 ExitOnFailure(hr, "Failed to recreate command-line arguments."); 208 ExitOnFailure(hr, "Failed to recreate command-line arguments.");
210 209
211 hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0); 210 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(
31 __in BURN_ENGINE_COMMAND* pInternalCommand, 31 __in BURN_ENGINE_COMMAND* pInternalCommand,
32 __in BOOTSTRAPPER_COMMAND* pCommand, 32 __in BOOTSTRAPPER_COMMAND* pCommand,
33 __in_z_opt LPCWSTR wzAppendLogPath, 33 __in_z_opt LPCWSTR wzAppendLogPath,
34 __in_z_opt LPCWSTR wzAncestors,
35 __in BURN_PACKAGE* pPackage 34 __in BURN_PACKAGE* pPackage
36 ); 35 );
37 36
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(
424 } 424 }
425 425
426 ReleaseStr(pRegistration->sczDetectedProviderKeyBundleId); 426 ReleaseStr(pRegistration->sczDetectedProviderKeyBundleId);
427 ReleaseStr(pRegistration->sczAncestors);
428 ReleaseStr(pRegistration->sczBundlePackageAncestors); 427 ReleaseStr(pRegistration->sczBundlePackageAncestors);
429 RelatedBundlesUninitialize(&pRegistration->relatedBundles); 428 RelatedBundlesUninitialize(&pRegistration->relatedBundles);
430 429
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
152 BOOL fEligibleForCleanup; // Only valid after detect. 152 BOOL fEligibleForCleanup; // Only valid after detect.
153 153
154 LPWSTR sczDetectedProviderKeyBundleId; 154 LPWSTR sczDetectedProviderKeyBundleId;
155 LPWSTR sczAncestors;
156 LPWSTR sczBundlePackageAncestors; 155 LPWSTR sczBundlePackageAncestors;
157} BURN_REGISTRATION; 156} BURN_REGISTRATION;
158 157
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(
105 MSG msg = { }; 105 MSG msg = { };
106 106
107 BURN_ENGINE_STATE* pEngineState = pContext->pEngineState; 107 BURN_ENGINE_STATE* pEngineState = pContext->pEngineState;
108 BOOL fElevatedEngine = BURN_MODE_ELEVATED == pContext->pEngineState->mode; 108 BOOL fElevatedEngine = BURN_MODE_ELEVATED == pContext->pEngineState->internalCommand.mode;
109 109
110 // If elevated, set up the thread local storage to store the correct pipe to communicate logging. 110 // If elevated, set up the thread local storage to store the correct pipe to communicate logging.
111 if (fElevatedEngine) 111 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
1144 __in LPCWSTR wzVersion 1144 __in LPCWSTR wzVersion
1145 ) 1145 )
1146 { 1146 {
1147 HRESULT hr = StrAllocString(&pEngineState->registration.sczAncestors, wzId, 0); 1147 HRESULT hr = StrAllocString(&pEngineState->internalCommand.sczAncestors, wzId, 0);
1148 NativeAssert::Succeeded(hr, "Failed to set registration's ancestors"); 1148 NativeAssert::Succeeded(hr, "Failed to set registration's ancestors");
1149 1149
1150 hr = StrAllocFormatted(&pEngineState->registration.sczBundlePackageAncestors, L"%ls;%ls", wzId, pEngineState->registration.sczId);
1151 NativeAssert::Succeeded(hr, "Failed to set registration's package ancestors");
1152
1150 pEngineState->command.relationType = BOOTSTRAPPER_RELATION_UPGRADE; 1153 pEngineState->command.relationType = BOOTSTRAPPER_RELATION_UPGRADE;
1151 1154
1152 DetectPackagesAsPresentAndCached(pEngineState); 1155 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
115 TestThrowOnFailure(hr, L"Failed to parse registration from XML."); 115 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
116 116
117 plan.action = BOOTSTRAPPER_ACTION_INSTALL; 117 plan.action = BOOTSTRAPPER_ACTION_INSTALL;
118 plan.pCommand = &command;
118 plan.pInternalCommand = &internalCommand; 119 plan.pInternalCommand = &internalCommand;
119 120
120 hr = PlanSetResumeCommand(&plan, &registration, &command, &logging); 121 hr = PlanSetResumeCommand(&plan, &registration, &logging);
121 TestThrowOnFailure(hr, L"Failed to set registration resume command."); 122 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
122 123
123 hr = PathForCurrentProcess(&sczCurrentProcess, NULL); 124 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -213,9 +214,10 @@ namespace Bootstrapper
213 TestThrowOnFailure(hr, L"Failed to parse registration from XML."); 214 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
214 215
215 plan.action = BOOTSTRAPPER_ACTION_INSTALL; 216 plan.action = BOOTSTRAPPER_ACTION_INSTALL;
217 plan.pCommand = &command;
216 plan.pInternalCommand = &internalCommand; 218 plan.pInternalCommand = &internalCommand;
217 219
218 hr = PlanSetResumeCommand(&plan, &registration, &command, &logging); 220 hr = PlanSetResumeCommand(&plan, &registration, &logging);
219 TestThrowOnFailure(hr, L"Failed to set registration resume command."); 221 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
220 222
221 hr = PathForCurrentProcess(&sczCurrentProcess, NULL); 223 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -334,9 +336,10 @@ namespace Bootstrapper
334 TestThrowOnFailure(hr, L"Failed to parse registration from XML."); 336 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
335 337
336 plan.action = BOOTSTRAPPER_ACTION_INSTALL; 338 plan.action = BOOTSTRAPPER_ACTION_INSTALL;
339 plan.pCommand = &command;
337 plan.pInternalCommand = &internalCommand; 340 plan.pInternalCommand = &internalCommand;
338 341
339 hr = PlanSetResumeCommand(&plan, &registration, &command, &logging); 342 hr = PlanSetResumeCommand(&plan, &registration, &logging);
340 TestThrowOnFailure(hr, L"Failed to set registration resume command."); 343 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
341 344
342 hr = PathForCurrentProcess(&sczCurrentProcess, NULL); 345 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -455,9 +458,10 @@ namespace Bootstrapper
455 TestThrowOnFailure(hr, L"Failed to parse registration from XML."); 458 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
456 459
457 plan.action = BOOTSTRAPPER_ACTION_INSTALL; 460 plan.action = BOOTSTRAPPER_ACTION_INSTALL;
461 plan.pCommand = &command;
458 plan.pInternalCommand = &internalCommand; 462 plan.pInternalCommand = &internalCommand;
459 463
460 hr = PlanSetResumeCommand(&plan, &registration, &command, &logging); 464 hr = PlanSetResumeCommand(&plan, &registration, &logging);
461 TestThrowOnFailure(hr, L"Failed to set registration resume command."); 465 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
462 466
463 hr = PathForCurrentProcess(&sczCurrentProcess, NULL); 467 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -601,9 +605,10 @@ namespace Bootstrapper
601 TestThrowOnFailure(hr, L"Failed to parse registration from XML."); 605 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
602 606
603 plan.action = BOOTSTRAPPER_ACTION_INSTALL; 607 plan.action = BOOTSTRAPPER_ACTION_INSTALL;
608 plan.pCommand = &command;
604 plan.pInternalCommand = &internalCommand; 609 plan.pInternalCommand = &internalCommand;
605 610
606 hr = PlanSetResumeCommand(&plan, &registration, &command, &logging); 611 hr = PlanSetResumeCommand(&plan, &registration, &logging);
607 TestThrowOnFailure(hr, L"Failed to set registration resume command."); 612 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
608 613
609 hr = PathForCurrentProcess(&sczCurrentProcess, NULL); 614 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -738,9 +743,10 @@ namespace Bootstrapper
738 TestThrowOnFailure(hr, L"Failed to parse registration from XML."); 743 TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
739 744
740 plan.action = BOOTSTRAPPER_ACTION_INSTALL; 745 plan.action = BOOTSTRAPPER_ACTION_INSTALL;
746 plan.pCommand = &command;
741 plan.pInternalCommand = &internalCommand; 747 plan.pInternalCommand = &internalCommand;
742 748
743 hr = PlanSetResumeCommand(&plan, &registration, &command, &logging); 749 hr = PlanSetResumeCommand(&plan, &registration, &logging);
744 TestThrowOnFailure(hr, L"Failed to set registration resume command."); 750 TestThrowOnFailure(hr, L"Failed to set registration resume command.");
745 751
746 hr = PathForCurrentProcess(&sczCurrentProcess, NULL); 752 hr = PathForCurrentProcess(&sczCurrentProcess, NULL);