ExRegisterCallback function

The ExRegisterCallback routine registers a given callback routine with a given callback object.


PVOID ExRegisterCallback(
  _Inout_  PCALLBACK_OBJECT   CallbackObject,
  _In_     PCALLBACK_FUNCTION CallbackFunction,
  _In_opt_ PVOID              CallbackContext



A pointer to a callback object obtained from the ExCreateCallback routine.


A pointer to a driver-implemented callback routine, which must be nonpageable. The callback routine must conform to the following prototype:

    IN PVOID CallbackContext,
    IN PVOID Argument1,
    IN PVOID Argument2

The callback routine parameters are as follows:


A pointer to a driver-supplied context area as specified in the CallbackContext parameter of ExRegisterCallback.


A pointer to a parameter defined by the callback object.


A pointer to a parameter defined by the callback object.


A pointer to a caller-defined structure of data items to be passed as the context parameter of the callback routine each time it is called. Typically the context is part of the caller's device object extension.

Return Value

ExRegisterCallback returns a pointer to a callback registration handle that should be treated as opaque and reserved for system use. This pointer is NULL if ExRegisterCallback completes with an error.


A driver calls ExRegisterCallback to register a callback routine with a specified callback object.

If the object allows only one registered callback routine, and such a routine is already registered, ExRegisterCallback returns NULL.

Callers of ExRegisterCallback must save the returned pointer for use later in a call to ExUnregisterCallback. The pointer is required when removing the callback routine from the list of registered callback routines for the callback object.

The meanings of Argument1 and Argument2 of the registered callback routine depend on the callback object and are defined by the component that created it. The following are the parameters for the system-defined callback objects:

Starting with Windows Vista, the \Callback\ProcessorAdd callback object is available to dynamically track changes in the processor population. The KeRegisterProcessorChangeCallback routine provides similar information, but additionally supports a KE_PROCESSOR_CHANGE_ADD_EXISTING flag that a driver can use to enumerate the processors in the initial multiprocessor system configuration. For drivers that run in Windows Server 2008 and later versions of Windows, use KeRegisterProcessorChangeCallback instead of the \Callback\ProcessorAdd callback object, if possible.

For more information about callback objects, see Callback Objects.

The operating system calls registered callback routines at the same IRQL at which the driver that created the callback called the ExNotifyCallback routine.


Windows version Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
DDI compliance rules IrqlExApcLte2, HwStorPortProhibitedDDIs

See Also






Send comments about this topic to Microsoft