Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/buffer.c | 23 ++++++++++++----------- dlls/hidclass.sys/descriptor.c | 18 +++++++++--------- dlls/hidclass.sys/device.c | 23 ++++++++++++----------- dlls/hidclass.sys/pnp.c | 13 +++++++------ 4 files changed, 40 insertions(+), 37 deletions(-)
diff --git a/dlls/hidclass.sys/buffer.c b/dlls/hidclass.sys/buffer.c index eccc3ed0c4e..5d15d44ffea 100644 --- a/dlls/hidclass.sys/buffer.c +++ b/dlls/hidclass.sys/buffer.c @@ -18,6 +18,7 @@ */
#include <stdarg.h> +#include <stdlib.h> #define NONAMELESSUNION #include "hid.h"
@@ -50,26 +51,26 @@ struct ReportRingBuffer* RingBuffer_Create(UINT buffer_size)
TRACE("Create Ring Buffer with buffer size %i\n",buffer_size);
- ring = HeapAlloc(GetProcessHeap(), 0, sizeof(*ring)); + ring = malloc(sizeof(*ring)); if (!ring) return NULL; ring->start = ring->end = 0; ring->size = BASE_BUFFER_SIZE; ring->buffer_size = buffer_size; ring->pointer_alloc = 2; - ring->pointers = HeapAlloc(GetProcessHeap(), 0, sizeof(UINT) * ring->pointer_alloc); + ring->pointers = malloc(sizeof(UINT) * ring->pointer_alloc); if (!ring->pointers) { - HeapFree(GetProcessHeap(), 0, ring); + free(ring); return NULL; } for (i = 0; i < ring->pointer_alloc; i++) ring->pointers[i] = POINTER_UNUSED; - ring->buffer = HeapAlloc(GetProcessHeap(), 0, buffer_size * ring->size); + ring->buffer = malloc(buffer_size * ring->size); if (!ring->buffer) { - HeapFree(GetProcessHeap(), 0, ring->pointers); - HeapFree(GetProcessHeap(), 0, ring); + free(ring->pointers); + free(ring); return NULL; } InitializeCriticalSection(&ring->lock); @@ -79,11 +80,11 @@ struct ReportRingBuffer* RingBuffer_Create(UINT buffer_size)
void RingBuffer_Destroy(struct ReportRingBuffer *ring) { - HeapFree(GetProcessHeap(), 0, ring->buffer); - HeapFree(GetProcessHeap(), 0, ring->pointers); + free(ring->buffer); + free(ring->pointers); ring->lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ring->lock); - HeapFree(GetProcessHeap(), 0, ring); + free(ring); }
UINT RingBuffer_GetBufferSize(struct ReportRingBuffer *ring) @@ -113,13 +114,13 @@ NTSTATUS RingBuffer_SetSize(struct ReportRingBuffer *ring, UINT size) if (ring->pointers[i] != POINTER_UNUSED) ring->pointers[i] = 0; } - new_buffer = HeapAlloc(GetProcessHeap(), 0, ring->buffer_size * size); + new_buffer = malloc(ring->buffer_size * size); if (!new_buffer) { LeaveCriticalSection(&ring->lock); return STATUS_NO_MEMORY; } - HeapFree(GetProcessHeap(), 0, ring->buffer); + free(ring->buffer); ring->buffer = new_buffer; ring->size = size; LeaveCriticalSection(&ring->lock); diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index c02988494fd..ab92540994a 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -507,7 +507,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l case TAG_MAIN_FEATURE: for (j = 0; j < caps->ReportCount; j++) { - feature = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*feature)); + feature = calloc(1, sizeof(*feature)); list_add_tail(&collection->features, &feature->entry); if (bTag == TAG_MAIN_INPUT) feature->type = HidP_Input; @@ -532,7 +532,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l break; case TAG_MAIN_COLLECTION: { - struct collection *subcollection = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct collection)); + struct collection *subcollection = calloc(1, sizeof(struct collection)); list_add_tail(&collection->collections, &subcollection->entry); subcollection->parent = collection; /* Only set our collection once... @@ -598,7 +598,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l break; case TAG_GLOBAL_PUSH: { - struct caps_stack *saved = HeapAlloc(GetProcessHeap(), 0, sizeof(*saved)); + struct caps_stack *saved = malloc(sizeof(*saved)); saved->caps = *caps; TRACE("Push\n"); list_add_tail(stack, &saved->entry); @@ -615,7 +615,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l saved = LIST_ENTRY(tail, struct caps_stack, entry); *caps = saved->caps; list_remove(tail); - HeapFree(GetProcessHeap(), 0, saved); + free(saved); } else ERR("Pop but no stack!\n"); @@ -928,7 +928,7 @@ static WINE_HIDP_PREPARSED_DATA* build_PreparseData(struct collection *base_coll nodes_offset = size; size += node_count * sizeof(WINE_HID_LINK_COLLECTION_NODE);
- data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + data = calloc(1, size); data->magic = HID_MAGIC; data->dwSize = size; data->caps.Usage = base_collection->caps.u.NotRange.Usage; @@ -953,9 +953,9 @@ static void free_collection(struct collection *collection) LIST_FOR_EACH_ENTRY_SAFE(fentry, fnext, &collection->features, struct feature, entry) { list_remove(&fentry->entry); - HeapFree(GetProcessHeap(), 0, fentry); + free(fentry); } - HeapFree(GetProcessHeap(), 0, collection); + free(collection); }
WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) @@ -983,7 +983,7 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length)
list_init(&caps_stack);
- base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*base)); + base = calloc(1, sizeof(*base)); base->index = 1; list_init(&base->features); list_init(&base->collections); @@ -1001,7 +1001,7 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) LIST_FOR_EACH_ENTRY_SAFE(entry, cursor, &caps_stack, struct caps_stack, entry) { list_remove(&entry->entry); - HeapFree(GetProcessHeap(), 0, entry); + free(entry); } }
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 4d031ffcaa0..e2ca635833d 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -19,6 +19,7 @@ */
#include <stdarg.h> +#include <stdlib.h> #define NONAMELESSUNION #define NONAMELESSSTRUCT #include "hid.h" @@ -115,7 +116,7 @@ static void hid_device_send_input(DEVICE_OBJECT *device, HID_XFER_PACKET *packet data_size = offsetof(RAWINPUT, data.hid.bRawData) + packet->reportBufferLen; if (!(id = ext->u.pdo.preparsed_data->reports[0].reportID)) data_size += 1;
- if (!(rawinput = HeapAlloc(GetProcessHeap(), 0, data_size))) + if (!(rawinput = malloc(data_size))) { ERR("Failed to allocate rawinput data!\n"); return; @@ -138,7 +139,7 @@ static void hid_device_send_input(DEVICE_OBJECT *device, HID_XFER_PACKET *packet input.u.hi.wParamL = 0; __wine_send_input(0, &input, rawinput);
- HeapFree(GetProcessHeap(), 0, rawinput); + free(rawinput); }
static void HID_Device_processQueue(DEVICE_OBJECT *device) @@ -148,7 +149,7 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device) UINT buffer_size = RingBuffer_GetBufferSize(ext->u.pdo.ring_buffer); HID_XFER_PACKET *packet;
- packet = HeapAlloc(GetProcessHeap(), 0, buffer_size); + packet = malloc(buffer_size);
while((irp = pop_irp_from_queue(ext))) { @@ -174,7 +175,7 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device) } IoCompleteRequest( irp, IO_NO_INCREMENT ); } - HeapFree(GetProcessHeap(), 0, packet); + free(packet); }
static DWORD CALLBACK hid_device_thread(void *args) @@ -189,7 +190,7 @@ static DWORD CALLBACK hid_device_thread(void *args) BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; USHORT report_size = ext->u.pdo.preparsed_data->caps.InputReportByteLength;
- packet = HeapAlloc(GetProcessHeap(), 0, sizeof(*packet) + report_size); + packet = malloc(sizeof(*packet) + report_size); packet->reportBuffer = (BYTE *)packet + sizeof(*packet);
if (ext->u.pdo.information.Polled) @@ -347,7 +348,7 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) TRACE_(hid_report)("Device %p Buffer length %i Buffer %p\n", ext, irpsp->Parameters.DeviceIoControl.OutputBufferLength, out_buffer);
len = sizeof(*packet) + irpsp->Parameters.DeviceIoControl.OutputBufferLength; - packet = HeapAlloc(GetProcessHeap(), 0, len); + packet = malloc(len); packet->reportBufferLen = irpsp->Parameters.DeviceIoControl.OutputBufferLength; packet->reportBuffer = ((BYTE*)packet) + sizeof(*packet); packet->reportId = out_buffer[0]; @@ -367,7 +368,7 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp)
TRACE_(hid_report)("Result 0x%x get %li bytes\n", rc, irp->IoStatus.Information);
- HeapFree(GetProcessHeap(), 0, packet); + free(packet);
return rc; } @@ -496,7 +497,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) BYTE *buffer = MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority); ULONG out_length;
- packet = HeapAlloc(GetProcessHeap(), 0, packet_size); + packet = malloc(packet_size);
if (ext->u.pdo.preparsed_data->reports[0].reportID) packet->reportId = buffer[0]; @@ -514,7 +515,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) else irp->IoStatus.Information = 0; irp->IoStatus.u.Status = rc; - HeapFree(GetProcessHeap(), 0, packet); + free(packet); break; } case IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS: @@ -578,7 +579,7 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); int ptr = -1;
- packet = HeapAlloc(GetProcessHeap(), 0, buffer_size); + packet = malloc(buffer_size); ptr = PtrToUlong( irp->Tail.Overlay.OriginalFileObject->FsContext );
irp->IoStatus.Information = 0; @@ -639,7 +640,7 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) IoCompleteRequest(irp, IO_NO_INCREMENT); } } - HeapFree(GetProcessHeap(), 0, packet); + free(packet);
return rc; } diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index b5862a01593..f372f8ffdf5 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -21,6 +21,7 @@ #define NONAMELESSUNION #include <unistd.h> #include <stdarg.h> +#include <stdlib.h> #include "initguid.h" #include "hid.h" #include "devguid.h" @@ -239,19 +240,19 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo) return; }
- reportDescriptor = HeapAlloc(GetProcessHeap(), 0, descriptor.DescriptorList[i].wReportLength); + 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) { ERR("Cannot get Report Descriptor(%x)\n",status); - HeapFree(GetProcessHeap(), 0, reportDescriptor); + free(reportDescriptor); IoDeleteDevice(child_pdo); return; }
pdo_ext->u.pdo.preparsed_data = ParseDescriptor(reportDescriptor, descriptor.DescriptorList[i].wReportLength); - HeapFree(GetProcessHeap(), 0, reportDescriptor); + free(reportDescriptor); if (!pdo_ext->u.pdo.preparsed_data) { ERR("Cannot parse Report Descriptor\n"); @@ -475,7 +476,7 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) } CloseHandle(ext->u.pdo.halt_event);
- HeapFree(GetProcessHeap(), 0, ext->u.pdo.preparsed_data); + free(ext->u.pdo.preparsed_data); if (ext->u.pdo.ring_buffer) RingBuffer_Destroy(ext->u.pdo.ring_buffer);
@@ -561,7 +562,7 @@ static void WINAPI driver_unload(DRIVER_OBJECT *driver) if (md->DriverUnload) md->DriverUnload(md->minidriver.DriverObject); list_remove(&md->entry); - HeapFree(GetProcessHeap(), 0, md); + free(md); } }
@@ -569,7 +570,7 @@ NTSTATUS WINAPI HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION *registration) { minidriver *driver;
- if (!(driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*driver)))) + if (!(driver = calloc(1, sizeof(*driver)))) return STATUS_NO_MEMORY;
driver->DriverUnload = registration->DriverObject->DriverUnload;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/buffer.c | 1 - dlls/hidclass.sys/descriptor.c | 123 ++++++++++++++++----------------- dlls/hidclass.sys/device.c | 80 +++++++++++---------- dlls/hidclass.sys/pnp.c | 25 ++++--- 4 files changed, 112 insertions(+), 117 deletions(-)
diff --git a/dlls/hidclass.sys/buffer.c b/dlls/hidclass.sys/buffer.c index 5d15d44ffea..a45833ae383 100644 --- a/dlls/hidclass.sys/buffer.c +++ b/dlls/hidclass.sys/buffer.c @@ -19,7 +19,6 @@
#include <stdarg.h> #include <stdlib.h> -#define NONAMELESSUNION #include "hid.h"
#include "wine/debug.h" diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index ab92540994a..c7687e400ef 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -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; diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index e2ca635833d..73ea6610ab8 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -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; } diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index f372f8ffdf5..4953bd3bebc 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -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; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index c4d162695a9..131a02af4eb 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -21,7 +21,6 @@
#include <stdarg.h>
-#define NONAMELESSUNION #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" @@ -275,14 +274,14 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT value->UsagePage != UsagePage) continue;
- if (value->IsRange && value->u.Range.UsageMin <= Usage && Usage <= value->u.Range.UsageMax) + if (value->IsRange && value->Range.UsageMin <= Usage && Usage <= value->Range.UsageMax) { *element = elems[report->elementIdx + i]; - element->valueStartBit += value->BitSize * (Usage - value->u.Range.UsageMin); + element->valueStartBit += value->BitSize * (Usage - value->Range.UsageMin); element->bitCount = elems[report->elementIdx + i].ElementType == ValueElement ? value->BitSize: 1; return HIDP_STATUS_SUCCESS; } - else if (value->u.NotRange.Usage == Usage) + else if (value->NotRange.Usage == Usage) { *element = elems[report->elementIdx + i]; element->bitCount = elems[report->elementIdx + i].ElementType == ValueElement ? value->BitSize : 1; @@ -453,7 +452,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH { if (uCount == *UsageLength) return HIDP_STATUS_BUFFER_TOO_SMALL; - UsageList[uCount] = element->caps.button.u.Range.UsageMin + k; + UsageList[uCount] = element->caps.button.Range.UsageMin + k; uCount++; } } @@ -612,8 +611,8 @@ ULONG WINAPI HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, USAGE UsagePag (UsagePage == 0 || elems[report[i].elementIdx + j].caps.button.UsagePage == UsagePage)) { if (elems[report[i].elementIdx + j].caps.button.IsRange) - count += (elems[report[i].elementIdx + j].caps.button.u.Range.UsageMax - - elems[report[i].elementIdx + j].caps.button.u.Range.UsageMin) + 1; + count += (elems[report[i].elementIdx + j].caps.button.Range.UsageMax - + elems[report[i].elementIdx + j].caps.button.Range.UsageMin) + 1; else count++; } @@ -740,10 +739,10 @@ NTSTATUS WINAPI HidP_GetSpecificButtonCaps(HIDP_REPORT_TYPE ReportType, (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.button.LinkCollection) && (Usage == 0 || ( (!elems[report[j].elementIdx + i].caps.button.IsRange && - Usage == elems[report[j].elementIdx + i].caps.button.u.NotRange.Usage)) || + Usage == elems[report[j].elementIdx + i].caps.button.NotRange.Usage)) || (elems[report[j].elementIdx + i].caps.button.IsRange && - Usage >= elems[report[j].elementIdx + i].caps.button.u.Range.UsageMin && - Usage <= elems[report[j].elementIdx + i].caps.button.u.Range.UsageMax))) + Usage >= elems[report[j].elementIdx + i].caps.button.Range.UsageMin && + Usage <= elems[report[j].elementIdx + i].caps.button.Range.UsageMax))) { ButtonCaps[u++] = elems[report[j].elementIdx + i].caps.button; } @@ -808,7 +807,7 @@ NTSTATUS WINAPI HidP_GetSpecificValueCaps(HIDP_REPORT_TYPE ReportType, if (elems[report[j].elementIdx + i].ElementType == ValueElement && (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.value.UsagePage) && (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.value.LinkCollection) && - (Usage == 0 || Usage == elems[report[j].elementIdx + i].caps.value.u.NotRange.Usage)) + (Usage == 0 || Usage == elems[report[j].elementIdx + i].caps.value.NotRange.Usage)) { ValueCaps[u++] = elems[report[j].elementIdx + i].caps.value; } @@ -877,7 +876,7 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect { if (uCount < *UsageLength) { - ButtonList[uCount].Usage = element->caps.button.u.Range.UsageMin + k; + ButtonList[uCount].Usage = element->caps.button.Range.UsageMin + k; ButtonList[uCount].UsagePage = element->caps.button.UsagePage; } uCount++; @@ -960,8 +959,8 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U { if (uCount < *DataLength) { - DataList[uCount].DataIndex = element->caps.button.u.Range.DataIndexMin + k; - DataList[uCount].u.On = v; + DataList[uCount].DataIndex = element->caps.button.Range.DataIndexMin + k; + DataList[uCount].On = v; } uCount++; } @@ -976,8 +975,8 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U element->valueStartBit, element->bitCount, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; - DataList[uCount].DataIndex = element->caps.value.u.NotRange.DataIndex; - DataList[uCount].u.RawValue = v; + DataList[uCount].DataIndex = element->caps.value.NotRange.DataIndex; + DataList[uCount].RawValue = v; } uCount++; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91885
Your paranoid android.
=== debiant2 (32 bit report) ===
hid: device: Timeout
On 6/4/21 12:21 PM, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91885
Your paranoid android.
=== debiant2 (32 bit report) ===
hid: device: Timeout
I think this is caused by empty mouse / keyboard HID input report descriptors.
This causes winedevice to crash on my machine (because it's trying to write at least the report id to an empty buffer passed to the ioctl), and it should probably check the available size and buffer.
We should also probably create non-empty input report descriptors for the dummy mouse and keyboard devices.
I'll send separate patches to fix these.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 41d627c62c2..4f9a63cfb88 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -21,8 +21,6 @@
#include <stdarg.h>
-#define NONAMELESSUNION -#define NONAMELESSSTRUCT #include "windef.h" #include "winbase.h" #include "wingdi.h" @@ -203,9 +201,9 @@ static void find_devices(void) WARN("Failed to get attributes.\n");
device->info.dwType = RIM_TYPEHID; - device->info.u.hid.dwVendorId = attr.VendorID; - device->info.u.hid.dwProductId = attr.ProductID; - device->info.u.hid.dwVersionNumber = attr.VersionNumber; + device->info.hid.dwVendorId = attr.VendorID; + device->info.hid.dwProductId = attr.ProductID; + device->info.hid.dwVersionNumber = attr.VersionNumber;
if (!HidD_GetPreparsedData(device->file, &device->data)) WARN("Failed to get preparsed data.\n"); @@ -213,8 +211,8 @@ static void find_devices(void) if (!HidP_GetCaps(device->data, &caps)) WARN("Failed to get caps.\n");
- device->info.u.hid.usUsagePage = caps.UsagePage; - device->info.u.hid.usUsage = caps.Usage; + device->info.hid.usUsagePage = caps.UsagePage; + device->info.hid.usUsage = caps.Usage; }
SetupDiDestroyDeviceInfoList(set); @@ -229,7 +227,7 @@ static void find_devices(void) continue;
device->info.dwType = RIM_TYPEMOUSE; - device->info.u.mouse = mouse_info; + device->info.mouse = mouse_info; }
SetupDiDestroyDeviceInfoList(set); @@ -244,7 +242,7 @@ static void find_devices(void) continue;
device->info.dwType = RIM_TYPEKEYBOARD; - device->info.u.keyboard = keyboard_info; + device->info.keyboard = keyboard_info; }
SetupDiDestroyDeviceInfoList(set); @@ -276,8 +274,8 @@ BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage) if (!(device = find_device_from_handle(handle))) return FALSE; if (device->info.dwType != RIM_TYPEHID) return FALSE;
- *usage_page = device->info.u.hid.usUsagePage; - *usage = device->info.u.hid.usUsage; + *usage_page = device->info.hid.usUsagePage; + *usage = device->info.hid.usUsage; return TRUE; }
@@ -317,36 +315,36 @@ BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_ms rawinput->header.wParam = 0;
rawinput->data.mouse.usFlags = MOUSE_MOVE_RELATIVE; - rawinput->data.mouse.u.s.usButtonFlags = 0; - rawinput->data.mouse.u.s.usButtonData = 0; + rawinput->data.mouse.usButtonFlags = 0; + rawinput->data.mouse.usButtonData = 0; for (i = 1; i < ARRAY_SIZE(button_flags); ++i) { if (msg_data->flags & (1 << i)) - rawinput->data.mouse.u.s.usButtonFlags |= button_flags[i]; + rawinput->data.mouse.usButtonFlags |= button_flags[i]; } if (msg_data->flags & MOUSEEVENTF_WHEEL) { - rawinput->data.mouse.u.s.usButtonFlags |= RI_MOUSE_WHEEL; - rawinput->data.mouse.u.s.usButtonData = msg_data->rawinput.mouse.data; + rawinput->data.mouse.usButtonFlags |= RI_MOUSE_WHEEL; + rawinput->data.mouse.usButtonData = msg_data->rawinput.mouse.data; } if (msg_data->flags & MOUSEEVENTF_HWHEEL) { - rawinput->data.mouse.u.s.usButtonFlags |= RI_MOUSE_HORIZONTAL_WHEEL; - rawinput->data.mouse.u.s.usButtonData = msg_data->rawinput.mouse.data; + rawinput->data.mouse.usButtonFlags |= RI_MOUSE_HORIZONTAL_WHEEL; + rawinput->data.mouse.usButtonData = msg_data->rawinput.mouse.data; } if (msg_data->flags & MOUSEEVENTF_XDOWN) { if (msg_data->rawinput.mouse.data == XBUTTON1) - rawinput->data.mouse.u.s.usButtonFlags |= RI_MOUSE_BUTTON_4_DOWN; + rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_DOWN; else if (msg_data->rawinput.mouse.data == XBUTTON2) - rawinput->data.mouse.u.s.usButtonFlags |= RI_MOUSE_BUTTON_5_DOWN; + rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_DOWN; } if (msg_data->flags & MOUSEEVENTF_XUP) { if (msg_data->rawinput.mouse.data == XBUTTON1) - rawinput->data.mouse.u.s.usButtonFlags |= RI_MOUSE_BUTTON_4_UP; + rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_UP; else if (msg_data->rawinput.mouse.data == XBUTTON2) - rawinput->data.mouse.u.s.usButtonFlags |= RI_MOUSE_BUTTON_5_UP; + rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_UP; }
rawinput->data.mouse.ulRawButtons = 0;
Buttons are really just values with BitSize == 1, and having a union for that makes the code more complicated than it needs.
We'll simplify the code a lot using HIDP_VALUE_CAPS everywhere, as the two structure types are compatible.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 66 ++++++------- dlls/hidclass.sys/descriptor.c | 176 ++++++++++++++++----------------- dlls/user32/rawinput.c | 2 + include/wine/hid.h | 43 +++++++- 4 files changed, 162 insertions(+), 125 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 131a02af4eb..92c1442d048 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -204,7 +204,7 @@ NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAP for (i = 0; i < report[j].elementCount && u < b_count; i++) { if (elems[report[j].elementIdx + i].ElementType == ButtonElement) - ButtonCaps[u++] = elems[report[j].elementIdx + i].caps.button; + ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i].caps; } }
@@ -268,7 +268,7 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT
for (i = 0; i < report->elementCount; i++) { - HIDP_VALUE_CAPS *value = &elems[report->elementIdx + i].caps.value; + HIDP_VALUE_CAPS *value = &elems[report->elementIdx + i].caps;
if (elems[report->elementIdx + i].ElementType != ElementType || value->UsagePage != UsagePage) @@ -298,7 +298,7 @@ static LONG sign_extend(ULONG value, const WINE_HID_ELEMENT *element)
if ((value & (1 << (bit_count - 1))) && element->ElementType == ValueElement - && element->caps.value.LogicalMin < 0) + && element->caps.LogicalMin < 0) { value -= (1 << bit_count); } @@ -307,12 +307,12 @@ static LONG sign_extend(ULONG value, const WINE_HID_ELEMENT *element)
static LONG logical_to_physical(LONG value, const WINE_HID_ELEMENT *element) { - if (element->caps.value.PhysicalMin || element->caps.value.PhysicalMax) + if (element->caps.PhysicalMin || element->caps.PhysicalMax) { - value = (((ULONGLONG)(value - element->caps.value.LogicalMin) - * (element->caps.value.PhysicalMax - element->caps.value.PhysicalMin)) - / (element->caps.value.LogicalMax - element->caps.value.LogicalMin)) - + element->caps.value.PhysicalMin; + value = (((ULONGLONG)(value - element->caps.LogicalMin) + * (element->caps.PhysicalMax - element->caps.PhysicalMin)) + / (element->caps.LogicalMax - element->caps.LogicalMin)) + + element->caps.PhysicalMin; } return value; } @@ -378,11 +378,11 @@ NTSTATUS WINAPI HidP_GetUsageValueArray(HIDP_REPORT_TYPE ReportType, USAGE Usage
if (rc == HIDP_STATUS_SUCCESS) { - if (element.caps.value.IsRange || element.caps.value.ReportCount <= 1 || !element.bitCount) + if (element.caps.IsRange || element.caps.ReportCount <= 1 || !element.bitCount) return HIDP_STATUS_NOT_VALUE_ARRAY;
return get_report_data_array((BYTE*)Report, ReportLength, element.valueStartBit, element.bitCount, - element.caps.value.ReportCount, UsageValue, UsageValueByteLength); + element.caps.ReportCount, UsageValue, UsageValueByteLength); }
return rc; @@ -436,7 +436,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH for (i = 0; i < report->elementCount && uCount < *UsageLength; i++) { if (elems[report->elementIdx + i].ElementType == ButtonElement && - elems[report->elementIdx + i].caps.button.UsagePage == UsagePage) + elems[report->elementIdx + i].caps.UsagePage == UsagePage) { int k; WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; @@ -452,7 +452,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH { if (uCount == *UsageLength) return HIDP_STATUS_BUFFER_TOO_SMALL; - UsageList[uCount] = element->caps.button.Range.UsageMin + k; + UsageList[uCount] = element->caps.Range.UsageMin + k; uCount++; } } @@ -515,7 +515,7 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS for (i = 0; i < report[j].elementCount && u < v_count; i++) { if (elems[report[j].elementIdx + i].ElementType == ValueElement) - ValueCaps[u++] = elems[report[j].elementIdx + i].caps.value; + ValueCaps[u++] = elems[report[j].elementIdx + i].caps; } }
@@ -608,11 +608,11 @@ ULONG WINAPI HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, USAGE UsagePag for (j = 0; j < report[i].elementCount; j++) { if (elems[report[i].elementIdx + j].ElementType == ButtonElement && - (UsagePage == 0 || elems[report[i].elementIdx + j].caps.button.UsagePage == UsagePage)) + (UsagePage == 0 || elems[report[i].elementIdx + j].caps.UsagePage == UsagePage)) { - if (elems[report[i].elementIdx + j].caps.button.IsRange) - count += (elems[report[i].elementIdx + j].caps.button.Range.UsageMax - - elems[report[i].elementIdx + j].caps.button.Range.UsageMin) + 1; + if (elems[report[i].elementIdx + j].caps.IsRange) + count += (elems[report[i].elementIdx + j].caps.Range.UsageMax - + elems[report[i].elementIdx + j].caps.Range.UsageMin) + 1; else count++; } @@ -735,16 +735,16 @@ NTSTATUS WINAPI HidP_GetSpecificButtonCaps(HIDP_REPORT_TYPE ReportType, for (i = 0; i < report[j].elementCount && u < b_count; i++) { if (elems[report[j].elementIdx + i].ElementType == ButtonElement && - (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.button.UsagePage) && - (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.button.LinkCollection) && + (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.UsagePage) && + (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.LinkCollection) && (Usage == 0 || ( - (!elems[report[j].elementIdx + i].caps.button.IsRange && - Usage == elems[report[j].elementIdx + i].caps.button.NotRange.Usage)) || - (elems[report[j].elementIdx + i].caps.button.IsRange && - Usage >= elems[report[j].elementIdx + i].caps.button.Range.UsageMin && - Usage <= elems[report[j].elementIdx + i].caps.button.Range.UsageMax))) + (!elems[report[j].elementIdx + i].caps.IsRange && + Usage == elems[report[j].elementIdx + i].caps.NotRange.Usage)) || + (elems[report[j].elementIdx + i].caps.IsRange && + Usage >= elems[report[j].elementIdx + i].caps.Range.UsageMin && + Usage <= elems[report[j].elementIdx + i].caps.Range.UsageMax))) { - ButtonCaps[u++] = elems[report[j].elementIdx + i].caps.button; + ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i].caps; } } } @@ -805,11 +805,11 @@ NTSTATUS WINAPI HidP_GetSpecificValueCaps(HIDP_REPORT_TYPE ReportType, for (i = 0; i < report[j].elementCount && u < v_count; i++) { if (elems[report[j].elementIdx + i].ElementType == ValueElement && - (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.value.UsagePage) && - (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.value.LinkCollection) && - (Usage == 0 || Usage == elems[report[j].elementIdx + i].caps.value.NotRange.Usage)) + (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.UsagePage) && + (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.LinkCollection) && + (Usage == 0 || Usage == elems[report[j].elementIdx + i].caps.NotRange.Usage)) { - ValueCaps[u++] = elems[report[j].elementIdx + i].caps.value; + ValueCaps[u++] = elems[report[j].elementIdx + i].caps; } } } @@ -876,8 +876,8 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect { if (uCount < *UsageLength) { - ButtonList[uCount].Usage = element->caps.button.Range.UsageMin + k; - ButtonList[uCount].UsagePage = element->caps.button.UsagePage; + ButtonList[uCount].Usage = element->caps.Range.UsageMin + k; + ButtonList[uCount].UsagePage = element->caps.UsagePage; } uCount++; } @@ -959,7 +959,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U { if (uCount < *DataLength) { - DataList[uCount].DataIndex = element->caps.button.Range.DataIndexMin + k; + DataList[uCount].DataIndex = element->caps.Range.DataIndexMin + k; DataList[uCount].On = v; } uCount++; @@ -975,7 +975,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U element->valueStartBit, element->bitCount, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; - DataList[uCount].DataIndex = element->caps.value.NotRange.DataIndex; + DataList[uCount].DataIndex = element->caps.NotRange.DataIndex; DataList[uCount].RawValue = v; } uCount++; diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index c7687e400ef..9c52dee5fe1 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -258,18 +258,18 @@ static void debug_collection(struct collection *collection)
static void debug_print_button_cap(const CHAR * type, WINE_HID_ELEMENT *wine_element) { - if (!wine_element->caps.button.IsRange) + if (!wine_element->caps.IsRange) TRACE("%s Button: 0x%x/0x%04x: ReportId %i, startBit %i/1\n" , type, - wine_element->caps.button.UsagePage, - wine_element->caps.button.NotRange.Usage, - wine_element->caps.value.ReportID, + wine_element->caps.UsagePage, + wine_element->caps.NotRange.Usage, + wine_element->caps.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.Range.UsageMin, - wine_element->caps.button.Range.UsageMax, - wine_element->caps.value.ReportID, + wine_element->caps.UsagePage, + wine_element->caps.Range.UsageMin, + wine_element->caps.Range.UsageMax, + wine_element->caps.ReportID, wine_element->valueStartBit, wine_element->bitCount); } @@ -280,19 +280,19 @@ static void debug_print_value_cap(const CHAR * type, WINE_HID_ELEMENT *wine_elem "Bit Size %i, ReportCount %i, UnitsExp %i, Units %i, " "LogicalMin %i, Logical Max %i, PhysicalMin %i, " "PhysicalMax %i -- StartBit %i/%i\n", type, - wine_element->caps.value.UsagePage, - wine_element->caps.value.NotRange.Usage, - wine_element->caps.value.ReportID, - wine_element->caps.value.IsAbsolute, - wine_element->caps.value.HasNull, - wine_element->caps.value.BitSize, - wine_element->caps.value.ReportCount, - wine_element->caps.value.UnitsExp, - wine_element->caps.value.Units, - wine_element->caps.value.LogicalMin, - wine_element->caps.value.LogicalMax, - wine_element->caps.value.PhysicalMin, - wine_element->caps.value.PhysicalMax, + wine_element->caps.UsagePage, + wine_element->caps.NotRange.Usage, + wine_element->caps.ReportID, + wine_element->caps.IsAbsolute, + wine_element->caps.HasNull, + wine_element->caps.BitSize, + wine_element->caps.ReportCount, + wine_element->caps.UnitsExp, + wine_element->caps.Units, + wine_element->caps.LogicalMin, + wine_element->caps.LogicalMax, + wine_element->caps.PhysicalMin, + wine_element->caps.PhysicalMax, wine_element->valueStartBit, wine_element->bitCount); } @@ -704,89 +704,89 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems if (feature->caps.BitSize == 1) { wine_element->ElementType = ButtonElement; - wine_element->caps.button.UsagePage = feature->caps.UsagePage; - 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.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; - wine_element->caps.button.IsDesignatorRange = feature->caps.IsDesignatorRange; - wine_element->caps.button.IsAbsolute = feature->IsAbsolute; - if (wine_element->caps.button.IsRange) + wine_element->caps.UsagePage = feature->caps.UsagePage; + wine_element->caps.ReportID = feature->caps.ReportID; + wine_element->caps.BitField = feature->BitField; + wine_element->caps.LinkCollection = feature->collection->index; + wine_element->caps.LinkUsage = feature->collection->caps.NotRange.Usage; + wine_element->caps.LinkUsagePage = feature->collection->caps.UsagePage; + wine_element->caps.IsRange = feature->caps.IsRange; + wine_element->caps.IsStringRange = feature->caps.IsStringRange; + wine_element->caps.IsDesignatorRange = feature->caps.IsDesignatorRange; + wine_element->caps.IsAbsolute = feature->IsAbsolute; + if (wine_element->caps.IsRange) { - 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; + wine_element->caps.Range.UsageMin = feature->caps.Range.UsageMin; + wine_element->caps.Range.UsageMax = feature->caps.Range.UsageMax; + wine_element->caps.Range.StringMin = feature->caps.Range.StringMin; + wine_element->caps.Range.StringMax = feature->caps.Range.StringMax; + wine_element->caps.Range.DesignatorMin = feature->caps.Range.DesignatorMin; + wine_element->caps.Range.DesignatorMax = feature->caps.Range.DesignatorMax; + wine_element->caps.Range.DataIndexMin = *data_index; + wine_element->caps.Range.DataIndexMax = *data_index + wine_element->bitCount - 1; *data_index = *data_index + wine_element->bitCount; } else { - 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; + wine_element->caps.NotRange.Usage = feature->caps.NotRange.Usage; + wine_element->caps.NotRange.Reserved1 = feature->caps.NotRange.Usage; + wine_element->caps.NotRange.StringIndex = feature->caps.NotRange.StringIndex; + wine_element->caps.NotRange.Reserved2 = feature->caps.NotRange.StringIndex; + wine_element->caps.NotRange.DesignatorIndex = feature->caps.NotRange.DesignatorIndex; + wine_element->caps.NotRange.Reserved3 = feature->caps.NotRange.DesignatorIndex; + wine_element->caps.NotRange.DataIndex = *data_index; + wine_element->caps.NotRange.Reserved4 = *data_index; *data_index = *data_index + 1; } } else { wine_element->ElementType = ValueElement; - wine_element->caps.value.UsagePage = feature->caps.UsagePage; - 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.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; - wine_element->caps.value.IsDesignatorRange = feature->caps.IsDesignatorRange; - wine_element->caps.value.IsAbsolute = feature->IsAbsolute; - wine_element->caps.value.HasNull = feature->HasNull; - wine_element->caps.value.BitSize = feature->caps.BitSize; - wine_element->caps.value.ReportCount = feature->caps.ReportCount; - wine_element->caps.value.UnitsExp = feature->caps.UnitsExp; - wine_element->caps.value.Units = feature->caps.Units; - wine_element->caps.value.LogicalMin = feature->caps.LogicalMin; - wine_element->caps.value.LogicalMax = feature->caps.LogicalMax; - wine_element->caps.value.PhysicalMin = feature->caps.PhysicalMin; - wine_element->caps.value.PhysicalMax = feature->caps.PhysicalMax; - if (wine_element->caps.value.IsRange) + wine_element->caps.UsagePage = feature->caps.UsagePage; + wine_element->caps.ReportID = feature->caps.ReportID; + wine_element->caps.BitField = feature->BitField; + wine_element->caps.LinkCollection = feature->collection->index; + wine_element->caps.LinkUsage = feature->collection->caps.NotRange.Usage; + wine_element->caps.LinkUsagePage = feature->collection->caps.UsagePage; + wine_element->caps.IsRange = feature->caps.IsRange; + wine_element->caps.IsStringRange = feature->caps.IsStringRange; + wine_element->caps.IsDesignatorRange = feature->caps.IsDesignatorRange; + wine_element->caps.IsAbsolute = feature->IsAbsolute; + wine_element->caps.HasNull = feature->HasNull; + wine_element->caps.BitSize = feature->caps.BitSize; + wine_element->caps.ReportCount = feature->caps.ReportCount; + wine_element->caps.UnitsExp = feature->caps.UnitsExp; + wine_element->caps.Units = feature->caps.Units; + wine_element->caps.LogicalMin = feature->caps.LogicalMin; + wine_element->caps.LogicalMax = feature->caps.LogicalMax; + wine_element->caps.PhysicalMin = feature->caps.PhysicalMin; + wine_element->caps.PhysicalMax = feature->caps.PhysicalMax; + if (wine_element->caps.IsRange) { - 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); + wine_element->caps.Range.UsageMin = feature->caps.Range.UsageMin; + wine_element->caps.Range.UsageMax = feature->caps.Range.UsageMax; + wine_element->caps.Range.StringMin = feature->caps.Range.StringMin; + wine_element->caps.Range.StringMax = feature->caps.Range.StringMax; + wine_element->caps.Range.DesignatorMin = feature->caps.Range.DesignatorMin; + wine_element->caps.Range.DesignatorMax = feature->caps.Range.DesignatorMax; + wine_element->caps.Range.DataIndexMin = *data_index; + wine_element->caps.Range.DataIndexMax = *data_index + + (wine_element->caps.Range.UsageMax - + wine_element->caps.Range.UsageMin); *data_index = *data_index + - (wine_element->caps.value.Range.UsageMax - - wine_element->caps.value.Range.UsageMin) + 1; + (wine_element->caps.Range.UsageMax - + wine_element->caps.Range.UsageMin) + 1; } else { - 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; + wine_element->caps.NotRange.Usage = feature->caps.NotRange.Usage; + wine_element->caps.NotRange.Reserved1 = feature->caps.NotRange.Usage; + wine_element->caps.NotRange.StringIndex = feature->caps.NotRange.StringIndex; + wine_element->caps.NotRange.Reserved2 = feature->caps.NotRange.StringIndex; + wine_element->caps.NotRange.DesignatorIndex = feature->caps.NotRange.DesignatorIndex; + wine_element->caps.NotRange.Reserved3 = feature->caps.NotRange.DesignatorIndex; + wine_element->caps.NotRange.DataIndex = *data_index; + wine_element->caps.NotRange.Reserved4 = *data_index; *data_index = *data_index + 1; } } diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 4f9a63cfb88..e08d11bc20a 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -21,6 +21,8 @@
#include <stdarg.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" #include "winbase.h" #include "wingdi.h" diff --git a/include/wine/hid.h b/include/wine/hid.h index 857dcae18fe..38d84bc96af 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -21,6 +21,14 @@ #ifndef __WINE_PARSE_H #define __WINE_PARSE_H
+#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "hidusage.h" +#include "ddk/hidpi.h" + #define HID_MAGIC 0x8491759
typedef enum __WINE_ELEMENT_TYPE { @@ -34,12 +42,39 @@ typedef struct __WINE_ELEMENT WINE_ELEMENT_TYPE ElementType; UINT valueStartBit; UINT bitCount; - union { - HIDP_VALUE_CAPS value; - HIDP_BUTTON_CAPS button; - } caps; + HIDP_VALUE_CAPS caps; } WINE_HID_ELEMENT;
+/* make sure HIDP_BUTTON_CAPS is a subset of HIDP_VALUE_CAPS */ +C_ASSERT( sizeof(HIDP_BUTTON_CAPS) == sizeof(HIDP_VALUE_CAPS) ); + +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, UsagePage) == offsetof(HIDP_VALUE_CAPS, UsagePage) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, ReportID) == offsetof(HIDP_VALUE_CAPS, ReportID) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, IsAlias) == offsetof(HIDP_VALUE_CAPS, IsAlias) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, BitField) == offsetof(HIDP_VALUE_CAPS, BitField) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, LinkCollection) == offsetof(HIDP_VALUE_CAPS, LinkCollection) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, LinkUsage) == offsetof(HIDP_VALUE_CAPS, LinkUsage) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, LinkUsagePage) == offsetof(HIDP_VALUE_CAPS, LinkUsagePage) ); + +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, IsRange) == offsetof(HIDP_VALUE_CAPS, IsRange) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, IsStringRange) == offsetof(HIDP_VALUE_CAPS, IsStringRange) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, IsDesignatorRange) == offsetof(HIDP_VALUE_CAPS, IsDesignatorRange) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, IsAbsolute) == offsetof(HIDP_VALUE_CAPS, IsAbsolute) ); + +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.UsageMin) == offsetof(HIDP_VALUE_CAPS, Range.UsageMin) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.UsageMax) == offsetof(HIDP_VALUE_CAPS, Range.UsageMax) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.StringMin) == offsetof(HIDP_VALUE_CAPS, Range.StringMin) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.StringMax) == offsetof(HIDP_VALUE_CAPS, Range.StringMax) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.DesignatorMin) == offsetof(HIDP_VALUE_CAPS, Range.DesignatorMin) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.DesignatorMax) == offsetof(HIDP_VALUE_CAPS, Range.DesignatorMax) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.DataIndexMin) == offsetof(HIDP_VALUE_CAPS, Range.DataIndexMin) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, Range.DataIndexMax) == offsetof(HIDP_VALUE_CAPS, Range.DataIndexMax) ); + +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, NotRange.Usage) == offsetof(HIDP_VALUE_CAPS, NotRange.Usage) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, NotRange.StringIndex) == offsetof(HIDP_VALUE_CAPS, NotRange.StringIndex) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, NotRange.DesignatorIndex) == offsetof(HIDP_VALUE_CAPS, NotRange.DesignatorIndex) ); +C_ASSERT( offsetof(HIDP_BUTTON_CAPS, NotRange.DataIndex) == offsetof(HIDP_VALUE_CAPS, NotRange.DataIndex) ); + typedef struct __WINE_HID_REPORT { UCHAR reportID;