Files
Aaru/DiscImageChef.Filesystems/FAT/Info.cs

1488 lines
82 KiB
C#
Raw Normal View History

// /***************************************************************************
* LICENSE.MIT: * LICENSE.LGPL: Added LICENSE files for LGPL and MIT licenses. * DiscImageChef.Devices/Enums.cs: * DiscImageChef.Partitions/MBR.cs: * DiscImageChef.Partitions/RDB.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Partitions/Sun.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.Partitions/GPT.cs: * DiscImageChef.Filesystems/FFS.cs: * DiscImageChef.Filesystems/FAT.cs: * DiscImageChef.Partitions/NeXT.cs: * DiscImageChef.Devices/Command.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef.Decoders/CD/PMA.cs: * DiscImageChef.Decoders/CD/TOC.cs: * DiscImageChef.Filesystems/BFS.cs: * DiscImageChef.Filesystems/ODS.cs: * DiscImageChef.Helpers/PrintHex.cs: * DiscImageChef.Helpers/Swapping.cs: * DiscImageChef.Decoders/DVD/PRI.cs: * DiscImageChef.Decoders/DVD/DMI.cs: * DiscImageChef.Decoders/DVD/DDS.cs: * DiscImageChef.Decoders/DVD/RMD.cs: * DiscImageChef.Decoders/DVD/UDI.cs: * DiscImageChef.Partitions/Atari.cs: * DiscImageChef.Decoders/DVD/BCA.cs: * DiscImageChef.Filesystems/SysV.cs: * DiscImageChef.Filesystems/HPFS.cs: * DiscImageChef.Filesystems/NTFS.cs: * DiscImageChef.Filesystems/APFS.cs: * DiscImageChef.Decoders/DVD/PFI.cs: * DiscImageChef.Decoders/CD/ATIP.cs: * DiscImageChef.Filesystems/Acorn.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.Filesystems/BTRFS.cs: * DiscImageChef.Decoders/Xbox/DMI.cs: * DiscImageChef.Helpers/ArrayFill.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef.Filesystems/Opera.cs: * DiscImageChef.Filesystems/extFS.cs: * DiscImageChef.Decoders/DVD/CPRM.cs: * DiscImageChef.Decoders/DVD/ADIP.cs: * DiscImageChef.Decoders/CD/Enums.cs: * DiscImageChef.Decoders/DVD/AACS.cs: * DiscImageChef.Decoders/SCSI/EVPD.cs: * DiscImageChef.Filesystems/ProDOS.cs: * DiscImageChef.Metadata/MediaType.cs: * DiscImageChef.Console/DicConsole.cs: * DiscImageChef.Decoders/DVD/Spare.cs: * DiscImageChef.Filesystems/ext2FS.cs: * DiscImageChef.Decoders/DVD/Enums.cs: * DiscImageChef.Filesystems/Symbian.cs: * DiscImageChef.Decoders/SCSI/Types.cs: * DiscImageChef.Filesystems/UNIXBFS.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.Decoders/SCSI/Sense.cs: * DiscImageChef.Decoders/CD/FullTOC.cs: * DiscImageChef.Decoders/Blu-ray/DI.cs: * DiscImageChef.Decoders/ATA/Errors.cs: * DiscImageChef.Filesystems/ISO9660.cs: * DiscImageChef.Filesystems/MinixFS.cs: * DiscImageChef.Devices/Linux/Enums.cs: * DiscImageChef.Filesystems/SolarFS.cs: * DiscImageChef.Filesystems/Structs.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Decoders/SCSI/Modes.cs: * DiscImageChef.Metadata/Dimensions.cs: * DiscImageChef.Partitions/AppleMap.cs: * DiscImageChef.Decoders/Floppy/ISO.cs: * DiscImageChef.Decoders/DVD/Layers.cs: * DiscImageChef.Decoders/CD/Session.cs: * DiscImageChef.Decoders/SCSI/Enums.cs: * DiscImageChef.Filesystems/Nintendo.cs: * DiscImageChef.Helpers/DateHandlers.cs: * DiscImageChef.Filesystems/AmigaDOS.cs: * DiscImageChef.DiscImages/ImageInfo.cs: * DiscImageChef.Checksums/MD5Context.cs: * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Filesystems/AppleHFS.cs: * DiscImageChef.Filesystems/AppleMFS.cs: * DiscImageChef.Helpers/ArrayIsEmpty.cs: * DiscImageChef.Decoders/Blu-ray/BCA.cs: * DiscImageChef.Decoders/Blu-ray/DDS.cs: * DiscImageChef.Filesystems/PCEngine.cs: * DiscImageChef.Decoders/ATA/Identify.cs: * DiscImageChef.Devices/Linux/Command.cs: * DiscImageChef.Devices/FreeBSD/Enums.cs: * DiscImageChef.Decoders/SCSI/Inquiry.cs: * DiscImageChef.Metadata/DeviceReport.cs: * DiscImageChef.Decoders/Floppy/Amiga.cs: * DiscImageChef.Devices/Linux/Structs.cs: * DiscImageChef.Devices/Windows/Enums.cs: * DiscImageChef.Decoders/DVD/CSS&CPRM.cs: * DiscImageChef.Checksums/SHA1Context.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.Partitions/PartPlugin.cs: * DiscImageChef.CommonTypes/Partition.cs: * DiscImageChef.Decoders/Floppy/Enums.cs: * DiscImageChef.CommonTypes/MediaType.cs: * DiscImageChef.Decoders/Floppy/Apple2.cs: * DiscImageChef.Devices/Windows/Extern.cs: * DiscImageChef.Decoders/SCSI/MMC/CPRM.cs: * DiscImageChef.Helpers/StringHandlers.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.Checksums/CRC64Context.cs: * DiscImageChef.Checksums/CRC32Context.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef.Checksums/CRC16Context.cs: * DiscImageChef.Filesystems/LisaFS/Dir.cs: * DiscImageChef.Decoders/DVD/Cartridge.cs: * DiscImageChef.Decoders/Blu-ray/Spare.cs: * DiscImageChef.Filesystems/Filesystem.cs: * DiscImageChef.Decoders/SCSI/MMC/AACS.cs: * DiscImageChef.Devices/FreeBSD/Extern.cs: * DiscImageChef.Devices/Device/Commands.cs: * DiscImageChef.Checksums/SHA384Context.cs: * DiscImageChef.Devices/FreeBSD/Command.cs: * DiscImageChef.Checksums/SHA512Context.cs: * DiscImageChef.Decoders/SCSI/MMC/Enums.cs: * DiscImageChef.Devices/Windows/Command.cs: * DiscImageChef.Devices/FreeBSD/Structs.cs: * DiscImageChef.Devices/Windows/Structs.cs: * DiscImageChef.Filesystems/LisaFS/Info.cs: * DiscImageChef.Checksums/SHA256Context.cs: * DiscImageChef.Filesystems/LisaFS/File.cs: * DiscImageChef.Filesystems/AppleHFSPlus.cs: * DiscImageChef.Filesystems/LisaFS/Super.cs: * DiscImageChef.Filesystems/LisaFS/Xattr.cs: * DiscImageChef.Checksums/Adler32Context.cs: * DiscImageChef.Decoders/Floppy/System34.cs: * DiscImageChef.Checksums/SpamSumContext.cs: * DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs: * DiscImageChef.Devices/Device/Variables.cs: * DiscImageChef.Filesystems/LisaFS/Consts.cs: * DiscImageChef.Filesystems/LisaFS/LisaFS.cs: * DiscImageChef.Decoders/Floppy/Commodore.cs: * DiscImageChef.Checksums/FletcherContext.cs: * DiscImageChef.Filesystems/LisaFS/Extent.cs: * DiscImageChef.Devices/Device/Destructor.cs: * DiscImageChef.Decoders/Floppy/AppleSony.cs: * DiscImageChef.Filesystems/LisaFS/Structs.cs: * DiscImageChef.Decoders/SCSI/VendorString.cs: * DiscImageChef.Decoders/SCSI/MMC/Features.cs: * DiscImageChef.Devices/Device/Constructor.cs: * DiscImageChef.Checksums/RIPEMD160Context.cs: * DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs: * DiscImageChef.Decoders/Blu-ray/Cartridge.cs: * DiscImageChef.Decoders/Floppy/System3740.cs: * DiscImageChef.Filesystems/LisaFS/Encoding.cs: * DiscImageChef.Decoders/SCSI/ModesEncoders.cs: * DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs: * DiscImageChef.Helpers/BigEndianBitConverter.cs: * DiscImageChef.Decoders/Floppy/Perpendicular.cs: * DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs: * DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs: * DiscImageChef.Devices/Device/ScsiCommands/HP.cs: * DiscImageChef.Devices/Device/AtaCommands/Cfa.cs: * DiscImageChef.Devices/Device/ScsiCommands/NEC.cs: * DiscImageChef.Helpers/EndianAwareBinaryReader.cs: * DiscImageChef.Devices/Device/ScsiCommands/MMC.cs: * DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/ScsiCommands/SSC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SMC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SBC.cs: * DiscImageChef.Metadata/Properties/AssemblyInfo.cs: * DiscImageChef.Devices/Device/AtaCommands/Atapi.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs: * DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs: * DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs: * DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs: * DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs: * DiscImageChef.Devices/Device/ScsiCommands/Certance.cs: * DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs: * DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs: Relicensed as LGPL. Updated standard header. * DiscImageChef/Main.cs: * DiscImageChef/Plugins.cs: * DiscImageChef/Options.cs: * DiscImageChef/Commands/Ls.cs: * DiscImageChef/Core/IBGLog.cs: * DiscImageChef/Core/MHDDLog.cs: * DiscImageChef/AssemblyInfo.cs: * DiscImageChef/Core/Checksum.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef.Interop/DetectOS.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef/Commands/Commands.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Benchmark.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/MediaInfo.cs: * DiscImageChef.Interop/PlatformID.cs: * DiscImageChef/Commands/MediaScan.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Checksums/ReedSolomon.cs: * DiscImageChef/Commands/DeviceReport.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.Checksums/CDChecksums.cs: * DiscImageChef/Commands/CreateSidecar.cs: Updated standard header. * DiscImageChef.Checksums/DiscImageChef.Checksums.csproj: Relicensed project as LGPL. Updated standard header. Embed license as resource. * DiscImageChef.Console/DiscImageChef.Console.csproj: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: * DiscImageChef.Helpers/DiscImageChef.Helpers.csproj: * DiscImageChef.Settings/DiscImageChef.Settings.csproj: * DiscImageChef.Decoders/DiscImageChef.Decoders.csproj: * DiscImageChef.Metadata/DiscImageChef.Metadata.csproj: * DiscImageChef.Partitions/DiscImageChef.Partitions.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: * DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj: Relicensed as LGPL. Updated standard header. Embed license as resource. * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.Interop/DiscImageChef.Interop.csproj: Updated standard header. Embed license as resource.
2016-07-28 18:13:49 +01:00
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Info.cs
* LICENSE.MIT: * LICENSE.LGPL: Added LICENSE files for LGPL and MIT licenses. * DiscImageChef.Devices/Enums.cs: * DiscImageChef.Partitions/MBR.cs: * DiscImageChef.Partitions/RDB.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Partitions/Sun.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.Partitions/GPT.cs: * DiscImageChef.Filesystems/FFS.cs: * DiscImageChef.Filesystems/FAT.cs: * DiscImageChef.Partitions/NeXT.cs: * DiscImageChef.Devices/Command.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef.Decoders/CD/PMA.cs: * DiscImageChef.Decoders/CD/TOC.cs: * DiscImageChef.Filesystems/BFS.cs: * DiscImageChef.Filesystems/ODS.cs: * DiscImageChef.Helpers/PrintHex.cs: * DiscImageChef.Helpers/Swapping.cs: * DiscImageChef.Decoders/DVD/PRI.cs: * DiscImageChef.Decoders/DVD/DMI.cs: * DiscImageChef.Decoders/DVD/DDS.cs: * DiscImageChef.Decoders/DVD/RMD.cs: * DiscImageChef.Decoders/DVD/UDI.cs: * DiscImageChef.Partitions/Atari.cs: * DiscImageChef.Decoders/DVD/BCA.cs: * DiscImageChef.Filesystems/SysV.cs: * DiscImageChef.Filesystems/HPFS.cs: * DiscImageChef.Filesystems/NTFS.cs: * DiscImageChef.Filesystems/APFS.cs: * DiscImageChef.Decoders/DVD/PFI.cs: * DiscImageChef.Decoders/CD/ATIP.cs: * DiscImageChef.Filesystems/Acorn.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.Filesystems/BTRFS.cs: * DiscImageChef.Decoders/Xbox/DMI.cs: * DiscImageChef.Helpers/ArrayFill.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef.Filesystems/Opera.cs: * DiscImageChef.Filesystems/extFS.cs: * DiscImageChef.Decoders/DVD/CPRM.cs: * DiscImageChef.Decoders/DVD/ADIP.cs: * DiscImageChef.Decoders/CD/Enums.cs: * DiscImageChef.Decoders/DVD/AACS.cs: * DiscImageChef.Decoders/SCSI/EVPD.cs: * DiscImageChef.Filesystems/ProDOS.cs: * DiscImageChef.Metadata/MediaType.cs: * DiscImageChef.Console/DicConsole.cs: * DiscImageChef.Decoders/DVD/Spare.cs: * DiscImageChef.Filesystems/ext2FS.cs: * DiscImageChef.Decoders/DVD/Enums.cs: * DiscImageChef.Filesystems/Symbian.cs: * DiscImageChef.Decoders/SCSI/Types.cs: * DiscImageChef.Filesystems/UNIXBFS.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.Decoders/SCSI/Sense.cs: * DiscImageChef.Decoders/CD/FullTOC.cs: * DiscImageChef.Decoders/Blu-ray/DI.cs: * DiscImageChef.Decoders/ATA/Errors.cs: * DiscImageChef.Filesystems/ISO9660.cs: * DiscImageChef.Filesystems/MinixFS.cs: * DiscImageChef.Devices/Linux/Enums.cs: * DiscImageChef.Filesystems/SolarFS.cs: * DiscImageChef.Filesystems/Structs.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Decoders/SCSI/Modes.cs: * DiscImageChef.Metadata/Dimensions.cs: * DiscImageChef.Partitions/AppleMap.cs: * DiscImageChef.Decoders/Floppy/ISO.cs: * DiscImageChef.Decoders/DVD/Layers.cs: * DiscImageChef.Decoders/CD/Session.cs: * DiscImageChef.Decoders/SCSI/Enums.cs: * DiscImageChef.Filesystems/Nintendo.cs: * DiscImageChef.Helpers/DateHandlers.cs: * DiscImageChef.Filesystems/AmigaDOS.cs: * DiscImageChef.DiscImages/ImageInfo.cs: * DiscImageChef.Checksums/MD5Context.cs: * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Filesystems/AppleHFS.cs: * DiscImageChef.Filesystems/AppleMFS.cs: * DiscImageChef.Helpers/ArrayIsEmpty.cs: * DiscImageChef.Decoders/Blu-ray/BCA.cs: * DiscImageChef.Decoders/Blu-ray/DDS.cs: * DiscImageChef.Filesystems/PCEngine.cs: * DiscImageChef.Decoders/ATA/Identify.cs: * DiscImageChef.Devices/Linux/Command.cs: * DiscImageChef.Devices/FreeBSD/Enums.cs: * DiscImageChef.Decoders/SCSI/Inquiry.cs: * DiscImageChef.Metadata/DeviceReport.cs: * DiscImageChef.Decoders/Floppy/Amiga.cs: * DiscImageChef.Devices/Linux/Structs.cs: * DiscImageChef.Devices/Windows/Enums.cs: * DiscImageChef.Decoders/DVD/CSS&CPRM.cs: * DiscImageChef.Checksums/SHA1Context.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.Partitions/PartPlugin.cs: * DiscImageChef.CommonTypes/Partition.cs: * DiscImageChef.Decoders/Floppy/Enums.cs: * DiscImageChef.CommonTypes/MediaType.cs: * DiscImageChef.Decoders/Floppy/Apple2.cs: * DiscImageChef.Devices/Windows/Extern.cs: * DiscImageChef.Decoders/SCSI/MMC/CPRM.cs: * DiscImageChef.Helpers/StringHandlers.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.Checksums/CRC64Context.cs: * DiscImageChef.Checksums/CRC32Context.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef.Checksums/CRC16Context.cs: * DiscImageChef.Filesystems/LisaFS/Dir.cs: * DiscImageChef.Decoders/DVD/Cartridge.cs: * DiscImageChef.Decoders/Blu-ray/Spare.cs: * DiscImageChef.Filesystems/Filesystem.cs: * DiscImageChef.Decoders/SCSI/MMC/AACS.cs: * DiscImageChef.Devices/FreeBSD/Extern.cs: * DiscImageChef.Devices/Device/Commands.cs: * DiscImageChef.Checksums/SHA384Context.cs: * DiscImageChef.Devices/FreeBSD/Command.cs: * DiscImageChef.Checksums/SHA512Context.cs: * DiscImageChef.Decoders/SCSI/MMC/Enums.cs: * DiscImageChef.Devices/Windows/Command.cs: * DiscImageChef.Devices/FreeBSD/Structs.cs: * DiscImageChef.Devices/Windows/Structs.cs: * DiscImageChef.Filesystems/LisaFS/Info.cs: * DiscImageChef.Checksums/SHA256Context.cs: * DiscImageChef.Filesystems/LisaFS/File.cs: * DiscImageChef.Filesystems/AppleHFSPlus.cs: * DiscImageChef.Filesystems/LisaFS/Super.cs: * DiscImageChef.Filesystems/LisaFS/Xattr.cs: * DiscImageChef.Checksums/Adler32Context.cs: * DiscImageChef.Decoders/Floppy/System34.cs: * DiscImageChef.Checksums/SpamSumContext.cs: * DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs: * DiscImageChef.Devices/Device/Variables.cs: * DiscImageChef.Filesystems/LisaFS/Consts.cs: * DiscImageChef.Filesystems/LisaFS/LisaFS.cs: * DiscImageChef.Decoders/Floppy/Commodore.cs: * DiscImageChef.Checksums/FletcherContext.cs: * DiscImageChef.Filesystems/LisaFS/Extent.cs: * DiscImageChef.Devices/Device/Destructor.cs: * DiscImageChef.Decoders/Floppy/AppleSony.cs: * DiscImageChef.Filesystems/LisaFS/Structs.cs: * DiscImageChef.Decoders/SCSI/VendorString.cs: * DiscImageChef.Decoders/SCSI/MMC/Features.cs: * DiscImageChef.Devices/Device/Constructor.cs: * DiscImageChef.Checksums/RIPEMD160Context.cs: * DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs: * DiscImageChef.Decoders/Blu-ray/Cartridge.cs: * DiscImageChef.Decoders/Floppy/System3740.cs: * DiscImageChef.Filesystems/LisaFS/Encoding.cs: * DiscImageChef.Decoders/SCSI/ModesEncoders.cs: * DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs: * DiscImageChef.Helpers/BigEndianBitConverter.cs: * DiscImageChef.Decoders/Floppy/Perpendicular.cs: * DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs: * DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs: * DiscImageChef.Devices/Device/ScsiCommands/HP.cs: * DiscImageChef.Devices/Device/AtaCommands/Cfa.cs: * DiscImageChef.Devices/Device/ScsiCommands/NEC.cs: * DiscImageChef.Helpers/EndianAwareBinaryReader.cs: * DiscImageChef.Devices/Device/ScsiCommands/MMC.cs: * DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/ScsiCommands/SSC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SMC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SBC.cs: * DiscImageChef.Metadata/Properties/AssemblyInfo.cs: * DiscImageChef.Devices/Device/AtaCommands/Atapi.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs: * DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs: * DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs: * DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs: * DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs: * DiscImageChef.Devices/Device/ScsiCommands/Certance.cs: * DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs: * DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs: Relicensed as LGPL. Updated standard header. * DiscImageChef/Main.cs: * DiscImageChef/Plugins.cs: * DiscImageChef/Options.cs: * DiscImageChef/Commands/Ls.cs: * DiscImageChef/Core/IBGLog.cs: * DiscImageChef/Core/MHDDLog.cs: * DiscImageChef/AssemblyInfo.cs: * DiscImageChef/Core/Checksum.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef.Interop/DetectOS.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef/Commands/Commands.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Benchmark.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/MediaInfo.cs: * DiscImageChef.Interop/PlatformID.cs: * DiscImageChef/Commands/MediaScan.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Checksums/ReedSolomon.cs: * DiscImageChef/Commands/DeviceReport.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.Checksums/CDChecksums.cs: * DiscImageChef/Commands/CreateSidecar.cs: Updated standard header. * DiscImageChef.Checksums/DiscImageChef.Checksums.csproj: Relicensed project as LGPL. Updated standard header. Embed license as resource. * DiscImageChef.Console/DiscImageChef.Console.csproj: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: * DiscImageChef.Helpers/DiscImageChef.Helpers.csproj: * DiscImageChef.Settings/DiscImageChef.Settings.csproj: * DiscImageChef.Decoders/DiscImageChef.Decoders.csproj: * DiscImageChef.Metadata/DiscImageChef.Metadata.csproj: * DiscImageChef.Partitions/DiscImageChef.Partitions.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: * DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj: Relicensed as LGPL. Updated standard header. Embed license as resource. * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.Interop/DiscImageChef.Interop.csproj: Updated standard header. Embed license as resource.
2016-07-28 18:13:49 +01:00
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Microsoft FAT filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies the Microsoft FAT filesystem and shows information.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2018-12-29 17:34:38 +00:00
// Copyright © 2011-2019 Natalia Portillo
* LICENSE.MIT: * LICENSE.LGPL: Added LICENSE files for LGPL and MIT licenses. * DiscImageChef.Devices/Enums.cs: * DiscImageChef.Partitions/MBR.cs: * DiscImageChef.Partitions/RDB.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Partitions/Sun.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.Partitions/GPT.cs: * DiscImageChef.Filesystems/FFS.cs: * DiscImageChef.Filesystems/FAT.cs: * DiscImageChef.Partitions/NeXT.cs: * DiscImageChef.Devices/Command.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef.Decoders/CD/PMA.cs: * DiscImageChef.Decoders/CD/TOC.cs: * DiscImageChef.Filesystems/BFS.cs: * DiscImageChef.Filesystems/ODS.cs: * DiscImageChef.Helpers/PrintHex.cs: * DiscImageChef.Helpers/Swapping.cs: * DiscImageChef.Decoders/DVD/PRI.cs: * DiscImageChef.Decoders/DVD/DMI.cs: * DiscImageChef.Decoders/DVD/DDS.cs: * DiscImageChef.Decoders/DVD/RMD.cs: * DiscImageChef.Decoders/DVD/UDI.cs: * DiscImageChef.Partitions/Atari.cs: * DiscImageChef.Decoders/DVD/BCA.cs: * DiscImageChef.Filesystems/SysV.cs: * DiscImageChef.Filesystems/HPFS.cs: * DiscImageChef.Filesystems/NTFS.cs: * DiscImageChef.Filesystems/APFS.cs: * DiscImageChef.Decoders/DVD/PFI.cs: * DiscImageChef.Decoders/CD/ATIP.cs: * DiscImageChef.Filesystems/Acorn.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.Filesystems/BTRFS.cs: * DiscImageChef.Decoders/Xbox/DMI.cs: * DiscImageChef.Helpers/ArrayFill.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef.Filesystems/Opera.cs: * DiscImageChef.Filesystems/extFS.cs: * DiscImageChef.Decoders/DVD/CPRM.cs: * DiscImageChef.Decoders/DVD/ADIP.cs: * DiscImageChef.Decoders/CD/Enums.cs: * DiscImageChef.Decoders/DVD/AACS.cs: * DiscImageChef.Decoders/SCSI/EVPD.cs: * DiscImageChef.Filesystems/ProDOS.cs: * DiscImageChef.Metadata/MediaType.cs: * DiscImageChef.Console/DicConsole.cs: * DiscImageChef.Decoders/DVD/Spare.cs: * DiscImageChef.Filesystems/ext2FS.cs: * DiscImageChef.Decoders/DVD/Enums.cs: * DiscImageChef.Filesystems/Symbian.cs: * DiscImageChef.Decoders/SCSI/Types.cs: * DiscImageChef.Filesystems/UNIXBFS.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.Decoders/SCSI/Sense.cs: * DiscImageChef.Decoders/CD/FullTOC.cs: * DiscImageChef.Decoders/Blu-ray/DI.cs: * DiscImageChef.Decoders/ATA/Errors.cs: * DiscImageChef.Filesystems/ISO9660.cs: * DiscImageChef.Filesystems/MinixFS.cs: * DiscImageChef.Devices/Linux/Enums.cs: * DiscImageChef.Filesystems/SolarFS.cs: * DiscImageChef.Filesystems/Structs.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Decoders/SCSI/Modes.cs: * DiscImageChef.Metadata/Dimensions.cs: * DiscImageChef.Partitions/AppleMap.cs: * DiscImageChef.Decoders/Floppy/ISO.cs: * DiscImageChef.Decoders/DVD/Layers.cs: * DiscImageChef.Decoders/CD/Session.cs: * DiscImageChef.Decoders/SCSI/Enums.cs: * DiscImageChef.Filesystems/Nintendo.cs: * DiscImageChef.Helpers/DateHandlers.cs: * DiscImageChef.Filesystems/AmigaDOS.cs: * DiscImageChef.DiscImages/ImageInfo.cs: * DiscImageChef.Checksums/MD5Context.cs: * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Filesystems/AppleHFS.cs: * DiscImageChef.Filesystems/AppleMFS.cs: * DiscImageChef.Helpers/ArrayIsEmpty.cs: * DiscImageChef.Decoders/Blu-ray/BCA.cs: * DiscImageChef.Decoders/Blu-ray/DDS.cs: * DiscImageChef.Filesystems/PCEngine.cs: * DiscImageChef.Decoders/ATA/Identify.cs: * DiscImageChef.Devices/Linux/Command.cs: * DiscImageChef.Devices/FreeBSD/Enums.cs: * DiscImageChef.Decoders/SCSI/Inquiry.cs: * DiscImageChef.Metadata/DeviceReport.cs: * DiscImageChef.Decoders/Floppy/Amiga.cs: * DiscImageChef.Devices/Linux/Structs.cs: * DiscImageChef.Devices/Windows/Enums.cs: * DiscImageChef.Decoders/DVD/CSS&CPRM.cs: * DiscImageChef.Checksums/SHA1Context.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.Partitions/PartPlugin.cs: * DiscImageChef.CommonTypes/Partition.cs: * DiscImageChef.Decoders/Floppy/Enums.cs: * DiscImageChef.CommonTypes/MediaType.cs: * DiscImageChef.Decoders/Floppy/Apple2.cs: * DiscImageChef.Devices/Windows/Extern.cs: * DiscImageChef.Decoders/SCSI/MMC/CPRM.cs: * DiscImageChef.Helpers/StringHandlers.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.Checksums/CRC64Context.cs: * DiscImageChef.Checksums/CRC32Context.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef.Checksums/CRC16Context.cs: * DiscImageChef.Filesystems/LisaFS/Dir.cs: * DiscImageChef.Decoders/DVD/Cartridge.cs: * DiscImageChef.Decoders/Blu-ray/Spare.cs: * DiscImageChef.Filesystems/Filesystem.cs: * DiscImageChef.Decoders/SCSI/MMC/AACS.cs: * DiscImageChef.Devices/FreeBSD/Extern.cs: * DiscImageChef.Devices/Device/Commands.cs: * DiscImageChef.Checksums/SHA384Context.cs: * DiscImageChef.Devices/FreeBSD/Command.cs: * DiscImageChef.Checksums/SHA512Context.cs: * DiscImageChef.Decoders/SCSI/MMC/Enums.cs: * DiscImageChef.Devices/Windows/Command.cs: * DiscImageChef.Devices/FreeBSD/Structs.cs: * DiscImageChef.Devices/Windows/Structs.cs: * DiscImageChef.Filesystems/LisaFS/Info.cs: * DiscImageChef.Checksums/SHA256Context.cs: * DiscImageChef.Filesystems/LisaFS/File.cs: * DiscImageChef.Filesystems/AppleHFSPlus.cs: * DiscImageChef.Filesystems/LisaFS/Super.cs: * DiscImageChef.Filesystems/LisaFS/Xattr.cs: * DiscImageChef.Checksums/Adler32Context.cs: * DiscImageChef.Decoders/Floppy/System34.cs: * DiscImageChef.Checksums/SpamSumContext.cs: * DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs: * DiscImageChef.Devices/Device/Variables.cs: * DiscImageChef.Filesystems/LisaFS/Consts.cs: * DiscImageChef.Filesystems/LisaFS/LisaFS.cs: * DiscImageChef.Decoders/Floppy/Commodore.cs: * DiscImageChef.Checksums/FletcherContext.cs: * DiscImageChef.Filesystems/LisaFS/Extent.cs: * DiscImageChef.Devices/Device/Destructor.cs: * DiscImageChef.Decoders/Floppy/AppleSony.cs: * DiscImageChef.Filesystems/LisaFS/Structs.cs: * DiscImageChef.Decoders/SCSI/VendorString.cs: * DiscImageChef.Decoders/SCSI/MMC/Features.cs: * DiscImageChef.Devices/Device/Constructor.cs: * DiscImageChef.Checksums/RIPEMD160Context.cs: * DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs: * DiscImageChef.Decoders/Blu-ray/Cartridge.cs: * DiscImageChef.Decoders/Floppy/System3740.cs: * DiscImageChef.Filesystems/LisaFS/Encoding.cs: * DiscImageChef.Decoders/SCSI/ModesEncoders.cs: * DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs: * DiscImageChef.Helpers/BigEndianBitConverter.cs: * DiscImageChef.Decoders/Floppy/Perpendicular.cs: * DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs: * DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs: * DiscImageChef.Devices/Device/ScsiCommands/HP.cs: * DiscImageChef.Devices/Device/AtaCommands/Cfa.cs: * DiscImageChef.Devices/Device/ScsiCommands/NEC.cs: * DiscImageChef.Helpers/EndianAwareBinaryReader.cs: * DiscImageChef.Devices/Device/ScsiCommands/MMC.cs: * DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/ScsiCommands/SSC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SMC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SBC.cs: * DiscImageChef.Metadata/Properties/AssemblyInfo.cs: * DiscImageChef.Devices/Device/AtaCommands/Atapi.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs: * DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs: * DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs: * DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs: * DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs: * DiscImageChef.Devices/Device/ScsiCommands/Certance.cs: * DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs: * DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs: Relicensed as LGPL. Updated standard header. * DiscImageChef/Main.cs: * DiscImageChef/Plugins.cs: * DiscImageChef/Options.cs: * DiscImageChef/Commands/Ls.cs: * DiscImageChef/Core/IBGLog.cs: * DiscImageChef/Core/MHDDLog.cs: * DiscImageChef/AssemblyInfo.cs: * DiscImageChef/Core/Checksum.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef.Interop/DetectOS.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef/Commands/Commands.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Benchmark.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/MediaInfo.cs: * DiscImageChef.Interop/PlatformID.cs: * DiscImageChef/Commands/MediaScan.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Checksums/ReedSolomon.cs: * DiscImageChef/Commands/DeviceReport.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.Checksums/CDChecksums.cs: * DiscImageChef/Commands/CreateSidecar.cs: Updated standard header. * DiscImageChef.Checksums/DiscImageChef.Checksums.csproj: Relicensed project as LGPL. Updated standard header. Embed license as resource. * DiscImageChef.Console/DiscImageChef.Console.csproj: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: * DiscImageChef.Helpers/DiscImageChef.Helpers.csproj: * DiscImageChef.Settings/DiscImageChef.Settings.csproj: * DiscImageChef.Decoders/DiscImageChef.Decoders.csproj: * DiscImageChef.Metadata/DiscImageChef.Metadata.csproj: * DiscImageChef.Partitions/DiscImageChef.Partitions.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: * DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj: Relicensed as LGPL. Updated standard header. Embed license as resource. * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.Interop/DiscImageChef.Interop.csproj: Updated standard header. Embed license as resource.
2016-07-28 18:13:49 +01:00
// ****************************************************************************/
using System;
2017-12-19 19:33:46 +00:00
using System.IO;
using System.Linq;
using System.Text;
2017-12-21 14:30:38 +00:00
using DiscImageChef.Checksums;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Console;
2017-12-21 14:30:38 +00:00
using DiscImageChef.Helpers;
using Schemas;
namespace DiscImageChef.Filesystems.FAT
{
public partial class FAT
{
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(2 + partition.Start >= partition.End) return false;
2014-07-09 19:49:14 +01:00
ushort bps;
2018-02-01 01:19:19 +00:00
byte spc;
byte numberOfFats;
ushort reservedSecs;
ushort rootEntries;
ushort sectors;
2018-02-01 01:19:19 +00:00
byte mediaDescriptor;
ushort fatSectors;
2018-02-01 01:19:19 +00:00
uint bigSectors;
byte bpbSignature;
byte fat32Signature;
ulong hugeSectors;
byte[] fat32Id = new byte[8];
2018-02-01 01:19:19 +00:00
byte[] msxId = new byte[6];
byte fatId;
byte[] dosOem = new byte[8];
byte[] atariOem = new byte[6];
ushort bootable = 0;
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
byte[] bpbSector = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb);
byte[] fatSector = imagePlugin.ReadSector(sectorsPerBpb + partition.Start);
2019-02-27 08:49:42 +00:00
HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0;
DicConsole.DebugWriteLine("FAT plugin", "Human bpc = {0}", humanBpb.bpc);
DicConsole.DebugWriteLine("FAT plugin", "Human clusters = {0}", humanBpb.clusters);
DicConsole.DebugWriteLine("FAT plugin", "Human big_clusters = {0}", humanBpb.big_clusters);
DicConsole.DebugWriteLine("FAT plugin", "Human expected clusters = {0}", expectedClusters);
// Check clusters for Human68k are correct
bool humanClustersCorrect = humanBpb.clusters == 0
? humanBpb.big_clusters == expectedClusters
: humanBpb.clusters == expectedClusters;
// Check OEM for Human68k is correct
bool humanOemCorrect = bpbSector[2] >= 0x20 && bpbSector[3] >= 0x20 && bpbSector[4] >= 0x20 &&
bpbSector[5] >= 0x20 && bpbSector[6] >= 0x20 && bpbSector[7] >= 0x20 &&
bpbSector[8] >= 0x20 && bpbSector[9] >= 0x20 && bpbSector[10] >= 0x20 &&
bpbSector[11] >= 0x20 && bpbSector[12] >= 0x20 && bpbSector[13] >= 0x20 &&
bpbSector[14] >= 0x20 && bpbSector[15] >= 0x20 && bpbSector[16] >= 0x20 &&
bpbSector[17] >= 0x20;
// Check correct branch for Human68k
bool humanBranchCorrect = bpbSector[0] == 0x60 && bpbSector[1] >= 0x20 && bpbSector[1] < 0xFE;
DicConsole.DebugWriteLine("FAT plugin", "humanClustersCorrect = {0}", humanClustersCorrect);
DicConsole.DebugWriteLine("FAT plugin", "humanOemCorrect = {0}", humanOemCorrect);
DicConsole.DebugWriteLine("FAT plugin", "humanBranchCorrect = {0}", humanBranchCorrect);
// If all Human68k checks are correct, it is a Human68k FAT16
if(humanClustersCorrect && humanOemCorrect && humanBranchCorrect && expectedClusters > 0) return true;
Array.Copy(bpbSector, 0x02, atariOem, 0, 6);
2018-02-01 01:19:19 +00:00
Array.Copy(bpbSector, 0x03, dosOem, 0, 8);
bps = BitConverter.ToUInt16(bpbSector, 0x00B);
spc = bpbSector[0x00D];
reservedSecs = BitConverter.ToUInt16(bpbSector, 0x00E);
numberOfFats = bpbSector[0x010];
rootEntries = BitConverter.ToUInt16(bpbSector, 0x011);
sectors = BitConverter.ToUInt16(bpbSector, 0x013);
mediaDescriptor = bpbSector[0x015];
2018-02-01 01:19:19 +00:00
fatSectors = BitConverter.ToUInt16(bpbSector, 0x016);
Array.Copy(bpbSector, 0x052, msxId, 0, 6);
2018-02-01 01:19:19 +00:00
bigSectors = BitConverter.ToUInt32(bpbSector, 0x020);
bpbSignature = bpbSector[0x026];
fat32Signature = bpbSector[0x042];
Array.Copy(bpbSector, 0x052, fat32Id, 0, 8);
hugeSectors = BitConverter.ToUInt64(bpbSector, 0x052);
fatId = fatSector[0];
2018-02-01 01:19:19 +00:00
int bitsInBps = CountBits.Count(bps);
if(imagePlugin.Info.SectorSize >= 512) bootable = BitConverter.ToUInt16(bpbSector, 0x1FE);
bool correctSpc = spc == 1 || spc == 2 || spc == 4 || spc == 8 || spc == 16 || spc == 32 || spc == 64;
string msxString = Encoding.ASCII.GetString(msxId);
string fat32String = Encoding.ASCII.GetString(fat32Id);
bool atariOemCorrect = atariOem[0] >= 0x20 && atariOem[1] >= 0x20 && atariOem[2] >= 0x20 &&
atariOem[3] >= 0x20 && atariOem[4] >= 0x20 && atariOem[5] >= 0x20;
bool dosOemCorrect = dosOem[0] >= 0x20 && dosOem[1] >= 0x20 && dosOem[2] >= 0x20 && dosOem[3] >= 0x20 &&
dosOem[4] >= 0x20 && dosOem[5] >= 0x20 && dosOem[6] >= 0x20 && dosOem[7] >= 0x20;
string atariString = Encoding.ASCII.GetString(atariOem);
2018-02-01 01:19:19 +00:00
string oemString = Encoding.ASCII.GetString(dosOem);
DicConsole.DebugWriteLine("FAT plugin", "atari_oem_correct = {0}", atariOemCorrect);
DicConsole.DebugWriteLine("FAT plugin", "dos_oem_correct = {0}", dosOemCorrect);
DicConsole.DebugWriteLine("FAT plugin", "bps = {0}", bps);
DicConsole.DebugWriteLine("FAT plugin", "bits in bps = {0}", bitsInBps);
DicConsole.DebugWriteLine("FAT plugin", "spc = {0}", spc);
DicConsole.DebugWriteLine("FAT plugin", "correct_spc = {0}", correctSpc);
DicConsole.DebugWriteLine("FAT plugin", "reserved_secs = {0}", reservedSecs);
DicConsole.DebugWriteLine("FAT plugin", "fats_no = {0}", numberOfFats);
DicConsole.DebugWriteLine("FAT plugin", "root_entries = {0}", rootEntries);
DicConsole.DebugWriteLine("FAT plugin", "sectors = {0}", sectors);
DicConsole.DebugWriteLine("FAT plugin", "media_descriptor = 0x{0:X2}", mediaDescriptor);
2018-02-01 01:19:19 +00:00
DicConsole.DebugWriteLine("FAT plugin", "fat_sectors = {0}", fatSectors);
DicConsole.DebugWriteLine("FAT plugin", "msx_id = \"{0}\"", msxString);
DicConsole.DebugWriteLine("FAT plugin", "big_sectors = {0}", bigSectors);
DicConsole.DebugWriteLine("FAT plugin", "bpb_signature = 0x{0:X2}", bpbSignature);
DicConsole.DebugWriteLine("FAT plugin", "fat32_signature = 0x{0:X2}", fat32Signature);
DicConsole.DebugWriteLine("FAT plugin", "fat32_id = \"{0}\"", fat32String);
DicConsole.DebugWriteLine("FAT plugin", "huge_sectors = {0}", hugeSectors);
DicConsole.DebugWriteLine("FAT plugin", "fat_id = 0x{0:X2}", fatId);
ushort apricotBps = BitConverter.ToUInt16(bpbSector, 0x50);
byte apricotSpc = bpbSector[0x52];
ushort apricotReservedSecs = BitConverter.ToUInt16(bpbSector, 0x53);
byte apricotFatsNo = bpbSector[0x55];
ushort apricotRootEntries = BitConverter.ToUInt16(bpbSector, 0x56);
ushort apricotSectors = BitConverter.ToUInt16(bpbSector, 0x58);
byte apricotMediaDescriptor = bpbSector[0x5A];
ushort apricotFatSectors = BitConverter.ToUInt16(bpbSector, 0x5B);
bool apricotCorrectSpc = apricotSpc == 1 || apricotSpc == 2 || apricotSpc == 4 || apricotSpc == 8 ||
apricotSpc == 16 || apricotSpc == 32 || apricotSpc == 64;
2018-02-01 01:19:19 +00:00
int bitsInApricotBps = CountBits.Count(apricotBps);
byte apricotPartitions = bpbSector[0x0C];
2018-02-01 01:19:19 +00:00
DicConsole.DebugWriteLine("FAT plugin", "apricot_bps = {0}", apricotBps);
DicConsole.DebugWriteLine("FAT plugin", "apricot_spc = {0}", apricotSpc);
DicConsole.DebugWriteLine("FAT plugin", "apricot_correct_spc = {0}", apricotCorrectSpc);
DicConsole.DebugWriteLine("FAT plugin", "apricot_reserved_secs = {0}", apricotReservedSecs);
DicConsole.DebugWriteLine("FAT plugin", "apricot_fats_no = {0}", apricotFatsNo);
DicConsole.DebugWriteLine("FAT plugin", "apricot_root_entries = {0}", apricotRootEntries);
DicConsole.DebugWriteLine("FAT plugin", "apricot_sectors = {0}", apricotSectors);
DicConsole.DebugWriteLine("FAT plugin", "apricot_media_descriptor = 0x{0:X2}", apricotMediaDescriptor);
2018-02-01 01:19:19 +00:00
DicConsole.DebugWriteLine("FAT plugin", "apricot_fat_sectors = {0}", apricotFatSectors);
2017-09-22 23:57:53 +01:00
// This is to support FAT partitions on hybrid ISO/USB images
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
{
2018-02-01 01:19:19 +00:00
sectors /= 4;
bigSectors /= 4;
hugeSectors /= 4;
}
switch(oemString)
{
// exFAT
case "EXFAT ": return false;
// NTFS
case "NTFS " when bootable == 0xAA55 && numberOfFats == 0 && fatSectors == 0: return false;
// QNX4
case "FQNX4FS ": return false;
}
// HPFS
2017-07-23 19:58:11 +01:00
if(16 + partition.Start <= partition.End)
{
byte[] hpfsSbSector =
2017-12-19 20:33:03 +00:00
imagePlugin.ReadSector(16 + partition.Start); // Seek to superblock, on logical sector 16
2018-06-20 22:22:21 +01:00
uint hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000);
uint hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004);
if(hpfsMagic1 == 0xF995E849 && hpfsMagic2 == 0xFA53E9C5) return false;
2017-07-23 19:58:11 +01:00
}
switch(bitsInBps)
{
// FAT32 for sure
2018-02-01 01:19:19 +00:00
case 1 when correctSpc && numberOfFats <= 2 && sectors == 0 && fatSectors == 0 &&
fat32Signature == 0x29 && fat32String == "FAT32 ": return true;
// short FAT32
case 1
when correctSpc && numberOfFats <= 2 && sectors == 0 && fatSectors == 0 && fat32Signature == 0x28:
2018-02-01 01:19:19 +00:00
return bigSectors == 0
? hugeSectors <= partition.End - partition.Start + 1
2018-02-01 01:19:19 +00:00
: bigSectors <= partition.End - partition.Start + 1;
// MSX-DOS FAT12
2018-02-01 01:19:19 +00:00
case 1 when correctSpc && numberOfFats <= 2 && rootEntries > 0 &&
sectors <= partition.End - partition.Start + 1 && fatSectors > 0 &&
msxString == "VOL_ID": return true;
// EBPB
case 1 when correctSpc && numberOfFats <= 2 && rootEntries > 0 && fatSectors > 0 &&
(bpbSignature == 0x28 || bpbSignature == 0x29):
return sectors == 0
? bigSectors <= partition.End - partition.Start + 1
: sectors <= partition.End - partition.Start + 1;
// BPB
case 1 when correctSpc && reservedSecs < partition.End - partition.Start && numberOfFats <= 2 &&
2018-02-01 01:19:19 +00:00
rootEntries > 0 && fatSectors > 0:
return sectors == 0
? bigSectors <= partition.End - partition.Start + 1
: sectors <= partition.End - partition.Start + 1;
}
2017-09-22 23:57:53 +01:00
// Apricot BPB
2018-02-01 01:19:19 +00:00
if(bitsInApricotBps == 1 && apricotCorrectSpc &&
apricotReservedSecs < partition.End - partition.Start &&
apricotFatsNo <= 2 &&
apricotRootEntries > 0 && apricotFatSectors > 0 &&
apricotSectors <= partition.End - partition.Start + 1 &&
apricotPartitions == 0) return true;
2017-09-22 23:57:53 +01:00
// All FAT12 without BPB can only be used on floppies, without partitions.
2017-12-19 20:33:03 +00:00
if(partition.Start != 0) return false;
// DEC Rainbow, lacks a BPB but has a very concrete structure...
if(imagePlugin.Info.Sectors == 800 && imagePlugin.Info.SectorSize == 512)
{
// DEC Rainbow boots up with a Z80, first byte should be DI (disable interrupts)
byte z80Di = bpbSector[0];
// First FAT1 sector resides at LBA 0x14
byte[] fat1Sector0 = imagePlugin.ReadSector(0x14);
// First FAT2 sector resides at LBA 0x1A
byte[] fat2Sector0 = imagePlugin.ReadSector(0x1A);
2018-02-01 01:19:19 +00:00
bool equalFatIds = fat1Sector0[0] == fat2Sector0[0] && fat1Sector0[1] == fat2Sector0[1];
// Volume is software interleaved 2:1
MemoryStream rootMs = new MemoryStream();
2017-12-26 06:46:28 +00:00
foreach(byte[] tmp in from ulong rootSector in new ulong[] {0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20}
select imagePlugin.ReadSector(rootSector)) rootMs.Write(tmp, 0, tmp.Length);
2017-12-19 20:33:03 +00:00
2018-02-01 01:19:19 +00:00
byte[] rootDir = rootMs.ToArray();
bool validRootDir = true;
// Iterate all root directory
for(int e = 0; e < 96 * 32; e += 32)
{
for(int c = 0; c < 11; c++)
if(rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05 ||
2018-02-01 01:19:19 +00:00
rootDir[c + e] == 0xFF ||
rootDir[c + e] == 0x2E)
{
validRootDir = false;
break;
}
if(!validRootDir) break;
}
if(z80Di == 0xF3 && equalFatIds && (fat1Sector0[0] & 0xF0) == 0xF0 && fat1Sector0[1] == 0xFF &&
validRootDir) return true;
}
2018-02-01 01:19:19 +00:00
byte fat2 = fatSector[1];
byte fat3 = fatSector[2];
ushort fat2ndCluster = (ushort)(((fat2 << 8) + fat3) & 0xFFF);
DicConsole.DebugWriteLine("FAT plugin", "1st fat cluster 1 = {0:X3}", fat2ndCluster);
if(fat2ndCluster < 0xFF0) return false;
ulong fat2SectorNo = 0;
switch(fatId)
{
case 0xE5:
if(imagePlugin.Info.Sectors == 2002 && imagePlugin.Info.SectorSize == 128) fat2SectorNo = 2;
break;
case 0xFD:
2018-02-01 01:19:19 +00:00
if(imagePlugin.Info.Sectors == 4004 && imagePlugin.Info.SectorSize == 128) fat2SectorNo = 7;
else if(imagePlugin.Info.Sectors == 2002 && imagePlugin.Info.SectorSize == 128) fat2SectorNo = 7;
break;
case 0xFE:
if(imagePlugin.Info.Sectors == 320 && imagePlugin.Info.SectorSize == 512) fat2SectorNo = 2;
else if(imagePlugin.Info.Sectors == 2002 && imagePlugin.Info.SectorSize == 128) fat2SectorNo = 7;
else if(imagePlugin.Info.Sectors == 1232 && imagePlugin.Info.SectorSize == 1024) fat2SectorNo = 3;
else if(imagePlugin.Info.Sectors == 616 && imagePlugin.Info.SectorSize == 1024) fat2SectorNo = 2;
else if(imagePlugin.Info.Sectors == 720 && imagePlugin.Info.SectorSize == 128) fat2SectorNo = 5;
else if(imagePlugin.Info.Sectors == 640 && imagePlugin.Info.SectorSize == 512) fat2SectorNo = 2;
break;
case 0xFF:
if(imagePlugin.Info.Sectors == 640 && imagePlugin.Info.SectorSize == 512) fat2SectorNo = 2;
break;
default:
if(fatId < 0xE8) return false;
2017-12-19 20:33:03 +00:00
fat2SectorNo = 2;
break;
}
if(fat2SectorNo > partition.End) return false;
DicConsole.DebugWriteLine("FAT plugin", "2nd fat starts at = {0}", fat2SectorNo);
byte[] fat2Sector = imagePlugin.ReadSector(fat2SectorNo);
2018-02-01 01:19:19 +00:00
fat2 = fat2Sector[1];
fat3 = fat2Sector[2];
fat2ndCluster = (ushort)(((fat2 << 8) + fat3) & 0xFFF);
if(fat2ndCluster < 0xFF0) return false;
return fatId == fat2Sector[0];
}
2017-12-26 08:01:40 +00:00
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
2018-02-01 01:19:19 +00:00
Encoding encoding)
{
2018-02-01 01:19:19 +00:00
Encoding = encoding ?? Encoding.GetEncoding("IBM437");
information = "";
StringBuilder sb = new StringBuilder();
XmlFsType = new FileSystemType();
2018-02-01 01:19:19 +00:00
bool useAtariBpb = false;
bool useMsxBpb = false;
bool useDos2Bpb = false;
bool useDos3Bpb = false;
bool useDos32Bpb = false;
bool useDos33Bpb = false;
bool userShortExtendedBpb = false;
2018-02-01 01:19:19 +00:00
bool useExtendedBpb = false;
bool useShortFat32 = false;
bool useLongFat32 = false;
bool andosOemCorrect = false;
bool useApricotBpb = false;
bool useDecRainbowBpb = false;
bool useHumanBpb;
2018-02-01 01:19:19 +00:00
AtariParameterBlock atariBpb = new AtariParameterBlock();
MsxParameterBlock msxBpb = new MsxParameterBlock();
BiosParameterBlock2 dos2Bpb = new BiosParameterBlock2();
BiosParameterBlock30 dos30Bpb = new BiosParameterBlock30();
BiosParameterBlock32 dos32Bpb = new BiosParameterBlock32();
BiosParameterBlock33 dos33Bpb = new BiosParameterBlock33();
BiosParameterBlockShortEbpb shortEbpb = new BiosParameterBlockShortEbpb();
BiosParameterBlockEbpb ebpb = new BiosParameterBlockEbpb();
Fat32ParameterBlockShort shortFat32Bpb = new Fat32ParameterBlockShort();
Fat32ParameterBlock fat32Bpb = new Fat32ParameterBlock();
ApricotLabel apricotBpb = new ApricotLabel();
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
byte[] bpbSector = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb);
2019-02-27 08:49:42 +00:00
HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0;
// Check clusters for Human68k are correct
bool humanClustersCorrect = humanBpb.clusters == 0
? humanBpb.big_clusters == expectedClusters
: humanBpb.clusters == expectedClusters;
// Check OEM for Human68k is correct
bool humanOemCorrect = bpbSector[2] >= 0x20 && bpbSector[3] >= 0x20 && bpbSector[4] >= 0x20 &&
bpbSector[5] >= 0x20 && bpbSector[6] >= 0x20 && bpbSector[7] >= 0x20 &&
bpbSector[8] >= 0x20 && bpbSector[9] >= 0x20 && bpbSector[10] >= 0x20 &&
bpbSector[11] >= 0x20 && bpbSector[12] >= 0x20 && bpbSector[13] >= 0x20 &&
bpbSector[14] >= 0x20 && bpbSector[15] >= 0x20 && bpbSector[16] >= 0x20 &&
bpbSector[17] >= 0x20;
// Check correct branch for Human68k
bool humanBranchCorrect = bpbSector[0] == 0x60 && bpbSector[1] >= 0x20 && bpbSector[1] < 0xFE;
DicConsole.DebugWriteLine("FAT plugin", "humanClustersCorrect = {0}", humanClustersCorrect);
DicConsole.DebugWriteLine("FAT plugin", "humanOemCorrect = {0}", humanOemCorrect);
DicConsole.DebugWriteLine("FAT plugin", "humanBranchCorrect = {0}", humanBranchCorrect);
// If all Human68k checks are correct, it is a Human68k FAT16
useHumanBpb = humanClustersCorrect && humanOemCorrect && humanBranchCorrect && expectedClusters > 0;
if(useHumanBpb) DicConsole.DebugWriteLine("FAT plugin", "Using Human68k BPB");
2016-04-19 02:11:47 +01:00
byte minBootNearJump = 0;
if(imagePlugin.Info.SectorSize >= 256 && !useHumanBpb)
{
atariBpb = Marshal.ByteArrayToStructureLittleEndian<AtariParameterBlock>(bpbSector);
msxBpb = Marshal.ByteArrayToStructureLittleEndian<MsxParameterBlock>(bpbSector);
dos2Bpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlock2>(bpbSector);
dos30Bpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlock30>(bpbSector);
dos32Bpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlock32>(bpbSector);
dos33Bpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlock33>(bpbSector);
shortEbpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlockShortEbpb>(bpbSector);
ebpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlockEbpb>(bpbSector);
shortFat32Bpb = Marshal.ByteArrayToStructureLittleEndian<Fat32ParameterBlockShort>(bpbSector);
fat32Bpb = Marshal.ByteArrayToStructureLittleEndian<Fat32ParameterBlock>(bpbSector);
apricotBpb = Marshal.ByteArrayToStructureLittleEndian<ApricotLabel>(bpbSector);
2018-02-01 01:19:19 +00:00
int bitsInBpsAtari = CountBits.Count(atariBpb.bps);
int bitsInBpsMsx = CountBits.Count(msxBpb.bps);
int bitsInBpsDos20 = CountBits.Count(dos2Bpb.bps);
int bitsInBpsDos30 = CountBits.Count(dos30Bpb.bps);
int bitsInBpsDos32 = CountBits.Count(dos32Bpb.bps);
int bitsInBpsDos33 = CountBits.Count(dos33Bpb.bps);
int bitsInBpsDos34 = CountBits.Count(shortEbpb.bps);
int bitsInBpsDos40 = CountBits.Count(ebpb.bps);
int bitsInBpsFat32Short = CountBits.Count(shortFat32Bpb.bps);
2018-02-01 01:19:19 +00:00
int bitsInBpsFat32 = CountBits.Count(fat32Bpb.bps);
int bitsInBpsApricot = CountBits.Count(apricotBpb.mainBPB.bps);
bool correctSpcAtari = atariBpb.spc == 1 || atariBpb.spc == 2 || atariBpb.spc == 4 ||
atariBpb.spc == 8 || atariBpb.spc == 16 || atariBpb.spc == 32 ||
atariBpb.spc == 64;
bool correctSpcMsx = msxBpb.spc == 1 || msxBpb.spc == 2 || msxBpb.spc == 4 || msxBpb.spc == 8 ||
msxBpb.spc == 16 || msxBpb.spc == 32 || msxBpb.spc == 64;
bool correctSpcDos20 = dos2Bpb.spc == 1 || dos2Bpb.spc == 2 || dos2Bpb.spc == 4 || dos2Bpb.spc == 8 ||
dos2Bpb.spc == 16 || dos2Bpb.spc == 32 || dos2Bpb.spc == 64;
bool correctSpcDos30 = dos30Bpb.spc == 1 || dos30Bpb.spc == 2 || dos30Bpb.spc == 4 ||
dos30Bpb.spc == 8 || dos30Bpb.spc == 16 || dos30Bpb.spc == 32 ||
dos30Bpb.spc == 64;
bool correctSpcDos32 = dos32Bpb.spc == 1 || dos32Bpb.spc == 2 || dos32Bpb.spc == 4 ||
dos32Bpb.spc == 8 || dos32Bpb.spc == 16 || dos32Bpb.spc == 32 ||
dos32Bpb.spc == 64;
bool correctSpcDos33 = dos33Bpb.spc == 1 || dos33Bpb.spc == 2 || dos33Bpb.spc == 4 ||
dos33Bpb.spc == 8 || dos33Bpb.spc == 16 || dos33Bpb.spc == 32 ||
dos33Bpb.spc == 64;
bool correctSpcDos34 = shortEbpb.spc == 1 || shortEbpb.spc == 2 || shortEbpb.spc == 4 ||
shortEbpb.spc == 8 || shortEbpb.spc == 16 || shortEbpb.spc == 32 ||
shortEbpb.spc == 64;
bool correctSpcDos40 = ebpb.spc == 1 || ebpb.spc == 2 || ebpb.spc == 4 || ebpb.spc == 8 ||
ebpb.spc == 16 || ebpb.spc == 32 || ebpb.spc == 64;
bool correctSpcFat32Short = shortFat32Bpb.spc == 1 || shortFat32Bpb.spc == 2 ||
shortFat32Bpb.spc == 4 || shortFat32Bpb.spc == 8 ||
shortFat32Bpb.spc == 16 || shortFat32Bpb.spc == 32 ||
shortFat32Bpb.spc == 64;
bool correctSpcFat32 = fat32Bpb.spc == 1 || fat32Bpb.spc == 2 || fat32Bpb.spc == 4 ||
fat32Bpb.spc == 8 || fat32Bpb.spc == 16 || fat32Bpb.spc == 32 ||
fat32Bpb.spc == 64;
2018-02-01 01:19:19 +00:00
bool correctSpcApricot = apricotBpb.mainBPB.spc == 1 || apricotBpb.mainBPB.spc == 2 ||
apricotBpb.mainBPB.spc == 4 || apricotBpb.mainBPB.spc == 8 ||
apricotBpb.mainBPB.spc == 16 || apricotBpb.mainBPB.spc == 32 ||
apricotBpb.mainBPB.spc == 64;
// This is to support FAT partitions on hybrid ISO/USB images
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
{
2018-02-01 01:19:19 +00:00
atariBpb.sectors /= 4;
msxBpb.sectors /= 4;
dos2Bpb.sectors /= 4;
dos30Bpb.sectors /= 4;
dos32Bpb.sectors /= 4;
dos33Bpb.sectors /= 4;
dos33Bpb.big_sectors /= 4;
shortEbpb.sectors /= 4;
shortEbpb.big_sectors /= 4;
ebpb.sectors /= 4;
ebpb.big_sectors /= 4;
shortFat32Bpb.sectors /= 4;
shortFat32Bpb.big_sectors /= 4;
shortFat32Bpb.huge_sectors /= 4;
2018-02-01 01:19:19 +00:00
fat32Bpb.sectors /= 4;
fat32Bpb.big_sectors /= 4;
apricotBpb.mainBPB.sectors /= 4;
}
2018-02-01 01:19:19 +00:00
andosOemCorrect = dos33Bpb.oem_name[0] < 0x20 && dos33Bpb.oem_name[1] >= 0x20 &&
dos33Bpb.oem_name[2] >= 0x20 && dos33Bpb.oem_name[3] >= 0x20 &&
dos33Bpb.oem_name[4] >= 0x20 && dos33Bpb.oem_name[5] >= 0x20 &&
dos33Bpb.oem_name[6] >= 0x20 && dos33Bpb.oem_name[7] >= 0x20;
2017-08-25 03:28:55 +01:00
2018-02-01 01:19:19 +00:00
if(bitsInBpsFat32 == 1 && correctSpcFat32 && fat32Bpb.fats_no <= 2 &&
fat32Bpb.sectors == 0 &&
fat32Bpb.spfat == 0 && fat32Bpb.signature == 0x29 &&
Encoding.ASCII.GetString(fat32Bpb.fs_type) == "FAT32 ")
{
DicConsole.DebugWriteLine("FAT plugin", "Using FAT32 BPB");
2018-02-01 01:19:19 +00:00
useLongFat32 = true;
minBootNearJump = 0x58;
}
2018-02-01 01:19:19 +00:00
else if(bitsInBpsFat32Short == 1 && correctSpcFat32Short && shortFat32Bpb.fats_no <= 2 &&
shortFat32Bpb.sectors == 0 && shortFat32Bpb.spfat == 0 &&
shortFat32Bpb.signature == 0x28)
{
DicConsole.DebugWriteLine("FAT plugin", "Using short FAT32 BPB");
2018-02-01 01:19:19 +00:00
useShortFat32 = shortFat32Bpb.big_sectors == 0
? shortFat32Bpb.huge_sectors <= partition.End - partition.Start + 1
2018-02-01 01:19:19 +00:00
: shortFat32Bpb.big_sectors <= partition.End - partition.Start + 1;
minBootNearJump = 0x57;
}
2018-02-01 01:19:19 +00:00
else if(bitsInBpsMsx == 1 &&
correctSpcMsx && msxBpb.fats_no <= 2 && msxBpb.root_ent > 0 &&
msxBpb.sectors <= partition.End - partition.Start + 1 &&
msxBpb.spfat > 0 &&
Encoding.ASCII.GetString(msxBpb.vol_id) == "VOL_ID")
{
DicConsole.DebugWriteLine("FAT plugin", "Using MSX BPB");
useMsxBpb = true;
}
2018-02-01 01:19:19 +00:00
else if(bitsInBpsApricot == 1 && correctSpcApricot &&
apricotBpb.mainBPB.fats_no <= 2 &&
apricotBpb.mainBPB.root_ent > 0 &&
apricotBpb.mainBPB.sectors <= partition.End - partition.Start + 1 &&
apricotBpb.mainBPB.spfat > 0 &&
apricotBpb.partitionCount == 0)
2017-09-22 23:57:53 +01:00
{
DicConsole.DebugWriteLine("FAT plugin", "Using Apricot BPB");
useApricotBpb = true;
2017-09-22 23:57:53 +01:00
}
else if(bitsInBpsDos40 == 1 && correctSpcDos40 && ebpb.fats_no <= 2 && ebpb.root_ent > 0 &&
ebpb.spfat > 0 && (ebpb.signature == 0x28 || ebpb.signature == 0x29 || andosOemCorrect))
{
if(ebpb.sectors == 0)
{
if(ebpb.big_sectors <= partition.End - partition.Start + 1)
if(ebpb.signature == 0x29 || andosOemCorrect)
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 4.0 BPB");
2018-02-01 01:19:19 +00:00
useExtendedBpb = true;
minBootNearJump = 0x3C;
}
else
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.4 BPB");
userShortExtendedBpb = true;
2018-02-01 01:19:19 +00:00
minBootNearJump = 0x29;
}
}
else if(ebpb.sectors <= partition.End - partition.Start + 1)
if(ebpb.signature == 0x29 || andosOemCorrect)
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 4.0 BPB");
2018-02-01 01:19:19 +00:00
useExtendedBpb = true;
minBootNearJump = 0x3C;
}
else
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.4 BPB");
userShortExtendedBpb = true;
2018-02-01 01:19:19 +00:00
minBootNearJump = 0x29;
}
}
else if(bitsInBpsDos33 == 1 && correctSpcDos33 &&
dos33Bpb.rsectors < partition.End - partition.Start &&
dos33Bpb.fats_no <= 2 &&
dos33Bpb.root_ent > 0 && dos33Bpb.spfat > 0)
if(dos33Bpb.sectors == 0 && dos33Bpb.hsectors <= partition.Start && dos33Bpb.big_sectors > 0 &&
dos33Bpb.big_sectors <= partition.End - partition.Start + 1)
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.3 BPB");
2018-02-01 01:19:19 +00:00
useDos33Bpb = true;
minBootNearJump = 0x22;
}
else if(dos33Bpb.big_sectors == 0 && dos33Bpb.hsectors <= partition.Start && dos33Bpb.sectors > 0 &&
dos33Bpb.sectors <= partition.End - partition.Start + 1)
if(atariBpb.jump[0] == 0x60 || atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 &&
Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ")
{
DicConsole.DebugWriteLine("FAT plugin", "Using Atari BPB");
useAtariBpb = true;
}
else
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.3 BPB");
2018-02-01 01:19:19 +00:00
useDos33Bpb = true;
minBootNearJump = 0x22;
}
else
{
2018-02-01 01:19:19 +00:00
if(dos32Bpb.hsectors <= partition.Start &&
dos32Bpb.hsectors + dos32Bpb.sectors == dos32Bpb.total_sectors)
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.2 BPB");
2018-02-01 01:19:19 +00:00
useDos32Bpb = true;
minBootNearJump = 0x1E;
}
else if(dos30Bpb.sptrk > 0 && dos30Bpb.sptrk < 64 && dos30Bpb.heads > 0 && dos30Bpb.heads < 256)
if(atariBpb.jump[0] == 0x60 || atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 &&
Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ")
{
DicConsole.DebugWriteLine("FAT plugin", "Using Atari BPB");
useAtariBpb = true;
}
else
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 3.0 BPB");
2018-02-01 01:19:19 +00:00
useDos3Bpb = true;
minBootNearJump = 0x1C;
}
else
{
if(atariBpb.jump[0] == 0x60 || atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 &&
Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ")
{
DicConsole.DebugWriteLine("FAT plugin", "Using Atari BPB");
useAtariBpb = true;
}
else
{
DicConsole.DebugWriteLine("FAT plugin", "Using DOS 2.0 BPB");
2018-02-01 01:19:19 +00:00
useDos2Bpb = true;
minBootNearJump = 0x16;
}
}
}
}
2018-02-01 01:19:19 +00:00
BiosParameterBlockEbpb fakeBpb = new BiosParameterBlockEbpb();
bool isFat12 = false;
bool isFat16 = false;
bool isFat32 = false;
ulong rootDirectorySector = 0;
string extraInfo = null;
string bootChk = null;
// This is needed because for FAT16, GEMDOS increases bytes per sector count instead of using big_sectors field.
uint sectorsPerRealSector;
// This is needed because some OSes don't put volume label as first entry in the root directory
uint sectorsForRootDirectory = 0;
2016-04-19 02:11:47 +01:00
// DEC Rainbow, lacks a BPB but has a very concrete structure...
2018-02-01 01:19:19 +00:00
if(imagePlugin.Info.Sectors == 800 && imagePlugin.Info.SectorSize == 512 && !useAtariBpb && !useMsxBpb &&
!useDos2Bpb && !useDos3Bpb && !useDos32Bpb && !useDos33Bpb &&
!userShortExtendedBpb && !useExtendedBpb &&
!useHumanBpb && !useShortFat32 && !useLongFat32 && !useApricotBpb)
{
// DEC Rainbow boots up with a Z80, first byte should be DI (disable interrupts)
byte z80Di = bpbSector[0];
// First FAT1 sector resides at LBA 0x14
byte[] fat1Sector0 = imagePlugin.ReadSector(0x14);
// First FAT2 sector resides at LBA 0x1A
byte[] fat2Sector0 = imagePlugin.ReadSector(0x1A);
2018-02-01 01:19:19 +00:00
bool equalFatIds = fat1Sector0[0] == fat2Sector0[0] && fat1Sector0[1] == fat2Sector0[1];
// Volume is software interleaved 2:1
MemoryStream rootMs = new MemoryStream();
foreach(byte[] tmp in from ulong rootSector in new[] {0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20}
select imagePlugin.ReadSector(rootSector)) rootMs.Write(tmp, 0, tmp.Length);
2017-12-19 20:33:03 +00:00
2018-02-01 01:19:19 +00:00
byte[] rootDir = rootMs.ToArray();
bool validRootDir = true;
// Iterate all root directory
for(int e = 0; e < 96 * 32; e += 32)
{
for(int c = 0; c < 11; c++)
if(rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05 ||
2018-02-01 01:19:19 +00:00
rootDir[c + e] == 0xFF ||
rootDir[c + e] == 0x2E)
{
validRootDir = false;
break;
}
if(!validRootDir) break;
}
if(z80Di == 0xF3 && equalFatIds && (fat1Sector0[0] & 0xF0) == 0xF0 && fat1Sector0[1] == 0xFF &&
validRootDir)
{
useDecRainbowBpb = true;
DicConsole.DebugWriteLine("FAT plugin", "Using DEC Rainbow hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 512;
fakeBpb.spc = 1;
fakeBpb.rsectors = 20;
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 96;
fakeBpb.sectors = 800;
fakeBpb.media = 0xFA;
fakeBpb.sptrk = 10;
fakeBpb.heads = 1;
fakeBpb.hsectors = 0;
fakeBpb.spfat = 3;
2017-12-26 08:01:40 +00:00
XmlFsType.Bootable = true;
2018-02-01 01:19:19 +00:00
fakeBpb.boot_code = bpbSector;
isFat12 = true;
}
}
if(!useAtariBpb && !useMsxBpb && !useDos2Bpb && !useDos3Bpb && !useDos32Bpb &&
!useDos33Bpb &&
!useHumanBpb && !userShortExtendedBpb && !useExtendedBpb && !useShortFat32 && !useLongFat32 &&
!useApricotBpb && !useDecRainbowBpb)
{
isFat12 = true;
byte[] fatSector = imagePlugin.ReadSector(1 + partition.Start);
switch(fatSector[0])
{
case 0xE5:
if(imagePlugin.Info.Sectors == 2002 && imagePlugin.Info.SectorSize == 128)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 128;
fakeBpb.spc = 4;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 64;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 2002;
fakeBpb.media = 0xE5;
fakeBpb.sptrk = 26;
fakeBpb.heads = 1;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 1;
}
2018-02-01 01:19:19 +00:00
break;
case 0xFD:
if(imagePlugin.Info.Sectors == 4004 && imagePlugin.Info.SectorSize == 128)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 128;
fakeBpb.spc = 4;
fakeBpb.rsectors = 4;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 68;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 4004;
fakeBpb.media = 0xFD;
fakeBpb.sptrk = 26;
fakeBpb.heads = 2;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 6;
}
else if(imagePlugin.Info.Sectors == 2002 && imagePlugin.Info.SectorSize == 128)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 128;
fakeBpb.spc = 4;
fakeBpb.rsectors = 4;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 68;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 2002;
fakeBpb.media = 0xFD;
fakeBpb.sptrk = 26;
fakeBpb.heads = 1;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 6;
}
2018-02-01 01:19:19 +00:00
break;
case 0xFE:
if(imagePlugin.Info.Sectors == 320 && imagePlugin.Info.SectorSize == 512)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" SSDD.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 512;
fakeBpb.spc = 1;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 64;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 320;
fakeBpb.media = 0xFE;
fakeBpb.sptrk = 8;
fakeBpb.heads = 1;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 1;
}
else if(imagePlugin.Info.Sectors == 2002 && imagePlugin.Info.SectorSize == 128)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 128;
fakeBpb.spc = 4;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 68;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 2002;
fakeBpb.media = 0xFE;
fakeBpb.sptrk = 26;
fakeBpb.heads = 1;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 6;
}
else if(imagePlugin.Info.Sectors == 1232 && imagePlugin.Info.SectorSize == 1024)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 1024;
fakeBpb.spc = 1;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 192;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 1232;
fakeBpb.media = 0xFE;
fakeBpb.sptrk = 8;
fakeBpb.heads = 2;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 2;
}
else if(imagePlugin.Info.Sectors == 616 && imagePlugin.Info.SectorSize == 1024)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 1024;
fakeBpb.spc = 1;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 6192;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 616;
fakeBpb.media = 0xFE;
fakeBpb.sptrk = 8;
fakeBpb.heads = 2;
fakeBpb.hsectors = 0;
}
else if(imagePlugin.Info.Sectors == 720 && imagePlugin.Info.SectorSize == 128)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 128;
fakeBpb.spc = 2;
fakeBpb.rsectors = 54;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 64;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 720;
fakeBpb.media = 0xFE;
fakeBpb.sptrk = 18;
fakeBpb.heads = 1;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 4;
}
else if(imagePlugin.Info.Sectors == 640 && imagePlugin.Info.SectorSize == 512)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" DSDD.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 512;
fakeBpb.spc = 2;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 112;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 640;
fakeBpb.media = 0xFF;
fakeBpb.sptrk = 8;
fakeBpb.heads = 2;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 1;
}
2018-02-01 01:19:19 +00:00
break;
case 0xFF:
if(imagePlugin.Info.Sectors == 640 && imagePlugin.Info.SectorSize == 512)
{
DicConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" DSDD.");
2018-02-01 01:19:19 +00:00
fakeBpb.bps = 512;
fakeBpb.spc = 2;
fakeBpb.rsectors = 1;
2018-02-01 01:19:19 +00:00
fakeBpb.fats_no = 2;
fakeBpb.root_ent = 112;
2018-02-01 01:19:19 +00:00
fakeBpb.sectors = 640;
fakeBpb.media = 0xFF;
fakeBpb.sptrk = 8;
fakeBpb.heads = 2;
fakeBpb.hsectors = 0;
2018-02-01 01:19:19 +00:00
fakeBpb.spfat = 1;
}
2018-02-01 01:19:19 +00:00
break;
}
// This assumes a bootable sector will jump somewhere or disable interrupts in x86 code
XmlFsType.Bootable |= bpbSector[0] == 0xFA ||
bpbSector[0] == 0xEB && bpbSector[1] <= 0x7F ||
2018-02-01 01:19:19 +00:00
bpbSector[0] == 0xE9 &&
BitConverter.ToUInt16(bpbSector, 1) <= 0x1FC;
fakeBpb.boot_code = bpbSector;
}
else if(useShortFat32 || useLongFat32)
{
isFat32 = true;
// This is to support FAT partitions on hybrid ISO/USB images
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
{
2018-02-01 01:19:19 +00:00
fat32Bpb.bps *= 4;
fat32Bpb.spc /= 4;
fat32Bpb.big_spfat /= 4;
2018-02-01 01:19:19 +00:00
fat32Bpb.hsectors /= 4;
fat32Bpb.sptrk /= 4;
}
if(fat32Bpb.version != 0)
{
sb.AppendLine("FAT+");
2017-12-26 08:01:40 +00:00
XmlFsType.Type = "FAT+";
}
else
{
sb.AppendLine("Microsoft FAT32");
2017-12-26 08:01:40 +00:00
XmlFsType.Type = "FAT32";
}
if(fat32Bpb.oem_name != null)
if(fat32Bpb.oem_name[5] == 0x49 && fat32Bpb.oem_name[6] == 0x48 && fat32Bpb.oem_name[7] == 0x43)
sb.AppendLine("Volume has been modified by Windows 9x/Me Volume Tracker.");
2019-04-23 01:38:33 +01:00
else XmlFsType.SystemIdentifier = StringHandlers.CToString(fat32Bpb.oem_name);
2017-12-26 08:01:40 +00:00
if(!string.IsNullOrEmpty(XmlFsType.SystemIdentifier))
sb.AppendFormat("OEM Name: {0}", XmlFsType.SystemIdentifier.Trim()).AppendLine();
sb.AppendFormat("{0} bytes per sector.", fat32Bpb.bps).AppendLine();
sb.AppendFormat("{0} sectors per cluster.", fat32Bpb.spc).AppendLine();
2019-04-23 01:38:33 +01:00
XmlFsType.ClusterSize = (uint)(fat32Bpb.bps * fat32Bpb.spc);
sb.AppendFormat("{0} sectors reserved between BPB and FAT.", fat32Bpb.rsectors).AppendLine();
if(fat32Bpb.big_sectors == 0 && fat32Bpb.signature == 0x28)
{
sb.AppendFormat("{0} sectors on volume ({1} bytes).", shortFat32Bpb.huge_sectors,
shortFat32Bpb.huge_sectors * shortFat32Bpb.bps).AppendLine();
2019-04-23 01:38:33 +01:00
XmlFsType.Clusters = shortFat32Bpb.huge_sectors / shortFat32Bpb.spc;
}
else
{
sb.AppendFormat("{0} sectors on volume ({1} bytes).", fat32Bpb.big_sectors,
fat32Bpb.big_sectors * fat32Bpb.bps).AppendLine();
2017-12-26 08:01:40 +00:00
XmlFsType.Clusters = fat32Bpb.big_sectors / fat32Bpb.spc;
}
2018-02-01 01:19:19 +00:00
sb.AppendFormat("{0} clusters on volume.", XmlFsType.Clusters).AppendLine();
sb.AppendFormat("Media descriptor: 0x{0:X2}", fat32Bpb.media).AppendLine();
sb.AppendFormat("{0} sectors per FAT.", fat32Bpb.big_spfat).AppendLine();
sb.AppendFormat("{0} sectors per track.", fat32Bpb.sptrk).AppendLine();
sb.AppendFormat("{0} heads.", fat32Bpb.heads).AppendLine();
sb.AppendFormat("{0} hidden sectors before BPB.", fat32Bpb.hsectors).AppendLine();
sb.AppendFormat("Cluster of root directory: {0}", fat32Bpb.root_cluster).AppendLine();
sb.AppendFormat("Sector of FSINFO structure: {0}", fat32Bpb.fsinfo_sector).AppendLine();
sb.AppendFormat("Sector of backup FAT32 parameter block: {0}", fat32Bpb.backup_sector).AppendLine();
sb.AppendFormat("Drive number: 0x{0:X2}", fat32Bpb.drive_no).AppendLine();
sb.AppendFormat("Volume Serial Number: 0x{0:X8}", fat32Bpb.serial_no).AppendLine();
2017-12-26 08:01:40 +00:00
XmlFsType.VolumeSerial = $"{fat32Bpb.serial_no:X8}";
if((fat32Bpb.flags & 0xF8) == 0x00)
{
if((fat32Bpb.flags & 0x01) == 0x01)
2016-09-13 12:58:19 +01:00
{
sb.AppendLine("Volume should be checked on next mount.");
2017-12-26 08:01:40 +00:00
XmlFsType.Dirty = true;
2016-09-13 12:58:19 +01:00
}
2018-02-01 01:19:19 +00:00
if((fat32Bpb.flags & 0x02) == 0x02) sb.AppendLine("Disk surface should be on next mount.");
}
if((fat32Bpb.mirror_flags & 0x80) == 0x80)
sb.AppendFormat("FATs are out of sync. FAT #{0} is in use.", fat32Bpb.mirror_flags & 0xF)
2017-12-19 20:33:03 +00:00
.AppendLine();
else sb.AppendLine("All copies of FAT are the same.");
2018-02-01 01:19:19 +00:00
if((fat32Bpb.mirror_flags & 0x6F20) == 0x6F20)
sb.AppendLine("DR-DOS will boot this FAT32 using CHS.");
else if((fat32Bpb.mirror_flags & 0x4F20) == 0x4F20)
sb.AppendLine("DR-DOS will boot this FAT32 using LBA.");
if(fat32Bpb.signature == 0x29)
{
2017-12-26 08:01:40 +00:00
XmlFsType.VolumeName = Encoding.ASCII.GetString(fat32Bpb.volume_label);
sb.AppendFormat("Filesystem type: {0}", Encoding.ASCII.GetString(fat32Bpb.fs_type)).AppendLine();
bootChk = Sha1Context.Data(fat32Bpb.boot_code, out _);
}
else bootChk = Sha1Context.Data(shortFat32Bpb.boot_code, out _);
// Check that jumps to a correct boot code position and has boot signature set.
// This will mean that the volume will boot, even if just to say "this is not bootable change disk"......
2018-02-01 01:19:19 +00:00
XmlFsType.Bootable |=
fat32Bpb.jump[0] == 0xEB && fat32Bpb.jump[1] >= minBootNearJump && fat32Bpb.jump[1] < 0x80 ||
fat32Bpb.jump[0] == 0xE9 && fat32Bpb.jump.Length >= 3 &&
2018-02-01 01:19:19 +00:00
BitConverter.ToUInt16(fat32Bpb.jump, 1) >= minBootNearJump &&
BitConverter.ToUInt16(fat32Bpb.jump, 1) <= 0x1FC;
sectorsPerRealSector = fat32Bpb.bps / imagePlugin.Info.SectorSize;
// First root directory sector
rootDirectorySector =
(ulong)((fat32Bpb.root_cluster - 2) * fat32Bpb.spc + fat32Bpb.big_spfat * fat32Bpb.fats_no +
fat32Bpb.rsectors) * sectorsPerRealSector;
sectorsForRootDirectory = 1;
if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End)
{
byte[] fsinfoSector = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start);
FsInfoSector fsInfo = Marshal.ByteArrayToStructureLittleEndian<FsInfoSector>(fsinfoSector);
if(fsInfo.signature1 == FSINFO_SIGNATURE1 && fsInfo.signature2 == FSINFO_SIGNATURE2 &&
fsInfo.signature3 == FSINFO_SIGNATURE3)
2016-09-13 12:58:19 +01:00
{
if(fsInfo.free_clusters < 0xFFFFFFFF)
{
sb.AppendFormat("{0} free clusters", fsInfo.free_clusters).AppendLine();
2018-02-01 01:19:19 +00:00
XmlFsType.FreeClusters = fsInfo.free_clusters;
2017-12-26 08:01:40 +00:00
XmlFsType.FreeClustersSpecified = true;
}
if(fsInfo.last_cluster > 2 && fsInfo.last_cluster < 0xFFFFFFFF)
sb.AppendFormat("Last allocated cluster {0}", fsInfo.last_cluster).AppendLine();
2016-09-13 12:58:19 +01:00
}
}
}
else if(useExtendedBpb) fakeBpb = ebpb;
else if(userShortExtendedBpb)
{
2018-02-01 01:19:19 +00:00
fakeBpb.jump = shortEbpb.jump;
fakeBpb.oem_name = shortEbpb.oem_name;
fakeBpb.bps = shortEbpb.bps;
fakeBpb.spc = shortEbpb.spc;
fakeBpb.rsectors = shortEbpb.rsectors;
fakeBpb.fats_no = shortEbpb.fats_no;
fakeBpb.root_ent = shortEbpb.root_ent;
fakeBpb.sectors = shortEbpb.sectors;
fakeBpb.media = shortEbpb.media;
fakeBpb.spfat = shortEbpb.spfat;
fakeBpb.sptrk = shortEbpb.sptrk;
fakeBpb.heads = shortEbpb.heads;
fakeBpb.hsectors = shortEbpb.hsectors;
fakeBpb.big_sectors = shortEbpb.big_sectors;
fakeBpb.drive_no = shortEbpb.drive_no;
fakeBpb.flags = shortEbpb.flags;
fakeBpb.signature = shortEbpb.signature;
fakeBpb.serial_no = shortEbpb.serial_no;
fakeBpb.boot_code = shortEbpb.boot_code;
fakeBpb.boot_signature = shortEbpb.boot_signature;
}
else if(useDos33Bpb)
{
2018-02-01 01:19:19 +00:00
fakeBpb.jump = dos33Bpb.jump;
fakeBpb.oem_name = dos33Bpb.oem_name;
fakeBpb.bps = dos33Bpb.bps;
fakeBpb.spc = dos33Bpb.spc;
fakeBpb.rsectors = dos33Bpb.rsectors;
fakeBpb.fats_no = dos33Bpb.fats_no;
fakeBpb.root_ent = dos33Bpb.root_ent;
fakeBpb.sectors = dos33Bpb.sectors;
fakeBpb.media = dos33Bpb.media;
fakeBpb.spfat = dos33Bpb.spfat;
fakeBpb.sptrk = dos33Bpb.sptrk;
fakeBpb.heads = dos33Bpb.heads;
fakeBpb.hsectors = dos33Bpb.hsectors;
fakeBpb.big_sectors = dos33Bpb.big_sectors;
fakeBpb.boot_code = dos33Bpb.boot_code;
fakeBpb.boot_signature = dos33Bpb.boot_signature;
}
else if(useDos32Bpb)
{
2018-02-01 01:19:19 +00:00
fakeBpb.jump = dos32Bpb.jump;
fakeBpb.oem_name = dos32Bpb.oem_name;
fakeBpb.bps = dos32Bpb.bps;
fakeBpb.spc = dos32Bpb.spc;
fakeBpb.rsectors = dos32Bpb.rsectors;
fakeBpb.fats_no = dos32Bpb.fats_no;
fakeBpb.root_ent = dos32Bpb.root_ent;
fakeBpb.sectors = dos32Bpb.sectors;
fakeBpb.media = dos32Bpb.media;
fakeBpb.spfat = dos32Bpb.spfat;
fakeBpb.sptrk = dos32Bpb.sptrk;
fakeBpb.heads = dos32Bpb.heads;
fakeBpb.hsectors = dos32Bpb.hsectors;
fakeBpb.boot_code = dos32Bpb.boot_code;
fakeBpb.boot_signature = dos32Bpb.boot_signature;
}
else if(useDos3Bpb)
{
2018-02-01 01:19:19 +00:00
fakeBpb.jump = dos30Bpb.jump;
fakeBpb.oem_name = dos30Bpb.oem_name;
fakeBpb.bps = dos30Bpb.bps;
fakeBpb.spc = dos30Bpb.spc;
fakeBpb.rsectors = dos30Bpb.rsectors;
fakeBpb.fats_no = dos30Bpb.fats_no;
fakeBpb.root_ent = dos30Bpb.root_ent;
fakeBpb.sectors = dos30Bpb.sectors;
fakeBpb.media = dos30Bpb.media;
fakeBpb.spfat = dos30Bpb.spfat;
fakeBpb.sptrk = dos30Bpb.sptrk;
fakeBpb.heads = dos30Bpb.heads;
fakeBpb.hsectors = dos30Bpb.hsectors;
fakeBpb.boot_code = dos30Bpb.boot_code;
fakeBpb.boot_signature = dos30Bpb.boot_signature;
}
else if(useDos2Bpb)
{
2018-02-01 01:19:19 +00:00
fakeBpb.jump = dos2Bpb.jump;
fakeBpb.oem_name = dos2Bpb.oem_name;
fakeBpb.bps = dos2Bpb.bps;
fakeBpb.spc = dos2Bpb.spc;
fakeBpb.rsectors = dos2Bpb.rsectors;
fakeBpb.fats_no = dos2Bpb.fats_no;
fakeBpb.root_ent = dos2Bpb.root_ent;
fakeBpb.sectors = dos2Bpb.sectors;
fakeBpb.media = dos2Bpb.media;
fakeBpb.spfat = dos2Bpb.spfat;
fakeBpb.boot_code = dos2Bpb.boot_code;
fakeBpb.boot_signature = dos2Bpb.boot_signature;
}
else if(useMsxBpb)
{
2018-02-01 01:19:19 +00:00
isFat12 = true;
fakeBpb.jump = msxBpb.jump;
fakeBpb.oem_name = msxBpb.oem_name;
fakeBpb.bps = msxBpb.bps;
fakeBpb.spc = msxBpb.spc;
fakeBpb.rsectors = msxBpb.rsectors;
fakeBpb.fats_no = msxBpb.fats_no;
fakeBpb.root_ent = msxBpb.root_ent;
fakeBpb.sectors = msxBpb.sectors;
fakeBpb.media = msxBpb.media;
fakeBpb.spfat = msxBpb.spfat;
fakeBpb.sptrk = msxBpb.sptrk;
fakeBpb.heads = msxBpb.heads;
fakeBpb.hsectors = msxBpb.hsectors;
fakeBpb.boot_code = msxBpb.boot_code;
fakeBpb.boot_signature = msxBpb.boot_signature;
2018-02-01 01:19:19 +00:00
fakeBpb.serial_no = msxBpb.serial_no;
// TODO: Is there any way to check this?
2017-12-26 08:01:40 +00:00
XmlFsType.Bootable = true;
}
else if(useAtariBpb)
{
2018-02-01 01:19:19 +00:00
fakeBpb.jump = atariBpb.jump;
fakeBpb.oem_name = atariBpb.oem_name;
fakeBpb.bps = atariBpb.bps;
fakeBpb.spc = atariBpb.spc;
fakeBpb.rsectors = atariBpb.rsectors;
fakeBpb.fats_no = atariBpb.fats_no;
fakeBpb.root_ent = atariBpb.root_ent;
fakeBpb.sectors = atariBpb.sectors;
fakeBpb.media = atariBpb.media;
fakeBpb.spfat = atariBpb.spfat;
fakeBpb.sptrk = atariBpb.sptrk;
fakeBpb.heads = atariBpb.heads;
fakeBpb.boot_code = atariBpb.boot_code;
ushort sum = 0;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
for(int i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i);
// TODO: Check this
if(sum == 0x1234)
{
XmlFsType.Bootable = true;
StringBuilder atariSb = new StringBuilder();
2017-12-19 20:33:03 +00:00
atariSb.AppendFormat("cmdload will be loaded with value {0:X4}h",
BigEndianBitConverter.ToUInt16(bpbSector, 0x01E)).AppendLine();
atariSb.AppendFormat("Boot program will be loaded at address {0:X4}h", atariBpb.ldaaddr)
2017-12-19 20:33:03 +00:00
.AppendLine();
atariSb.AppendFormat("FAT and directory will be cached at address {0:X4}h", atariBpb.fatbuf)
2017-12-19 20:33:03 +00:00
.AppendLine();
if(atariBpb.ldmode == 0)
{
byte[] tmp = new byte[8];
Array.Copy(atariBpb.fname, 0, tmp, 0, 8);
string fname = Encoding.ASCII.GetString(tmp).Trim();
tmp = new byte[3];
Array.Copy(atariBpb.fname, 8, tmp, 0, 3);
string extension = Encoding.ASCII.GetString(tmp).Trim();
string filename;
2017-12-19 20:33:03 +00:00
if(string.IsNullOrEmpty(extension)) filename = fname;
2018-02-01 01:19:19 +00:00
else filename = fname + "." + extension;
atariSb.AppendFormat("Boot program resides in file \"{0}\"", filename).AppendLine();
}
else
2017-12-19 20:33:03 +00:00
atariSb.AppendFormat("Boot program starts in sector {0} and is {1} sectors long ({2} bytes)",
atariBpb.ssect, atariBpb.sectcnt, atariBpb.sectcnt * atariBpb.bps)
2017-12-19 20:33:03 +00:00
.AppendLine();
extraInfo = atariSb.ToString();
}
}
else if(useApricotBpb)
2017-09-22 23:57:53 +01:00
{
2018-02-01 01:19:19 +00:00
isFat12 = true;
fakeBpb.bps = apricotBpb.mainBPB.bps;
fakeBpb.spc = apricotBpb.mainBPB.spc;
fakeBpb.rsectors = apricotBpb.mainBPB.rsectors;
fakeBpb.fats_no = apricotBpb.mainBPB.fats_no;
fakeBpb.root_ent = apricotBpb.mainBPB.root_ent;
fakeBpb.sectors = apricotBpb.mainBPB.sectors;
fakeBpb.media = apricotBpb.mainBPB.media;
fakeBpb.spfat = apricotBpb.mainBPB.spfat;
fakeBpb.sptrk = apricotBpb.spt;
2017-12-26 08:01:40 +00:00
XmlFsType.Bootable = apricotBpb.bootType > 0;
2018-02-01 01:19:19 +00:00
if(apricotBpb.bootLocation > 0 &&
apricotBpb.bootLocation + apricotBpb.bootSize < imagePlugin.Info.Sectors)
fakeBpb.boot_code = imagePlugin.ReadSectors(apricotBpb.bootLocation,
(uint)(apricotBpb.sectorSize * apricotBpb.bootSize) /
imagePlugin.Info.SectorSize);
2017-09-22 23:57:53 +01:00
}
// Some fields could overflow fake BPB, those will be handled below
else if(useHumanBpb)
{
isFat16 = true;
fakeBpb.jump = humanBpb.jump;
fakeBpb.oem_name = humanBpb.oem_name;
fakeBpb.bps = (ushort)imagePlugin.Info.SectorSize;
fakeBpb.spc = (byte)(humanBpb.bpc / fakeBpb.bps);
fakeBpb.fats_no = 2;
fakeBpb.root_ent = humanBpb.root_ent;
fakeBpb.media = humanBpb.media;
fakeBpb.spfat = (ushort)(humanBpb.cpfat * fakeBpb.spc);
fakeBpb.boot_code = humanBpb.boot_code;
XmlFsType.Bootable = true;
}
if(!isFat32)
{
// This is to support FAT partitions on hybrid ISO/USB images
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
{
2018-02-01 01:19:19 +00:00
fakeBpb.bps *= 4;
fakeBpb.spc /= 4;
fakeBpb.spfat /= 4;
fakeBpb.hsectors /= 4;
2018-02-01 01:19:19 +00:00
fakeBpb.sptrk /= 4;
fakeBpb.rsectors /= 4;
if(fakeBpb.spc == 0) fakeBpb.spc = 1;
}
// This assumes no sane implementation will violate cluster size rules
// However nothing prevents this to happen
// If first file on disk uses only one cluster there is absolutely no way to differentiate between FAT12 and FAT16,
// so let's hope implementations use common sense?
if(!isFat12 && !isFat16)
{
ulong clusters;
if(fakeBpb.sectors == 0)
2018-02-01 01:19:19 +00:00
clusters = fakeBpb.spc == 0 ? fakeBpb.big_sectors : fakeBpb.big_sectors / fakeBpb.spc;
else clusters = fakeBpb.spc == 0 ? fakeBpb.sectors : (ulong)fakeBpb.sectors / fakeBpb.spc;
if(clusters < 4089) isFat12 = true;
2018-02-01 01:19:19 +00:00
else isFat16 = true;
}
if(isFat12)
{
if(useAtariBpb) sb.AppendLine("Atari FAT12");
else if(useApricotBpb) sb.AppendLine("Apricot FAT12");
else sb.AppendLine("Microsoft FAT12");
2017-12-26 08:01:40 +00:00
XmlFsType.Type = "FAT12";
}
else if(isFat16)
{
sb.AppendLine(useAtariBpb
? "Atari FAT16"
: useHumanBpb
? "Human68k FAT16"
: "Microsoft FAT16");
2017-12-26 08:01:40 +00:00
XmlFsType.Type = "FAT16";
}
if(useAtariBpb)
{
if(atariBpb.serial_no[0] == 0x49 && atariBpb.serial_no[1] == 0x48 && atariBpb.serial_no[2] == 0x43)
sb.AppendLine("Volume has been modified by Windows 9x/Me Volume Tracker.");
else
2017-12-26 08:01:40 +00:00
XmlFsType.VolumeSerial =
$"{atariBpb.serial_no[0]:X2}{atariBpb.serial_no[1]:X2}{atariBpb.serial_no[2]:X2}";
XmlFsType.SystemIdentifier = StringHandlers.CToString(atariBpb.oem_name);
2017-12-26 08:01:40 +00:00
if(string.IsNullOrEmpty(XmlFsType.SystemIdentifier)) XmlFsType.SystemIdentifier = null;
}
else if(fakeBpb.oem_name != null)
{
if(fakeBpb.oem_name[5] == 0x49 && fakeBpb.oem_name[6] == 0x48 && fakeBpb.oem_name[7] == 0x43)
sb.AppendLine("Volume has been modified by Windows 9x/Me Volume Tracker.");
else
{
// Later versions of Windows create a DOS 3 BPB without OEM name on 8 sectors/track floppies
// OEM ID should be ASCII, otherwise ignore it
if(fakeBpb.oem_name[0] >= 0x20 && fakeBpb.oem_name[0] <= 0x7F && fakeBpb.oem_name[1] >= 0x20 &&
fakeBpb.oem_name[1] <= 0x7F && fakeBpb.oem_name[2] >= 0x20 && fakeBpb.oem_name[2] <= 0x7F &&
fakeBpb.oem_name[3] >= 0x20 && fakeBpb.oem_name[3] <= 0x7F && fakeBpb.oem_name[4] >= 0x20 &&
fakeBpb.oem_name[4] <= 0x7F && fakeBpb.oem_name[5] >= 0x20 && fakeBpb.oem_name[5] <= 0x7F &&
fakeBpb.oem_name[6] >= 0x20 && fakeBpb.oem_name[6] <= 0x7F && fakeBpb.oem_name[7] >= 0x20 &&
fakeBpb.oem_name[7] <= 0x7F)
2017-12-26 08:01:40 +00:00
XmlFsType.SystemIdentifier = StringHandlers.CToString(fakeBpb.oem_name);
2018-02-01 01:19:19 +00:00
else if(fakeBpb.oem_name[0] < 0x20 && fakeBpb.oem_name[1] >= 0x20 &&
fakeBpb.oem_name[1] <= 0x7F && fakeBpb.oem_name[2] >= 0x20 &&
fakeBpb.oem_name[2] <= 0x7F && fakeBpb.oem_name[3] >= 0x20 &&
fakeBpb.oem_name[3] <= 0x7F && fakeBpb.oem_name[4] >= 0x20 &&
fakeBpb.oem_name[4] <= 0x7F && fakeBpb.oem_name[5] >= 0x20 &&
fakeBpb.oem_name[5] <= 0x7F && fakeBpb.oem_name[6] >= 0x20 &&
fakeBpb.oem_name[6] <= 0x7F && fakeBpb.oem_name[7] >= 0x20 &&
fakeBpb.oem_name[7] <= 0x7F)
2017-12-26 08:01:40 +00:00
XmlFsType.SystemIdentifier = StringHandlers.CToString(fakeBpb.oem_name, Encoding, start: 1);
}
if(fakeBpb.signature == 0x28 || fakeBpb.signature == 0x29)
2017-12-26 08:01:40 +00:00
XmlFsType.VolumeSerial = $"{fakeBpb.serial_no:X8}";
}
2016-04-19 02:11:47 +01:00
2017-12-26 08:01:40 +00:00
if(XmlFsType.SystemIdentifier != null)
sb.AppendFormat("OEM Name: {0}", XmlFsType.SystemIdentifier.Trim()).AppendLine();
sb.AppendFormat("{0} bytes per sector.", fakeBpb.bps).AppendLine();
if(!useHumanBpb)
if(fakeBpb.sectors == 0)
{
sb.AppendFormat("{0} sectors on volume ({1} bytes).", fakeBpb.big_sectors,
fakeBpb.big_sectors * fakeBpb.bps).AppendLine();
XmlFsType.Clusters = fakeBpb.spc == 0 ? fakeBpb.big_sectors : fakeBpb.big_sectors / fakeBpb.spc;
}
else
{
sb.AppendFormat("{0} sectors on volume ({1} bytes).", fakeBpb.sectors,
fakeBpb.sectors * fakeBpb.bps).AppendLine();
2019-04-23 01:38:33 +01:00
XmlFsType.Clusters =
(ulong)(fakeBpb.spc == 0 ? fakeBpb.sectors : fakeBpb.sectors / fakeBpb.spc);
}
else
{
XmlFsType.Clusters = humanBpb.clusters == 0 ? humanBpb.big_clusters : humanBpb.clusters;
sb.AppendFormat("{0} sectors on volume ({1} bytes).",
XmlFsType.Clusters * humanBpb.bpc / imagePlugin.Info.SectorSize,
XmlFsType.Clusters * humanBpb.bpc).AppendLine();
}
2018-02-01 01:19:19 +00:00
sb.AppendFormat("{0} sectors per cluster.", fakeBpb.spc).AppendLine();
sb.AppendFormat("{0} clusters on volume.", XmlFsType.Clusters).AppendLine();
2019-04-23 01:38:33 +01:00
XmlFsType.ClusterSize = (uint)(fakeBpb.bps * fakeBpb.spc);
sb.AppendFormat("{0} sectors reserved between BPB and FAT.", fakeBpb.rsectors).AppendLine();
sb.AppendFormat("{0} FATs.", fakeBpb.fats_no).AppendLine();
sb.AppendFormat("{0} entries on root directory.", fakeBpb.root_ent).AppendLine();
2016-04-19 02:11:47 +01:00
if(fakeBpb.media > 0) sb.AppendFormat("Media descriptor: 0x{0:X2}", fakeBpb.media).AppendLine();
2017-12-19 20:33:03 +00:00
sb.AppendFormat("{0} sectors per FAT.", fakeBpb.spfat).AppendLine();
2016-04-19 02:11:47 +01:00
if(fakeBpb.sptrk > 0 && fakeBpb.sptrk < 64 && fakeBpb.heads > 0 && fakeBpb.heads < 256)
{
sb.AppendFormat("{0} sectors per track.", fakeBpb.sptrk).AppendLine();
sb.AppendFormat("{0} heads.", fakeBpb.heads).AppendLine();
}
2018-02-01 01:19:19 +00:00
if(fakeBpb.hsectors <= partition.Start)
sb.AppendFormat("{0} hidden sectors before BPB.", fakeBpb.hsectors).AppendLine();
if(fakeBpb.signature == 0x28 || fakeBpb.signature == 0x29 || andosOemCorrect)
{
sb.AppendFormat("Drive number: 0x{0:X2}", fakeBpb.drive_no).AppendLine();
2017-12-26 08:01:40 +00:00
if(XmlFsType.VolumeSerial != null)
sb.AppendFormat("Volume Serial Number: {0}", XmlFsType.VolumeSerial).AppendLine();
if((fakeBpb.flags & 0xF8) == 0x00)
{
if((fakeBpb.flags & 0x01) == 0x01)
{
2016-04-19 02:11:47 +01:00
sb.AppendLine("Volume should be checked on next mount.");
2017-12-26 08:01:40 +00:00
XmlFsType.Dirty = true;
}
2018-02-01 01:19:19 +00:00
if((fakeBpb.flags & 0x02) == 0x02) sb.AppendLine("Disk surface should be on next mount.");
}
if(fakeBpb.signature == 0x29 || andosOemCorrect)
{
2017-12-26 08:01:40 +00:00
XmlFsType.VolumeName = Encoding.ASCII.GetString(fakeBpb.volume_label);
sb.AppendFormat("Filesystem type: {0}", Encoding.ASCII.GetString(fakeBpb.fs_type)).AppendLine();
}
}
2017-12-26 08:01:40 +00:00
else if(useAtariBpb && XmlFsType.VolumeSerial != null)
sb.AppendFormat("Volume Serial Number: {0}", XmlFsType.VolumeSerial).AppendLine();
bootChk = Sha1Context.Data(fakeBpb.boot_code, out _);
2018-08-29 22:15:43 +01:00
// Workaround that PCExchange jumps into "FAT16 "...
if(XmlFsType.SystemIdentifier == "PCX 2.0 ") fakeBpb.jump[1] += 8;
2018-02-01 01:19:19 +00:00
// Check that jumps to a correct boot code position and has boot signature set.
// This will mean that the volume will boot, even if just to say "this is not bootable change disk"......
2017-12-26 08:01:40 +00:00
if(XmlFsType.Bootable == false && fakeBpb.jump != null)
2018-02-01 01:19:19 +00:00
XmlFsType.Bootable |=
fakeBpb.jump[0] == 0xEB && fakeBpb.jump[1] >= minBootNearJump && fakeBpb.jump[1] < 0x80 ||
fakeBpb.jump[0] == 0xE9 && fakeBpb.jump.Length >= 3 &&
2018-02-01 01:19:19 +00:00
BitConverter.ToUInt16(fakeBpb.jump, 1) >= minBootNearJump &&
BitConverter.ToUInt16(fakeBpb.jump, 1) <= 0x1FC;
sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize;
// First root directory sector
rootDirectorySector =
(ulong)(fakeBpb.spfat * fakeBpb.fats_no + fakeBpb.rsectors) * sectorsPerRealSector;
sectorsForRootDirectory = (uint)(fakeBpb.root_ent * 32 / imagePlugin.Info.SectorSize);
}
2017-12-19 20:33:03 +00:00
if(extraInfo != null) sb.Append(extraInfo);
if(rootDirectorySector + partition.Start < partition.End &&
2018-02-01 01:19:19 +00:00
imagePlugin.Info.XmlMediaType != XmlMediaType.OpticalDisc)
{
byte[] rootDirectory =
imagePlugin.ReadSectors(rootDirectorySector + partition.Start, sectorsForRootDirectory);
if(useDecRainbowBpb)
{
MemoryStream rootMs = new MemoryStream();
foreach(byte[] tmp in from ulong rootSector in new[] {0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20}
select imagePlugin.ReadSector(rootSector)) rootMs.Write(tmp, 0, tmp.Length);
2017-12-19 20:33:03 +00:00
rootDirectory = rootMs.ToArray();
}
for(int i = 0; i < rootDirectory.Length; i += 32)
{
// Not a correct entry
if(rootDirectory[i] < 0x20 && rootDirectory[i] != 0x05) continue;
// Deleted or subdirectory entry
if(rootDirectory[i] == 0x2E || rootDirectory[i] == 0xE5) continue;
// Not a volume label
if(rootDirectory[i + 0x0B] != 0x08 && rootDirectory[i + 0x0B] != 0x28) continue;
2019-02-27 08:49:42 +00:00
DirectoryEntry entry =
Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(rootDirectory, i, 32);
byte[] fullname = new byte[11];
2018-02-01 01:19:19 +00:00
Array.Copy(entry.filename, 0, fullname, 0, 8);
Array.Copy(entry.extension, 0, fullname, 8, 3);
2017-12-26 08:01:40 +00:00
string volname = Encoding.GetString(fullname).Trim();
if(!string.IsNullOrEmpty(volname))
2017-12-26 08:01:40 +00:00
XmlFsType.VolumeName = (entry.caseinfo & 0x0C) > 0 ? volname.ToLower() : volname;
if(entry.ctime > 0 && entry.cdate > 0)
{
2017-12-26 08:01:40 +00:00
XmlFsType.CreationDate = DateHandlers.DosToDateTime(entry.cdate, entry.ctime);
if(entry.ctime_ms > 0)
XmlFsType.CreationDate = XmlFsType.CreationDate.AddMilliseconds(entry.ctime_ms * 10);
2017-12-26 08:01:40 +00:00
XmlFsType.CreationDateSpecified = true;
sb.AppendFormat("Volume created on {0}", XmlFsType.CreationDate).AppendLine();
}
2016-04-19 02:11:47 +01:00
if(entry.mtime > 0 && entry.mdate > 0)
{
2018-02-01 01:19:19 +00:00
XmlFsType.ModificationDate = DateHandlers.DosToDateTime(entry.mdate, entry.mtime);
2017-12-26 08:01:40 +00:00
XmlFsType.ModificationDateSpecified = true;
sb.AppendFormat("Volume last modified on {0}", XmlFsType.ModificationDate).AppendLine();
}
if(entry.adate > 0)
2017-12-23 03:59:48 +00:00
sb.AppendFormat("Volume last accessed on {0:d}", DateHandlers.DosToDateTime(entry.adate, 0))
2017-12-19 20:33:03 +00:00
.AppendLine();
2017-08-25 03:28:55 +01:00
break;
}
}
2017-12-26 08:01:40 +00:00
if(!string.IsNullOrEmpty(XmlFsType.VolumeName))
sb.AppendFormat("Volume label: {0}", XmlFsType.VolumeName).AppendLine();
if(XmlFsType.Bootable)
{
// Intel short jump
if(bpbSector[0] == 0xEB && bpbSector[1] < 0x80)
{
2018-02-01 01:19:19 +00:00
int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length);
Sha1Context.Data(bootCode, out _);
}
// Intel big jump
else if(bpbSector[0] == 0xE9 && BitConverter.ToUInt16(bpbSector, 1) < 0x1FC)
{
int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
2018-02-01 01:19:19 +00:00
byte[] bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3];
Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0, bootCode.Length);
Sha1Context.Data(bootCode, out _);
}
2018-02-01 01:19:19 +00:00
sb.AppendLine("Volume is bootable");
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
string bootName = knownBootHashes.FirstOrDefault(t => t.hash == bootChk).name;
if(string.IsNullOrWhiteSpace(bootName)) sb.AppendLine("Unknown boot code.");
2018-02-01 01:19:19 +00:00
else sb.AppendFormat("Boot code corresponds to {0}", bootName).AppendLine();
}
2016-04-19 02:11:47 +01:00
information = sb.ToString();
}
}
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
}