From 9033065e392c535f486b5750a86c52f7a81b51c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sun, 4 Nov 2018 01:02:42 +0100 Subject: [PATCH] Fixed --- DerpingDrivers/DerpingDrivers.csproj | 3 -- DerpingDrivers/MainWindow.xaml.cs | 2 ++ DerpingDrivers/Util/BcdHelper.cs | 42 ++++++++++++++++++++-------- DerpingDrivers/packages.config | 1 - 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/DerpingDrivers/DerpingDrivers.csproj b/DerpingDrivers/DerpingDrivers.csproj index fd1ad3d..90d319e 100644 --- a/DerpingDrivers/DerpingDrivers.csproj +++ b/DerpingDrivers/DerpingDrivers.csproj @@ -79,9 +79,6 @@ ..\packages\PInvoke.Windows.Core.0.5.155\lib\net35\PInvoke.Windows.Core.dll - - ..\packages\RunProcessAsTask.1.2.3\lib\net45\RunProcessAsTask.dll - ..\packages\Simple-MAPI.NET.1.1.0\lib\net20\SimpleMapi.dll diff --git a/DerpingDrivers/MainWindow.xaml.cs b/DerpingDrivers/MainWindow.xaml.cs index a7b9d13..1ca018d 100644 --- a/DerpingDrivers/MainWindow.xaml.cs +++ b/DerpingDrivers/MainWindow.xaml.cs @@ -69,6 +69,8 @@ namespace DerpingDrivers { get { + BcdHelper.DisableTestSigning(); + var t = BcdHelper.IsTestSignEnabled; #region TESTSIGNING mode diff --git a/DerpingDrivers/Util/BcdHelper.cs b/DerpingDrivers/Util/BcdHelper.cs index 01418e1..7ac878a 100644 --- a/DerpingDrivers/Util/BcdHelper.cs +++ b/DerpingDrivers/Util/BcdHelper.cs @@ -1,6 +1,6 @@ -using DerpingDrivers.Exceptions; +using System.Diagnostics; +using DerpingDrivers.Exceptions; using Microsoft.Win32; -using RunProcessAsTask; namespace DerpingDrivers.Util { @@ -18,30 +18,50 @@ namespace DerpingDrivers.Util $@"HKEY_LOCAL_MACHINE\BCD00000000\Objects\{bootmgrDefaultGuid}\Elements\16000049", "Element", default(byte[])); - return allowPrereleaseSignatures != null && bool.Parse(allowPrereleaseSignatures[0].ToString()); + return allowPrereleaseSignatures != null && int.Parse(allowPrereleaseSignatures[0].ToString()) > 0; } } public static void EnableTestSigning() { // NOTE: haven't found an API for this (yet), so system() we go! - var ret = ProcessEx.RunAsync("Bcdedit.exe", "-set TESTSIGNING ON").Result; - - if (ret.ExitCode != 0) + var cmd = new Process { + StartInfo = + { + FileName = "Bcdedit.exe", + Arguments = "-set TESTSIGNING ON", + WindowStyle = ProcessWindowStyle.Hidden, + CreateNoWindow = true + } + }; + + cmd.Start(); + cmd.WaitForExit(); + + if (cmd.ExitCode != 0) throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't enable TESTSIGNING"); - } } public static void DisableTestSigning() { // NOTE: haven't found an API for this (yet), so system() we go! - var ret = ProcessEx.RunAsync("Bcdedit.exe", "-set TESTSIGNING OFF").Result; - - if (ret.ExitCode != 0) + var cmd = new Process { + StartInfo = + { + FileName = "Bcdedit.exe", + Arguments = "-set TESTSIGNING OFF", + WindowStyle = ProcessWindowStyle.Hidden, + CreateNoWindow = true + } + }; + + cmd.Start(); + cmd.WaitForExit(); + + if (cmd.ExitCode != 0) throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't disable TESTSIGNING"); - } } } } \ No newline at end of file diff --git a/DerpingDrivers/packages.config b/DerpingDrivers/packages.config index cb07c84..5901955 100644 --- a/DerpingDrivers/packages.config +++ b/DerpingDrivers/packages.config @@ -12,6 +12,5 @@ - \ No newline at end of file