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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 378 - (show annotations) (download)
Tue Jun 19 07:56:36 2012 UTC (9 years, 3 months ago) by william
File size: 3729 byte(s)
use uint instead of int for memory addresses

1 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 public InRangeComparer(uint address, object value)
12 : base(address, value)
13 {
14 }
15 #region IRangeComparer<object> Members
16 public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, BinaryReader reader)
17 {
18 reader.BaseStream.Seek(this.Address, SeekOrigin.Begin);
19
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 lookup_value = new DataTypeConverter(reader.ReadByte());
29 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 lookup_value = new DataTypeConverter(reader.ReadSByte());
34 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 lookup_value = new DataTypeConverter(reader.ReadUInt16());
42 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 lookup_value = new DataTypeConverter(reader.ReadInt16());
47 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 lookup_value = new DataTypeConverter(reader.ReadUInt32());
55 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 lookup_value = new DataTypeConverter(reader.ReadInt32());
60 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 lookup_value = new DataTypeConverter(reader.ReadUInt64());
68 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 lookup_value = new DataTypeConverter(reader.ReadInt64());
73 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