5 |
|
using System.Diagnostics; |
6 |
|
using System.Drawing; |
7 |
|
using System.IO; |
8 |
+ |
using libWin32.Win32.Threading; |
9 |
|
|
10 |
|
namespace RomCheater.PluginFramework.Core |
11 |
|
{ |
15 |
|
public ProcContainer(Process process) |
16 |
|
: this() |
17 |
|
{ |
18 |
< |
this.ProcessInfo = process; this.CreateProcessIcon(4); |
19 |
< |
FileInfo fi = new FileInfo(process.MainModule.FileName); |
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 |
< |
FileInfo fi = new FileInfo(process.MainModule.FileName); |
29 |
> |
string fname = ThreadControl.GetProcessFilename(process); |
30 |
> |
FileInfo fi = new FileInfo(fname); |
31 |
|
this.FileName = fi.FullName; |
32 |
|
this.Name = fi.Name; |
33 |
|
} |
35 |
|
: this() |
36 |
|
{ |
37 |
|
this.ProcessInfo = process; this.ProcessIcon = icon; |
38 |
< |
FileInfo fi = new FileInfo(process.MainModule.FileName); |
38 |
> |
string fname = ThreadControl.GetProcessFilename(process); |
39 |
> |
FileInfo fi = new FileInfo(fname); |
40 |
|
this.FileName = fi.FullName; |
41 |
|
this.Name = fi.Name; |
42 |
|
} |
53 |
|
|
54 |
|
public override string ToString() |
55 |
|
{ |
56 |
< |
return this.FileName == "" ? |
52 |
< |
(ProcessInfo != null) ? ProcessInfo.MainModule.FileName : "" : |
53 |
< |
this.FileName; |
56 |
> |
return this.FileName; |
57 |
|
} |
58 |
|
|
59 |
< |
public static Bitmap CreateIconFromProcess(Process proc) |
59 |
> |
public static Bitmap CreateIconFromProcess(ProcContainer proc) |
60 |
|
{ |
61 |
|
if (proc == null) return null; |
62 |
< |
return Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap(); |
62 |
> |
return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); |
63 |
|
} |
64 |
< |
public static Bitmap CreateIconFromProcess(Process proc, int Scale) |
64 |
> |
public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale) |
65 |
|
{ |
66 |
|
if (proc == null) return null; |
67 |
< |
Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap(); |
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(Process proc, int Width, int Height) |
71 |
> |
public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height) |
72 |
|
{ |
73 |
|
if (proc == null) return null; |
74 |
< |
Bitmap ret = Icon.ExtractAssociatedIcon(proc.MainModule.FileName).ToBitmap(); |
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.ProcessInfo.MainModule.FileName).ToBitmap(); |
81 |
> |
this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); |
82 |
|
} |
83 |
|
private void CreateProcessIcon(int Scale) |
84 |
|
{ |
85 |
< |
Bitmap ret = Icon.ExtractAssociatedIcon(this.ProcessInfo.MainModule.FileName).ToBitmap(); |
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.ProcessInfo.MainModule.FileName).ToBitmap(); |
92 |
> |
Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); |
93 |
|
ret = new Bitmap(ret, Width, Height); |
94 |
|
this.ProcessIcon = ret; |
95 |
|
} |