1
0

Fixed handling test mode when secure boot is enabled

This commit is contained in:
Benjamin Höglinger-Stelzer 2019-06-07 13:07:39 +02:00
parent 13b4cdf09f
commit d07e6cb17e
4 changed files with 48 additions and 4 deletions

View File

@ -113,6 +113,7 @@
<Compile Include="Util\BcdHelper.cs" />
<Compile Include="Util\CodeIntegrityHelper.cs" />
<Compile Include="Util\CodeIntegrityPolicyHelper.cs" />
<Compile Include="Util\InverseBooleanConverter.cs" />
<Compile Include="Util\OsUpgradeDetection.cs" />
<Compile Include="Util\OSVersionInfo.cs" />
<Compile Include="Util\UEFIHelper.cs" />

View File

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DerpingDrivers"
xmlns:util="clr-namespace:DerpingDrivers.Util"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
@ -15,6 +15,9 @@
BorderThickness="0"
GlowBrush="{DynamicResource AccentColorBrush}"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<controls:MetroWindow.Resources>
<util:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
</controls:MetroWindow.Resources>
<TabControl Margin="15">
@ -100,7 +103,8 @@
Header="Allow Prerelease Signatures"
OnLabel="TESTSINGING is on"
OffLabel="TESTSINGING is off"
IsChecked="{Binding Path=AllowPrereleaseSignatures}" />
IsChecked="{Binding Path=AllowPrereleaseSignatures}"
IsEnabled="{Binding Path=IsSecureBootEnabled, Converter={StaticResource InverseBooleanConverter}}"/>
<TextBlock Grid.Row="0" Grid.Column="1"
Margin="10,0,0,0"

View File

@ -57,7 +57,17 @@ namespace DerpingDrivers
/// <summary>
/// Gets test-mode status.
/// </summary>
public string TestSigningStatus => CodeIntegrityHelper.IsTestSignEnabled ? "Enabled" : "Disabled";
public string TestSigningStatus => UefiHelper.IsRunningInUefiMode && UefiHelper.IsSecureBootEnabled
?
"Not available"
: CodeIntegrityHelper.IsTestSignEnabled
? "Enabled"
: "Disabled";
/// <summary>
/// True if SecureBoot enabled, false otherwise.
/// </summary>
public bool IsSecureBootEnabled => UefiHelper.IsRunningInUefiMode && UefiHelper.IsSecureBootEnabled;
/// <summary>
/// Gets or sets whether prerelease signatures (a.k.a. TESTSIGNING) are accepted by the kernel.

View File

@ -0,0 +1,29 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace DerpingDrivers.Util
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");
return !(bool) value;
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
throw new NotSupportedException();
}
#endregion
}
}