/[RomCheater]/trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs
ViewVC logotype

Contents of /trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88 - (show annotations) (download)
Wed May 9 20:52:20 2012 UTC (8 years, 8 months ago) by william
File size: 2595 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using RomCheater.PluginFramework.Interfaces;
6 using System.Diagnostics;
7 using libWin32.Win32.Threading;
8
9 namespace RomCheater.PluginFramework.Core
10 {
11 /// <summary>
12 /// Base class for all configuration plugins
13 /// </summary>
14 public abstract class ConfigPlugin : PluginBase, IConfigPlugin
15 {
16 public ConfigPlugin() : base() { this.ValidProcessesForPlugin = new List<ProcContainer>(); init(); }
17
18 private void init()
19 {
20 List<ProcContainer> proc_list = new List<ProcContainer>();
21 foreach (Process proc in Process.GetProcesses())
22 {
23 try
24 {
25 bool isSystem = false;
26 string proc_name = proc.ProcessName.ToLower();
27 string proc_user = ThreadControl.GetProcessOwner(proc.Handle, out isSystem).ToLower();
28 if (isSystem)
29 {
30 continue;
31 }
32 ProcContainer container = null;
33 try
34 {
35 container = new ProcContainer(proc);
36 }
37 catch (Exception)
38 {
39 throw;
40 }
41 proc_list.Add(container);
42 }
43 catch (System.ComponentModel.Win32Exception)
44 {
45 continue;
46 }
47 catch (Exception)
48 {
49 continue;
50 }
51 }
52 proc_list = proc_list.OrderBy(p => p.Name).ToList();
53 Predicate<ProcContainer> predicate = new Predicate<ProcContainer>(IsNotValidProcess);
54 proc_list.RemoveAll(predicate);
55 ValidProcessesForPlugin = proc_list;
56 }
57
58 protected abstract bool IsNotValidProcess(ProcContainer p);
59
60 #region IConfigPlugin Members
61 public List<ProcContainer> ValidProcessesForPlugin { get; protected set; }
62 public override Guid Id
63 {
64 get { return new Guid(); }
65 }
66 public override string Name
67 {
68 get
69 {
70 return "Unknown Config Plugin";
71 }
72 }
73 public override string Description
74 {
75 get
76 {
77 return "";
78 }
79 }
80 #endregion
81 }
82 }

  ViewVC Help
Powered by ViewVC 1.1.22