Пример #1
0
        private void EstimateMapSize(MetaMap map, uint mapAddress, MemoryMap memMap, int entryCount)
        {
            bool alreadyVisited = map.HasSizeEstimates;

            int newSize = memMap.EstimateBlockSize(mapAddress);
            map.EstimateSize(newSize / entryCount);
            map.Truncate(newSize);

            if (!alreadyVisited)
            {
                foreach (MetaValueGuess guess in map.Guesses)
                {
                    if (guess.Type == MetaValueType.Reflexive)
                    {
                        MetaMap subMap = map.GetSubMap(guess.Offset);
                        if (subMap != null)
                            EstimateMapSize(subMap, guess.Pointer, memMap, (int)guess.Data1);
                    }
                }
            }
        }
Пример #2
0
 private void FoldSubMaps(MetaMap map)
 {
     foreach (MetaValueGuess guess in map.Guesses)
     {
         if (guess.Type == MetaValueType.Reflexive)
         {
             MetaMap subMap = map.GetSubMap(guess.Offset);
             if (subMap != null)
             {
                 int entryCount = (int)guess.Data1;
                 int firstBlockSize = subMap.GetBestSizeEstimate();
                 //if (firstBlockSize > 0 && !subMap.IsFolded(firstBlockSize))
                 //{
                     subMap.Fold(firstBlockSize);
                     FoldSubMaps(subMap);
                 //}
             }
         }
     }
 }
Пример #3
0
        private void WritePlugin(MetaMap map, int size, AssemblyPluginWriter writer)
        {
            for (int offset = 0; offset < size; offset += 4)
            {
                MetaValueGuess guess = map.GetGuess(offset);
                if (guess != null)
                {
                    switch (guess.Type)
                    {
                        case MetaValueType.DataReference:
                            if (offset <= size - 0x14)
                            {
                                writer.VisitDataReference("Unknown", (uint)offset, false, 0);
                                offset += 0x10;
                                continue;
                            }
                            break;

                        case MetaValueType.TagReference:
                            if (offset <= size - 0x10)
                            {
                                writer.VisitTagReference("Unknown", (uint)offset, false, true, true, 0);
                                offset += 0xC;
                                continue;
                            }
                            break;

                        case MetaValueType.Reflexive:
                            if (offset <= size - 0xC)
                            {
                                MetaMap subMap = map.GetSubMap(offset);
                                if (subMap != null)
                                {
                                    int subMapSize = subMap.GetBestSizeEstimate();
                                    writer.EnterReflexive("Unknown", (uint)offset, false, (uint)subMapSize, 0);
                                    WritePlugin(subMap, subMapSize, writer);
                                    writer.LeaveReflexive();
                                    offset += 0x8;
                                    continue;
                                }
                            }
                            break;
                    }
                }

                // Just write an unknown value depending upon how much space we have left
                if (offset <= size - 4)
                    writer.VisitUndefined("Unknown", (uint)offset, false, 0);
                else if (offset <= size - 2)
                    writer.VisitInt16("Unknown", (uint)offset, false, 0);
                else
                    writer.VisitInt8("Unknown", (uint)offset, false, 0);
            }
        }
Пример #4
0
        public void MergeWith(MetaMap other)
        {
            if (other == this || _ancestors.Contains(other) || other._ancestors.Contains(this))
                return;

            foreach (MetaValueGuess guess in other._guesses.Values)
            {
                MetaMap otherMap = other.GetSubMap(guess.Offset);
                MetaMap myMap = GetSubMap(guess.Offset);
                if (otherMap != null || myMap == null)
                {
                    if (AddGuess(guess))
                        AssociateSubMap(guess.Offset, otherMap);
                }
            }

            foreach (KeyValuePair<int, int> estimate in other._sizeEstimates)
                EstimateSize(estimate.Key, estimate.Value);
        }