Appendix 2 - Structure of internal DOS tables.

Invar.

Offset
Size
Item
-02hWordSegment of first memory arena header.
00hDWord--> First block header.
04hDWord--> FILES array.
08hDWord--> CLOCK$ driver.
0ChDWord--> CON driver.
10hWordMax. bytes per sector.
12hDWord--> First disk buffer.
16hDWord--> LASTDRIVE array.
1AhDWord--> FCB table.
1EhWordSize of FCB table.
20hByteNo. of block devices.
21hByteLASTDRIVE value.
22hNUL device starts here.

Device Driver.

Offset
Size
Item
00hDWord--> Next driver in chain (x:FFFF means end.)
04hWordDevice attributes.
06hWordDevice strategy routine offset.
08hWordDevice interrupt routine offset.
0Ah8 BytesDevice name padded with spaces.

Bios Parameter Block (BPB.)

Offset
Size
Item
00hWordBytes per sector.
02hByteSectors per cluster.
03hWordReserved sectors.
05hByteNumber of FATs.
06hWordMax. root directory entries.
08hWordTotal number of sectors.
0AhByteMedia descriptor byte.
0BhWordSectors per FAT.

Block Header.

Offset
Size
Item
00hByteAbsolute block number.
01hByteBlock number in device.
02hWordBytes per sector.
04hByteSectors per cluster - 1.
05hByteCluster to sector shift (how far to shift left bytes/sector to get bytes/cluster.)
06hWordNumber of reserved sectors.
08hByteNumber of FATs.
09hWordNumber of root directory entries.
0BhWordSector no. of first data.
0DhWordNo. of clusters + 1.
0FhWordSectors per FAT.

NOTE: This is a single byte in DOS 3, so all offsets from here onwards must have one subtracted from them.

11hWordFirst sector of root directory.
13hDWord--> Device driver for this block.
17hByteMedia descriptor byte.
18hByte0FFh means must rebuild.
19hDWord--> Next block header in chain (x:FFFF means end.)
1DhWord?
1FhByte?
20hByte?

Arena Header.

Offset
Size
Item
00hByte'Z' if last block, else 'M'.
01hWordSegment owner.
03hWordSegment size.
05h3 BytesUnused.
08h8 BytesOwner name (if self owned.) Terminated with NULL byte if less than eight characters.

Program Segment Prefix (PSP.)

Offset
Size
Item
00hWordProgram exit point (INT 20h.)
02hWordMemory size in paragraphs.
04hByteUnused.
05h5 BytesFar call to DOS function handler.
0AhDWordOld INT 22h vector.
0EhDWordOld INT 23h vector.
12hDWordOld INT 24h vector.
16hWordParent PSP segment.
18h14h BytesOpen files (0FFh = unused.)
2ChWordEnvironment segment.
2EhDWordFar ptr to SS:SP.
32hWordMax. open files.
34hDWord--> Open files table (usually PSP:0018h.)
38h8 Bytes?
40hWordVersion number reported to this process (DOS 5+.)
42h0Eh Bytes?
50h3 BytesDOS function dispatcher (INT 21h, RETF.)
53hWordUnused.
55hFCB #1 extension.
5ChFCB #1.
6ChFCB #2.
80h80h BytesCommand line tail.