Ejemplo n.º 1
0
        internal static List <BinderFileHeader> ReadHeader(IBND3 bnd, BinaryReaderEx br)
        {
            br.AssertASCII("BND3");
            bnd.Version = br.ReadFixStr(8);

            bnd.BitBigEndian = br.GetBoolean(0xE);

            bnd.Format    = Binder.ReadFormat(br, bnd.BitBigEndian);
            bnd.BigEndian = br.ReadBoolean();
            br.AssertBoolean(bnd.BitBigEndian);
            br.AssertByte(0);

            br.BigEndian = bnd.BigEndian || Binder.ForceBigEndian(bnd.Format);

            int fileCount = br.ReadInt32();

            br.ReadInt32(); // End of file headers, not including padding before data
            bnd.Unk18 = br.AssertInt32(0, unchecked ((int)0x80000000));
            br.AssertInt32(0);

            var fileHeaders = new List <BinderFileHeader>(fileCount);

            for (int i = 0; i < fileCount; i++)
            {
                fileHeaders.Add(BinderFileHeader.ReadBinder3FileHeader(br, bnd.Format, bnd.BitBigEndian));
            }

            return(fileHeaders);
        }
Ejemplo n.º 2
0
        internal static List <BinderFileHeader> ReadBHFHeader(IBXF3 bxf, BinaryReaderEx br)
        {
            br.AssertASCII("BHF3");
            bxf.Version = br.ReadFixStr(8);

            bxf.BitBigEndian = br.GetBoolean(0xE);

            bxf.Format    = Binder.ReadFormat(br, bxf.BitBigEndian);
            bxf.BigEndian = br.ReadBoolean();
            br.AssertBoolean(bxf.BitBigEndian);
            br.AssertByte(0);

            br.BigEndian = bxf.BigEndian || Binder.ForceBigEndian(bxf.Format);

            int fileCount = br.ReadInt32();

            br.AssertInt32(0);
            br.AssertInt32(0);
            br.AssertInt32(0);

            var fileHeaders = new List <BinderFileHeader>(fileCount);

            for (int i = 0; i < fileCount; i++)
            {
                fileHeaders.Add(BinderFileHeader.ReadBinder3FileHeader(br, bxf.Format, bxf.BitBigEndian));
            }

            return(fileHeaders);
        }
Ejemplo n.º 3
0
        internal static List <BinderFileHeader> ReadBHFHeader(IBXF4 bxf, BinaryReaderEx br)
        {
            br.AssertASCII("BHF4");

            bxf.Unk04 = br.ReadBoolean();
            bxf.Unk05 = br.ReadBoolean();
            br.AssertByte(0);
            br.AssertByte(0);

            br.AssertByte(0);
            bxf.BigEndian    = br.ReadBoolean();
            bxf.BitBigEndian = !br.ReadBoolean();
            br.AssertByte(0);

            br.BigEndian = bxf.BigEndian;

            int fileCount = br.ReadInt32();

            br.AssertInt64(0x40); // Header size
            bxf.Version = br.ReadFixStr(8);
            long fileHeaderSize = br.ReadInt64();

            br.AssertInt64(0);

            bxf.Unicode  = br.ReadBoolean();
            bxf.Format   = Binder.ReadFormat(br, bxf.BitBigEndian);
            bxf.Extended = br.AssertByte(0, 4);
            br.AssertByte(0);

            if (fileHeaderSize != Binder.GetBND4FileHeaderSize(bxf.Format))
            {
                throw new FormatException($"File header size for format {bxf.Format} is expected to be 0x{Binder.GetBND4FileHeaderSize(bxf.Format):X}, but was 0x{fileHeaderSize:X}");
            }

            br.AssertInt32(0);

            if (bxf.Extended == 4)
            {
                long hashGroupsOffset = br.ReadInt64();
                br.StepIn(hashGroupsOffset);
                BinderHashTable.Assert(br);
                br.StepOut();
            }
            else
            {
                br.AssertInt64(0);
            }

            var fileHeaders = new List <BinderFileHeader>(fileCount);

            for (int i = 0; i < fileCount; i++)
            {
                fileHeaders.Add(BinderFileHeader.ReadBinder4FileHeader(br, bxf.Format, bxf.BitBigEndian, bxf.Unicode));
            }

            return(fileHeaders);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads file data according to the given header.
        /// </summary>
        public byte[] ReadFile(BinderFileHeader fileHeader)
        {
            BinderFile file = fileHeader.ReadFileData(DataBR);

            return(file.Bytes);
        }