Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 3
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) // On exit
 {
     if (DevConAvailable)
     {
         string devices   = "";
         string processes = "";
         HIDGuardianAPI.RemoveAllWhitelistedProcesses();    // Remove all added processes.
         UnhideDevices();                                   // Remove and unhide hidden devices.
         foreach (var device in HiddenDevicesListBox.Items) // Store the settings.
         {
             devices += device.ToString() + ";";
         }
         foreach (var process in PermenantProccessesTextBox.Text.TrimEnd(';').Split(';'))
         {
             processes += process + ";";
         }
         File.WriteAllText("settings.ini", "devices=" + devices + "\r\n" + "processes=" + processes);
     }
 }
Ejemplo n.º 4
0
 private void DenyAllProcessBtn_Click(object sender, EventArgs e)
 {
     HIDGuardianAPI.RemoveAllWhitelistedProcesses();
     HIDGuardianAPI.AddWhitelistedProcess(Process.GetCurrentProcess().Id.ToString());
     MoveListBoxItems(AllowedProcessesListBox, DeniedProcessesListBox);
 }