📄 fat.h
字号:
// Boot Sector Configuration
// =================================================================================================
// Entry Position / Description Remarks
// Length
// =================================================================================================
#DEFINE bsJumpCommand // 0x00 / 3 Jump Command 0xEB 0xXX 0x90
#DEFINE bsOEMName // 0x03 / 8 OEM Name XXX
#DEFINE bsBytesPerSec // 0x0B / 2 Bytes/Sector 512
#DEFINE bsSecPerCluster // 0x0D / 1 Sectors/Cluster XXX (range: 1-64)
#DEFINE bsReservedSec // 0x0E / 2 Reserved Sectors 1
#DEFINE bsNoOfFATs // 0x10 / 1 Number of FATs 2
#DEFINE bsNoRootDirs // 0x11 / 2 Number of Root Directory Entries 512
#DEFINE bsNoSecOnMedia // 0x13 / 2 Number of Sectors on Media XXX (Depends on card capacity. If the media has more than 65535 sectors, this field is zero and the 'number of total sectos' is set.)
#DEFINE bsMediaDescriptor // 0x15 / 1 Media Descriptor 0xF8 (Harddisk)
#DEFINE bsSecPerFAT // 0x16 / 2 Sectors/FAT XXX
#DEFINE bsSecPerTrack // 0x18 / 2 Sectors/Track 32 (No Meaning)
#DEFINE bsNoOfHeads // 0x1A / 2 Number of Heads 2 (No Meaning)
#DEFINE bsNoHiddenSec // 0x1C / 4 Number of Hidden Sectors 0
#DEFINE bsNoTotalSec // 0x20 / 4 Number of Total Sectors XXX (Depends on Capacity)
#DEFINE bsDriveNo // 0x24 / 1 Drive Number 0x80
//#DEFINE bsReserved // 0x25 / 1 Reserved 0
#DEFINE bsExtdBootSign // 0x26 / 1 Extended Boot Signature 0x29
#DEFINE bsVolIDSN // 0x27 / 4 Volume ID or Serial Number XXX
#DEFINE bsVolLabel // 0x2B / 11 Volume Label XXX (ASCII characters padded with blanks if less than 11 characters)
#DEFINE bsFileSysType // 0x36 / 8 File System Type XXX (ASCII characters identifying the file system type FAT12 or FAT16)
#DEFINE bsLoadProgCode // 0x3E / 448 Load Program Code XXX
#DEFINE bsSignature // 0x01FE / 2 Signature 0x55 0xAA
// Partition Table
// =================================================================================================
// Entry Position / Description Remarks
// Length
// =================================================================================================
#DEFINE ptCRC // 0x00 / 446 Consistency Routine Check
#DEFINE ptEntry1 // 0x01BE / 16 Partition Table Entry
#DEFINE ptEntry2 // 0x01CE / 16 Partition Table Entry
#DEFINE ptEntry3 // 0x01DE / 16 Partition Table Entry
#DEFINE ptEntry4 // 0x01EE / 16 Partition Table Entry
#DEFINE ptSignature // 0x01FE / 1 Signature 0x55 0xAA
// Partition Entry Description
// ====================================================================================================================================================
// Entry Position / Description Remarks
// Length
// ===============================================================================================================================================
#DEFINE peBootDesc // 0x00 / 1 Boot Descriptor 0x00 (Non-Bootable Device)
// 0x80 (Bootable Device)
#DEFINE peFirstPartitionSec // 0x01 / 3 First Partition Sector Address of Frist sector.
#DEFINE peFileSysDesc // 0x04 / 1 File System Descriptor 0x00 (Empty)
// 0x01 (DOS 12-bit FAT < 16 MB)
// 0x04 (DOS 16-bit FAT < 32 MB)
// 0x05 (Extended DOS)
// 0x06 (DOS 16-bit FAT >= 32 MB)
#DEFINE peLastPartitionSec // 0x05 / 3 Last Partition Sector Address of Last Sector.
#DEFINE peFirstSecPos // 0x08 / 4 First Sector Relative to Number of First Sector (Linear Address)
// Beginning of Device
#DEFINE peNoSecinPartition // 0x0C / 4 Number of Sectors in Partition Between one and Maximum Number of Sectors on Device
// Partition Entry Addresses
#DEFINE PARTITION1 0x01BE
#DEFINE PARTITION2 0x01CE
#DEFINE PARTITION3 0x01DE
#DEFINE PARTITION4 0x01EE
// FAT Codes
// Global Variables
DWORD peStart; // Absolute byte address of the first sector of Partition 1.
DWORD fatStart; // Absolute byte address of the first sector of the FAT of Partition 1.
DWORD rootDirStart; // Absolute byte address of the first sector of the Root Directory of Partition 1.
DWORD dataSecStart; // Absolute byte address of the first sector of the first data cluster of Partition 1 (ie N=2)
BYTE fatSecPerClus; // Stores the size of a cluster in number of sectors.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -