From f5d607120adfc66ff512cb94f8cd14401eae8ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sun, 4 Nov 2018 01:08:39 +0100 Subject: [PATCH] Renamed property --- DerpingDrivers/MainWindow.xaml.cs | 4 -- DerpingDrivers/Util/BcdHelper.cs | 79 ++++++++++++++++--------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/DerpingDrivers/MainWindow.xaml.cs b/DerpingDrivers/MainWindow.xaml.cs index 1ca018d..9056855 100644 --- a/DerpingDrivers/MainWindow.xaml.cs +++ b/DerpingDrivers/MainWindow.xaml.cs @@ -69,10 +69,6 @@ namespace DerpingDrivers { get { - BcdHelper.DisableTestSigning(); - - var t = BcdHelper.IsTestSignEnabled; - #region TESTSIGNING mode if (CodeIntegrityHelper.IsTestSignEnabled) diff --git a/DerpingDrivers/Util/BcdHelper.cs b/DerpingDrivers/Util/BcdHelper.cs index 7ac878a..05deef0 100644 --- a/DerpingDrivers/Util/BcdHelper.cs +++ b/DerpingDrivers/Util/BcdHelper.cs @@ -6,7 +6,10 @@ namespace DerpingDrivers.Util { public static class BcdHelper { - public static bool IsTestSignEnabled + /// + /// Gets or sets the current value if BCDE_LIBRARY_TYPE_ALLOW_PRERELEASE_SIGNATURES from the default boot entry. + /// + public static bool AllowPrereleaseSignatures { get { @@ -20,48 +23,50 @@ namespace DerpingDrivers.Util 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 cmd = new Process + set { - StartInfo = + if (value) { - FileName = "Bcdedit.exe", - Arguments = "-set TESTSIGNING ON", - WindowStyle = ProcessWindowStyle.Hidden, - CreateNoWindow = true + // NOTE: haven't found an API for this (yet), so system() we go! + 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"); } - }; - - 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 cmd = new Process - { - StartInfo = + else { - FileName = "Bcdedit.exe", - Arguments = "-set TESTSIGNING OFF", - WindowStyle = ProcessWindowStyle.Hidden, - CreateNoWindow = true + // NOTE: haven't found an API for this (yet), so system() we go! + 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"); } - }; - - cmd.Start(); - cmd.WaitForExit(); - - if (cmd.ExitCode != 0) - throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't disable TESTSIGNING"); + } } } } \ No newline at end of file