1
0

Fixed setting AllowPrereleaseSignatures

This commit is contained in:
Benjamin Höglinger-Stelzer 2018-11-04 02:15:25 +01:00
parent f5d607120a
commit dc7b7c07c9
5 changed files with 125 additions and 37 deletions

View File

@ -38,6 +38,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
@ -120,6 +121,7 @@
</Compile>
<Compile Include="Util\BcdHelper.cs" />
<Compile Include="Util\CodeIntegrityHelper.cs" />
<Compile Include="Util\CodeIntegrityPolicyHelper.cs" />
<Compile Include="Util\OsUpgradeDetection.cs" />
<Compile Include="Util\OSVersionInfo.cs" />
<Compile Include="Util\UEFIHelper.cs" />

View File

@ -22,7 +22,7 @@
<TabControl Margin="15">
<!-- System Details -->
<TabItem Header="System Details">
<TabItem Header="System Overview">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -78,8 +78,37 @@
</TabItem>
<!-- Compatibility Summary -->
<TabItem Header="Compatibility Summary">
<markdig:MarkdownViewer x:Name="SummaryViewer"/>
<TabItem Header="Details">
<markdig:MarkdownViewer x:Name="SummaryViewer" />
</TabItem>
<TabItem Header="Settings">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<controls:ToggleSwitch Grid.Row="0" Grid.Column="0"
Margin="0,10,0,0"
Header="Allow Prerelease Signatures"
OnLabel="TESTSINGING is on"
OffLabel="TESTSINGING is off"
IsChecked="{Binding Path=AllowPrereleaseSignatures}" />
<controls:ToggleSwitch Grid.Row="1" Grid.Column="0"
Margin="0,10,0,0"
Header="WHQL Developer Test Mode"
OnLabel="Cross-signed driver loading allowed"
OffLabel="Only WHQL-signed drivers allowed"
IsEnabled="{Binding Path=IsWindows10}"
IsChecked="{Binding Path=WhqlDeveloperTestMode}" />
</Grid>
</TabItem>
<!-- About -->
@ -106,7 +135,7 @@
Style="{DynamicResource MetroCircleButtonStyle}"
Content="{iconPacks:FontAwesome Kind=WordpressBrands, Width=32, Height=32}"
ToolTip="Visit home page"
Click="Web_OnClick"/>
Click="Web_OnClick" />
<Button Grid.Column="1"
Margin="10"
@ -114,7 +143,7 @@
Style="{DynamicResource MetroCircleButtonStyle}"
Content="{iconPacks:FontAwesome Kind=DiscordBrands, Width=32, Height=32}"
ToolTip="Join Discord server"
Click="Discord_OnClick"/>
Click="Discord_OnClick" />
<Button Grid.Column="2"
Margin="10"
@ -122,7 +151,7 @@
Style="{DynamicResource MetroCircleButtonStyle}"
Content="{iconPacks:FontAwesome Kind=NodeJsBrands, Width=32, Height=32}"
ToolTip="Visit community forums"
Click="Forums_OnClick"/>
Click="Forums_OnClick" />
</Grid>
</Grid>
</TabItem>

View File

@ -65,6 +65,20 @@ namespace DerpingDrivers
/// </summary>
public string TestSigningStatus => CodeIntegrityHelper.IsTestSignEnabled ? "Enabled" : "Disabled";
public bool AllowPrereleaseSignatures
{
get => BcdHelper.AllowPrereleaseSignatures;
set => BcdHelper.AllowPrereleaseSignatures = value;
}
public bool WhqlDeveloperTestMode
{
get => CodeIntegrityPolicyHelper.WhqlDeveloperTestMode;
set => CodeIntegrityPolicyHelper.WhqlDeveloperTestMode = value;
}
public bool IsWindows10 => OsVersionInfo.IsWindows10;
private string MatchingSummaryContent
{
get

View File

@ -1,5 +1,7 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using DerpingDrivers.Exceptions;
using ExceptionReporting;
using Microsoft.Win32;
namespace DerpingDrivers.Util
@ -26,45 +28,62 @@ namespace DerpingDrivers.Util
set
{
if (value)
try
{
// NOTE: haven't found an API for this (yet), so system() we go!
var cmd = new Process
if (value)
{
StartInfo =
// NOTE: haven't found an API for this (yet), so system() we go!
var cmd = new Process
{
FileName = "Bcdedit.exe",
Arguments = "-set TESTSIGNING ON",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
}
};
StartInfo =
{
FileName = @"C:\WINDOWS\system32\bcdedit.exe",
Arguments = "-set TESTSIGNING ON",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false
}
};
cmd.Start();
cmd.WaitForExit();
cmd.Start();
cmd.WaitForExit();
if (cmd.ExitCode != 0)
throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't enable TESTSIGNING");
if (cmd.ExitCode != 0)
throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't enable TESTSIGNING");
}
else
{
// NOTE: haven't found an API for this (yet), so system() we go!
var cmd = new Process
{
StartInfo =
{
FileName = @"C:\WINDOWS\system32\bcdedit.exe",
Arguments = "-set TESTSIGNING OFF",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false
}
};
cmd.Start();
cmd.WaitForExit();
if (cmd.ExitCode != 0)
throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't disable TESTSIGNING");
}
}
else
catch (Exception ex)
{
// NOTE: haven't found an API for this (yet), so system() we go!
var cmd = new Process
var er = new ExceptionReporter
{
StartInfo =
Config =
{
FileName = "Bcdedit.exe",
Arguments = "-set TESTSIGNING OFF",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
AppName = "DerpingDrivers",
SendMethod = ReportSendMethod.None
}
};
cmd.Start();
cmd.WaitForExit();
if (cmd.ExitCode != 0)
throw new BcdAlterAllowPrereleaseSignaturesFailedException("Couldn't disable TESTSIGNING");
er.Show(ex);
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using Microsoft.Win32;
namespace DerpingDrivers.Util
{
public static class CodeIntegrityPolicyHelper
{
public static bool WhqlDeveloperTestMode
{
get
{
var value = (int?) Registry.GetValue(@"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\CI\Policy",
"WhqlDeveloperTestMode", null);
if (value == null) return false;
return value > 0;
}
set => Registry.SetValue(@"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\CI\Policy",
"WhqlDeveloperTestMode", Convert.ToInt32(value), RegistryValueKind.DWord);
}
}
}