From e293db88a81bb364a773aaba5be4bc568f332f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Fri, 17 Sep 2021 09:06:23 +0200 Subject: [PATCH] dinput8/tests: Make ret_length optional in struct hid_expect. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that we don't have to specify it explicitely every time. Input reports length is now enforced, and we don't mean to test the length every time we inject input. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/dinput8/tests/driver_hid.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/dinput8/tests/driver_hid.c b/dlls/dinput8/tests/driver_hid.c index 28694e5a4c6..f484710e498 100644 --- a/dlls/dinput8/tests/driver_hid.c +++ b/dlls/dinput8/tests/driver_hid.c @@ -225,11 +225,15 @@ static void input_queue_cleanup( struct input_queue *queue ) static BOOL input_queue_read_locked( struct input_queue *queue, IRP *irp ) { + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); + ULONG out_size = stack->Parameters.DeviceIoControl.OutputBufferLength; struct hid_expect *tmp = queue->pos; - if (tmp >= queue->end) return FALSE; - memcpy( irp->UserBuffer, tmp->report_buf, tmp->ret_length ); - irp->IoStatus.Information = tmp->ret_length; + if (tmp >= queue->end) return FALSE; + if (tmp->ret_length) out_size = tmp->ret_length; + + memcpy( irp->UserBuffer, tmp->report_buf, out_size ); + irp->IoStatus.Information = out_size; irp->IoStatus.Status = tmp->ret_status; if (tmp < queue->end) queue->pos = tmp + 1; @@ -464,7 +468,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) "unexpected data\n" ); winetest_pop_context(); - irp->IoStatus.Information = expect.ret_length; + irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len; ret = expect.ret_status; break; } @@ -487,8 +491,8 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); winetest_pop_context(); - memcpy( packet->reportBuffer, expect.report_buf, expect.ret_length ); - irp->IoStatus.Information = expect.ret_length; + irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len; + memcpy( packet->reportBuffer, expect.report_buf, irp->IoStatus.Information ); ret = expect.ret_status; break; } @@ -513,7 +517,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) "unexpected data\n" ); winetest_pop_context(); - irp->IoStatus.Information = expect.ret_length; + irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len; ret = expect.ret_status; break; } @@ -536,8 +540,8 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen ); winetest_pop_context(); - memcpy( packet->reportBuffer, expect.report_buf, expect.ret_length ); - irp->IoStatus.Information = expect.ret_length; + irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len; + memcpy( packet->reportBuffer, expect.report_buf, irp->IoStatus.Information ); ret = expect.ret_status; break; } @@ -562,7 +566,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) "unexpected data\n" ); winetest_pop_context(); - irp->IoStatus.Information = expect.ret_length; + irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len; ret = expect.ret_status; break; }