[MOUCLASS] Support IRP cancellation on Port device objects

This commit is contained in:
Hervé Poussineau
2026-08-08 12:04:32 +02:00
parent 4592e3c65d
commit bf4dcaf623

View File

@@ -699,24 +699,34 @@ ClassCancelRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PCLASS_DEVICE_EXTENSION ClassDeviceExtension = DeviceObject->DeviceExtension;
PCOMMON_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
PREAD_DATA ReadData;
KIRQL OldIrql;
BOOLEAN wasQueued = FALSE;
TRACE_(CLASS_NAME, "ClassCancelRoutine(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
ASSERT(ClassDeviceExtension->Common.IsClassDO);
if (DeviceExtension->IsClassDO)
{
ReadData = ((PCLASS_DEVICE_EXTENSION)DeviceExtension)->ReadData;
}
else
{
PPORT_DEVICE_EXTENSION Port = (PPORT_DEVICE_EXTENSION)DeviceExtension;
PCLASS_DEVICE_EXTENSION Class = (PCLASS_DEVICE_EXTENSION)Port->ClassDO->DeviceExtension;
ReadData = Class->ReadData;
}
IoReleaseCancelSpinLock(Irp->CancelIrql);
KeAcquireSpinLock(&ClassDeviceExtension->ReadData->SpinLock, &OldIrql);
KeAcquireSpinLock(&ReadData->SpinLock, &OldIrql);
if (ClassDeviceExtension->ReadData->PendingIrp == Irp)
if (ReadData->PendingIrp == Irp)
{
ClassDeviceExtension->ReadData->PendingIrp = NULL;
ReadData->PendingIrp = NULL;
wasQueued = TRUE;
}
KeReleaseSpinLock(&ClassDeviceExtension->ReadData->SpinLock, OldIrql);
KeReleaseSpinLock(&ReadData->SpinLock, OldIrql);
if (wasQueued)
{