Aric Stewart : hidclass.sys: Use IoSetCompletionRoutine.

Alexandre Julliard julliard at winehq.org
Wed Oct 19 20:47:57 CDT 2016


Module: wine
Branch: master
Commit: c5dde63b19a85510c5dfd2877c6e026e459f2323
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c5dde63b19a85510c5dfd2877c6e026e459f2323

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Oct 18 17:07:59 2016 +0200

hidclass.sys: Use IoSetCompletionRoutine.

Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 189cd2e..45f88eb 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 1ab25da..b9b5a3a 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 81514c0..1e607df 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);




More information about the wine-cvs mailing list