mirror of
https://github.com/4sval/FModel.git
synced 2026-06-21 07:20:05 -05:00
IoStoreToc PartitionSize fix
This commit is contained in:
parent
dfa291e293
commit
c060047d31
|
|
@ -57,6 +57,7 @@ namespace FModel.PakReader.IO
|
|||
CaseSensitive = caseSensitive;
|
||||
ContainerFile.FileHandle = containerStream;
|
||||
var tocResource = new FIoStoreTocResource(tocStream, tocReadOptions);
|
||||
tocStream.Dispose();
|
||||
TocResource = tocResource;
|
||||
|
||||
var containerUncompressedSize = tocResource.Header.TocCompressedBlockEntryCount > 0
|
||||
|
|
|
|||
|
|
@ -4,40 +4,42 @@ using FModel.PakReader.Parsers.Objects;
|
|||
|
||||
namespace FModel.PakReader.IO
|
||||
{
|
||||
public enum EIoStoreTocVersion : byte
|
||||
public enum EIoStoreTocVersion
|
||||
{
|
||||
Invalid = 0,
|
||||
Initial,
|
||||
DirectoryIndex,
|
||||
PartitionSize,
|
||||
LatestPlusOne,
|
||||
Latest = LatestPlusOne - 1
|
||||
}
|
||||
|
||||
public class FIoStoreTocHeader
|
||||
{
|
||||
public const int SIZE = 144;
|
||||
public static byte[] TOC_MAGIC = new byte[]
|
||||
{0x2D, 0x3D, 0x3D, 0x2D, 0x2D, 0x3D, 0x3D, 0x2D, 0x2D, 0x3D, 0x3D, 0x2D, 0x2D, 0x3D, 0x3D, 0x2D};
|
||||
|
||||
public byte[] TocMagic;
|
||||
public EIoStoreTocVersion Version;
|
||||
public uint TocHeaderSize;
|
||||
public uint TocEntryCount;
|
||||
public uint TocCompressedBlockEntryCount;
|
||||
public uint TocCompressedBlockEntrySize; // For sanity checking
|
||||
public uint CompressionMethodNameCount;
|
||||
public uint CompressionMethodNameLength;
|
||||
public uint CompressionBlockSize;
|
||||
public long DirectoryIndexSize;
|
||||
public FIoContainerId ContainerId;
|
||||
public FGuid EncryptionKeyGuid;
|
||||
public EIoContainerFlags ContainerFlags;
|
||||
public readonly struct FIoStoreTocHeader
|
||||
{
|
||||
public static byte[] TOC_MAGIC = { 0x2D, 0x3D, 0x3D, 0x2D, 0x2D, 0x3D, 0x3D, 0x2D, 0x2D, 0x3D, 0x3D, 0x2D, 0x2D, 0x3D, 0x3D, 0x2D };
|
||||
|
||||
public readonly byte[] TocMagic;
|
||||
public readonly EIoStoreTocVersion Version;
|
||||
public readonly uint TocHeaderSize;
|
||||
public readonly uint TocEntryCount;
|
||||
public readonly uint TocCompressedBlockEntryCount;
|
||||
public readonly uint TocCompressedBlockEntrySize; // For sanity checking
|
||||
public readonly uint CompressionMethodNameCount;
|
||||
public readonly uint CompressionMethodNameLength;
|
||||
public readonly uint CompressionBlockSize;
|
||||
public readonly uint DirectoryIndexSize;
|
||||
public readonly uint PartitionCount;
|
||||
public readonly FIoContainerId ContainerId;
|
||||
public readonly FGuid EncryptionKeyGuid;
|
||||
public readonly EIoContainerFlags ContainerFlags;
|
||||
|
||||
public FIoStoreTocHeader(BinaryReader reader)
|
||||
{
|
||||
TocMagic = reader.ReadBytes(16);
|
||||
|
||||
if (!TOC_MAGIC.SequenceEqual(TocMagic))
|
||||
throw new FileLoadException("Invalid utoc magic");
|
||||
|
||||
Version = (EIoStoreTocVersion) reader.ReadInt32();
|
||||
TocHeaderSize = reader.ReadUInt32();
|
||||
TocEntryCount = reader.ReadUInt32();
|
||||
|
|
@ -46,11 +48,12 @@ namespace FModel.PakReader.IO
|
|||
CompressionMethodNameCount = reader.ReadUInt32();
|
||||
CompressionMethodNameLength = reader.ReadUInt32();
|
||||
CompressionBlockSize = reader.ReadUInt32();
|
||||
DirectoryIndexSize = reader.ReadInt64();
|
||||
DirectoryIndexSize = reader.ReadUInt32();
|
||||
PartitionCount = reader.ReadUInt32();
|
||||
ContainerId = new FIoContainerId(reader);
|
||||
EncryptionKeyGuid = new FGuid(reader);
|
||||
ContainerFlags = (EIoContainerFlags) reader.ReadInt32();
|
||||
reader.BaseStream.Position += 60; // Padding
|
||||
//reader.BaseStream.Position += 60; // Padding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,11 +8,11 @@ namespace FModel.PakReader.IO
|
|||
public enum EIoStoreTocReadOptions
|
||||
{
|
||||
Default,
|
||||
ReadDirectoryIndex = (1 << 0),
|
||||
ReadTocMeta = (1 << 1),
|
||||
ReadAll = ReadDirectoryIndex | ReadTocMeta
|
||||
}
|
||||
|
||||
ReadDirectoryIndex = 1 << 0,
|
||||
ReadTocMeta = 1 << 1,
|
||||
ReadAll = ReadDirectoryIndex | ReadTocMeta
|
||||
}
|
||||
|
||||
public class FIoStoreTocResource
|
||||
{
|
||||
public readonly FIoStoreTocHeader Header;
|
||||
|
|
@ -30,8 +30,9 @@ namespace FModel.PakReader.IO
|
|||
tocStream.Read(streamBuffer, 0, streamBuffer.Length);
|
||||
using var reader = new BinaryReader(new MemoryStream(streamBuffer));
|
||||
Header = new FIoStoreTocHeader(reader);
|
||||
reader.BaseStream.Position = Header.TocHeaderSize;
|
||||
|
||||
var totalTocSize = tocStream.Length - FIoStoreTocHeader.SIZE;
|
||||
var totalTocSize = tocStream.Length - Header.TocHeaderSize;
|
||||
var tocMetaSize = Header.TocEntryCount * FIoStoreTocEntryMeta.SIZE;
|
||||
var defaultTocSize = totalTocSize - Header.DirectoryIndexSize - tocMetaSize;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user