Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit a791743

Browse files
authored
Develop (#16)
* groundwork for unit tests * fixing red border to datepicker * Adding Windows Remediation Service and making service list configurable * Adding lock check to Hosts file
1 parent 5236b60 commit a791743

40 files changed

Lines changed: 943 additions & 404 deletions

Wu10Man.sln

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27004.2009
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wu10Man", "Wu10Man\Wu10Man.csproj", "{5162DE0E-A9CE-480D-A550-E4F8833E5D26}"
7-
EndProject
8-
Global
9-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|Any CPU = Debug|Any CPU
11-
Release|Any CPU = Release|Any CPU
12-
EndGlobalSection
13-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.Build.0 = Release|Any CPU
18-
EndGlobalSection
19-
GlobalSection(SolutionProperties) = preSolution
20-
HideSolutionNode = FALSE
21-
EndGlobalSection
22-
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {5FF65910-90B3-413F-B7D3-A1F3D40FC5C1}
24-
EndGlobalSection
25-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29025.244
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wu10Man", "Wu10Man\Wu10Man.csproj", "{5162DE0E-A9CE-480D-A550-E4F8833E5D26}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5FF65910-90B3-413F-B7D3-A1F3D40FC5C1}
24+
EndGlobalSection
25+
EndGlobal

Wu10Man/App.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22
<configuration>
33
<appSettings>
44
<add key="WindowsUpdateUrls" value="stats.microsoft.com,download.microsoft.com,update.microsoft.com,windowsupdate.microsoft.com,windowsupdate.com,download.windowsupdate.com,ntservicepack.microsoft.com,wustat.windows.com" />
5+
<add key="WindowsServiceNames" value="wuauserv,TrustedInstaller,WaaSMedicSvc,sedsvc" />
6+
<add key="ClientSettingsProvider.ServiceUri" value="" />
57
</appSettings>
68
<startup>
79
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
810
</startup>
11+
<system.web>
12+
<membership defaultProvider="ClientAuthenticationMembershipProvider">
13+
<providers>
14+
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
15+
</providers>
16+
</membership>
17+
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
18+
<providers>
19+
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
20+
</providers>
21+
</roleManager>
22+
</system.web>
923
</configuration>

Wu10Man/App.xaml.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
using System;
1+
using Autofac;
2+
using System;
23
using System.Windows;
4+
using WereDev.Utils.Wu10Man.Editors;
5+
using WereDev.Utils.Wu10Man.Interfaces;
36
using WereDev.Utils.Wu10Man.Helpers;
47
using WereDev.Utils.Wu10Man.UserWindows;
8+
using WereDev.Utils.Wu10Man.Utilites;
9+
using System.Linq;
10+
using WereDev.Utils.Wu10Man.Utilites.Models;
511

612
namespace WereDev.Utils.Wu10Man
713
{
@@ -15,6 +21,7 @@ public App() : base()
1521
Wu10Logger.LogInfo("Application starting");
1622
try
1723
{
24+
RegisterDependencies();
1825
WriteStartupLogs();
1926
this.Dispatcher.UnhandledException += OnDispatcherUnhandledException;
2027
this.MainWindow = new MainWindow();
@@ -26,10 +33,26 @@ public App() : base()
2633
{
2734
Wu10Logger.LogError(ex);
2835
MessageBox.Show("An error occured attempting to initialize the application. Check the log file for more details.", "Error!", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
29-
this.Shutdown();
36+
base.Shutdown();
3037
}
3138
}
3239

40+
private void RegisterDependencies()
41+
{
42+
var builder = new ContainerBuilder();
43+
builder.Register<IWindowsServices>((context, parameters) => { return GetWindowsServices(); });
44+
builder.RegisterType<FilesHelper>().As<IFilesHelper>();
45+
builder.RegisterType<HostsFileEditor>().As<IHostsFileEditor>();
46+
builder.RegisterType<RegistryEditor>().As<IRegistryEditor>();
47+
builder.RegisterType<ServiceCredentialsEditor>().As<IServiceCredentialsEditor>();
48+
builder.RegisterType<TokenEditor>().As<ITokenEditor>();
49+
builder.RegisterType<WindowsServiceManager>().As<IWindowsServiceManager>();
50+
builder.RegisterType<WindowsServiceProviderFactory>().As<IWindowsServiceProviderFactory>();
51+
52+
53+
DependencyManager.Container = builder.Build();
54+
}
55+
3356
protected override void OnExit(ExitEventArgs e)
3457
{
3558
Wu10Logger.LogInfo("Application ended");
@@ -51,5 +74,14 @@ void WriteStartupLogs()
5174
Wu10Logger.LogInfo(EnvironmentVersionHelper.GetWindowsVersion());
5275
Wu10Logger.LogInfo($".Net Framework: {EnvironmentVersionHelper.GetDotNetFrameworkBuild()}");
5376
}
77+
78+
WindowsServiceNames GetWindowsServices()
79+
{
80+
var serviceNames = System.Configuration.ConfigurationManager.AppSettings["WindowsServiceNames"];
81+
var split = serviceNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
82+
var names = new WindowsServiceNames();
83+
names.AddRange(split.Distinct());
84+
return names;
85+
}
5486
}
5587
}

Wu10Man/Constants.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace WereDev.Utils.Wu10Man
8+
{
9+
public static class Constants
10+
{
11+
public const string USERNAME_LOCAL_SYSTEM = @".\LocalSystem";
12+
}
13+
}

Wu10Man/DependencyManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Autofac;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace WereDev.Utils.Wu10Man
9+
{
10+
public static class DependencyManager
11+
{
12+
public static IContainer Container { get; set; }
13+
14+
public static T Resolve<T>() => Container.Resolve<T>();
15+
}
16+
}

Wu10Man/Editors/ServiceCredentialsEditor.cs

Lines changed: 0 additions & 152 deletions
This file was deleted.

Wu10Man/Helpers/EnvironmentVersionHelper.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
namespace WereDev.Utils.Wu10Man.Helpers
1+
using WereDev.Utils.Wu10Man.Interfaces;
2+
3+
namespace WereDev.Utils.Wu10Man.Helpers
24
{
35
public static class EnvironmentVersionHelper
46
{
57
private const string WindowsVersionRegistryKey = @"SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion";
68
private const string DotNetVersionRegistryKey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full";
9+
private static IRegistryEditor RegistryEditor => DependencyManager.Resolve<IRegistryEditor>();
10+
11+
712
public static string GetDotNetFrameworkBuild()
813
{
9-
var release = Editors.RegistryEditor.ReadLocalMachineRegistryValue(DotNetVersionRegistryKey, "Release");
14+
var release = RegistryEditor.ReadLocalMachineRegistryValue(DotNetVersionRegistryKey, "Release");
1015
int.TryParse(release, out var releaseInt);
1116

1217
if (releaseInt >= 528040)
@@ -37,10 +42,10 @@ public static string GetDotNetFrameworkBuild()
3742

3843
public static string GetWindowsVersion()
3944
{
40-
var windowsProduct = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ProductName");
41-
var windowsRelease = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ReleaseId");
42-
var windowsBuild = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "CurrentBuild");
43-
var windowsBuildRevision = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "BaseBuildRevisionNumber");
45+
var windowsProduct = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ProductName");
46+
var windowsRelease = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ReleaseId");
47+
var windowsBuild = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "CurrentBuild");
48+
var windowsBuildRevision = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "BaseBuildRevisionNumber");
4449
return $"{windowsProduct} Version {windowsRelease} Build {windowsBuild}.{windowsBuildRevision}";
4550
}
4651
}

0 commit comments

Comments
 (0)