7.3.2  Setting Up Driver-Managed Queues

The DriverEntry routine must set up each interlocked queue and/or each supplemental device queue that an NT driver has, as follows:

·For drivers that use a doubly-linked interlocked queue, the DriverEntry routine must initialize the queue header by calling InitializeListHead, which is an NT runtime library routine. It also must initialize the executive spin lock by calling KeInitializeSpinLock.

·For drivers that use a supplemental device queue, the DriverEntry routine must call KeInitializeDeviceQueue to initialize the device queue object.

If a new NT driver sets up an internal queue for an indefinite (but limited at any given moment) number of fixed-size, driver-structured entries, a zone buffer can be useful for allocating and freeing memory for such entries. For more information about using zones, see Chapter 16.

For more information about setting up and using an interlocked queue or a device queue object, see also Chapter 3. For specific information about calling the Ex...Zone, ExInterlocked..List, Ke..SpinLock, and Ke..DeviceQueue routines, see the Kernel-mode Driver Reference.