From 6ce359752afac0d3d70c2cf5fabd7d92859564ee Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 12 Mar 2020 16:22:04 +1100 Subject: Retry ElevationElevate once if we think it failed due to antivirus interference. --- src/engine/core.cpp | 10 ++++++++-- src/engine/elevation.cpp | 4 ++++ src/engine/engine.vcxproj | 4 ++-- src/engine/packages.config | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/engine/core.cpp b/src/engine/core.cpp index 519012e9..10750be8 100644 --- a/src/engine/core.cpp +++ b/src/engine/core.cpp @@ -508,10 +508,11 @@ extern "C" HRESULT CoreElevate( ) { HRESULT hr = S_OK; + DWORD cAVRetryAttempts = 0; - // If the elevated companion pipe isn't created yet, let's make that happen. - if (INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe) + while (INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe) { + // If the elevated companion pipe isn't created yet, let's make that happen. if (!pEngineState->sczBundleEngineWorkingPath) { hr = CacheBundleToWorkingDirectory(pEngineState->registration.sczId, pEngineState->registration.sczExecutableName, &pEngineState->userExperience.payloads, &pEngineState->section, &pEngineState->sczBundleEngineWorkingPath); @@ -519,6 +520,11 @@ extern "C" HRESULT CoreElevate( } hr = ElevationElevate(pEngineState, hwndParent); + if (E_SUSPECTED_AV_INTERFERENCE == hr && 1 > cAVRetryAttempts) + { + ++cAVRetryAttempts; + continue; + } ExitOnFailure(hr, "Failed to actually elevate."); hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, TRUE, TRUE); diff --git a/src/engine/elevation.cpp b/src/engine/elevation.cpp index 1b9336e0..0b96c300 100644 --- a/src/engine/elevation.cpp +++ b/src/engine/elevation.cpp @@ -291,6 +291,10 @@ extern "C" HRESULT ElevationElevate( LogId(REPORT_STANDARD, MSG_LAUNCH_ELEVATED_ENGINE_SUCCESS); hr = PipeWaitForChildConnect(&pEngineState->companionConnection); + if (HRESULT_FROM_WIN32(ERROR_NO_DATA) == hr) + { + hr = E_SUSPECTED_AV_INTERFERENCE; + } ExitOnFailure(hr, "Failed to connect to elevated child process."); LogId(REPORT_STANDARD, MSG_CONNECT_TO_ELEVATED_ENGINE_SUCCESS); diff --git a/src/engine/engine.vcxproj b/src/engine/engine.vcxproj index fecef29e..499fcd4d 100644 --- a/src/engine/engine.vcxproj +++ b/src/engine/engine.vcxproj @@ -2,7 +2,7 @@ - + @@ -167,7 +167,7 @@ rc.exe -fo "$(OutDir)engine.res" "$(IntDir)engine.messages.rc" This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/engine/packages.config b/src/engine/packages.config index f7638ec7..01a9390c 100644 --- a/src/engine/packages.config +++ b/src/engine/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb