ANY QUESTIONS? => alexander_grau@web.de

Actually, Drive Rescue cannot access a drive if the boot sector is lost.

To rebuild a virtual boot sector consider the following:

Idea:
1. Determine the cluster size (sectors per cluster) upon the (user selected) partition size
   For details see Microsoft Hardware White Paper - FAT: General Overview of On-Disk 
   Format (fatgen102.doc)
2. Get FAT size via calculating (if first FAT is lost) 
   or scanning (distance from 1. to 2. FAT! - media byte)
3. FAT12/16: Determine root size via scanning:
   "AnalyseDirEntries" returns count of entries in the root
4. FAT32: Get root cluster via scanning:
   If directory entries found from the root (means no ./.. entries, and other stuff ok), walk 
   the cluster chain back by "GetPreviousCluster" as far as possible - then the root is found



 FAT Filesystem Overview
======================================= 
 Reserved (usually Boot Sector)
  
 sector count: BPB_RsvdSecCnt (usally 1 for FAT12/16, 32 for FAT32)
--------------------------------------
 FAT's (usually 2)

 sector count: BPB_FATsz * BBP_NumFATs
--------------------------------------
 FAT12/16 Root

 sector count: ceil[ (BPB_RootEntCnt*32)/BPB_BytesPSec ]
--------------------------------------
 Data

======================================= 


FAT type detection:

    if DI_CountofClusters < 4085 then
      DI_FATtype:=FAT12
    else if DI_CountofClusters < 65525 then
      DI_FATtype:=FAT16
    else DI_FATtype:=FAT32;


----------------------

Example floppy disk (all numbers are sector counts):

res: 1
fats: 9*2
root: 224/32=7
