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

Contents of /trunk/RomCheater.Core/Docking/MemorySearch/SearchPatcher.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 892 - (show annotations) (download)
Wed Sep 17 05:56:41 2014 UTC (6 years, 10 months ago) by william
File size: 6798 byte(s)
+ alot of dang work to force an icon to be shown on the docked panels
  ** when it was as simple as setting: DockPanel.ShowDocumentIcon to true

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

  ViewVC Help
Powered by ViewVC 1.1.22