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
);
If the routine succeeds, it must return STATUS_SUCCESS. Otherwise, it must return one of the error status values defined in ntstatus.h.
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.