Fix DIFAT assumptions for directory entries

This commit is contained in:
Matt Nadareski
2025-07-30 16:28:43 -04:00
parent d71cb413fd
commit b2b9083221

View File

@@ -389,14 +389,6 @@ namespace BinaryObjectScanner.FileType
#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>();
@@ -440,9 +432,8 @@ namespace BinaryObjectScanner.FileType
// 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