using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace RomCheater.Docking.MemorySearch { public partial class PatchRangeAdder : Form { SearchDataTypes DataType; bool Unsigned = false; int _pid = -1; public PatchRangeAdder(int pid) { InitializeComponent(); _pid = pid; Unsigned = true; DataType = SearchDataTypes._8bits; txtStartAddress.Text = string.Format("0x{0:x8}", 0); txtEndAddress.Text = string.Format("0x{0:x8}", 0); this.AddedPatchValue = new List(); txtStartAddress.MaxLength = sizeof(uint) * 2 + 2; txtEndAddress.MaxLength = sizeof(uint) * 2 + 2; } private void PatchRangeAdder_Load(object sender, EventArgs e) { foreach (int val in Enum.GetValues(typeof(SearchDataTypes))) { comboDataBitSize.Items.Add(val); } comboDataBitSize.SelectedIndex = 0; comboDataBitSize.Text = comboDataBitSize.Items[comboDataBitSize.SelectedIndex].ToString(); txtStartAddress.ReadOnly = false; txtEndAddress.ReadOnly = false; txtStartAddress.Text = ""; txtEndAddress.Text = ""; } private void btnOK_Click(object sender, EventArgs e) { uint StartAddress = txtStartAddress.ToUInt32(); uint EndAddress = txtEndAddress.ToUInt32(); uint BIT_SIZE = ((uint)DataType) / 8; //if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX || ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX)) //{ // 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); // txtStartAddress.Text = ""; // txtEndAddress.Text = ""; // return; //} //if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX)) //{ // 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); // txtStartAddress.Text = ""; // return; //} //if (!(ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX)) //{ // 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); // txtEndAddress.Text = ""; // return; //} for (uint i = StartAddress; i <= EndAddress; i += BIT_SIZE) { ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", i), DataType, Unsigned, _pid); ResultDataType _result = _result_state; this.AddedPatchValue.Add(_result); } this.Close(); } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } public bool WasAPatchAdded { get { return (this.AddedPatchValue.Count > 0); } } private List _AddedPatchValue; public List AddedPatchValue { get { return _AddedPatchValue; } private set { _AddedPatchValue = value; } } private void comboDataBitSize_SelectedIndexChanged(object sender, EventArgs e) { int selected_index = comboDataBitSize.SelectedIndex; int bit_size = -1; bit_size = Convert.ToInt32(comboDataBitSize.Items[comboDataBitSize.SelectedIndex]); this.DataType = (SearchDataTypes)bit_size; } private void PatchRangeAdder_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) btnOK.PerformClick(); } } }