Parse most of Burn command line parameters into BURN_ENGINE_COMMAND.
Sean Hall committed
Aug 3, 2021 at 15:41 UTC
9ae1c04d5fa02ac020885cdad7c592f7bb43d83e
18 files changed
+161
-161
src/burn/engine/core.cpp
+60
-72
@@ -15,12 +15,9 @@ struct BURN_CACHE_THREAD_CONTEXT
15
// internal function declarations
16
17
static HRESULT GetSanitizedCommandLine(
18
- __in int argc,
19
- __in LPWSTR* argv,
18
+ __in BURN_ENGINE_COMMAND* pInternalCommand,
19
__in BOOTSTRAPPER_COMMAND* pCommand,
20
__in BURN_VARIABLES* pVariables,
22
- __in DWORD cUnknownArgs,
23
- __in int* rgUnknownArgs,
21
__inout_z LPWSTR* psczSanitizedCommandLine
22
);
23
static HRESULT ParsePipeConnection(
@@ -89,7 +86,7 @@ extern "C" HRESULT CoreInitialize(
86
hr = ContainersInitialize(&pEngineState->containers, &pEngineState->section);
87
ExitOnFailure(hr, "Failed to initialize containers.");
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);
90
ExitOnFailure(hr, "Fatal error while sanitizing command line.");
91
92
LogId(REPORT_STANDARD, MSG_BURN_COMMAND_LINE, sczSanitizedCommandLine ? sczSanitizedCommandLine : L"");
@@ -97,7 +94,7 @@ extern "C" HRESULT CoreInitialize(
94
// The command line wasn't logged immediately so that hidden variables set on the command line can be obscured in the log.
95
// This delay creates issues when troubleshooting parsing errors because the original command line is not in the log.
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)
98
{
99
LogExitOnRootFailure(hr = E_INVALIDARG, MSG_FAILED_PARSE_COMMAND_LINE, "Failed to parse command line.");
100
}
@@ -137,7 +134,7 @@ extern "C" HRESULT CoreInitialize(
134
ExitOnFailure(hr, "Failed to set original source variable.");
135
}
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)
138
{
139
hr = CacheInitializeSources(&pEngineState->cache, &pEngineState->registration, &pEngineState->variables, &pEngineState->internalCommand);
140
ExitOnFailure(hr, "Failed to initialize internal cache source functionality.");
@@ -145,7 +142,7 @@ extern "C" HRESULT CoreInitialize(
142
143
// If we're not elevated then we'll be loading the bootstrapper application, so extract
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)
146
{
147
// Extract all UX payloads to working folder.
148
hr = UserExperienceEnsureWorkingFolder(&pEngineState->cache, &pEngineState->userExperience.sczTempDirectory);
@@ -176,15 +173,16 @@ extern "C" HRESULT CoreInitializeConstants(
173
)
174
{
175
HRESULT hr = S_OK;
176
+ BURN_ENGINE_COMMAND* pInternalCommand = &pEngineState->internalCommand;
177
BURN_REGISTRATION* pRegistration = &pEngineState->registration;
178
181
- hr = DependencyInitialize(&pEngineState->internalCommand, &pEngineState->dependencies, pRegistration);
179
+ hr = DependencyInitialize(pInternalCommand, &pEngineState->dependencies, pRegistration);
180
ExitOnFailure(hr, "Failed to initialize dependency data.");
181
182
// Support passing Ancestors to embedded burn bundles.
185
- if (pRegistration->sczAncestors && *pRegistration->sczAncestors)
183
+ if (pInternalCommand->sczAncestors && *pInternalCommand->sczAncestors)
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);
186
ExitOnFailure(hr, "Failed to copy ancestors and self to bundle package ancestors.");
187
}
188
else
@@ -459,6 +457,7 @@ extern "C" HRESULT CorePlan(
457
// we make everywhere.
458
pEngineState->plan.action = action;
459
pEngineState->plan.pCache = &pEngineState->cache;
460
+ pEngineState->plan.pCommand = &pEngineState->command;
461
pEngineState->plan.pInternalCommand = &pEngineState->internalCommand;
462
pEngineState->plan.pPayloads = &pEngineState->payloads;
463
pEngineState->plan.wzBundleId = pEngineState->registration.sczId;
@@ -470,7 +469,7 @@ extern "C" HRESULT CorePlan(
469
ExitOnFailure(hr, "Failed to update action.");
470
471
// Set resume commandline
473
- hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->command, &pEngineState->log);
472
+ hr = PlanSetResumeCommand(&pEngineState->plan, &pEngineState->registration, &pEngineState->log);
473
ExitOnFailure(hr, "Failed to set resume command");
474
475
hr = DependencyPlanInitialize(&pEngineState->dependencies, &pEngineState->plan);
@@ -499,7 +498,7 @@ extern "C" HRESULT CorePlan(
498
}
499
else
500
{
502
- hr = PlanForwardCompatibleBundles(&pEngineState->userExperience, &pEngineState->command, &pEngineState->plan, &pEngineState->registration, action);
501
+ hr = PlanForwardCompatibleBundles(&pEngineState->userExperience, &pEngineState->plan, &pEngineState->registration);
502
ExitOnFailure(hr, "Failed to plan forward compatible bundles.");
503
504
if (pEngineState->plan.fEnabledForwardCompatibleBundle)
@@ -688,7 +687,7 @@ extern "C" HRESULT CoreApply(
687
hr = CoreElevate(pEngineState, pEngineState->userExperience.hwndApply);
688
ExitOnFailure(hr, "Failed to elevate.");
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);
691
ExitOnFailure(hr, "Failed to initialize apply in elevated process.");
692
693
fElevated = TRUE;
@@ -932,9 +931,7 @@ extern "C" HRESULT CoreRecreateCommandLine(
931
__in BOOTSTRAPPER_COMMAND* pCommand,
932
__in BOOTSTRAPPER_RELATION_TYPE relationType,
933
__in BOOL fPassthrough,
935
- __in_z_opt LPCWSTR wzAncestors,
936
- __in_z_opt LPCWSTR wzAppendLogPath,
937
- __in_z_opt LPCWSTR wzAdditionalCommandLineArguments
934
+ __in_z_opt LPCWSTR wzAppendLogPath
935
)
936
{
937
HRESULT hr = S_OK;
@@ -986,9 +983,9 @@ extern "C" HRESULT CoreRecreateCommandLine(
983
ExitOnFailure(hr, "Failed to append active parent command-line to command-line.");
984
}
985
989
- if (wzAncestors)
986
+ if (pInternalCommand->sczAncestors)
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);
989
ExitOnFailure(hr, "Failed to format ancestors for command-line.");
990
991
hr = StrAllocConcat(psczCommandLine, scz, 0);
@@ -1022,12 +1019,12 @@ extern "C" HRESULT CoreRecreateCommandLine(
1019
ExitOnFailure(hr, "Failed to append log command-line to command-line");
1020
}
1021
1025
- if (wzAdditionalCommandLineArguments && *wzAdditionalCommandLineArguments)
1022
+ if (pCommand->wzCommandLine && *pCommand->wzCommandLine)
1023
{
1024
hr = StrAllocConcat(psczCommandLine, L" ", 0);
1025
ExitOnFailure(hr, "Failed to append space to command-line.");
1026
1030
- hr = StrAllocConcat(psczCommandLine, wzAdditionalCommandLineArguments, 0);
1027
+ hr = StrAllocConcat(psczCommandLine, pCommand->wzCommandLine, 0);
1028
ExitOnFailure(hr, "Failed to append command-line to command-line.");
1029
}
1030
@@ -1171,33 +1168,20 @@ LExit:
1168
}
1169
1170
extern "C" HRESULT CoreParseCommandLine(
1174
- __in int argc,
1175
- __in LPWSTR* argv,
1171
+ __in BURN_ENGINE_COMMAND* pInternalCommand,
1172
__in BOOTSTRAPPER_COMMAND* pCommand,
1173
__in BURN_PIPE_CONNECTION* pCompanionConnection,
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,
1175
__inout HANDLE* phSectionFile,
1185
- __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
1176
+ __inout HANDLE* phSourceEngineFile
1177
)
1178
{
1179
HRESULT hr = S_OK;
1180
BOOL fUnknownArg = FALSE;
1181
BOOL fInvalidCommandLine = FALSE;
1182
DWORD64 qw = 0;
1183
+ int argc = pInternalCommand->argc;
1184
+ LPWSTR* argv = pInternalCommand->argv;
1185
1186
for (int i = 0; i < argc; ++i)
1187
{
@@ -1209,11 +1193,11 @@ extern "C" HRESULT CoreParseCommandLine(
1193
CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"log", -1) ||
1194
CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"xlog", -1))
1195
{
1212
- *pdwLoggingAttributes &= ~BURN_LOGGING_ATTRIBUTE_APPEND;
1196
+ pInternalCommand->dwLoggingAttributes &= ~BURN_LOGGING_ATTRIBUTE_APPEND;
1197
1198
if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], 1, L"x", 1))
1199
{
1216
- *pdwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE | BURN_LOGGING_ATTRIBUTE_EXTRADEBUG;
1200
+ pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE | BURN_LOGGING_ATTRIBUTE_EXTRADEBUG;
1201
}
1202
1203
if (i + 1 >= argc)
@@ -1224,7 +1208,7 @@ extern "C" HRESULT CoreParseCommandLine(
1208
1209
++i;
1210
1227
- hr = StrAllocString(psczLogFile, argv[i], 0);
1211
+ hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0);
1212
ExitOnFailure(hr, "Failed to copy log file path.");
1213
}
1214
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"?", -1) ||
@@ -1291,19 +1275,19 @@ extern "C" HRESULT CoreParseCommandLine(
1275
}
1276
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"noaupause", -1))
1277
{
1294
- *pAutomaticUpdates = BURN_AU_PAUSE_ACTION_NONE;
1278
+ pInternalCommand->automaticUpdates = BURN_AU_PAUSE_ACTION_NONE;
1279
}
1280
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"keepaupaused", -1))
1281
{
1282
// Switch /noaupause takes precedence.
1299
- if (BURN_AU_PAUSE_ACTION_NONE != *pAutomaticUpdates)
1283
+ if (BURN_AU_PAUSE_ACTION_NONE != pInternalCommand->automaticUpdates)
1284
{
1301
- *pAutomaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME;
1285
+ pInternalCommand->automaticUpdates = BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME;
1286
}
1287
}
1288
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"disablesystemrestore", -1))
1289
{
1306
- *pfDisableSystemRestore = TRUE;
1290
+ pInternalCommand->fDisableSystemRestore = TRUE;
1291
}
1292
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"originalsource", -1))
1293
{
@@ -1314,7 +1298,7 @@ extern "C" HRESULT CoreParseCommandLine(
1298
}
1299
1300
++i;
1317
- hr = StrAllocString(psczOriginalSource, argv[i], 0);
1301
+ hr = StrAllocString(&pInternalCommand->sczOriginalSource, argv[i], 0);
1302
ExitOnFailure(hr, "Failed to copy last used source.");
1303
}
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(
1311
1312
++i;
1313
1330
- hr = StrAllocString(psczActiveParent, argv[i], 0);
1314
+ hr = StrAllocString(&pInternalCommand->sczActiveParent, argv[i], 0);
1315
ExitOnFailure(hr, "Failed to copy parent.");
1316
}
1317
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT_NONE, -1))
1318
{
1335
- hr = StrAllocString(psczActiveParent, L"", 0);
1319
+ hr = StrAllocString(&pInternalCommand->sczActiveParent, L"", 0);
1320
ExitOnFailure(hr, "Failed to initialize parent to none.");
1321
}
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(
1329
1330
++i;
1331
1348
- hr = StrAllocString(psczLogFile, argv[i], 0);
1332
+ hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0);
1333
ExitOnFailure(hr, "Failed to copy append log file path.");
1334
1351
- *pdwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND;
1335
+ pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND;
1336
}
1337
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_ELEVATED, -1))
1338
{
@@ -1358,13 +1342,13 @@ extern "C" HRESULT CoreParseCommandLine(
1342
ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the elevated name, token and parent process id.");
1343
}
1344
1361
- if (BURN_MODE_UNTRUSTED != *pMode)
1345
+ if (BURN_MODE_UNTRUSTED != pInternalCommand->mode)
1346
{
1347
fInvalidCommandLine = TRUE;
1348
TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
1349
}
1350
1367
- *pMode = BURN_MODE_ELEVATED;
1351
+ pInternalCommand->mode = BURN_MODE_ELEVATED;
1352
1353
++i;
1354
@@ -1380,9 +1364,9 @@ extern "C" HRESULT CoreParseCommandLine(
1364
}
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)))
1366
{
1383
- if (BURN_MODE_UNTRUSTED == *pMode)
1367
+ if (BURN_MODE_UNTRUSTED == pInternalCommand->mode)
1368
{
1385
- *pMode = BURN_MODE_NORMAL;
1369
+ pInternalCommand->mode = BURN_MODE_NORMAL;
1370
}
1371
else
1372
{
@@ -1401,7 +1385,7 @@ extern "C" HRESULT CoreParseCommandLine(
1385
}
1386
else if (L'\0' != wzParam[1])
1387
{
1404
- hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0);
1388
+ hr = StrAllocString(&pInternalCommand->sczSourceProcessPath, wzParam + 1, 0);
1389
ExitOnFailure(hr, "Failed to copy source process path.");
1390
}
1391
}
@@ -1414,7 +1398,7 @@ extern "C" HRESULT CoreParseCommandLine(
1398
ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the embedded name, token and parent process id.");
1399
}
1400
1417
- switch (*pMode)
1401
+ switch (pInternalCommand->mode)
1402
{
1403
case BURN_MODE_UNTRUSTED:
1404
// Leave mode as UNTRUSTED to launch the clean room process.
@@ -1423,7 +1407,7 @@ extern "C" HRESULT CoreParseCommandLine(
1407
// The initialization code already assumes that the
1408
// clean room switch is at the beginning of the command line,
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;
1411
break;
1412
default:
1413
fInvalidCommandLine = TRUE;
@@ -1478,17 +1462,17 @@ extern "C" HRESULT CoreParseCommandLine(
1462
}
1463
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_DISABLE_UNELEVATE, -1))
1464
{
1481
- *pfDisableUnelevate = TRUE;
1465
+ pInternalCommand->fDisableUnelevate = TRUE;
1466
}
1467
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1))
1468
{
1485
- if (BURN_MODE_UNTRUSTED != *pMode)
1469
+ if (BURN_MODE_UNTRUSTED != pInternalCommand->mode)
1470
{
1471
fInvalidCommandLine = TRUE;
1472
TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
1473
}
1474
1491
- *pMode = BURN_MODE_RUNONCE;
1475
+ pInternalCommand->mode = BURN_MODE_RUNONCE;
1476
}
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)))
1478
{
@@ -1501,7 +1485,7 @@ extern "C" HRESULT CoreParseCommandLine(
1485
}
1486
else
1487
{
1504
- hr = StrAllocString(psczIgnoreDependencies, &wzParam[1], 0);
1488
+ hr = StrAllocString(&pInternalCommand->sczIgnoreDependencies, &wzParam[1], 0);
1489
ExitOnFailure(hr, "Failed to allocate the list of dependencies to ignore.");
1490
}
1491
}
@@ -1516,7 +1500,7 @@ extern "C" HRESULT CoreParseCommandLine(
1500
}
1501
else
1502
{
1519
- hr = StrAllocString(psczAncestors, &wzParam[1], 0);
1503
+ hr = StrAllocString(&pInternalCommand->sczAncestors, &wzParam[1], 0);
1504
ExitOnFailure(hr, "Failed to allocate the list of ancestors.");
1505
}
1506
}
@@ -1604,18 +1588,21 @@ extern "C" HRESULT CoreParseCommandLine(
1588
1589
if (fUnknownArg)
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);
1592
ExitOnFailure(hr, "Failed to ensure size for unknown args.");
1593
1610
- (*prgUnknownArgs)[*pcUnknownArgs] = i;
1611
- *pcUnknownArgs += 1;
1594
+ pInternalCommand->rgUnknownArgs[pInternalCommand->cUnknownArgs] = i;
1595
+ pInternalCommand->cUnknownArgs += 1;
1596
}
1597
}
1598
1615
- // If embedded, ensure the display goes embedded as well.
1616
- if (BURN_MODE_EMBEDDED == *pMode)
1599
+ if (BURN_MODE_EMBEDDED == pInternalCommand->mode)
1600
{
1601
+ // Ensure the display goes embedded as well.
1602
pCommand->display = BOOTSTRAPPER_DISPLAY_EMBEDDED;
1603
+
1604
+ // Disable system restore since the parent bundle may have done it.
1605
+ pInternalCommand->fDisableSystemRestore = TRUE;
1606
}
1607
1608
// Set the defaults if nothing was set above.
@@ -1633,7 +1620,7 @@ LExit:
1620
if (fInvalidCommandLine)
1621
{
1622
hr = S_OK;
1636
- *pfInvalidCommandLine = TRUE;
1623
+ pInternalCommand->fInvalidCommandLine = TRUE;
1624
}
1625
1626
return hr;
@@ -1642,12 +1629,9 @@ LExit:
1629
// internal helper functions
1630
1631
static HRESULT GetSanitizedCommandLine(
1645
- __in int argc,
1646
- __in LPWSTR* argv,
1632
+ __in BURN_ENGINE_COMMAND* pInternalCommand,
1633
__in BOOTSTRAPPER_COMMAND* pCommand,
1634
__in BURN_VARIABLES* pVariables,
1649
- __in DWORD cUnknownArgs,
1650
- __in int* rgUnknownArgs,
1635
__inout_z LPWSTR* psczSanitizedCommandLine
1636
)
1637
{
@@ -1656,6 +1640,10 @@ static HRESULT GetSanitizedCommandLine(
1640
BOOL fHidden = FALSE;
1641
LPWSTR sczSanitizedArgument = 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;
1647
1648
for (int i = 0; i < argc; ++i)
1649
{
src/burn/engine/core.h
+17
-30
@@ -80,13 +80,27 @@ enum BURN_AU_PAUSE_ACTION
80
81
typedef struct _BURN_ENGINE_COMMAND
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;
93
BOOL fInitiallyElevated;
94
95
LPWSTR sczActiveParent;
96
+ LPWSTR sczAncestors;
97
LPWSTR sczIgnoreDependencies;
98
99
LPWSTR sczSourceProcessPath;
100
LPWSTR sczOriginalSource;
101
+
102
+ DWORD dwLoggingAttributes;
103
+ LPWSTR sczLogFile;
104
} BURN_ENGINE_COMMAND;
105
106
typedef struct _BURN_ENGINE_STATE
@@ -122,7 +136,6 @@ typedef struct _BURN_ENGINE_STATE
136
HANDLE hMessageWindowThread;
137
138
BOOL fDisableRollback;
125
- BOOL fDisableSystemRestore;
139
BOOL fParallelCacheAndExecute;
140
141
BURN_LOGGING log;
@@ -131,9 +144,6 @@ typedef struct _BURN_ENGINE_STATE
144
145
BURN_PLAN plan;
146
134
- BURN_MODE mode;
135
- BURN_AU_PAUSE_ACTION automaticUpdates;
136
-
147
DWORD dwElevatedLoggingTlsId;
148
149
LPWSTR sczBundleEngineWorkingPath;
@@ -141,14 +151,8 @@ typedef struct _BURN_ENGINE_STATE
151
BURN_PIPE_CONNECTION embeddedConnection;
152
153
BURN_RESUME_MODE resumeMode;
144
- BOOL fDisableUnelevate;
154
146
- int argc;
147
- LPWSTR* argv;
148
- BOOL fInvalidCommandLine;
155
BURN_ENGINE_COMMAND internalCommand;
150
- DWORD cUnknownArgs;
151
- int* rgUnknownArgs;
156
} BURN_ENGINE_STATE;
157
158
typedef struct _BURN_APPLY_CONTEXT
@@ -218,9 +222,7 @@ HRESULT CoreRecreateCommandLine(
222
__in BOOTSTRAPPER_COMMAND* pCommand,
223
__in BOOTSTRAPPER_RELATION_TYPE relationType,
224
__in BOOL fPassthrough,
221
- __in_z_opt LPCWSTR wzAncestors,
222
- __in_z_opt LPCWSTR wzAppendLogPath,
223
- __in_z_opt LPCWSTR wzAdditionalCommandLineArguments
225
+ __in_z_opt LPCWSTR wzAppendLogPath
226
);
227
HRESULT CoreAppendFileHandleAttachedToCommandLine(
228
__in HANDLE hFileWithAttachedContainer,
@@ -241,27 +243,12 @@ void CoreCleanup(
243
__in BURN_ENGINE_STATE* pEngineState
244
);
245
HRESULT CoreParseCommandLine(
244
- __in int argc,
245
- __in LPWSTR* argv,
246
+ __in BURN_ENGINE_COMMAND* pInternalCommand,
247
__in BOOTSTRAPPER_COMMAND* pCommand,
248
__in BURN_PIPE_CONNECTION* pCompanionConnection,
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,
250
__inout HANDLE* phSectionFile,
255
- __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
251
+ __inout HANDLE* phSourceEngineFile
252
);
253
254
#if defined(__cplusplus)
src/burn/engine/elevation.cpp
+5
-7
@@ -339,7 +339,7 @@ extern "C" HRESULT ElevationElevate(
339
__in_opt HWND hwndParent
340
)
341
{
342
- Assert(BURN_MODE_ELEVATED != pEngineState->mode);
342
+ Assert(BURN_MODE_ELEVATED != pEngineState->internalCommand.mode);
343
Assert(!pEngineState->companionConnection.sczName);
344
Assert(!pEngineState->companionConnection.sczSecret);
345
Assert(!pEngineState->companionConnection.hProcess);
@@ -407,9 +407,7 @@ extern "C" HRESULT ElevationApplyInitialize(
407
__in HANDLE hPipe,
408
__in BURN_USER_EXPERIENCE* pBA,
409
__in BURN_VARIABLES* pVariables,
410
- __in BOOTSTRAPPER_ACTION action,
411
- __in BURN_AU_PAUSE_ACTION auAction,
412
- __in BOOL fTakeSystemRestorePoint
410
+ __in BURN_PLAN* pPlan
411
)
412
{
413
HRESULT hr = S_OK;
@@ -421,13 +419,13 @@ extern "C" HRESULT ElevationApplyInitialize(
419
context.pBA = pBA;
420
421
// serialize message data
424
- hr = BuffWriteNumber(&pbData, &cbData, (DWORD)action);
422
+ hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pPlan->action);
423
ExitOnFailure(hr, "Failed to write action to message buffer.");
424
427
- hr = BuffWriteNumber(&pbData, &cbData, (DWORD)auAction);
425
+ hr = BuffWriteNumber(&pbData, &cbData, (DWORD)pPlan->pInternalCommand->automaticUpdates);
426
ExitOnFailure(hr, "Failed to write update action to message buffer.");
427
430
- hr = BuffWriteNumber(&pbData, &cbData, (DWORD)fTakeSystemRestorePoint);
428
+ hr = BuffWriteNumber(&pbData, &cbData, (DWORD)!pPlan->pInternalCommand->fDisableSystemRestore);
429
ExitOnFailure(hr, "Failed to write system restore point action to message buffer.");
430
431
hr = VariableSerialize(pVariables, FALSE, &pbData, &cbData);
src/burn/engine/elevation.h
+1
-3
@@ -16,9 +16,7 @@ HRESULT ElevationApplyInitialize(
16
__in HANDLE hPipe,
17
__in BURN_USER_EXPERIENCE* pBA,
18
__in BURN_VARIABLES* pVariables,
19
- __in BOOTSTRAPPER_ACTION action,
20
- __in BURN_AU_PAUSE_ACTION auAction,
21
- __in BOOL fTakeSystemRestorePoint
19
+ __in BURN_PLAN* pPlan
20
);
21
HRESULT ElevationApplyUninitialize(
22
__in HANDLE hPipe
src/burn/engine/engine.cpp
+12
-13
@@ -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
114
#endif
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.");
118
119
hr = InitializeEngineState(&engineState, hEngineFile);
@@ -121,7 +121,7 @@ extern "C" HRESULT EngineRun(
121
122
engineState.command.nCmdShow = nCmdShow;
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
{
126
SplashScreenCreate(hInstance, NULL, &engineState.command.hwndSplashScreen);
127
}
@@ -192,7 +192,7 @@ extern "C" HRESULT EngineRun(
192
ExitOnFailure(hr, "Failed to initialize core.");
193
194
// Select run mode.
195
- switch (engineState.mode)
195
+ switch (engineState.internalCommand.mode)
196
{
197
case BURN_MODE_UNTRUSTED:
198
hr = RunUntrusted(wzCommandLine, &engineState);
@@ -328,7 +328,7 @@ static HRESULT InitializeEngineState(
328
HANDLE hSectionFile = hEngineFile;
329
HANDLE hSourceEngineFile = INVALID_HANDLE_VALUE;
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;
333
::InitializeCriticalSection(&pEngineState->userExperience.csEngineActive);
334
PipeConnectionInitialize(&pEngineState->companionConnection);
@@ -338,7 +338,7 @@ static HRESULT InitializeEngineState(
338
ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated);
339
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.");
343
344
hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile);
@@ -355,12 +355,12 @@ static void UninitializeEngineState(
355
__in BURN_ENGINE_STATE* pEngineState
356
)
357
{
358
- if (pEngineState->argv)
358
+ if (pEngineState->internalCommand.argv)
359
{
360
- AppFreeCommandLineArgs(pEngineState->argv);
360
+ AppFreeCommandLineArgs(pEngineState->internalCommand.argv);
361
}
362
363
- ReleaseMem(pEngineState->rgUnknownArgs);
363
+ ReleaseMem(pEngineState->internalCommand.rgUnknownArgs);
364
365
PipeConnectionUninitialize(&pEngineState->embeddedConnection);
366
PipeConnectionUninitialize(&pEngineState->companionConnection);
@@ -390,7 +390,9 @@ static void UninitializeEngineState(
390
ReleaseStr(pEngineState->command.wzCommandLine);
391
392
ReleaseStr(pEngineState->internalCommand.sczActiveParent);
393
+ ReleaseStr(pEngineState->internalCommand.sczAncestors);
394
ReleaseStr(pEngineState->internalCommand.sczIgnoreDependencies);
395
+ ReleaseStr(pEngineState->internalCommand.sczLogFile);
396
ReleaseStr(pEngineState->internalCommand.sczOriginalSource);
397
ReleaseStr(pEngineState->internalCommand.sczSourceProcessPath);
398
@@ -469,7 +471,7 @@ static HRESULT RunUntrusted(
471
472
#ifdef ENABLE_UNELEVATE
473
// TODO: Pass file handle to unelevated process if this ever gets reenabled.
472
- if (!pEngineState->fDisableUnelevate)
474
+ if (!pEngineState->internalCommand.fDisableUnelevate)
475
{
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).
477
hr = ProcExecuteAsInteractiveUser(wzCleanRoomBundlePath, sczParameters, &hProcess);
@@ -522,7 +524,7 @@ static HRESULT RunNormal(
524
BURN_EXTENSION_ENGINE_CONTEXT extensionEngineContext = { };
525
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);
528
ExitOnFailure(hr, "Failed to open log.");
529
530
// Ensure we're on a supported operating system.
@@ -694,9 +696,6 @@ static HRESULT RunEmbedded(
696
{
697
HRESULT hr = S_OK;
698
697
- // Disable system restore since the parent bundle may have done it.
698
- pEngineState->fDisableSystemRestore = TRUE;
699
-
699
// Connect to parent process.
700
hr = PipeChildConnect(&pEngineState->embeddedConnection, FALSE);
701
ExitOnFailure(hr, "Failed to connect to parent of embedded process.");
src/burn/engine/externalengine.cpp
+3
-3
@@ -197,7 +197,7 @@ HRESULT ExternalEngineSendEmbeddedError(
197
SIZE_T cbData = 0;
198
DWORD dwResult = *pnResult = 0;
199
200
- if (BURN_MODE_EMBEDDED != pEngineState->mode)
200
+ if (BURN_MODE_EMBEDDED != pEngineState->internalCommand.mode)
201
{
202
hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE);
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;
236
DWORD dwResult = *pnResult = 0;
237
238
- if (BURN_MODE_EMBEDDED != pEngineState->mode)
238
+ if (BURN_MODE_EMBEDDED != pEngineState->internalCommand.mode)
239
{
240
hr = HRESULT_FROM_WIN32(ERROR_INVALID_STATE);
241
ExitOnRootFailure(hr, "BA requested to send embedded progress message when not in embedded mode.");
@@ -295,7 +295,7 @@ HRESULT ExternalEngineSetUpdate(
295
{
296
UpdateUninitialize(&pEngineState->update);
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.");
300
301
// Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths.
src/burn/engine/logging.cpp
+33
-6
@@ -15,7 +15,11 @@ static CONST LPWSTR LOG_FAILED_EVENT_LOG_MESSAGE = L"Burn Engine Fatal Error: fa
15
// internal function declarations
16
17
static void CheckLoggingPolicy(
18
- __out DWORD *pdwAttributes
18
+ __inout DWORD* pdwAttributes
19
+ );
20
+static HRESULT InitializeLogging(
21
+ __in BURN_LOGGING* pLog,
22
+ __in BURN_ENGINE_COMMAND* pInternalCommand
23
);
24
static HRESULT GetNonSessionSpecificTempFolder(
25
__deref_out_z LPWSTR* psczNonSessionTempFolder
@@ -26,8 +30,9 @@ static HRESULT GetNonSessionSpecificTempFolder(
30
31
extern "C" HRESULT LoggingOpen(
32
__in BURN_LOGGING* pLog,
33
+ __in BURN_ENGINE_COMMAND* pInternalCommand,
34
+ __in BOOTSTRAPPER_COMMAND* pCommand,
35
__in BURN_VARIABLES* pVariables,
30
- __in BOOTSTRAPPER_DISPLAY display,
36
__in_z LPCWSTR wzBundleName
37
)
38
{
@@ -35,8 +40,8 @@ extern "C" HRESULT LoggingOpen(
40
LPWSTR sczLoggingBaseFolder = NULL;
41
LPWSTR sczPrefixFormatted = NULL;
42
38
- // Check if the logging policy is set and configure the logging appropriately.
39
- CheckLoggingPolicy(&pLog->dwAttributes);
43
+ hr = InitializeLogging(pLog, pInternalCommand);
44
+ ExitOnFailure(hr, "Failed to initialize logging.");
45
46
if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_VERBOSE || pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_EXTRADEBUG)
47
{
@@ -94,7 +99,7 @@ extern "C" HRESULT LoggingOpen(
99
HRESULT hrOriginal = hr;
100
101
hr = HRESULT_FROM_WIN32(ERROR_INSTALL_LOG_FAILURE);
97
- SplashScreenDisplayError(display, wzBundleName, hr);
102
+ SplashScreenDisplayError(pCommand->display, wzBundleName, hr);
103
104
ExitOnFailure(hrOriginal, "Failed to open log: %ls", pLog->sczPath);
105
}
@@ -709,7 +714,7 @@ extern "C" LPWSTR LoggingStringOrUnknownIfNull(
714
// internal function declarations
715
716
static void CheckLoggingPolicy(
712
- __out DWORD *pdwAttributes
717
+ __inout DWORD *pdwAttributes
718
)
719
{
720
HRESULT hr = S_OK;
@@ -743,6 +748,28 @@ static void CheckLoggingPolicy(
748
ReleaseRegKey(hk);
749
}
750
751
+static 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
+
769
+LExit:
770
+ return hr;
771
+}
772
+
773
static HRESULT GetNonSessionSpecificTempFolder(
774
__deref_out_z LPWSTR* psczNonSessionTempFolder
775
)
src/burn/engine/logging.h
+2
-1
@@ -43,8 +43,9 @@ typedef struct _BURN_LOGGING
43
44
HRESULT LoggingOpen(
45
__in BURN_LOGGING* pLog,
46
+ __in BURN_ENGINE_COMMAND* pInternalCommand,
47
+ __in BOOTSTRAPPER_COMMAND* pCommand,
48
__in BURN_VARIABLES* pVariables,
47
- __in BOOTSTRAPPER_DISPLAY display,
49
__in_z LPCWSTR wzBundleName
50
);
51
src/burn/engine/manifest.cpp
+1
-1
@@ -98,7 +98,7 @@ static HRESULT ParseFromXml(
98
}
99
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)
103
{
104
ExitOnFailure(hr, "Failed to get Chain/@DisableSystemRestore");
src/burn/engine/plan.cpp
+7
-8
@@ -428,15 +428,14 @@ LExit:
428
429
extern "C" HRESULT PlanForwardCompatibleBundles(
430
__in BURN_USER_EXPERIENCE* pUX,
431
- __in BOOTSTRAPPER_COMMAND* pCommand,
431
__in BURN_PLAN* pPlan,
433
- __in BURN_REGISTRATION* pRegistration,
434
- __in BOOTSTRAPPER_ACTION action
432
+ __in BURN_REGISTRATION* pRegistration
433
)
434
{
435
HRESULT hr = S_OK;
436
BOOL fRecommendIgnore = TRUE;
437
BOOL fIgnoreBundle = FALSE;
438
+ BOOTSTRAPPER_ACTION action = pPlan->action;
439
440
if (!pRegistration->fForwardCompatibleBundleExists)
441
{
@@ -480,7 +479,7 @@ extern "C" HRESULT PlanForwardCompatibleBundles(
479
480
if (!fIgnoreBundle)
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);
483
ExitOnFailure(hr, "Failed to initialize pass through bundle.");
484
485
pPlan->fEnabledForwardCompatibleBundle = TRUE;
@@ -1239,9 +1238,9 @@ extern "C" HRESULT PlanRelatedBundlesBegin(
1238
UINT cAncestors = 0;
1239
STRINGDICT_HANDLE sdAncestors = NULL;
1240
1242
- if (pRegistration->sczAncestors)
1241
+ if (pPlan->pInternalCommand->sczAncestors)
1242
{
1244
- hr = StrSplitAllocArray(&rgsczAncestors, &cAncestors, pRegistration->sczAncestors, L";");
1243
+ hr = StrSplitAllocArray(&rgsczAncestors, &cAncestors, pPlan->pInternalCommand->sczAncestors, L";");
1244
ExitOnFailure(hr, "Failed to create string array from ancestors.");
1245
1246
hr = DictCreateStringListFromArray(&sdAncestors, rgsczAncestors, cAncestors, DICT_FLAG_CASEINSENSITIVE);
@@ -1777,14 +1776,14 @@ LExit:
1776
extern "C" HRESULT PlanSetResumeCommand(
1777
__in BURN_PLAN* pPlan,
1778
__in BURN_REGISTRATION* pRegistration,
1780
- __in BOOTSTRAPPER_COMMAND* pCommand,
1779
__in BURN_LOGGING* pLog
1780
)
1781
{
1782
HRESULT hr = S_OK;
1783
+ BOOTSTRAPPER_COMMAND* pCommand = pPlan->pCommand;
1784
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);
1787
ExitOnFailure(hr, "Failed to recreate resume command-line.");
1788
1789
LExit:
src/burn/engine/plan.h
+2
-4
@@ -230,6 +230,7 @@ typedef struct _BURN_PLAN
230
{
231
BOOTSTRAPPER_ACTION action;
232
BURN_CACHE* pCache;
233
+ BOOTSTRAPPER_COMMAND* pCommand;
234
BURN_ENGINE_COMMAND* pInternalCommand;
235
BURN_PAYLOADS* pPayloads;
236
LPWSTR wzBundleId; // points directly into parent the ENGINE_STATE.
@@ -326,10 +327,8 @@ HRESULT PlanLayoutBundle(
327
);
328
HRESULT PlanForwardCompatibleBundles(
329
__in BURN_USER_EXPERIENCE* pUX,
329
- __in BOOTSTRAPPER_COMMAND* pCommand,
330
__in BURN_PLAN* pPlan,
331
- __in BURN_REGISTRATION* pRegistration,
332
- __in BOOTSTRAPPER_ACTION action
331
+ __in BURN_REGISTRATION* pRegistration
332
);
333
HRESULT PlanPackages(
334
__in BURN_USER_EXPERIENCE* pUX,
@@ -446,7 +445,6 @@ HRESULT PlanRollbackBoundaryComplete(
445
HRESULT PlanSetResumeCommand(
446
__in BURN_PLAN* pPlan,
447
__in BURN_REGISTRATION* pRegistration,
449
- __in BOOTSTRAPPER_COMMAND* pCommand,
448
__in BURN_LOGGING* pLog
449
);
450
void PlanDump(
src/burn/engine/pseudobundle.cpp
+1
-2
@@ -166,7 +166,6 @@ extern "C" HRESULT PseudoBundleInitializePassthrough(
166
__in BURN_ENGINE_COMMAND* pInternalCommand,
167
__in BOOTSTRAPPER_COMMAND* pCommand,
168
__in_z_opt LPCWSTR wzAppendLogPath,
169
- __in_z_opt LPCWSTR wzAncestors,
169
__in BURN_PACKAGE* pPackage
170
)
171
{
@@ -205,7 +204,7 @@ extern "C" HRESULT PseudoBundleInitializePassthrough(
204
205
// No matter the operation, we're passing the same command-line. That's what makes
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);
208
ExitOnFailure(hr, "Failed to recreate command-line arguments.");
209
210
hr = StrAllocString(&pPassthroughPackage->Exe.sczInstallArguments, sczArguments, 0);
src/burn/engine/pseudobundle.h
-1
@@ -31,7 +31,6 @@ HRESULT PseudoBundleInitializePassthrough(
31
__in BURN_ENGINE_COMMAND* pInternalCommand,
32
__in BOOTSTRAPPER_COMMAND* pCommand,
33
__in_z_opt LPCWSTR wzAppendLogPath,
34
- __in_z_opt LPCWSTR wzAncestors,
34
__in BURN_PACKAGE* pPackage
35
);
36
src/burn/engine/registration.cpp
-1
@@ -424,7 +424,6 @@ extern "C" void RegistrationUninitialize(
424
}
425
426
ReleaseStr(pRegistration->sczDetectedProviderKeyBundleId);
427
- ReleaseStr(pRegistration->sczAncestors);
427
ReleaseStr(pRegistration->sczBundlePackageAncestors);
428
RelatedBundlesUninitialize(&pRegistration->relatedBundles);
429
src/burn/engine/registration.h
-1
@@ -152,7 +152,6 @@ typedef struct _BURN_REGISTRATION
152
BOOL fEligibleForCleanup; // Only valid after detect.
153
154
LPWSTR sczDetectedProviderKeyBundleId;
155
- LPWSTR sczAncestors;
155
LPWSTR sczBundlePackageAncestors;
156
} BURN_REGISTRATION;
157
src/burn/engine/uithread.cpp
+1
-1
@@ -105,7 +105,7 @@ static DWORD WINAPI ThreadProc(
105
MSG msg = { };
106
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
110
// If elevated, set up the thread local storage to store the correct pipe to communicate logging.
111
if (fElevatedEngine)
src/burn/test/BurnUnitTest/PlanTest.cpp
+4
-1
@@ -1144,9 +1144,12 @@ namespace Bootstrapper
1144
__in LPCWSTR wzVersion
1145
)
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");
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
+
1153
pEngineState->command.relationType = BOOTSTRAPPER_RELATION_UPGRADE;
1154
1155
DetectPackagesAsPresentAndCached(pEngineState);
src/burn/test/BurnUnitTest/RegistrationTest.cpp
+12
-6
@@ -115,9 +115,10 @@ namespace Bootstrapper
115
TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
116
117
plan.action = BOOTSTRAPPER_ACTION_INSTALL;
118
+ plan.pCommand = &command;
119
plan.pInternalCommand = &internalCommand;
120
120
- hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging);
121
+ hr = PlanSetResumeCommand(&plan, ®istration, &logging);
122
TestThrowOnFailure(hr, L"Failed to set registration resume command.");
123
124
hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -213,9 +214,10 @@ namespace Bootstrapper
214
TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
215
216
plan.action = BOOTSTRAPPER_ACTION_INSTALL;
217
+ plan.pCommand = &command;
218
plan.pInternalCommand = &internalCommand;
219
218
- hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging);
220
+ hr = PlanSetResumeCommand(&plan, ®istration, &logging);
221
TestThrowOnFailure(hr, L"Failed to set registration resume command.");
222
223
hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -334,9 +336,10 @@ namespace Bootstrapper
336
TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
337
338
plan.action = BOOTSTRAPPER_ACTION_INSTALL;
339
+ plan.pCommand = &command;
340
plan.pInternalCommand = &internalCommand;
341
339
- hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging);
342
+ hr = PlanSetResumeCommand(&plan, ®istration, &logging);
343
TestThrowOnFailure(hr, L"Failed to set registration resume command.");
344
345
hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -455,9 +458,10 @@ namespace Bootstrapper
458
TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
459
460
plan.action = BOOTSTRAPPER_ACTION_INSTALL;
461
+ plan.pCommand = &command;
462
plan.pInternalCommand = &internalCommand;
463
460
- hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging);
464
+ hr = PlanSetResumeCommand(&plan, ®istration, &logging);
465
TestThrowOnFailure(hr, L"Failed to set registration resume command.");
466
467
hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -601,9 +605,10 @@ namespace Bootstrapper
605
TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
606
607
plan.action = BOOTSTRAPPER_ACTION_INSTALL;
608
+ plan.pCommand = &command;
609
plan.pInternalCommand = &internalCommand;
610
606
- hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging);
611
+ hr = PlanSetResumeCommand(&plan, ®istration, &logging);
612
TestThrowOnFailure(hr, L"Failed to set registration resume command.");
613
614
hr = PathForCurrentProcess(&sczCurrentProcess, NULL);
@@ -738,9 +743,10 @@ namespace Bootstrapper
743
TestThrowOnFailure(hr, L"Failed to parse registration from XML.");
744
745
plan.action = BOOTSTRAPPER_ACTION_INSTALL;
746
+ plan.pCommand = &command;
747
plan.pInternalCommand = &internalCommand;
748
743
- hr = PlanSetResumeCommand(&plan, ®istration, &command, &logging);
749
+ hr = PlanSetResumeCommand(&plan, ®istration, &logging);
750
TestThrowOnFailure(hr, L"Failed to set registration resume command.");
751
752
hr = PathForCurrentProcess(&sczCurrentProcess, NULL);