DriverEntry's Required Responsibilities
The required, ordered responsibilities of a DriverEntry routine are as follows:
Supply entry points for the driver's standard routines.
The driver stores entry points for many of its standard routines in the driver object or driver extension. Such entry points include those for the driver's AddDevice routine, dispatch routines, StartIo routine, and Unload routine. For example, a driver would set the entry points for its AddDevice, DispatchPnP, and DispatchPower routines with statements like the following (Xxx is a placeholder for a vendor-supplied prefix identifying the driver):
: DriverObject->DriverExtension->AddDevice = XxxAddDevice; DriverObject->MajorFunction[IRP_MJ_PNP] = XxxDispatchPnp; DriverObject->MajorFunction[IRP_MJ_POWER] = XxxDispatchPower; :
Additional standard routines, such as ISRs or IoCompletion routines, are specified by calling system support routines. For more information, see the descriptions of individual standard driver routines.
Create and/or initialize various driver-wide objects, types, or resources the driver uses. Note that most standard routines use objects on a per-device basis, so drivers should set up such objects in their AddDevice routines or after receiving an IRP_MN_START_DEVICE request.
If the driver has a device-dedicated thread or waits on any kernel-defined dispatcher objects, the DriverEntry routine might initialize kernel dispatcher objects. (Depending on how the driver uses the object(s), it might instead perform this task in its AddDevice routine or after receiving an IRP_MN_START_DEVICE request.)
Free any memory that it allocated and is no longer required.
Return NTSTATUS indicating whether the driver successfully loaded and can accept and process requests from the PnP manager to configure, add, and start its devices. (See DriverEntry Return Values.)