Esempio n. 1
0
        public void FixStructureChilds(StructureOffset initialStructure)
        {
            initialStructure.StructureBytes = _memory.ReadBytes(initialStructure.BaseAddress, initialStructure.MaxStructSize);

            foreach (var structureOffsetChild in initialStructure.Child)
            {
                var searchParams = new OffsetSearchParams(initialStructure.StructureBytes, initialStructure.BaseAddress);
                structureOffsetChild.FoundOffsets = structureOffsetChild.OffsetSearch.SearchOffsets(searchParams, _memory);
                structureOffsetChild.UsedOffset   = structureOffsetChild.OffsetIsFound ? structureOffsetChild.FoundOffsets[0] : -1;

                var offsetsCount = structureOffsetChild.FoundOffsets.Count;

                if (offsetsCount == 0)
                {
                    structureOffsetChild.SearchStatus = OffsetSearchStatus.NotFound;
                }
                else if (offsetsCount == 1)
                {
                    structureOffsetChild.SearchStatus = OffsetSearchStatus.FoundSingle;
                }
                else if (offsetsCount > 1)
                {
                    structureOffsetChild.SearchStatus = OffsetSearchStatus.FoundMultiple;
                }

                if (structureOffsetChild is StructureOffset structureOffset)
                {
                    if (structureOffset.ShouldProcess() && structureOffsetChild.FoundOffsets.Count == 1)
                    {
                        structureOffset.BaseAddress = _memory.ReadLong(initialStructure.BaseAddress + structureOffsetChild.UsedOffset);
                        FixStructureChilds(structureOffset);
                        structureOffset.OnOffsetsFound();
                    }
                    else
                    {
                        structureOffset.FoundOffsets.Clear();
                        structureOffset.BaseAddress     = -1;
                        structureOffsetChild.UsedOffset = -1;
                    }
                }
            }
        }
 public static void AddUShortSearch(this StructureOffset structOffset, string offsetName, ushort value, bool firstFound = false)
 {
     structOffset.Child.Add(new DataOffset(offsetName,
                                           new ValueReaderStrategy(new UShortValueReader(new DefaultValueCompare <ushort>(value)), sizeof(ushort), firstFound: firstFound)));
 }
 public static void AddFloatSearch(this StructureOffset structOffset, string offsetName, float value, float tolerance, bool firstFound = false)
 {
     structOffset.Child.Add(new DataOffset(offsetName,
                                           new ValueReaderStrategy(new FloatValueReader(new FloatValueCompare(value, tolerance)), sizeof(int), firstFound: firstFound)));
 }
 public static void AddByteSearch(this StructureOffset structOffset, string offsetName, byte value, bool firstFound = false, int alignment = 1)
 {
     structOffset.Child.Add(new DataOffset(offsetName,
                                           new ValueReaderStrategy(new ByteValueReader(new DefaultValueCompare <byte>(value)), alignment, firstFound: firstFound)));
 }
 public static void AddStringSearch(this StructureOffset structOffset, string offsetName, string value, bool firstFound = false)
 {
     structOffset.Child.Add(new DataOffset(offsetName,
                                           new PointersSearchStrategy(new StringValueReader(new DefaultValueCompare <string>(value)), checkVmt: false, firstFound: firstFound)));
 }