diff --git a/CHANGELOG b/CHANGELOG index 5c37ad3e8..efcf201d6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,25 @@ # Nmap Changelog ($Id$); -*-text-*- +o Our WinPcap installer now starts the NPF driver running as a + service immediately upon installation and after restarts. You can + disable this with new checkboxes. This behavior is important for + Vista and Windows Server 2008 machines when User Account + Control (UAC) is enabled. [Rob Nicholls] + +o Nmap and Nmap-Winpcap silent installation now works. Nmap can + be silently installed with the /S option to the installer. + If you install Nmap from the zip file, you can install just + Winpcap silently with the /S option to that + installer. [Rob Nicholls] + +o Our WinPcap installer is now included with the Nmap Win32 zip + file. [Rob Nicholls] + +o Numerous miscellaneous improvements were made to our Win32 + installer, such as using the "Modern" NSIS UI for WinPcap, + improving the option description labels, and showing a finish + page in all cases. [Rob Nicholls] + o Fixed bug that prevented the R1.UID OS from being recorded properly when scanning some certain printers on little endian computers. Updated nmap-os-db to compensate for signatures that had an incorrect U1.RID value. diff --git a/mswin32/Makefile b/mswin32/Makefile index ed23a641a..1f3922344 100644 --- a/mswin32/Makefile +++ b/mswin32/Makefile @@ -28,12 +28,12 @@ winbuild: mkdir nmap-$(NMAP_VERSION)/nselib cp -a Release/nselib nmap-$(NMAP_VERSION) cp -a Release/nselib-bin nmap-$(NMAP_VERSION) - zip -r nmap-$(NMAP_VERSION)-win32.zip nmap-$(NMAP_VERSION) cp winpcap/winpcap-nmap-*.exe nmap-$(NMAP_VERSION) + zip -r nmap-$(NMAP_VERSION)-win32.zip nmap-$(NMAP_VERSION) mkdir nmap-$(NMAP_VERSION)/zenmap cd ../zenmap && install_scripts/windows/copy_and_compile.bat cp -R ../zenmap/dist/* ../zenmap/COPYING* ../zenmap/README nmap-$(NMAP_VERSION)/zenmap - cp nsis/AddToPath.nsh nsis/Nmap.nsi nsis/shortcuts.ini nmap-$(NMAP_VERSION) + cp nsis/AddToPath.nsh nsis/Nmap.nsi nsis/shortcuts.ini nsis/final.ini nmap-$(NMAP_VERSION) $(MAKENSIS) nmap-$(NMAP_VERSION)/Nmap.nsi mv nmap-$(NMAP_VERSION)/NmapInstaller.exe nmap-$(NMAP_VERSION)-setup.exe diff --git a/mswin32/nsis/Nmap.nsi b/mswin32/nsis/Nmap.nsi index 6785d5708..885d20d28 100644 --- a/mswin32/nsis/Nmap.nsi +++ b/mswin32/nsis/Nmap.nsi @@ -14,7 +14,7 @@ Name "Nmap" OutFile "NmapInstaller.exe" - ;Required for removing shortcuts (http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista) + ;Required for removing shortcuts RequestExecutionLevel admin ;Default installation folder @@ -41,15 +41,14 @@ ;-------------------------------- ;Pages -; !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" !insertmacro MUI_PAGE_LICENSE "..\LICENSE" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES - !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES Page custom shortcutsPage makeShortcuts + Page custom finalPage doFinal ;-------------------------------- ;Languages @@ -65,6 +64,7 @@ Var zenmapset ;Reserves ReserveFile "shortcuts.ini" +ReserveFile "final.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;-------------------------------- @@ -72,6 +72,7 @@ ReserveFile "shortcuts.ini" Function .onInit !insertmacro MUI_INSTALLOPTIONS_EXTRACT "shortcuts.ini" + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "final.ini" FunctionEnd @@ -105,6 +106,16 @@ Function makeShortcuts skip: FunctionEnd +Function finalPage + ; diplay a page saying everything's finished + !insertmacro MUI_HEADER_TEXT "Finished" "Thank you for installing Nmap" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "final.ini" +FunctionEnd + +Function doFinal + ; don't need to do anything +FunctionEnd + ;-------------------------------- ;Installer Sections @@ -189,37 +200,51 @@ Section "Register Nmap Path" SecRegisterPath SectionEnd Section "WinPcap 4.02" SecWinPcap + SetOutPath "$INSTDIR" + SetOverwrite on File ..\winpcap\winpcap-nmap-4.02.exe - Exec '"$INSTDIR\winpcap-nmap-4.02.exe"' + ; If the Nmap installer was launched using /S then pass some arguments to WinPcap + IfSilent winpcap_silent winpcap_loud + winpcap_silent: + ExecWait '"$INSTDIR\winpcap-nmap-4.02.exe" /S /D=$\""$PROGRAMFILES\WinPcap\"$\"' + Goto delete_winpcap + winpcap_loud: + ExecWait '"$INSTDIR\winpcap-nmap-4.02.exe"' + delete_winpcap: Delete "$INSTDIR\winpcap-nmap-4.02.exe" SectionEnd - -Section "Network Performance Improvements (Registry Changes)" SecPerfRegistryMods + +Section "Network Performance Improvements" SecPerfRegistryMods + SetOutPath "$INSTDIR" + SetOverwrite on File ..\nmap_performance.reg Exec 'regedt32 /S "$INSTDIR\nmap_performance.reg"' SectionEnd -Section "Zenmap (GUI frontend)" SecZenmap +Section "Zenmap (GUI Frontend)" SecZenmap + SetOutPath "$INSTDIR" + SetOverwrite on File /r /x mswin32 /x .svn ..\nmap-${VERSION}\zenmap StrCpy $zenmapset "true" SectionEnd - ;-------------------------------- ;Descriptions ;Component strings - LangString DESC_SecCore ${LANG_ENGLISH} "Installs Nmap executables and script files" + LangString DESC_SecCore ${LANG_ENGLISH} "Installs Nmap executable and NSE scripts" LangString DESC_SecRegisterPath ${LANG_ENGLISH} "Registers Nmap path to System path so you can execute it from any directory" LangString DESC_SecWinPcap ${LANG_ENGLISH} "Installs WinPcap 4.0 (required for most Nmap scans unless it is already installed)" LangString DESC_SecPerfRegistryMods ${LANG_ENGLISH} "Modifies Windows registry values to improve TCP connect scan performance. Recommended." - + LangString DESC_SecZenmap ${LANG_ENGLISH} "Installs Zenmap, the official Nmap graphical user interface. Recommended." + ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore) !insertmacro MUI_DESCRIPTION_TEXT ${SecWinPcap} $(DESC_SecWinPcap) !insertmacro MUI_DESCRIPTION_TEXT ${SecRegisterPath} $(DESC_SecRegisterPath) !insertmacro MUI_DESCRIPTION_TEXT ${SecPerfRegistryMods} $(DESC_SecPerfRegistryMods) + !insertmacro MUI_DESCRIPTION_TEXT ${SecZenmap} $(DESC_SecZenmap) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section diff --git a/mswin32/nsis/final.ini b/mswin32/nsis/final.ini new file mode 100644 index 000000000..54104cf1f --- /dev/null +++ b/mswin32/nsis/final.ini @@ -0,0 +1,23 @@ +[Settings] +NumFields=2 +BackEnabled=0 +NextButtonText=Finish + +[Field 1] +Type=Label +Left=10 +Right=-1 +Top=10 +Bottom=18 +Text=Nmap has been installed on your computer. +State=0 + +[Field 2] +Type=Label +Left=10 +Right=-1 +Top=30 +Bottom=38 +Text=Click Finish to close this wizard. +State=0 + diff --git a/mswin32/winpcap/Upgrading-Instructions.txt b/mswin32/winpcap/Upgrading-Instructions.txt index a4fc10464..f21bc50dc 100644 --- a/mswin32/winpcap/Upgrading-Instructions.txt +++ b/mswin32/winpcap/Upgrading-Instructions.txt @@ -1,79 +1,79 @@ -How to upgrade Nmap to a new WinPcap release (2007) ---------------------------------------------------- - -1) Download the latest version of WinPcap from www.winpcap.org and make - a note of the version (for example 4.0). - -2) Remove all instances of WinPcap (through Add/Remove Programs), then - install the new version. - - 2a) Update the LICENSE file, if necessary. I couldn't find a plain - WinPcap license file anywhere. There's an HTML version at - http://www.winpcap.org/misc/copyright.htm. You can copy and paste - the license text from the installer into the LICENSE file. - -3) Copy the installed files into the mswin32/winpcap directory. The - installed files at time of writing are - - C:\Program Files\WinPcap\rpcapd.exe - C:\Windows\system32\Packet.dll - C:\Windows\system32\pthreadVC.dll - C:\Windows\system32\WanPacket.dll - C:\Windows\system32\wpcap.dll - C:\Windows\system32\drivers\npf.sys - -4) Copy the Vista version of Packet.dll. This is tricky because there - are several (three, as of this writing) versions of Packet.dll in the - installer but only one is installed at a time. You can see all the - versions by opening the installer with 7-Zip (http://www.7-zip.org/). - Select the installer within 7-Zip and click "File", "Open Inside". - Enter the $SYSDIR subdirectory. One by one, extract (you can drag and - drop) the copies of Packet.dll somewhere. Right-click on each - Packet.dll, click "Properties", then select the "Version" tab. The - "Description:" field will have a string containing "NT4", "NT5", or - "Vista". When you find the Vista file copy it to vista/Packet.dll. - -5) Open winpcap-nmap.nsi. - 5a) Change the version for the following lines: - - Name "winpcap-nmap-X.X" - OutFile "winpcap-nmap-X.X.exe - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "DisplayName" "winpcap-nmap X.X" - - 5b) Get the internal 'FileVersion' from wpcap.dll. Right-click on - wpcap.dll and select "Properties", then select the "Version" tab. - Copy the number there into this part of winpcap-nmap.nsi: - - var /GLOBAL my_ver - StrCpy $my_ver "X.X.X.X" <-- file version goes here - -6) Generate installer exe by compiling winpcap-nmap.nsi using the - running the command - makensis winpcap-nmap.nsi - makensis is part of the "Nullsoft Scriptable Install System" at - http://nsis.sourceforge.net/. - -7) Give the installer a test, make sure the correct version appears in - the installer's name and in Add/Remove Programs. You may also want to - try installing it when it is already installed or an older version is - installed. - -8) Open mswin32/nsis/Nmap.nsi and update the references to the winpcap - installer's name. You should only have to change the version number. - The section you need to look at starts like this: - Section "WinPcap X.X" SecWinPcap - -9) Download the WinPcap developer package - (http://www.winpcap.org/devel.htm) and replace all the files in - mswin32/lib/ with the new versions inside the package. - -10) Build the Nmap installer. The best way to do this is to run "make" in - the mswin32 directory. This will build Nmap and run makensis for you. - Test the installer. You may want to try it with Nmap already - installed and with different versions installed. Also check that - everything appears in Add/Remove Programs correctly. - -11) Test Nmap functionallity that uses WinPcap (raw packet scans, raw - packet pings, traceroute). - -12) Sit back and have a cup of coffee, you deserve it :) +How to upgrade Nmap to a new WinPcap release (2007) +--------------------------------------------------- + +1) Download the latest version of WinPcap from www.winpcap.org and make + a note of the version (for example 4.0). + +2) Remove all instances of WinPcap (through Add/Remove Programs), then + install the new version. + + 2a) Update the LICENSE file, if necessary. I couldn't find a plain + WinPcap license file anywhere. There's an HTML version at + http://www.winpcap.org/misc/copyright.htm. You can copy and paste + the license text from the installer into the LICENSE file. + +3) Copy the installed files into the mswin32/winpcap directory. The + installed files at time of writing are + + C:\Program Files\WinPcap\rpcapd.exe + C:\Windows\system32\Packet.dll + C:\Windows\system32\pthreadVC.dll + C:\Windows\system32\WanPacket.dll + C:\Windows\system32\wpcap.dll + C:\Windows\system32\drivers\npf.sys + +4) Copy the Vista version of Packet.dll. This is tricky because there + are several (three, as of this writing) versions of Packet.dll in the + installer but only one is installed at a time. You can see all the + versions by opening the installer with 7-Zip (http://www.7-zip.org/). + Select the installer within 7-Zip and click "File", "Open Inside". + Enter the $SYSDIR subdirectory. One by one, extract (you can drag and + drop) the copies of Packet.dll somewhere. Right-click on each + Packet.dll, click "Properties", then select the "Version" tab. The + "Description:" field will have a string containing "NT4", "NT5", or + "Vista". When you find the Vista file copy it to vista/Packet.dll. + +5) Open winpcap-nmap.nsi. + 5a) Change the version for the following lines: + + Name "WinPcap (Nmap) X.X" + OutFile "winpcap-nmap-X.X.exe + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "DisplayName" "winpcap-nmap X.X" + + 5b) Get the internal 'FileVersion' from wpcap.dll. Right-click on + wpcap.dll and select "Properties", then select the "Version" tab. + Copy the number there into this part of winpcap-nmap.nsi: + + var /GLOBAL my_ver + StrCpy $my_ver "X.X.X.X" <-- file version goes here + +6) Generate installer exe by compiling winpcap-nmap.nsi using the + running the command + makensis winpcap-nmap.nsi + makensis is part of the "Nullsoft Scriptable Install System" at + http://nsis.sourceforge.net/. + +7) Give the installer a test, make sure the correct version appears in + the installer's name and in Add/Remove Programs. You may also want to + try installing it when it is already installed or an older version is + installed. + +8) Open mswin32/nsis/Nmap.nsi and update the references to the winpcap + installer's name. You should only have to change the version number. + The section you need to look at starts like this: + Section "WinPcap X.X" SecWinPcap + +9) Download the WinPcap developer package + (http://www.winpcap.org/devel.htm) and replace all the files in + mswin32/lib/ with the new versions inside the package. + +10) Build the Nmap installer. The best way to do this is to run "make" in + the mswin32 directory. This will build Nmap and run makensis for you. + Test the installer. You may want to try it with Nmap already + installed and with different versions installed. Also check that + everything appears in Add/Remove Programs correctly. + +11) Test Nmap functionallity that uses WinPcap (raw packet scans, raw + packet pings, traceroute). + +12) Sit back and have a cup of coffee, you deserve it :) diff --git a/mswin32/winpcap/final.ini b/mswin32/winpcap/final.ini new file mode 100644 index 000000000..5e67df2aa --- /dev/null +++ b/mswin32/winpcap/final.ini @@ -0,0 +1,23 @@ +[Settings] +NumFields=2 +BackEnabled=0 +NextButtonText=Finish + +[Field 1] +Type=Label +Left=10 +Right=-1 +Top=10 +Bottom=18 +Text=WinPcap has been installed on your computer. +State=0 + +[Field 2] +Type=Label +Left=10 +Right=-1 +Top=30 +Bottom=38 +Text=Click Finish to close this wizard. +State=0 + diff --git a/mswin32/winpcap/options.ini b/mswin32/winpcap/options.ini new file mode 100644 index 000000000..bb7d08a3c --- /dev/null +++ b/mswin32/winpcap/options.ini @@ -0,0 +1,20 @@ +[Settings] +NumFields=2 + +[Field 1] +Type=CheckBox +Left=10 +Right=-1 +Top=20 +Bottom=28 +Text=Start the WinPcap service 'NPF' at startup (recommended on Windows Vista) +State=1 + +[Field 2] +Type=CheckBox +Left=10 +Right=-1 +Top=10 +Bottom=18 +Text=Start the WinPcap service 'NPF' now +State=1 diff --git a/mswin32/winpcap/winpcap-nmap.nsi b/mswin32/winpcap/winpcap-nmap.nsi index 88882b199..a54e9e6ea 100644 --- a/mswin32/winpcap/winpcap-nmap.nsi +++ b/mswin32/winpcap/winpcap-nmap.nsi @@ -1,157 +1,248 @@ -;; Custom winpcap for nmap -;; Started by Doug Hoyte, April 2006 - -;; Eddie Bell -;; Updated to 4.0, June 2007 -;; Updated to 4.01, July 2007 -;; Updated to 4.02, November 2007 - -;-------------------------------- - -; The name of the installer -Name "winpcap-nmap-4.02" - -; The file to write -OutFile "winpcap-nmap-4.02.exe" - -; The default installation directory -InstallDir $PROGRAMFILES\WinPcap - -LicenseText "Winpcap License" -LicenseData "LICENSE" - -;-------------------------------- - -Page license -Page directory -Page instfiles - -UninstPage uninstConfirm -UninstPage instfiles - -;-------------------------------- - -; This function is called on startup. IfSilent checks -; if the flag /S was specified. If so, it sets the installer -; to run in "silent mode" which displays no windows and accepts -; all defaults. - -; We also check if there is a previously installed winpcap -; on this system. If it's the same as the version we're installing, -; abort the install. If not, prompt the user about whether to -; replace it or not. - -Function .onInit - var /GLOBAL inst_ver - var /GLOBAL my_ver - StrCpy $my_ver "4.0.0.1040" - - IfSilent do_silent no_silent - - do_silent: - SetSilent silent - IfFileExists "$SYSDIR\wpcap.dll" finish - return - - no_silent: - - IfFileExists "$SYSDIR\wpcap.dll" do_version_check - return - - do_version_check: - - GetDllVersion "$SYSDIR\wpcap.dll" $R0 $R1 - IntOp $R2 $R0 / 0x00010000 - IntOp $R3 $R0 & 0x0000FFFF - IntOp $R4 $R1 / 0x00010000 - IntOp $R5 $R1 & 0x0000FFFF - StrCpy $inst_ver "$R2.$R3.$R4.$R5" - - StrCmp $inst_ver $my_ver same_ver - - MessageBox MB_YESNO|MB_ICONQUESTION "WinPcap version $inst_ver exists on this system. Replace with version $my_ver?" IDYES finish - quit - - same_ver: - MessageBox MB_OK "Skipping WinPcap installation since version $inst_ver already exists on this system. Uninstall that version first if you wish to force install." - quit - - finish: - ReadRegStr $0 "HKLM" "Software\WinPcap" "" - - IfFileExists "$0\Uninstall.exe" run_uninstaller - return - - run_uninstaller: - ExecWait '"$0\Uninstall.exe" _?=$INSTDIR' - -FunctionEnd - -;-------------------------------- - -; The stuff to install -Section "" ;No components page, name is not important - - ; Set output path to the installation directory. - SetOutPath $INSTDIR - - ; Put file there - File rpcapd.exe - File LICENSE - - WriteUninstaller "uninstall.exe" - - SetOutPath $SYSDIR - - File pthreadVC.dll - File wpcap.dll - - ; Check windows version - ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion - StrCmp $R0 '6.0' vista_files - - File Packet.dll - File WanPacket.dll - Goto install - - vista_files: - File vista\Packet.dll - - install: - SetOutPath $SYSDIR\drivers - - File npf.sys - - ; Install some basic registry keys - WriteRegStr HKLM "Software\WinPcap" "" '"$INSTDIR"' - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "DisplayName" "winpcap-nmap 4.02" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "NoRepair" 1 - -SectionEnd ; end the section - - -;-------------------------------- - -Section "Uninstall" - - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" - DeleteRegKey HKLM "Software\WinPcap" - - Delete $INSTDIR\rpcapd.exe - Delete $INSTDIR\LICENSE - Delete $INSTDIR\uninstall.exe - - Delete $SYSDIR\Packet.dll - Delete $SYSDIR\pthreadVC.dll - Delete $SYSDIR\WanPacket.dll - Delete $SYSDIR\wpcap.dll - - Delete $SYSDIR\drivers\npf.sys - - RMDir "$INSTDIR" - -SectionEnd +;; Custom winpcap for nmap +;; Started by Doug Hoyte, April 2006 + +;; Eddie Bell +;; Updated to 4.0, June 2007 +;; Updated to 4.01, July 2007 +;; Updated to 4.02, November 2007 + +;-------------------------------- +;Include Modern UI + + !include "MUI.nsh" + +;-------------------------------- +;General + +; The name of the installer +Name "WinPcap (Nmap) 4.0.2" + +; The file to write +OutFile "winpcap-nmap-4.02.exe" + +RequestExecutionLevel admin + +; The default installation directory +InstallDir $PROGRAMFILES\WinPcap + +;Get installation folder from registry if available +InstallDirRegKey HKLM "Software\WinPcap" "" + +VIProductVersion "4.0.0.1040" +VIAddVersionKey /LANG=1033 "FileVersion" "4.0.0.1040" +VIAddVersionKey /LANG=1033 "ProductName" "WinPcap" +VIAddVersionKey /LANG=1033 "FileDescription" "WinPcap 4.0.2 installer" +VIAddVersionKey /LANG=1033 "LegalCopyright" "" + + +;-------------------------------- +;Interface Settings + + !define MUI_ABORTWARNING + +;-------------------------------- +;Pages + +!insertmacro MUI_PAGE_LICENSE "LICENSE" +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +Page custom optionsPage doOptions +Page custom finalPage doFinal + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Reserves + +ReserveFile "options.ini" +ReserveFile "final.ini" +!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS + +;-------------------------------- + +; This function is called on startup. IfSilent checks +; if the flag /S was specified. If so, it sets the installer +; to run in "silent mode" which displays no windows and accepts +; all defaults. + +; We also check if there is a previously installed winpcap +; on this system. If it's the same as the version we're installing, +; abort the install. If not, prompt the user about whether to +; replace it or not. + +Function .onInit + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "options.ini" + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "final.ini" + + var /GLOBAL inst_ver + var /GLOBAL my_ver + StrCpy $my_ver "4.0.0.1040" + + IfSilent do_silent no_silent + + do_silent: + SetSilent silent + IfFileExists "$SYSDIR\wpcap.dll" finish + return + + no_silent: + + IfFileExists "$SYSDIR\wpcap.dll" do_version_check + return + + do_version_check: + + GetDllVersion "$SYSDIR\wpcap.dll" $R0 $R1 + IntOp $R2 $R0 / 0x00010000 + IntOp $R3 $R0 & 0x0000FFFF + IntOp $R4 $R1 / 0x00010000 + IntOp $R5 $R1 & 0x0000FFFF + StrCpy $inst_ver "$R2.$R3.$R4.$R5" + + StrCmp $inst_ver $my_ver same_ver + + MessageBox MB_YESNO|MB_ICONQUESTION "WinPcap version $inst_ver exists on this system. Replace with version $my_ver?" IDYES finish + quit + + same_ver: + MessageBox MB_OK "Skipping WinPcap installation since version $inst_ver already exists on this system. Uninstall that version first if you wish to force install." + quit + + finish: + ReadRegStr $0 "HKLM" "Software\WinPcap" "" + + IfFileExists "$0\Uninstall.exe" run_uninstaller + return + + run_uninstaller: + ExecWait '"$0\Uninstall.exe" _?=$INSTDIR' + +FunctionEnd + +Function optionsPage + !insertmacro MUI_HEADER_TEXT "WinPcap Options" "" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "options.ini" +FunctionEnd + +Function doOptions + ReadINIStr $0 "$PLUGINSDIR\options.ini" "Field 1" "State" + StrCmp $0 "0" do_options_end + WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\NPF" "Start" 2 + ReadINIStr $0 "$PLUGINSDIR\options.ini" "Field 2" "State" + StrCmp $0 "0" do_options_end + nsExec::Exec "net start npf" + do_options_end: +FunctionEnd + +Function finalPage + ; diplay a page saying everything's finished + !insertmacro MUI_HEADER_TEXT "Finished" "Thank you for installing WinPcap" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "final.ini" +FunctionEnd + +Function doFinal + ; don't need to do anything +FunctionEnd + +Function registerServiceSC + nsExec::Exec "sc create npf binpath= system32\drivers\npf.sys type= kernel DisplayName= $\"NetGroup Packet Filter Driver$\"" +FunctionEnd + +Function un.registerServiceSC + nsExec::Exec "sc stop npf" +FunctionEnd + +Function autoStartWinPcap + WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\NPF" "Start" 2 + ; silently fails on 2000 if the service isn't registered + nsExec::Exec "net start npf" +FunctionEnd + + +;-------------------------------- +; The stuff to install +Section "WinPcap" SecWinPcap + + ; Set output path to the installation directory. + SetOutPath $INSTDIR + + ; Put file there + File rpcapd.exe + File LICENSE + + WriteUninstaller "uninstall.exe" + + SetOutPath $SYSDIR + + File pthreadVC.dll + File wpcap.dll + + ; Check windows version + ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion + StrCmp $R0 '6.0' vista_files + + File Packet.dll + File WanPacket.dll + Goto install + + vista_files: + File vista\Packet.dll + + install: + SetOutPath $SYSDIR\drivers + + File npf.sys + + ; Install some basic registry keys + WriteRegStr HKLM "Software\WinPcap" "" '"$INSTDIR"' + + ; register the driver as a system service using sc.exe on xp or higher + ; this will silently fail on 2000 (unless they installed sc.exe from the resource kit) + Call registerServiceSC + + ; automatically start the service if performing a silent install + IfSilent auto_start skip_auto_start + auto_start: + Call autoStartWinPcap + skip_auto_start: + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "DisplayName" "winpcap-nmap 4.02" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" "NoRepair" 1 + +SectionEnd ; end the section + + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + + ; unregister the driver as a system service using sc.exe on xp or higher + ; this will silently fail on 2000 (unless they installed sc.exe from the resource kit) + Call un.registerServiceSC + + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\winpcap-nmap" + DeleteRegKey HKLM "Software\WinPcap" + + Delete $INSTDIR\rpcapd.exe + Delete $INSTDIR\LICENSE + Delete $INSTDIR\uninstall.exe + + Delete $SYSDIR\Packet.dll + Delete $SYSDIR\pthreadVC.dll + Delete $SYSDIR\WanPacket.dll + Delete $SYSDIR\wpcap.dll + + Delete $SYSDIR\drivers\npf.sys + + RMDir "$INSTDIR" + +SectionEnd