コード例 #1
0
        private MetaAddressConverter LoadAddressConverter(StructureValueCollection values)
        {
            VirtualBaseAddress = values.GetNumber("virtual base address");

            if (values.HasNumber("raw table offset") && values.HasNumber("raw table size"))
            {
                // Load raw table info
                RawTableSize = values.GetNumber("raw table size");
                RawTableOffset = values.GetNumber("raw table offset");
                _originalRawTableOffset = RawTableOffset;

                // There are two ways to get the meta offset:
                // 1. Raw table offset + raw table size
                // 2. If raw table offset is zero, then the meta offset is directly stored in the header
                //    (The raw table offset can still be calculated in this case, but can't be used to find the meta the traditional way)
                if (RawTableOffset != 0)
                    MetaOffset = RawTableOffset + RawTableSize;
                else
                    RawTableOffset = values.GetNumber("raw table offset from header") + (uint)HeaderSize;
            }

            uint temp = MetaOffset;
            if (MetaOffset == 0 && !values.FindNumber("meta offset", out temp))
            {
                throw new ArgumentException("The XML layout file is missing information on how to calculate map magic.");
            }
            MetaOffset = temp;

            return new MetaAddressConverter(this);
        }