#include <stdio.h>
#include <stdLib.h>
#include <conio.h>
#include <dos.h>
#include <alloc.h>
void Doc_RDET()
{
unsigned char buffer[512];
unsigned int o_dia;
char filename[50];
FILE *f;
printf ("\nNhap vao o dia can doc RDET (0:A;2:B,....): ");
int kq=absread(o_dia,1,0,&buffer);
if (kq!=0)
{
printf ("\nDisk has a problem"); exit(1);
}
else
{
//So entry tren RDET
unsigned int Number_ENTRY=buffer[0x12]*0x100+buffer[0x11];
//So sector cua RDET
unsigned int Number_sector_ENTRY=(Number_ENTRY*32)/512;
//So sector danh rieng (so sector truoc bang FAT)
unsigned int Sector_reserve=buffer[0x0F]*0x100+buffer[0x0E];
//So luong bang FAT
unsigned int Number_FAT=buffer[0x10];//So bang FAT
//Kich thuoc 1 bang FAT
unsigned int Size_one_FAT=buffer[0x17]*0x100+buffer[0x16];
//Tong so sector truoc RDET
unsigned int Total_before_RDET=Sector_reserve+Number_FAT*Size_one_FAT;
// printf ("\nVi tri cua RDET %d co kich thuoc la: %d",Total_before_RDET,Number_ENTRY);
unsigned char *buf;
buf
=(unsigned char*)malloc(Number_sector_ENTRY
*512);
if (buf==NULL)
printf ("\nKhong the cap phat bo nho cho buf\n"); else
{
kq=absread(o_dia,Number_sector_ENTRY,Total_before_RDET,buf);
if(kq!=0)
{
printf ("\nKhong the doc duoc bang thu muc goc RDET\n"); exit(1);
}
else
{
printf ("\nNhap vao ten tap tin can luu: "); if (f==NULL)
printf ("\nKhong the luu duoc vao file"); else
{
fwrite(buf
,sizeof(unsigned char),Number_sector_ENTRY
*512,f
); }
}
}
}
}
void main()
{
clrscr();
printf ("\n\t\tDOC BANG THU MUC GOC VA LUU VAO MOT FILE\n\n\n"); Doc_RDET();
getch();
}