/[RomCheater]/trunk/RomCheater/Docking/MemorySearch/PatchRangeAdder.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/MemorySearch/PatchRangeAdder.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 477 - (show annotations) (download)
Mon Jun 3 18:35:45 2013 UTC (7 years, 3 months ago) by william
File size: 5187 byte(s)
revert r471: pass process informatin by using the process's PID, instead of passing the process as a reference

+ pass the process instead
1 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 using RomCheater.PluginFramework.Interfaces;
9 using System.Diagnostics;
10
11 namespace RomCheater.Docking.MemorySearch
12 {
13 public partial class PatchRangeAdder : Form,
14 IAcceptsPlugin<IConfigPlugin>,
15 IAcceptsProcess<Process>,
16 IAcceptsProcessAndConfig
17 {
18 #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 SearchDataTypes DataType;
25 bool Unsigned = false;
26 public PatchRangeAdder(IAcceptsProcessAndConfig pconfig)
27 {
28 InitializeComponent();
29 this.AcceptedPlugin = pconfig.AcceptedPlugin;
30 this.AcceptedProcess = pconfig.AcceptedProcess;
31 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 ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", i), DataType, Unsigned, (IAcceptsProcessAndConfig)this);
88 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

  ViewVC Help
Powered by ViewVC 1.1.22