diff --git a/DerpingDrivers/DerpingDrivers.csproj b/DerpingDrivers/DerpingDrivers.csproj index 229f3eb..fd1ad3d 100644 --- a/DerpingDrivers/DerpingDrivers.csproj +++ b/DerpingDrivers/DerpingDrivers.csproj @@ -79,6 +79,9 @@ ..\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 @@ -111,12 +114,14 @@ MSBuild:Compile Designer + True True Resources.resx + diff --git a/DerpingDrivers/Exceptions/BcdAlterAllowPrereleaseSignaturesFailedException.cs b/DerpingDrivers/Exceptions/BcdAlterAllowPrereleaseSignaturesFailedException.cs new file mode 100644 index 0000000..67eea46 --- /dev/null +++ b/DerpingDrivers/Exceptions/BcdAlterAllowPrereleaseSignaturesFailedException.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.Serialization; + +namespace DerpingDrivers.Exceptions +{ + public class BcdAlterAllowPrereleaseSignaturesFailedException : Exception + { + public BcdAlterAllowPrereleaseSignaturesFailedException() + { + } + + public BcdAlterAllowPrereleaseSignaturesFailedException(string message) : base(message) + { + } + + public BcdAlterAllowPrereleaseSignaturesFailedException(string message, Exception innerException) : base(message, innerException) + { + } + + protected BcdAlterAllowPrereleaseSignaturesFailedException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} \ No newline at end of file diff --git a/DerpingDrivers/MainWindow.xaml.cs b/DerpingDrivers/MainWindow.xaml.cs index 9056855..a7b9d13 100644 --- a/DerpingDrivers/MainWindow.xaml.cs +++ b/DerpingDrivers/MainWindow.xaml.cs @@ -69,6 +69,8 @@ namespace DerpingDrivers { get { + var t = BcdHelper.IsTestSignEnabled; + #region TESTSIGNING mode if (CodeIntegrityHelper.IsTestSignEnabled) diff --git a/DerpingDrivers/Util/BcdHelper.cs b/DerpingDrivers/Util/BcdHelper.cs new file mode 100644 index 0000000..01418e1 --- /dev/null +++ b/DerpingDrivers/Util/BcdHelper.cs @@ -0,0 +1,47 @@ +using DerpingDrivers.Exceptions; +using Microsoft.Win32; +using RunProcessAsTask; + +namespace DerpingDrivers.Util +{ + public static class BcdHelper + { + public static bool IsTestSignEnabled + { + get + { + var bootmgrDefaultGuid = (string) Registry.GetValue( + @"HKEY_LOCAL_MACHINE\BCD00000000\Objects\{9DEA862C-5CDD-4E70-ACC1-F32B344D4795}\Elements\23000003", + "Element", null); + + var allowPrereleaseSignatures = (byte[]) Registry.GetValue( + $@"HKEY_LOCAL_MACHINE\BCD00000000\Objects\{bootmgrDefaultGuid}\Elements\16000049", + "Element", default(byte[])); + + return allowPrereleaseSignatures != null && bool.Parse(allowPrereleaseSignatures[0].ToString()); + } + } + + 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) + { + 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) + { + throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't disable TESTSIGNING"); + } + } + } +} \ No newline at end of file diff --git a/DerpingDrivers/packages.config b/DerpingDrivers/packages.config index 5901955..cb07c84 100644 --- a/DerpingDrivers/packages.config +++ b/DerpingDrivers/packages.config @@ -12,5 +12,6 @@ + \ No newline at end of file diff --git a/README.md b/README.md index 43ac1bc..dbb39fc 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,13 @@ - Icon by [Rebin Infotech](https://www.iconfinder.com/rebininfotech) - [Getting Operating System Version Info - Even for Windows 10!](https://www.codeproject.com/Articles/73000/Getting-Operating-System-Version-Info-Even-for-Win) -- [How do I tell if Windows 10 was a fresh install or upgrade from 7/8?](https://superuser.com/questions/1032064/how-do-i-tell-if-windows-10-was-a-fresh-install-or-upgrade-from-7-8/1184670#1184670) - [NtQuerySystemInformation](https://docs.microsoft.com/de-de/windows/desktop/api/winternl/nf-winternl-ntquerysysteminformation) -- [Can I have any way to detect the Driver Signing Policy status?](https://stackoverflow.com/questions/40084077/can-i-have-any-way-to-detect-the-driver-signing-policy-status/51230137#51230137) - [The TESTSIGNING Boot Configuration Option](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/the-testsigning-boot-configuration-option) - [Windows Version Numbers](http://techthoughts.info/windows-version-numbers/) -- [Is there an easy way to check the .NET Framework version?](https://stackoverflow.com/questions/951856/is-there-an-easy-way-to-check-the-net-framework-version) +- [Super user: How do I tell if Windows 10 was a fresh install or upgrade from 7/8?](https://superuser.com/questions/1032064/how-do-i-tell-if-windows-10-was-a-fresh-install-or-upgrade-from-7-8/1184670#1184670) +- [Stack Overflow: Is there an easy way to check the .NET Framework version?](https://stackoverflow.com/questions/951856/is-there-an-easy-way-to-check-the-net-framework-version) +- [Stack Overflow: Can I have any way to detect the Driver Signing Policy status?](https://stackoverflow.com/questions/40084077/can-i-have-any-way-to-detect-the-driver-signing-policy-status/51230137#51230137) +- [BCDEdit: Mounting the BCD Store as a Registry Hive](http://www.mistyprojects.co.uk/documents/BCDEdit/files/bcd_as_registry_hive.htm) +- [BCDEdit: Objects and Elements](http://www.mistyprojects.co.uk/documents/BCDEdit/files/object_element_codes.htm) +- [Geoff Chappell: BCD Elements](https://www.geoffchappell.com/notes/windows/boot/bcd/elements.htm) +- [Geoff Chappell: Back Doors for Cross-Signed Drivers](https://www.geoffchappell.com/notes/security/whqlsettings/index.htm)