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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 240 - (show annotations) (download)
Sun Jun 3 12:54:18 2012 UTC (8 years, 10 months ago) by william
File size: 3781 byte(s)
+ implement GenericMemoryProvider : NOTE: config is null

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.Logging;
9 using System.Diagnostics;
10 using Sojaner.MemoryScanner.MemoryProviers;
11
12
13 namespace RomCheater.Docking.MemorySearch
14 {
15 public partial class SearchRangePatcher : Form
16 {
17 //PCSX2MemoryProvider provider;
18 private int pid = -1;
19 SearchDataTypes DataType;
20 //bool Unsigned = false;
21 private List<ResultDataType> PatchList;
22 public SearchRangePatcher(int pid,List<ResultDataType> patchList)
23 {
24 InitializeComponent();
25 this.pid = pid;
26 PatchList = patchList;
27 int CurrentBitSize = 0;
28 // get the larget datatype
29 foreach (ResultDataType patch in PatchList)
30 {
31 if ((int)patch.ValueType > CurrentBitSize)
32 {
33 CurrentBitSize = (int)patch.ValueType;
34 }
35 }
36 switch (CurrentBitSize)
37 {
38 case (int)SearchDataTypes._8bits: txtValue.CreateTypeSize<byte>(); break;
39 case (int)SearchDataTypes._16bits: txtValue.CreateTypeSize<ushort>(); break;
40 case (int)SearchDataTypes._32bits: txtValue.CreateTypeSize<uint>(); break;
41 case (int)SearchDataTypes._64bits: txtValue.CreateTypeSize<ulong>(); break;
42 }
43
44 }
45
46 private void SearchPatcher_Load(object sender, EventArgs e)
47 {
48 txtValue.ReadOnly = false;
49 }
50 private void btnCancel_Click(object sender, EventArgs e)
51 {
52 this.Close();
53 }
54 private void btnOK_Click(object sender, EventArgs e)
55 {
56 GenericMemoryProvider provider = new GenericMemoryProvider(null, Process.GetProcessById(pid));
57 foreach(ResultDataType patch in PatchList)
58 {
59 switch (patch.ValueType)
60 {
61 case SearchDataTypes._8bits:
62 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (byte)txtValue.Value); }
63 else { provider.PatchMemory(patch.Address, (sbyte)txtValue.Value); }
64 break;
65 case SearchDataTypes._16bits:
66 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ushort)txtValue.Value); }
67 else { provider.PatchMemory(patch.Address, (short)txtValue.Value); }
68 break;
69 case SearchDataTypes._32bits:
70 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (uint)txtValue.Value); }
71 else { provider.PatchMemory(patch.Address, (int)txtValue.Value); }
72 break;
73 case SearchDataTypes._64bits:
74 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ulong)txtValue.Value); }
75 else { provider.PatchMemory(patch.Address, (long)txtValue.Value); }
76 break;
77 }
78 }
79 this.Close();
80 }
81
82 private void CopyToClipboard(string data)
83 {
84 Clipboard.SetData(DataFormats.Text, data);
85 }
86
87 private void btnCopyvaluetoClipboard_Click(object sender, EventArgs e)
88 {
89 this.CopyToClipboard(txtValue.Text);
90 }
91
92 private void SearchPatcher_KeyDown(object sender, KeyEventArgs e)
93 {
94 if (e.KeyCode == Keys.Enter) btnOK.PerformClick();
95 }
96 }
97 }

  ViewVC Help
Powered by ViewVC 1.1.22