Hi, all,
I have a crash dump on an XP system that shows the wait wake callback function tries to access the NULL pointer. By digging deeply, it seems that callback function was being call with the context set to NULL. We use the context for passing the device extension pointer and use it in the function, so the crash happens.
I am sure the context is set correctly when calling PoRequestPowerIrp, why that context turns to NULL in the callback?
Here is my code.
Status = PoRequestPowerIrp ( DeviceExtension->PhysicalDeviceObject,
IRP_MN_WAIT_WAKE,
PowerState,
(PREQUEST_POWER_COMPLETE)UsbWaitWakeCallback,
DeviceExtension,
&DeviceExtension->WaitWakeIrp);
VOID
UsbWaitWakeCallback (
PDEVICE_OBJECT DeviceObject,
UCHAR MinorFunction,
POWER_STATE PowerState,
PVOID Context,
PIO_STATUS_BLOCK IoStatus )
{
FUNCTIONNAME(“UsbWaitWakeCallback()”)
PUSB_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = (PUSB_DEVICE_EXTENSION)Context;
// Context is NULL here!!!
Thanks,
Adam