Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 62 +++++++++++++++++++++++++++++- dlls/hidclass.sys/descriptor.c | 11 ++++-- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 16 +++----- include/wine/hid.h | 1 + 4 files changed, 75 insertions(+), 15 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 6a9fba6e425..a4e5afbbfcc 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -286,6 +286,18 @@ static NTSTATUS get_usage( const struct hid_value_caps *caps, void *user ) { struct get_usage_params *params = user; ULONG bit, last; + BYTE index; + + if (HID_VALUE_CAPS_IS_ARRAY( caps )) + { + for (bit = caps->start_bit, last = bit + caps->report_count * caps->bit_size - 1; bit <= last; bit += 8) + { + if (!(index = params->report_buf[bit / 8])) continue; + if (params->usages < params->usages_end) *params->usages = caps->usage_min + index - caps->start_index; + params->usages++; + } + return HIDP_STATUS_SUCCESS; + }
for (bit = caps->start_bit, last = bit + caps->usage_max - caps->usage_min; bit <= last; ++bit) { @@ -423,7 +435,22 @@ struct set_usage_params static NTSTATUS set_usage( const struct hid_value_caps *caps, void *user ) { struct set_usage_params *params = user; - ULONG bit = caps->start_bit + params->usage - caps->usage_min; + ULONG bit, last; + + if (HID_VALUE_CAPS_IS_ARRAY( caps )) + { + for (bit = caps->start_bit, last = bit + caps->report_count * caps->bit_size - 1; bit <= last; bit += 8) + { + if (params->report_buf[bit / 8]) continue; + params->report_buf[bit / 8] = caps->start_index + params->usage - caps->usage_min; + break; + } + + if (bit > last) return HIDP_STATUS_BUFFER_TOO_SMALL; + return HIDP_STATUS_NULL; + } + + bit = caps->start_bit + params->usage - caps->usage_min; params->report_buf[bit / 8] |= (1 << (bit % 8)); return HIDP_STATUS_NULL; } @@ -595,6 +622,22 @@ static NTSTATUS get_usage_and_page( const struct hid_value_caps *caps, void *use { struct get_usage_and_page_params *params = user; ULONG bit, last; + BYTE index; + + if (HID_VALUE_CAPS_IS_ARRAY( caps )) + { + for (bit = caps->start_bit, last = bit + caps->report_count * caps->bit_size - 1; bit <= last; bit += 8) + { + if (!(index = params->report_buf[bit / 8])) continue; + if (params->usages < params->usages_end) + { + params->usages->UsagePage = caps->usage_page; + params->usages->Usage = caps->usage_min + index - caps->start_index; + } + params->usages++; + } + return HIDP_STATUS_SUCCESS; + }
for (bit = caps->start_bit, last = bit + caps->usage_max - caps->usage_min; bit <= last; bit++) { @@ -667,9 +710,24 @@ static NTSTATUS find_all_data( const struct hid_value_caps *caps, void *user ) HIDP_DATA *data = params->data, *data_end = params->data_end; ULONG bit, last, bit_count = caps->bit_size * caps->report_count; char *report_buf = params->report_buf; + BYTE index;
if (!caps->bit_size) return HIDP_STATUS_SUCCESS; - if (caps->bit_size == 1) + + if (HID_VALUE_CAPS_IS_ARRAY( caps )) + { + for (bit = caps->start_bit, last = bit + caps->report_count * caps->bit_size - 1; bit <= last; bit += 8) + { + if (!(index = report_buf[bit / 8])) continue; + if (data < data_end) + { + data->DataIndex = caps->data_index_min + index - caps->start_index; + data->On = 1; + } + data++; + } + } + else if (HID_VALUE_CAPS_IS_BUTTON( caps )) { for (bit = caps->start_bit, last = bit + caps->usage_max - caps->usage_min; bit <= last; bit++) { diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 986912990a7..f8bacbbbc1a 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -460,6 +460,7 @@ static BOOL parse_new_value_caps( struct hid_parser_state *state, HIDP_REPORT_TY USHORT *data_idx = state->data_idx[type]; ULONG *bit_size = &state->bit_size[type][state->items.report_id]; struct feature *feature; + BOOL is_array; int j;
for (j = 0; j < state->items.report_count; j++) @@ -496,10 +497,14 @@ static BOOL parse_new_value_caps( struct hid_parser_state *state, HIDP_REPORT_TY } value = state->values[type] + *value_idx;
- state->items.report_count -= usages_size - 1; + state->items.start_index = 0; + if (!(is_array = HID_VALUE_CAPS_IS_ARRAY( &state->items ))) state->items.report_count -= usages_size - 1; + else state->items.start_bit -= state->items.report_count * state->items.bit_size; + while (usages_size--) { - state->items.start_bit -= state->items.report_count * state->items.bit_size; + if (!is_array) state->items.start_bit -= state->items.report_count * state->items.bit_size; + else state->items.start_index += 1; state->items.usage_page = state->usages_page[usages_size]; state->items.usage_min = state->usages_min[usages_size]; state->items.usage_max = state->usages_max[usages_size]; @@ -508,7 +513,7 @@ static BOOL parse_new_value_caps( struct hid_parser_state *state, HIDP_REPORT_TY if (state->items.usage_max || state->items.usage_min) *data_idx = state->items.data_index_max + 1; *value++ = state->items; *value_idx += 1; - state->items.report_count = 1; + if (!is_array) state->items.report_count = 1; }
state->items.usage_page = usage_page; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 401401bbffe..892e839fa56 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2229,10 +2229,10 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled memcpy(buffer, report, caps.InputReportByteLength); status = HidP_SetUsages(HidP_Input, HID_USAGE_PAGE_KEYBOARD, 0, usages, &value, preparsed_data, report, caps.InputReportByteLength); - todo_wine ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_SetUsages returned %#x\n", status); + ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_SetUsages returned %#x\n", status); buffer[6] = 2; buffer[7] = 4; - todo_wine ok(!memcmp(buffer, report, caps.InputReportByteLength), "unexpected report data\n"); + ok(!memcmp(buffer, report, caps.InputReportByteLength), "unexpected report data\n");
status = HidP_SetUsageValue(HidP_Input, HID_USAGE_PAGE_LED, 0, 6, 1, preparsed_data, report, caps.InputReportByteLength); @@ -2272,7 +2272,7 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled status = HidP_GetUsagesEx(HidP_Input, 0, usage_and_pages, &value, preparsed_data, report, caps.InputReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_GetUsagesEx returned %#x\n", status); - todo_wine ok(value == 6, "got usage count %d, expected %d\n", value, 4); + ok(value == 6, "got usage count %d, expected %d\n", value, 4); ok(usage_and_pages[0].UsagePage == HID_USAGE_PAGE_BUTTON, "got usage_and_pages[0] UsagePage %x, expected %x\n", usage_and_pages[0].UsagePage, HID_USAGE_PAGE_BUTTON); ok(usage_and_pages[1].UsagePage == HID_USAGE_PAGE_BUTTON, "got usage_and_pages[1] UsagePage %x, expected %x\n", @@ -2281,7 +2281,6 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled usage_and_pages[2].UsagePage, HID_USAGE_PAGE_KEYBOARD); ok(usage_and_pages[3].UsagePage == HID_USAGE_PAGE_KEYBOARD, "got usage_and_pages[3] UsagePage %x, expected %x\n", usage_and_pages[3].UsagePage, HID_USAGE_PAGE_KEYBOARD); - todo_wine ok(usage_and_pages[4].UsagePage == HID_USAGE_PAGE_LED, "got usage_and_pages[4] UsagePage %x, expected %x\n", usage_and_pages[4].UsagePage, HID_USAGE_PAGE_LED); ok(usage_and_pages[5].UsagePage == HID_USAGE_PAGE_LED, "got usage_and_pages[5] UsagePage %x, expected %x\n", @@ -2292,13 +2291,10 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled usage_and_pages[1].Usage, 6); ok(usage_and_pages[2].Usage == 9, "got usage_and_pages[2] Usage %x, expected %x\n", usage_and_pages[2].Usage, 9); - todo_wine ok(usage_and_pages[3].Usage == 11, "got usage_and_pages[3] Usage %x, expected %x\n", usage_and_pages[3].Usage, 11); - todo_wine ok(usage_and_pages[4].Usage == 6, "got usage_and_pages[4] Usage %x, expected %x\n", usage_and_pages[4].Usage, 6); - todo_wine ok(usage_and_pages[5].Usage == 4, "got usage_and_pages[5] Usage %x, expected %x\n", usage_and_pages[5].Usage, 4);
@@ -2314,15 +2310,15 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled value = 1; status = HidP_GetData(HidP_Input, data, &value, preparsed_data, report, caps.InputReportByteLength); ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_GetData returned %#x\n", status); - todo_wine ok(value == 11, "got data count %d, expected %d\n", value, 11); + ok(value == 11, "got data count %d, expected %d\n", value, 11); memset(data, 0, sizeof(data)); status = HidP_GetData(HidP_Input, data, &value, preparsed_data, report, caps.InputReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_GetData returned %#x\n", status); for (i = 0; i < ARRAY_SIZE(expect_data); ++i) { winetest_push_context("data[%d]", i); - todo_wine_if(i >= 4) check_member(data[i], expect_data[i], "%d", DataIndex); - todo_wine_if(i >= 4) check_member(data[i], expect_data[i], "%d", RawValue); + check_member(data[i], expect_data[i], "%d", DataIndex); + check_member(data[i], expect_data[i], "%d", RawValue); winetest_pop_context(); }
diff --git a/include/wine/hid.h b/include/wine/hid.h index b15b26474a0..ade9681ab7d 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -60,6 +60,7 @@ struct hid_value_caps USHORT bit_size; USHORT report_count; ULONG start_bit; + ULONG start_index; LONG logical_min; LONG logical_max; LONG physical_min;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 96 ++++++++++++++------------------------ 1 file changed, 35 insertions(+), 61 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 73a8428ad22..b8e3061b274 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -157,13 +157,11 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device) RingBuffer_Read(ext->u.pdo.ring_buffer, ptr, packet, &buffer_size); if (buffer_size) { - NTSTATUS rc; ULONG out_length; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); packet->reportBuffer = (BYTE *)packet + sizeof(*packet); TRACE_(hid_report)("Processing Request (%i)\n",ptr); - rc = copy_packet_into_buffer(packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length); - irp->IoStatus.Status = rc; + irp->IoStatus.Status = copy_packet_into_buffer( packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length ); irp->IoStatus.Information = out_length; } else @@ -272,7 +270,7 @@ void HID_StartDeviceThread(DEVICE_OBJECT *device) ext->u.pdo.thread = CreateThread(NULL, 0, hid_device_thread, device, 0, NULL); }
-static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_INFORMATION(IRP *irp, BASE_DEVICE_EXTENSION *ext) +static void handle_IOCTL_HID_GET_COLLECTION_INFORMATION( IRP *irp, BASE_DEVICE_EXTENSION *ext ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(HID_COLLECTION_INFORMATION)) @@ -286,10 +284,9 @@ static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_INFORMATION(IRP *irp, BASE_DEVIC irp->IoStatus.Information = sizeof(HID_COLLECTION_INFORMATION); irp->IoStatus.Status = STATUS_SUCCESS; } - return STATUS_SUCCESS; }
-static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(IRP *irp, BASE_DEVICE_EXTENSION *ext) +static void handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR( IRP *irp, BASE_DEVICE_EXTENSION *ext ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; @@ -305,10 +302,9 @@ static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(IRP *irp, BASE_DEVICE irp->IoStatus.Information = data->dwSize; irp->IoStatus.Status = STATUS_SUCCESS; } - return STATUS_SUCCESS; }
-static NTSTATUS handle_minidriver_string(BASE_DEVICE_EXTENSION *ext, IRP *irp, SHORT index) +static void handle_minidriver_string( BASE_DEVICE_EXTENSION *ext, IRP *irp, SHORT index ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); WCHAR buffer[127]; @@ -328,16 +324,13 @@ static NTSTATUS handle_minidriver_string(BASE_DEVICE_EXTENSION *ext, IRP *irp, S irp->IoStatus.Information = (lstrlenW(buffer)+1) * sizeof(WCHAR); } irp->IoStatus.Status = status; - - return STATUS_SUCCESS; }
-static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) +static void HID_get_feature( BASE_DEVICE_EXTENSION *ext, IRP *irp ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); HID_XFER_PACKET *packet; DWORD len; - NTSTATUS rc = STATUS_SUCCESS; BYTE *out_buffer;
irp->IoStatus.Information = 0; @@ -348,7 +341,7 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) if (!irpsp->Parameters.DeviceIoControl.OutputBufferLength || !out_buffer) { irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; - return rc; + return; }
len = sizeof(*packet) + irpsp->Parameters.DeviceIoControl.OutputBufferLength; @@ -359,9 +352,8 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet->reportId, packet->reportBufferLen, packet->reportBuffer);
- rc = call_minidriver(IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet)); + irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) );
- irp->IoStatus.Status = rc; if (irp->IoStatus.Status == STATUS_SUCCESS) { irp->IoStatus.Information = packet->reportBufferLen; @@ -370,21 +362,18 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) else irp->IoStatus.Information = 0;
- TRACE_(hid_report)("Result 0x%x get %li bytes\n", rc, irp->IoStatus.Information); + TRACE_(hid_report)( "Result 0x%x get %li bytes\n", irp->IoStatus.Status, irp->IoStatus.Information );
free(packet); - - return rc; }
-static NTSTATUS HID_set_to_device(DEVICE_OBJECT *device, IRP *irp) +static void HID_set_to_device( DEVICE_OBJECT *device, IRP *irp ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; HID_XFER_PACKET packet; ULONG max_len; - NTSTATUS rc;
TRACE_(hid_report)("Device %p Buffer length %i Buffer %p\n", device, irpsp->Parameters.DeviceIoControl.InputBufferLength, irp->AssociatedIrp.SystemBuffer); packet.reportId = ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0]; @@ -412,23 +401,19 @@ static NTSTATUS HID_set_to_device(DEVICE_OBJECT *device, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet.reportId, packet.reportBufferLen, packet.reportBuffer);
- rc = call_minidriver(irpsp->Parameters.DeviceIoControl.IoControlCode, - ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet)); + irp->IoStatus.Status = call_minidriver( irpsp->Parameters.DeviceIoControl.IoControlCode, + ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) );
- irp->IoStatus.Status = rc; if (irp->IoStatus.Status == STATUS_SUCCESS) irp->IoStatus.Information = irpsp->Parameters.DeviceIoControl.InputBufferLength; else irp->IoStatus.Information = 0;
- TRACE_(hid_report)("Result 0x%x set %li bytes\n", rc, irp->IoStatus.Information); - - return rc; + TRACE_(hid_report)( "Result 0x%x set %li bytes\n", irp->IoStatus.Status, irp->IoStatus.Information ); }
NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) { - NTSTATUS rc = STATUS_SUCCESS; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; BOOL removed; @@ -484,27 +469,27 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) } case IOCTL_HID_GET_PRODUCT_STRING: { - rc = handle_minidriver_string(ext, irp, HID_STRING_ID_IPRODUCT); + handle_minidriver_string( ext, irp, HID_STRING_ID_IPRODUCT ); break; } case IOCTL_HID_GET_SERIALNUMBER_STRING: { - rc = handle_minidriver_string(ext, irp, HID_STRING_ID_ISERIALNUMBER); + handle_minidriver_string( ext, irp, HID_STRING_ID_ISERIALNUMBER ); break; } case IOCTL_HID_GET_MANUFACTURER_STRING: { - rc = handle_minidriver_string(ext, irp, HID_STRING_ID_IMANUFACTURER); + handle_minidriver_string( ext, irp, HID_STRING_ID_IMANUFACTURER ); break; } case IOCTL_HID_GET_COLLECTION_INFORMATION: { - rc = handle_IOCTL_HID_GET_COLLECTION_INFORMATION(irp, ext); + handle_IOCTL_HID_GET_COLLECTION_INFORMATION( irp, ext ); break; } case IOCTL_HID_GET_COLLECTION_DESCRIPTOR: { - rc = handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(irp, ext); + handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR( irp, ext ); break; } case IOCTL_HID_GET_INPUT_REPORT: @@ -529,15 +514,14 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) packet->reportBuffer = (BYTE *)packet + sizeof(*packet); packet->reportBufferLen = irpsp->Parameters.DeviceIoControl.OutputBufferLength - 1;
- rc = call_minidriver(IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet)); - if (rc == STATUS_SUCCESS) + irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) ); + if (irp->IoStatus.Status == STATUS_SUCCESS) { - rc = copy_packet_into_buffer(packet, buffer, irpsp->Parameters.DeviceIoControl.OutputBufferLength, &out_length); + irp->IoStatus.Status = copy_packet_into_buffer( packet, buffer, irpsp->Parameters.DeviceIoControl.OutputBufferLength, &out_length ); irp->IoStatus.Information = out_length; } else irp->IoStatus.Information = 0; - irp->IoStatus.Status = rc; free(packet); break; } @@ -547,12 +531,11 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
if (irpsp->Parameters.DeviceIoControl.InputBufferLength != sizeof(ULONG)) { - irp->IoStatus.Status = rc = STATUS_BUFFER_OVERFLOW; + irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW; } else { - rc = RingBuffer_SetSize(ext->u.pdo.ring_buffer, *(ULONG *)irp->AssociatedIrp.SystemBuffer); - irp->IoStatus.Status = rc; + irp->IoStatus.Status = RingBuffer_SetSize( ext->u.pdo.ring_buffer, *(ULONG *)irp->AssociatedIrp.SystemBuffer ); } break; } @@ -561,22 +544,22 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) { irp->IoStatus.Information = 0; - irp->IoStatus.Status = rc = STATUS_BUFFER_TOO_SMALL; + irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; } else { *(ULONG *)irp->AssociatedIrp.SystemBuffer = RingBuffer_GetSize(ext->u.pdo.ring_buffer); irp->IoStatus.Information = sizeof(ULONG); - rc = irp->IoStatus.Status = STATUS_SUCCESS; + irp->IoStatus.Status = STATUS_SUCCESS; } break; } case IOCTL_HID_GET_FEATURE: - rc = HID_get_feature(ext, irp); + HID_get_feature( ext, irp ); break; case IOCTL_HID_SET_FEATURE: case IOCTL_HID_SET_OUTPUT_REPORT: - rc = HID_set_to_device(device, irp); + HID_set_to_device( device, irp ); break; default: { @@ -584,15 +567,13 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) FIXME("Unsupported ioctl %x (device=%x access=%x func=%x method=%x)\n", code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3); irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - rc = STATUS_UNSUCCESSFUL; break; } }
- if (rc != STATUS_PENDING) - IoCompleteRequest( irp, IO_NO_INCREMENT ); + if (irp->IoStatus.Status != STATUS_PENDING) IoCompleteRequest( irp, IO_NO_INCREMENT );
- return rc; + return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) @@ -601,7 +582,6 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; UINT buffer_size = RingBuffer_GetBufferSize(ext->u.pdo.ring_buffer); - NTSTATUS rc = STATUS_SUCCESS; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); int ptr = -1; BOOL removed; @@ -634,14 +614,12 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) if (buffer_size) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); - NTSTATUS rc; ULONG out_length; packet->reportBuffer = (BYTE *)packet + sizeof(*packet); TRACE_(hid_report)("Got Packet %p %i\n", packet->reportBuffer, packet->reportBufferLen);
- rc = copy_packet_into_buffer(packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length); + irp->IoStatus.Status = copy_packet_into_buffer( packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length ); irp->IoStatus.Information = out_length; - irp->IoStatus.Status = rc; IoCompleteRequest(irp, IO_NO_INCREMENT); } else @@ -666,7 +644,6 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) IoMarkIrpPending(irp);
KeReleaseSpinLock(&ext->u.pdo.irp_queue_lock, old_irql); - rc = STATUS_PENDING; } else { @@ -675,20 +652,19 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) packet.reportId = ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0]; packet.reportBuffer = &((BYTE*)irp->AssociatedIrp.SystemBuffer)[1]; packet.reportBufferLen = irpsp->Parameters.Read.Length - 1; - rc = call_minidriver(IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet)); + irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) );
- if (rc == STATUS_SUCCESS) + if (irp->IoStatus.Status == STATUS_SUCCESS) { ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0] = packet.reportId; irp->IoStatus.Information = packet.reportBufferLen + 1; - irp->IoStatus.Status = rc; } IoCompleteRequest(irp, IO_NO_INCREMENT); } } free(packet);
- return rc; + return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) @@ -699,7 +675,6 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) HID_XFER_PACKET packet; ULONG max_len; BOOL removed; - NTSTATUS rc; KIRQL irql;
KeAcquireSpinLock(&ext->u.pdo.lock, &irql); @@ -748,18 +723,17 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet.reportId, packet.reportBufferLen, packet.reportBuffer);
- rc = call_minidriver(IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet)); + irp->IoStatus.Status = call_minidriver( IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) );
- irp->IoStatus.Status = rc; if (irp->IoStatus.Status == STATUS_SUCCESS) irp->IoStatus.Information = irpsp->Parameters.Write.Length; else irp->IoStatus.Information = 0;
- TRACE_(hid_report)("Result 0x%x wrote %li bytes\n", rc, irp->IoStatus.Information); + TRACE_(hid_report)( "Result 0x%x wrote %li bytes\n", irp->IoStatus.Status, irp->IoStatus.Information );
IoCompleteRequest( irp, IO_NO_INCREMENT ); - return rc; + return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp)
On 8/3/21 3:19 AM, Rémi Bernon wrote:
@@ -584,15 +567,13 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) FIXME("Unsupported ioctl %x (device=%x access=%x func=%x method=%x)\n", code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3); irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
rc = STATUS_UNSUCCESSFUL; break; } }
if (rc != STATUS_PENDING)
IoCompleteRequest( irp, IO_NO_INCREMENT );
- if (irp->IoStatus.Status != STATUS_PENDING) IoCompleteRequest( irp, IO_NO_INCREMENT );
- return rc;
return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp)
You can't access the IRP after calling IoCompleteRequest().
There are other instances in this patch of the same thing.
On 8/3/21 5:28 PM, Zebediah Figura (she/her) wrote:
On 8/3/21 3:19 AM, Rémi Bernon wrote:
@@ -584,15 +567,13 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) FIXME("Unsupported ioctl %x (device=%x access=%x func=%x method=%x)\n", code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3); irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - rc = STATUS_UNSUCCESSFUL; break; } } - if (rc != STATUS_PENDING) - IoCompleteRequest( irp, IO_NO_INCREMENT ); + if (irp->IoStatus.Status != STATUS_PENDING) IoCompleteRequest( irp, IO_NO_INCREMENT ); - return rc; + return irp->IoStatus.Status; } NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp)
You can't access the IRP after calling IoCompleteRequest().
There are other instances in this patch of the same thing.
Ah thanks I wasn't aware of this, I think some previous patches introduced some as well. I'll fix these and resend the series.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 7 ++++++- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index b8e3061b274..344d8b5d8e8 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -499,7 +499,12 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) BYTE *buffer = MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority); ULONG out_length;
- if (!irpsp->Parameters.DeviceIoControl.OutputBufferLength || !buffer) + if (!buffer) + { + irp->IoStatus.Status = STATUS_INVALID_USER_BUFFER; + break; + } + if (!irpsp->Parameters.DeviceIoControl.OutputBufferLength) { irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; break; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 892e839fa56..3c883edb7c8 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2441,7 +2441,7 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled SetLastError(0xdeadbeef); ret = HidD_GetInputReport(file, report, 0); ok(!ret, "HidD_GetInputReport succeeded\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "HidD_GetInputReport returned error %u\n", GetLastError()); + ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "HidD_GetInputReport returned error %u\n", GetLastError());
SetLastError(0xdeadbeef); ret = HidD_GetInputReport(file, report, caps.InputReportByteLength - 1);
Instead of STATUS_BUFFER_TOO_SMALL when input report buffer length is less than InputReportByteLength.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 12 +++++++----- dlls/ntoskrnl.exe/tests/driver_hid.c | 2 +- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 2 -- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 344d8b5d8e8..93f591fb345 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -416,6 +416,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; + const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; BOOL removed; KIRQL irql;
@@ -495,7 +496,8 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) case IOCTL_HID_GET_INPUT_REPORT: { HID_XFER_PACKET *packet; - UINT packet_size = sizeof(*packet) + irpsp->Parameters.DeviceIoControl.OutputBufferLength; + ULONG buffer_len = irpsp->Parameters.DeviceIoControl.OutputBufferLength; + UINT packet_size = sizeof(*packet) + buffer_len; BYTE *buffer = MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority); ULONG out_length;
@@ -504,9 +506,9 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) irp->IoStatus.Status = STATUS_INVALID_USER_BUFFER; break; } - if (!irpsp->Parameters.DeviceIoControl.OutputBufferLength) + if (buffer_len < data->caps.InputReportByteLength) { - irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; + irp->IoStatus.Status = STATUS_INVALID_PARAMETER; break; }
@@ -517,12 +519,12 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) else packet->reportId = 0; packet->reportBuffer = (BYTE *)packet + sizeof(*packet); - packet->reportBufferLen = irpsp->Parameters.DeviceIoControl.OutputBufferLength - 1; + packet->reportBufferLen = buffer_len - 1;
irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) ); if (irp->IoStatus.Status == STATUS_SUCCESS) { - irp->IoStatus.Status = copy_packet_into_buffer( packet, buffer, irpsp->Parameters.DeviceIoControl.OutputBufferLength, &out_length ); + irp->IoStatus.Status = copy_packet_into_buffer( packet, buffer, buffer_len, &out_length ); irp->IoStatus.Information = out_length; } else diff --git a/dlls/ntoskrnl.exe/tests/driver_hid.c b/dlls/ntoskrnl.exe/tests/driver_hid.c index f1289b8a1bb..a45e5f56928 100644 --- a/dlls/ntoskrnl.exe/tests/driver_hid.c +++ b/dlls/ntoskrnl.exe/tests/driver_hid.c @@ -535,7 +535,7 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
todo_wine_if(packet->reportId == 0x5a || (polled && report_id && packet->reportId == 0)) ok(packet->reportId == report_id, "got id %u\n", packet->reportId); - todo_wine_if(packet->reportBufferLen == 21 || packet->reportBufferLen == 22) + todo_wine_if(packet->reportBufferLen == 22) ok(packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen); ok(!!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer);
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 3c883edb7c8..91fa7e73c88 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2445,9 +2445,7 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled
SetLastError(0xdeadbeef); ret = HidD_GetInputReport(file, report, caps.InputReportByteLength - 1); - todo_wine ok(!ret, "HidD_GetInputReport succeeded\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == ERROR_CRC), "HidD_GetInputReport returned error %u\n", GetLastError());
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 24 +++++++++++++----------- dlls/hidclass.sys/hid.h | 3 ++- dlls/hidclass.sys/pnp.c | 28 +++++++++++++--------------- 3 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 93f591fb345..7c2ecb9b4df 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -308,14 +308,13 @@ static void handle_minidriver_string( BASE_DEVICE_EXTENSION *ext, IRP *irp, SHOR { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); WCHAR buffer[127]; - NTSTATUS status; ULONG InputBuffer;
InputBuffer = MAKELONG(index, 0); - status = call_minidriver(IOCTL_HID_GET_STRING, ext->u.pdo.parent_fdo, - ULongToPtr(InputBuffer), sizeof(InputBuffer), buffer, sizeof(buffer)); + call_minidriver( IOCTL_HID_GET_STRING, ext->u.pdo.parent_fdo, ULongToPtr( InputBuffer ), + sizeof(InputBuffer), buffer, sizeof(buffer), &irp->IoStatus );
- if (status == STATUS_SUCCESS) + if (irp->IoStatus.Status == STATUS_SUCCESS) { WCHAR *out_buffer = MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority); int length = irpsp->Parameters.DeviceIoControl.OutputBufferLength/sizeof(WCHAR); @@ -323,7 +322,6 @@ static void handle_minidriver_string( BASE_DEVICE_EXTENSION *ext, IRP *irp, SHOR lstrcpynW(out_buffer, buffer, length); irp->IoStatus.Information = (lstrlenW(buffer)+1) * sizeof(WCHAR); } - irp->IoStatus.Status = status; }
static void HID_get_feature( BASE_DEVICE_EXTENSION *ext, IRP *irp ) @@ -352,7 +350,8 @@ static void HID_get_feature( BASE_DEVICE_EXTENSION *ext, IRP *irp )
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet->reportId, packet->reportBufferLen, packet->reportBuffer);
- irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) ); + call_minidriver( IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet), + &irp->IoStatus );
if (irp->IoStatus.Status == STATUS_SUCCESS) { @@ -401,8 +400,8 @@ static void HID_set_to_device( DEVICE_OBJECT *device, IRP *irp )
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet.reportId, packet.reportBufferLen, packet.reportBuffer);
- irp->IoStatus.Status = call_minidriver( irpsp->Parameters.DeviceIoControl.IoControlCode, - ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) ); + call_minidriver( irpsp->Parameters.DeviceIoControl.IoControlCode, ext->u.pdo.parent_fdo, NULL, + 0, &packet, sizeof(packet), &irp->IoStatus );
if (irp->IoStatus.Status == STATUS_SUCCESS) irp->IoStatus.Information = irpsp->Parameters.DeviceIoControl.InputBufferLength; @@ -521,7 +520,8 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) packet->reportBuffer = (BYTE *)packet + sizeof(*packet); packet->reportBufferLen = buffer_len - 1;
- irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) ); + call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, + sizeof(*packet), &irp->IoStatus ); if (irp->IoStatus.Status == STATUS_SUCCESS) { irp->IoStatus.Status = copy_packet_into_buffer( packet, buffer, buffer_len, &out_length ); @@ -659,7 +659,8 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) packet.reportId = ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0]; packet.reportBuffer = &((BYTE*)irp->AssociatedIrp.SystemBuffer)[1]; packet.reportBufferLen = irpsp->Parameters.Read.Length - 1; - irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) ); + call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, + sizeof(packet), &irp->IoStatus );
if (irp->IoStatus.Status == STATUS_SUCCESS) { @@ -730,7 +731,8 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet.reportId, packet.reportBufferLen, packet.reportBuffer);
- irp->IoStatus.Status = call_minidriver( IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) ); + call_minidriver( IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, + sizeof(packet), &irp->IoStatus );
if (irp->IoStatus.Status == STATUS_SUCCESS) irp->IoStatus.Information = irpsp->Parameters.Write.Length; diff --git a/dlls/hidclass.sys/hid.h b/dlls/hidclass.sys/hid.h index 19ac7091065..f0982d508e3 100644 --- a/dlls/hidclass.sys/hid.h +++ b/dlls/hidclass.sys/hid.h @@ -108,7 +108,8 @@ typedef struct _minidriver PDRIVER_DISPATCH PNPDispatch; } minidriver;
-NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size) DECLSPEC_HIDDEN; +void call_minidriver( ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, + void *out_buff, ULONG out_size, IO_STATUS_BLOCK *io ) DECLSPEC_HIDDEN;
/* Internal device functions */ void HID_StartDeviceThread(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index 2f5fe5de4eb..e5a38dafc1c 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -188,14 +188,15 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo) BYTE *reportDescriptor; UNICODE_STRING string; WCHAR pdo_name[255]; + IO_STATUS_BLOCK io; USAGE page, usage; NTSTATUS status; INT i;
- status = call_minidriver(IOCTL_HID_GET_DEVICE_ATTRIBUTES, fdo, NULL, 0, &attr, sizeof(attr)); - if (status != STATUS_SUCCESS) + call_minidriver( IOCTL_HID_GET_DEVICE_ATTRIBUTES, fdo, NULL, 0, &attr, sizeof(attr), &io ); + if (io.Status != STATUS_SUCCESS) { - ERR("Minidriver failed to get Attributes(%x)\n",status); + ERR( "Minidriver failed to get attributes, status %#x.\n", io.Status ); return; }
@@ -204,7 +205,7 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo) RtlInitUnicodeString(&string, pdo_name); if ((status = IoCreateDevice(fdo->DriverObject, sizeof(*pdo_ext), &string, 0, 0, FALSE, &child_pdo))) { - ERR("Failed to create child PDO, status %#x.\n", status); + ERR( "Failed to create child PDO, status %#x.\n", io.Status ); return; } fdo_ext->u.fdo.child_pdo = child_pdo; @@ -221,8 +222,8 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo) pdo_ext->u.pdo.information.VersionNumber = attr.VersionNumber; pdo_ext->u.pdo.information.Polled = minidriver->minidriver.DevicesArePolled;
- status = call_minidriver(IOCTL_HID_GET_DEVICE_DESCRIPTOR, fdo, NULL, 0, &descriptor, sizeof(descriptor)); - if (status != STATUS_SUCCESS) + call_minidriver( IOCTL_HID_GET_DEVICE_DESCRIPTOR, fdo, NULL, 0, &descriptor, sizeof(descriptor), &io ); + if (io.Status != STATUS_SUCCESS) { ERR("Cannot get Device Descriptor(%x)\n",status); IoDeleteDevice(child_pdo); @@ -240,9 +241,9 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo) }
reportDescriptor = malloc(descriptor.DescriptorList[i].wReportLength); - status = call_minidriver(IOCTL_HID_GET_REPORT_DESCRIPTOR, fdo, NULL, 0, - reportDescriptor, descriptor.DescriptorList[i].wReportLength); - if (status != STATUS_SUCCESS) + call_minidriver( IOCTL_HID_GET_REPORT_DESCRIPTOR, fdo, NULL, 0, reportDescriptor, + descriptor.DescriptorList[i].wReportLength, &io ); + if (io.Status != STATUS_SUCCESS) { ERR("Cannot get Report Descriptor(%x)\n",status); free(reportDescriptor); @@ -606,19 +607,16 @@ NTSTATUS WINAPI HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION *registration) return STATUS_SUCCESS; }
-NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size) +void call_minidriver( ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, + void *out_buff, ULONG out_size, IO_STATUS_BLOCK *io ) { IRP *irp; - IO_STATUS_BLOCK io; KEVENT event;
KeInitializeEvent(&event, NotificationEvent, FALSE);
- irp = IoBuildDeviceIoControlRequest(code, device, in_buff, in_size, - out_buff, out_size, TRUE, &event, &io); + irp = IoBuildDeviceIoControlRequest( code, device, in_buff, in_size, out_buff, out_size, TRUE, &event, io );
if (IoCallDriver(device, irp) == STATUS_PENDING) KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); - - return io.Status; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 5 ----- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 7c2ecb9b4df..5de946a0d17 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -523,12 +523,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet), &irp->IoStatus ); if (irp->IoStatus.Status == STATUS_SUCCESS) - { irp->IoStatus.Status = copy_packet_into_buffer( packet, buffer, buffer_len, &out_length ); - irp->IoStatus.Information = out_length; - } - else - irp->IoStatus.Information = 0; free(packet); break; } diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 91fa7e73c88..02f37773c67 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2475,7 +2475,7 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled value = caps.InputReportByteLength * 2; ret = sync_ioctl(file, IOCTL_HID_GET_INPUT_REPORT, NULL, 0, report, &value); ok(ret, "IOCTL_HID_GET_INPUT_REPORT failed, last error %u\n", GetLastError()); - todo_wine ok(value == 3, "got length %u, expected 3\n", value); + ok(value == 3, "got length %u, expected 3\n", value); ok(report[0] == report_id, "got report[0] %02x, expected %02x\n", report[0], report_id);