Ejemplo n.º 1
0
        public void ResizeSection(CacheFileSectionType type, int requestedAdditionalSpace)
        {
            var sectionTable = BaseMapFile.Header.SectionTable;
            var section      = sectionTable.Sections[(int)type];

            var sectionFileOffset = sectionTable.GetSectionOffset(type);
            var sectionSize       = section.Size;
            var shiftAmount       = (requestedAdditionalSpace + SectionAlign - 1) & ~(SectionAlign - 1);
            var sectionNewSize    = sectionSize + shiftAmount;


            //
            // Need to update all references to the section in the header and the section table. If it's a tag section, need to update the partitions.
            // if it's a locale, need to update matg, if it's a resource, need to update play, if it's a string, need to update the string offsets
            // once all the updating is done, fix sections

            section.Size = sectionNewSize;

            for (int i = (int)type + 1; i < (int)CacheFileSectionType.Count; i++)
            {
                sectionTable.SectionAddressToOffsets[i] += shiftAmount;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the offset of the specified address in the section.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="address"></param>
 /// <returns></returns>
 public uint GetOffset(CacheFileSectionType type, uint address)
 {
     return((uint)(address + SectionAddressToOffsets[(int)type]));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Get the section's file offset given the type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public uint GetSectionOffset(CacheFileSectionType type)
 {
     return((uint)(Sections[(int)type].Offset + SectionAddressToOffsets[(int)type]));
 }