hidclass.sys: Enforce output packet lengths to match report lengths.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
29b90620c1
commit
88a8e824e6
|
@ -389,7 +389,6 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
|
|||
winetest_push_context( "%s expect[%d]", expect.context, index );
|
||||
ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
|
||||
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
|
||||
todo_wine_if( expect.todo_report_len )
|
||||
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
|
||||
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
|
||||
"unexpected data\n" );
|
||||
|
@ -439,7 +438,6 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
|
|||
winetest_push_context( "%s expect[%d]", expect.context, index );
|
||||
ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
|
||||
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
|
||||
todo_wine_if( expect.todo_report_len )
|
||||
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
|
||||
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
|
||||
"unexpected data\n" );
|
||||
|
@ -489,7 +487,6 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
|
|||
winetest_push_context( "%s expect[%d]", expect.context, index );
|
||||
ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
|
||||
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
|
||||
todo_wine_if( expect.todo_report_len )
|
||||
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
|
||||
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
|
||||
"unexpected data\n" );
|
||||
|
|
|
@ -48,7 +48,6 @@ struct hid_expect
|
|||
DWORD ret_status;
|
||||
BYTE broken; /* missing on some win versions */
|
||||
BYTE report_id;
|
||||
BYTE todo_report_len;
|
||||
BYTE report_len;
|
||||
BYTE report_buf[128];
|
||||
char context[64];
|
||||
|
|
|
@ -946,7 +946,6 @@ static void test_hidp_set_feature( HANDLE file, int report_id, ULONG report_len,
|
|||
{
|
||||
.code = IOCTL_HID_SET_FEATURE,
|
||||
.report_id = report_id,
|
||||
.todo_report_len = TRUE,
|
||||
.report_len = report_len - (report_id ? 0 : 1),
|
||||
.report_buf =
|
||||
{
|
||||
|
@ -1048,7 +1047,6 @@ static void test_hidp_set_output( HANDLE file, int report_id, ULONG report_len,
|
|||
{
|
||||
.code = IOCTL_HID_SET_OUTPUT_REPORT,
|
||||
.report_id = report_id,
|
||||
.todo_report_len = TRUE,
|
||||
.report_len = report_len - (report_id ? 0 : 1),
|
||||
.report_buf = {report_id,0,0xcd,0xcd,0xcd},
|
||||
.ret_length = 3,
|
||||
|
@ -1135,7 +1133,6 @@ static void test_write_file( HANDLE file, int report_id, ULONG report_len )
|
|||
{
|
||||
.code = IOCTL_HID_WRITE_REPORT,
|
||||
.report_id = report_id,
|
||||
.todo_report_len = report_id == 0,
|
||||
.report_len = report_len - (report_id ? 0 : 1),
|
||||
.report_buf = {report_id ? report_id : 0xcd,0xcd,0xcd,0xcd,0xcd},
|
||||
.ret_length = 3,
|
||||
|
|
|
@ -365,7 +365,7 @@ static void hid_device_xfer_report( BASE_DEVICE_EXTENSION *ext, ULONG code, IRP
|
|||
HIDP_REPORT_IDS *reports = ext->u.pdo.device_desc.ReportIDs;
|
||||
ULONG report_count = ext->u.pdo.device_desc.ReportIDsLength;
|
||||
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp );
|
||||
ULONG i, report_len = 0, buffer_len = 0;
|
||||
ULONG i, offset = 0, report_len = 0, buffer_len = 0;
|
||||
HID_XFER_PACKET packet;
|
||||
BYTE *buffer = NULL;
|
||||
|
||||
|
@ -402,6 +402,7 @@ static void hid_device_xfer_report( BASE_DEVICE_EXTENSION *ext, ULONG code, IRP
|
|||
irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||
return;
|
||||
}
|
||||
if (!reports[i].ReportID) offset = 1;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
|
@ -423,26 +424,20 @@ static void hid_device_xfer_report( BASE_DEVICE_EXTENSION *ext, ULONG code, IRP
|
|||
return;
|
||||
}
|
||||
|
||||
packet.reportId = buffer[0];
|
||||
packet.reportBuffer = buffer;
|
||||
packet.reportBufferLen = buffer_len;
|
||||
|
||||
if (!reports[i].ReportID)
|
||||
{
|
||||
packet.reportId = 0;
|
||||
packet.reportBuffer++;
|
||||
packet.reportBufferLen--;
|
||||
}
|
||||
packet.reportId = reports[i].ReportID;
|
||||
packet.reportBuffer = buffer + offset;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case IOCTL_HID_GET_FEATURE:
|
||||
case IOCTL_HID_GET_INPUT_REPORT:
|
||||
packet.reportBufferLen = buffer_len - offset;
|
||||
call_minidriver( code, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet), &irp->IoStatus );
|
||||
break;
|
||||
case IOCTL_HID_SET_FEATURE:
|
||||
case IOCTL_HID_SET_OUTPUT_REPORT:
|
||||
case IOCTL_HID_WRITE_REPORT:
|
||||
packet.reportBufferLen = report_len - offset;
|
||||
call_minidriver( code, ext->u.pdo.parent_fdo, NULL, sizeof(packet), &packet, 0, &irp->IoStatus );
|
||||
if (code == IOCTL_HID_WRITE_REPORT && packet.reportId) irp->IoStatus.Information--;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue