Exemple #1
0
        private void NicSelection_Load(object sender, EventArgs e)
        {
            Main m = Application.OpenForms["Main"] as Main;

            #region Some tedious visual garbage

            if (Properties.Settings.Default.Color == "Dark")
            {
                materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;
                m.ListOverlay.BackColor   = Color.FromArgb(71, 71, 71);
                m.ListOverlay.TextColor   = Color.FromArgb(204, 204, 204);
                m.ListOverlay.BorderColor = Color.Teal;
                m.pictureBox2.Image       = NetStalker.Properties.Resources._30G;
            }
            else
            {
                m.ListOverlay.BorderColor = Color.Teal;
                materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
                m.fastObjectListView1.HeaderFormatStyle = m.LightHeaders;
                m.fastObjectListView1.HotItemStyle      = m.LightHot;
                m.ListOverlay.BackColor                          = Color.FromArgb(204, 204, 204);
                m.ListOverlay.TextColor                          = Color.FromArgb(71, 71, 71);
                m.fastObjectListView1.BackColor                  = Color.White;
                m.fastObjectListView1.ForeColor                  = Color.FromArgb(54, 54, 54);
                m.fastObjectListView1.SelectedBackColor          = Color.FromArgb(214, 214, 214);
                m.fastObjectListView1.SelectedForeColor          = Color.FromArgb(51, 51, 51);
                m.fastObjectListView1.UnfocusedSelectedBackColor = Color.FromArgb(71, 71, 71);
                m.fastObjectListView1.UnfocusedSelectedForeColor = Color.FromArgb(204, 204, 204);
                m.pictureBox2.Image = NetStalker.Properties.Resources._30W;
            }

            #endregion

            #region Check for the chosen minimization option

            if (Properties.Settings.Default.Minimize == "Tray")
            {
                m.Resize     -= m.Main_Resize_1;
                m.Resize     += m.Main_Resize;
                m.ResizeState = "Tray";
            }
            else
            {
                m.Resize     -= m.Main_Resize;
                m.Resize     += m.Main_Resize_1;
                m.ResizeState = "Taskbar";
            }

            #endregion

            //Open the registry, show the License Agreement dialog if it's not accepted,
            //then check for the Npcap driver and display an error dialog if it's not installed,
            //otherwise grab the driver version and show it.
            var         root = Registry.CurrentUser;
            RegistryKey reg1 = root.OpenSubKey("Software", true).CreateSubKey("hSmNz");
            if (reg1 != null)
            {
                #region License agreement

                if (string.IsNullOrEmpty((string)reg1.GetValue("Des")) || (string)reg1.GetValue("Des") != "True")
                {
                    LicenseAgreement la = new LicenseAgreement();
                    if (la.ShowDialog() == DialogResult.Yes)
                    {
                        reg1.SetValue("Des", "True");
                    }
                    else
                    {
                        reg1.SetValue("Des", "False");
                        reg1.Close();
                        root.Close();
                        Application.Exit();
                    }
                }

                #endregion

                #region Npcap driver check

                string ver = null;

                if (!Environment.Is64BitOperatingSystem)
                {
                    using (RegistryKey np = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Npcap", false))
                    {
                        //Get Npcap installation path
                        var InstallationPath = np.GetValue(string.Empty) as string;

                        if (!string.IsNullOrEmpty(InstallationPath))
                        {
                            ver = FileVersionInfo.GetVersionInfo(Path.Combine(InstallationPath, "NPFInstall.exe")).FileVersion;

                            materialLabel3.Text = ver;
                        }
                    }
                }
                else
                {
                    using (RegistryKey np = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Npcap", false))
                    {
                        //Get Npcap installation path
                        var InstallationPath = np.GetValue(string.Empty) as string;

                        if (!string.IsNullOrEmpty(InstallationPath))
                        {
                            ver = FileVersionInfo.GetVersionInfo(Path.Combine(InstallationPath, "NPFInstall.exe")).FileVersion;

                            materialLabel3.Text = ver;
                        }
                    }
                }

                if (string.IsNullOrEmpty(ver))
                {
                    var verError = new ErrorForm();
                    verError.ShowDialog();
                }

                #endregion

                #region Password check

                if (!string.IsNullOrEmpty((string)reg1.GetValue("IsSNG")) && (string)reg1.GetValue("IsSNG") == "True")
                {
                    reg1.Close();
                    root.Close();
                    PasswordCheck pass = new PasswordCheck();
                    pass.ShowDialog();
                }

                #endregion
            }

            GetNics();

            //Populate the combo box with the available network interfaces
            foreach (var nic in Nics)
            {
                comboBox1.Items.Add(nic.Name);
            }
        }
Exemple #2
0
        private void NicSelection_Load(object sender, EventArgs e)
        {
            m = Application.OpenForms["Main"] as Main;
            if (Properties.Settings.Default.color == "Dark")
            {
                materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;
                m.textOverlay.BackColor   = Color.FromArgb(71, 71, 71);
                m.textOverlay.TextColor   = Color.FromArgb(204, 204, 204);
                m.textOverlay.BorderColor = Color.Teal;
                m.pictureBox2.Image       = NetStalker.Properties.Resources._30G;
            }
            else
            {
                m.textOverlay.BorderColor = Color.Teal;
                materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
                m.fastObjectListView1.HeaderFormatStyle = m.LightHeaders;
                m.fastObjectListView1.HotItemStyle      = m.LightHot;
                m.textOverlay.BackColor                          = Color.FromArgb(204, 204, 204);
                m.textOverlay.TextColor                          = Color.FromArgb(71, 71, 71);
                m.fastObjectListView1.BackColor                  = Color.White;
                m.fastObjectListView1.ForeColor                  = Color.FromArgb(54, 54, 54);
                m.fastObjectListView1.SelectedBackColor          = Color.FromArgb(214, 214, 214);
                m.fastObjectListView1.SelectedForeColor          = Color.FromArgb(51, 51, 51);
                m.fastObjectListView1.UnfocusedSelectedBackColor = Color.FromArgb(71, 71, 71);
                m.fastObjectListView1.UnfocusedSelectedForeColor = Color.FromArgb(204, 204, 204);
                m.pictureBox2.Image = NetStalker.Properties.Resources._30W;
            }

            if (Properties.Settings.Default.minimize == "Tray")
            {
                m.Resize     -= m.Main_Resize_1;
                m.Resize     += m.Main_Resize;
                m.resizestate = "Tray";
            }
            else
            {
                m.Resize     -= m.Main_Resize;
                m.Resize     += m.Main_Resize_1;
                m.resizestate = "Taskbar";
            }

            var         root = Registry.CurrentUser;
            RegistryKey reg1 = root.OpenSubKey("Software", true).CreateSubKey("hSmNz");

            if (reg1 != null)
            {
                if (string.IsNullOrEmpty((string)reg1.GetValue("Des")) || (string)reg1.GetValue("Des") != "True")
                {
                    LicenseAgreement la = new LicenseAgreement();
                    if (la.ShowDialog() == DialogResult.Yes)
                    {
                        reg1.SetValue("Des", "True");
                    }
                    else
                    {
                        reg1.SetValue("Des", "False");
                        reg1.Close();
                        root.Close();
                        Application.Exit();
                    }
                }

                RegistryKey winpcapkey = null;
                if (Environment.Is64BitOperatingSystem)
                {
                    winpcapkey =
                        Registry.LocalMachine.OpenSubKey(
                            @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst");
                }
                else
                {
                    winpcapkey =
                        Registry.LocalMachine.OpenSubKey(
                            @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst");
                }


                if (winpcapkey != null)
                {
                    string ver = (string)winpcapkey.GetValue("DisplayName");
                    if (!string.IsNullOrEmpty(ver))
                    {
                        materialLabel3.Text = ver;
                        winpcapkey.Close();
                    }
                }
                else
                {
                    try
                    {
                        ErrorForm EF = new ErrorForm();
                        EF.ShowDialog();
                    }
                    catch (Exception)
                    {
                    }
                }



                if (!string.IsNullOrEmpty((string)reg1.GetValue("IsSNG")) && (string)reg1.GetValue("IsSNG") == "True")
                {
                    reg1.Close();
                    root.Close();
                    PasswordCheck pass = new PasswordCheck();
                    pass.ShowDialog();
                }
            }

            GetNics();
            foreach (var nic in Nics)
            {
                comboBox1.Items.Add(nic.Name);
            }
        }