using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace RomCheater.Docking.MemorySearch { public class NotInRangeComparer : RangedComparer, IRangeComparer { public NotInRangeComparer(uint address, object value) : base(address, value) { } #region IRangeComparer Members public bool Compare(object Start, object End, SearchDataTypes bitsize, bool unsigned, byte[] buffered_mem) { //reader.BaseStream.Seek(this.Address, SeekOrigin.Begin); ulong start_value, end_value; start_value = new DataTypeConverter(Start).ToUInt64(); end_value = new DataTypeConverter(End).ToUInt64(); DataTypeConverter lookup_value; if (bitsize == SearchDataTypes._8bits) { if (unsigned) { lookup_value = new DataTypeConverter(buffered_mem[this.Address]); if (lookup_value.ToByte() < (byte)start_value || lookup_value.ToByte() > (byte)end_value) { this.Value = lookup_value.Value; return true; } } else { lookup_value = new DataTypeConverter(buffered_mem[this.Address]); if (lookup_value.ToSByte() < (sbyte)start_value || lookup_value.ToSByte() > (sbyte)end_value) { this.Value = lookup_value.Value; return true; } } } else if (bitsize == SearchDataTypes._16bits) { if (unsigned) { lookup_value = new DataTypeConverter(BitConverter.ToUInt16(buffered_mem, (int)this.Address)); if (lookup_value.ToUInt16() < (ushort)start_value || lookup_value.ToUInt16() > (ushort)end_value) { this.Value = lookup_value.Value; return true; } } else { lookup_value = new DataTypeConverter(BitConverter.ToInt16(buffered_mem, (int)this.Address)); if (lookup_value.ToInt16() < (short)start_value || lookup_value.ToInt16() > (short)end_value) { this.Value = lookup_value.Value; return true; } } } else if (bitsize == SearchDataTypes._32bits) { if (unsigned) { lookup_value = new DataTypeConverter(BitConverter.ToUInt32(buffered_mem, (int)this.Address)); if (lookup_value.ToUInt32() < (uint)start_value || lookup_value.ToUInt32() > (uint)end_value) { this.Value = lookup_value.Value; return true; } } else { lookup_value = new DataTypeConverter(BitConverter.ToInt32(buffered_mem, (int)this.Address)); if (lookup_value.ToInt32() < (int)start_value || lookup_value.ToInt32() > (int)end_value) { this.Value = lookup_value.Value; return true; } } } else if (bitsize == SearchDataTypes._64bits) { if (unsigned) { lookup_value = new DataTypeConverter(BitConverter.ToUInt64(buffered_mem, (int)this.Address)); if (lookup_value.ToUInt64() < (ulong)start_value || lookup_value.ToUInt64() > (ulong)end_value) { this.Value = lookup_value.Value; return true; } } else { lookup_value = new DataTypeConverter(BitConverter.ToInt64(buffered_mem, (int)this.Address)); if (lookup_value.ToInt64() < (long)start_value || lookup_value.ToInt64() > (long)end_value) { this.Value = lookup_value.Value; return true; } } } return false; } #endregion } }