Function 04H (4): Read

The read function transfers data from the device into the specified memory buffer. If an error is encountered during the read, the function must set the error status and, in addition, report the number of bytes or sectors successfully transferred; it is not sufficient to simply report an error.

The read function is called with

RH + 1 BYTE Unit code (block devices)

RH + 2 BYTE Command code = 4

RH + 13 BYTE Media descriptor byte

RH + 14 DWORD Transfer address

RH + 18 WORD Byte/sector count

RH + 20 WORD Starting sector number (block

devices)

For block-device read operations in MS-DOS version 4, if the logical unit is larger than 32 MB and bit 1 of the driver's attribute word is set, the following request structure is used instead:

RH + 1 BYTE Unit code

RH + 2 BYTE Command code = 4

RH + 13 BYTE Media descriptor byte

RH + 14 DWORD Transfer address

RH + 18 WORD Sector count

RH + 20 WORD Contains -1 to signal use of 32-bit

sector number

RH + 26 DWORD 32-bit starting sector number

The read function returns

RH + 3 WORD Status

RH + 18 WORD Actual bytes or sectors transferred

RH + 22 DWORD Pointer to volume label if error 0FH

is returned (MS-DOS versions 3.0 and

later)

Under MS-DOS versions 3.0 and later, this routine can use the count of open files maintained by the open and close functions (0DH and 0EH) and the media descriptor byte to determine whether the disk has been illegally changed.