From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/driver_bus.c | 53 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index 6a1994e509c..dc9b549e1d8 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -1244,40 +1244,29 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) return fdo_internal_ioctl( device, irp ); }
-static NTSTATUS WINAPI pdo_ioctl( DEVICE_OBJECT *device, IRP *irp ) +static NTSTATUS pdo_handle_ioctl( struct phys_device *impl, IRP *irp, ULONG code, void *in_buffer, ULONG in_size ) { - IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); - struct phys_device *impl = pdo_from_DEVICE_OBJECT( device ); - ULONG in_size = stack->Parameters.DeviceIoControl.InputBufferLength; - ULONG code = stack->Parameters.DeviceIoControl.IoControlCode; - NTSTATUS status; KIRQL irql;
- if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_ioctl(code) ); - switch (code) { case IOCTL_WINETEST_HID_SET_EXPECT: - expect_queue_reset( &impl->expect_queue, irp->AssociatedIrp.SystemBuffer, in_size ); - status = STATUS_SUCCESS; - break; + expect_queue_reset( &impl->expect_queue, in_buffer, in_size ); + return STATUS_SUCCESS; case IOCTL_WINETEST_HID_WAIT_EXPECT: { - struct wait_expect_params wait_params = *(struct wait_expect_params *)irp->AssociatedIrp.SystemBuffer; - if (!wait_params.wait_pending) status = expect_queue_wait( &impl->expect_queue, irp ); - else status = expect_queue_wait_pending( &impl->expect_queue, irp ); - break; + struct wait_expect_params wait_params = *(struct wait_expect_params *)in_buffer; + if (!wait_params.wait_pending) return expect_queue_wait( &impl->expect_queue, irp ); + else return expect_queue_wait_pending( &impl->expect_queue, irp ); } case IOCTL_WINETEST_HID_SEND_INPUT: - input_queue_reset( &impl->input_queue, irp->AssociatedIrp.SystemBuffer, in_size ); - status = STATUS_SUCCESS; - break; + input_queue_reset( &impl->input_queue, in_buffer, in_size ); + return STATUS_SUCCESS; case IOCTL_WINETEST_HID_SET_CONTEXT: KeAcquireSpinLock( &impl->expect_queue.lock, &irql ); - memcpy( impl->expect_queue.context, irp->AssociatedIrp.SystemBuffer, in_size ); + memcpy( impl->expect_queue.context, in_buffer, in_size ); KeReleaseSpinLock( &impl->expect_queue.lock, irql ); - status = STATUS_SUCCESS; - break; + return STATUS_SUCCESS; case IOCTL_WINETEST_REMOVE_DEVICE: KeAcquireSpinLock( &impl->base.lock, &irql ); impl->base.state = PNP_DEVICE_REMOVED; @@ -1285,17 +1274,27 @@ static NTSTATUS WINAPI pdo_ioctl( DEVICE_OBJECT *device, IRP *irp ) KeReleaseSpinLock( &impl->base.lock, irql ); impl->pending_remove = irp; IoMarkIrpPending( irp ); - status = STATUS_PENDING; - break; + return STATUS_PENDING; case IOCTL_WINETEST_CREATE_DEVICE: ok( 0, "unexpected call\n" ); - status = irp->IoStatus.Status; - break; + return irp->IoStatus.Status; default: ok( 0, "unexpected call\n" ); - status = irp->IoStatus.Status; - break; + return irp->IoStatus.Status; } +} + +static NTSTATUS WINAPI pdo_ioctl( DEVICE_OBJECT *device, IRP *irp ) +{ + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); + struct phys_device *impl = pdo_from_DEVICE_OBJECT( device ); + ULONG in_size = stack->Parameters.DeviceIoControl.InputBufferLength; + ULONG code = stack->Parameters.DeviceIoControl.IoControlCode; + NTSTATUS status; + + if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_ioctl(code) ); + + status = pdo_handle_ioctl( impl, irp, code, irp->AssociatedIrp.SystemBuffer, in_size );
if (status != STATUS_PENDING) {