win32: add detection of Npcap to Windows installer
authorPascal Quantin <pascal.quantin@gmail.com>
Sat, 22 Aug 2015 18:08:31 +0000 (20:08 +0200)
committerAnders Broman <a.broman58@gmail.com>
Tue, 25 Aug 2015 07:26:12 +0000 (07:26 +0000)
If Npcap is installed without WinPcap API-compatible mode, propose to install WinPcap
If Npcap is installed with WinPcap API-compatible mode, do not allow to install Winpcap without manually uninstalling Npcap first

Change-Id: I606f8b11c950fd54cf7fdda7f4a1886cc2580d31
Reviewed-on: https://code.wireshark.org/review/10197
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Yang Luo <hsluoyz@sohu.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
packaging/nsis/uninstall.nsi
packaging/nsis/wireshark.nsi

index d65d30c67ab4185f64cc91cbe79192fcab80496f..9da64fc2e6e70eb752063b87c8af828433414617 100755 (executable)
@@ -296,10 +296,12 @@ Section /o "Un.WinPcap" un.SecWinPcap
 SectionIn 2
 ReadRegStr $1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" "UninstallString"
 ;IfErrors un.lbl_winpcap_notinstalled ;if RegKey is unavailable, WinPcap is not installed
-;MessageBox MB_OK "WinPcap $1" /SD IDOK
-ExecWait '$1' $0
-DetailPrint "WinPcap uninstaller returned $0"
-;SetRebootFlag true
+${If} $1 != ""
+    ;MessageBox MB_OK "WinPcap $1" /SD IDOK
+    ExecWait '$1' $0
+    DetailPrint "WinPcap uninstaller returned $0"
+    ;SetRebootFlag true
+${EndIf}
 ;un.lbl_winpcap_notinstalled:
 SectionEnd
 
index a8ef88dc0462cce2604a10065cee938a3e6052fb..77b323475adb7f74d6811d6805f8d7b8d25d0753 100644 (file)
@@ -804,7 +804,7 @@ IfSilent SecRequired_skip_Winpcap
 ; Install WinPcap (depending on winpcap page setting)
 ReadINIStr $0 "$PLUGINSDIR\WinPcapPage.ini" "Field 4" "State"
 StrCmp $0 "0" SecRequired_skip_Winpcap
-; Uinstall old WinPcap first
+; Uninstall old WinPcap first
 ReadRegStr $WINPCAP_UNINSTALL HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" "UninstallString"
 IfErrors lbl_winpcap_notinstalled ;if RegKey is unavailable, WinPcap is not installed
 ; from released version 3.1, WinPcap will uninstall an old version by itself
@@ -1168,6 +1168,7 @@ FunctionEnd
 
 Var WINPCAP_NAME ; DisplayName from WinPcap installation
 Var WINWINPCAP_VERSION ; DisplayVersion from WinPcap installation
+Var NPCAP_NAME ; DisplayName from Npcap installation
 
 Function myShowCallback
 
@@ -1188,6 +1189,9 @@ Function myShowCallback
     WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 4" "Text" "Install WinPcap ${PCAP_DISPLAY_VERSION}"
     ReadRegStr $WINPCAP_NAME HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" "DisplayName"
     IfErrors 0 lbl_winpcap_installed ;if RegKey is available, WinPcap is already installed
+    ; check also if Npcap is installed
+    ReadRegStr $NPCAP_NAME HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NpcapInst" "DisplayName"
+    IfErrors 0 lbl_npcap_installed
     WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 2" "Text" "WinPcap is currently not installed"
     WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 2" "Flags" "DISABLED"
     WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 5" "Text" "(Use Add/Remove Programs first to uninstall any undetected old WinPcap versions)"
@@ -1215,6 +1219,24 @@ lbl_winpcap_installed:
     WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 5" "Flags" "DISABLED"
     Goto lbl_winpcap_done
 
+lbl_npcap_installed:
+    ReadRegDWORD $0 HKEY_LOCAL_MACHINE "SOFTWARE\Npcap" "WinPcapCompatible"
+    WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 1" "Text" "Currently installed Npcap version"
+    ${If} $0 == "0"
+        ; Npcap is installed without WinPcap API-compatible mode; WinPcap can be installed
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 2" "Text" "$NPCAP_NAME is currently installed without WinPcap API-compatible mode"
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 4" "State" "1"
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 5" "Text" "(Use Add/Remove Programs first to uninstall any undetected old WinPcap versions)"
+    ${Else}
+        ; Npcap is installed with WinPcap API-compatible mode; WinPcap must not be installed
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 2" "Text" "$NPCAP_NAME"
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 4" "State" "0"
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 4" "Flags" "DISABLED"
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 5" "Text" "If you wish to install WinPcap ${PCAP_DISPLAY_VERSION}, please uninstall $NPCAP_NAME manually first."
+        WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 5" "Flags" "DISABLED"
+    ${EndIf}
+    Goto lbl_winpcap_done
+
 lbl_winpcap_do_install:
     ; seems to be an old version, install newer one
     WriteINIStr "$PLUGINSDIR\WinPcapPage.ini" "Field 4" "State" "1"