9 |
using System.Diagnostics; |
using System.Diagnostics; |
10 |
using RomCheater.Logging; |
using RomCheater.Logging; |
11 |
using Sojaner.MemoryScanner.MemoryProviers; |
using Sojaner.MemoryScanner.MemoryProviers; |
12 |
|
using RomCheater.PluginFramework.Interfaces; |
13 |
|
|
14 |
|
|
15 |
namespace RomCheater.Docking.MemorySearch |
namespace RomCheater.Docking.MemorySearch |
16 |
{ |
{ |
17 |
public partial class SearchPatcher : Form |
public partial class SearchPatcher : Form, |
18 |
|
IAcceptsPlugin<IConfigPlugin>, |
19 |
|
IAcceptsProcess<Process>, |
20 |
|
IAcceptsProcessAndConfig |
21 |
{ |
{ |
22 |
|
#region IAcceptsProcess<Process> Members |
23 |
|
public Process AcceptedProcess { get; set; } |
24 |
|
#endregion |
25 |
|
#region IAcceptsPlugin<IConfigPlugin> Members |
26 |
|
public IConfigPlugin AcceptedPlugin { get; set; } |
27 |
|
#endregion |
28 |
//PCSX2MemoryProvider provider; |
//PCSX2MemoryProvider provider; |
|
private int pid = -1; |
|
29 |
SearchDataTypes DataType; |
SearchDataTypes DataType; |
30 |
bool Unsigned = false; |
bool Unsigned = false; |
31 |
public SearchPatcher(int pid, uint Address) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address) |
32 |
{ |
{ |
33 |
InitializeComponent(); |
InitializeComponent(); |
34 |
this.pid = pid; |
this.AcceptedPlugin = pconfig.AcceptedPlugin; |
35 |
|
this.AcceptedProcess = pconfig.AcceptedProcess; |
36 |
txtAddress.Text = string.Format("0x{0:x8}", Address); |
txtAddress.Text = string.Format("0x{0:x8}", Address); |
37 |
} |
} |
38 |
public SearchPatcher(int pid, uint Address, byte Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, byte Value) |
39 |
: this(pid, Address) |
: this(pconfig, Address) |
40 |
{ |
{ |
41 |
Unsigned = true; |
Unsigned = true; |
42 |
DataType = SearchDataTypes._8bits; |
DataType = SearchDataTypes._8bits; |
43 |
txtValue.CreateTypeSize<byte>(); |
txtValue.CreateTypeSize<byte>(); |
44 |
txtValue.Text = string.Format("0x{0:x2}", Value); |
txtValue.Text = string.Format("0x{0:x2}", Value); |
45 |
} |
} |
46 |
public SearchPatcher(int pid, uint Address, sbyte Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, sbyte Value) |
47 |
: this(pid, Address) |
: this(pconfig, Address) |
48 |
{ |
{ |
49 |
DataType = SearchDataTypes._8bits; |
DataType = SearchDataTypes._8bits; |
50 |
txtValue.CreateTypeSize<sbyte>(); |
txtValue.CreateTypeSize<sbyte>(); |
51 |
txtValue.Text = string.Format("0x{0:x2}", Value); |
txtValue.Text = string.Format("0x{0:x2}", Value); |
52 |
} |
} |
53 |
public SearchPatcher(int pid, uint Address, ushort Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, ushort Value) |
54 |
: this(pid, Address) |
: this(pconfig, Address) |
55 |
{ |
{ |
56 |
Unsigned = true; |
Unsigned = true; |
57 |
DataType = SearchDataTypes._16bits; |
DataType = SearchDataTypes._16bits; |
58 |
txtValue.CreateTypeSize<ushort>(); |
txtValue.CreateTypeSize<ushort>(); |
59 |
txtValue.Text = string.Format("0x{0:x4}", Value); |
txtValue.Text = string.Format("0x{0:x4}", Value); |
60 |
} |
} |
61 |
public SearchPatcher(int pid, uint Address, short Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, short Value) |
62 |
: this(pid, Address) |
: this(pconfig, Address) |
63 |
{ |
{ |
64 |
DataType = SearchDataTypes._16bits; |
DataType = SearchDataTypes._16bits; |
65 |
txtValue.CreateTypeSize<short>(); |
txtValue.CreateTypeSize<short>(); |
66 |
txtValue.Text = string.Format("0x{0:x4}", Value); |
txtValue.Text = string.Format("0x{0:x4}", Value); |
67 |
} |
} |
68 |
public SearchPatcher(int pid, uint Address, uint Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, uint Value) |
69 |
: this(pid, Address) |
: this(pconfig, Address) |
70 |
{ |
{ |
71 |
Unsigned = true; |
Unsigned = true; |
72 |
DataType = SearchDataTypes._32bits; |
DataType = SearchDataTypes._32bits; |
73 |
txtValue.CreateTypeSize<uint>(); |
txtValue.CreateTypeSize<uint>(); |
74 |
txtValue.Text = string.Format("0x{0:x8}", Value); |
txtValue.Text = string.Format("0x{0:x8}", Value); |
75 |
} |
} |
76 |
public SearchPatcher(int pid, uint Address, int Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, int Value) |
77 |
: this(pid, Address) |
: this(pconfig, Address) |
78 |
{ |
{ |
79 |
DataType = SearchDataTypes._32bits; |
DataType = SearchDataTypes._32bits; |
80 |
txtValue.CreateTypeSize<int>(); |
txtValue.CreateTypeSize<int>(); |
81 |
txtValue.Text = string.Format("0x{0:x8}", Value); |
txtValue.Text = string.Format("0x{0:x8}", Value); |
82 |
} |
} |
83 |
public SearchPatcher(int pid, uint Address, ulong Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, ulong Value) |
84 |
: this(pid, Address) |
: this(pconfig, Address) |
85 |
{ |
{ |
86 |
Unsigned = true; |
Unsigned = true; |
87 |
DataType = SearchDataTypes._64bits; |
DataType = SearchDataTypes._64bits; |
88 |
txtValue.CreateTypeSize<ulong>(); |
txtValue.CreateTypeSize<ulong>(); |
89 |
txtValue.Text = string.Format("0x{0:x16}", Value); |
txtValue.Text = string.Format("0x{0:x16}", Value); |
90 |
} |
} |
91 |
public SearchPatcher(int pid, uint Address, long Value) |
public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, long Value) |
92 |
: this(pid, Address) |
: this(pconfig, Address) |
93 |
{ |
{ |
94 |
DataType = SearchDataTypes._64bits; |
DataType = SearchDataTypes._64bits; |
95 |
txtValue.CreateTypeSize<long>(); |
txtValue.CreateTypeSize<long>(); |
108 |
{ |
{ |
109 |
uint Address = txtAddress.ToUInt32(); |
uint Address = txtAddress.ToUInt32(); |
110 |
|
|
111 |
GenericMemoryProvider provider = new GenericMemoryProvider(null, Process.GetProcessById(pid)); |
GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this); |
112 |
switch (DataType) |
switch (DataType) |
113 |
{ |
{ |
114 |
case SearchDataTypes._8bits: |
case SearchDataTypes._8bits: |