⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dofat.c

📁 都在一个程序里
💻 C
字号:
  
/*以读取硬盘C盘 FAT32的FAT为例,来调用读取硬盘绝对扇区的函数 */
#include "dolba.h"

/*获取FAT参数(FAT前距离DBR的扇区数,FAT所占的扇区数)*/
void getFATinfo(unsigned int hardDisk,
	unsigned int *reservedSector,
	unsigned long *sectorPerFAT)
{
unsigned char buffer[512];
unsigned int fat16=0;
unsigned long fat32=0;
//unsigned int f16;
//unsigned int f32;
/*获取DBR,以便 获取FAT参数 */
biosdisk(2,hardDisk,1,0,1,1,buffer);
/* 获取FAT前距离DBR的扇区数 */
*reservedSector=*((unsigned int *)&buffer[0xE]);

fat16=*((unsigned int *)&buffer[0x16]);
fat32=*((unsigned long *)&buffer[0x24]);
//f16=*((unsigned int *)&buffer[0x39]);
//f32=*((unsigned int *)&buffer[0x55]);
/* 获取FAT所占的扇区数 */
if(fat16!=0) *sectorPerFAT=fat16;
else if(fat32!=0) *sectorPerFAT=fat32;
else {printf("FAT information not found.\n"); return;}
}

void doFat(char *prompt,unsigned int cmd, char *buf,char *showFileName)
{
unsigned int reservedSector=0;
unsigned long sectorPerFAT=0;

/* 获取FAT参数  */
getFATinfo(0x80,&reservedSector,&sectorPerFAT);
if(reservedSector==0 || sectorPerFAT==0)
{printf("DBR or FAT information error.\n"); return;}
/*保存FAT到文件  */
//printf("%u,%lu",reservedSector,sectorPerFAT);
//printf("%d,%d\n",reservedSector,sectorPerFAT);
//return;
doLBA(prompt,cmd,0x80,63+reservedSector,sectorPerFAT,buf,showFileName);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -