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

View File

@ -22,7 +22,7 @@
<TabControl Margin="15"> <TabControl Margin="15">
<!-- System Details --> <!-- System Details -->
<TabItem Header="System Details"> <TabItem Header="System Overview">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -45,7 +45,7 @@
<Label Grid.Row="0" Grid.Column="0">Windows version name:</Label> <Label Grid.Row="0" Grid.Column="0">Windows version name:</Label>
<Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=OsVersionName}" <Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=OsVersionName}"
ToolTip="Product name of the operating system." /> ToolTip="Product name of the operating system." />
<Label Grid.Row="1" Grid.Column="0">Windows edition name:</Label> <Label Grid.Row="1" Grid.Column="0">Windows edition name:</Label>
<Label Grid.Row="1" Grid.Column="2" Content="{Binding Path=OsEditionName}" <Label Grid.Row="1" Grid.Column="2" Content="{Binding Path=OsEditionName}"
ToolTip="Edition name of the operating system (if any)." /> ToolTip="Edition name of the operating system (if any)." />
@ -78,8 +78,37 @@
</TabItem> </TabItem>
<!-- Compatibility Summary --> <!-- Compatibility Summary -->
<TabItem Header="Compatibility Summary"> <TabItem Header="Details">
<markdig:MarkdownViewer x:Name="SummaryViewer"/> <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> </TabItem>
<!-- About --> <!-- About -->
@ -106,7 +135,7 @@
Style="{DynamicResource MetroCircleButtonStyle}" Style="{DynamicResource MetroCircleButtonStyle}"
Content="{iconPacks:FontAwesome Kind=WordpressBrands, Width=32, Height=32}" Content="{iconPacks:FontAwesome Kind=WordpressBrands, Width=32, Height=32}"
ToolTip="Visit home page" ToolTip="Visit home page"
Click="Web_OnClick"/> Click="Web_OnClick" />
<Button Grid.Column="1" <Button Grid.Column="1"
Margin="10" Margin="10"
@ -114,15 +143,15 @@
Style="{DynamicResource MetroCircleButtonStyle}" Style="{DynamicResource MetroCircleButtonStyle}"
Content="{iconPacks:FontAwesome Kind=DiscordBrands, Width=32, Height=32}" Content="{iconPacks:FontAwesome Kind=DiscordBrands, Width=32, Height=32}"
ToolTip="Join Discord server" ToolTip="Join Discord server"
Click="Discord_OnClick"/> Click="Discord_OnClick" />
<Button Grid.Column="2" <Button Grid.Column="2"
Margin="10" Margin="10"
Width="64" Height="64" Width="64" Height="64"
Style="{DynamicResource MetroCircleButtonStyle}" Style="{DynamicResource MetroCircleButtonStyle}"
Content="{iconPacks:FontAwesome Kind=NodeJsBrands, Width=32, Height=32}" Content="{iconPacks:FontAwesome Kind=NodeJsBrands, Width=32, Height=32}"
ToolTip="Visit community forums" ToolTip="Visit community forums"
Click="Forums_OnClick"/> Click="Forums_OnClick" />
</Grid> </Grid>
</Grid> </Grid>
</TabItem> </TabItem>

View File

@ -65,6 +65,20 @@ namespace DerpingDrivers
/// </summary> /// </summary>
public string TestSigningStatus => CodeIntegrityHelper.IsTestSignEnabled ? "Enabled" : "Disabled"; 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 private string MatchingSummaryContent
{ {
get get

View File

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

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);
}
}
}