Hardware Dev Center

CustomTimerDpc routine

The CustomTimerDpc routine executes after a timer object's time interval expires.

Syntax


KDEFERRED_ROUTINE CustomTimerDpc;

VOID CustomTimerDpc(
  _In_     struct _KDPC *Dpc,
  _In_opt_ PVOID        DeferredContext,
  _In_opt_ PVOID        SystemArgument1,
  _In_opt_ PVOID        SystemArgument2
)
{ ... }

Parameters

Dpc [in]

Caller-supplied pointer to a KDPC structure, which represents the DPC object associated with this CustomTimerDpc routine.

DeferredContext [in, optional]

Caller-supplied pointer to driver-defined context information, specified in a previous call to KeInitializeDpc.

SystemArgument1 [in, optional]

Not used.

SystemArgument2 [in, optional]

Not used.

Return value

None

Remarks

To create a DPC object and register a CustomTimerDpc routine for that object, a driver must call KeInitializeDpc.

To queue a CustomTimerDpc routine for execution, a driver routine must call KeSetTimer or KeSetTimerEx, supplying a DPC object pointer returned by KeInitializeDpc. The system calls the CustomTimerDpc routine when the timer interval expires.

For more information about CustomTimerDpc routines, see Timer Objects and DPCs.

Examples

To define a CustomTimerDpc callback routine, you must first provide a function declaration that identifies the type of callback routine you're defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it's a requirement for writing drivers for the Windows operating system.

For example, to define a CustomTimerDpc callback routine that is named MyCustomTimerDpc, use the KDEFERRED_ROUTINE type as shown in this code example:


KDEFERRED_ROUTINE CustomTimerDpc;

Then, implement your callback routine as follows:


_Use_decl_annotations_
VOID
  MyCustomTimerDpc(
    struct _KDPC  *Dpc,
    PVOID  DeferredContext,
    PVOID  SystemArgument1,
    PVOID  SystemArgument2
    )
  {
      // Function body
  }

The KDEFERRED_ROUTINE function type is defined in the Wdm.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the _Use_decl_annotations_ annotation to your function definition. The _Use_decl_annotations_ annotation ensures that the annotations that are applied to the KDEFERRED_ROUTINE function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for WDM Drivers. For information about _Use_decl_annotations_, see Annotating Function Behavior.

Requirements

Target platform

Desktop

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

IRQL

Called at DISPATCH_LEVEL.

See also

KeInitializeDpc
KeSetTimer
KeSetTimerEx

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft