/[RomCheater]/trunk/RomCheater/Docking/UI/UIMemoryViewer.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/UI/UIMemoryViewer.cs

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

--- trunk/RomCheater/Docking/UI/UIMemoryViewer.cs	2012/06/03 12:48:09	237
+++ trunk/RomCheater/Docking/UI/UIMemoryViewer.cs	2012/06/03 12:48:38	238
@@ -10,10 +10,11 @@
 using RomCheater.Logging;
 using RomCheater.PluginFramework.Interfaces;
 using System.Diagnostics;
+using Sojaner.MemoryScanner.MemoryProviers;
 
 namespace RomCheater.Docking.UI
 {
-    public partial class UIMemoryViewer : UserControl, IProcessConfig, IAcceptsPlugin<IConfigPlugin>//, IAcceptsMemoryRange
+    public partial class UIMemoryViewer : UserControl, IAcceptsProcess<Process>, IAcceptsPlugin<IConfigPlugin>//, IAcceptsMemoryRange
     {
         public UIMemoryViewer()
         {
@@ -49,16 +50,14 @@
         {
             if (!DesignMode)
             {
-                Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
-                reader.ReadProcess = this.AcceptedProcess;
-                reader.OpenProcess();
+                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
                 uint addr = 0;
-                reader.ReadFirstNonZeroByte(MemoryStart, MemorySize, out addr);
+                provider.ReadFirstNonZeroByte(MemoryStart, MemorySize, out addr);
                 GotoAddress(addr);
             }
         }
 
-        #region IProcessConfig Members
+        #region  IAcceptsProcess<Process> Members
         private Process _AcceptedProcess;
         public Process AcceptedProcess
         {
@@ -190,12 +189,10 @@
         {
             try
             {
-                Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
-                reader.ReadProcess = this.AcceptedProcess;
-                reader.OpenProcess();
+                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
                 int bytesReadSize;
                 byte[] data;
-                reader.ReadProcessMemory(CURRENT_TOP_ADDR, max_ram_view, out bytesReadSize, out data);
+                provider.ReadProcessMemory(CURRENT_TOP_ADDR, max_ram_view, out bytesReadSize, out data);
                 //this.Logger.LogDebugMessage(string.Format("GetMemory() -> Memory Size: {0}0x{2:X8}{1}", "{", "}", data.Length));
                 return data;
             }
@@ -281,18 +278,14 @@
                 if (AcceptedPlugin == null) { return; }
                 // Byte changed
                 //byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
-                
-
-                Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
-                reader.ReadProcess = this.AcceptedProcess;
-                reader.OpenProcess();
+                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
                 int bytesReadSize;
 
                 for (int i = 0; i < data.Length; i ++)
                 {
                     uint addr = (uint)(start_address + i);
                     byte data_to_write = data[i];
-                    reader.WriteProcessMemory((UIntPtr)addr, data_to_write, out bytesReadSize);
+                    provider.WriteProcessMemory(addr, data_to_write, out bytesReadSize);
                 }
             }
             catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }

 

  ViewVC Help
Powered by ViewVC 1.1.22