protected Utility(IntPtr hwnd, ScreenSize size) { this.SC2hwnd = hwnd; this.mem = new ReadWriteMemory(this.SC2hwnd); this.ChangeSize(size); this.debug = /*Debugger.IsAttached*/ false; }
static void Main(string[] args) { ReadWriteMemory rwm = new ReadWriteMemory("Lightshot"); Console.WriteLine("Before: " + rwm.ReadString(0x00DC7FF5, 8)); rwm.Write(0x00DC7FF5, "This is a test"); Console.WriteLine("After: " + rwm.ReadString(0x00DC7FF5, 16)); Console.ReadLine(); }
public AbilRally(uint address, ReadWriteMemory mem) : base(address, mem) { uint num; this._mem = mem; base.Address = address; this._mem.ReadMemory(base.Address + 0x30, 4, out num); base.Address = num; }
public Object ReadStructMember(ORNames Struct, ORNames Member, byte[] Data) { int Offset = GetStructMemberOffset(Struct, Member); int Size = GetStructMemberSize(Struct, Member); int Count = GetStructMemberCount(Struct, Member); Type type = GetStructMemberType(Struct, Member); if (Data == null) { throw new NullReferenceException("OffsetReader.ReadStructMember: Data was null. Struct: " + Struct + " Member: " + Member); } if (Data.Length < Offset + Size) { char[] hex = new char[16] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; string HexData = string.Empty; foreach (byte b in Data) { HexData += hex[b >> 4]; HexData += hex[b & 0x0F] + " "; } throw new IndexOutOfRangeException("OffsetReader.ReadStructMember: Data was too small to read all data.\nData.Length: " + Data.Length.ToString() + " Offset: " + Offset.ToString() + " Size: " + Size.ToString() + " Struct: " + Struct.ToString() + " Member: " + Member.ToString() + "\n Data: " + HexData); } if (type == StringType) { string ReturnValS = Encoding.UTF8.GetString(Data, Offset, Size); int NullPos = ReturnValS.IndexOf('\0'); if (NullPos >= 0) { ReturnValS = ReturnValS.Remove(NullPos); } return(ReturnValS); } if (Count <= 0) { return(ReadWriteMemory.RawDeserialize(Data, Offset, type)); } Array ReturnVal = Array.CreateInstance(type, Count); for (int i = 0; i < Count; i++) { ReturnVal.SetValue(ReadWriteMemory.RawDeserialize(Data, Offset + i * Size / Count, type), i); } return(ReturnVal); }
public Abil(uint address, ReadWriteMemory mem) { if (address == 0) { throw new Exception("InvalidAddress"); } if (mem == null) { throw new Exception("Need Proper ReadWriteMemory Object"); } this._address = address; this._mem = mem; this.RefreshData(); }
public Object ReadStructMember(ORNames Struct, ORNames Member, uint Address = 0) { if (Address <= 0) { Address = GetStructAddress(Struct); } Type type = GetStructMemberType(Struct, Member); if (type == StringType) { int Length = GetStructMemberSize(Struct, Member); byte[] buffer = new byte[Length]; mem.ReadMemory((uint)(GetStructMemberOffset(Struct, Member) + Address), buffer.Length, out buffer); string ReturnValS = Encoding.UTF8.GetString(buffer); int NullPos = ReturnValS.IndexOf('\0'); if (NullPos >= 0) { ReturnValS = ReturnValS.Remove(NullPos); } return(ReturnValS); } int Count = GetStructMemberCount(Struct, Member); if (Count <= 0) { return(mem.ReadMemory((uint)(GetStructMemberOffset(Struct, Member) + Address), GetStructMemberType(Struct, Member))); } int Size = GetStructMemberSize(Struct, Member); byte[] Data = new byte[Size]; mem.ReadMemory(Address, Data.Length, out Data); Array ReturnVal = Array.CreateInstance(type, Count); for (int i = 0; i < Count; i++) { ReturnVal.SetValue(ReadWriteMemory.RawDeserialize(Data, i * Size, type), i); } return(ReturnVal); }
public bool WriteStructMember(ORNames Struct, ORNames Member, Object NewValue, uint Address = 0) { if (Address <= 0) { Address = GetStructAddress(Struct); } int Offset = GetStructMemberOffset(Struct, Member); int Size = GetStructMemberSize(Struct, Member); int Count = GetStructMemberCount(Struct, Member); Type type = GetStructMemberType(Struct, Member); if (Count <= 0 && NewValue.GetType() != type) { throw new InvalidCastException("OffsetReader.WriteStructMember: NewValue is not of the expected type. NewValue type: " + NewValue.GetType().ToString() + " Expected type: " + type.ToString()); } if (type == StringType) { int Length = Size; byte[] StringAsBytes = Encoding.UTF8.GetBytes((string)NewValue); byte[] buffer = new byte[Length]; Array.Copy(StringAsBytes, buffer, StringAsBytes.Length < buffer.Length - 1 ? StringAsBytes.Length : buffer.Length - 1); buffer[buffer.Length - 1] = 0; return(mem.WriteMemory((uint)(Offset + Address), buffer.Length, ref buffer)); } if (Count <= 0) { byte[] buffer = ReadWriteMemory.RawSerialize(NewValue); return(mem.WriteMemory((uint)(Offset + Address), buffer.Length, ref buffer)); } else { Array NewArray = (Array)NewValue; byte[] buffer = new byte[Size]; for (int i = 0; i < Count && i < NewArray.Length; i++) { ReadWriteMemory.RawSerialize(NewArray.GetValue(i)).CopyTo(buffer, i * Size / Count); } return(mem.WriteMemory((uint)(Offset + Address), buffer.Length, ref buffer)); } }
public void WriteStructMember(ORNames Struct, ORNames Member, Object NewValue, ref byte[] Data) { int Offset = GetStructMemberOffset(Struct, Member); int Size = GetStructMemberSize(Struct, Member); int Count = GetStructMemberCount(Struct, Member); Type type = GetStructMemberType(Struct, Member); if (Count <= 0 && NewValue.GetType() != type) { throw new InvalidCastException("OffsetReader.WriteStructMember: NewValue is not of the expected type. NewValue type: " + NewValue.GetType().ToString() + " Expected type: " + type.ToString()); } if (type == StringType) { int Length = Size; byte[] StringAsBytes = Encoding.UTF8.GetBytes((string)NewValue); int CopyLength = StringAsBytes.Length < Length - 1 ? StringAsBytes.Length : Length - 1; Array.Copy(StringAsBytes, 0, Data, Offset, CopyLength); Data[Offset + CopyLength] = 0; return; } if (Count <= 0) { byte[] buffer = ReadWriteMemory.RawSerialize(NewValue); buffer.CopyTo(Data, Offset); return; } else { Array NewArray = (Array)NewValue; byte[] buffer = new byte[Size]; for (int i = 0; i < Count && i < NewArray.Length; i++) { ReadWriteMemory.RawSerialize(NewArray.GetValue(i)).CopyTo(buffer, i * Size / Count); } buffer.CopyTo(Data, Offset); return; } }
public void SetMemoryReader(int ID) { this.mem = new ReadWriteMemory(ID); }
public AbilBuildable(uint address, ReadWriteMemory mem) : base(address, mem) { this._mem = mem; }
public AbilQueue(uint address, ReadWriteMemory mem) : base(address, mem) { this._mem = mem; }