Re: Serial Port Filter Driver causes DRIVER_POWER_STATE_FAILURE (0x9f) Bug Check

See the latest ddk:
Calling PoStartNextPowerIrp from a Filter Driver

===========================
Mark Roddy
Consultant, Microsoft DDK MVP
Hollis Technology Solutions
xxxxx@hollistech.com
www.hollistech.com
603-321-1032

-----Original Message-----
From: “Dale Larson”
To: “NT Developers Interest List”
Date: Fri, 16 Aug 2002 11:36:53 -0400
Subject: [ntdev] Serial Port Filter Driver causes
DRIVER_POWER_STATE_FAILURE (0x9f) Bug Check

> Hi,
>
> I’m attempting to create a filter driver for a serial port. I can
> successfully attach the driver and intercept serial calls. However,
> when the driver is unloaded I get a 0x9F bug check
> (DRIVER_POWER_STATE_FAILURE) with parameter 1 = 1. The DDK docs
> say this means “The device object being freed still has an
> outstanding power request which it has not completed”.
>
> My desire was to have a filter driver that could run on NT4 as
> well as the later version of NT so I initially simply passed
> all IRPs down to the next layer like so:
>
> NTSTATUS JCSerialFilterDispatch(PDEVICE_OBJECT pDeviceObject, PIRP
> pIrp)
> {
> PIO_STACK_LOCATION pIrpStkCur;
> PIO_STACK_LOCATION pIrpStkNext;
> PJCSERIAL_EXTENSION pDevExt =
> (PJCSERIAL_EXTENSION)pDeviceObject->DeviceExtension;
>
> pIrpStkCur = IoGetCurrentIrpStackLocation(pIrp);
> pIrpStkNext = IoGetNextIrpStackLocation(pIrp);
> *pIrpStkNext = pIrpStkCur;
> IoSetCompletionRoutine(pIrp, NULL, NULL, FALSE, FALSE, FALSE);
>
> return IoCallDriver(pDevExt->pSerialDevice, pIrp);
> }
>
> Looking around on the net I found that IRPs for the function
> IRP_MJ_POWER should use PoCallDriver() rather than IoCallDriver.
> Of course this call isn’t in NT4 but I can live with that
> (create two versions) if necessary. So I changed my dispatch
> routine to look like:
>
> NTSTATUS JCSerialFilterDispatch(PDEVICE_OBJECT pDeviceObject, PIRP
> pIrp)
> {
> PIO_STACK_LOCATION pIrpStkCur;
> PIO_STACK_LOCATION pIrpStkNext;
> PJCSERIAL_EXTENSION pDevExt =
> (PJCSERIAL_EXTENSION)pDeviceObject->DeviceExtension;
> USHORT nMajorFunction;
>
> pIrpStkCur = IoGetCurrentIrpStackLocation(pIrp);
> nMajorFunction = pIrpStkCur->MajorFunction;
> #if WINVER >= 0x0500
> if (nMajorFunction == IRP_MJ_POWER)
> {
> // Need to handle power IRPs in a special manner.
> IoSkipCurrentIrpStackLocation(pIrp);
> return PoCallDriver(pDevExt->pSerialDevice, pIrp);
> }
> #endif
> /
@@ Eventually do other stuff here @@ */
> pIrpStkNext = IoGetNextIrpStackLocation(pIrp);
> *pIrpStkNext = *pIrpStkCur;
> IoSetCompletionRoutine(pIrp, NULL, NULL, FALSE, FALSE, FALSE);
>
> return IoCallDriver(pDevExt->pSerialDevice, pIrp);
> }
>
> Unfortunately this fails in the same manner. I set a
> breakpoint on the IRP_MJ_POWER handler and it is called.
>
> How should this situation be properly handled? I would
> think that all legacy filter drivers would have this
> problem but I can’t find a solution to this in DejaNews.
>
> Dale
> —
> You are currently subscribed to ntdev as: xxxxx@hollistech.com
> To unsubscribe send a blank email to %%email.unsub%%