From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winexinput.sys/main.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/winexinput.sys/main.c b/dlls/winexinput.sys/main.c index 5a5c6ca8f00..45c6835bfe7 100644 --- a/dlls/winexinput.sys/main.c +++ b/dlls/winexinput.sys/main.c @@ -461,6 +461,24 @@ static WCHAR *query_compatible_ids(DEVICE_OBJECT *device) return dst; }
+static void remove_pending_irps(DEVICE_OBJECT *device) +{ + struct func_device *fdo = fdo_from_DEVICE_OBJECT(device); + IRP *pending; + + RtlEnterCriticalSection(&fdo->cs); + pending = fdo->pending_read; + fdo->pending_read = NULL; + RtlLeaveCriticalSection(&fdo->cs); + + if (pending) + { + pending->IoStatus.Status = STATUS_DELETE_PENDING; + pending->IoStatus.Information = 0; + IoCompleteRequest(pending, IO_NO_INCREMENT); + } +} + static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); @@ -468,7 +486,6 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) struct device *impl = impl_from_DEVICE_OBJECT(device); UCHAR code = stack->MinorFunction; NTSTATUS status; - IRP *pending;
TRACE("device %p, irp %p, code %#x, bus_device %p.\n", device, irp, code, fdo->bus_device);
@@ -481,21 +498,11 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) case IRP_MN_SURPRISE_REMOVAL: status = STATUS_SUCCESS; if (InterlockedExchange(&impl->removed, TRUE)) break; - - RtlEnterCriticalSection(&fdo->cs); - pending = fdo->pending_read; - fdo->pending_read = NULL; - RtlLeaveCriticalSection(&fdo->cs); - - if (pending) - { - pending->IoStatus.Status = STATUS_DELETE_PENDING; - pending->IoStatus.Information = 0; - IoCompleteRequest(pending, IO_NO_INCREMENT); - } + remove_pending_irps(device); break;
case IRP_MN_REMOVE_DEVICE: + remove_pending_irps(device); irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(irp, IO_NO_INCREMENT); IoDeleteDevice(device);