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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100 - (show annotations) (download)
Thu May 10 09:03:13 2012 UTC (9 years, 6 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 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 using libWin32.Win32.Threading;
9
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 this.ProcessInfo = process;
19 string fname = ThreadControl.GetProcessFilename(process);
20 FileInfo fi = new FileInfo(fname);
21 this.FileName = fi.FullName;
22 this.Name = fi.Name;
23 this.CreateProcessIcon(4);
24 }
25 public ProcContainer(Process process, Icon icon)
26 : this()
27 {
28 this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap();
29 string fname = ThreadControl.GetProcessFilename(process);
30 FileInfo fi = new FileInfo(fname);
31 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 string fname = ThreadControl.GetProcessFilename(process);
39 FileInfo fi = new FileInfo(fname);
40 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 return this.FileName;
57 }
58
59 public static Bitmap CreateIconFromProcess(ProcContainer proc)
60 {
61 if (proc == null) return null;
62 return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
63 }
64 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale)
65 {
66 if (proc == null) return null;
67 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
68 ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale);
69 return ret;
70 }
71 public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height)
72 {
73 if (proc == null) return null;
74 Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap();
75 ret = new Bitmap(ret, Width, Height);
76 return ret;
77 }
78 private void CreateProcessIcon()
79 {
80 if (this.ProcessInfo == null) return;
81 this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
82 }
83 private void CreateProcessIcon(int Scale)
84 {
85 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
86 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 Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap();
93 ret = new Bitmap(ret, Width, Height);
94 this.ProcessIcon = ret;
95 }
96 }
97 }

  ViewVC Help
Powered by ViewVC 1.1.22