@joebigelow / wix / commits / 58156885

Update Burn ARP command lines to skip clean room.

This also adds an escape hatch to Burn for antivirus interfering with clean room.

Sean Hall committed Aug 3, 2021 at 15:38 UTC 5815688519a60e63e18c13dfe0908d76757cbc53
3 files changed +20 -16
src/burn/engine/core.cpp
+16 -11
@@ -1375,7 +1375,11 @@ extern "C" HRESULT CoreParseCommandLine(
1375 }
1376 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)))
1377 {
1378 - if (BURN_MODE_UNTRUSTED != *pMode)
1378 + if (BURN_MODE_UNTRUSTED == *pMode)
1379 + {
1380 + *pMode = BURN_MODE_NORMAL;
1381 + }
1382 + else
1383 {
1384 fInvalidCommandLine = TRUE;
1385 TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
@@ -1383,17 +1387,18 @@ extern "C" HRESULT CoreParseCommandLine(
1387
1388 // Get a pointer to the next character after the switch.
1389 LPCWSTR wzParam = &argv[i][1 + lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM)];
1386 - if (L'=' != wzParam[0] || L'\0' == wzParam[1])
1387 - {
1388 - fInvalidCommandLine = TRUE;
1389 - TraceLog(E_INVALIDARG, "Missing required parameter for switch: %ls", BURN_COMMANDLINE_SWITCH_CLEAN_ROOM);
1390 - }
1391 - else
1390 + if (L'\0' != wzParam[0])
1391 {
1393 - *pMode = BURN_MODE_NORMAL;
1394 -
1395 - hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0);
1396 - ExitOnFailure(hr, "Failed to copy source process path.");
1392 + if (L'=' != wzParam[0])
1393 + {
1394 + fInvalidCommandLine = TRUE;
1395 + TraceLog(E_INVALIDARG, "Invalid switch: %ls", argv[i]);
1396 + }
1397 + else if (L'\0' != wzParam[1])
1398 + {
1399 + hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0);
1400 + ExitOnFailure(hr, "Failed to copy source process path.");
1401 + }
1402 }
1403 }
1404 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_EMBEDDED, -1))
src/burn/engine/engine.cpp
+1 -2
@@ -71,8 +71,7 @@ extern "C" BOOL EngineInCleanRoom(
71 // that should be setting this command line option, that is in our control.
72 BOOL fInCleanRoom = (wzCommandLine &&
73 (wzCommandLine[0] == L'-' || wzCommandLine[0] == L'/') &&
74 - CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzCommandLine + 1, cchCleanRoomSwitch, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, cchCleanRoomSwitch) &&
75 - wzCommandLine[1 + cchCleanRoomSwitch] == L'='
74 + CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzCommandLine + 1, cchCleanRoomSwitch, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, cchCleanRoomSwitch)
75 );
76
77 return fInCleanRoom;
src/burn/engine/registration.cpp
+3 -3
@@ -773,7 +773,7 @@ extern "C" HRESULT RegistrationSessionBegin(
773 else if (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON != pRegistration->modify) // if support modify (aka: did not disable anything)
774 {
775 // ModifyPath: [path to exe] /modify
776 - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_MODIFY_PATH, L"\"%ls\" /modify", pRegistration->sczCacheExecutablePath);
776 + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_MODIFY_PATH, L"\"%ls\" /%ls /modify", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM);
777 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_MODIFY_PATH);
778
779 // NoElevateOnModify: 1
@@ -796,14 +796,14 @@ extern "C" HRESULT RegistrationSessionBegin(
796 }
797
798 // QuietUninstallString: [path to exe] /uninstall /quiet
799 - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING, L"\"%ls\" /uninstall /quiet", pRegistration->sczCacheExecutablePath);
799 + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING, L"\"%ls\" /%ls /uninstall /quiet", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM);
800 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING);
801
802 // UninstallString, [path to exe]
803 // If the modify button is to be disabled, we'll add "/modify" to the uninstall string because the button is "Uninstall/Change". Otherwise,
804 // it's just the "Uninstall" button so we add "/uninstall" to make the program just go away.
805 LPCWSTR wzUninstallParameters = (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON == pRegistration->modify) ? L"/modify" : L" /uninstall";
806 - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_UNINSTALL_STRING, L"\"%ls\" %ls", pRegistration->sczCacheExecutablePath, wzUninstallParameters);
806 + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_UNINSTALL_STRING, L"\"%ls\" /%ls %ls", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, wzUninstallParameters);
807 ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_UNINSTALL_STRING);
808
809 if (pRegistration->softwareTags.cSoftwareTags)