Skip to content

Commit

Permalink
Made the loopback feature optional in the installer suggested by Mark…
Browse files Browse the repository at this point in the history
…pizz.
  • Loading branch information
hsluoyz committed Mar 1, 2016
1 parent 7635d1a commit 66846a9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 18 deletions.
43 changes: 35 additions & 8 deletions installer/NPcap-for-nmap.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Var /GLOBAL os_ver
Var /GLOBAL admin_only
Var /GLOBAL winpcap_mode
Var /GLOBAL driver_name
Var /GLOBAL loopback_support
Var /GLOBAL dlt_null
Var /GLOBAL vlan_support
Var /GLOBAL restore_point_support
Expand Down Expand Up @@ -204,6 +205,7 @@ Function .onInit
do_silent:
SetSilent silent
StrCpy $admin_only "no"
StrCpy $loopback_support "yes"
StrCpy $dlt_null "no"
StrCpy $vlan_support "yes"
StrCpy $restore_point_support "no"
Expand Down Expand Up @@ -352,15 +354,28 @@ FunctionEnd
Function adminOnlyOptionsPage
IfFileExists "$SYSDIR\wpcap.dll" winpcap_exist no_winpcap_exist
winpcap_exist:
WriteINIStr "$PLUGINSDIR\options_admin_only.ini" "Field 6" "Text" "Npcap detected you have installed WinPcap, in order to Install Npcap \r\nin WinPcap API-compatible Mode, you must uninstall WinPcap first."
WriteINIStr "$PLUGINSDIR\options_admin_only.ini" "Field 5" "State" 0
WriteINIStr "$PLUGINSDIR\options_admin_only.ini" "Field 5" "Flags" "DISABLED"
WriteINIStr "$PLUGINSDIR\options_admin_only.ini" "Field 7" "Text" "Npcap detected you have installed WinPcap, in order to Install Npcap \r\nin WinPcap API-compatible Mode, you must uninstall WinPcap first."
WriteINIStr "$PLUGINSDIR\options_admin_only.ini" "Field 6" "State" 0
WriteINIStr "$PLUGINSDIR\options_admin_only.ini" "Field 6" "Flags" "DISABLED"
no_winpcap_exist:
!insertmacro MUI_HEADER_TEXT "Installation Options" "Please review the following options before installing Npcap ${VERSION}"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "options_admin_only.ini"
FunctionEnd

Function doAdminOnlyOptions
ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Settings" "State"
${If} $0 == 2
ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 2" "State"
${If} $0 == "0"
ReadINIStr $1 "$PLUGINSDIR\options_admin_only.ini" "Field 3" "HWND"
EnableWindow $1 0
${Else}
ReadINIStr $1 "$PLUGINSDIR\options_admin_only.ini" "Field 3" "HWND"
EnableWindow $1 1
${EndIf}
abort
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 1" "State"
${If} $0 == "0"
StrCpy $admin_only "no" ; by default
Expand All @@ -369,27 +384,35 @@ Function doAdminOnlyOptions
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 2" "State"
${If} $0 == "0"
StrCpy $loopback_support "no"
StrCpy $dlt_null "no" ; if even loopback feature is not enabled, there's no need to care whether it's DLT_NULL or not
${Else}
StrCpy $loopback_support "yes" ; by default
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 3" "State"
${If} $0 == "0"
StrCpy $dlt_null "no" ; by default
${Else}
StrCpy $dlt_null "yes"
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 3" "State"
ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 4" "State"
${If} $0 == "0"
StrCpy $vlan_support "no"
${Else}
StrCpy $vlan_support "yes" ; by default
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 4" "State"
ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 5" "State"
${If} $0 == "0"
StrCpy $restore_point_support "no" ; by default
${Else}
StrCpy $restore_point_support "yes"
${EndIf}

ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 5" "State"
ReadINIStr $0 "$PLUGINSDIR\options_admin_only.ini" "Field 6" "State"
${If} $0 == "0"
StrCpy $winpcap_mode "no"
StrCpy $driver_name "npcap"
Expand Down Expand Up @@ -462,8 +485,12 @@ FunctionEnd

Function registerServiceAPI_win7
; delete the npf service to avoid an error message later if it already exists
; create the Npcap Loopback Adapter, used for capturing loopback packets
ExecWait '"$INSTDIR\NPFInstall.exe" -il'

${If} $loopback_support == "yes"
; create the Npcap Loopback Adapter, used for capturing loopback packets
ExecWait '"$INSTDIR\NPFInstall.exe" -il'
${Endif}

; install the WFP callout driver
ExecWait '"$INSTDIR\NPFInstall.exe" -iw' $0
; install the NDIS filter driver
Expand Down
30 changes: 20 additions & 10 deletions installer/options_admin_only.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Settings]
NumFields=5
NumFields=7

[Field 1]
Type=CheckBox
Expand All @@ -16,39 +16,49 @@ Left=10
Right=-1
Top=35
Bottom=43
Text=Use DLT_NULL protocol as loopback packets' link layer instead of Ethernet II
State=0
Text=Support loopback traffic, an interface named "Npcap Loopback Adapter" will be created
State=1
Flags=NOTIFY
[Field 3]
Type=CheckBox
Left=10
Right=-1
Top=50
Bottom=58
Text=Support 802.1Q VLAN tag when capturing and sending data
State=1
Text=Use DLT_NULL protocol as loopback packets' link layer instead of Ethernet II
State=0

[Field 4]
Type=CheckBox
Left=10
Right=-1
Top=65
Bottom=73
Text=Create a system restore point before installing Npcap
State=0
Text=Support 802.1Q VLAN tag when capturing and sending data
State=1

[Field 5]
Type=CheckBox
Left=10
Right=-1
Top=80
Bottom=88
Text=Create a system restore point before installing Npcap
State=0

[Field 6]
Type=CheckBox
Left=10
Right=-1
Top=95
Bottom=103
Text=Install Npcap in WinPcap API-compatible Mode
State=1

[Field 6]
[Field 7]
Type=Label
Left=10
Right=-1
Top=95
Bottom=115
Top=110
Bottom=130

0 comments on commit 66846a9

Please sign in to comment.