From d7b920cae620fd8bdea8613bf1a4a6c2fa0061a5 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 15 Jan 2010 20:14:15 +0000 Subject: [PATCH] Initialize our NPF/Start registry key with the value 3 (SERVICE_DEMAND_START) before possibly changing it to 2 (SERVICE_AUTO_START) at the user's request. This ensures that if the "Start NPF service at boot" option is unchecked, the NPF service will not start at boot, even if WinPcap was previously installed that way. The patch is by Rob Nicholls. --- mswin32/winpcap/winpcap-nmap.nsi | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mswin32/winpcap/winpcap-nmap.nsi b/mswin32/winpcap/winpcap-nmap.nsi index 3b655816d..2b9cbabe0 100644 --- a/mswin32/winpcap/winpcap-nmap.nsi +++ b/mswin32/winpcap/winpcap-nmap.nsi @@ -333,6 +333,16 @@ FunctionEnd ; The stuff to install Section "WinPcap" SecWinPcap + ; stop the service, in case it's still registered, so files can be + ; safely overwritten and the service can be deleted. + nsExec::Exec "net stop npf" + + ; NB: We may need to introduce a check here to ensure that NPF + ; has been stopped before we continue, otherwise we Sleep for a + ; while and try the check again. This might help prevent any race + ; conditions during a silent install (and potentially during the + ; slower GUI installation. + ; These x86 files are automatically redirected to the right place on x64 SetOutPath $SYSDIR File pthreadVC.dll @@ -398,13 +408,13 @@ Section "WinPcap" SecWinPcap npfdone: - ; stop the service, in case it's still registered, so it can be deleted - nsExec::Exec "net stop npf" - ; register the driver as a system service using Windows API calls ; this will work on Windows 2000 (that lacks sc.exe) and higher Call registerServiceAPI + ; Create the default NPF startup setting of 3 (SERVICE_DEMAND_START) + WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\NPF" "Start" 3 + ; automatically start the service if performing a silent install, unless ; /NPFSTARTUP=NO was given. IfSilent 0 skip_auto_start