power Irp debug help



I copied the following power Irp code from a sample driver file. It works
fine with Windows XP but on Windows Vista (with driver Verifier enabled) I
get blue screen when I am shutting down my PC. Can someone help me with
debugging.

Thanks,
Raj

NTSTATUS
t1394Diag_Power(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION IrpSp;
PDEVICE_EXTENSION deviceExtension;
POWER_STATE State;
KIRQL Irql;

ENTER("t1394Diag_Power");

deviceExtension = DeviceObject->DeviceExtension;

IrpSp = IoGetCurrentIrpStackLocation(Irp);

State = IrpSp->Parameters.Power.State;

TRACE(TL_TRACE, ("Power.Type = 0x%x\n", IrpSp->Parameters.Power.Type));
TRACE(TL_TRACE, ("Power.State.SystemState = 0x%x\n", State.SystemState));
TRACE(TL_TRACE, ("Power.State.DeviceState = 0x%x\n", State.DeviceState));

switch (IrpSp->MinorFunction)
{
case IRP_MN_SET_POWER:

TRACE(TL_TRACE, ("IRP_MN_SET_POWER\n"));

switch (IrpSp->Parameters.Power.Type)
{
case SystemPowerState:

TRACE(TL_TRACE, ("SystemPowerState\n"));

// Send the IRP down
PoStartNextPowerIrp(Irp);
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(Irp,
(PIO_COMPLETION_ROUTINE) t1394Diag_SystemSetPowerIrpCompletion,
NULL, TRUE, TRUE, TRUE);

ntStatus = PoCallDriver(deviceExtension->StackDeviceObject, Irp);

break;

case DevicePowerState:

TRACE(TL_TRACE, (" POWER: Current device state = 0x%x, new device
state = 0x%x\n",
deviceExtension->CurrentDevicePowerState, State.DeviceState));

PoStartNextPowerIrp(Irp);
IoCopyCurrentIrpStackLocationToNext(Irp);

ntStatus = PoCallDriver(deviceExtension->StackDeviceObject, Irp);

break; // DevicePowerState

default:

TRACE(TL_ERROR,(" default case Set_Power type 0x%x
\n",IrpSp->Parameters.Power.Type));
PoStartNextPowerIrp(Irp); // Added in Windows Vista porting
IoSkipCurrentIrpStackLocation(Irp);

ntStatus = PoCallDriver(deviceExtension->StackDeviceObject, Irp);

break;
}

break; // IRP_MN_SET_POWER

case IRP_MN_QUERY_POWER:

TRACE(TL_TRACE, ("IRP_MN_QUERY_POWER\n"));

PoStartNextPowerIrp(Irp);

IoSkipCurrentIrpStackLocation(Irp);

ntStatus = PoCallDriver(deviceExtension->StackDeviceObject, Irp);

break; // IRP_MN_QUERY_POWER

default:

TRACE(TL_ERROR, (" Default DiagPower 0x%x\n", IrpSp->MinorFunction));

PoStartNextPowerIrp(Irp);
IoSkipCurrentIrpStackLocation(Irp);

ntStatus = PoCallDriver(deviceExtension->StackDeviceObject, Irp);

break; // default

} // switch

EXIT("t1394Diag_Power", ntStatus);

return(ntStatus);
} // t1394Diag_Power



1: kd> !analyze -v
*******************************************************************************
*
*
* Bugcheck Analysis
*
*
*
*******************************************************************************

DRIVER_VERIFIER_IOMANAGER_VIOLATION (c9)
The IO manager has caught a misbehaving driver.
Arguments:
Arg1: 00000226, (Fatal error) An IRP dispatch handler has returned without
passing down or
completing this IRP, or someone forgot to return STATUS_PENDING. (IRP
specified.)
Arg2: 8e38f130
Arg3: 00000000
Arg4: 00000000

Debugging Details:
------------------


ERROR_CODE: (NTSTATUS) 0xc9 - The operating system cannot run %1.

BUGCHECK_STR: 0xc9_226

DRIVER_VERIFIER_IO_VIOLATION_TYPE: 226

FAULTING_IP:
sfbXp!t1394Diag_Power+0
[z:\0590-090-909_windows_sfb\software\sfb\driver\1394diag\power.c @ 26]
8e38f130 8bff mov edi,edi

DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

PROCESS_NAME: System

CURRENT_IRQL: 2

LAST_CONTROL_TRANSFER: from 826ca6fb to 824acf57

STACK_TEXT:
a64b2774 826ca6fb 0000004c 000000c9 a64b2794 nt!KeBugCheckEx+0x1e
a64b28fc 826ca293 890c3238 8661d540 888bf830 nt!ViBugcheckHalt+0xb0
a64b2ba0 826ca1a4 00000226 a64b2bb0 a64b2c98 nt!VfBugcheckThrowException+0xd9
a64b2c80 826cb5da 00000226 00000041 8e38f130
nt!VfBugcheckThrowIoException+0x11b
a64b2cb4 826c9f80 890c329c c38d6eb8 a64b2ce4 nt!IovpCallDriver2+0x33e
a64b2cc4 826c268e 890c329c c38d6fb0 87bd3020 nt!VfAfterCallDriver+0x110
a64b2ce4 82467b80 82405e07 c38d6fd4 87bd3020 nt!IovCallDriver+0x25f
a64b2cf8 82405e07 a64b2d20 826d42ab 87bd3020 nt!IofCallDriver+0x1b
a64b2d00 826d42ab 87bd3020 c38d6eb8 87bd31c0 nt!PoCallDriver+0x10
a64b2d20 82406d12 87bd3278 c38d6eb8 00000000 nt!ViFilterDispatchPower+0x5e
a64b2d7c 825afbad 87957080 a64b9680 00000000 nt!PopIrpWorker+0x40f
a64b2dc0 8249a346 824068ff 87957080 00000000 nt!PspSystemThreadStartup+0x9d
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16


STACK_COMMAND: .bugcheck ; kb

FOLLOWUP_IP:
sfbXp!t1394Diag_Power+0
[z:\0590-090-909_windows_sfb\software\sfb\driver\1394diag\power.c @ 26]
8e38f130 8bff mov edi,edi

SYMBOL_NAME: sfbXp!t1394Diag_Power+0

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: sfbXp

IMAGE_NAME: sfbXp.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 4762fea9

FAILURE_BUCKET_ID: 0xc9_226_VRF_sfbXp!t1394Diag_Power+0

BUCKET_ID: 0xc9_226_VRF_sfbXp!t1394Diag_Power+0

Followup: MachineOwner
---------

1: kd> .bugcheck;kb
Bugcheck code 000000C9
Arguments 00000226 8e38f130 00000000 00000000
ChildEBP RetAddr Args to Child
a64b2774 826ca6fb 0000004c 000000c9 a64b2794 nt!KeBugCheckEx+0x1e
a64b28fc 826ca293 890c3238 8661d540 888bf830 nt!ViBugcheckHalt+0xb0
a64b2ba0 826ca1a4 00000226 a64b2bb0 a64b2c98 nt!VfBugcheckThrowException+0xd9
a64b2c80 826cb5da 00000226 00000041 8e38f130
nt!VfBugcheckThrowIoException+0x11b
a64b2cb4 826c9f80 890c329c c38d6eb8 a64b2ce4 nt!IovpCallDriver2+0x33e
a64b2cc4 826c268e 890c329c c38d6fb0 87bd3020 nt!VfAfterCallDriver+0x110
a64b2ce4 82467b80 82405e07 c38d6fd4 87bd3020 nt!IovCallDriver+0x25f
a64b2cf8 82405e07 a64b2d20 826d42ab 87bd3020 nt!IofCallDriver+0x1b
a64b2d00 826d42ab 87bd3020 c38d6eb8 87bd31c0 nt!PoCallDriver+0x10
a64b2d20 82406d12 87bd3278 c38d6eb8 00000000 nt!ViFilterDispatchPower+0x5e
a64b2d7c 825afbad 87957080 a64b9680 00000000 nt!PopIrpWorker+0x40f
a64b2dc0 8249a346 824068ff 87957080 00000000 nt!PspSystemThreadStartup+0x9d
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16

.



Relevant Pages

  • RE: Question about WinXP standby removes device
    ... // Get a pointer to the current location in the Irp. ... switch ... case PowerSystemWorking: ... PoSetPowerState(fdo, DevicePowerState, ...
    (microsoft.public.development.device.drivers)
  • Re: drive present detection?
    ... the free space of all online drives. ... If the underlying device driver determines that the media has not ... changed, the driver should complete the IRP, returning the IoStatus ...
    (microsoft.public.win32.programmer.kernel)
  • winddk7600.16385.0srcinputvserialVSerial.c WDK 1.9 IRP_MN_QUERY_ID can not pass DTM Device Path Exer
    ... I've developed a virtual HID driver for win 7 which I have to implement ... IRP_MN_QUERY_ID to report Hardware IDs, ... if forward IRP to lower device, got The driver has responded to an IRP ... PWCHAR buffer = NULL; ...
    (microsoft.public.development.device.drivers)
  • Re: Questions about I/O Buffers
    ... Windows Driver Developer Support ... > I am developing the firmware of a camera that talks to Microsoft USB Video ... > IRP ... >>> I look into the IRP packet that sends DEVICE_CONTROL to low layer. ...
    (microsoft.public.development.device.drivers)
  • Re: Propagating the Pending Bit
    ... Here is the quotation from IoMarkIrpPending documentation in WDK ... If a driver sets an IoCompletion routine for an IRP and then passes the ...
    (microsoft.public.development.device.drivers)

Loading