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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs	2012/05/09 19:51:42	87
+++ trunk/RomCheater.PluginFramework/Core/ConfigPlugin.cs	2012/05/09 20:52:20	88
@@ -4,6 +4,7 @@
 using System.Text;
 using RomCheater.PluginFramework.Interfaces;
 using System.Diagnostics;
+using libWin32.Win32.Threading;
 
 namespace RomCheater.PluginFramework.Core
 {
@@ -12,9 +13,52 @@
     /// </summary>
     public abstract class ConfigPlugin : PluginBase, IConfigPlugin
     {
-        public ConfigPlugin() : base() { this.ValidProcessesForPlugin = new List<Process>(); }
+        public ConfigPlugin() : base() { this.ValidProcessesForPlugin = new List<ProcContainer>(); init(); }
+
+        private void init()
+        {
+            List<ProcContainer> proc_list = new List<ProcContainer>();
+            foreach (Process proc in Process.GetProcesses())
+            {
+                try
+                {
+                    bool isSystem = false;
+                    string proc_name = proc.ProcessName.ToLower();
+                    string proc_user = ThreadControl.GetProcessOwner(proc.Handle, out isSystem).ToLower();
+                    if (isSystem)
+                    {
+                        continue;
+                    }
+                    ProcContainer container = null;
+                    try
+                    {
+                        container = new ProcContainer(proc);
+                    }
+                    catch (Exception)
+                    {
+                        throw;
+                    }
+                    proc_list.Add(container);
+                }
+                catch (System.ComponentModel.Win32Exception)
+                {
+                    continue;
+                }
+                catch (Exception)
+                {
+                    continue;
+                }
+            }
+            proc_list = proc_list.OrderBy(p => p.Name).ToList();
+            Predicate<ProcContainer> predicate = new Predicate<ProcContainer>(IsNotValidProcess);
+            proc_list.RemoveAll(predicate);
+            ValidProcessesForPlugin = proc_list;
+        }
+
+        protected abstract bool IsNotValidProcess(ProcContainer p);
+
         #region IConfigPlugin Members
-        public List<Process> ValidProcessesForPlugin { get; protected set; }
+        public List<ProcContainer> ValidProcessesForPlugin { get; protected set; }
         public override Guid Id
         {
             get { return new Guid(); }

 

  ViewVC Help
Powered by ViewVC 1.1.22