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

Annotation of /trunk/RomCheater/Docking/MemorySearch/InRangeComparer.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 408 - (hide annotations) (download)
Thu Jun 21 18:10:21 2012 UTC (9 years, 3 months ago) by william
File size: 5389 byte(s)

1 william 280 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using System.IO;
6 william 408 using RomCheater.PluginFramework.Interfaces;
7     using Sojaner.MemoryScanner.MemoryProviers;
8 william 280
9     namespace RomCheater.Docking.MemorySearch
10     {
11     public class InRangeComparer : RangedComparer<object>, IRangeComparer<object>
12     {
13 william 378 public InRangeComparer(uint address, object value)
14 william 280 : base(address, value)
15     {
16     }
17     #region IRangeComparer<object> Members
18 william 408 public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, IAcceptsProcessAndConfig pconfig)
19 william 280 {
20 william 384 //reader.BaseStream.Seek(this.Address, SeekOrigin.Begin);
21 william 280
22     ulong start_value, end_value;
23     start_value = new DataTypeConverter(Start).ToUInt64();
24     end_value = new DataTypeConverter(End).ToUInt64();
25     DataTypeConverter lookup_value;
26     if (bitsize == SearchDataTypes._8bits)
27     {
28     if (unsigned)
29     {
30 william 408 byte val = 0;
31     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
32     lookup_value = new DataTypeConverter(val);
33 william 280 if (lookup_value.ToByte() >= (byte)start_value && lookup_value.ToByte() <= (byte)end_value) { this.Value = lookup_value.Value; return true; }
34     }
35     else
36     {
37 william 408 sbyte val = 0;
38     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
39     lookup_value = new DataTypeConverter(val);
40 william 280 if (lookup_value.ToSByte() >= (sbyte)start_value && lookup_value.ToSByte() <= (sbyte)end_value) { this.Value = lookup_value.Value; return true; }
41     }
42     }
43     else if (bitsize == SearchDataTypes._16bits)
44     {
45     if (unsigned)
46     {
47 william 408 ushort val = 0;
48     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
49     lookup_value = new DataTypeConverter(val);
50 william 280 if (lookup_value.ToUInt16() >= (ushort)start_value && lookup_value.ToUInt16() <= (ushort)end_value) { this.Value = lookup_value.Value; return true; }
51     }
52     else
53     {
54 william 408 short val = 0;
55     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
56     lookup_value = new DataTypeConverter(val);
57 william 280 if (lookup_value.ToInt16() >= (short)start_value && lookup_value.ToInt16() <= (short)end_value) { this.Value = lookup_value.Value; return true; }
58     }
59     }
60     else if (bitsize == SearchDataTypes._32bits)
61     {
62     if (unsigned)
63     {
64 william 408 uint val = 0;
65     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
66     lookup_value = new DataTypeConverter(val);
67 william 280 if (lookup_value.ToUInt32() >= (uint)start_value && lookup_value.ToUInt32() <= (uint)end_value) { this.Value = lookup_value.Value; return true; }
68     }
69     else
70     {
71 william 408 int val = 0;
72     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
73     lookup_value = new DataTypeConverter(val);
74 william 280 if (lookup_value.ToInt32() >= (int)start_value && lookup_value.ToInt32() <= (int)end_value) { this.Value = lookup_value.Value; return true; }
75     }
76     }
77     else if (bitsize == SearchDataTypes._64bits)
78     {
79     if (unsigned)
80     {
81 william 408 ulong val = 0;
82     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
83     lookup_value = new DataTypeConverter(val);
84 william 280 if (lookup_value.ToUInt64() >= (ulong)start_value && lookup_value.ToUInt64() <= (ulong)end_value) { this.Value = lookup_value.Value; return true; }
85     }
86     else
87     {
88 william 408 long val = 0;
89     using (GenericMemoryProvider gmp = new GenericMemoryProvider(pconfig)) { gmp.OpenProvider(); gmp.ReadMemory(Address, out val); gmp.CloseProvider(); }
90     lookup_value = new DataTypeConverter(val);
91 william 280 if (lookup_value.ToInt64() >= (long)start_value && lookup_value.ToInt64() <= (long)end_value) { this.Value = lookup_value.Value; return true; }
92     }
93     }
94     return false;
95     }
96     #endregion
97     }
98     }

  ViewVC Help
Powered by ViewVC 1.1.22