Exemple #1
0
        private void RefreshProcessesBtn_Click(object sender, EventArgs e) // Refresh the processes lists both of them.
        {
            ListBox TempLB = new ListBox();

            DeniedProcessesListBox.Items.Clear();

            HIDGuardianAPI.RemoveAllWhitelistedProcesses(); // Remove all added processes and then add HIDer's pid.
            HIDGuardianAPI.AddWhitelistedProcess(Process.GetCurrentProcess().Id.ToString());

            foreach (Process process in Process.GetProcesses()) // Iterate over processes and check if the refreshed processes are not available in the allowed listbox, if they are not, add them to the main list. If they are, add them to a temp list then refresh the allowed whitelist listbox with the temp list. This is used because some processes added to the allowed list might have been terminated, so they need to be removed.
            {
                if (!process.ProcessName.Contains("HIDer") && process.ProcessName != "System" && process.ProcessName != "Idle")
                {
                    if (AllowedProcessesListBox.FindStringExact(process.ProcessName + ":" + process.Id) == -1)
                    {
                        DeniedProcessesListBox.Items.Add(process.ProcessName + ":" + process.Id);
                    }
                    else
                    {
                        HIDGuardianAPI.AddWhitelistedProcess(process.Id.ToString()); // Re-add the removed processes.
                        TempLB.Items.Add(process.ProcessName + ":" + process.Id);
                    }
                }
            }

            AllowedProcessesListBox.Items.Clear();
            if (TempLB.Items.Count > 0)
            {
                MoveListBoxItems(TempLB, AllowedProcessesListBox);
            }
        }
Exemple #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            string path = Application.StartupPath;

            if (Directory.Exists(path + @"\update") && !IsDirectoryEmpty(path + @"\update")) // This is used to make it easier for the user to install the external resources required for the project.
            {
                ProcessUpdates(path);
            }

            DevConAvailable = CheckDevCon();

            if (DevConAvailable) // Check if devcon is available. Close the application if it is not.
            {
                LoadSettings();
                CheckExternalResources();

                // if (HIDGuardianAPI.IsWebsiteAvailable()) // Check if the website is available. If it is not, do not proceed. HidGuardianWebAPI only.

                HIDGuardianAPI.RemoveAllWhitelistedProcesses();                                  // Remove all processes from last run in case the user crashed the application.
                HIDGuardianAPI.AddWhitelistedProcess(Process.GetCurrentProcess().Id.ToString()); // This is probably not necessary. Check later.

                UnhideDevices();                                                                 // In case the user crashed the application instead of closing it.
                HandleProcesses();                                                               // Deal with available processes and add whitelisted processes based on the stored settings (settings.ini file). HandleProcesses is called before HandleDevices because HandleDevices refreshes (replugs) the hidden devices making them available for the whitelisted processes from this step.
                HandleDevices();                                                                 // Add available and hidden devices from previous time, that the application stored in the file (settings.ini). All hidden devices are stored on application exit.
            }
            else
            {
                DisplayMissing();
            }
        }
Exemple #3
0
 private void AllowProcessBtn_Click(object sender, EventArgs e)
 {
     if (DeniedProcessesListBox.SelectedIndex != -1)
     {
         HIDGuardianAPI.AddWhitelistedProcess(DeniedProcessesListBox.SelectedItem.ToString().Split(':')[1]);
         MoveSelectedListBoxItem(DeniedProcessesListBox, AllowedProcessesListBox);
     }
 }
Exemple #4
0
 private void HandleProcesses()
 {
     foreach (Process process in Process.GetProcesses()) // Iterate over the list of available processes skipping this program, system, and idle processes.
     {
         if (!process.ProcessName.Contains("HIDer") && process.ProcessName != "System" && process.ProcessName != "Idle")
         {
             string whitelistedprocesses = PermenantProccessesTextBox.Text;
             if (whitelistedprocesses != "" && whitelistedprocesses.Contains(process.ProcessName + ";")) // If the current process name matches one from permenant proccesses (PermenantProccessesTextBox.Text), it is added to the HidGuardian whitelist.
             {
                 HIDGuardianAPI.AddWhitelistedProcess(process.Id.ToString());
                 AllowedProcessesListBox.Items.Add(process.ProcessName + ":" + process.Id);
             }
             else
             {
                 DeniedProcessesListBox.Items.Add(process.ProcessName + ":" + process.Id); // Everything else goes in here.
             }
         }
     }
 }
Exemple #5
0
 private void DenyAllProcessBtn_Click(object sender, EventArgs e)
 {
     HIDGuardianAPI.RemoveAllWhitelistedProcesses();
     HIDGuardianAPI.AddWhitelistedProcess(Process.GetCurrentProcess().Id.ToString());
     MoveListBoxItems(AllowedProcessesListBox, DeniedProcessesListBox);
 }