From 9d6aa5413e7e4713ec313a6890dcf46e22507fab Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 6 Nov 2017 20:01:26 -0600 Subject: [PATCH] Add convenience methods for managing HidGuardian whitelist key Currently commented out to the public. Using for my local copy --- DS4Windows/DS4Control/ControlService.cs | 24 ++++++++++++++++++++++-- DS4Windows/Program.cs | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index e4a9f4d..a592e55 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -2,11 +2,13 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Process = System.Diagnostics.Process; using System.Media; using System.Threading.Tasks; using static DS4Windows.Global; using System.Threading; +using Registry = Microsoft.Win32.Registry; namespace DS4Windows { @@ -76,6 +78,24 @@ namespace DS4Windows } } + public void createHidGuardKey() + { + try + { + Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + Process.GetCurrentProcess().Id); + } + catch { } + } + + public void removeHidGuardKey() + { + try + { + Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + Process.GetCurrentProcess().Id); + } + catch { } + } + public bool Start(object tempui, bool showlog = true) { if (x360Bus.Open() && x360Bus.Start()) @@ -376,7 +396,7 @@ namespace DS4Windows string programPath = LaunchProgram[ind]; if (programPath != string.Empty) { - System.Diagnostics.Process[] localAll = System.Diagnostics.Process.GetProcesses(); + Process[] localAll = Process.GetProcesses(); bool procFound = false; for (int procInd = 0, procsLen = localAll.Length; !procFound && procInd < procsLen; procInd++) { @@ -397,7 +417,7 @@ namespace DS4Windows { Task processTask = new Task(() => { - System.Diagnostics.Process tempProcess = new System.Diagnostics.Process(); + Process tempProcess = new Process(); tempProcess.StartInfo.FileName = programPath; tempProcess.StartInfo.WorkingDirectory = new FileInfo(programPath).Directory.ToString(); //tempProcess.StartInfo.UseShellExecute = false; diff --git a/DS4Windows/Program.cs b/DS4Windows/Program.cs index 4d16d05..103ae44 100644 --- a/DS4Windows/Program.cs +++ b/DS4Windows/Program.cs @@ -104,10 +104,12 @@ namespace DS4Windows //if (mutex.WaitOne(TimeSpan.Zero, true)) //{ createControlService(); + //rootHub.createHidGuardKey(); //rootHub = new ControlService(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DS4Form(args)); + //rootHub.removeHidGuardKey(); //mutex.ReleaseMutex(); //}