14.1.2.1 Setting Up a CustomTimerDpc Routine
At a minimum, any NT driver that has CustomTimerDpc routines must provide resident storage for at least one timer object (of type KTIMER) and resident storage for some number, determined by how many DPC routines that driver has, of DPC objects (of type KDPC).
With very few exceptions, NT drivers that have CustomTimerDpc routines should provide storage for both a timer object and a DPC object for each CustomTimerDpc routine the driver has.
The DriverEntry routine must set up each CustomTimerDpc routine as follows:
1.Call KeInitializeDpc to set up the DPC object with the CustomTimerDpc routine and a DeferredContext pointer to the driver-determined context area.
2.Call KeInitializeTimer or KeInitializeTimerEx to set up the timer object to be associated with the CustomTimerDpc routine.
In other words, setting up a CustomTimerDpc routine is exactly like setting up a CustomDpc routine with an additional step to initialize the timer object. A CustomTimerDpc routine is not associated with a particular timer object until the driver calls KeSetTimer or KeSetTimerEx with the Dpc pointer to the corresponding DPC object and Timer pointer to that timer object.
Note also that a driver cannot pass additional context pointers to its CustomTimerDpc routine in calls to KeSetTimer or KeSetTimerEx, while a device driver's ISR can pass two SystemArgument pointers when it queues a CustomDpc routine with KeInsertQueueDpc.
For more information about CustomDpc routines, see Chapter 9. For more information about setting up timer objects and DPCs, see also Chapter 3. For specific information about any support routine mentioned in this chapter, see the Kernel-Mode Driver Reference.