IoStartPacket() and optional CancelFunction parameter

Hello all. I was wondering if anyone is familiar with WDM driver
cancellation routines.

Any help would be greatly appreciated. Thanks.

The following WDM PCI driver cancellation routine causes a system reset on
Windows 2000/XP.

Debugging it with NuMega SoftICE results in “Break due to Page Fault
(0Eh). Fault=0002” at the

KeRemoveEntryDeviceQueue() method call in the OnCancelReadWrite() routine
below.

I copied this code out the “Windows NT device driver development” book by
P. Viscarola & W. Mason - OSR

Ch 14 page 355 example 14.7

Here are the calling methods:

.

.

case BL_SEND:

IoMarkIrpPending(Irp );

IoStartPacket( DeviceObject, Irp, 0, OnCancelReadWrite );

status = STATUS_PENDING;

break;

case BL_RECEIVE:

IoMarkIrpPending(Irp );

IoStartPacket( DeviceObject, Irp, 0, OnCancelReadWrite );

status = STATUS_PENDING;

break;

.

.

VOID OnCancelReadWrite(IN PDEVICE_OBJECT fdo, IN PIRP Irp)

{

if (fdo->CurrentIrp == Irp)

{

IoReleaseCancelSpinLock(Irp->CancelIrql);

IoStartNextPacket(fdo, TRUE);

}

else

{

KeRemoveEntryDeviceQueue(&fdo->DeviceQueue,

&Irp->Tail.Overlay.DeviceQueueEntry);

IoReleaseCancelSpinLock(Irp->CancelIrql);

}

Irp->IoStatus.Status = STATUS_CANCELLED;

Irp->IoStatus.Information = 0;

IoSetCancelRoutine( Irp, NULL);

IoCompleteRequest(Irp,IO_NO_INCREMENT);

}

I have also experimented with using the following verses using

KeRemoveEntryDeviceQueue(), but

Also have the same page fault error.

RemoveEntryList(&Irp->Tail.Overlay.ListEntry);

or

PBLACE_DEVICE_EXTENSION pDeviceExtension =
fdo->DeviceExtension;

KeRemoveQueueDpc(&pDeviceExtension->BuslaceDpcObject);

If you are interested in the details of the driver code,

Click here:

http://oxygenaddicts.com/code/pci_wdm.c

John Carneiro

Email and Microsoft Messenger ID
mailto:xxxxx xxxxx@waters.com

===========================================================

The information in this email is confidential, and is intended solely for the addressee(s). Access to this email by anyone else is unauthorized and therefore prohibited. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful.

===========================================================</mailto:xxxxx>