Advertisement
anhkiet2507

Program to display content of first 100 FAT cell

Sep 29th, 2022 (edited)
1,293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <memory.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. struct BOOT {  //for FAT16
  8.     char jmp[3];
  9.     char OEM[8];
  10.     int bytes_per_sector;
  11.     char sectors_per_cluster;
  12.     int reserved;
  13.     char FAT_cnt;
  14.     int ROOT_size;
  15.     int total_sectors;
  16.     char media;
  17.     int FAT_size;
  18.     int sectors_per_track;
  19.     int head_cnt;
  20.     long hidden_sectors;
  21.     long total_sectors_long;
  22.     char unknown[3];
  23.     long serial;
  24.     char volume[11];
  25.     char FAT_type[8];
  26.     char loader[448];
  27.     char mark[2];
  28. };
  29.  
  30. struct ROOT {
  31.     char name[8];
  32.     char ext[3];
  33.     char attr;
  34.     char reserved[10];
  35.     char time[2];
  36.     char date[2];
  37.     int first_cluster;
  38.     long size;
  39. };
  40.  
  41. void main()
  42. {
  43.  
  44.     int drive = 3; //A=0, B=1, C=2, D=3 ...
  45.  
  46.     //Reading boot sector from disk D
  47.     BOOT boot;
  48.     int res = absread(drive, 1, 0, &boot);
  49.     int i;
  50.     unsigned int *fat = (unsigned int *)malloc (boot.FAT_size * boot.bytes_per_sector);
  51.     //printing first 15 FAT cells
  52.     printf("Content of first 100 FAT cells:");
  53.     for (i = 0; i < 100; i++)
  54.         printf("%u ", fat[i]);
  55.  
  56.    
  57.     getchar();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement