diff --git a/src/LibHac/Tools/FsSystem/PartitionFileSystemBuilder.cs b/src/LibHac/Tools/FsSystem/PartitionFileSystemBuilder.cs index b9858d21..2e8ec276 100644 --- a/src/LibHac/Tools/FsSystem/PartitionFileSystemBuilder.cs +++ b/src/LibHac/Tools/FsSystem/PartitionFileSystemBuilder.cs @@ -23,6 +23,7 @@ public enum PartitionFileSystemType public class PartitionFileSystemBuilder { private const int HeaderSize = 0x10; + private const int DefaultHashTargetSize = 0x200; private List Entries { get; } = new List(); private long CurrentOffset { get; set; } @@ -58,7 +59,7 @@ public class PartitionFileSystemBuilder Offset = CurrentOffset, NameLength = Encoding.UTF8.GetByteCount(filename), HashOffset = 0, - HashLength = 0x200 + HashLength = (int)Math.Min(DefaultHashTargetSize, fileSize) }; CurrentOffset += entry.Length; @@ -163,7 +164,10 @@ public class PartitionFileSystemBuilder foreach (Entry entry in Entries) { - if (entry.HashLength == 0) entry.HashLength = 0x200; + if (entry.HashLength == 0) + { + entry.HashLength = (int)Math.Min(DefaultHashTargetSize, entry.Length); + } byte[] data = new byte[entry.HashLength]; entry.File.Read(out long bytesRead, entry.HashOffset, data); @@ -180,7 +184,7 @@ public class PartitionFileSystemBuilder sha.GetHash(entry.Hash); } } - + public static int GetEntrySize(PartitionFileSystemType type) { switch (type)