From 5815688519a60e63e18c13dfe0908d76757cbc53 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 Aug 2021 15:38:46 -0500 Subject: Update Burn ARP command lines to skip clean room. This also adds an escape hatch to Burn for antivirus interfering with clean room. --- src/burn/engine/core.cpp | 27 ++++++++++++++++----------- src/burn/engine/engine.cpp | 3 +-- src/burn/engine/registration.cpp | 6 +++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index f71103a8..0468d406 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -1375,7 +1375,11 @@ extern "C" HRESULT CoreParseCommandLine( } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM), BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM))) { - if (BURN_MODE_UNTRUSTED != *pMode) + if (BURN_MODE_UNTRUSTED == *pMode) + { + *pMode = BURN_MODE_NORMAL; + } + else { fInvalidCommandLine = TRUE; TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided."); @@ -1383,17 +1387,18 @@ extern "C" HRESULT CoreParseCommandLine( // Get a pointer to the next character after the switch. LPCWSTR wzParam = &argv[i][1 + lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM)]; - if (L'=' != wzParam[0] || L'\0' == wzParam[1]) - { - fInvalidCommandLine = TRUE; - TraceLog(E_INVALIDARG, "Missing required parameter for switch: %ls", BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); - } - else + if (L'\0' != wzParam[0]) { - *pMode = BURN_MODE_NORMAL; - - hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0); - ExitOnFailure(hr, "Failed to copy source process path."); + if (L'=' != wzParam[0]) + { + fInvalidCommandLine = TRUE; + TraceLog(E_INVALIDARG, "Invalid switch: %ls", argv[i]); + } + else if (L'\0' != wzParam[1]) + { + hr = StrAllocString(psczSourceProcessPath, wzParam + 1, 0); + ExitOnFailure(hr, "Failed to copy source process path."); + } } } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_EMBEDDED, -1)) diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp index 4323b540..e6cb1708 100644 --- a/src/burn/engine/engine.cpp +++ b/src/burn/engine/engine.cpp @@ -71,8 +71,7 @@ extern "C" BOOL EngineInCleanRoom( // that should be setting this command line option, that is in our control. BOOL fInCleanRoom = (wzCommandLine && (wzCommandLine[0] == L'-' || wzCommandLine[0] == L'/') && - CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzCommandLine + 1, cchCleanRoomSwitch, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, cchCleanRoomSwitch) && - wzCommandLine[1 + cchCleanRoomSwitch] == L'=' + CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzCommandLine + 1, cchCleanRoomSwitch, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, cchCleanRoomSwitch) ); return fInCleanRoom; diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index 147865fa..0a8fb602 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp @@ -773,7 +773,7 @@ extern "C" HRESULT RegistrationSessionBegin( else if (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON != pRegistration->modify) // if support modify (aka: did not disable anything) { // ModifyPath: [path to exe] /modify - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_MODIFY_PATH, L"\"%ls\" /modify", pRegistration->sczCacheExecutablePath); + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_MODIFY_PATH, L"\"%ls\" /%ls /modify", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_MODIFY_PATH); // NoElevateOnModify: 1 @@ -796,14 +796,14 @@ extern "C" HRESULT RegistrationSessionBegin( } // QuietUninstallString: [path to exe] /uninstall /quiet - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING, L"\"%ls\" /uninstall /quiet", pRegistration->sczCacheExecutablePath); + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING, L"\"%ls\" /%ls /uninstall /quiet", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM); ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING); // UninstallString, [path to exe] // If the modify button is to be disabled, we'll add "/modify" to the uninstall string because the button is "Uninstall/Change". Otherwise, // it's just the "Uninstall" button so we add "/uninstall" to make the program just go away. LPCWSTR wzUninstallParameters = (BURN_REGISTRATION_MODIFY_DISABLE_BUTTON == pRegistration->modify) ? L"/modify" : L" /uninstall"; - hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_UNINSTALL_STRING, L"\"%ls\" %ls", pRegistration->sczCacheExecutablePath, wzUninstallParameters); + hr = RegWriteStringFormatted(hkRegistration, REGISTRY_BUNDLE_UNINSTALL_STRING, L"\"%ls\" /%ls %ls", pRegistration->sczCacheExecutablePath, BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, wzUninstallParameters); ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_UNINSTALL_STRING); if (pRegistration->softwareTags.cSoftwareTags) -- cgit v1.2.3-55-g6feb