IO_TIMER_ROUTINE callback function (wdm.h)

The IoTimer routine is a DPC that, if registered, is called once per second.

Syntax

IO_TIMER_ROUTINE IoTimerRoutine;

void IoTimerRoutine(
  [in]           _DEVICE_OBJECT *DeviceObject,
  [in, optional] PVOID Context
)
{...}

Parameters

[in] DeviceObject

Caller-supplied pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.

[in, optional] Context

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

Return value

None

Remarks

A driver's IoTimer routine executes in a DPC context, at IRQL = DISPATCH_LEVEL.

A driver can associate an IoTimer routine with each device object it creates. (You can use a single IoTimer routine with multiple device objects, or a separate routine with each device object.) To register an IoTimer routine, a driver must call IoInitializeTimer, supplying the IoTimer routine's address and a device object pointer.

To queue an IoTimer routine for execution, a driver routine must call IoStartTimer. The system calls the IoTimer routine once per second until the driver calls IoStopTimer.

For more information about IoTimer routines, see IoTimer Routines.

Examples

To define an IoTimer 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 an IoTimer callback routine that is named MyIoTimer, use the IO_TIMER_ROUTINE type as shown in this code example:

IO_TIMER_ROUTINE MyIoTimer;

Then, implement your callback routine as follows:

_Use_decl_annotations_
VOID
  MyIoTimer(
    struct DEVICE_OBJECT  *DeviceObject,
    PVOID  Context
    )
  {
      // Function body
  }

The IO_TIMER_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 IO_TIMER_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

Requirement Value
Target Platform Desktop
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
IRQL Called at DISPATCH_LEVEL (see Remarks section).