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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Tue Jun 5 00:13:29 2012 UTC (9 years ago) by william
File size: 3720 byte(s)
+ import search code from PCSX2 Ram Dump (no need to re-invent the wheel...plus it cuts down on code refactoring time)

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 NotInRangeComparer : RangedComparer<object>, IRangeComparer<object>
10 {
11 public NotInRangeComparer(int address, object value)
12 : base(address, value)
13 {
14 }
15
16 #region IRangeComparer<object> Members
17 public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, BinaryReader reader)
18 {
19 reader.BaseStream.Seek(this.Address, SeekOrigin.Begin);
20
21 ulong start_value, end_value;
22 start_value = new DataTypeConverter(Start).ToUInt64();
23 end_value = new DataTypeConverter(End).ToUInt64();
24 DataTypeConverter lookup_value;
25 if (bitsize == SearchDataTypes._8bits)
26 {
27 if (unsigned)
28 {
29 lookup_value = new DataTypeConverter(reader.ReadByte());
30 if (lookup_value.ToByte() < (byte)start_value || lookup_value.ToByte() > (byte)end_value) { this.Value = lookup_value.Value; return true; }
31 }
32 else
33 {
34 lookup_value = new DataTypeConverter(reader.ReadSByte());
35 if (lookup_value.ToSByte() < (sbyte)start_value || lookup_value.ToSByte() > (sbyte)end_value) { this.Value = lookup_value.Value; return true; }
36 }
37 }
38 else if (bitsize == SearchDataTypes._16bits)
39 {
40 if (unsigned)
41 {
42 lookup_value = new DataTypeConverter(reader.ReadUInt16());
43 if (lookup_value.ToUInt16() < (ushort)start_value || lookup_value.ToUInt16() > (ushort)end_value) { this.Value = lookup_value.Value; return true; }
44 }
45 else
46 {
47 lookup_value = new DataTypeConverter(reader.ReadInt16());
48 if (lookup_value.ToInt16() < (short)start_value || lookup_value.ToInt16() > (short)end_value) { this.Value = lookup_value.Value; return true; }
49 }
50 }
51 else if (bitsize == SearchDataTypes._32bits)
52 {
53 if (unsigned)
54 {
55 lookup_value = new DataTypeConverter(reader.ReadUInt32());
56 if (lookup_value.ToUInt32() < (uint)start_value || lookup_value.ToUInt32() > (uint)end_value) { this.Value = lookup_value.Value; return true; }
57 }
58 else
59 {
60 lookup_value = new DataTypeConverter(reader.ReadInt32());
61 if (lookup_value.ToInt32() < (int)start_value || lookup_value.ToInt32() > (int)end_value) { this.Value = lookup_value.Value; return true; }
62 }
63 }
64 else if (bitsize == SearchDataTypes._64bits)
65 {
66 if (unsigned)
67 {
68 lookup_value = new DataTypeConverter(reader.ReadUInt64());
69 if (lookup_value.ToUInt64() < (ulong)start_value || lookup_value.ToUInt64() > (ulong)end_value) { this.Value = lookup_value.Value; return true; }
70 }
71 else
72 {
73 lookup_value = new DataTypeConverter(reader.ReadInt64());
74 if (lookup_value.ToInt64() < (long)start_value || lookup_value.ToInt64() > (long)end_value) { this.Value = lookup_value.Value; return true; }
75 }
76 }
77 return false;
78 }
79 #endregion
80 }
81 }

  ViewVC Help
Powered by ViewVC 1.1.22