hidclass.sys: Use nameless unions.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-06-04 11:30:32 +02:00 committed by Alexandre Julliard
parent 1c5e57fc75
commit 975e33c7e7
4 changed files with 112 additions and 117 deletions

View File

@ -19,7 +19,6 @@
#include <stdarg.h>
#include <stdlib.h>
#define NONAMELESSUNION
#include "hid.h"
#include "wine/debug.h"

View File

@ -21,7 +21,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#define NONAMELESSUNION
#include "hid.h"
#include "wine/debug.h"
@ -174,25 +173,25 @@ struct caps_stack {
static const char* debugstr_usages(struct caps *caps)
{
if (!caps->IsRange)
return wine_dbg_sprintf("[0x%x]", caps->u.NotRange.Usage);
return wine_dbg_sprintf("[0x%x]", caps->NotRange.Usage);
else
return wine_dbg_sprintf("[0x%x - 0x%x]", caps->u.Range.UsageMin, caps->u.Range.UsageMax);
return wine_dbg_sprintf("[0x%x - 0x%x]", caps->Range.UsageMin, caps->Range.UsageMax);
}
static const char* debugstr_stringindex(struct caps *caps)
{
if (!caps->IsStringRange)
return wine_dbg_sprintf("%i", caps->u.NotRange.StringIndex);
return wine_dbg_sprintf("%i", caps->NotRange.StringIndex);
else
return wine_dbg_sprintf("[%i - %i]", caps->u.Range.StringMin, caps->u.Range.StringMax);
return wine_dbg_sprintf("[%i - %i]", caps->Range.StringMin, caps->Range.StringMax);
}
static const char* debugstr_designatorindex(struct caps *caps)
{
if (!caps->IsDesignatorRange)
return wine_dbg_sprintf("%i", caps->u.NotRange.DesignatorIndex);
return wine_dbg_sprintf("%i", caps->NotRange.DesignatorIndex);
else
return wine_dbg_sprintf("[%i - %i]", caps->u.Range.DesignatorMin, caps->u.Range.DesignatorMax);
return wine_dbg_sprintf("[%i - %i]", caps->Range.DesignatorMin, caps->Range.DesignatorMax);
}
static void debugstr_caps(const char* type, struct caps *caps)
@ -262,14 +261,14 @@ static void debug_print_button_cap(const CHAR * type, WINE_HID_ELEMENT *wine_ele
if (!wine_element->caps.button.IsRange)
TRACE("%s Button: 0x%x/0x%04x: ReportId %i, startBit %i/1\n" , type,
wine_element->caps.button.UsagePage,
wine_element->caps.button.u.NotRange.Usage,
wine_element->caps.button.NotRange.Usage,
wine_element->caps.value.ReportID,
wine_element->valueStartBit);
else
TRACE("%s Button: 0x%x/[0x%04x-0x%04x]: ReportId %i, startBit %i/%i\n" ,type,
wine_element->caps.button.UsagePage,
wine_element->caps.button.u.Range.UsageMin,
wine_element->caps.button.u.Range.UsageMax,
wine_element->caps.button.Range.UsageMin,
wine_element->caps.button.Range.UsageMax,
wine_element->caps.value.ReportID,
wine_element->valueStartBit,
wine_element->bitCount);
@ -282,7 +281,7 @@ static void debug_print_value_cap(const CHAR * type, WINE_HID_ELEMENT *wine_elem
"LogicalMin %i, Logical Max %i, PhysicalMin %i, "
"PhysicalMax %i -- StartBit %i/%i\n", type,
wine_element->caps.value.UsagePage,
wine_element->caps.value.u.NotRange.Usage,
wine_element->caps.value.NotRange.Usage,
wine_element->caps.value.ReportID,
wine_element->caps.value.IsAbsolute,
wine_element->caps.value.HasNull,
@ -455,7 +454,7 @@ static void new_caps(struct caps *caps)
caps->IsRange = 0;
caps->IsStringRange = 0;
caps->IsDesignatorRange = 0;
caps->u.NotRange.Usage = 0;
caps->NotRange.Usage = 0;
}
static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int length,
@ -517,7 +516,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l
feature->type = HidP_Feature;
parse_io_feature(bSize, itemVal, bTag, feature_index, feature);
if (j < usages_top)
caps->u.NotRange.Usage = usages[j];
caps->NotRange.Usage = usages[j];
feature->caps = *caps;
feature->caps.ReportCount = 1;
feature->collection = collection;
@ -539,7 +538,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l
We do not properly handle composite devices yet. */
if (usages_top)
{
caps->u.NotRange.Usage = usages[usages_top-1];
caps->NotRange.Usage = usages[usages_top-1];
usages_top = 0;
}
if (*collection_index == 0)
@ -639,35 +638,35 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l
}
break;
case TAG_LOCAL_USAGE_MINIMUM:
caps->u.Range.UsageMin = getValue(bSize, itemVal, FALSE);
caps->Range.UsageMin = getValue(bSize, itemVal, FALSE);
caps->IsRange = TRUE;
break;
case TAG_LOCAL_USAGE_MAXIMUM:
caps->u.Range.UsageMax = getValue(bSize, itemVal, FALSE);
caps->Range.UsageMax = getValue(bSize, itemVal, FALSE);
caps->IsRange = TRUE;
break;
case TAG_LOCAL_DESIGNATOR_INDEX:
caps->u.NotRange.DesignatorIndex = getValue(bSize, itemVal, FALSE);
caps->NotRange.DesignatorIndex = getValue(bSize, itemVal, FALSE);
caps->IsDesignatorRange = FALSE;
break;
case TAG_LOCAL_DESIGNATOR_MINIMUM:
caps->u.Range.DesignatorMin = getValue(bSize, itemVal, FALSE);
caps->Range.DesignatorMin = getValue(bSize, itemVal, FALSE);
caps->IsDesignatorRange = TRUE;
break;
case TAG_LOCAL_DESIGNATOR_MAXIMUM:
caps->u.Range.DesignatorMax = getValue(bSize, itemVal, FALSE);
caps->Range.DesignatorMax = getValue(bSize, itemVal, FALSE);
caps->IsDesignatorRange = TRUE;
break;
case TAG_LOCAL_STRING_INDEX:
caps->u.NotRange.StringIndex = getValue(bSize, itemVal, FALSE);
caps->NotRange.StringIndex = getValue(bSize, itemVal, FALSE);
caps->IsStringRange = FALSE;
break;
case TAG_LOCAL_STRING_MINIMUM:
caps->u.Range.StringMin = getValue(bSize, itemVal, FALSE);
caps->Range.StringMin = getValue(bSize, itemVal, FALSE);
caps->IsStringRange = TRUE;
break;
case TAG_LOCAL_STRING_MAXIMUM:
caps->u.Range.StringMax = getValue(bSize, itemVal, FALSE);
caps->Range.StringMax = getValue(bSize, itemVal, FALSE);
caps->IsStringRange = TRUE;
break;
case TAG_LOCAL_DELIMITER:
@ -709,7 +708,7 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems
wine_element->caps.button.ReportID = feature->caps.ReportID;
wine_element->caps.button.BitField = feature->BitField;
wine_element->caps.button.LinkCollection = feature->collection->index;
wine_element->caps.button.LinkUsage = feature->collection->caps.u.NotRange.Usage;
wine_element->caps.button.LinkUsage = feature->collection->caps.NotRange.Usage;
wine_element->caps.button.LinkUsagePage = feature->collection->caps.UsagePage;
wine_element->caps.button.IsRange = feature->caps.IsRange;
wine_element->caps.button.IsStringRange = feature->caps.IsStringRange;
@ -717,26 +716,26 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems
wine_element->caps.button.IsAbsolute = feature->IsAbsolute;
if (wine_element->caps.button.IsRange)
{
wine_element->caps.button.u.Range.UsageMin = feature->caps.u.Range.UsageMin;
wine_element->caps.button.u.Range.UsageMax = feature->caps.u.Range.UsageMax;
wine_element->caps.button.u.Range.StringMin = feature->caps.u.Range.StringMin;
wine_element->caps.button.u.Range.StringMax = feature->caps.u.Range.StringMax;
wine_element->caps.button.u.Range.DesignatorMin = feature->caps.u.Range.DesignatorMin;
wine_element->caps.button.u.Range.DesignatorMax = feature->caps.u.Range.DesignatorMax;
wine_element->caps.button.u.Range.DataIndexMin = *data_index;
wine_element->caps.button.u.Range.DataIndexMax = *data_index + wine_element->bitCount - 1;
wine_element->caps.button.Range.UsageMin = feature->caps.Range.UsageMin;
wine_element->caps.button.Range.UsageMax = feature->caps.Range.UsageMax;
wine_element->caps.button.Range.StringMin = feature->caps.Range.StringMin;
wine_element->caps.button.Range.StringMax = feature->caps.Range.StringMax;
wine_element->caps.button.Range.DesignatorMin = feature->caps.Range.DesignatorMin;
wine_element->caps.button.Range.DesignatorMax = feature->caps.Range.DesignatorMax;
wine_element->caps.button.Range.DataIndexMin = *data_index;
wine_element->caps.button.Range.DataIndexMax = *data_index + wine_element->bitCount - 1;
*data_index = *data_index + wine_element->bitCount;
}
else
{
wine_element->caps.button.u.NotRange.Usage = feature->caps.u.NotRange.Usage;
wine_element->caps.button.u.NotRange.Reserved1 = feature->caps.u.NotRange.Usage;
wine_element->caps.button.u.NotRange.StringIndex = feature->caps.u.NotRange.StringIndex;
wine_element->caps.button.u.NotRange.Reserved2 = feature->caps.u.NotRange.StringIndex;
wine_element->caps.button.u.NotRange.DesignatorIndex = feature->caps.u.NotRange.DesignatorIndex;
wine_element->caps.button.u.NotRange.Reserved3 = feature->caps.u.NotRange.DesignatorIndex;
wine_element->caps.button.u.NotRange.DataIndex = *data_index;
wine_element->caps.button.u.NotRange.Reserved4 = *data_index;
wine_element->caps.button.NotRange.Usage = feature->caps.NotRange.Usage;
wine_element->caps.button.NotRange.Reserved1 = feature->caps.NotRange.Usage;
wine_element->caps.button.NotRange.StringIndex = feature->caps.NotRange.StringIndex;
wine_element->caps.button.NotRange.Reserved2 = feature->caps.NotRange.StringIndex;
wine_element->caps.button.NotRange.DesignatorIndex = feature->caps.NotRange.DesignatorIndex;
wine_element->caps.button.NotRange.Reserved3 = feature->caps.NotRange.DesignatorIndex;
wine_element->caps.button.NotRange.DataIndex = *data_index;
wine_element->caps.button.NotRange.Reserved4 = *data_index;
*data_index = *data_index + 1;
}
}
@ -747,7 +746,7 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems
wine_element->caps.value.ReportID = feature->caps.ReportID;
wine_element->caps.value.BitField = feature->BitField;
wine_element->caps.value.LinkCollection = feature->collection->index;
wine_element->caps.value.LinkUsage = feature->collection->caps.u.NotRange.Usage;
wine_element->caps.value.LinkUsage = feature->collection->caps.NotRange.Usage;
wine_element->caps.value.LinkUsagePage = feature->collection->caps.UsagePage;
wine_element->caps.value.IsRange = feature->caps.IsRange;
wine_element->caps.value.IsStringRange = feature->caps.IsStringRange;
@ -764,30 +763,30 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems
wine_element->caps.value.PhysicalMax = feature->caps.PhysicalMax;
if (wine_element->caps.value.IsRange)
{
wine_element->caps.value.u.Range.UsageMin = feature->caps.u.Range.UsageMin;
wine_element->caps.value.u.Range.UsageMax = feature->caps.u.Range.UsageMax;
wine_element->caps.value.u.Range.StringMin = feature->caps.u.Range.StringMin;
wine_element->caps.value.u.Range.StringMax = feature->caps.u.Range.StringMax;
wine_element->caps.value.u.Range.DesignatorMin = feature->caps.u.Range.DesignatorMin;
wine_element->caps.value.u.Range.DesignatorMax = feature->caps.u.Range.DesignatorMax;
wine_element->caps.value.u.Range.DataIndexMin = *data_index;
wine_element->caps.value.u.Range.DataIndexMax = *data_index +
(wine_element->caps.value.u.Range.UsageMax -
wine_element->caps.value.u.Range.UsageMin);
wine_element->caps.value.Range.UsageMin = feature->caps.Range.UsageMin;
wine_element->caps.value.Range.UsageMax = feature->caps.Range.UsageMax;
wine_element->caps.value.Range.StringMin = feature->caps.Range.StringMin;
wine_element->caps.value.Range.StringMax = feature->caps.Range.StringMax;
wine_element->caps.value.Range.DesignatorMin = feature->caps.Range.DesignatorMin;
wine_element->caps.value.Range.DesignatorMax = feature->caps.Range.DesignatorMax;
wine_element->caps.value.Range.DataIndexMin = *data_index;
wine_element->caps.value.Range.DataIndexMax = *data_index +
(wine_element->caps.value.Range.UsageMax -
wine_element->caps.value.Range.UsageMin);
*data_index = *data_index +
(wine_element->caps.value.u.Range.UsageMax -
wine_element->caps.value.u.Range.UsageMin) + 1;
(wine_element->caps.value.Range.UsageMax -
wine_element->caps.value.Range.UsageMin) + 1;
}
else
{
wine_element->caps.value.u.NotRange.Usage = feature->caps.u.NotRange.Usage;
wine_element->caps.value.u.NotRange.Reserved1 = feature->caps.u.NotRange.Usage;
wine_element->caps.value.u.NotRange.StringIndex = feature->caps.u.NotRange.StringIndex;
wine_element->caps.value.u.NotRange.Reserved2 = feature->caps.u.NotRange.StringIndex;
wine_element->caps.value.u.NotRange.DesignatorIndex = feature->caps.u.NotRange.DesignatorIndex;
wine_element->caps.value.u.NotRange.Reserved3 = feature->caps.u.NotRange.DesignatorIndex;
wine_element->caps.value.u.NotRange.DataIndex = *data_index;
wine_element->caps.value.u.NotRange.Reserved4 = *data_index;
wine_element->caps.value.NotRange.Usage = feature->caps.NotRange.Usage;
wine_element->caps.value.NotRange.Reserved1 = feature->caps.NotRange.Usage;
wine_element->caps.value.NotRange.StringIndex = feature->caps.NotRange.StringIndex;
wine_element->caps.value.NotRange.Reserved2 = feature->caps.NotRange.StringIndex;
wine_element->caps.value.NotRange.DesignatorIndex = feature->caps.NotRange.DesignatorIndex;
wine_element->caps.value.NotRange.Reserved3 = feature->caps.NotRange.DesignatorIndex;
wine_element->caps.value.NotRange.DataIndex = *data_index;
wine_element->caps.value.NotRange.Reserved4 = *data_index;
*data_index = *data_index + 1;
}
}
@ -888,7 +887,7 @@ static void preparse_collection(const struct collection *root, const struct coll
if (root != base)
{
nodes[base->index].LinkUsagePage = base->caps.UsagePage;
nodes[base->index].LinkUsage = base->caps.u.NotRange.Usage;
nodes[base->index].LinkUsage = base->caps.NotRange.Usage;
nodes[base->index].Parent = base->parent == root ? 0 : base->parent->index;
nodes[base->index].CollectionType = base->type;
nodes[base->index].IsAlias = 0;
@ -931,7 +930,7 @@ static WINE_HIDP_PREPARSED_DATA* build_PreparseData(struct collection *base_coll
data = calloc(1, size);
data->magic = HID_MAGIC;
data->dwSize = size;
data->caps.Usage = base_collection->caps.u.NotRange.Usage;
data->caps.Usage = base_collection->caps.NotRange.Usage;
data->caps.UsagePage = base_collection->caps.UsagePage;
data->caps.NumberLinkCollectionNodes = node_count;
data->elementOffset = element_off;

View File

@ -20,8 +20,6 @@
#include <stdarg.h>
#include <stdlib.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "hid.h"
#include "winreg.h"
#include "winuser.h"
@ -44,11 +42,11 @@ IRP *pop_irp_from_queue(BASE_DEVICE_EXTENSION *ext)
while (!irp && (entry = RemoveHeadList(&ext->u.pdo.irp_queue)) != &ext->u.pdo.irp_queue)
{
irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry);
irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
if (!IoSetCancelRoutine(irp, NULL))
{
/* cancel routine is already cleared, meaning that it was called. let it handle completion. */
InitializeListHead(&irp->Tail.Overlay.s.ListEntry);
InitializeListHead(&irp->Tail.Overlay.ListEntry);
irp = NULL;
}
}
@ -70,11 +68,11 @@ static void WINAPI read_cancel_routine(DEVICE_OBJECT *device, IRP *irp)
KeAcquireSpinLock(&ext->u.pdo.irp_queue_lock, &old_irql);
RemoveEntryList(&irp->Tail.Overlay.s.ListEntry);
RemoveEntryList(&irp->Tail.Overlay.ListEntry);
KeReleaseSpinLock(&ext->u.pdo.irp_queue_lock, old_irql);
irp->IoStatus.u.Status = STATUS_CANCELLED;
irp->IoStatus.Status = STATUS_CANCELLED;
irp->IoStatus.Information = 0;
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
@ -134,9 +132,9 @@ static void hid_device_send_input(DEVICE_OBJECT *device, HID_XFER_PACKET *packet
memcpy(report, packet->reportBuffer, packet->reportBufferLen);
input.type = INPUT_HARDWARE;
input.u.hi.uMsg = WM_INPUT;
input.u.hi.wParamH = 0;
input.u.hi.wParamL = 0;
input.hi.uMsg = WM_INPUT;
input.hi.wParamH = 0;
input.hi.wParamL = 0;
__wine_send_input(0, &input, rawinput);
free(rawinput);
@ -165,13 +163,13 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device)
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.u.Status = rc;
irp->IoStatus.Status = rc;
irp->IoStatus.Information = out_length;
}
else
{
irp->IoStatus.Information = 0;
irp->IoStatus.u.Status = STATUS_UNSUCCESSFUL;
irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
}
IoCompleteRequest( irp, IO_NO_INCREMENT );
}
@ -210,7 +208,7 @@ static DWORD CALLBACK hid_device_thread(void *args)
if (IoCallDriver(ext->u.pdo.parent_fdo, irp) == STATUS_PENDING)
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
if (irp_status.u.Status == STATUS_SUCCESS)
if (irp_status.Status == STATUS_SUCCESS)
{
RingBuffer_Write(ext->u.pdo.ring_buffer, packet);
hid_device_send_input(device, packet);
@ -246,7 +244,7 @@ static DWORD CALLBACK hid_device_thread(void *args)
if (rc == WAIT_OBJECT_0)
exit_now = TRUE;
if (!exit_now && irp_status.u.Status == STATUS_SUCCESS)
if (!exit_now && irp_status.Status == STATUS_SUCCESS)
{
packet->reportBufferLen = irp_status.Information;
if (ext->u.pdo.preparsed_data->reports[0].reportID)
@ -279,14 +277,14 @@ static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_INFORMATION(IRP *irp, BASE_DEVIC
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(HID_COLLECTION_INFORMATION))
{
irp->IoStatus.u.Status = STATUS_BUFFER_OVERFLOW;
irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
irp->IoStatus.Information = 0;
}
else
{
memcpy(irp->AssociatedIrp.SystemBuffer, &ext->u.pdo.information, sizeof(HID_COLLECTION_INFORMATION));
irp->IoStatus.Information = sizeof(HID_COLLECTION_INFORMATION);
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
}
return STATUS_SUCCESS;
}
@ -298,14 +296,14 @@ static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(IRP *irp, BASE_DEVICE
if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < data->dwSize)
{
irp->IoStatus.u.Status = STATUS_INVALID_BUFFER_SIZE;
irp->IoStatus.Status = STATUS_INVALID_BUFFER_SIZE;
irp->IoStatus.Information = 0;
}
else
{
memcpy(irp->UserBuffer, data, data->dwSize);
irp->IoStatus.Information = data->dwSize;
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
}
return STATUS_SUCCESS;
}
@ -329,7 +327,7 @@ static NTSTATUS handle_minidriver_string(BASE_DEVICE_EXTENSION *ext, IRP *irp, S
lstrcpynW(out_buffer, buffer, length);
irp->IoStatus.Information = (lstrlenW(buffer)+1) * sizeof(WCHAR);
}
irp->IoStatus.u.Status = status;
irp->IoStatus.Status = status;
return STATUS_SUCCESS;
}
@ -357,8 +355,8 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp)
rc = call_minidriver(IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet));
irp->IoStatus.u.Status = rc;
if (irp->IoStatus.u.Status == STATUS_SUCCESS)
irp->IoStatus.Status = rc;
if (irp->IoStatus.Status == STATUS_SUCCESS)
{
irp->IoStatus.Information = packet->reportBufferLen;
memcpy(out_buffer, packet->reportBuffer, packet->reportBufferLen);
@ -411,8 +409,8 @@ static NTSTATUS HID_set_to_device(DEVICE_OBJECT *device, IRP *irp)
rc = call_minidriver(irpsp->Parameters.DeviceIoControl.IoControlCode,
ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet));
irp->IoStatus.u.Status = rc;
if (irp->IoStatus.u.Status == STATUS_SUCCESS)
irp->IoStatus.Status = rc;
if (irp->IoStatus.Status == STATUS_SUCCESS)
irp->IoStatus.Information = irpsp->Parameters.DeviceIoControl.InputBufferLength;
else
irp->IoStatus.Information = 0;
@ -438,13 +436,13 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
TRACE("IOCTL_HID_GET_POLL_FREQUENCY_MSEC\n");
if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG))
{
irp->IoStatus.u.Status = STATUS_BUFFER_OVERFLOW;
irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
irp->IoStatus.Information = 0;
break;
}
*(ULONG *)irp->AssociatedIrp.SystemBuffer = ext->u.pdo.poll_interval;
irp->IoStatus.Information = sizeof(ULONG);
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
break;
case IOCTL_HID_SET_POLL_FREQUENCY_MSEC:
{
@ -452,17 +450,17 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
TRACE("IOCTL_HID_SET_POLL_FREQUENCY_MSEC\n");
if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(ULONG))
{
irp->IoStatus.u.Status = STATUS_BUFFER_TOO_SMALL;
irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
break;
}
poll_interval = *(ULONG *)irp->AssociatedIrp.SystemBuffer;
if (poll_interval <= MAX_POLL_INTERVAL_MSEC)
{
ext->u.pdo.poll_interval = poll_interval;
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
}
else
irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER;
irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
break;
}
case IOCTL_HID_GET_PRODUCT_STRING:
@ -514,7 +512,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
}
else
irp->IoStatus.Information = 0;
irp->IoStatus.u.Status = rc;
irp->IoStatus.Status = rc;
free(packet);
break;
}
@ -524,12 +522,12 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
if (irpsp->Parameters.DeviceIoControl.InputBufferLength != sizeof(ULONG))
{
irp->IoStatus.u.Status = rc = STATUS_BUFFER_OVERFLOW;
irp->IoStatus.Status = rc = STATUS_BUFFER_OVERFLOW;
}
else
{
rc = RingBuffer_SetSize(ext->u.pdo.ring_buffer, *(ULONG *)irp->AssociatedIrp.SystemBuffer);
irp->IoStatus.u.Status = rc;
irp->IoStatus.Status = rc;
}
break;
}
@ -537,12 +535,12 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
{
if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG))
{
irp->IoStatus.u.Status = rc = STATUS_BUFFER_TOO_SMALL;
irp->IoStatus.Status = rc = STATUS_BUFFER_TOO_SMALL;
}
else
{
*(ULONG *)irp->AssociatedIrp.SystemBuffer = RingBuffer_GetSize(ext->u.pdo.ring_buffer);
rc = irp->IoStatus.u.Status = STATUS_SUCCESS;
rc = irp->IoStatus.Status = STATUS_SUCCESS;
}
break;
}
@ -558,7 +556,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
ULONG code = irpsp->Parameters.DeviceIoControl.IoControlCode;
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.u.Status = STATUS_NOT_SUPPORTED;
irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
rc = STATUS_UNSUCCESSFUL;
break;
}
@ -595,7 +593,7 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp)
rc = copy_packet_into_buffer(packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length);
irp->IoStatus.Information = out_length;
irp->IoStatus.u.Status = rc;
irp->IoStatus.Status = rc;
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
else
@ -611,12 +609,12 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp)
if (irp->Cancel && !IoSetCancelRoutine(irp, NULL))
{
/* IRP was canceled before we set cancel routine */
InitializeListHead(&irp->Tail.Overlay.s.ListEntry);
InitializeListHead(&irp->Tail.Overlay.ListEntry);
KeReleaseSpinLock(&ext->u.pdo.irp_queue_lock, old_irql);
return STATUS_CANCELLED;
}
InsertTailList(&ext->u.pdo.irp_queue, &irp->Tail.Overlay.s.ListEntry);
InsertTailList(&ext->u.pdo.irp_queue, &irp->Tail.Overlay.ListEntry);
IoMarkIrpPending(irp);
KeReleaseSpinLock(&ext->u.pdo.irp_queue_lock, old_irql);
@ -635,7 +633,7 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp)
{
((BYTE*)irp->AssociatedIrp.SystemBuffer)[0] = packet.reportId;
irp->IoStatus.Information = packet.reportBufferLen + 1;
irp->IoStatus.u.Status = rc;
irp->IoStatus.Status = rc;
}
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
@ -677,8 +675,8 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp)
rc = call_minidriver(IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet));
irp->IoStatus.u.Status = rc;
if (irp->IoStatus.u.Status == STATUS_SUCCESS)
irp->IoStatus.Status = rc;
if (irp->IoStatus.Status == STATUS_SUCCESS)
irp->IoStatus.Information = irpsp->Parameters.Write.Length;
else
irp->IoStatus.Information = 0;
@ -695,7 +693,7 @@ NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp)
TRACE("Open handle on device %p\n", device);
irp->Tail.Overlay.OriginalFileObject->FsContext = UlongToPtr(RingBuffer_AddPointer(ext->u.pdo.ring_buffer));
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( irp, IO_NO_INCREMENT );
return STATUS_SUCCESS;
}
@ -706,7 +704,7 @@ NTSTATUS WINAPI pdo_close(DEVICE_OBJECT *device, IRP *irp)
int ptr = PtrToUlong(irp->Tail.Overlay.OriginalFileObject->FsContext);
TRACE("Close handle on device %p\n", device);
RingBuffer_RemovePointer(ext->u.pdo.ring_buffer, ptr);
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( irp, IO_NO_INCREMENT );
return STATUS_SUCCESS;
}

View File

@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define NONAMELESSUNION
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
@ -91,7 +90,7 @@ static NTSTATUS get_device_id(DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCH
wcscpy(id, (WCHAR *)irp_status.Information);
ExFreePool((WCHAR *)irp_status.Information);
return irp_status.u.Status;
return irp_status.Status;
}
/* user32 reserves 1 & 2 for winemouse and winekeyboard,
@ -123,9 +122,9 @@ static void send_wm_input_device_change(BASE_DEVICE_EXTENSION *ext, LPARAM param
((USAGE *)rawinput.data.hid.bRawData)[1] = ext->u.pdo.preparsed_data->caps.Usage;
input.type = INPUT_HARDWARE;
input.u.hi.uMsg = WM_INPUT_DEVICE_CHANGE;
input.u.hi.wParamH = 0;
input.u.hi.wParamL = 0;
input.hi.uMsg = WM_INPUT_DEVICE_CHANGE;
input.hi.wParamH = 0;
input.hi.wParamL = 0;
__wine_send_input(0, &input, &rawinput);
}
@ -312,7 +311,7 @@ static NTSTATUS fdo_pnp(DEVICE_OBJECT *device, IRP *irp)
if (!(devices = ExAllocatePool(PagedPool, offsetof(DEVICE_RELATIONS, Objects[1]))))
{
irp->IoStatus.u.Status = STATUS_NO_MEMORY;
irp->IoStatus.Status = STATUS_NO_MEMORY;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_NO_MEMORY;
}
@ -329,7 +328,7 @@ static NTSTATUS fdo_pnp(DEVICE_OBJECT *device, IRP *irp)
}
irp->IoStatus.Information = (ULONG_PTR)devices;
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
IoSkipCurrentIrpStackLocation(irp);
return IoCallDriver(ext->u.fdo.hid_ext.NextDeviceObject, irp);
}
@ -364,7 +363,7 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp)
{
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
BASE_DEVICE_EXTENSION *ext = device->DeviceExtension;
NTSTATUS status = irp->IoStatus.u.Status;
NTSTATUS status = irp->IoStatus.Status;
TRACE("irp %p, minor function %#x.\n", irp, irpsp->MinorFunction);
@ -482,13 +481,13 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp)
while ((queued_irp = pop_irp_from_queue(ext)))
{
queued_irp->IoStatus.u.Status = STATUS_DEVICE_REMOVED;
queued_irp->IoStatus.Status = STATUS_DEVICE_REMOVED;
IoCompleteRequest(queued_irp, IO_NO_INCREMENT);
}
RtlFreeUnicodeString(&ext->u.pdo.link_name);
irp->IoStatus.u.Status = STATUS_SUCCESS;
irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
IoDeleteDevice(device);
return STATUS_SUCCESS;
@ -502,7 +501,7 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp)
FIXME("Unhandled minor function %#x.\n", irpsp->MinorFunction);
}
irp->IoStatus.u.Status = status;
irp->IoStatus.Status = status;
IoCompleteRequest( irp, IO_NO_INCREMENT );
return status;
}
@ -523,7 +522,7 @@ static NTSTATUS WINAPI driver_create(DEVICE_OBJECT *device, IRP *irp)
if (ext->is_fdo)
{
irp->IoStatus.u.Status = STATUS_UNSUCCESSFUL;
irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_UNSUCCESSFUL;
}
@ -608,5 +607,5 @@ NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG
if (IoCallDriver(device, irp) == STATUS_PENDING)
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
return io.u.Status;
return io.Status;
}