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 PatchRangeAdder : 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 |
SearchDataTypes DataType; |
25 |
|
|
bool Unsigned = false; |
26 |
william |
245 |
public PatchRangeAdder(IAcceptsProcessAndConfig pconfig) |
27 |
william |
229 |
{ |
28 |
|
|
InitializeComponent(); |
29 |
william |
245 |
this.AcceptedPlugin = pconfig.AcceptedPlugin; |
30 |
|
|
this.AcceptedProcess = pconfig.AcceptedProcess; |
31 |
william |
229 |
Unsigned = true; |
32 |
|
|
DataType = SearchDataTypes._8bits; |
33 |
|
|
txtStartAddress.Text = string.Format("0x{0:x8}", 0); |
34 |
|
|
txtEndAddress.Text = string.Format("0x{0:x8}", 0); |
35 |
|
|
this.AddedPatchValue = new List<ResultDataType>(); |
36 |
|
|
txtStartAddress.MaxLength = sizeof(uint) * 2 + 2; |
37 |
|
|
txtEndAddress.MaxLength = sizeof(uint) * 2 + 2; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
private void PatchRangeAdder_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 |
|
|
txtStartAddress.ReadOnly = false; |
49 |
|
|
txtEndAddress.ReadOnly = false; |
50 |
|
|
txtStartAddress.Text = ""; |
51 |
|
|
txtEndAddress.Text = ""; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
private void btnOK_Click(object sender, EventArgs e) |
55 |
|
|
{ |
56 |
|
|
uint StartAddress = txtStartAddress.ToUInt32(); |
57 |
|
|
uint EndAddress = txtEndAddress.ToUInt32(); |
58 |
|
|
uint BIT_SIZE = ((uint)DataType) / 8; |
59 |
|
|
|
60 |
|
|
//if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX || ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX)) |
61 |
|
|
//{ |
62 |
|
|
// MessageBox.Show(string.Format("EE Ram requires the Starting and End 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); |
63 |
|
|
// txtStartAddress.Text = ""; |
64 |
|
|
// txtEndAddress.Text = ""; |
65 |
|
|
// return; |
66 |
|
|
//} |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
//if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX)) |
70 |
|
|
//{ |
71 |
|
|
// MessageBox.Show(string.Format("EE Ram requires the Starting 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); |
72 |
|
|
// txtStartAddress.Text = ""; |
73 |
|
|
// return; |
74 |
|
|
//} |
75 |
|
|
|
76 |
|
|
|
77 |
|
|
//if (!(ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX)) |
78 |
|
|
//{ |
79 |
|
|
// MessageBox.Show(string.Format("EE Ram requires the Ending 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); |
80 |
|
|
// txtEndAddress.Text = ""; |
81 |
|
|
// return; |
82 |
|
|
//} |
83 |
|
|
|
84 |
|
|
for (uint i = StartAddress; i <= EndAddress; i += BIT_SIZE) |
85 |
|
|
{ |
86 |
|
|
|
87 |
william |
245 |
ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", i), DataType, Unsigned, (IAcceptsProcessAndConfig)this); |
88 |
william |
229 |
ResultDataType _result = _result_state; |
89 |
|
|
this.AddedPatchValue.Add(_result); |
90 |
|
|
} |
91 |
|
|
this.Close(); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
private void btnCancel_Click(object sender, EventArgs e) |
95 |
|
|
{ |
96 |
|
|
this.Close(); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
public bool WasAPatchAdded |
100 |
|
|
{ |
101 |
|
|
get { return (this.AddedPatchValue.Count > 0); } |
102 |
|
|
} |
103 |
|
|
private List<ResultDataType> _AddedPatchValue; |
104 |
|
|
public List<ResultDataType> AddedPatchValue |
105 |
|
|
{ |
106 |
|
|
get { return _AddedPatchValue; } |
107 |
|
|
private set { _AddedPatchValue = value; } |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
private void comboDataBitSize_SelectedIndexChanged(object sender, EventArgs e) |
111 |
|
|
{ |
112 |
|
|
int selected_index = comboDataBitSize.SelectedIndex; |
113 |
|
|
int bit_size = -1; |
114 |
|
|
|
115 |
|
|
bit_size = Convert.ToInt32(comboDataBitSize.Items[comboDataBitSize.SelectedIndex]); |
116 |
|
|
this.DataType = (SearchDataTypes)bit_size; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
private void PatchRangeAdder_KeyDown(object sender, KeyEventArgs e) |
120 |
|
|
{ |
121 |
|
|
if (e.KeyCode == Keys.Enter) btnOK.PerformClick(); |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
} |
125 |
|
|
|