@joebigelow / wix / commits / 6ce35975

Retry ElevationElevate once if we think it failed due to antivirus interference.

Sean Hall committed Mar 12, 2020 at 16:22 UTC 6ce359752afac0d3d70c2cf5fabd7d92859564ee
4 files changed +15 -5
src/engine/core.cpp
+8 -2
@@ -508,10 +508,11 @@ extern "C" HRESULT CoreElevate(
508 )
509 {
510 HRESULT hr = S_OK;
511 + DWORD cAVRetryAttempts = 0;
512
512 - // If the elevated companion pipe isn't created yet, let's make that happen.
513 - if (INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe)
513 + while (INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe)
514 {
515 + // If the elevated companion pipe isn't created yet, let's make that happen.
516 if (!pEngineState->sczBundleEngineWorkingPath)
517 {
518 hr = CacheBundleToWorkingDirectory(pEngineState->registration.sczId, pEngineState->registration.sczExecutableName, &pEngineState->userExperience.payloads, &pEngineState->section, &pEngineState->sczBundleEngineWorkingPath);
@@ -519,6 +520,11 @@ extern "C" HRESULT CoreElevate(
520 }
521
522 hr = ElevationElevate(pEngineState, hwndParent);
523 + if (E_SUSPECTED_AV_INTERFERENCE == hr && 1 > cAVRetryAttempts)
524 + {
525 + ++cAVRetryAttempts;
526 + continue;
527 + }
528 ExitOnFailure(hr, "Failed to actually elevate.");
529
530 hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, TRUE, TRUE);
src/engine/elevation.cpp
+4
@@ -291,6 +291,10 @@ extern "C" HRESULT ElevationElevate(
291 LogId(REPORT_STANDARD, MSG_LAUNCH_ELEVATED_ENGINE_SUCCESS);
292
293 hr = PipeWaitForChildConnect(&pEngineState->companionConnection);
294 + if (HRESULT_FROM_WIN32(ERROR_NO_DATA) == hr)
295 + {
296 + hr = E_SUSPECTED_AV_INTERFERENCE;
297 + }
298 ExitOnFailure(hr, "Failed to connect to elevated child process.");
299
300 LogId(REPORT_STANDARD, MSG_CONNECT_TO_ELEVATED_ENGINE_SUCCESS);
src/engine/engine.vcxproj
+2 -2
@@ -2,7 +2,7 @@
2 <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4 <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 - <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.11\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.11\build\WixToolset.BootstrapperCore.Native.props')" />
5 + <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.12\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.12\build\WixToolset.BootstrapperCore.Native.props')" />
6 <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" />
7
8 <ItemGroup Label="ProjectConfigurations">
@@ -167,7 +167,7 @@ rc.exe -fo "$(OutDir)engine.res" "$(IntDir)engine.messages.rc"</Command>
167 <PropertyGroup>
168 <ErrorText>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}.</ErrorText>
169 </PropertyGroup>
170 - <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.11\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.11\build\WixToolset.BootstrapperCore.Native.props'))" />
170 + <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.12\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.12\build\WixToolset.BootstrapperCore.Native.props'))" />
171 <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" />
172 <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" />
173 </Target>
src/engine/packages.config
+1 -1
@@ -1,6 +1,6 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <packages>
3 <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" />
4 - <package id="WixToolset.BootstrapperCore.Native" version="4.0.11" targetFramework="native" />
4 + <package id="WixToolset.BootstrapperCore.Native" version="4.0.12" targetFramework="native" />
5 <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" />
6 </packages>
\ No newline at end of file