ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Docking/MemorySearch/InRangeComparer.cs
(Generate patch)

Comparing trunk/RomCheater/Docking/MemorySearch/InRangeComparer.cs (file contents):
Revision 407 by william, Wed Jun 20 10:51:25 2012 UTC vs.
Revision 408 by william, Thu Jun 21 18:10:21 2012 UTC

--- trunk/RomCheater/Docking/MemorySearch/InRangeComparer.cs	2012/06/21 15:59:29	407
+++ trunk/RomCheater/Docking/MemorySearch/InRangeComparer.cs	2012/06/21 18:10:21	408
@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.IO;
+using RomCheater.PluginFramework.Interfaces;
+using Sojaner.MemoryScanner.MemoryProviers;
 
 namespace RomCheater.Docking.MemorySearch
 {
@@ -13,7 +15,7 @@ namespace RomCheater.Docking.MemorySearc
         {
         }
         #region IRangeComparer<object> Members
-        public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, BinaryReader r)
+        public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, IAcceptsProcessAndConfig pconfig)
         {
             //reader.BaseStream.Seek(this.Address, SeekOrigin.Begin);
 
@@ -25,12 +27,16 @@ namespace RomCheater.Docking.MemorySearc
             {
                 if (unsigned)
                 {
-                    lookup_value = new DataTypeConverter(r.ReadByte());
+                    byte val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToByte() >= (byte)start_value && lookup_value.ToByte() <= (byte)end_value) { this.Value = lookup_value.Value; return true; }
                 }
                 else
                 {
-                    lookup_value = new DataTypeConverter(r.ReadSByte());
+                    sbyte val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToSByte() >= (sbyte)start_value && lookup_value.ToSByte() <= (sbyte)end_value) { this.Value = lookup_value.Value; return true; }
                 }
             }
@@ -38,12 +44,16 @@ namespace RomCheater.Docking.MemorySearc
             {
                 if (unsigned)
                 {
-                    lookup_value = new DataTypeConverter(r.ReadUInt16()) ;
+                    ushort val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToUInt16() >= (ushort)start_value && lookup_value.ToUInt16() <= (ushort)end_value) { this.Value = lookup_value.Value; return true; }
                 }
                 else
                 {
-                    lookup_value = new DataTypeConverter(r.ReadInt16());
+                    short val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToInt16() >= (short)start_value && lookup_value.ToInt16() <= (short)end_value) { this.Value = lookup_value.Value; return true; }
                 }
             }
@@ -51,12 +61,16 @@ namespace RomCheater.Docking.MemorySearc
             {
                 if (unsigned)
                 {
-                    lookup_value = new DataTypeConverter(r.ReadUInt32());
+                    uint val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToUInt32() >= (uint)start_value && lookup_value.ToUInt32() <= (uint)end_value) { this.Value = lookup_value.Value; return true; }
                 }
                 else
                 {
-                    lookup_value = new DataTypeConverter(r.ReadInt32());
+                    int val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToInt32() >= (int)start_value && lookup_value.ToInt32() <= (int)end_value) { this.Value = lookup_value.Value; return true; }
                 }
             }
@@ -64,12 +78,16 @@ namespace RomCheater.Docking.MemorySearc
             {
                 if (unsigned)
                 {
-                    lookup_value = new DataTypeConverter(r.ReadUInt64());
+                    ulong val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToUInt64() >= (ulong)start_value && lookup_value.ToUInt64() <= (ulong)end_value) { this.Value = lookup_value.Value; return true; }
                 }
                 else
                 {
-                    lookup_value = new DataTypeConverter(r.ReadInt64());
+                    long val = 0;
+                    using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
+                    lookup_value = new DataTypeConverter(val);   
                     if (lookup_value.ToInt64() >= (long)start_value && lookup_value.ToInt64() <= (long)end_value) { this.Value = lookup_value.Value; return true; }
                 }
             }