Exemplo n.º 1
0
        private static void Read(PexFile file, IBinaryReadStream br)
        {
            var magic = br.ReadUInt32();

            if (magic != PexMagic)
            {
                throw new InvalidDataException($"File does not have fast code! Magic does not match {PexMagic:x8} is {magic:x8}");
            }

            file.MajorVersion    = br.ReadUInt8();
            file.MinorVersion    = br.ReadUInt8();
            file.GameId          = br.ReadUInt16();
            file.CompilationTime = br.ReadUInt64().ToDateTime();
            file.SourceFileName  = br.ReadPrependedString(2);
            file.Username        = br.ReadPrependedString(2);
            file.MachineName     = br.ReadPrependedString(2);

            var stringsCount = br.ReadUInt16();

            var bundle = new PexParseMeta(
                file._gameCategory,
                br,
                new Dictionary <ushort, string>());

            for (var i = 0; i < stringsCount; i++)
            {
                bundle.Strings.Add((ushort)i, br.ReadPrependedString(2));
            }

            var hasDebugInfo = bundle.Reader.ReadUInt8() == 1;

            if (hasDebugInfo)
            {
                file.DebugInfo = Mutagen.Bethesda.Pex.DebugInfo.Create(bundle);
            }

            var userFlagCount = br.ReadUInt16();

            for (var i = 0; i < userFlagCount; i++)
            {
                var str = bundle.ReadString();
                file.UserFlags[br.ReadUInt8()] = str;
            }

            var objectCount = br.ReadUInt16();

            for (var i = 0; i < objectCount; i++)
            {
                var pexObject = PexObject.Create(bundle);
                file.Objects.Add(pexObject);
            }
        }