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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 230 by william, Sat Jun 2 19:12:20 2012 UTC revision 243 by william, Sun Jun 3 13:21:51 2012 UTC
# Line 7  using System.Text; Line 7  using System.Text;
7  using System.Windows.Forms;  using System.Windows.Forms;
8  using RomCheater.Logging;  using RomCheater.Logging;
9  using System.Diagnostics;  using System.Diagnostics;
10    using Sojaner.MemoryScanner.MemoryProviers;
11    using RomCheater.PluginFramework.Interfaces;
12    
13    
14  namespace RomCheater.Docking.MemorySearch  namespace RomCheater.Docking.MemorySearch
15  {  {
16      public partial class SearchRangePatcher : Form      public partial class SearchRangePatcher : Form,
17            IAcceptsPlugin<IConfigPlugin>,
18            IAcceptsProcess<Process>,
19            IAcceptsProcessAndConfig
20      {      {
21            #region  IAcceptsProcess<Process> Members
22            public Process AcceptedProcess { get; set; }
23            #endregion
24            #region IAcceptsPlugin<IConfigPlugin> Members
25            public IConfigPlugin AcceptedPlugin { get; set; }
26            #endregion
27          //PCSX2MemoryProvider provider;          //PCSX2MemoryProvider provider;
28          private int pid = -1;          //SearchDataTypes DataType;
         SearchDataTypes DataType;  
29          //bool Unsigned = false;          //bool Unsigned = false;
30          private List<ResultDataType> PatchList;          private List<ResultDataType> PatchList;
31          public SearchRangePatcher(int pid,List<ResultDataType> patchList)          public SearchRangePatcher(IAcceptsProcessAndConfig pconfig ,List<ResultDataType> patchList)
32          {          {
33              InitializeComponent();              InitializeComponent();
34              this.pid = pid;              this.AcceptedPlugin = pconfig.AcceptedPlugin;
35                this.AcceptedProcess = pconfig.AcceptedProcess;
36              PatchList = patchList;              PatchList = patchList;
37              int CurrentBitSize = 0;              int CurrentBitSize = 0;
38              // get the larget datatype              // get the larget datatype
# Line 52  namespace RomCheater.Docking.MemorySearc Line 63  namespace RomCheater.Docking.MemorySearc
63          }          }
64          private void btnOK_Click(object sender, EventArgs e)          private void btnOK_Click(object sender, EventArgs e)
65          {          {
66                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
             Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();  
             reader.ReadProcess = Process.GetProcessById(pid);  
             if (reader.ReadProcess == null) { logger.Error.WriteLine("Could not attach to process: {0}", pid); return; }  
67              foreach(ResultDataType patch in PatchList)              foreach(ResultDataType patch in PatchList)
68              {              {
69                  switch (patch.ValueType)                  switch (patch.ValueType)
70                  {                  {
71                      case SearchDataTypes._8bits:                      case SearchDataTypes._8bits:
72                          if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (byte)txtValue.Value); }                          if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (byte)txtValue.Value); }
73                          else { reader.PatchMemory(patch.Address, (sbyte)txtValue.Value); }                          else { provider.PatchMemory(patch.Address, (sbyte)txtValue.Value); }
74                          break;                          break;
75                      case SearchDataTypes._16bits:                      case SearchDataTypes._16bits:
76                          if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (ushort)txtValue.Value); }                          if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ushort)txtValue.Value); }
77                          else { reader.PatchMemory(patch.Address, (short)txtValue.Value); }                          else { provider.PatchMemory(patch.Address, (short)txtValue.Value); }
78                          break;                          break;
79                      case SearchDataTypes._32bits:                      case SearchDataTypes._32bits:
80                          if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (uint)txtValue.Value); }                          if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (uint)txtValue.Value); }
81                          else { reader.PatchMemory(patch.Address, (int)txtValue.Value); }                          else { provider.PatchMemory(patch.Address, (int)txtValue.Value); }
82                          break;                          break;
83                      case SearchDataTypes._64bits:                      case SearchDataTypes._64bits:
84                          if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (ulong)txtValue.Value); }                          if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ulong)txtValue.Value); }
85                          else { reader.PatchMemory(patch.Address, (long)txtValue.Value); }                          else { provider.PatchMemory(patch.Address, (long)txtValue.Value); }
86                          break;                          break;
87                  }                  }
88              }              }

Legend:
Removed from v.230  
changed lines
  Added in v.243

  ViewVC Help
Powered by ViewVC 1.1.22