From d73c3cc8b231759a5f13c0c7bbe7327e18514594 Mon Sep 17 00:00:00 2001 From: Benjamin Moir Date: Tue, 27 Feb 2024 22:16:53 +1000 Subject: [PATCH] Preliminary Xillia 2 support --- tools/TLTool/DataHeader.InternalHeaderEntry.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/TLTool/DataHeader.InternalHeaderEntry.cs b/tools/TLTool/DataHeader.InternalHeaderEntry.cs index ed976d2..41c8ed4 100644 --- a/tools/TLTool/DataHeader.InternalHeaderEntry.cs +++ b/tools/TLTool/DataHeader.InternalHeaderEntry.cs @@ -1,4 +1,5 @@ using System.Text; +using System.Buffers; using System.IO.Compression; using LzmaDecoder = SevenZip.Compression.LZMA.Decoder; @@ -62,12 +63,22 @@ public Stream OpenRead() var blockSizes = new ushort[blockCount]; var remaining = uncompressedSize; decoder.SetDecoderProperties(reader.ReadBytes(5)); - + for (int i = 0; i < blockSizes.Length; i++) blockSizes[i] = reader.ReadUInt16(); for (int i = 0; i < blockSizes.Length; i++) { + if (blockSizes[i] == 0) + { + // If the block size is zero, then the rest of the file is uncompressed. + var buffer = ArrayPool.Shared.Rent((int)remaining); + stream.ReadExactly(buffer, 0, (int)remaining); + decoded.Write(buffer, 0, (int)remaining); + ArrayPool.Shared.Return(buffer); + break; + } + decoder.Code(stream, decoded, blockSizes[i], uint.Min(remaining, 0x10000), null); remaining -= 0x10000; }