Skip to content

Commit

Permalink
AppControl Manager v1.3.0.0 and WDACConfig v0.4.9 (#398)
Browse files Browse the repository at this point in the history
Look at the PR notes for full change log: #398


* Added multiple pages and functionalities

Added multiple pages and functionalities

* Final part of the development

Final part of the development

---------

Signed-off-by: Violet Hansen <[email protected]>
  • Loading branch information
HotCakeX authored Nov 16, 2024
1 parent d2ddf1a commit 8dff2c9
Show file tree
Hide file tree
Showing 149 changed files with 11,399 additions and 4,124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Installing the necessary programs
run: |
winget source update
winget install --id Microsoft.DotNet.SDK.Preview --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
winget install --id Microsoft.DotNet.SDK.9 --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
winget install --id Microsoft.VisualStudio.2022.BuildTools --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
winget install --id Microsoft.WindowsSDK.10.0.26100 --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
# https://github.com/microsoft/winget-cli/issues/1705
Expand Down
21 changes: 21 additions & 0 deletions AppControl Manager/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,24 @@ dotnet_diagnostic.CA1507.severity = error

# IDE0001: Simplify name
dotnet_diagnostic.IDE0001.severity = error

# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
dotnet_diagnostic.SYSLIB1045.severity = error

# Use collection expression for array (IDE0300)
dotnet_diagnostic.IDE0300.severity = error

# Inline variable declaration (IDE0018)
dotnet_diagnostic.IDE0018.severity = error

# IDE0044: Add readonly modifier
dotnet_diagnostic.IDE0044.severity = error

# IDE0031: Use null propagation
dotnet_diagnostic.IDE0031.severity = error

# SYSLIB1092: The usage of 'LibraryImportAttribute' does not follow recommendations.
dotnet_diagnostic.SYSLIB1092.severity = error

# CA2263: Prefer generic overload when type is known
dotnet_diagnostic.CA2263.severity = error
75 changes: 72 additions & 3 deletions AppControl Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using static WDACConfig.AppSettings;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand All @@ -30,6 +31,11 @@ public partial class App : Application
// Convert it to a normal Version object
internal static readonly Version currentAppVersion = new(packageVersion.Major, packageVersion.Minor, packageVersion.Build, packageVersion.Revision);

// Check if another instance of AppControl Manager is running
private static bool IsUniqueAppInstance;

private static Mutex? _mutex;
private const string MutexName = "AppControlManagerRunning";

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
Expand All @@ -45,14 +51,72 @@ public App()

// to handle unhandled exceptions
this.UnhandledException += App_UnhandledException;


#region

// Check for the SoundSetting in the local settings
bool soundSetting = AppSettings.GetSetting<bool>(SettingKeys.SoundSetting);

if (soundSetting)
{
ElementSoundPlayer.State = ElementSoundPlayerState.On;
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.On;
}
else
{
ElementSoundPlayer.State = ElementSoundPlayerState.Off;
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.Off;
}

// Subscribe to the SoundSettingChanged event to listen for changes globally
SoundManager.SoundSettingChanged += OnSoundSettingChanged;

#endregion

}



/// <summary>
/// Event handler for when the sound setting is changed.
/// </summary>
/// <param name="isSoundOn"></param>
private void OnSoundSettingChanged(bool isSoundOn)
{
// Set the global sound state based on the event
if (isSoundOn)
{
ElementSoundPlayer.State = ElementSoundPlayerState.On;
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.On;
}
else
{
ElementSoundPlayer.State = ElementSoundPlayerState.Off;
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.Off;
}
}



/// <summary>
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{

// Creates a named Mutex with the specified unique name
// The first parameter specifies that this instance initially owns the Mutex if created successfully
// The third parameter indicates whether this application instance is the first/unique one
// If "IsUniqueAppInstance" is true, it means no other instance of the app is running; otherwise, another instance exists and it will be false
_mutex = new Mutex(true, MutexName, out IsUniqueAppInstance);

if (!IsUniqueAppInstance)
{
Logger.Write("There is another instance of the AppControl Manager running!");
}

m_window = new MainWindow();
m_window.Closed += Window_Closed; // Assign event handler for the window closed event
m_window.Activate();
Expand Down Expand Up @@ -87,19 +151,24 @@ private async void App_UnhandledException(object sender, Microsoft.UI.Xaml.Unhan
/// </summary>
private void Window_Closed(object sender, WindowEventArgs e)
{
// Clean up the staging area
if (Directory.Exists(GlobalVars.StagingArea))
// Clean up the staging area only if there are no other instance of the AppControl Manager running
// Don't want to disrupt their workflow
if (Directory.Exists(GlobalVars.StagingArea) && IsUniqueAppInstance)
{
Directory.Delete(GlobalVars.StagingArea, true);
}

// Release the Mutex
_mutex?.Dispose();
}


/// <summary>
/// Displays a ContentDialog with the error message.
/// </summary>
private async Task ShowErrorDialogAsync(Exception ex)
{
if (m_window != null)
if (m_window is not null)
{
// Wait for the semaphore before showing a new error dialog
await _dialogSemaphore.WaitAsync();
Expand Down
65 changes: 62 additions & 3 deletions AppControl Manager/AppControl Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<Nullable>enable</Nullable>
<WindowsSdkPackageVersion>10.0.26100.38</WindowsSdkPackageVersion>

<!-- Defined by CsWinRT https://github.com/microsoft/CsWinRT
Using the latest version as defined in the CsWinRT release notes guarantees that we use the latest CsWinRT projections features.
The reason Windows.SDK.NET.Ref is released in batches of 3: https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref
is that they have different targets. Lowest one is .NET 6, middle one is .NET 8 without UWP XAML and highest one is .NET 8 with UWP XAML.
-->
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>

<!--
By default .NET runtimes are contained in the MSIX. This line will also include the WindowsAppSDK in the MSIX file
Expand Down Expand Up @@ -68,7 +75,7 @@
<AssemblyName>AppControlManager</AssemblyName>
<PublishAot>False</PublishAot>
<ErrorReport>send</ErrorReport>
<FileVersion>1.2.0.0</FileVersion>
<FileVersion>1.3.0.0</FileVersion>
<AssemblyVersion>$(FileVersion)</AssemblyVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand All @@ -88,16 +95,18 @@
<!-- Nuget packages -->
<ItemGroup>
<!-- <PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.DataTable" Version="0.1.241015-build.1760" /> -->
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.ColorPicker" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.RadialGauge" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.6" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241106002" />
<PackageReference Include="System.Diagnostics.EventLog" Version="9.0.0" />
<PackageReference Include="System.Management.Automation" Version="7.4.6" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.0" />
Expand Down Expand Up @@ -140,11 +149,18 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Pages\AllowNewAppsDataGrid.xaml" />
<None Remove="Pages\AllowNewAppsEventLogsDataGrid.xaml" />
<None Remove="Pages\AllowNewAppsLocalFilesDataGrid.xaml" />
<None Remove="Pages\AllowNewAppsStart.xaml" />
<None Remove="Pages\ConfigurePolicyRuleOptions.xaml" />
<None Remove="Pages\Deployment.xaml" />
<None Remove="Pages\EventLogsPolicyCreation.xaml" />
<None Remove="Pages\GetCIHashes.xaml" />
<None Remove="Pages\GetSecurePolicySettings.xaml" />
<None Remove="Pages\GitHubDocumentation.xaml" />
<None Remove="Pages\Logs.xaml" />
<None Remove="Pages\MDEAHPolicyCreation.xaml" />
<None Remove="Pages\MicrosoftDocumentation.xaml" />
<None Remove="Pages\Settings.xaml" />
<None Remove="Pages\Simulation.xaml" />
Expand Down Expand Up @@ -189,6 +205,26 @@
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\AllowNewApps.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\MDEAHPolicyCreation.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\EventLogsPolicyCreation.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\Deployment.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\Update.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -229,5 +265,28 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="Pages\AllowNewApps\" />
</ItemGroup>
<ItemGroup>
<Page Update="Pages\AllowNewAppsStart.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\AllowNewAppsLocalFilesDataGrid.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\AllowNewAppsEventLogsDataGrid.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="Pages\AllowNewAppsDataGrid.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

</Project>
Loading

0 comments on commit 8dff2c9

Please sign in to comment.