/[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

--- trunk/RomCheater/Docking/MemorySearch/SearchRangePatcher.cs	2012/06/02 19:12:20	230
+++ trunk/RomCheater/Docking/MemorySearch/SearchRangePatcher.cs	2012/06/03 13:21:51	243
@@ -7,21 +7,32 @@
 using System.Windows.Forms;
 using RomCheater.Logging;
 using System.Diagnostics;
+using Sojaner.MemoryScanner.MemoryProviers;
+using RomCheater.PluginFramework.Interfaces;
 
 
 namespace RomCheater.Docking.MemorySearch
 {
-    public partial class SearchRangePatcher : Form
+    public partial class SearchRangePatcher : Form,
+        IAcceptsPlugin<IConfigPlugin>,
+        IAcceptsProcess<Process>,
+        IAcceptsProcessAndConfig
     {
+        #region  IAcceptsProcess<Process> Members
+        public Process AcceptedProcess { get; set; }
+        #endregion
+        #region IAcceptsPlugin<IConfigPlugin> Members
+        public IConfigPlugin AcceptedPlugin { get; set; }
+        #endregion
         //PCSX2MemoryProvider provider;
-        private int pid = -1;
-        SearchDataTypes DataType;
+        //SearchDataTypes DataType;
         //bool Unsigned = false;
         private List<ResultDataType> PatchList;
-        public SearchRangePatcher(int pid,List<ResultDataType> patchList)
+        public SearchRangePatcher(IAcceptsProcessAndConfig pconfig ,List<ResultDataType> patchList)
         {
             InitializeComponent();
-            this.pid = pid;
+            this.AcceptedPlugin = pconfig.AcceptedPlugin;
+            this.AcceptedProcess = pconfig.AcceptedProcess;
             PatchList = patchList;
             int CurrentBitSize = 0;
             // get the larget datatype
@@ -52,29 +63,26 @@
         }
         private void btnOK_Click(object sender, EventArgs e)
         {
-
-            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; }
+            GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
             foreach(ResultDataType patch in PatchList)
             {
                 switch (patch.ValueType)
                 {
                     case SearchDataTypes._8bits:
-                        if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (byte)txtValue.Value); }
-                        else { reader.PatchMemory(patch.Address, (sbyte)txtValue.Value); }
+                        if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (byte)txtValue.Value); }
+                        else { provider.PatchMemory(patch.Address, (sbyte)txtValue.Value); }
                         break;
                     case SearchDataTypes._16bits:
-                        if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (ushort)txtValue.Value); }
-                        else { reader.PatchMemory(patch.Address, (short)txtValue.Value); }
+                        if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ushort)txtValue.Value); }
+                        else { provider.PatchMemory(patch.Address, (short)txtValue.Value); }
                         break;
                     case SearchDataTypes._32bits:
-                        if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (uint)txtValue.Value); }
-                        else { reader.PatchMemory(patch.Address, (int)txtValue.Value); }
+                        if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (uint)txtValue.Value); }
+                        else { provider.PatchMemory(patch.Address, (int)txtValue.Value); }
                         break;
                     case SearchDataTypes._64bits:
-                        if (patch.IsUnsigned) { reader.PatchMemory(patch.Address, (ulong)txtValue.Value); }
-                        else { reader.PatchMemory(patch.Address, (long)txtValue.Value); }
+                        if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ulong)txtValue.Value); }
+                        else { provider.PatchMemory(patch.Address, (long)txtValue.Value); }
                         break;
                 }
             }

 

  ViewVC Help
Powered by ViewVC 1.1.22