16.9.2  Creating Symbolic Links between Devices and ARC Names

Drivers of floppy and CD-ROM devices from which the system itself can be loaded must be identified by the ARC or NtDetect components during the earliest phase of the system boot process.

For such a boot-from floppy or CD-ROM device in a given machine, a hardware device name, representing a vector to the device, is passed to the system boot loader by the ARC component. To ensure driver portablity across NT platforms, the OS loader sets up the ARC names in x86-based NT machines.

When the driver of a floppy or CD-ROM device is loaded, it must call IoAssignArcName to create a symbolic link between the ARC name for the device and the name that the driver assigned when it created a device object to represent a possible boot-from device.

For example, when such a CD-ROM driver creates a device object for a CD-ROM drive, it should include code somewhat like the following:

{

    CCHAR ntNameBuffer[MAXIMUM_FILENAME_LENGTH];

    CCHAR arcNameBuffer[MAXIMUM_FILENAME_LENGTH];

    STRING ntNameString;

    STRING arcNameString;

    UNICODE_STRING ntUnicodeString;

    UNICODE_STRING arcUnicodeString;

            :      :

    RtlInitString(&ntNameString, ntNameBuffer);

    (VOID)RtlAnsiStringToUnicodeString(

                                        &ntUnicodeString,

                                        &ntNameString,

                                        TRUE);

            :     :

    // Call IoCreateDevice with ntUnicodeString

            :     :

    //

    // An ARC name looks something like

    // \ArcName\scsi(0)cdrom(0)fdisk(0)

    //

    RtlInitString(&arcNameString, arcNameBuffer);

    status = RtlAnsiStringToUnicodeString(

                                        &arcUnicodeString,

                                        &arcNameString,

                                        TRUE);

    if (!NT_SUCCESS(status)) {

        RtlFreeUnicodeString(&ntUnicodeString);

        goto CreateDeviceObjectsExit;

    }

    IoAssignArcName(&arcUnicodeString,  &ntUnicodeString);

    RtlFreeUnicodeString(&arcUnicodeString);

            :     :

 

If such a driver has an Unload routine, it must call IoDeassignArcName to delete each such symbolic link that the DriverEntry routine set up.