BOOLEAN
KeRegisterBugCheckCallback(
IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
IN PVOID Buffer,
IN ULONG Length,
IN PUCHAR Component
);
Device drivers can call KeRegisterBugCheckCallback to register their bug-check callback routines. If a system bug check occurs, such a callback usually saves device-state information to be written into the system crash dump file.
VOID
(*PKBUGCHECK_CALLBACK_ROUTINE) (
IN PVOID Buffer,
IN ULONG Length
);
This caller-supplied routine is responsible for writing driver-determined
state information at Buffer if a bug check occurs.
KeRegisterBugCheckCallback returns TRUE if the caller-supplied routine has been successfully added to the set of registered bug-check callbacks.
KeRegisterBugCheckCallback sets up a driver-supplied routine to be called if a bug check occurs so a device driver can save state information, such as the contents of device registers, that would not otherwise be saved in a system crash-dump file.
A driver-supplied bug-check callback routine writes whatever information the driver designer chooses into the memory at Buffer. The format of the data written at Buffer is driver-determined. This memory cannot be freed unless the driver first calls KeDeregisterBugCheckCallback. Like the driver-allocated memory at Buffer, such a bug-check callback routine cannot be pageable.
When the callback routine runs, interrupts are disabled. A callback routine cannot allocate resources, such as memory, because the system is being shut down. A bug-check callback also cannot use synchronization mechanisms, such as a spin lock. However, it should not need to acquire synchronization resources because other driver routines are effectively disabled while the system is being shut down for a bug check. The callback routine can safely call the HAL’s READ_PORT_XXX and/or READ_REGISTER_XXX to collect state information from the device and transfer this data to the driver-allocated buffer. It can call any KeXxx or HalXxx that neither allocates memory nor acquires a synchronization resource.
The given Component string should identify the driver to aid in crash-dump debugging. During driver development, the Component identifier can be passed to the debugger to select only that component’s dump data for examination. A bug-check callback routine also can be debugged.
Callers of KeRegisterBugCheckCallback can be running at any IRQL. Usually, a device driver is running at IRQL PASSIVE_LEVEL in its DriverEntry routine when it calls KeRegisterBugCheckCallback.
ExAllocatePool, KeBugCheck, KeBugCheckEx, KeDeregisterBugCheckCallback, KeInitializeCallbackRecord