Previous Next

AddDevice

The AddDevice routine is responsible for creating functional device objects (FDO) or filter device objects (filter DO) for devices enumerated by the Plug and Play (PnP) Manager.

NTSTATUS
  XxxAddDevice(
    IN PDRIVER_OBJECT  DriverObject,
    IN PDEVICE_OBJECT  PhysicalDeviceObject 
    );

Parameters

DriverObject
Caller-supplied pointer to a DRIVER_OBJECT structure. This is the driver's driver object.
PhysicalDeviceObject
Caller-supplied pointer to a DEVICE_OBJECT structure representing a physical device object (PDO) created by a lower-level driver.

Return Value

If the routine succeeds, it must return STATUS_SUCCESS. Otherwise, it must return one of the error status values defined in ntstatus.h.

Comments

All kernel-mode drivers that support PnP must provide an AddDevice routine.

A driver's AddDevice routine executes in a system thread context at IRQL = PASSIVE_LEVEL.

A driver's AddDevice routine should be named XxxAddDevice, where Xxx is a driver-specific prefix. The driver's DriverEntry routine must store the AddDevice routine's address in DriverObject->DriverExtension->AddDevice.

An AddDevice routine's primary responsibilities are calling IoCreateDevice to create a device object, then calling IoAttachDeviceToDeviceStack to attach the device object to the device stack. For detailed information about implementing a driver's AddDevice routine, see Writing an AddDevice Routine.