winebus.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-08-12 09:47:02 +02:00 committed by Alexandre Julliard
parent a446e0e57d
commit 8f37267f92
4 changed files with 32 additions and 41 deletions

View File

@ -79,8 +79,6 @@
#undef PAGE_SHIFT #undef PAGE_SHIFT
#endif /* HAVE_IOKIT_HID_IOHIDLIB_H */ #endif /* HAVE_IOKIT_HID_IOHIDLIB_H */
#define NONAMELESSUNION
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"

View File

@ -31,8 +31,6 @@
# include <SDL.h> # include <SDL.h>
#endif #endif
#define NONAMELESSUNION
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"

View File

@ -54,8 +54,6 @@
# endif # endif
#endif #endif
#define NONAMELESSUNION
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"

View File

@ -20,9 +20,6 @@
#include "config.h" #include "config.h"
#include <stdarg.h> #include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include "winternl.h" #include "winternl.h"
@ -242,8 +239,8 @@ static void remove_pending_irps(DEVICE_OBJECT *device)
while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue)
{ {
IRP *queued_irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry); IRP *queued_irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
queued_irp->IoStatus.u.Status = STATUS_DELETE_PENDING; queued_irp->IoStatus.Status = STATUS_DELETE_PENDING;
queued_irp->IoStatus.Information = 0; queued_irp->IoStatus.Information = 0;
IoCompleteRequest(queued_irp, IO_NO_INCREMENT); IoCompleteRequest(queued_irp, IO_NO_INCREMENT);
} }
@ -420,7 +417,7 @@ static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices)
static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp) static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp)
{ {
NTSTATUS status = irp->IoStatus.u.Status; NTSTATUS status = irp->IoStatus.Status;
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
TRACE("IRP_MN_QUERY_DEVICE_RELATIONS\n"); TRACE("IRP_MN_QUERY_DEVICE_RELATIONS\n");
@ -445,7 +442,7 @@ static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp)
static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp) static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp)
{ {
NTSTATUS status = irp->IoStatus.u.Status; NTSTATUS status = irp->IoStatus.Status;
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
BUS_QUERY_ID_TYPE type = irpsp->Parameters.QueryId.IdType; BUS_QUERY_ID_TYPE type = irpsp->Parameters.QueryId.IdType;
@ -637,7 +634,7 @@ static NTSTATUS fdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
switch (irpsp->MinorFunction) switch (irpsp->MinorFunction)
{ {
case IRP_MN_QUERY_DEVICE_RELATIONS: case IRP_MN_QUERY_DEVICE_RELATIONS:
irp->IoStatus.u.Status = handle_IRP_MN_QUERY_DEVICE_RELATIONS(irp); irp->IoStatus.Status = handle_IRP_MN_QUERY_DEVICE_RELATIONS(irp);
break; break;
case IRP_MN_START_DEVICE: case IRP_MN_START_DEVICE:
mouse_device_create(); mouse_device_create();
@ -647,23 +644,23 @@ static NTSTATUS fdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
{ {
if (sdl_driver_init() == STATUS_SUCCESS) if (sdl_driver_init() == STATUS_SUCCESS)
{ {
irp->IoStatus.u.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
break; break;
} }
} }
udev_driver_init(); udev_driver_init();
iohid_driver_init(); iohid_driver_init();
irp->IoStatus.u.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
break; break;
case IRP_MN_SURPRISE_REMOVAL: case IRP_MN_SURPRISE_REMOVAL:
irp->IoStatus.u.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
break; break;
case IRP_MN_REMOVE_DEVICE: case IRP_MN_REMOVE_DEVICE:
udev_driver_unload(); udev_driver_unload();
iohid_driver_unload(); iohid_driver_unload();
sdl_driver_unload(); sdl_driver_unload();
irp->IoStatus.u.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
IoSkipCurrentIrpStackLocation(irp); IoSkipCurrentIrpStackLocation(irp);
ret = IoCallDriver(bus_pdo, irp); ret = IoCallDriver(bus_pdo, irp);
IoDetachDevice(bus_pdo); IoDetachDevice(bus_pdo);
@ -680,7 +677,7 @@ static NTSTATUS fdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
{ {
struct device_extension *ext = device->DeviceExtension; struct device_extension *ext = device->DeviceExtension;
NTSTATUS status = irp->IoStatus.u.Status; NTSTATUS status = irp->IoStatus.Status;
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
TRACE("device %p, irp %p, minor function %#x.\n", device, irp, irpsp->MinorFunction); TRACE("device %p, irp %p, minor function %#x.\n", device, irp, irpsp->MinorFunction);
@ -721,7 +718,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
HeapFree(GetProcessHeap(), 0, ext->serial); HeapFree(GetProcessHeap(), 0, ext->serial);
HeapFree(GetProcessHeap(), 0, ext->last_report); HeapFree(GetProcessHeap(), 0, ext->last_report);
irp->IoStatus.u.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
IoDeleteDevice(device); IoDeleteDevice(device);
@ -740,7 +737,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
break; break;
} }
irp->IoStatus.u.Status = status; irp->IoStatus.Status = status;
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
return status; return status;
} }
@ -819,7 +816,7 @@ static NTSTATUS hid_get_native_string(DEVICE_OBJECT *device, DWORD index, WCHAR
static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
{ {
NTSTATUS status = irp->IoStatus.u.Status; NTSTATUS status = irp->IoStatus.Status;
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
struct device_extension *ext = (struct device_extension *)device->DeviceExtension; struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
ULONG code, buffer_len = irpsp->Parameters.DeviceIoControl.OutputBufferLength; ULONG code, buffer_len = irpsp->Parameters.DeviceIoControl.OutputBufferLength;
@ -837,7 +834,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
if (ext->removed) if (ext->removed)
{ {
LeaveCriticalSection(&ext->cs); LeaveCriticalSection(&ext->cs);
irp->IoStatus.u.Status = STATUS_DELETE_PENDING; irp->IoStatus.Status = STATUS_DELETE_PENDING;
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_DELETE_PENDING; return STATUS_DELETE_PENDING;
} }
@ -851,7 +848,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
if (buffer_len < sizeof(*attr)) if (buffer_len < sizeof(*attr))
{ {
irp->IoStatus.u.Status = status = STATUS_BUFFER_TOO_SMALL; irp->IoStatus.Status = status = STATUS_BUFFER_TOO_SMALL;
break; break;
} }
@ -861,7 +858,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
attr->ProductID = ext->pid; attr->ProductID = ext->pid;
attr->VersionNumber = ext->version; attr->VersionNumber = ext->version;
irp->IoStatus.u.Status = status = STATUS_SUCCESS; irp->IoStatus.Status = status = STATUS_SUCCESS;
irp->IoStatus.Information = sizeof(*attr); irp->IoStatus.Information = sizeof(*attr);
break; break;
} }
@ -873,7 +870,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
if (buffer_len < sizeof(*descriptor)) if (buffer_len < sizeof(*descriptor))
{ {
irp->IoStatus.u.Status = status = STATUS_BUFFER_TOO_SMALL; irp->IoStatus.Status = status = STATUS_BUFFER_TOO_SMALL;
break; break;
} }
@ -881,7 +878,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
if (status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL) if (status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
{ {
WARN("Failed to get platform report descriptor length\n"); WARN("Failed to get platform report descriptor length\n");
irp->IoStatus.u.Status = status; irp->IoStatus.Status = status;
break; break;
} }
@ -894,13 +891,13 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
descriptor->DescriptorList[0].bReportType = HID_REPORT_DESCRIPTOR_TYPE; descriptor->DescriptorList[0].bReportType = HID_REPORT_DESCRIPTOR_TYPE;
descriptor->DescriptorList[0].wReportLength = length; descriptor->DescriptorList[0].wReportLength = length;
irp->IoStatus.u.Status = status = STATUS_SUCCESS; irp->IoStatus.Status = status = STATUS_SUCCESS;
irp->IoStatus.Information = sizeof(*descriptor); irp->IoStatus.Information = sizeof(*descriptor);
break; break;
} }
case IOCTL_HID_GET_REPORT_DESCRIPTOR: case IOCTL_HID_GET_REPORT_DESCRIPTOR:
TRACE("IOCTL_HID_GET_REPORT_DESCRIPTOR\n"); TRACE("IOCTL_HID_GET_REPORT_DESCRIPTOR\n");
irp->IoStatus.u.Status = status = ext->vtbl->get_reportdescriptor(device, irp->UserBuffer, buffer_len, &buffer_len); irp->IoStatus.Status = status = ext->vtbl->get_reportdescriptor(device, irp->UserBuffer, buffer_len, &buffer_len);
irp->IoStatus.Information = buffer_len; irp->IoStatus.Information = buffer_len;
break; break;
case IOCTL_HID_GET_STRING: case IOCTL_HID_GET_STRING:
@ -908,9 +905,9 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
DWORD index = (ULONG_PTR)irpsp->Parameters.DeviceIoControl.Type3InputBuffer; DWORD index = (ULONG_PTR)irpsp->Parameters.DeviceIoControl.Type3InputBuffer;
TRACE("IOCTL_HID_GET_STRING[%08x]\n", index); TRACE("IOCTL_HID_GET_STRING[%08x]\n", index);
irp->IoStatus.u.Status = status = hid_get_native_string(device, index, (WCHAR *)irp->UserBuffer, buffer_len / sizeof(WCHAR)); irp->IoStatus.Status = status = hid_get_native_string(device, index, (WCHAR *)irp->UserBuffer, buffer_len / sizeof(WCHAR));
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
irp->IoStatus.u.Status = status = ext->vtbl->get_string(device, index, (WCHAR *)irp->UserBuffer, buffer_len / sizeof(WCHAR)); irp->IoStatus.Status = status = ext->vtbl->get_string(device, index, (WCHAR *)irp->UserBuffer, buffer_len / sizeof(WCHAR));
if (status == STATUS_SUCCESS) if (status == STATUS_SUCCESS)
irp->IoStatus.Information = (strlenW((WCHAR *)irp->UserBuffer) + 1) * sizeof(WCHAR); irp->IoStatus.Information = (strlenW((WCHAR *)irp->UserBuffer) + 1) * sizeof(WCHAR);
break; break;
@ -922,11 +919,11 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
status = ext->vtbl->begin_report_processing(device); status = ext->vtbl->begin_report_processing(device);
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
{ {
irp->IoStatus.u.Status = status; irp->IoStatus.Status = status;
break; break;
} }
irp->IoStatus.u.Status = status = deliver_last_report(ext, irp->IoStatus.Status = status = deliver_last_report(ext,
packet->reportBufferLen, packet->reportBuffer, packet->reportBufferLen, packet->reportBuffer,
&irp->IoStatus.Information); &irp->IoStatus.Information);
@ -940,18 +937,18 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
status = ext->vtbl->begin_report_processing(device); status = ext->vtbl->begin_report_processing(device);
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
{ {
irp->IoStatus.u.Status = status; irp->IoStatus.Status = status;
break; break;
} }
if (!ext->last_report_read) if (!ext->last_report_read)
{ {
irp->IoStatus.u.Status = status = deliver_last_report(ext, irp->IoStatus.Status = status = deliver_last_report(ext,
buffer_len, irp->UserBuffer, &irp->IoStatus.Information); buffer_len, irp->UserBuffer, &irp->IoStatus.Information);
ext->last_report_read = TRUE; ext->last_report_read = TRUE;
} }
else else
{ {
InsertTailList(&ext->irp_queue, &irp->Tail.Overlay.s.ListEntry); InsertTailList(&ext->irp_queue, &irp->Tail.Overlay.ListEntry);
status = STATUS_PENDING; status = STATUS_PENDING;
} }
break; break;
@ -961,7 +958,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
{ {
HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer);
TRACE_(hid_report)("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n"); TRACE_(hid_report)("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n");
irp->IoStatus.u.Status = status = ext->vtbl->set_output_report( irp->IoStatus.Status = status = ext->vtbl->set_output_report(
device, packet->reportId, packet->reportBuffer, device, packet->reportId, packet->reportBuffer,
packet->reportBufferLen, &irp->IoStatus.Information); packet->reportBufferLen, &irp->IoStatus.Information);
break; break;
@ -970,7 +967,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
{ {
HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer);
TRACE_(hid_report)("IOCTL_HID_GET_FEATURE\n"); TRACE_(hid_report)("IOCTL_HID_GET_FEATURE\n");
irp->IoStatus.u.Status = status = ext->vtbl->get_feature_report( irp->IoStatus.Status = status = ext->vtbl->get_feature_report(
device, packet->reportId, packet->reportBuffer, device, packet->reportId, packet->reportBuffer,
packet->reportBufferLen, &irp->IoStatus.Information); packet->reportBufferLen, &irp->IoStatus.Information);
packet->reportBufferLen = irp->IoStatus.Information; packet->reportBufferLen = irp->IoStatus.Information;
@ -980,7 +977,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
{ {
HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer);
TRACE_(hid_report)("IOCTL_HID_SET_FEATURE\n"); TRACE_(hid_report)("IOCTL_HID_SET_FEATURE\n");
irp->IoStatus.u.Status = status = ext->vtbl->set_feature_report( irp->IoStatus.Status = status = ext->vtbl->set_feature_report(
device, packet->reportId, packet->reportBuffer, device, packet->reportId, packet->reportBuffer,
packet->reportBufferLen, &irp->IoStatus.Information); packet->reportBufferLen, &irp->IoStatus.Information);
break; break;
@ -1034,9 +1031,9 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
{ {
IO_STACK_LOCATION *irpsp; IO_STACK_LOCATION *irpsp;
TRACE_(hid_report)("Processing Request\n"); TRACE_(hid_report)("Processing Request\n");
irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry); irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
irpsp = IoGetCurrentIrpStackLocation(irp); irpsp = IoGetCurrentIrpStackLocation(irp);
irp->IoStatus.u.Status = deliver_last_report(ext, irp->IoStatus.Status = deliver_last_report(ext,
irpsp->Parameters.DeviceIoControl.OutputBufferLength, irpsp->Parameters.DeviceIoControl.OutputBufferLength,
irp->UserBuffer, &irp->IoStatus.Information); irp->UserBuffer, &irp->IoStatus.Information);
ext->last_report_read = TRUE; ext->last_report_read = TRUE;