1 |
william |
229 |
using System; |
2 |
|
|
using System.Collections.Generic; |
3 |
|
|
using System.ComponentModel; |
4 |
|
|
using System.Data; |
5 |
|
|
using System.Drawing; |
6 |
|
|
using System.Text; |
7 |
|
|
using System.Windows.Forms; |
8 |
william |
245 |
using RomCheater.PluginFramework.Interfaces; |
9 |
|
|
using System.Diagnostics; |
10 |
william |
229 |
|
11 |
|
|
namespace RomCheater.Docking.MemorySearch |
12 |
|
|
{ |
13 |
william |
245 |
public partial class PatchAdder : Form, |
14 |
|
|
IAcceptsPlugin<IConfigPlugin>, |
15 |
|
|
IAcceptsProcess<Process>, |
16 |
|
|
IAcceptsProcessAndConfig |
17 |
william |
229 |
{ |
18 |
william |
245 |
#region IAcceptsProcess<Process> Members |
19 |
|
|
public Process AcceptedProcess { get; set; } |
20 |
|
|
#endregion |
21 |
|
|
#region IAcceptsPlugin<IConfigPlugin> Members |
22 |
|
|
public IConfigPlugin AcceptedPlugin { get; set; } |
23 |
|
|
#endregion |
24 |
william |
229 |
//PCSX2MemoryProvider provider; |
25 |
|
|
SearchDataTypes DataType; |
26 |
|
|
bool Unsigned = false; |
27 |
william |
245 |
public PatchAdder(IAcceptsProcessAndConfig pconfig) |
28 |
william |
229 |
{ |
29 |
|
|
InitializeComponent(); |
30 |
william |
245 |
this.AcceptedPlugin = pconfig.AcceptedPlugin; |
31 |
|
|
this.AcceptedProcess = pconfig.AcceptedProcess; |
32 |
william |
229 |
//provider = new PCSX2MemoryProvider(_pid, log_control); |
33 |
|
|
Unsigned = true; |
34 |
|
|
DataType = SearchDataTypes._8bits; |
35 |
|
|
txtAddress.Text = string.Format("0x{0:x8}", 0); |
36 |
|
|
this.AddedPatchValue = null; |
37 |
|
|
txtAddress.MaxLength = sizeof(uint) * 2 + 2; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
private void SearchPatcher_Load(object sender, EventArgs e) |
41 |
|
|
{ |
42 |
|
|
foreach (int val in Enum.GetValues(typeof(SearchDataTypes))) |
43 |
|
|
{ |
44 |
|
|
comboDataBitSize.Items.Add(val); |
45 |
|
|
} |
46 |
|
|
comboDataBitSize.SelectedIndex = 0; |
47 |
|
|
comboDataBitSize.Text = comboDataBitSize.Items[comboDataBitSize.SelectedIndex].ToString(); |
48 |
|
|
txtAddress.ReadOnly = false; |
49 |
|
|
txtAddress.Text = ""; |
50 |
|
|
} |
51 |
|
|
private void btnCancel_Click(object sender, EventArgs e) |
52 |
|
|
{ |
53 |
|
|
this.Close(); |
54 |
|
|
} |
55 |
|
|
private void btnOK_Click(object sender, EventArgs e) |
56 |
|
|
{ |
57 |
|
|
uint Address = txtAddress.ToUInt32(); |
58 |
|
|
|
59 |
|
|
//if (!(ramdumper.VTLB_VADDR_MIN <= Address && Address < ramdumper.VTLB_VADDR_MAX)) |
60 |
|
|
//{ |
61 |
|
|
// MessageBox.Show(string.Format("EE Ram requires the Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
62 |
|
|
// txtAddress.Text = ""; |
63 |
|
|
// return; |
64 |
|
|
//} |
65 |
|
|
|
66 |
william |
245 |
ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", txtAddress.ToUInt32()), DataType, Unsigned, (IAcceptsProcessAndConfig)this); |
67 |
william |
229 |
ResultDataType _result = _result_state; |
68 |
|
|
this.AddedPatchValue = _result; |
69 |
|
|
this.Close(); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
public bool WasAPatchAdded |
73 |
|
|
{ |
74 |
|
|
get { return (this.AddedPatchValue != null); } |
75 |
|
|
} |
76 |
|
|
private ResultDataType _AddedPatchValue; |
77 |
|
|
public ResultDataType AddedPatchValue |
78 |
|
|
{ |
79 |
|
|
get { return _AddedPatchValue; } |
80 |
|
|
private set { _AddedPatchValue = value; } |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
private void comboDataBitSize_SelectedIndexChanged(object sender, EventArgs e) |
84 |
|
|
{ |
85 |
|
|
int selected_index = comboDataBitSize.SelectedIndex; |
86 |
|
|
int bit_size = -1; |
87 |
|
|
|
88 |
|
|
bit_size = Convert.ToInt32(comboDataBitSize.Items[comboDataBitSize.SelectedIndex]); |
89 |
|
|
this.DataType = (SearchDataTypes)bit_size; |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
private void chkIsUnsigned_CheckedChanged(object sender, EventArgs e) |
93 |
|
|
{ |
94 |
|
|
if (chkIsUnsigned.Checked) { this.Unsigned = true; } |
95 |
|
|
else { this.Unsigned = false; } |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
private void PatchAdder_KeyDown(object sender, KeyEventArgs e) |
99 |
|
|
{ |
100 |
|
|
if (e.KeyCode == Keys.Enter) btnOK.PerformClick(); |
101 |
|
|
} |
102 |
|
|
} |
103 |
|
|
} |