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

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

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

--- trunk/RomCheater/Docking/MemorySearch/ResultItemState.cs	2012/06/03 13:30:16	244
+++ trunk/RomCheater/Docking/MemorySearch/ResultItemState.cs	2012/06/03 14:50:09	245
@@ -7,11 +7,15 @@
 using System.Diagnostics;
 using RomCheater.Logging;
 using Sojaner.MemoryScanner.MemoryProviers;
+using RomCheater.PluginFramework.Interfaces;
 
 namespace RomCheater.Docking.MemorySearch
 {
     [Serializable]
-    public class ResultItemState
+    public class ResultItemState :
+        IAcceptsPlugin<IConfigPlugin>,
+        IAcceptsProcess<Process>,
+        IAcceptsProcessAndConfig
     {
         #region Implicit Conversion
         public static implicit operator ResultDataType(ResultItemState state)
@@ -47,8 +51,14 @@
             return _result;
         }
         #endregion
-
-        public ResultItemState()
+        #region  IAcceptsProcess<Process> Members
+        public Process AcceptedProcess { get; set; }
+        #endregion
+        #region IAcceptsPlugin<IConfigPlugin> Members
+        public IConfigPlugin AcceptedPlugin { get; set; }
+        #endregion
+        public ResultItemState() : this(null) { }
+        public ResultItemState(IAcceptsProcessAndConfig pconfig)
         {
             this.IconKey = "";
             this.Address = (0).ToString("x8");
@@ -56,13 +66,17 @@
             this.Frozen = false.ToString();
             this.ValueType = SearchDataTypes._32bits;
             this.IsUnsigned = true;
+
+            this.AcceptedPlugin = pconfig.AcceptedPlugin;
+            this.AcceptedProcess = pconfig.AcceptedProcess;
         }
-        public ResultItemState(string address, SearchDataTypes bitsize, bool IsUnsigned, int pid)
-            : this(AVPIconKeys.NOTFROZEN, address, "", false.ToString(), bitsize, IsUnsigned)
+        public ResultItemState(string address, SearchDataTypes bitsize, bool IsUnsigned, IAcceptsProcessAndConfig pconfig)
+            : this(AVPIconKeys.NOTFROZEN, address, "", false.ToString(), bitsize, IsUnsigned, pconfig)
         {
             uint Address = 0;
             Address = Convert.ToUInt32(this.Address, 16);
-            GenericMemoryProvider provider = new GenericMemoryProvider(null, Process.GetProcessById(pid));
+            GenericMemoryProvider provider = new GenericMemoryProvider(pconfig);
+            provider.OpenProvider();
             int bytesReadSize;
             byte[] data;
             uint bytesToRead=0;
@@ -107,39 +121,10 @@
                     else { this.Value = string.Format("0x{0:x16}", r_ms.ReadInt64()); }
                     break;
             }
+            provider.CloseProvider();
         }
-        //public ResultItemState(string address, SearchDataTypes bitsize, bool IsUnsigned)
-        //    : this(AVPIconKeys.NOTFROZEN, address, "", false.ToString(), bitsize, IsUnsigned)
-        //{
-        //    //PCSX2MemoryProvider provider = new PCSX2MemoryProvider(pcsx2_pid, null);
-        //    //byte[] buffered_mem = provider.GetMemory();
-        //    //MemoryStream ms = new MemoryStream(buffered_mem);
-        //    //BinaryReader r_ms = new BinaryReader(ms);
-        //    uint Address = 0;
-        //    Address = Convert.ToUInt32(this.Address, 16);
-        //    //r_ms.BaseStream.Seek(Address, SeekOrigin.Begin);
-        //    int val = 0;
-        //    switch (bitsize)
-        //    {
-        //        case SearchDataTypes._8bits:
-        //            if (IsUnsigned) { this.Value = string.Format("0x{0:x2}", val); }
-        //            else { this.Value = string.Format("0x{0:x2}", val); }
-        //            break;
-        //        case SearchDataTypes._16bits:
-        //            if (IsUnsigned) { this.Value = string.Format("0x{0:x4}", val); }
-        //            else { this.Value = string.Format("0x{0:x4}", val); }
-        //            break;
-        //        case SearchDataTypes._32bits:
-        //            if (IsUnsigned) { this.Value = string.Format("0x{0:x8}", val); }
-        //            else { this.Value = string.Format("0x{0:x8}", val); }
-        //            break;
-        //        case SearchDataTypes._64bits:
-        //            if (IsUnsigned) { this.Value = string.Format("0x{0:x16}", val); }
-        //            else { this.Value = string.Format("0x{0:x16}", val); }
-        //            break;
-        //    }
-        //}
-        public ResultItemState(string IconKey, string address, string value, string frozen, SearchDataTypes bitsize, bool IsUnsigned)
+        public ResultItemState(string IconKey, string address, string value, string frozen, SearchDataTypes bitsize, bool IsUnsigned, IAcceptsProcessAndConfig pconfig)
+            : this(pconfig)
         {
             this.IconKey = IconKey;
             this.Address = address;

 

  ViewVC Help
Powered by ViewVC 1.1.22