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

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

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

--- trunk/RomCheater.PluginFramework/Core/ProcContainer.cs	2012/05/09 23:23:38	99
+++ trunk/RomCheater.PluginFramework/Core/ProcContainer.cs	2012/05/10 09:03:13	100
@@ -5,6 +5,7 @@
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
+using libWin32.Win32.Threading;
 
 namespace RomCheater.PluginFramework.Core
 {
@@ -14,16 +15,19 @@
         public ProcContainer(Process process)
             : this()
         {
-            this.ProcessInfo = process; this.CreateProcessIcon(4);
-            FileInfo fi = new FileInfo(process.MainModule.FileName);
+            this.ProcessInfo = process;
+            string fname = ThreadControl.GetProcessFilename(process);
+            FileInfo fi = new FileInfo(fname);
             this.FileName = fi.FullName;
             this.Name = fi.Name;
+            this.CreateProcessIcon(4);
         }
         public ProcContainer(Process process, Icon icon)
             : this()
         {
             this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap();
-            FileInfo fi = new FileInfo(process.MainModule.FileName);
+            string fname = ThreadControl.GetProcessFilename(process);
+            FileInfo fi = new FileInfo(fname);
             this.FileName = fi.FullName;
             this.Name = fi.Name;
         }
@@ -31,7 +35,8 @@
             : this()
         {
             this.ProcessInfo = process; this.ProcessIcon = icon;
-            FileInfo fi = new FileInfo(process.MainModule.FileName);
+            string fname = ThreadControl.GetProcessFilename(process);
+            FileInfo fi = new FileInfo(fname);
             this.FileName = fi.FullName;
             this.Name = fi.Name;
         }
@@ -48,45 +53,43 @@
 
         public override string ToString()
         {
-            return this.FileName == "" ?
-                (ProcessInfo != null) ? ProcessInfo.MainModule.FileName : "" :
-                this.FileName;
+            return this.FileName;
         }
 
-        public static Bitmap CreateIconFromProcess(Process proc)
+        public static Bitmap CreateIconFromProcess(ProcContainer proc)
         {
             if (proc == null) return null;
-            return Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap();
+            return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
         }
-        public static Bitmap CreateIconFromProcess(Process proc, int Scale)
+        public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale)
         {
             if (proc == null) return null;
-            Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap();
+            Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
             ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
             return ret;
         }
-        public static Bitmap CreateIconFromProcess(Process proc, int Width, int Height)
+        public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height)
         {
             if (proc == null) return null;
-            Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap();
+            Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
             ret = new Bitmap(ret, Width, Height);
             return ret;
         }
         private void CreateProcessIcon()
         {
             if (this.ProcessInfo == null) return;
-            this.ProcessIcon = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap();
+            this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
         }
         private void CreateProcessIcon(int Scale)
         {
-            Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap();
+            Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
             ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
             this.ProcessIcon = ret;
         }
         private void CreateProcessIcon(int Width, int Height)
         {
             if (this.ProcessInfo == null) return;
-            Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap();
+            Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
             ret = new Bitmap(ret, Width, Height);
             this.ProcessIcon = ret;
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22