Skip to content

Commit

Permalink
Added Application Control Status
Browse files Browse the repository at this point in the history
Added Application Control Status to the System Information page
  • Loading branch information
HotCakeX committed Dec 21, 2024
1 parent d3186c6 commit e0d4fab
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
42 changes: 28 additions & 14 deletions AppControl Manager/Pages/SystemInformation/CodeIntegrityInfo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,37 @@
xmlns:ci="using:AppControlManager.CodeIntegrity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
mc:Ignorable="d">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ScrollViewer>

<Button x:Name="RetrieveCodeIntegrityInfo"
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Button x:Name="RetrieveCodeIntegrityInfo"
Content="Retrieve Code Integrity Info"
Click="RetrieveCodeIntegrityInfo_Click"
ToolTipService.ToolTip="Retrieve the latest effective Code Integrity information from the current system"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Style="{StaticResource AccentButtonStyle}"
Margin="10"
Margin="0,0,0,10"
Grid.Row="0"/>

<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" Margin="10,10,10,10">
<ListView Name="CodeIntegrityInfoListView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionMode="None">
<ListView Grid.Row="1" Name="CodeIntegrityInfoListView" HorizontalAlignment="Center" SelectionMode="None">
<!-- ListView Headers -->
<ListView.Header>
<Grid Padding="16,12" ColumnSpacing="16">
<Grid ColumnSpacing="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="Effective Code Integrity Features" />
<TextBlock Margin="0,10,0,10" Style="{ThemeResource TitleTextBlockStyle}" HorizontalAlignment="Center" Text="Effective Code Integrity Features" />
</Grid>
</ListView.Header>

Expand All @@ -46,7 +50,7 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Bind only the Description properties from CodeIntegrityOption -->
<TextBlock Text="{x:Bind Description}" Margin="0,0,0,10" />
<TextBox IsReadOnly="True" TextWrapping="Wrap" Text="{x:Bind Description}" Margin="0,0,0,10" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
Expand All @@ -57,6 +61,16 @@
</Style>
</ListView.ItemContainerStyle>
</ListView>
</ScrollViewer>
</Grid>


<controls:WrapPanel Margin="10,10,0,10" HorizontalAlignment="Center" Orientation="Vertical" HorizontalSpacing="10" VerticalSpacing="15" Grid.Row="2">
<TextBlock Text="Application Control for Business Status" Style="{ThemeResource TitleTextBlockStyle}" />
<TextBox x:Name="UMCI" TextWrapping="Wrap" IsReadOnly="True" Header="User Mode Code Integrity" />
<TextBox x:Name="KMCI" TextWrapping="Wrap" IsReadOnly="True" Header="Kernel Mode Code Integrity" />
</controls:WrapPanel>

</Grid>

</ScrollViewer>

</Page>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;

namespace AppControlManager.Pages;

Expand All @@ -9,15 +10,42 @@ public CodeIntegrityInfo()
{
this.InitializeComponent();

this.NavigationCacheMode = Microsoft.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
this.NavigationCacheMode = NavigationCacheMode.Enabled;
}


/// <summary>
/// Local method to convert numbers to their actual string values
/// </summary>
/// <param name="status"></param>
/// <returns></returns>
private static string? GetPolicyStatus(uint? status) => status switch
{
0 => "Disabled/Not running",
1 => "Audit mode",
2 => "Enforced Mode",
_ => null
};


/// <summary>
/// Event handler for the retrieve code integrity information button
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RetrieveCodeIntegrityInfo_Click(object sender, RoutedEventArgs e)
{
// Get the system code integrity information
CodeIntegrity.SystemCodeIntegrityInfo codeIntegrityInfoResult = CodeIntegrity.DetailsRetrieval.Get();

// Bind the CodeIntegrityDetails (List<CodeIntegrityOption>) to the ListView
CodeIntegrityInfoListView.ItemsSource = codeIntegrityInfoResult.CodeIntegrityDetails;

// Get the Application Control Status
DeviceGuardStatus? DGStatus = DeviceGuardInfo.GetDeviceGuardStatus();

UMCI.Text = GetPolicyStatus(DGStatus?.UsermodeCodeIntegrityPolicyEnforcementStatus);
KMCI.Text = GetPolicyStatus(DGStatus?.CodeIntegrityPolicyEnforcementStatus);

}
}

0 comments on commit e0d4fab

Please sign in to comment.