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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 william 79 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5 william 83 using RomCheater.PluginFramework.Interfaces;
6     using System.Diagnostics;
7 william 88 using libWin32.Win32.Threading;
8 william 79
9     namespace RomCheater.PluginFramework.Core
10     {
11     /// <summary>
12     /// Base class for all configuration plugins
13     /// </summary>
14 william 83 public abstract class ConfigPlugin : PluginBase, IConfigPlugin
15 william 79 {
16 william 88 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 william 83 #region IConfigPlugin Members
61 william 88 public List<ProcContainer> ValidProcessesForPlugin { get; protected set; }
62 william 86 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 william 83 #endregion
81 william 79 }
82     }

  ViewVC Help
Powered by ViewVC 1.1.22