读写FAT32引导程序映像文件在SD卡上的Win CE
Reading/Writing FAT32 Bootloader image file on SD card for Win CE
我试图在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引导扇区?如有其他方法,请告知。
有可能你有一个bug,由于以下原因:
// First, allocate buffers for the sector data
if ((dst_data = (FAT32BOOTSECTOR *)VirtualAlloc(NULL,
sizeof(FAT16BOOTSECTOR), MEM_COMMIT, PAGE_READWRITE)) == NULL)
看起来你正在为FAT32BOOTSECTOR
分配空间,但你指定了sizeof(FAT16BOOTSECTOR)
的大小,所以你可能会得到比你需要的更小的内存块,并且部分结构可能会被其他部分的代码损坏。
相关文章:
- 如何找出应用程序崩溃的原因 - Win 10 LTSB
- win 表单应用程序字符串^ 到 int
- Windows 后台服务(系统配置文件)无法使用 C++ 访问 win 10 上的用户 appData 文件夹?
- sf::Windows上的音乐:api-ms-win-crt-locale-l1-1-0.dll:无法打开共享对象文件
- Win API对齐按钮上的文本
- 为什么 std::swap 不适用于<bool> Clang/Win(英语:Clang/Win)下的矢量元素?
- 命名空间 Win 没有成员"simpleControl"是什么意思
- C# 或 C++ ;可以像在CE中一样修改内存吗?
- 传递 boost::filesystem::p ath 到 boost::p rocess::child 会导致 Win
- 从 win 7 升级到 Win 10 后,出现 Dev-C++ makefile.win 编译错误
- 如何使用 WIN RPC 发送终止的字符数组(用于将图像从客户端上传到服务器)
- 放大倍率低于 125% 默认 win API(介于 101 - 124% 之间)
- C++ API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL依赖项问题
- [WIN API]为什么共享相同的 WriteFile(sync) 和 ReadFile(sync) 句柄会导致 Rea
- 尝试在 win 32 中禁用窗口大小调整时,窗口样式行为不一致
- 为什么简单的控制台应用运行,但基于对话框在 WIN CE 6.0 中不运行
- 为 WIN CE 仿真器 5.0 开发的应用程序不适用于 WIN CE 设备 6.0
- 读写FAT32引导程序映像文件在SD卡上的Win CE
- 无法使用VS2005在Win CE 6.0上调试应用程序
- 无法在WIN CE平台的.net紧凑框架中添加对DLL的引用