Esempio n. 1
0
        /// <summary>
        ///     Serializes the header's values, storing them into a StructureValueCollection.
        /// </summary>
        /// <param name="localeArea">The locale area of the cache file. Can be null.</param>
        /// <param name="localePointerMask">The value to add to locale pointers to translate them to file offsets.</param>
        /// <returns>The resulting StructureValueCollection.</returns>
        public StructureValueCollection Serialize(FileSegmentGroup localeArea)
        {
            var values = new StructureValueCollection();

            values.SetInteger("file size", (ulong)FileSize);
            values.SetInteger("type", (uint)Type);
            values.SetString("internal name", InternalName);
            values.SetString("scenario name", ScenarioName);
            values.SetInteger("xdk version", (uint)XDKVersion);

            AdjustPartitions();
            values.SetArray("partitions", SerializePartitions());

            RebuildInteropData(localeArea);

            values.SetArray("offset masks", SectionOffsetMasks.Select(m =>
            {
                var result = new StructureValueCollection();
                result.SetInteger("mask", m);
                return(result);
            }).ToArray());

            values.SetArray("sections", Sections.Select(s => s.Serialize()).ToArray());
            values.SetInteger("tag buffer offset", Sections[(int)ThirdGenInteropSectionType.Tag].VirtualAddress);

            if (MetaArea != null)
            {
                values.SetInteger("virtual base address", (ulong)MetaArea.BasePointer);
                values.SetInteger("index header address", (ulong)IndexHeaderLocation.AsPointer());
                values.SetInteger("virtual size", (uint)MetaArea.Size);
            }

            if (StringBlockLocation != null)
            {
                values.SetInteger("string block offset", (ulong)StringBlockLocation.AsPointer());
            }

            values.SetInteger("string table count", (uint)StringIDCount);
            if (StringIDData != null)
            {
                values.SetInteger("string table size", (uint)StringIDData.Size);
                values.SetInteger("string table offset", (ulong)StringIDDataLocation.AsPointer());
            }

            if (StringIDNamespaceTable != null)
            {
                values.SetInteger("string namespace table count", (uint)StringIDNamespaceCount);
                values.SetInteger("string namespace table offset", (uint)StringIDNamespaceTableLocation.AsPointer());
            }

            if (StringIDIndexTableLocation != null)
            {
                values.SetInteger("string index table offset", (ulong)StringIDIndexTableLocation.AsPointer());
            }

            if (StringArea != null)
            {
                values.SetInteger("string data size", (uint)StringArea.Size);
            }

            values.SetInteger("file table count", (uint)FileNameCount);
            if (FileNameData != null)
            {
                values.SetInteger("file table offset", (ulong)FileNameDataLocation.AsPointer());
                values.SetInteger("file table size", (uint)FileNameData.Size);
            }

            if (FileNameIndexTableLocation != null)
            {
                values.SetInteger("file index table offset", (ulong)FileNameIndexTableLocation.AsPointer());
            }

            if (localeArea != null)
            {
                values.SetInteger("locale data index offset", (uint)localeArea.BasePointer);
                values.SetInteger("locale data size", (uint)localeArea.Size);
            }

            if (UnknownTableLocation != null)
            {
                values.SetInteger("unknown table count", (uint)UnknownCount);
                values.SetInteger("unknown table offset", (ulong)UnknownTableLocation.AsPointer());
            }

            values.SetInteger("checksum", Checksum);
            return(values);
        }
Esempio n. 2
0
        /// <summary>
        ///     Serializes the header's values, storing them into a StructureValueCollection.
        /// </summary>
        /// <param name="localeArea">The locale area of the cache file. Can be null.</param>
        /// <param name="localePointerMask">The value to add to locale pointers to translate them to file offsets.</param>
        /// <returns>The resulting StructureValueCollection.</returns>
        public StructureValueCollection Serialize(FileSegmentGroup localeArea)
        {
            var values = new StructureValueCollection();

            values.SetInteger("file size", FileSize);
            values.SetInteger("type", (uint)Type);
            values.SetString("internal name", InternalName);
            values.SetString("scenario path", ScenarioPath);
            //values.SetInteger("xdk version", (uint) XDKVersion);

            //AdjustPartitions();
            //values.SetArray("partitions", SerializePartitions());

            //RebuildInteropData(localeArea);

            /*
             *          values.SetArray("offset masks", SectionOffsetMasks.Select(m =>
             *          {
             *                  var result = new StructureValueCollection();
             *                  result.SetInteger("mask", m);
             *                  return result;
             *          }).ToArray());
             *
             *          values.SetArray("sections", Sections.Select(s => s.Serialize()).ToArray());
             *          values.SetInteger("tag buffer offset", Sections[(int) FourthGenInteropSectionType.Tag].VirtualAddress);
             */
            /*
             *          if (MetaArea != null)
             *          {
             *                  values.SetInteger("virtual base address", MetaArea.BasePointer);
             *                  values.SetInteger("index header address", IndexHeaderLocation.AsPointer());
             *                  values.SetInteger("virtual size", (uint) MetaArea.Size);
             *          }
             */

            if (StringBlockLocation != null)
            {
                values.SetInteger("string block offset", StringBlockLocation.AsPointer());
            }

            values.SetInteger("string table count", (uint)StringIDCount);
            if (StringIDData != null)
            {
                values.SetInteger("string table size", (uint)StringIDData.Size);
                values.SetInteger("string table offset", StringIDDataLocation.AsPointer());
            }

            if (StringIDIndexTableLocation != null)
            {
                values.SetInteger("string index table offset", StringIDIndexTableLocation.AsPointer());
            }

            if (StringArea != null)
            {
                values.SetInteger("string data size", (uint)StringArea.Size);
            }

            /*
             *          values.SetInteger("file table count", (uint) FileNameCount);
             *          if (FileNameData != null)
             *          {
             *                  values.SetInteger("file table offset", FileNameDataLocation.AsPointer());
             *                  values.SetInteger("file table size", (uint) FileNameData.Size);
             *          }
             *
             *          if (FileNameIndexTableLocation != null)
             *                  values.SetInteger("file index table offset", FileNameIndexTableLocation.AsPointer());
             */

            if (localeArea != null)
            {
                values.SetInteger("locale data index offset", localeArea.BasePointer);
                values.SetInteger("locale data size", (uint)localeArea.Size);
            }

            /*
             *          if (UnknownTableLocation != null)
             *          {
             *                  values.SetInteger("unknown table count", (uint) UnknownCount);
             *                  values.SetInteger("unknown table offset", UnknownTableLocation.AsPointer());
             *          }
             * */

            return(values);
        }