Commit e9c3c494 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winebus.sys: Use last report length in IOCTL_HID_GET_INPUT_REPORT.

Instead of packet length, which may be larger than the last report buffer. Based on a patch from Ivo Ivanov <logos128@gmail.com>. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent dfaf7e04
...@@ -82,7 +82,7 @@ struct device_extension ...@@ -82,7 +82,7 @@ struct device_extension
ULONG report_desc_length; ULONG report_desc_length;
HIDP_DEVICE_DESC collection_desc; HIDP_DEVICE_DESC collection_desc;
BYTE *last_reports[256]; struct hid_report *last_reports[256];
struct list reports; struct list reports;
IRP *pending_read; IRP *pending_read;
...@@ -432,7 +432,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report_buf, DWORD re ...@@ -432,7 +432,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report_buf, DWORD re
{ {
struct device_extension *ext = (struct device_extension *)device->DeviceExtension; struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
ULONG size = offsetof(struct hid_report, buffer[report_len]); ULONG size = offsetof(struct hid_report, buffer[report_len]);
struct hid_report *report; struct hid_report *report, *last_report;
IRP *irp; IRP *irp;
if (!(report = RtlAllocateHeap(GetProcessHeap(), 0, size))) return; if (!(report = RtlAllocateHeap(GetProcessHeap(), 0, size))) return;
...@@ -442,8 +442,11 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report_buf, DWORD re ...@@ -442,8 +442,11 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report_buf, DWORD re
RtlEnterCriticalSection(&ext->cs); RtlEnterCriticalSection(&ext->cs);
list_add_tail(&ext->reports, &report->entry); list_add_tail(&ext->reports, &report->entry);
if (!ext->collection_desc.ReportIDs[0].ReportID) memcpy(ext->last_reports[0], report_buf, report_len); if (!ext->collection_desc.ReportIDs[0].ReportID) last_report = ext->last_reports[0];
else memcpy(ext->last_reports[report_buf[0]], report_buf, report_len); else last_report = ext->last_reports[report_buf[0]];
last_report->length = report_len;
memcpy(last_report->buffer, report_buf, report_len);
if ((irp = pop_pending_read(ext))) if ((irp = pop_pending_read(ext)))
{ {
...@@ -857,6 +860,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) ...@@ -857,6 +860,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
for (i = 0; i < ext->collection_desc.ReportIDsLength; ++i) for (i = 0; i < ext->collection_desc.ReportIDsLength; ++i)
{ {
if (!(size = reports[i].InputLength)) continue; if (!(size = reports[i].InputLength)) continue;
size = offsetof( struct hid_report, buffer[size] );
if (!(ext->last_reports[reports[i].ReportID] = RtlAllocateHeap(GetProcessHeap(), 0, size))) status = STATUS_NO_MEMORY; if (!(ext->last_reports[reports[i].ReportID] = RtlAllocateHeap(GetProcessHeap(), 0, size))) status = STATUS_NO_MEMORY;
} }
if (!status) ext->state = DEVICE_STATE_STARTED; if (!status) ext->state = DEVICE_STATE_STARTED;
...@@ -1035,7 +1039,9 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) ...@@ -1035,7 +1039,9 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
case IOCTL_HID_GET_INPUT_REPORT: case IOCTL_HID_GET_INPUT_REPORT:
{ {
HID_XFER_PACKET *packet = (HID_XFER_PACKET *)irp->UserBuffer; HID_XFER_PACKET *packet = (HID_XFER_PACKET *)irp->UserBuffer;
memcpy(packet->reportBuffer, ext->last_reports[packet->reportId], packet->reportBufferLen); struct hid_report *last_report = ext->last_reports[packet->reportId];
memcpy(packet->reportBuffer, last_report->buffer, last_report->length);
packet->reportBufferLen = last_report->length;
irp->IoStatus.Information = packet->reportBufferLen; irp->IoStatus.Information = packet->reportBufferLen;
irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
if (TRACE_ON(hid)) if (TRACE_ON(hid))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment