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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (hide annotations) (download)
Thu May 10 09:03:13 2012 UTC (8 years, 9 months ago) by william
File size: 3629 byte(s)
+ add windows api to get module filename so there won't be errors with 32bit processes being unable to access 64bit process modules

1 william 88 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using System.Diagnostics;
6     using System.Drawing;
7     using System.IO;
8 william 100 using libWin32.Win32.Threading;
9 william 88
10     namespace RomCheater.PluginFramework.Core
11     {
12     public class ProcContainer
13     {
14     public ProcContainer() { this.init(); }
15     public ProcContainer(Process process)
16     : this()
17     {
18 william 100 this.ProcessInfo = process;
19     string fname = ThreadControl.GetProcessFilename(process);
20     FileInfo fi = new FileInfo(fname);
21 william 88 this.FileName = fi.FullName;
22     this.Name = fi.Name;
23 william 100 this.CreateProcessIcon(4);
24 william 88 }
25     public ProcContainer(Process process, Icon icon)
26     : this()
27     {
28     this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap();
29 william 100 string fname = ThreadControl.GetProcessFilename(process);
30     FileInfo fi = new FileInfo(fname);
31 william 88 this.FileName = fi.FullName;
32     this.Name = fi.Name;
33     }
34     public ProcContainer(Process process, Bitmap icon)
35     : this()
36     {
37     this.ProcessInfo = process; this.ProcessIcon = icon;
38 william 100 string fname = ThreadControl.GetProcessFilename(process);
39     FileInfo fi = new FileInfo(fname);
40 william 88 this.FileName = fi.FullName;
41     this.Name = fi.Name;
42     }
43     private void init() { this.ProcessInfo = null; this.ProcessIcon = null; }
44    
45    
46     public string Name { get; set; }
47     public string FileName { get; set; }
48    
49     private Process _ProcessInfo;
50     public Process ProcessInfo { get { return _ProcessInfo; } set { _ProcessInfo = value; } }
51     private Bitmap _ProcessIcon;
52     public Bitmap ProcessIcon { get { return _ProcessIcon; } set { _ProcessIcon = value; } }
53    
54     public override string ToString()
55     {
56 william 100 return this.FileName;
57 william 88 }
58    
59 william 100 public static Bitmap CreateIconFromProcess(ProcContainer proc)
60 william 88 {
61     if (proc == null) return null;
62 william 100 return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
63 william 88 }
64 william 100 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale)
65 william 88 {
66     if (proc == null) return null;
67 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
68 william 88 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
69     return ret;
70     }
71 william 100 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height)
72 william 88 {
73     if (proc == null) return null;
74 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
75 william 88 ret = new Bitmap(ret, Width, Height);
76     return ret;
77     }
78     private void CreateProcessIcon()
79     {
80     if (this.ProcessInfo == null) return;
81 william 100 this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
82 william 88 }
83     private void CreateProcessIcon(int Scale)
84     {
85 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
86 william 88 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
87     this.ProcessIcon = ret;
88     }
89     private void CreateProcessIcon(int Width, int Height)
90     {
91     if (this.ProcessInfo == null) return;
92 william 100 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
93 william 88 ret = new Bitmap(ret, Width, Height);
94     this.ProcessIcon = ret;
95     }
96     }
97     }

  ViewVC Help
Powered by ViewVC 1.1.22