Beispiel #1
0
        public static CaffHeader[] GenerateCaffHeaders(BinaryReader br, PkgHeader[] pkgHeader, uint count)
        {
            CaffHeader[] headers = new CaffHeader[count];

            for (int i = 0; i < count; i++)
            {
                headers[i] = new CaffHeader();

                br.BaseStream.Seek(pkgHeader[i].caffOffset, SeekOrigin.Begin);

                headers[i].magic   = br.ReadBytes(4);
                headers[i].version = br.ReadBytes(13).ToString();
                br.ReadBytes(3);
                headers[i].stream0Offset    = br.ReadUInt32();
                headers[i].unk0             = br.ReadBytes(4);
                headers[i].chunkCount       = br.ReadUInt32();
                headers[i].chunkSpreadCount = br.ReadUInt32();
                headers[i].unk1             = br.ReadBytes(44);
                headers[i].stream0UncSize   = br.ReadUInt32();
                headers[i].unk2             = br.ReadBytes(12);
                headers[i].stream0CSize     = br.ReadUInt32();
                headers[i].stream1UncSize   = br.ReadUInt32();
                headers[i].unk2             = br.ReadBytes(12);
                headers[i].stream1CSize     = br.ReadUInt32();
            }
            return(headers);
        }
Beispiel #2
0
        public void UpdateInfo(PkgHeader pkgHeader, CaffHeader caffHeader, int index)
        {
            CaffName.Text = $"Caff {index}";

            CaffSize.Text   = $"Size(bytes): {pkgHeader.caffSize}";
            CaffOffset.Text = $"Offset(h): {pkgHeader.caffOffset}";

            DataChunkCount.Text = $".DATA chunk count: {caffHeader.chunkCount}";
            GpuChunkCount.Text  = $".GPU chunk count: {caffHeader.chunkSpreadCount - caffHeader.chunkCount}";

            Stream0Offset.Text = $"0 offset(h): {caffHeader.stream0Offset}";
            Stream0Size.Text   = $"0 size(bytes) - Compressed: {caffHeader.stream0CSize} -> Uncompressed: {caffHeader.stream0UncSize}";

            Stream1Offset.Text = $"1 offset(h): {caffHeader.stream0Offset + caffHeader.stream0CSize + pkgHeader.caffOffset}";
            Stream1Size.Text   = $"1 size(bytes) - Compressed: {caffHeader.stream1CSize} -> Uncompressed: {caffHeader.stream1UncSize}";

            Stream2Size.Text = $"2 size(bytes) - Compressed: {caffHeader.stream2CSize} -> Uncompressed: {caffHeader.stream2UncSize}";

            Stream3Size.Text = $"3 size(bytes) - Compressed: {caffHeader.stream3CSize} -> Uncompressed: {caffHeader.stream3UncSize}";
        }
Beispiel #3
0
        public Caff(BinaryReader br, CaffHeader header, uint caffOffset, int index)
        {
            m_header = header;
            m_index  = index;
            br.BaseStream.Seek(m_header.stream0Offset + caffOffset, SeekOrigin.Begin);

            streams[0] = new MemoryStream();

            if (m_header.stream0CSize != m_header.stream0UncSize)
            {
                MemoryStream tempStream = new MemoryStream();
                Globals.CopyStream(br.BaseStream, tempStream, (int)m_header.stream0CSize);

                tempStream.Seek(2, SeekOrigin.Begin);
                using (DeflateStream deflateStream = new DeflateStream(tempStream, CompressionMode.Decompress))
                {
                    deflateStream.CopyTo(streams[0]);
                    deflateStream.Dispose();
                }
            }

            GetChunkStrings();
        }