Click to Rate and Give Feedback

  Switch on low bandwidth view
Windows Driver Kit: Kernel-Mode Driver Architecture
Writing a DriverEntry Routine

Each driver must have a DriverEntry routine, which initializes driver-wide data structures and resources. The I/O manager calls the DriverEntry routine when it loads the driver.

In a driver that supports Plug and Play (PnP), as all drivers should, the DriverEntry routine is responsible for driver initialization, while the AddDevice routine (and, possibly, the dispatch routine that handles a PnP IRP_MN_START_DEVICE request) is responsible for device initialization. Driver initialization includes exporting the driver's other entry points, initializing certain objects the driver uses, and setting up various per-driver system resources. (non-PnP drivers have significantly different requirements, as described in the Driver Development Kit [DDK] for Microsoft Windows NT 4.0 and earlier.)

DriverEntry routines are called in the context of a system thread at IRQL = PASSIVE_LEVEL.

A DriverEntry routine can be pageable and should be in an INIT segment so it will be discarded. Use an alloc_text pragma directive, as illustrated in the sample drivers that are provided with the Windows Driver Kit (WDK).

This section contains the following topics:


Send feedback on this topic
Built on May 20, 2009
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker