Exemple #1
0
 protected virtual void RefreshDynamic()
 {
     if (Pool == null || Pool.Value == null)
     {
         return;
     }
     _Value = MemoryDataConverter.Read <T>(Pool.Value, Offset);
 }
Exemple #2
0
 public TOut ReadAs <TOut>(string field)
 {
     if (Fields.ContainsKey(field))
     {
         return(Fields[field].ReadAs <TOut>());
     }
     else
     {
         return(MemoryDataConverter.Read <TOut>(new byte[32], 0));
     }
 }
Exemple #3
0
        private void ScanRegion <T>(MemoryRegion region, IEnumerable <MemorySignatureScanObject> signature, Action <T, int> addAction)
        {
            if (region.Data.Length == 0)
            {
                return;
            }

            byte startByte       = signature.FirstOrDefault().data;
            var  signatureLength = signature.Count();

            var address = (uint)Array.IndexOf(region.Data, startByte, 0);

            var signatureCheckIndex = 0;
            var targetIndex         = 0;
            var target      = new byte[32];
            var matchFailed = false;

            while (address < region.Data.Length - signatureLength)
            {
                foreach (var sigByte in signature)
                {
                    if (sigByte.wildcard)
                    {
                        signatureCheckIndex++;
                        continue;
                    }
                    var by = region.Data[address + signatureCheckIndex];

                    if (sigByte.target)
                    {
                        target[targetIndex++] = by;
                    }
                    else if (sigByte.data != by)
                    {
                        matchFailed = true;
                        break;
                    }

                    signatureCheckIndex++;
                }
                if (!matchFailed)
                {
                    addAction(MemoryDataConverter.Read <T>(target, 0), (int)address);
                    //Debug.WriteLine("0x{0} -> 0x{2:X} [ 0x{1:X} ] ",string.Format("{0:X}", address), BitConverter.ToString(target), address);

                    target = new byte[32];
                }
                signatureCheckIndex = 0;
                targetIndex         = 0;
                matchFailed         = false;

                address = (uint)Array.IndexOf(region.Data, startByte, (int)address + 1);
            }
        }
Exemple #4
0
        public byte[] ReadBytes(string field)
        {
            var oField = this.Fields[field];

            if (oField.HasChanged())
            {
                return(MemoryDataConverter.Rawify(oField.Read));
            }
            else
            {
                return(new byte[0]);
            }
        }
Exemple #5
0
        protected virtual void RefreshStatic()
        {
            if (Memory == null)
            {
                return;
            }

            var computedAddress = 0;

            if (Address != 0 && Offset != 0)
            {
                computedAddress = Memory.Reader.ReadInt32(Memory.BaseAddress + Address) + Offset;
            }
            else
            {
                computedAddress = AddressType == MemoryAddress.Static ? Memory.BaseAddress + Address : Address;
            }

            var data = Memory.Reader.ReadBytes(computedAddress, (uint)Size);

            _Value = MemoryDataConverter.Read <T>(data, 0);
        }
Exemple #6
0
 public TOut ReadAs <TOut>()
 {
     return(MemoryDataConverter.Cast <T, TOut>(ValidationFunc(Pool)));
 }
Exemple #7
0
 public TOut ReadAs <TOut>(int offset)
 {
     return(MemoryDataConverter.Read <TOut>(Value, offset));
 }
Exemple #8
0
 public TOut ReadAs <TOut>()
 {
     return(MemoryDataConverter.Read <TOut>(new byte[32], 0));
 }
Exemple #9
0
        public void Refresh()
        {
            if (IsTemplate)
            {
                return;
            }

            var computedAddress = 0;

            if (IsSignature && Offset == 0 && Address == 0 && Memory.Scanner.Enabled)
            {
                var result = Memory.Scanner.Scan <uint>(MemoryRegionType.EXECUTE, Signature);

                // Search the address and offset.
                switch (AddressType)
                {
                case MemoryAddress.StaticAbsolute:
                case MemoryAddress.Static:
                    if (result == 0)
                    {
                        return;
                    }

                    if (Pointers.Count() == 0)
                    {
                        // The result is directly our address
                        Address = (int)result;
                    }
                    else
                    {
                        // We must follow one pointer.
                        if (AddressType == MemoryAddress.Static)
                        {
                            computedAddress = Memory.BaseAddress + (int)result;
                        }
                        else
                        {
                            computedAddress = (int)result;
                        }

                        Address = computedAddress;
                    }
                    break;

                case MemoryAddress.Dynamic:
                    Offset = (int)result;
                    break;

                default:
                    throw new Exception("AddressType for '" + Name + "' is not valid");
                    break;
                }
            }

            // Refresh pointers too
            foreach (var ptr in Pointers)
            {
                ptr.Refresh(Memory);
            }

            // Refresh this memory block.
            if (Size > 0)
            {
                AddressTree = new int[1 + Pointers.Count()];
                if (IsStatic)
                {
                    if (Address != 0 && Offset != 0)
                    {
                        computedAddress = Memory.Reader.ReadInt32(Memory.BaseAddress + Address) + Offset;
                    }
                    else
                    {
                        computedAddress = AddressType == MemoryAddress.Static
                                              ? Memory.BaseAddress + Address
                                              : Address;
                    }
                }
                else
                {
                    computedAddress = Pool == null ? 0 : MemoryDataConverter.Read <int>(Pool.Value, Offset);
                }
                int treeInd = 0;
                foreach (var ptr in Pointers)
                {
                    AddressTree[treeInd++] = computedAddress;
                    if (ptr.Additive)
                    {
                        computedAddress += ptr.Offset;
                    }
                    else
                    {
                        computedAddress = Memory.Reader.ReadInt32(computedAddress + ptr.Offset);
                    }
                }
                AddressTree[treeInd] = computedAddress;

                // Read into this buffer.
                Memory.Reader.Read(computedAddress, Value);
            }

            // Refresh underlying fields.
            foreach (var field in Fields)
            {
                field.Value.Refresh();
            }

            foreach (var pool in Pools.Values)
            {
                pool.Refresh();
            }
        }
Exemple #10
0
 public TOut ReadAs <TOut>()
 {
     return(MemoryDataConverter.Cast <T, TOut>(StaticValue));
 }
Exemple #11
0
 public virtual TOut ReadAs <TOut>()
 {
     return(MemoryDataConverter.Cast <T, TOut>(Value));
 }