From c5dde63b19a85510c5dfd2877c6e026e459f2323 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 18 Oct 2016 17:07:59 +0200 Subject: [PATCH] hidclass.sys: Use IoSetCompletionRoutine. Signed-off-by: Aric Stewart Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- dlls/hidclass.sys/device.c | 20 +++++++------------- dlls/hidclass.sys/main.c | 13 +++++-------- dlls/hidclass.sys/pnp.c | 10 +++++----- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 189cd2e0535..45f88ebbe76 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -242,9 +242,10 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device) HeapFree(GetProcessHeap(), 0, packet); } -static NTSTATUS WINAPI read_Completion(DEVICE_OBJECT *deviceObject, IRP *irp, void *context ) +static NTSTATUS WINAPI read_Completion(DEVICE_OBJECT *deviceObject, IRP *irp, void *context) { - SetEvent(irp->UserEvent); + HANDLE event = context; + SetEvent(event); return STATUS_MORE_PROCESSING_REQUIRED; } @@ -254,7 +255,6 @@ static DWORD CALLBACK hid_device_thread(void *args) IRP *irp; IO_STATUS_BLOCK irp_status; - IO_STACK_LOCATION *irpsp; DWORD rc; HANDLE events[2]; NTSTATUS ntrc; @@ -276,13 +276,10 @@ static DWORD CALLBACK hid_device_thread(void *args) packet->reportId = 0; irp = IoBuildDeviceIoControlRequest(IOCTL_HID_GET_INPUT_REPORT, - device, NULL, 0, packet, sizeof(*packet), TRUE, events[0], + device, NULL, 0, packet, sizeof(*packet), TRUE, NULL, &irp_status); - irpsp = IoGetNextIrpStackLocation(irp); - irpsp->CompletionRoutine = read_Completion; - irpsp->Control = SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR; - + IoSetCompletionRoutine(irp, read_Completion, events[0], TRUE, TRUE, TRUE); ntrc = IoCallDriver(device, irp); if (ntrc == STATUS_PENDING) @@ -324,13 +321,10 @@ static DWORD CALLBACK hid_device_thread(void *args) irp = IoBuildDeviceIoControlRequest(IOCTL_HID_READ_REPORT, device, NULL, 0, buffer, - ext->preparseData->caps.InputReportByteLength, TRUE, events[0], + ext->preparseData->caps.InputReportByteLength, TRUE, NULL, &irp_status); - irpsp = IoGetNextIrpStackLocation(irp); - irpsp->CompletionRoutine = read_Completion; - irpsp->Control = SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR; - + IoSetCompletionRoutine(irp, read_Completion, events[0], TRUE, TRUE, TRUE); ntrc = IoCallDriver(device, irp); if (ntrc == STATUS_PENDING) diff --git a/dlls/hidclass.sys/main.c b/dlls/hidclass.sys/main.c index 1ab25da9a99..b9b5a3af76a 100644 --- a/dlls/hidclass.sys/main.c +++ b/dlls/hidclass.sys/main.c @@ -86,9 +86,10 @@ NTSTATUS WINAPI HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION *registration) } static NTSTATUS WINAPI internalComplete(DEVICE_OBJECT *deviceObject, IRP *irp, - void *context ) + void *context) { - SetEvent(irp->UserEvent); + HANDLE event = context; + SetEvent(event); return STATUS_MORE_PROCESSING_REQUIRED; } @@ -96,7 +97,6 @@ NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG { IRP *irp; IO_STATUS_BLOCK irp_status; - IO_STACK_LOCATION *irpsp; NTSTATUS status; void *buffer = NULL; @@ -109,12 +109,9 @@ NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG } irp = IoBuildDeviceIoControlRequest(code, device, in_buff, in_size, - buffer, out_size, TRUE, event, &irp_status); - - irpsp = IoGetNextIrpStackLocation(irp); - irpsp->CompletionRoutine = internalComplete; - irpsp->Control = SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR; + buffer, out_size, TRUE, NULL, &irp_status); + IoSetCompletionRoutine(irp, internalComplete, event, TRUE, TRUE, TRUE); IoCallDriver(device, irp); if (irp->IoStatus.u.Status == STATUS_PENDING) diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index 81514c00c13..1e607df76ac 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -36,9 +36,10 @@ static const WCHAR device_deviceid_fmtW[] = {'%','s','\\', 'v','i','d','_','%','0','4','x','&','p','i','d','_','%', '0','4','x'}; static NTSTATUS WINAPI internalComplete(DEVICE_OBJECT *deviceObject, IRP *irp, - void *context ) + void *context) { - SetEvent(irp->UserEvent); + HANDLE event = context; + SetEvent(event); return STATUS_MORE_PROCESSING_REQUIRED; } @@ -54,13 +55,12 @@ static NTSTATUS get_device_id(DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCH if (irp == NULL) return STATUS_NO_MEMORY; - irp->UserEvent = event = CreateEventA(NULL, FALSE, FALSE, NULL); + event = CreateEventA(NULL, FALSE, FALSE, NULL); irpsp = IoGetNextIrpStackLocation(irp); irpsp->MinorFunction = IRP_MN_QUERY_ID; irpsp->Parameters.QueryId.IdType = type; - irpsp->CompletionRoutine = internalComplete; - irpsp->Control = SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR; + IoSetCompletionRoutine(irp, internalComplete, event, TRUE, TRUE, TRUE); IoCallDriver(device, irp); if (irp->IoStatus.u.Status == STATUS_PENDING) WaitForSingleObject(event, INFINITE); -- 2.11.4.GIT