WipeDisk

From lo-tech.co.uk
Jump to: navigation, search

WipeDisk is a simple utility to erase the partition table from a fixed disk. This is useful on MS-DOS powered PCs, where the partition table contains non-DOS partitions since MS-DOS's FDISK utility will not delete such partitions.

Contents

Usage

A:\>wipedisk
WipeDisk - this will erase the first 64 sectors of the
primary hard disk (80h)
Press C to continue and erase the disk: _

Press 'C' (as in uppercase) to erase as shown; any other key will exit to the DOS prompt.

Source Code

Turbo Pascal source:

Program WipeDisk;
 
{Erases the first 64 sectors of drive 80h.  Use with care!}
 
uses crt;
 
type
  Buff = array[0..32767] of byte;
 
 
var
  Buffer : ^Buff;
  i      : word;
  sBuff,
  oBuff  : word;
  Chr    : Char;
  Res    : byte;
 
begin
  WriteLn('WipeDisk - this will erase the first 64 sectors of the');
  WriteLn('primary hard disk (80h)');
  WriteLn;
  Write('Press C to continue and erase the disk: ');
  Chr := ReadKey;   {get user key input}
  WriteLn(Chr);
 
  If Chr <> 'C' then Halt(0);
 
  Write('Erasing...');
  new(Buffer);
  sBuff := Seg(Buffer^);
  oBuff := Ofs(Buffer^);
  for i := 0 to 32767 do Buffer^[i] := 0;
  Res := 0; {ok}
 
  asm
    mov AL, 64;  {64 sectors}
    mov AH, 3;   {03h = write}
    mov CH, 0;
    mov CL, 1;
    mov DH, 0;   {we're wiping the first 128 sectors}
    mov DL, $80; {drive 80h = C}
    mov ES, sBuff;
    mov BX, oBuff;
    int $13;     {call BIOS, bye-bye MBR and partition table!}
    jnc @OK
    mov Res, AL; {save error code}
    @OK:
  end;{asm}
 
  if Res = 0 then WriteLn(' done.')
  else WriteLn(' BIOS returned error code ', Res);
 
  Dispose(Buffer);
 
end.{program}

Downloads

See Also