NDIS_TIMER_FUNCTION callback function

The NetTimerCallback function is called by NDIS after a driver sets a one-shot or periodic timer when a timer fires.

Note  You must declare the function by using the NDIS_TIMER_FUNCTION type. For more information, see the following Examples section.



VOID NetTimerCallback(
  _In_ PVOID SystemSpecific1,
  _In_ PVOID FunctionContext,
  _In_ PVOID SystemSpecific2,
  _In_ PVOID SystemSpecific3
{ ... }


SystemSpecific1 [in]

A pointer to a system-specific value that is reserved for system use.

FunctionContext [in]

A pointer to a driver-supplied context area that the driver passed to the NdisSetTimerObject function. If the FunctionContext parameter of NdisSetTimerObject was NULL, NDIS uses the default value that the driver specified in the NDIS_TIMER_CHARACTERISTICS structure. The driver passed the structure to the NdisAllocateTimerObject function to initialize the associated timer object.

SystemSpecific2 [in]

A pointer to a system-specific value that is reserved for system use.

SystemSpecific3 [in]

A pointer to a system-specific value that is reserved for system use.

Return value



Any NDIS driver can have one or more NetTimerCallback functions. Each such NetTimerCallback function must be associated with a different driver-allocated and initialized timer object.

The driver initializes a driver-allocated timer object by calling the NdisAllocateTimerObject function.

A subsequent call to the NdisSetTimerObject function causes the NetTimerCallback function that is associated with the timer object to be run after a specified interval or periodically.

To cancel calls to NetTimerCallback, call the NdisCancelTimerObject function. NDIS might still call NetTimerCallback if the timeout has already expired before the call to NdisCancelTimerObject.

If a NetTimerCallback function shares resources with other driver functions, the driver should synchronize access to those resources with a spin lock.


To define a NetTimerCallback function, you must first provide a function declaration that identifies the type of function you're defining. Windows provides a set of function types for drivers. Declaring a function using the 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 NetTimerCallback function that is named "MyTimerCallback", use the NDIS_TIMER_FUNCTION type as shown in this code example:


Then, implement your function as follows:

    PVOID  SystemSpecific1,
    PVOID  FunctionContext,
    PVOID  SystemSpecific2,
    PVOID  SystemSpecific3

The NDIS_TIMER_FUNCTION function type is defined in the Ndis.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 NDIS_TIMER_FUNCTION 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 NDIS Drivers. For information about _Use_decl_annotations_, see Annotating Function Behavior.


Target platform


Supported in NDIS 6.0 and later.


Ndis.h (include Ndis.h)



See also

Initializing NDIS Timers
Servicing Timers
Setting and Clearing Timers



Send comments about this topic to Microsoft