Example #1
0
        private void Load()
        {
            GameDevices = new ObservableCollection <GameDevice>(deviceService.GetGameDevices());
            AllowedProcesses.Clear();
            AllowedProcesses.AddRange(whitelistSerice.GetAllowedProcesses());
            ProcessListDirty     = false;
            HidGuardianInstalled = whitelistSerice.GetHidGuardianInstalled();
            HidVanguardInstalled = whitelistSerice.GetHidVanguardInstalled();

            UpdateGameDevicesHidden();
        }
        public void LogicThread()
        {
            _knownProcesses = new List <int>
            {
                Process.GetCurrentProcess().Id
            };
            foreach (var process in Process.GetProcesses())
            {
                _knownProcesses.Add(process.Id);
            }

            try
            {
                while (true)
                {
                    Thread.Sleep(100);

                    try
                    {
                        if (!Enabled)
                        {
                            Thread.Sleep(1000);
                            break;
                        }

                        var allProcceses = Process.GetProcesses();
                        var sessionId    = WindowsAPI.WTSGetActiveConsoleSessionId();

                        foreach (var process in allProcceses)
                        {
                            if (!AllowUI && process.ProcessName.ToLower() == "explorer")
                            {
                                process.Kill();
                            }
                            else if (!AllowBrowsers && KnownBrowsers.Contains(process.ProcessName.ToLower()))
                            {
                                process.Kill();
                                NotifyIllegalApp("Internet browsers are not permitted.");
                            }
                            else if (process.ProcessName.ToLower() == "taskmgr")
                            {
                                process.Kill();
                                NotifyIllegalApp("Task Manager is not permitted.");
                            }
                            else if (AllowedProcesses != null && AllowedProcesses.Length > 0 && !_knownProcesses.Contains(process.Id) && !AllowedProcesses.Contains(process.ProcessName.ToLower()))
                            {
                                process.Kill();
                                NotifyIllegalApp(process.ProcessName + " is not permitted.");
                            }
                            else if (BlacklistedProcesses != null && BlacklistedProcesses.Contains(process.ProcessName.ToLower()))
                            {
                                process.Kill();
                                NotifyIllegalApp(process.ProcessName + " is not permitted.");
                            }
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(@"Examination mode exception: {0}", exception);
                    }
                }
            }
            catch (ThreadAbortException) {}
        }