Rémi Bernon : hidclass.sys: Pass output buffer directly in handle_minidriver_string.

Alexandre Julliard julliard at winehq.org
Tue Oct 5 15:51:41 CDT 2021


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Tue Oct  5 09:11:53 2021 +0200

hidclass.sys: Pass output buffer directly in handle_minidriver_string.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/hidclass.sys/device.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
index cebdc3e1e65..2e618df2927 100644
--- a/dlls/hidclass.sys/device.c
+++ b/dlls/hidclass.sys/device.c
@@ -404,25 +404,14 @@ static void handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR( IRP *irp, BASE_DEVICE_EX
     }
 }
 
-static void handle_minidriver_string( BASE_DEVICE_EXTENSION *ext, IRP *irp, SHORT index )
+static void handle_minidriver_string( BASE_DEVICE_EXTENSION *ext, IRP *irp, ULONG index )
 {
-    IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
-    WCHAR buffer[127];
-    ULONG InputBuffer;
-
-    InputBuffer = MAKELONG(index, 0);
-
-    call_minidriver( IOCTL_HID_GET_STRING, ext->u.pdo.parent_fdo, ULongToPtr( InputBuffer ),
-                     sizeof(InputBuffer), buffer, sizeof(buffer), &irp->IoStatus );
+    IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp );
+    WCHAR *output_buf = MmGetSystemAddressForMdlSafe( irp->MdlAddress, NormalPagePriority );
+    ULONG output_len = stack->Parameters.DeviceIoControl.OutputBufferLength;
 
-    if (irp->IoStatus.Status == STATUS_SUCCESS)
-    {
-        WCHAR *out_buffer = MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority);
-        int length = irpsp->Parameters.DeviceIoControl.OutputBufferLength/sizeof(WCHAR);
-        TRACE("got string %s from minidriver\n",debugstr_w(buffer));
-        lstrcpynW(out_buffer, buffer, length);
-        irp->IoStatus.Information = (lstrlenW(buffer)+1) * sizeof(WCHAR);
-    }
+    call_minidriver( IOCTL_HID_GET_STRING, ext->u.pdo.parent_fdo, ULongToPtr( index ),
+                     sizeof(index), output_buf, output_len, &irp->IoStatus );
 }
 
 static void hid_device_xfer_report( BASE_DEVICE_EXTENSION *ext, ULONG code, IRP *irp )




More information about the wine-cvs mailing list