Skip to content

Commit 43243b3

Browse files
authored
Harden System Security v1.0.2.0 (#811)
Added an app alias for the Harden System Security. You can now launch it from commandline via HSS.exe. Added a new file association for .pol files. The app will now handle files with the extension .pol and open them in the Harden System Security application's Group Policy Editor page. They will also have a beautiful icon in the file explorer. By default, .pol files don't have any icons associated with them. When you hover over the link button for each security measure, a tiny flyout will appear that'll open the URL of the security measure in a mini browser, allowing you to quickly browse the resource and get accurate up to date information on demand. You have the option to disable this feature in the app settings. Reduced the amount of empty spaces around each security measure item in the List Views by better utilizing the available space. Reduced the amount of empty spaces in each page between the page header and the Guide button. (This change has been applied to the AppControl Manager as well.) Improved some of the security measure names in the TLS category to be more descriptive and easier to understand. Made the columns in the List View in the Group Policy Editor page resizable by offering draggable areas in the header. Added a new setting to the app settings page that allows you to control whether the List Views that show items in groups have sticky header or the header will scroll with the rest of the items. Fixed a visual issue with animations in some of the pages' toolbars. During back navigation (when using the back button), some of them would have half opacity. The settings page now shows the correct app name in the About section.
1 parent dde0e12 commit 43243b3

File tree

95 files changed

+1253
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1253
-294
lines changed

AppControl Manager/App.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@
103103
</Setter>
104104
</Style>
105105

106+
107+
<!-- The styles of the Wrap Panel which is at the top of almost every page -->
108+
<Style x:Key="PageHeaderWrapPanelStyle" TargetType="controls:WrapPanel">
109+
<Setter Property="Grid.Row" Value="0"/>
110+
<Setter Property="VerticalSpacing" Value="4"/>
111+
<Setter Property="HorizontalSpacing" Value="4"/>
112+
<Setter Property="Orientation" Value="Vertical"/>
113+
<Setter Property="Margin" Value="6,0,6,5"/>
114+
</Style>
115+
106116
</ResourceDictionary>
107117
</Application.Resources>
108118
</Application>

AppControl Manager/App.xaml.cs

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ public partial class App : Application
148148
// to this variable before using ShowAsync() method to display it.
149149
internal static ContentDialog? CurrentlyOpenContentDialog;
150150

151-
internal static NavigationService _nav => ViewModelProvider.NavigationService;
152-
153-
#if APP_CONTROL_MANAGER
154-
private static PolicyEditorVM PolicyEditorViewModel => ViewModelProvider.PolicyEditorVM;
155-
#endif
156-
157151
/// <summary>
158152
/// Initializes the singleton application object. This is the first line of authored code
159153
/// executed, and as such is the logical equivalent of main() or WinMain().
@@ -235,12 +229,7 @@ private async void TaskScheduler_UnobservedTaskException(object? sender, Unobser
235229
/// Invoked when the application is launched.
236230
/// </summary>
237231
/// <param name="args">Details about the launch request and process.</param>
238-
#if APP_CONTROL_MANAGER
239232
protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
240-
#endif
241-
#if HARDEN_SYSTEM_SECURITY
242-
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
243-
#endif
244233

245234
{
246235
// Register the Jump List tasks
@@ -467,7 +456,7 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
467456
MainWindowVM.SetCaptionButtonsFlowDirection(string.Equals(Settings.ApplicationGlobalFlowDirection, "LeftToRight", StringComparison.OrdinalIgnoreCase) ? FlowDirection.LeftToRight : FlowDirection.RightToLeft);
468457

469458
NavigationService.RestoreWindowSize(m_window.AppWindow); // Restore window size on startup
470-
_nav.mainWindowVM.OnIconsStylesChanged(Settings.IconsStyle); // Set the initial Icons styles based on the user's settings
459+
ViewModelProvider.NavigationService.mainWindowVM.OnIconsStylesChanged(Settings.IconsStyle); // Set the initial Icons styles based on the user's settings
471460
m_window.Closed += Window_Closed; // Assign event handler for the window closed event
472461
m_window.Activate();
473462

@@ -478,12 +467,13 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
478467

479468
if (!string.IsNullOrWhiteSpace(Settings.FileActivatedLaunchArg))
480469
{
481-
#if APP_CONTROL_MANAGER
470+
482471
Logger.Write(string.Format(GlobalVars.GetStr("FileActivationLaunchMessage"), Settings.FileActivatedLaunchArg));
483472

473+
#if APP_CONTROL_MANAGER
484474
try
485475
{
486-
await PolicyEditorViewModel.OpenInPolicyEditor(Settings.FileActivatedLaunchArg);
476+
await ViewModelProvider.PolicyEditorVM.OpenInPolicyEditor(Settings.FileActivatedLaunchArg);
487477
}
488478
catch (Exception ex)
489479
{
@@ -511,7 +501,7 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
511501
{
512502
case ViewModelBase.LaunchProtocolActions.PolicyEditor:
513503
{
514-
await PolicyEditorViewModel.OpenInPolicyEditor(Settings.LaunchActivationFilePath);
504+
await ViewModelProvider.PolicyEditorVM.OpenInPolicyEditor(Settings.LaunchActivationFilePath);
515505
break;
516506
}
517507
case ViewModelBase.LaunchProtocolActions.FileSignature:
@@ -554,6 +544,30 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
554544
Settings.LaunchActivationAction = string.Empty;
555545
}
556546
#endif
547+
548+
549+
#if HARDEN_SYSTEM_SECURITY
550+
551+
try
552+
{
553+
await ViewModelProvider.GroupPolicyEditorVM.OpenInGroupPolicyEditor(Settings.FileActivatedLaunchArg);
554+
}
555+
catch (Exception ex)
556+
{
557+
Logger.Write(ErrorWriter.FormatException(ex));
558+
559+
// Continue doing the normal navigation if there was a problem
560+
InitialNav();
561+
}
562+
finally
563+
{
564+
// Clear the file activated launch args after it's been used
565+
Settings.FileActivatedLaunchArg = string.Empty;
566+
}
567+
568+
#endif
569+
570+
557571
}
558572
else
559573
{
@@ -575,10 +589,10 @@ private static void InitialNav()
575589
{
576590
#if APP_CONTROL_MANAGER
577591
// Navigate to the CreatePolicy page when the window is loaded and is Admin, else Policy Editor
578-
_nav.Navigate(IsElevated ? typeof(Pages.CreatePolicy) : typeof(Pages.PolicyEditor));
592+
ViewModelProvider.NavigationService.Navigate(IsElevated ? typeof(Pages.CreatePolicy) : typeof(Pages.PolicyEditor));
579593
#endif
580594
#if HARDEN_SYSTEM_SECURITY
581-
_nav.Navigate(IsElevated ? typeof(Pages.Protect) : typeof(Pages.Protects.NonAdmin));
595+
ViewModelProvider.NavigationService.Navigate(IsElevated ? typeof(Pages.Protect) : typeof(Pages.Protects.NonAdmin));
582596
#endif
583597
}
584598

AppControl Manager/AppControl Manager.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<UseWinUI>true</UseWinUI>
1010
<EnableMsixTooling>true</EnableMsixTooling>
1111

12+
<!-- https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/static -->
13+
<WebView2LoaderPreference>Static</WebView2LoaderPreference>
14+
1215
<!-- Defined by CsWinRT https://github.com/microsoft/CsWinRT
1316
Using the latest version as defined in the CsWinRT release notes guarantees that we use the latest CsWinRT projections features.
1417

AppControl Manager/AppSettings/Main.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ internal Main(ApplicationDataContainer LocalSettings)
5656
MainWindowHeight = ReadValue(nameof(MainWindowHeight), MainWindowHeight);
5757
MainWindowIsMaximized = ReadValue(nameof(MainWindowIsMaximized), MainWindowIsMaximized);
5858
ListViewsVerticalCentering = ReadValue(nameof(ListViewsVerticalCentering), ListViewsVerticalCentering);
59+
StickyHeadersForListViews = ReadValue(nameof(StickyHeadersForListViews), StickyHeadersForListViews);
5960
CacheSecurityCatalogsScanResults = ReadValue(nameof(CacheSecurityCatalogsScanResults), CacheSecurityCatalogsScanResults);
6061
PromptForElevationOnStartup = ReadValue(nameof(PromptForElevationOnStartup), PromptForElevationOnStartup);
6162
AutomaticAssignmentSidebar = ReadValue(nameof(AutomaticAssignmentSidebar), AutomaticAssignmentSidebar);
@@ -68,6 +69,7 @@ internal Main(ApplicationDataContainer LocalSettings)
6869
LaunchActivationAction = ReadValue(nameof(LaunchActivationAction), LaunchActivationAction);
6970
ScreenShield = ReadValue(nameof(ScreenShield), ScreenShield);
7071
PublishUserActivityInTheOS = ReadValue(nameof(PublishUserActivityInTheOS), PublishUserActivityInTheOS);
72+
LinkPreviewsForSecurityMeasure = ReadValue(nameof(LinkPreviewsForSecurityMeasure), LinkPreviewsForSecurityMeasure);
7173
}
7274

7375
/// <summary>
@@ -264,6 +266,22 @@ internal bool ListViewsVerticalCentering
264266
}
265267
}
266268

269+
/// <summary>
270+
/// Whether ListView headers remain visible when scrolling through the list content.
271+
/// Only applies to ListViews that have items grouping.
272+
/// </summary>
273+
internal bool StickyHeadersForListViews
274+
{
275+
get;
276+
set
277+
{
278+
if (SP(ref field, value))
279+
{
280+
SaveValue(nameof(StickyHeadersForListViews), field);
281+
}
282+
}
283+
} = true;
284+
267285
/// <summary>
268286
/// Cache the security catalog scan results to speed up various components of the app that use them.
269287
/// </summary>
@@ -448,4 +466,19 @@ internal bool PublishUserActivityInTheOS
448466
}
449467
}
450468
} = true;
469+
470+
/// <summary>
471+
/// Whether link previews are enabled for security measures when hovering over.
472+
/// </summary>
473+
internal bool LinkPreviewsForSecurityMeasure
474+
{
475+
get;
476+
set
477+
{
478+
if (SP(ref field, value))
479+
{
480+
SaveValue(nameof(LinkPreviewsForSecurityMeasure), field);
481+
}
482+
}
483+
} = true;
451484
}

AppControl Manager/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ homepage = "https://github.com/HotCakeX/Harden-Windows-Security"
1717
repository = "https://github.com/HotCakeX/Harden-Windows-Security"
1818
documentation = "https://github.com/HotCakeX/Harden-Windows-Security"
1919
publish = false
20-
rust-version = "1.90"
20+
rust-version = "1.91"
2121

2222
[profile.release]
2323
codegen-units = 1

AppControl Manager/CustomUIElements/SigningDetailsDialog.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using AppControlManager.IntelGathering;
2424
using AppControlManager.Main;
2525
using AppControlManager.Others;
26+
using AppControlManager.ViewModels;
2627
using Microsoft.UI.Xaml;
2728
using Microsoft.UI.Xaml.Controls;
2829
using Microsoft.UI.Xaml.Input;
@@ -191,7 +192,7 @@ private void OpenAppSettingsButton_Click(object sender, RoutedEventArgs e)
191192
// Hide the dialog box
192193
this.Hide();
193194

194-
App._nav.Navigate(typeof(Pages.Settings), null);
195+
ViewModelProvider.NavigationService.Navigate(typeof(Pages.Settings), null);
195196
}
196197

197198
/// <summary>

AppControl Manager/CustomUIElements/SigningDetailsDialogForRemoval.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using AppControlManager.IntelGathering;
2424
using AppControlManager.Main;
2525
using AppControlManager.Others;
26+
using AppControlManager.ViewModels;
2627
using Microsoft.UI.Xaml;
2728
using Microsoft.UI.Xaml.Controls;
2829
using Microsoft.UI.Xaml.Input;
@@ -194,7 +195,7 @@ private void OpenAppSettingsButton_Click()
194195
// Hide the dialog box
195196
this.Hide();
196197

197-
App._nav.Navigate(typeof(Pages.Settings), null);
198+
ViewModelProvider.NavigationService.Navigate(typeof(Pages.Settings), null);
198199
}
199200

200201
/// <summary>

AppControl Manager/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440
Padding="10"
441441
AutomationProperties.LandmarkType="Custom"
442442
AutomationProperties.LocalizedLandmarkType="Bread Crumb Bar Navigation and Page Title"
443-
Margin="20,10,0,10"
443+
Margin="20,10,0,5"
444444
ItemsSource="{x:Bind ViewModel.Breadcrumbs}"
445445
ItemClicked="{x:Bind Nav.BreadcrumbBar_ItemClicked}">
446446

@@ -464,7 +464,7 @@
464464

465465
<!-- Global margin settings for every page's content -->
466466
<Frame x:Name="ContentFrame"
467-
Margin="15,15,15,10"
467+
Margin="15,10,15,10"
468468
Grid.Row="1"
469469
AutomationProperties.LandmarkType="Main" />
470470

AppControl Manager/Others/FileDialogHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using System.IO;
2121
using System.Runtime.InteropServices;
2222
#if HARDEN_SYSTEM_SECURITY
23-
using HardenSystemSecurity;
2423
#endif
2524

2625
namespace AppControlManager.Others;
@@ -30,7 +29,12 @@ internal unsafe static class FileDialogHelper
3029
// Location where File/Folder picker dialog will be opened
3130
// It is only the directory where the first dialog will be opened in, it will then be replaced by the directory
3231
// That user browses to to pick a single file/directory
32+
#if APP_CONTROL_MANAGER
3333
private static string DirectoryToOpen = App.IsElevated ? GlobalVars.UserConfigDir : Path.GetPathRoot(Environment.SystemDirectory)!;
34+
#endif
35+
#if HARDEN_SYSTEM_SECURITY
36+
private static string DirectoryToOpen = Path.GetPathRoot(Environment.SystemDirectory)!;
37+
#endif
3438

3539
[StructLayout(LayoutKind.Sequential)]
3640
internal struct StringArray

AppControl Manager/Others/GlobalVars.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using System;
1919
using System.IO;
2020
#if HARDEN_SYSTEM_SECURITY
21-
using HardenSystemSecurity;
2221
#endif
2322
using Microsoft.Windows.ApplicationModel.Resources;
2423

@@ -84,7 +83,6 @@ internal static string GetStr(string key)
8483
Environment.GetEnvironmentVariable("SystemDrive") + @"\",
8584
"Windows", "schemas", "CodeIntegrity", "cipolicy.xsd");
8685

87-
8886
#if HARDEN_SYSTEM_SECURITY
8987
// Storing the path to the app's folder in the Program Files
9088
internal static readonly string UserConfigDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Harden System Security");
@@ -187,6 +185,8 @@ internal static string GetStr(string key)
187185
/// </summary>
188186
internal static readonly string SystemDrive = Environment.GetEnvironmentVariable("SystemDrive") ?? "C:";
189187

188+
#if APP_CONTROL_MANAGER
189+
190190
static GlobalVars()
191191
{
192192
if (!App.IsElevated)
@@ -198,4 +198,7 @@ static GlobalVars()
198198
_ = Directory.CreateDirectory(UserConfigDir);
199199
}
200200
}
201+
202+
#endif
203+
201204
}

0 commit comments

Comments
 (0)