Int 21H [2.0] Function 44H (68) Subfunction 02H IOCTL: read control data from character device driver

Reads control data from a character-device driver. The length and contents of the data are specific to each device driver and do not follow any standard format. This function does not necessarily result in any input from the physical device.

Call with:

AH = 44H

AL = 02H

BX = handle

CX = number of bytes to read

DS:DX = segment:offset of buffer

Returns:

If function successful

Carry flag = clear

AX = bytes read

and buffer contains control data from driver

If function unsuccessful

Carry flag = set

AX = error code

Notes:

If supported by the driver, this subfunction can be used to obtain hardware-dependent status and availability information that is not supported by other MS-DOS function calls.

Character-device drivers are not required to support IOCTL Subfunction 02H. A program can test bit 14 of the device information word returned by IOCTL Subfunction 00H to determine whether the driver supports this subfunction. If Subfunction 02H is requested and the driver does not have the ability to process control data, control returns to the program with the carry flag set and error code 0001H (invalid function) in register AX.

Example:

Read a control string from the standard list driver into the buffer buff.

stdprn equ 4 ; standard list handle

buflen equ 64 ; length of buffer

ctllen dw ? ; length of control string

buff db buflen dup (0) ; receives control string

.

.

.

mov ax,4402h ; function & subfunction

mov bx,stdprn ; standard list handle

mov cx,buflen ; buffer length

mov dx,seg buff ; buffer address

mov ds,dx

mov dx,offset buff

int 21h ; transfer to MS-DOS

jc error ; jump if read failed

mov ctllen,ax ; save control string length

.

.

.