Tuesday, September 29, 2015

Modify FAT16 file-system

The FAT-16 file-system consists of:

  • Reserved area
    • boot sector
    • optional file system information sector (FAT-32) 
  • FATs
    • number of copies is specified in boot sector
  • Data area
    • a root directory
      FAT-12 & FAT-16 has fixed root dir size, while it's customizable in FAT-32. 
    • data clusters

Boot sector

    Bytes/AddrPurpose
    0-2/ 0x00-0x02Assembly code instructions to jump to boot code (mandatory in bootable partition)
    3-10 0x03-0x0AOEM name in ASCII
    11-12/ 0x0B-0x0CBytes per sector (512, 1024, 2048, or 4096)
    13/ 0x0DSectors per cluster (Must be a power of 2 and cluster size must be <=32 KB)
    14-15/ 0x0E-0x0FSize of reserved area, in sectors
    16/  0x10Number of FATs (usually 2)
    17-18/ 0x11-0x12Maximum number of files in the root directory (FAT12/16; 0 for FAT32)
    19-20/ 0x13-0x14Number of sectors in the file system; if 2 B is not large enough, set to 0 and use 4 B value in bytes 32-35 below
    21/ 0x15Media type (0xf0=removable disk, 0xf8=fixed disk)
    22-23/ 0x16-0x17Size of each FAT, in sectors, for FAT12/16; 0 for FAT32
    24-25/ 0x18-0x19Sectors per track in storage device
    26-27/ 0x1A-0x1BNumber of heads in storage device
    28-31/ 0x1C-0x1FNumber of sectors before the start partition
    32-35/ 0x20-0x23Number of sectors in the file system; this field will be 0 if the 2B field above (bytes 19-20) is non-zero

while for our case, 

screenshot of hexedit
===============================================
ADDR : VALUE       MEANING
===============================================
00-02: eb 3c 90    Instructions to jump to boot code
03-0a: 6d 6B 64 6f 73 66 73 00
                   Name string (mkdosfs.)
0b-0c: 00 02       Bytes/sector (0x0200 = 512)
0d   : 20          Sectors/cluster (20)
0e-0f: 20 00       Size of reserved area (20 sector)
10   : 02          Number of FATs (2)
11-12: 00 02       Max. number of root directory entries (0x0200 = 512)
13-14: 00 00       Total number of sectors (value equal to 0, check value in 0x20-0x23)
15   : F8          Media type (fixed disk)
16-17: 00 01       FAT size (0x0100 = 256 sectors)
18-19: 3F 00       Sectors/track (0x003F = 63)
1a-1b: FF 00       Number of heads (0x00FF = 255)
1c-1f: 00 00 00 00 Number of sector before partition (0)
20-23: 00 F8 1F 00 Total number of sectors (0xF800001F = 4160749599)??
24   : 00          Drive number (0)
25   : 00          Unused
26   : 29          Extended boot signature
27-2a: F5 7E 18 E5 Volume serial number (.~..)
2b-35: 20 20 20 20 20 20 20 20 20 20 20
                   Volume label ("           ")
36-3d: 46 41 54 31 36 20 20 20
                   File system type label ("FAT16 ")
3e-1fd : [snip]    Not used
1fe-1ff: 55 aa     Signature value (0xaa55)


to be continue....

No comments:

Post a Comment