summaryrefslogtreecommitdiff
path: root/src/burn/engine/core.cpp
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 /src/burn/engine/core.cpp
parentce8acddf52bde840571535c3dfd56a2371d80684 (diff)
downloadwix-9ae1c04d5fa02ac020885cdad7c592f7bb43d83e.tar.gz
wix-9ae1c04d5fa02ac020885cdad7c592f7bb43d83e.tar.bz2
wix-9ae1c04d5fa02ac020885cdad7c592f7bb43d83e.zip
Parse most of Burn command line parameters into BURN_ENGINE_COMMAND.
Diffstat (limited to 'src/burn/engine/core.cpp')
-rw-r--r--src/burn/engine/core.cpp132
1 files changed, 60 insertions, 72 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 {