An example of a device with an MS-DOS device name is the serial port, COM1. It has the MS-DOS device name \DosDevices\COM1. Likewise, the C: drive has the name \DosDevices\C:.
WDM drivers do not usually supply MS-DOS device names for their devices. Instead, WDM drivers use the IoRegisterDeviceInterface routine to register a device interface. The device interface specifies devices by their capabilities, rather than by a particular naming convention. For more information, see Device Interface Classes.
Drivers are only required to supply an MS-DOS device name if the device is required to have a specific well-known MS-DOS device name to work with user-mode programs.
A driver supplies an MS-DOS device name for a device object by using the IoCreateSymbolicLink routine to create a symbolic link to the device. For example, the following code creates a symbolic link from \DosDevices\DosDeviceName to \Device\DeviceName.
UNICODE_STRING DeviceName; UNICODE_STRING DosDeviceName; RtlInitUnicodeString(&DeviceName, "L\\Device\\DeviceName"); RtlInitUnicodeString(&DosDeviceName, L"\\DosDevices\\DosDeviceName"); IoCreateSymbolicLink(&DosDeviceName, &DeviceName);Note that the system supports multiple versions of the \DosDevices directory. Make sure that your driver creates its symbolic links in the version that you intend. For more information, see Local and Global MS-DOS Device Names.
A symbolic link can also be created from a user-mode application by using the user-mode DefineDosDevice routine. For more information, see the Platform SDK.
No comments:
Post a Comment