From c1c25b5f5e9844b575b4f22e36511d6ca3df6ba5 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Wed, 13 Mar 2024 12:45:20 +0900 Subject: [PATCH] Fix issue from moving to ST.Hashing --- IRDKit/IRDKit.csproj | 2 +- LibIRD/IRD.cs | 19 ++++++++++++++++++- LibIRD/LibIRD.csproj | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index ee9b9c7..89bb46c 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -11,7 +11,7 @@ latest true true - 0.8.0 + 0.9.0 Deterous diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index 0fb523e..fdcaf5c 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -1105,6 +1105,22 @@ namespace LibIRD // If end of ISO reached, stop reading if (numBytes == 0) { + // Ensure all hashes have been saved + foreach (int i in regions) + { + // Close region hash + regionMD5[i].Terminate(); + RegionHashes[i] = regionMD5[i].CurrentHashBytes; + regionMD5[i].Dispose(); + } + foreach (int i in files) + { + // Close file hash + fileMD5[i].Terminate(); + FileHashes[i] = fileMD5[i].CurrentHashBytes; + fileMD5[i].Dispose(); + } + // If making redump-style IRD, save CRC32 hash to UID field if (redump) { @@ -1112,6 +1128,7 @@ namespace LibIRD Array.Reverse(crc32); UID = BitConverter.ToUInt32(crc32, 0); } + return; } @@ -1240,7 +1257,7 @@ namespace LibIRD // Check if current file has ended in this buffer (assumes last extent contains last byte) int lastExtent = FileExtents[i].Length - 1; long lastByte = SectorSize * FileExtents[i][lastExtent].Offset + FileExtents[i][lastExtent].Count; - if (lastByte < SectorSize * (currentSector + bufSectors) + if (lastByte <= SectorSize * (currentSector + bufSectors) && lastByte > SectorSize * currentSector) { // Close file hash diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj index 9e575b3..59f0a60 100644 --- a/LibIRD/LibIRD.csproj +++ b/LibIRD/LibIRD.csproj @@ -7,7 +7,7 @@ latest true true - 0.8.0 + 0.9.0 ../nupkg