Skip to content

Commit 22c0ad3

Browse files
committed
Switched from Winpcap to Npcap driver and added a Npcap driver check
1 parent 766fdaf commit 22c0ad3

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

NetStalker/NetStalker/Forms/Information/ErrorForm.Designer.cs

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NetStalker/NetStalker/Forms/Information/ErrorForm.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private void MaterialFlatButton1_Click(object sender, EventArgs e)
2323

2424
private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
2525
{
26-
Process.Start("https://www.winpcap.org/install/bin/WinPcap_4_1_3.exe");
26+
Process.Start("https://nmap.org/download.html");
2727
}
2828

2929
private void ErrorForm_Load(object sender, EventArgs e)

NetStalker/NetStalker/Forms/Main/NicSelection.cs

+33-23
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
using SharpPcap.Npcap;
88
using System;
99
using System.Collections.Generic;
10+
using System.Diagnostics;
1011
using System.Drawing;
1112
using System.Drawing.Drawing2D;
13+
using System.IO;
1214
using System.Linq;
1315
using System.Net;
1416
using System.Net.NetworkInformation;
@@ -140,7 +142,7 @@ private void NicSelection_Load(object sender, EventArgs e)
140142
#endregion
141143

142144
//Open the registry, show the License Agreement dialog if it's not accepted,
143-
//then check for the WinPcap driver and display an error dialog if it's not installed,
145+
//then check for the Npcap driver and display an error dialog if it's not installed,
144146
//otherwise grab the driver version and show it.
145147
var root = Registry.CurrentUser;
146148
RegistryKey reg1 = root.OpenSubKey("Software", true).CreateSubKey("hSmNz");
@@ -166,37 +168,45 @@ private void NicSelection_Load(object sender, EventArgs e)
166168

167169
#endregion
168170

169-
#region WinPcap driver check
171+
#region Npcap driver check
170172

171-
RegistryKey winpcapkey = null;
172-
if (Environment.Is64BitOperatingSystem)
173-
{
174-
winpcapkey =
175-
Registry.LocalMachine.OpenSubKey(
176-
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst");
177-
}
178-
else
179-
{
180-
winpcapkey =
181-
Registry.LocalMachine.OpenSubKey(
182-
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst");
183-
}
173+
string ver = null;
184174

185-
if (winpcapkey != null)
175+
if (!Environment.Is64BitOperatingSystem)
186176
{
187-
string ver = (string)winpcapkey.GetValue("DisplayName");
188-
if (!string.IsNullOrEmpty(ver))
177+
using (RegistryKey np = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Npcap", false))
189178
{
190-
materialLabel3.Text = ver;
191-
winpcapkey.Close();
179+
//Get Npcap installation path
180+
var InstallationPath = np.GetValue(string.Empty) as string;
181+
182+
if (!string.IsNullOrEmpty(InstallationPath))
183+
{
184+
ver = FileVersionInfo.GetVersionInfo(Path.Combine(InstallationPath, "NPFInstall.exe")).FileVersion;
185+
186+
materialLabel3.Text = ver;
187+
}
192188
}
193189
}
194190
else
195191
{
196-
winpcapkey.Close();
192+
using (RegistryKey np = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Npcap", false))
193+
{
194+
//Get Npcap installation path
195+
var InstallationPath = np.GetValue(string.Empty) as string;
196+
197+
if (!string.IsNullOrEmpty(InstallationPath))
198+
{
199+
ver = FileVersionInfo.GetVersionInfo(Path.Combine(InstallationPath, "NPFInstall.exe")).FileVersion;
200+
201+
materialLabel3.Text = ver;
202+
}
203+
}
204+
}
197205

198-
ErrorForm EF = new ErrorForm();
199-
EF.ShowDialog();
206+
if (string.IsNullOrEmpty(ver))
207+
{
208+
var verError = new ErrorForm();
209+
verError.ShowDialog();
200210
}
201211

202212
#endregion

0 commit comments

Comments
 (0)