├── .gitattributes ├── .gitignore ├── README.md ├── SrvDrv.sln └── SrvDrv ├── App.config ├── App.xaml ├── App.xaml.cs ├── Constants.cs ├── Icons ├── data.ico ├── driver.ico ├── gear.ico ├── gear_run.ico ├── gear_stop.ico ├── info.ico ├── main.ico ├── pause.ico ├── play.ico └── stop.ico ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Resources └── Templates.xaml ├── SrvDrv.csproj ├── ViewModels ├── MainViewModel.cs └── ServiceViewModel.cs ├── Views ├── MainView.xaml └── MainView.xaml.cs ├── Win32.cs ├── app.manifest └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SrvDrv 2 | Services and Drivers control application 3 | 4 | Simple tool to view and manage services and drivers on a Windows system. 5 | -------------------------------------------------------------------------------- /SrvDrv.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SrvDrv", "SrvDrv\SrvDrv.csproj", "{D929029D-C69C-4306-95EB-5251F5551310}" 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 | {D929029D-C69C-4306-95EB-5251F5551310}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D929029D-C69C-4306-95EB-5251F5551310}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D929029D-C69C-4306-95EB-5251F5551310}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D929029D-C69C-4306-95EB-5251F5551310}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /SrvDrv/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SrvDrv/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /SrvDrv/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.ComponentModel.Composition.Hosting; 5 | using System.Configuration; 6 | using System.Data; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Threading.Tasks; 10 | using System.Windows; 11 | using SrvDrv.ViewModels; 12 | using Zodiacon.WPF; 13 | 14 | namespace SrvDrv { 15 | /// 16 | /// Interaction logic for App.xaml 17 | /// 18 | public partial class App : Application { 19 | public App() { 20 | LoadAssemblies(); 21 | } 22 | 23 | readonly Dictionary _assemblies = new Dictionary(4); 24 | 25 | private void LoadAssemblies() { 26 | var appAssembly = typeof(App).Assembly; 27 | foreach(var resourceName in appAssembly.GetManifestResourceNames()) { 28 | if(resourceName.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) { 29 | using(var stream = appAssembly.GetManifestResourceStream(resourceName)) { 30 | var assemblyData = new byte[(int)stream.Length]; 31 | stream.Read(assemblyData, 0, assemblyData.Length); 32 | var assembly = Assembly.Load(assemblyData); 33 | _assemblies.Add(assembly.GetName().Name, assembly); 34 | } 35 | } 36 | } 37 | AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; 38 | } 39 | 40 | Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) { 41 | var shortName = new AssemblyName(args.Name).Name; 42 | Assembly assembly; 43 | if(_assemblies.TryGetValue(shortName, out assembly)) { 44 | return assembly; 45 | } 46 | return null; 47 | } 48 | 49 | CompositionContainer _container; 50 | protected override void OnStartup(StartupEventArgs e) { 51 | base.OnStartup(e); 52 | 53 | var catalog = new AggregateCatalog( 54 | new AssemblyCatalog(Assembly.GetExecutingAssembly()), 55 | new AssemblyCatalog(typeof(IDialogService).Assembly)); 56 | 57 | _container = new CompositionContainer(catalog); 58 | _container.ComposeExportedValue(_container); 59 | _container.ComposeExportedValue("AppName", "Services and Drivers"); 60 | _container.ComposeExportedValue(new UIServicesDefaults()); 61 | 62 | var vm = _container.GetExportedValue(); 63 | var win = new MainWindow { DataContext = vm }; 64 | win.Show(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SrvDrv/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SrvDrv { 8 | static class Constants { 9 | public const string AppName = "Services and Drivers"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SrvDrv/Icons/data.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/data.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/driver.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/driver.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/gear.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/gear.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/gear_run.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/gear_run.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/gear_stop.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/gear_stop.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/info.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/info.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/main.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/main.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/pause.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/pause.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/play.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/play.ico -------------------------------------------------------------------------------- /SrvDrv/Icons/stop.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/SrvDrv/fc37f24ee1689687bc1709be86186b2ef27957c3/SrvDrv/Icons/stop.ico -------------------------------------------------------------------------------- /SrvDrv/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SrvDrv/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace SrvDrv { 17 | /// 18 | /// Interaction logic for MainWindow.xaml 19 | /// 20 | public partial class MainWindow { 21 | public MainWindow() { 22 | InitializeComponent(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SrvDrv/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("SrvDrv")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("SrvDrv")] 15 | [assembly: AssemblyCopyright("Copyright © 2016")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /SrvDrv/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SrvDrv.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SrvDrv.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SrvDrv/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /SrvDrv/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SrvDrv.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SrvDrv/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SrvDrv/Resources/Templates.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | -------------------------------------------------------------------------------- /SrvDrv/SrvDrv.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D929029D-C69C-4306-95EB-5251F5551310} 8 | WinExe 9 | Properties 10 | SrvDrv 11 | SrvDrv 12 | v4.6.2 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 649 29 | false 30 | 31 | 32 | AnyCPU 33 | pdbonly 34 | true 35 | bin\Release\ 36 | TRACE 37 | prompt 38 | 4 39 | 649 40 | 41 | 42 | app.manifest 43 | 44 | 45 | Icons\main.ico 46 | 47 | 48 | 49 | ..\packages\MahApps.Metro.1.6.0-alpha009\lib\net45\MahApps.Metro.dll 50 | 51 | 52 | ..\packages\Prism.Core.6.3.0\lib\net45\Prism.dll 53 | 54 | 55 | 56 | 57 | 58 | 59 | ..\packages\MahApps.Metro.1.6.0-alpha009\lib\net45\System.Windows.Interactivity.dll 60 | True 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 4.0 70 | 71 | 72 | 73 | 74 | 75 | ..\packages\Zodiacon.WPF.1.2.13\lib\net45\Zodiacon.WPF.dll 76 | 77 | 78 | 79 | 80 | MSBuild:Compile 81 | Designer 82 | 83 | 84 | 85 | 86 | 87 | MainView.xaml 88 | 89 | 90 | 91 | MSBuild:Compile 92 | Designer 93 | 94 | 95 | App.xaml 96 | Code 97 | 98 | 99 | MainWindow.xaml 100 | Code 101 | 102 | 103 | Designer 104 | MSBuild:Compile 105 | 106 | 107 | Designer 108 | MSBuild:Compile 109 | 110 | 111 | 112 | 113 | Code 114 | 115 | 116 | True 117 | True 118 | Resources.resx 119 | 120 | 121 | True 122 | Settings.settings 123 | True 124 | 125 | 126 | ResXFileCodeGenerator 127 | Resources.Designer.cs 128 | 129 | 130 | 131 | 132 | SettingsSingleFileGenerator 133 | Settings.Designer.cs 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 177 | -------------------------------------------------------------------------------- /SrvDrv/ViewModels/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.ComponentModel.Composition.Hosting; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.ServiceProcess; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Data; 12 | using System.Windows.Input; 13 | using Prism.Commands; 14 | using Prism.Mvvm; 15 | using Zodiacon.WPF; 16 | 17 | namespace SrvDrv.ViewModels { 18 | [Export] 19 | class MainViewModel : BindableBase { 20 | IEnumerable _services; 21 | 22 | public IEnumerable Services { 23 | get { 24 | if(_services == null) { 25 | _services = ServiceController.GetServices().Concat(ServiceController.GetDevices()).OrderBy(svc => svc.ServiceName) 26 | .Select(svc => new ServiceViewModel(svc)); 27 | } 28 | return _services; 29 | } 30 | } 31 | 32 | [Import] 33 | IUIServices UI; 34 | 35 | public MainViewModel() { 36 | StartCommand = new DelegateCommand(async () => { 37 | var vm = SelectedItem; 38 | await StartService(vm, true); 39 | }, () => SelectedItem != null && SelectedItem.Service.StartType != ServiceStartMode.Disabled && SelectedItem.Status == ServiceControllerStatus.Stopped) 40 | .ObservesProperty(() => SelectedItem); 41 | 42 | StopCommand = new DelegateCommand(async () => { 43 | var vm = SelectedItem; 44 | await StartService(vm, false); 45 | }, () => SelectedItem != null && SelectedItem.Service.CanStop && SelectedItem.Status == ServiceControllerStatus.Running) 46 | .ObservesProperty(() => SelectedItem); 47 | 48 | PauseContinueCommand = new DelegateCommand(async () => { 49 | var vm = SelectedItem; 50 | await Task.Run(() => PauseOrContinue(vm)); 51 | }, () => SelectedItem != null && SelectedItem.Service.CanPauseAndContinue) 52 | .ObservesProperty(() => SelectedItem); 53 | 54 | GotoRegistryCommand = new DelegateCommand(() => { 55 | var regedit = Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\regedit.exe"); 56 | regedit.WaitForInputIdle(); 57 | 58 | // now comes the tricky part. need to send keystrokes 59 | 60 | }); 61 | 62 | OpenImageFolderCommand = new DelegateCommand(() => { 63 | var path = SelectedItem.ImagePath.Trim('\"'); 64 | if(path.StartsWith("\\SystemRoot\\")) 65 | path = path.Replace("\\SystemRoot\\", "%SystemRoot%\\"); 66 | Process.Start(Path.GetDirectoryName(Environment.ExpandEnvironmentVariables(path))); 67 | }); 68 | } 69 | 70 | private bool PauseOrContinue(ServiceViewModel vm) { 71 | try { 72 | IsBusy = true; 73 | if(vm.Status == ServiceControllerStatus.Running) { 74 | vm.Service.Pause(); 75 | vm.Service.WaitForStatus(ServiceControllerStatus.Paused, TimeSpan.FromSeconds(5)); 76 | } 77 | else if(vm.Status == ServiceControllerStatus.Paused) { 78 | vm.Service.Continue(); 79 | vm.Service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(5)); 80 | } 81 | else 82 | return false; 83 | } 84 | catch(System.ServiceProcess.TimeoutException) { 85 | return false; 86 | } 87 | finally { 88 | vm.Refresh(); 89 | IsBusy = false; 90 | } 91 | return true; 92 | } 93 | 94 | private ServiceViewModel _selectedItem; 95 | 96 | public ServiceViewModel SelectedItem { 97 | get { return _selectedItem; } 98 | set { SetProperty(ref _selectedItem, value); } 99 | } 100 | 101 | public DelegateCommandBase StartCommand { get; } 102 | public DelegateCommandBase StopCommand { get; } 103 | public DelegateCommandBase GotoRegistryCommand { get; } 104 | public DelegateCommandBase PauseContinueCommand { get; } 105 | public DelegateCommandBase OpenImageFolderCommand { get; } 106 | 107 | private bool _isBusy; 108 | 109 | public bool IsBusy { 110 | get { return _isBusy; } 111 | set { SetProperty(ref _isBusy, value); } 112 | } 113 | 114 | 115 | private async Task StartService(ServiceViewModel service, bool start) { 116 | try { 117 | var svc = service.Service; 118 | IsBusy = true; 119 | if(start) 120 | svc.Start(); 121 | else 122 | svc.Stop(); 123 | await Task.Run(() => { 124 | svc.WaitForStatus(start ? ServiceControllerStatus.Running : ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10)); 125 | }); 126 | } 127 | catch(System.ServiceProcess.TimeoutException) { 128 | UI.MessageBoxService.ShowMessage("Operation timed out.", Constants.AppName); 129 | } 130 | catch(Exception ex) { 131 | UI.MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName); 132 | } 133 | finally { 134 | IsBusy = false; 135 | 136 | service.Refresh(); 137 | StartCommand.RaiseCanExecuteChanged(); 138 | StopCommand.RaiseCanExecuteChanged(); 139 | } 140 | } 141 | 142 | private bool _showServices = true; 143 | 144 | public bool ShowServices { 145 | get { return _showServices; } 146 | set { 147 | if(SetProperty(ref _showServices, value)) { 148 | UpdateFilter(); 149 | } 150 | } 151 | } 152 | 153 | private bool _showDrivers = true; 154 | 155 | public bool ShowDrivers { 156 | get { return _showDrivers; } 157 | set { 158 | if(SetProperty(ref _showDrivers, value)) { 159 | UpdateFilter(); 160 | } 161 | } 162 | } 163 | 164 | private string _searchText = string.Empty; 165 | 166 | public string SearchText { 167 | get { return _searchText; } 168 | set { 169 | if(SetProperty(ref _searchText, value)) { 170 | UpdateFilter(); 171 | } 172 | } 173 | } 174 | 175 | void UpdateFilter() { 176 | var view = CollectionViewSource.GetDefaultView(_services); 177 | view.Filter = obj => { 178 | var svc = (ServiceViewModel)obj; 179 | int type = (int)svc.Service.ServiceType; 180 | if(!ShowServices && type >= 0x10) 181 | return false; 182 | 183 | if(!ShowDrivers && type < 0x10) 184 | return false; 185 | 186 | var text = SearchText.ToLower(); 187 | return svc.Name.ToLower().Contains(text) || svc.DisplayName.ToLower().Contains(text); 188 | }; 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /SrvDrv/ViewModels/ServiceViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.ComponentModel.Composition.Hosting; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.ServiceProcess; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Input; 11 | using Microsoft.Win32; 12 | using Microsoft.Win32.SafeHandles; 13 | using Prism.Commands; 14 | using Prism.Mvvm; 15 | using Zodiacon.WPF; 16 | 17 | namespace SrvDrv.ViewModels { 18 | sealed class ServiceViewModel : BindableBase, IDisposable { 19 | public ServiceController Service { get; } 20 | 21 | public ServiceViewModel(ServiceController service) { 22 | Service = service; 23 | } 24 | 25 | public string Name => Service.ServiceName; 26 | public string DisplayName => Service.DisplayName; 27 | 28 | public string Type { 29 | get { 30 | switch(Service.ServiceType & (~ServiceType.InteractiveProcess)) { 31 | case ServiceType.FileSystemDriver: 32 | return "File System Driver"; 33 | 34 | case ServiceType.Win32OwnProcess: 35 | return "Service (Own Process)"; 36 | 37 | case ServiceType.Win32ShareProcess: 38 | return "Service (Share Process)"; 39 | 40 | case ServiceType.KernelDriver: 41 | return "Kernel Driver"; 42 | 43 | case ServiceType.RecognizerDriver: 44 | return "Recognizer Driver"; 45 | } 46 | return Service.ServiceType.ToString(); 47 | } 48 | } 49 | 50 | public ServiceControllerStatus Status => Service.Status; 51 | 52 | string _description; 53 | public string Description => _description ?? (_description = GetDescription()); 54 | 55 | [DllImport("advapi32", CharSet = CharSet.Unicode)] 56 | private static extern int RegLoadMUIString(SafeRegistryHandle hKey, string value, StringBuilder output, int count, out int size, uint flags, string directory); 57 | 58 | public void Refresh() { 59 | Service.Refresh(); 60 | RaisePropertyChanged(nameof(Status)); 61 | RaisePropertyChanged(nameof(Icon)); 62 | RaisePropertyChanged(nameof(DependentServices)); 63 | RaisePropertyChanged(nameof(DependsOn)); 64 | } 65 | 66 | static StringBuilder _descString = new StringBuilder(1024); 67 | 68 | RegistryKey _key; 69 | private string GetDescription() { 70 | var key = GetRegistryKey(); 71 | int size = _descString.Capacity; 72 | int error = RegLoadMUIString(key.Handle, "Description", _descString, size, out size, 0, null); 73 | var desc = string.Empty; 74 | if(error == 0) 75 | desc = _descString.ToString(); 76 | return desc; 77 | } 78 | 79 | private RegistryKey GetRegistryKey() { 80 | if(_key == null) 81 | _key = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + Name); 82 | return _key; 83 | } 84 | 85 | public string RunAs { 86 | get { 87 | var key = GetRegistryKey(); 88 | return key.GetValue("ObjectName", string.Empty).ToString(); 89 | } 90 | } 91 | 92 | public string ImagePath => GetRegistryKey().GetValue("ImagePath", string.Empty, RegistryValueOptions.None).ToString(); 93 | 94 | public bool IsDelayStart { 95 | get { 96 | try { 97 | int delayStart, size; 98 | Win32.QueryServiceConfig2(Service.ServiceHandle.DangerousGetHandle(), Win32.ServiceInfoLevel.DelayedAutoStart, out delayStart, sizeof(int), out size); 99 | return delayStart > 0; 100 | } 101 | catch { 102 | return false; 103 | } 104 | } 105 | } 106 | 107 | public string DelayedStart => Service.StartType == ServiceStartMode.Automatic && IsDelayStart ? " (Delay Start)" : string.Empty; 108 | 109 | public string StartType => $"{Service.StartType} ({(int)Service.StartType}) {DelayedStart}"; 110 | 111 | public string DependsOn => string.Join(", ", Service.ServicesDependedOn.Select(svc => svc.ServiceName)); 112 | 113 | public string DependentServices => string.Join(", ", Service.DependentServices.Select(svc => svc.ServiceName)); 114 | 115 | public string Icon => GetIcon(); 116 | 117 | private string GetIcon() { 118 | var type = Service.ServiceType & ~ServiceType.InteractiveProcess; 119 | 120 | switch(type) { 121 | case ServiceType.Win32OwnProcess: 122 | case ServiceType.Win32ShareProcess: 123 | return Service.Status == ServiceControllerStatus.Running ? "/icons/gear_run.ico" : "/icons/gear_stop.ico"; 124 | 125 | case ServiceType.FileSystemDriver: 126 | return "/icons/data.ico"; 127 | 128 | } 129 | return "/icons/driver.ico"; 130 | } 131 | 132 | public void Dispose() { 133 | Service.Dispose(); 134 | _key.Dispose(); 135 | } 136 | 137 | public bool IsPaused => Status == ServiceControllerStatus.Paused; 138 | 139 | public string SupportedOperations { 140 | get { 141 | var ops = new List(4); 142 | if(Service.CanStop) 143 | ops.Add("Can Stop"); 144 | if(Service.CanShutdown) 145 | ops.Add("Can Shutdown"); 146 | if(Service.CanPauseAndContinue) 147 | ops.Add("Can Pause and Continue"); 148 | return string.Join(", ", ops); 149 | } 150 | } 151 | 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /SrvDrv/Views/MainView.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 34 | 35 | 36 | 37 | 40 | 43 | 44 | 45 | 46 | 47 | 50 | 53 | 54 | 55 | 56 | 68 | 80 | 83 | 84 | 87 | 90 | 91 | 92 | 93 | 104 | 111 | 112 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 137 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 158 | 159 | 163 | Description: 164 | 165 | 166 | 167 | ImagePath: 168 | 169 | 170 | 171 | Depends on: 172 | 173 | 174 | 175 | Dependent Services: 176 | 177 | 178 | 179 | Supported Operations: 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /SrvDrv/Views/MainView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace SrvDrv.Views { 17 | /// 18 | /// Interaction logic for MainView.xaml 19 | /// 20 | public partial class MainView : UserControl { 21 | public MainView() { 22 | InitializeComponent(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SrvDrv/Win32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SrvDrv { 9 | static class Win32 { 10 | public enum ServiceInfoLevel { 11 | DelayedAutoStart = 3, 12 | TriggerInfo = 8 13 | } 14 | 15 | [DllImport("advapi32", CharSet = CharSet.Unicode)] 16 | public static extern bool QueryServiceConfig2(IntPtr hService, ServiceInfoLevel infoLevel, out int autoStart, int size, out int needed); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SrvDrv/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 59 | 60 | 61 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /SrvDrv/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------