using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RomCheater.PluginFramework.Interfaces;
using System.Diagnostics;
using libWin32.Win32.Threading;
namespace RomCheater.PluginFramework.Core
{
///
/// Base class for all configuration plugins
///
public abstract class ConfigPlugin : PluginBase, IConfigPlugin
{
public ConfigPlugin() : this(false) { }
public ConfigPlugin(bool doinit) : base() { this.ValidProcessesForPlugin = new List(); if(doinit) init(); }
public override void Reload()
{
init();
}
private void init()
{
List proc_list = new List();
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 predicate = new Predicate(IsNotValidProcess);
proc_list.RemoveAll(predicate);
ValidProcessesForPlugin = proc_list;
}
protected abstract bool IsNotValidProcess(ProcContainer p);
#region IConfigPlugin Members
public List ValidProcessesForPlugin { get; protected set; }
public override Guid Id
{
get { return new Guid(); }
}
public override string Name
{
get
{
return "Unknown Config Plugin";
}
}
public override string Description
{
get
{
return "";
}
}
#endregion
}
}