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

Annotation of /trunk/RomCheater/Docking/MemorySearch/SearchPatcher.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (hide annotations) (download)
Sun Jun 3 16:09:05 2012 UTC (8 years, 10 months ago) by william
File size: 6251 byte(s)
change address from uint to int

1 william 230 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.Docking.MemorySearch;
9     using System.Diagnostics;
10     using RomCheater.Logging;
11 william 239 using Sojaner.MemoryScanner.MemoryProviers;
12 william 243 using RomCheater.PluginFramework.Interfaces;
13 william 230
14    
15     namespace RomCheater.Docking.MemorySearch
16     {
17 william 243 public partial class SearchPatcher : Form,
18     IAcceptsPlugin<IConfigPlugin>,
19     IAcceptsProcess<Process>,
20     IAcceptsProcessAndConfig
21 william 230 {
22 william 243 #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 william 230 //PCSX2MemoryProvider provider;
29     SearchDataTypes DataType;
30     bool Unsigned = false;
31 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address)
32 william 230 {
33     InitializeComponent();
34 william 243 this.AcceptedPlugin = pconfig.AcceptedPlugin;
35     this.AcceptedProcess = pconfig.AcceptedProcess;
36 william 230 txtAddress.Text = string.Format("0x{0:x8}", Address);
37     }
38 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, byte Value)
39     : this(pconfig, Address)
40 william 230 {
41     Unsigned = true;
42     DataType = SearchDataTypes._8bits;
43     txtValue.CreateTypeSize<byte>();
44     txtValue.Text = string.Format("0x{0:x2}", Value);
45     }
46 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, sbyte Value)
47     : this(pconfig, Address)
48 william 230 {
49     DataType = SearchDataTypes._8bits;
50     txtValue.CreateTypeSize<sbyte>();
51     txtValue.Text = string.Format("0x{0:x2}", Value);
52     }
53 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, ushort Value)
54     : this(pconfig, Address)
55 william 230 {
56     Unsigned = true;
57     DataType = SearchDataTypes._16bits;
58     txtValue.CreateTypeSize<ushort>();
59     txtValue.Text = string.Format("0x{0:x4}", Value);
60     }
61 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, short Value)
62     : this(pconfig, Address)
63 william 230 {
64     DataType = SearchDataTypes._16bits;
65     txtValue.CreateTypeSize<short>();
66     txtValue.Text = string.Format("0x{0:x4}", Value);
67     }
68 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, uint Value)
69     : this(pconfig, Address)
70 william 230 {
71     Unsigned = true;
72     DataType = SearchDataTypes._32bits;
73     txtValue.CreateTypeSize<uint>();
74     txtValue.Text = string.Format("0x{0:x8}", Value);
75     }
76 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, int Value)
77     : this(pconfig, Address)
78 william 230 {
79     DataType = SearchDataTypes._32bits;
80     txtValue.CreateTypeSize<int>();
81     txtValue.Text = string.Format("0x{0:x8}", Value);
82     }
83 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, ulong Value)
84     : this(pconfig, Address)
85 william 230 {
86     Unsigned = true;
87     DataType = SearchDataTypes._64bits;
88     txtValue.CreateTypeSize<ulong>();
89     txtValue.Text = string.Format("0x{0:x16}", Value);
90     }
91 william 243 public SearchPatcher(IAcceptsProcessAndConfig pconfig, uint Address, long Value)
92     : this(pconfig, Address)
93 william 230 {
94     DataType = SearchDataTypes._64bits;
95     txtValue.CreateTypeSize<long>();
96     txtValue.Text = string.Format("0x{0:x16}", Value);
97     }
98     private void SearchPatcher_Load(object sender, EventArgs e)
99     {
100     txtAddress.ReadOnly = true;
101     txtValue.ReadOnly = false;
102     }
103     private void btnCancel_Click(object sender, EventArgs e)
104     {
105     this.Close();
106     }
107     private void btnOK_Click(object sender, EventArgs e)
108     {
109 william 249 int Address = txtAddress.ToInt32();
110 william 230
111 william 243 GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
112 william 245 provider.OpenProvider();
113 william 230 switch (DataType)
114     {
115     case SearchDataTypes._8bits:
116 william 239 if (Unsigned) { provider.PatchMemory(Address, txtValue.ToByte()); }
117     else { provider.PatchMemory(Address, txtValue.ToSByte()); }
118 william 230 break;
119     case SearchDataTypes._16bits:
120 william 239 if (Unsigned) { provider.PatchMemory(Address, txtValue.ToUInt16()); }
121     else { provider.PatchMemory(Address, txtValue.ToInt16()); }
122 william 230 break;
123     case SearchDataTypes._32bits:
124 william 239 if (Unsigned) { provider.PatchMemory(Address, txtValue.ToUInt32()); }
125     else { provider.PatchMemory(Address, txtValue.ToInt32()); }
126 william 230 break;
127     case SearchDataTypes._64bits:
128 william 239 if (Unsigned) { provider.PatchMemory(Address, txtValue.ToUInt64()); }
129     else { provider.PatchMemory(Address, txtValue.ToInt64()); }
130 william 230 break;
131     }
132 william 245 provider.CloseProvider();
133 william 230 this.Close();
134     }
135    
136     private void CopyToClipboard(string data)
137     {
138     Clipboard.SetData(DataFormats.Text, data);
139     }
140    
141     private void btnCopyAddressToClipboard_Click(object sender, EventArgs e)
142     {
143     this.CopyToClipboard(txtAddress.Text);
144     }
145    
146     private void btnCopyvaluetoClipboard_Click(object sender, EventArgs e)
147     {
148     this.CopyToClipboard(txtValue.Text);
149     }
150    
151     private void SearchPatcher_KeyDown(object sender, KeyEventArgs e)
152     {
153     if (e.KeyCode == Keys.Enter) btnOK.PerformClick();
154     }
155     }
156     }

  ViewVC Help
Powered by ViewVC 1.1.22