Fix DIFAT assumptions for directory entries

This commit is contained in:
Matt Nadareski
2025-07-30 16:28:54 -04:00
parent 36edf9ed54
commit 5ba9ab3457

View File

@@ -166,14 +166,6 @@ namespace SabreTools.Serialization.Deserializers
#region Directory Entries
// Get the offset of the first directory sector
long firstDirectoryOffset = (long)(fileHeader.FirstDirectorySectorLocation * Math.Pow(2, fileHeader.SectorShift));
if (firstDirectoryOffset < 0 || firstDirectoryOffset >= data.Length)
return null;
// Seek to the first directory sector
data.Seek(firstDirectoryOffset, SeekOrigin.Begin);
// Create a directory sector table
var directorySectors = new List<DirectoryEntry>();
@@ -217,9 +209,8 @@ namespace SabreTools.Serialization.Deserializers
// Add the sector shifts
directorySectors.AddRange(directoryEntries);
// Get the next sector from the DIFAT
var fat = binary.DIFATSectorNumbers[(int)currentSector];
currentSector = binary.FATSectorNumbers[(int)fat];
// Get the next sector from the FAT
currentSector = binary.FATSectorNumbers[(int)currentSector];
}
// Assign the Directory sectors table