/[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 384 - (hide annotations) (download)
Tue Jun 19 10:15:53 2012 UTC (9 years, 3 months ago) by william
File size: 3958 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    
7     namespace RomCheater.Docking.MemorySearch
8     {
9     public class InRangeComparer : RangedComparer<object>, IRangeComparer<object>
10     {
11 william 378 public InRangeComparer(uint address, object value)
12 william 280 : base(address, value)
13     {
14     }
15     #region IRangeComparer<object> Members
16 william 384 public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, byte[] buffered_mem)
17 william 280 {
18 william 384 //reader.BaseStream.Seek(this.Address, SeekOrigin.Begin);
19 william 280
20     ulong start_value, end_value;
21     start_value = new DataTypeConverter(Start).ToUInt64();
22     end_value = new DataTypeConverter(End).ToUInt64();
23     DataTypeConverter lookup_value;
24     if (bitsize == SearchDataTypes._8bits)
25     {
26     if (unsigned)
27     {
28 william 384 lookup_value = new DataTypeConverter(buffered_mem[this.Address]);
29 william 280 if (lookup_value.ToByte() >= (byte)start_value && lookup_value.ToByte() <= (byte)end_value) { this.Value = lookup_value.Value; return true; }
30     }
31     else
32     {
33 william 384 lookup_value = new DataTypeConverter(buffered_mem[this.Address]);
34 william 280 if (lookup_value.ToSByte() >= (sbyte)start_value && lookup_value.ToSByte() <= (sbyte)end_value) { this.Value = lookup_value.Value; return true; }
35     }
36     }
37     else if (bitsize == SearchDataTypes._16bits)
38     {
39     if (unsigned)
40     {
41 william 384 lookup_value = new DataTypeConverter(BitConverter.ToUInt16(buffered_mem,(int)this.Address)) ;
42 william 280 if (lookup_value.ToUInt16() >= (ushort)start_value && lookup_value.ToUInt16() <= (ushort)end_value) { this.Value = lookup_value.Value; return true; }
43     }
44     else
45     {
46 william 384 lookup_value = new DataTypeConverter(BitConverter.ToInt16(buffered_mem, (int)this.Address));
47 william 280 if (lookup_value.ToInt16() >= (short)start_value && lookup_value.ToInt16() <= (short)end_value) { this.Value = lookup_value.Value; return true; }
48     }
49     }
50     else if (bitsize == SearchDataTypes._32bits)
51     {
52     if (unsigned)
53     {
54 william 384 lookup_value = new DataTypeConverter(BitConverter.ToUInt32(buffered_mem, (int)this.Address));
55 william 280 if (lookup_value.ToUInt32() >= (uint)start_value && lookup_value.ToUInt32() <= (uint)end_value) { this.Value = lookup_value.Value; return true; }
56     }
57     else
58     {
59 william 384 lookup_value = new DataTypeConverter(BitConverter.ToInt32(buffered_mem, (int)this.Address));
60 william 280 if (lookup_value.ToInt32() >= (int)start_value && lookup_value.ToInt32() <= (int)end_value) { this.Value = lookup_value.Value; return true; }
61     }
62     }
63     else if (bitsize == SearchDataTypes._64bits)
64     {
65     if (unsigned)
66     {
67 william 384 lookup_value = new DataTypeConverter(BitConverter.ToUInt64(buffered_mem, (int)this.Address));
68 william 280 if (lookup_value.ToUInt64() >= (ulong)start_value && lookup_value.ToUInt64() <= (ulong)end_value) { this.Value = lookup_value.Value; return true; }
69     }
70     else
71     {
72 william 384 lookup_value = new DataTypeConverter(BitConverter.ToInt64(buffered_mem, (int)this.Address));
73 william 280 if (lookup_value.ToInt64() >= (long)start_value && lookup_value.ToInt64() <= (long)end_value) { this.Value = lookup_value.Value; return true; }
74     }
75     }
76     return false;
77     }
78     #endregion
79     }
80     }

  ViewVC Help
Powered by ViewVC 1.1.22