我正在尝试在 VC++ MFC 中编写一个程序,该程序允许我在 FAT32 文件系统中移动。但是,我很难理解和应用方程式来收集 FAT32 引导扇区的正确数据。下面是关于读取和访问 FAT32 引导扇区的伪代码:
// First, allocate buffers for the sector data
if ((dst_data = (FAT32BOOTSECTOR *)VirtualAlloc(NULL,
sizeof(FAT16BOOTSECTOR), MEM_COMMIT, PAGE_READWRITE)) == NULL)
//Create destination drive
str.Format(_T("\\\\.\\%c:"), toupper(destDrive[2]));
hDestinationDrive = CreateFile(str, GENERIC_READ |
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
// Now read the boot sector of the destination drive to get it's drive params.
ReadFile(hDestinationDrive, dst_data, 512, &dwBytesRead, NULL);
我正在显示 FAT32 引导扇区数据,如下所示:
Jump code: EB:3C:90
OEM code: [MSDOS5.0]
sector_size: 512
sectors_per_cluster: 32
reserved_sectors: 2
number_of_fats: 2
root_dir_entries: 512
total_sectors_short: 0
media_descriptor: 0xF8
fat_size_sectors: 239
sectors_per_track: 63
number_of_heads: 255
hidden_sectors: 129
total_sectors_long: 1953663
drive_number: 0x80
current_head: 0x00
boot_signature: 0x29
volume_id: 0x1263EBDD
Volume label: [NO NAME ]
Filesystem type: [FAT16 ]
Boot sector signature: 0xAA55
Remainder: 33, FFFFFFC9, FFFFFF8E, FFFFFFD1...
但是检索到的文件系统类型是“FAT16”而不是“FAT32”,因为我使用 Win XP SP3 格式化了 SD 卡。
我完全不明白如何读/写 FAT32 引导扇区?请让我知道是否有任何替代方法。