mov bx, Handle ;handle of file or device
mov ax, 4400h ;Get Device Data
int 21h
jc error_handler ;carry set means error
mov DevStatus, dx ;device-status value
Get Device Data (Function 4400h) returns information about the handle, such as whether it identifies a file or a device.
Handle
Identifies the file or device to return information about.
If the function is successful, the carry flag is clear and the DX register contains the device-status value. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following:
Value | Name |
0001h | ERROR_INVALID_FUNCTION |
0005h | ERROR_ACCESS_DENIED |
0006h | ERROR_INVALID_HANDLE |
Bit 7 in the DX register specifies whether the handle identifies a file or a device. If bit 7 is 0, the handle identifies a file, and the other bits in the DX register have the following meaning:
Bits | Meaning |
0-5 | Drive number (0 = A, 1 = B, etc.) |
6 | 1 = file has not been written to |
All other bits are zero. Bits 0–5 may specify an invalid drive number if the file is a network file that is not associated with a redirected drive.
If bit 7 is 1, the handle identifies a device, and the other bits in the DX register have the following meaning:
Bit | Meaning |
0 | 1 = Console input device |
1 | 1 = Console output device |
2 | 1 = Null device |
3 | 1 = Clock device |
4 | 1 = Special device |
5 | 1 = Binary mode, 0 = ASCII mode |
6 | 0 = End of file returned if device is read |
Bits 8 through 15 are identical to the high 8 bits of the dhAttribute field in the DEVICEHEADER structure for the device.
Function 4401h Set Device Data