/[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 424 - (show annotations) (download)
Tue May 28 12:03:10 2013 UTC (7 years, 2 months ago) by william
File size: 5398 byte(s)
revert r423
+  do not close provider - keep it open for shared access

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6 using Sojaner.MemoryScanner.MemoryProviers;
7 using RomCheater.PluginFramework.Interfaces;
8
9 namespace RomCheater.Docking.MemorySearch
10 {
11 public class NotInRangeComparer : RangedComparer<object>, IRangeComparer<object>
12 {
13 public NotInRangeComparer(uint address, object value)
14 : base(address, value)
15 {
16 }
17
18 #region IRangeComparer<object> Members
19 public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, IAcceptsProcessAndConfig pconfig)
20 {
21 //reader.BaseStream.Seek(this.Address, SeekOrigin.Begin);
22
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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