From dce8ebd459ecfc16a45dfe68590dcf3708f15e82 Mon Sep 17 00:00:00 2001 From: basil00 Date: Sun, 6 Oct 2013 15:15:59 +0800 Subject: [PATCH] - If driver installation fails, then also attempt to delete the service. This should fix some confusing errors caused by a zombie WinDivert service. --- dll/windivert.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dll/windivert.c b/dll/windivert.c index adb62b7..4650338 100644 --- a/dll/windivert.c +++ b/dll/windivert.c @@ -503,6 +503,7 @@ static BOOLEAN WinDivertDriverInstall(VOID) WDF_COINSTALLER_INSTALL_OPTIONS client_options; LPWSTR windivert_dir = NULL, windivert_sys = NULL, windivert_inf = NULL, windivert_dll = NULL; + SERVICE_STATUS status; // Do nothing if the driver is already installed: if (installed) @@ -535,13 +536,13 @@ static BOOLEAN WinDivertDriverInstall(VOID) if (!WinDivertDriverFiles(&windivert_dir, &windivert_sys, &windivert_inf, &windivert_dll)) { - return FALSE; + goto WinDivertDriverInstallExit; } // Load the co-installer: if (WinDivertLoadCoInstaller(windivert_dll) == NULL) { - return FALSE; + goto WinDivertDriverInstallExit; } // Pre-install: @@ -601,6 +602,12 @@ WinDivertDriverInstallExit: free(windivert_dll); if (service != NULL) { + // Delete the service if there was an error. + if (!installed) + { + ControlService(service, SERVICE_CONTROL_STOP, &status); + DeleteService(service); + } CloseServiceHandle(service); } if (manager != NULL)