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

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

  ViewVC Help
Powered by ViewVC 1.1.22