1
0
This commit is contained in:
Benjamin Höglinger-Stelzer 2018-11-04 01:02:42 +01:00
parent abb4039ea0
commit 9033065e39
4 changed files with 33 additions and 15 deletions

View File

@ -79,9 +79,6 @@
<Reference Include="PInvoke.Windows.Core, Version=0.5.0.0, Culture=neutral, PublicKeyToken=9e300f9f87f04a7a, processorArchitecture=MSIL"> <Reference Include="PInvoke.Windows.Core, Version=0.5.0.0, Culture=neutral, PublicKeyToken=9e300f9f87f04a7a, processorArchitecture=MSIL">
<HintPath>..\packages\PInvoke.Windows.Core.0.5.155\lib\net35\PInvoke.Windows.Core.dll</HintPath> <HintPath>..\packages\PInvoke.Windows.Core.0.5.155\lib\net35\PInvoke.Windows.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="RunProcessAsTask, Version=1.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RunProcessAsTask.1.2.3\lib\net45\RunProcessAsTask.dll</HintPath>
</Reference>
<Reference Include="SimpleMapi, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="SimpleMapi, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Simple-MAPI.NET.1.1.0\lib\net20\SimpleMapi.dll</HintPath> <HintPath>..\packages\Simple-MAPI.NET.1.1.0\lib\net20\SimpleMapi.dll</HintPath>
</Reference> </Reference>

View File

@ -69,6 +69,8 @@ namespace DerpingDrivers
{ {
get get
{ {
BcdHelper.DisableTestSigning();
var t = BcdHelper.IsTestSignEnabled; var t = BcdHelper.IsTestSignEnabled;
#region TESTSIGNING mode #region TESTSIGNING mode

View File

@ -1,6 +1,6 @@
using DerpingDrivers.Exceptions; using System.Diagnostics;
using DerpingDrivers.Exceptions;
using Microsoft.Win32; using Microsoft.Win32;
using RunProcessAsTask;
namespace DerpingDrivers.Util namespace DerpingDrivers.Util
{ {
@ -18,30 +18,50 @@ namespace DerpingDrivers.Util
$@"HKEY_LOCAL_MACHINE\BCD00000000\Objects\{bootmgrDefaultGuid}\Elements\16000049", $@"HKEY_LOCAL_MACHINE\BCD00000000\Objects\{bootmgrDefaultGuid}\Elements\16000049",
"Element", default(byte[])); "Element", default(byte[]));
return allowPrereleaseSignatures != null && bool.Parse(allowPrereleaseSignatures[0].ToString()); return allowPrereleaseSignatures != null && int.Parse(allowPrereleaseSignatures[0].ToString()) > 0;
} }
} }
public static void EnableTestSigning() public static void EnableTestSigning()
{ {
// NOTE: haven't found an API for this (yet), so system() we go! // NOTE: haven't found an API for this (yet), so system() we go!
var ret = ProcessEx.RunAsync("Bcdedit.exe", "-set TESTSIGNING ON").Result; var cmd = new Process
if (ret.ExitCode != 0)
{ {
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"); throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't enable TESTSIGNING");
}
} }
public static void DisableTestSigning() public static void DisableTestSigning()
{ {
// NOTE: haven't found an API for this (yet), so system() we go! // NOTE: haven't found an API for this (yet), so system() we go!
var ret = ProcessEx.RunAsync("Bcdedit.exe", "-set TESTSIGNING OFF").Result; var cmd = new Process
if (ret.ExitCode != 0)
{ {
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"); throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't disable TESTSIGNING");
}
} }
} }
} }

View File

@ -12,6 +12,5 @@
<package id="Markdig.Wpf" version="0.2.5" targetFramework="net461" /> <package id="Markdig.Wpf" version="0.2.5" targetFramework="net461" />
<package id="PInvoke.Kernel32" version="0.5.155" targetFramework="net461" /> <package id="PInvoke.Kernel32" version="0.5.155" targetFramework="net461" />
<package id="PInvoke.Windows.Core" version="0.5.155" targetFramework="net461" /> <package id="PInvoke.Windows.Core" version="0.5.155" targetFramework="net461" />
<package id="RunProcessAsTask" version="1.2.3" targetFramework="net461" />
<package id="Simple-MAPI.NET" version="1.1.0" targetFramework="net461" /> <package id="Simple-MAPI.NET" version="1.1.0" targetFramework="net461" />
</packages> </packages>