Exemple #1
0
        public InstallHandler(BLTEStream blte)
        {
            if (CASContainer.BuildConfig["install-size"][0] != null && blte.Length != long.Parse(CASContainer.BuildConfig["install-size"][0]))
            {
                CASContainer.Settings?.Logger.LogAndThrow(Logging.LogType.Critical, "Install File is corrupt.");
            }

            BinaryReader stream = new BinaryReader(blte);

            Header = new InstallHeader()
            {
                Magic      = stream.ReadBytes(2),
                Version    = stream.ReadByte(),
                HashSize   = stream.ReadByte(),
                NumTags    = stream.ReadUInt16BE(),
                NumEntries = stream.ReadUInt32BE()
            };

            // tags
            int numMaskBytes = (int)(Header.NumEntries + 7) / 8;

            for (int i = 0; i < Header.NumTags; i++)
            {
                InstallTag tag = new InstallTag()
                {
                    Name    = stream.ReadCString(),
                    Type    = stream.ReadUInt16BE(),
                    BitMask = new BoolArray(stream.ReadBytes(numMaskBytes))
                };

                // We need to remove trailing bits from the padded byte array.
                while (tag.BitMask.Count != Header.NumEntries)
                {
                    tag.BitMask.RemoveAt(tag.BitMask.Count - 1);
                }

                Tags.Add(tag);
            }

            // entries
            for (int i = 0; i < Header.NumEntries; i++)
            {
                InstallEntry entry = new InstallEntry()
                {
                    Name  = stream.ReadCString(),
                    CEKey = new MD5Hash(stream),
                    Size  = stream.ReadUInt32BE()
                };

                InstallData.Add(entry);
            }

            EncodingMap = blte.EncodingMap.ToArray();

            stream?.Dispose();
            blte?.Dispose();
        }
Exemple #2
0
 public InstallHandler()
 {
     Header      = new InstallHeader();
     EncodingMap = new[]
     {
         new EncodingMap(EncodingType.ZLib, 9),
         new EncodingMap(EncodingType.None, 6),
     };
 }