Skip to content

Commit 8dff2c9

Browse files
authored
AppControl Manager v1.3.0.0 and WDACConfig v0.4.9 (#398)
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]>
1 parent d2ddf1a commit 8dff2c9

File tree

149 files changed

+11399
-4124
lines changed

Some content is hidden

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

149 files changed

+11399
-4124
lines changed

.github/workflows/Build AppControl Manager MSIX Package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Installing the necessary programs
5656
run: |
5757
winget source update
58-
winget install --id Microsoft.DotNet.SDK.Preview --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
58+
winget install --id Microsoft.DotNet.SDK.9 --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
5959
winget install --id Microsoft.VisualStudio.2022.BuildTools --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
6060
winget install --id Microsoft.WindowsSDK.10.0.26100 --exact --accept-package-agreements --accept-source-agreements --uninstall-previous --force --source winget
6161
# https://github.com/microsoft/winget-cli/issues/1705

AppControl Manager/.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,24 @@ dotnet_diagnostic.CA1507.severity = error
344344

345345
# IDE0001: Simplify name
346346
dotnet_diagnostic.IDE0001.severity = error
347+
348+
# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
349+
dotnet_diagnostic.SYSLIB1045.severity = error
350+
351+
# Use collection expression for array (IDE0300)
352+
dotnet_diagnostic.IDE0300.severity = error
353+
354+
# Inline variable declaration (IDE0018)
355+
dotnet_diagnostic.IDE0018.severity = error
356+
357+
# IDE0044: Add readonly modifier
358+
dotnet_diagnostic.IDE0044.severity = error
359+
360+
# IDE0031: Use null propagation
361+
dotnet_diagnostic.IDE0031.severity = error
362+
363+
# SYSLIB1092: The usage of 'LibraryImportAttribute' does not follow recommendations.
364+
dotnet_diagnostic.SYSLIB1092.severity = error
365+
366+
# CA2263: Prefer generic overload when type is known
367+
dotnet_diagnostic.CA2263.severity = error

AppControl Manager/App.xaml.cs

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Threading;
77
using System.Threading.Tasks;
88
using Windows.ApplicationModel;
9+
using static WDACConfig.AppSettings;
910

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

34+
// Check if another instance of AppControl Manager is running
35+
private static bool IsUniqueAppInstance;
36+
37+
private static Mutex? _mutex;
38+
private const string MutexName = "AppControlManagerRunning";
3339

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

4652
// to handle unhandled exceptions
4753
this.UnhandledException += App_UnhandledException;
54+
55+
56+
#region
57+
58+
// Check for the SoundSetting in the local settings
59+
bool soundSetting = AppSettings.GetSetting<bool>(SettingKeys.SoundSetting);
60+
61+
if (soundSetting)
62+
{
63+
ElementSoundPlayer.State = ElementSoundPlayerState.On;
64+
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.On;
65+
}
66+
else
67+
{
68+
ElementSoundPlayer.State = ElementSoundPlayerState.Off;
69+
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.Off;
70+
}
71+
72+
// Subscribe to the SoundSettingChanged event to listen for changes globally
73+
SoundManager.SoundSettingChanged += OnSoundSettingChanged;
74+
75+
#endregion
76+
77+
}
78+
79+
80+
81+
/// <summary>
82+
/// Event handler for when the sound setting is changed.
83+
/// </summary>
84+
/// <param name="isSoundOn"></param>
85+
private void OnSoundSettingChanged(bool isSoundOn)
86+
{
87+
// Set the global sound state based on the event
88+
if (isSoundOn)
89+
{
90+
ElementSoundPlayer.State = ElementSoundPlayerState.On;
91+
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.On;
92+
}
93+
else
94+
{
95+
ElementSoundPlayer.State = ElementSoundPlayerState.Off;
96+
ElementSoundPlayer.SpatialAudioMode = ElementSpatialAudioMode.Off;
97+
}
4898
}
4999

100+
101+
50102
/// <summary>
51103
/// Invoked when the application is launched.
52104
/// </summary>
53105
/// <param name="args">Details about the launch request and process.</param>
54106
protected override void OnLaunched(LaunchActivatedEventArgs args)
55107
{
108+
109+
// Creates a named Mutex with the specified unique name
110+
// The first parameter specifies that this instance initially owns the Mutex if created successfully
111+
// The third parameter indicates whether this application instance is the first/unique one
112+
// If "IsUniqueAppInstance" is true, it means no other instance of the app is running; otherwise, another instance exists and it will be false
113+
_mutex = new Mutex(true, MutexName, out IsUniqueAppInstance);
114+
115+
if (!IsUniqueAppInstance)
116+
{
117+
Logger.Write("There is another instance of the AppControl Manager running!");
118+
}
119+
56120
m_window = new MainWindow();
57121
m_window.Closed += Window_Closed; // Assign event handler for the window closed event
58122
m_window.Activate();
@@ -87,19 +151,24 @@ private async void App_UnhandledException(object sender, Microsoft.UI.Xaml.Unhan
87151
/// </summary>
88152
private void Window_Closed(object sender, WindowEventArgs e)
89153
{
90-
// Clean up the staging area
91-
if (Directory.Exists(GlobalVars.StagingArea))
154+
// Clean up the staging area only if there are no other instance of the AppControl Manager running
155+
// Don't want to disrupt their workflow
156+
if (Directory.Exists(GlobalVars.StagingArea) && IsUniqueAppInstance)
92157
{
93158
Directory.Delete(GlobalVars.StagingArea, true);
94159
}
160+
161+
// Release the Mutex
162+
_mutex?.Dispose();
95163
}
96164

165+
97166
/// <summary>
98167
/// Displays a ContentDialog with the error message.
99168
/// </summary>
100169
private async Task ShowErrorDialogAsync(Exception ex)
101170
{
102-
if (m_window != null)
171+
if (m_window is not null)
103172
{
104173
// Wait for the semaphore before showing a new error dialog
105174
await _dialogSemaphore.WaitAsync();

AppControl Manager/AppControl Manager.csproj

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
<UseWinUI>true</UseWinUI>
2020
<EnableMsixTooling>true</EnableMsixTooling>
2121
<Nullable>enable</Nullable>
22-
<WindowsSdkPackageVersion>10.0.26100.38</WindowsSdkPackageVersion>
22+
23+
<!-- Defined by CsWinRT https://github.com/microsoft/CsWinRT
24+
Using the latest version as defined in the CsWinRT release notes guarantees that we use the latest CsWinRT projections features.
25+
26+
The reason Windows.SDK.NET.Ref is released in batches of 3: https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref
27+
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.
28+
-->
29+
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>
2330

2431
<!--
2532
By default .NET runtimes are contained in the MSIX. This line will also include the WindowsAppSDK in the MSIX file
@@ -68,7 +75,7 @@
6875
<AssemblyName>AppControlManager</AssemblyName>
6976
<PublishAot>False</PublishAot>
7077
<ErrorReport>send</ErrorReport>
71-
<FileVersion>1.2.0.0</FileVersion>
78+
<FileVersion>1.3.0.0</FileVersion>
7279
<AssemblyVersion>$(FileVersion)</AssemblyVersion>
7380
<NeutralLanguage>en-US</NeutralLanguage>
7481
<PackageLicenseFile>LICENSE</PackageLicenseFile>
@@ -88,16 +95,18 @@
8895
<!-- Nuget packages -->
8996
<ItemGroup>
9097
<!-- <PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.DataTable" Version="0.1.241015-build.1760" /> -->
98+
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.1.240916" />
9199
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.1.240916" />
92100
<PackageReference Include="CommunityToolkit.WinUI.Controls.ColorPicker" Version="8.1.240916" />
93101
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" />
94102
<PackageReference Include="CommunityToolkit.WinUI.Controls.RadialGauge" Version="8.1.240916" />
103+
<PackageReference Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240916" />
95104
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
96105
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
97106
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.6" />
98107
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
99108
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
100-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
109+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241106002" />
101110
<PackageReference Include="System.Diagnostics.EventLog" Version="9.0.0" />
102111
<PackageReference Include="System.Management.Automation" Version="7.4.6" />
103112
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.0" />
@@ -140,11 +149,18 @@
140149
</PropertyGroup>
141150

142151
<ItemGroup>
152+
<None Remove="Pages\AllowNewAppsDataGrid.xaml" />
153+
<None Remove="Pages\AllowNewAppsEventLogsDataGrid.xaml" />
154+
<None Remove="Pages\AllowNewAppsLocalFilesDataGrid.xaml" />
155+
<None Remove="Pages\AllowNewAppsStart.xaml" />
143156
<None Remove="Pages\ConfigurePolicyRuleOptions.xaml" />
157+
<None Remove="Pages\Deployment.xaml" />
158+
<None Remove="Pages\EventLogsPolicyCreation.xaml" />
144159
<None Remove="Pages\GetCIHashes.xaml" />
145160
<None Remove="Pages\GetSecurePolicySettings.xaml" />
146161
<None Remove="Pages\GitHubDocumentation.xaml" />
147162
<None Remove="Pages\Logs.xaml" />
163+
<None Remove="Pages\MDEAHPolicyCreation.xaml" />
148164
<None Remove="Pages\MicrosoftDocumentation.xaml" />
149165
<None Remove="Pages\Settings.xaml" />
150166
<None Remove="Pages\Simulation.xaml" />
@@ -189,6 +205,26 @@
189205
<PackagePath>\</PackagePath>
190206
</None>
191207
</ItemGroup>
208+
<ItemGroup>
209+
<Page Update="Pages\AllowNewApps.xaml">
210+
<Generator>MSBuild:Compile</Generator>
211+
</Page>
212+
</ItemGroup>
213+
<ItemGroup>
214+
<Page Update="Pages\MDEAHPolicyCreation.xaml">
215+
<Generator>MSBuild:Compile</Generator>
216+
</Page>
217+
</ItemGroup>
218+
<ItemGroup>
219+
<Page Update="Pages\EventLogsPolicyCreation.xaml">
220+
<Generator>MSBuild:Compile</Generator>
221+
</Page>
222+
</ItemGroup>
223+
<ItemGroup>
224+
<Page Update="Pages\Deployment.xaml">
225+
<Generator>MSBuild:Compile</Generator>
226+
</Page>
227+
</ItemGroup>
192228
<ItemGroup>
193229
<Page Update="Pages\Update.xaml">
194230
<Generator>MSBuild:Compile</Generator>
@@ -229,5 +265,28 @@
229265
<Generator>MSBuild:Compile</Generator>
230266
</Page>
231267
</ItemGroup>
268+
<ItemGroup>
269+
<Folder Include="Pages\AllowNewApps\" />
270+
</ItemGroup>
271+
<ItemGroup>
272+
<Page Update="Pages\AllowNewAppsStart.xaml">
273+
<Generator>MSBuild:Compile</Generator>
274+
</Page>
275+
</ItemGroup>
276+
<ItemGroup>
277+
<Page Update="Pages\AllowNewAppsLocalFilesDataGrid.xaml">
278+
<Generator>MSBuild:Compile</Generator>
279+
</Page>
280+
</ItemGroup>
281+
<ItemGroup>
282+
<Page Update="Pages\AllowNewAppsEventLogsDataGrid.xaml">
283+
<Generator>MSBuild:Compile</Generator>
284+
</Page>
285+
</ItemGroup>
286+
<ItemGroup>
287+
<Page Update="Pages\AllowNewAppsDataGrid.xaml">
288+
<Generator>MSBuild:Compile</Generator>
289+
</Page>
290+
</ItemGroup>
232291

233292
</Project>

0 commit comments

Comments
 (0)