Ink Blot welcomes you to Lance's Web Site!

I've decided to resurrect my web site on a limited basis; mainly to discuss FAT32X, but also to test a new site build process. LC

(best viewed at 800x600 full screen!)


Home
Boot Sectors
FAT32X
Utility Programs
Site Map

BOOTSECT

Boot Sector Utility

(read/write/verify/dump/fornicate)

Major Updates

1/26/98 - Now Handles FAT32

Download

BOOTSECT.ZIP or BOOTSECT.EXE

Description

This program reads, writes, verifies, dumps, and shows info about master and partition boot records on hard or floppy drives.
Whew!

Help

C:>bootsect -?

BOOTSECT (01.07, 05/07/98) - Read/Write/etc Boot Records

usage: BOOTSECT (DRIVE) [-F] -M | -P [(PART)] -R | -W | -V | -D | -T [(FILE)]

BOOTSECT (01.07, 05/07/98)

(DRIVE) specifies the physical or logical disk drive.
   For -M, must be 0 for 1st drive, 1 for 2nd drive.
   For -P, may also be A[:] to Z[:].
   May be @(FILE) to specify an external file.

-F specifies that (DRIVE) is a FDD when (DRIVE) is a physical drive.
   The default is that (DRIVE) is a HDD.

-M selects the master boot record (HDD only).
-P selects the partition boot record when (DRIVE) is a physical drive.

(PART) is the optional partition number; 0, 1, 2, or 3 (HDD only)
   Defaults to 0; must be 0 for FDD.

-R reads the record, writes to (FILE).
-W writes the record, reads from (FILE).
-V reads the record, verifies with (FILE).
-D dumps the record in hex and Ascii.
-T with -M displays the partition table.
-T with -P displays the FAT info.
-X with -M -T displays the extended partition tables.
-X with -M -D dumps the extended partition tables.
-I initializes the record (writes 0x00)

By default, -W and -V options only work with the boot code.

-Z use entire record.
   -Z with -W writes entire record,
   the boot code AND the partition table or FAT info. (DANGER!)
   -Z with -V verifies the entire record.
   -Z with -I initializes the record (writes 0x00)

-Y only use partition or FAT info.
   -Y with -W only writes the partition table or FAT info,
   it does not modify the boot code.
   -Y with -V only verifies the partition table or FAT info.

(FILE) is the input/output file.
  is written to when -R is specified.
  is read from  when -W is specified.
  is read from  when -V is specified.
  defaults to 'MBR.BIN' for master boot record.
  defaults to 'PBR.BIN' for partition boot record.

When the @(FILE) syntax is used for the (DRIVE) parameter, the boot sector is read or written from the file (FILE) instead of the physical drive. Also, the -F (floppy) option is invalid, and specifying a non-zero partition number (i.e. -P 1) is also invalid.

-Z is an optional flag that may be used with the -W (write) and -V (verify) options. When specified, it indicates to write or verify the entire boot record. Normally, only the portion of the boot record that contains the boot code is used. To be specific, when -Z is specified, all 512 bytes of the boot record are processed. When -Z is not specifed, only bytes 000h to 1BDh of a master boot sector are processed (ignoring the partition table and magic number); or only bytes 000h to 002h, and 03Eh to 1FDh of a FAT12 or FAT16 partition boot sector are processed (ignoring the partition info and magic number); or only bytes 000h to 002h, and 05Ah to 1FDh of a FAT32 partition boot sector are processed (ignoring the partition info and magic number).

When -Z is used with the -V (verify) option, all bytes of the boot record are checked. If you have a baseline copy of your boot sector, this can be used to check for changes in the code AND the critical areas.

When -Z is used with the -W (write) option, all bytes of the boot sector are written. This is a really good way to trash the partition table / FAT info! This is also a really good way to recover it, IF you create a bootable floppy and put BOOTSECT on it along with the current valid boot sector images from your drives.

Sample Execution

Since there are so many options and combinations, I've only illustrated several of the more common ones.

Reading a master boot sector from physical hard drive 0:
C:>bootsect 0 -m -r bootc.bin

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading master boot record from drive 0
Writing to 'bootc.bin'

C:>
Reading a partition boot sector from floppy drive 1 (typically B:):
C:>bootsect 1 -f -p -r bootb.bin

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading partition boot record from drive 1 partition 0
Writing to 'bootb.bin'

C:>
Writing the master boot sector to physical hard drive 0:
C:>bootsect 0 -m -w newbootc.bin

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading master boot record from drive 0
Reading new record from 'newbootc.bin'
Merging record, preserving partition table
Writing master boot record to drive 0
OK

C:>
Writing the partition boot sector to physical hard drive 1 partition 1:
C:>bootsect 1 -p 1 -w part11.bin

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading partition boot record from drive 1 partition 1
Reading new record from 'part11.bin'
Merging record, preserving partition info
Writing partition boot record to drive 1 partition 1
OK

C:>
Dumping the master boot record:
C:>bootsect 0 -m -d

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading master boot record from drive 0

Master boot record from drive 0:
0000 FA 33 C0 8E D0 BC 00 7C 8B F4 50 07 50 1F FB FC  .3.....|..P.P...
0010 BF 00 06 B9 00 01 F2 A5 EA 1D 06 00 00 BE BE 07  ................
0020 B3 04 80 3C 80 74 0E 80 3C 00 75 1C 83 C6 10 FE  ...<.t..<.u.....
0030 CB 75 EF CD 18 8B 14 8B 4C 02 8B EE 83 C6 10 FE  .u......L.......
0040 CB 74 1A 80 3C 00 74 F4 BE 8B 06 AC 3C 00 74 0B  .t..<.t.....<.t.
0050 56 BB 07 00 B4 0E CD 10 5E EB F0 EB FE BF 05 00  V.......^.......
0060 BB 00 7C B8 01 02 57 CD 13 5F 73 0C 33 C0 CD 13  ..|...W.._s.3...
0070 4F 75 ED BE A3 06 EB D3 BE C2 06 BF FE 7D 81 3D  Ou...........}.=
0080 55 AA 75 C7 8B F5 EA 00 7C 00 00 49 6E 76 61 6C  U.u.....|..Inval
0090 69 64 20 70 61 72 74 69 74 69 6F 6E 20 74 61 62  id partition tab
00A0 6C 65 00 45 72 72 6F 72 20 6C 6F 61 64 69 6E 67  le.Error loading
00B0 20 6F 70 65 72 61 74 69 6E 67 20 73 79 73 74 65   operating syste
00C0 6D 00 4D 69 73 73 69 6E 67 20 6F 70 65 72 61 74  m.Missing operat
00D0 69 6E 67 20 73 79 73 74 65 6D 00 00 80 14 56 09  ing system....V.
00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 01  ................
01C0 01 00 06 3F BF 0B 3F 00 00 00 C1 3C 20 00 00 00  ...?..?....< ...
01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA  ..............U.

C:>
Displaying info about the master boot record:
C:>bootsect 0 -m -t

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading master boot record from drive 0

Partition table for drive 0:
Part  Boot  Sys   Start Address   End Address   Starting  Number of
Num   Flag  Type   Cyl Head Sec   Cyl Head Sec    Sector    Sectors
  0    80h  06h      0   1   1    523  63  63         63    2112705
  1    00h  00h      0   0   0      0   0   0          0          0
  2    00h  00h      0   0   0      0   0   0          0          0
  3    00h  00h      0   0   0      0   0   0          0          0

Drive 0  Cylinders=524 Heads=64 Sectors=63

C:>
Displaying info about the partition:
C:>bootsect 0 -p -t

BOOTSECT (01.05, 02/01/98) - Read/Write/etc Boot Records

Reading master boot record from drive 0
Reading partition boot record from drive 0 partition 0

Partition info for drive 0 partition 0:

System ID            MSDOS5.0
bytes.per.sector     512
sectors.per.cluster  64
reserved.sectors     1
fat.copies           2
root.dir.entries     512
total.sectors        0
media.desc           F8h
sectors.per.fat      129
sectors.per.track    63
heads                64
hidden.sectors       63
big.total.sectors    2112705
drive                80h
head                 0
signature            29h
volume.serial        3551-15D4
volume.label                    
file.system.id       FAT16   

Drive 0  Cylinders=524 Heads=64 Sectors=63

C:>

Functionality

Parse parameters. Verify that required parameters are specified, and that a valid combination of parameters is specified. Get the physical disk drive information (cyls, heads, sectors). Perform the function:
  • -R : Read boot sector from disk.
    Write boot sector to (FILE).
  • -W : Read boot sector from disk.
    Read new boot sector from (FILE).
    If -Z WAS NOT specified, only merge boot code.
    If -Z WAS specifed, replace boot sector.
    Write boot sector to disk.
  • -V : Read boot sector from disk.
    Read other boot sector from (FILE).
    If -Z WAS NOT specified, compare boot code.
    If -Z WAS specified, compare entire boot sector.
  • -T : Read boot sector from disk.
    Display info on screen.
  • -D : Read boot sector from disk.
    Display boot sector dump on screen.

Notes

The correct method to read the pbr of a DOS drive in an extended partition is to use the drive letter, and not the physical partition. Using the physical partition reads the 1st sector of the extended partition, which contains the extended partition info. Using the drive letter reads the first sector of the logical DOS drive. i.e.
C:>bootsect d: -p -t
instead of
C:>bootsect 0 -p 1 -t
Lance Costanzo, [email protected]