[Compuware Corporation] [Compuware NuMega home page] [NuMega Lab] [teal] [DriverStudio] [Image][Image] · Home [Driver Products] Driver Technical Tips · DriverStudio Understanding NT Symbolic Links · DriverBundle · Previews Many device drivers communicate with applications. · Compatibility Typically, an application uses CreateFile to open a [Downloads] · device, and then uses ReadFile, WriteFile, and DeviceIoControl to exchange information with the Wizards driver. The name that an application passes to · Utilities CreateFile is neither the name of the driver nor the · NT source name of the device object to be opened. Instead, it examples is the name of a symbolic link to the device object, · VxD source with a special prefix to designate it as such. examples · WDM source To understand what a symbolic link is, you need to examples know that Windows NT maintains a hierarchical [Resources] · directory of objects. Device objects are just one Technical papers type of object in the hierarchy, and reside in the · Useful links \Device branch of the object directory. For example, · Technical tips \Device\Serial0 names the device object created by [Support] · SERIAL.SYS to control COM1. The system uses the object directory structure as a repository for Support information that is common to a variety of different · Knowledge base kinds of objects, such as security data and reference · Problem counts. submission · Product A symbolic link is a special type of object whose registration purpose is to refer to another object in the object · Release notes directory. The system stores symbolic links to [Shop NuMega] · devices that applications may open in branch \?? of Buy it! the object directory. Prior to NT 4.0, the branch was · Price list named \DosDevices, which is still valid. Each · How to buy symbolic link contains a string that specifies · Sales offices another object in the hierarchy. Most often, that object is a device object. For example, \??\COM1 refers to \Device\Serial0. [Y2K Compliance] Sometimes a symbolic link refers to another symbolic link. For example, \??\PRN is an alias for \??\LPT1. [More information] When calling CreateFile, an application tells the system to search for a device in the \?? branch of the object directory by prefixing the symbolic link name with the special string "\\.\". In C/C++, the quoted string looks like "\\\\.\\". For example, if the symbolic link name is MyDevice0, then the name passed to CreateFile is "\\\\.\\MyDevice0". An application can't open a device for which there is no symbolic link in the \?? branch. You can download symlinks.zip (68kb), a very simple utility program that quickly shows you the symbolic links currently defined on your system. To view the entire object directory, get Winobj from the NT Internals web site. Creating Symbolic Links There are three ways to create symbolic links: * By adding special registry entries under \HKLM\CurrentControlSet\Control\Session Manager\DOS. This approach is rarely used, and not recommended. * By calling DefineDosDevice from an application. This API is documented in the Win32 SDK. * By calling IoCreateSymbolicLink or IoCreateUnprotectedSymoblicLink from a kernel mode driver. If you are using DriverWorks, the constructor for class KDevice automatically creates the symbolic link if a link name is supplied. The link name is the third parameter to the constructor of KDevice. Here's an example, the constructor for class RamdiskDevice, which implements a ram disk: RamdiskDevice::RamdiskDevice( PCWSTR DriveLetter, ULONG nRootDirs, ULONG nSectorsPerCluster, ULONG DiskSize ) : KDevice( L"RAMDISK0", // Device name FILE_DEVICE_VIRTUAL_DISK, DriveLetter, // Symbolic Link name FILE_REMOVABLE_MEDIA, DO_DIRECT_IO ), m_Image(NULL), m_OpenCount(0) { . . . Note: In the above that string DriveLetter passed to the constructor of RamdiskDevice becomes the symbolic link to the device object. In other words, the device is known to applications by its drive letter, not by "RAMDISK0", its actual name. DriverWorks automatically prefixes \Device and \?? to the device and link names, respectively. Back to technical tip start page. DriverCentral · DriverStudio · Free downloads · Resources · Support and Services · Shop NuMega Compuware NuMega · Tel: +1 603 578-8400 · Updated: 9 August 1999 · Problems? Contact our webmaster.