ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.PluginFramework/Core/ProcContainer.cs
(Generate patch)

Comparing trunk/RomCheater.PluginFramework/Core/ProcContainer.cs (file contents):
Revision 88 by william, Wed May 9 20:52:20 2012 UTC vs.
Revision 105 by william, Thu May 10 10:53:07 2012 UTC

--- trunk/RomCheater.PluginFramework/Core/ProcContainer.cs	2012/05/09 20:52:20	88
+++ trunk/RomCheater.PluginFramework/Core/ProcContainer.cs	2012/05/10 10:53:07	105
@@ -5,6 +5,7 @@ using System.Text;
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
+using libWin32.Win32.Threading;
 
 namespace RomCheater.PluginFramework.Core
 {
@@ -14,16 +15,28 @@ namespace RomCheater.PluginFramework.Cor
         public ProcContainer(Process process)
             : this()
         {
-            this.ProcessInfo = process; this.CreateProcessIcon(4);
-            FileInfo fi = new FileInfo(process.MainModule.FileName);
+            this.ProcessInfo = process;
+            FileInfo fi = null;
+            string fname = "";
+            try
+            {
+                fname = ProcessModeleInfoEx.GetMainModulePath(process);
+                fi = new FileInfo(fname);
+            }
+            catch (Exception)
+            {
+                throw;
+            }
             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 = ProcessModeleInfoEx.GetMainModulePath(process);
+            FileInfo fi = new FileInfo(fname);
             this.FileName = fi.FullName;
             this.Name = fi.Name;
         }
@@ -31,7 +44,8 @@ namespace RomCheater.PluginFramework.Cor
             : this()
         {
             this.ProcessInfo = process; this.ProcessIcon = icon;
-            FileInfo fi = new FileInfo(process.MainModule.FileName);
+            string fname = ProcessModeleInfoEx.GetMainModulePath(process);
+            FileInfo fi = new FileInfo(fname);
             this.FileName = fi.FullName;
             this.Name = fi.Name;
         }
@@ -48,45 +62,43 @@ namespace RomCheater.PluginFramework.Cor
 
         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;
         }