WINAPI: DeviceIoControl KERNEL32.DLL
0
8 -- Cylinders
4 -- MediaType
4 -- TracksPerCylinder
4 -- SectorsPerTrack
4 -- BytesPerSector

CONSTANT /DISK_GEOMETRY

0
4 -- MediaType
4 -- StartCylinderNumber
4 -- EndCylinderNumber
4 -- StartHeadNumber
4 -- EndHeadNumber
CONSTANT /FORMAT_PARAMETERS

CREATE lpOutBuffer HERE /DISK_GEOMETRY DUP ALLOT ERASE
CREATE lpInBuffer HERE /FORMAT_PARAMETERS DUP ALLOT ERASE
8 lpInBuffer MediaType !
0 lpInBuffer StartCylinderNumber !
39 lpInBuffer EndCylinderNumber !
0 lpInBuffer StartHeadNumber !
1 lpInBuffer EndHeadNumber !

VARIABLE lpBytesReturned 
HEX
70000 CONSTANT IOCTL_DISK_GET_DRIVE_GEOMETRY
7C018 CONSTANT IOCTL_DISK_FORMAT_TRACKS
DECIMAL

: GEOMETRY
  S" \\.\B:" R/O OPEN-FILE THROW >R
  0
  lpBytesReturned
  /DISK_GEOMETRY
  lpOutBuffer
  0
  0
  IOCTL_DISK_GET_DRIVE_GEOMETRY
  R@ DeviceIoControl . CR
  R> CLOSE-FILE THROW
  lpOutBuffer /DISK_GEOMETRY DUMP
;
: FORMAT
  S" \\.\B:" R/W OPEN-FILE THROW >R
  0
  lpBytesReturned
  0
  0
  /FORMAT_PARAMETERS
  lpInBuffer
  IOCTL_DISK_FORMAT_TRACKS
  R@ DeviceIoControl . CR
  R> CLOSE-FILE THROW
;