From: Rémi Bernon rbernon@codeweavers.com
--- dlls/hidclass.sys/device.c | 105 +++++++++++++++--------------- dlls/hidclass.sys/hid.h | 46 ++++++------- dlls/hidclass.sys/pnp.c | 129 ++++++++++++++++++------------------- 3 files changed, 140 insertions(+), 140 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 8fda73ff8f5..da641aedca9 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -216,10 +216,9 @@ static struct hid_report *hid_queue_pop_report( struct hid_queue *queue ) return report; }
-static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *packet, BOOL polled ) +static void hid_device_queue_input( struct phys_device *pdo, HID_XFER_PACKET *packet, BOOL polled ) { - struct device *ext = device->DeviceExtension; - HIDP_COLLECTION_DESC *desc = ext->u.pdo.collection_desc; + HIDP_COLLECTION_DESC *desc = pdo->collection_desc; ULONG size, report_len = polled ? packet->reportBufferLen : desc->InputLength; struct hid_report *last_report, *report; struct hid_queue *queue; @@ -227,9 +226,9 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack KIRQL irql; IRP *irp;
- TRACE("device %p, packet %p\n", device, packet); + TRACE( "pdo %p, packet %p\n", pdo, packet );
- if (IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID )) + if (IsEqualGUID( pdo->base.class_guid, &GUID_DEVINTERFACE_HID )) { struct hid_packet *hid;
@@ -243,7 +242,7 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack input.hi.wParamH = HIWORD(RIM_INPUT); input.hi.wParamL = LOWORD(RIM_INPUT);
- hid->head.device = ext->u.pdo.rawinput_handle; + hid->head.device = pdo->rawinput_handle; hid->head.usage = MAKELONG(desc->Usage, desc->UsagePage);
hid->head.count = 1; @@ -264,9 +263,9 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack
InitializeListHead( &completed );
- KeAcquireSpinLock( &ext->u.pdo.lock, &irql ); - if (ext->u.pdo.removed) WARN( "Device has been removed, dropping report\n" ); - else LIST_FOR_EACH_ENTRY( queue, &ext->u.pdo.queues, struct hid_queue, entry ) + KeAcquireSpinLock( &pdo->lock, &irql ); + if (pdo->removed) WARN( "Device has been removed, dropping report\n" ); + else LIST_FOR_EACH_ENTRY( queue, &pdo->queues, struct hid_queue, entry ) { if (!polled) hid_queue_push_report( queue, last_report );
@@ -284,7 +283,7 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack } while (polled); } - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeReleaseSpinLock( &pdo->lock, irql );
while ((entry = RemoveHeadList( &completed )) != &completed) { @@ -375,7 +374,7 @@ DWORD CALLBACK hid_device_thread(void *args) ERR( "dropping report for unknown child %u\n", report->CollectionNumber ); else { - DEVICE_OBJECT *pdo = ext->u.fdo.child_pdos[report->CollectionNumber - 1]; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( ext->u.fdo.child_pdos[report->CollectionNumber - 1] ); packet->reportId = buffer[0]; packet->reportBuffer = buffer; packet->reportBufferLen = io.Information; @@ -456,11 +455,11 @@ static NTSTATUS CALLBACK xfer_completion( DEVICE_OBJECT *device, IRP *irp, void return STATUS_SUCCESS; }
-static NTSTATUS hid_device_xfer_report( struct device *ext, ULONG code, IRP *irp ) +static NTSTATUS hid_device_xfer_report( struct phys_device *pdo, ULONG code, IRP *irp ) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); - ULONG offset, report_len = 0, buffer_len = 0, collection = ext->u.pdo.collection_desc->CollectionNumber; - struct device *fdo_ext = ext->u.pdo.parent_fdo->DeviceExtension; + ULONG offset, report_len = 0, buffer_len = 0, collection = pdo->collection_desc->CollectionNumber; + struct device *fdo_ext = pdo->parent_fdo->DeviceExtension; HIDP_DEVICE_DESC *desc = &fdo_ext->u.fdo.device_desc; struct completion_params *params; HIDP_REPORT_IDS *report = NULL; @@ -515,7 +514,7 @@ static NTSTATUS hid_device_xfer_report( struct device *ext, ULONG code, IRP *irp case IOCTL_HID_GET_FEATURE: case IOCTL_HID_GET_INPUT_REPORT: params->packet.reportBufferLen = buffer_len - offset; - irp = IoBuildDeviceIoControlRequest( code, ext->u.pdo.parent_fdo, NULL, 0, ¶ms->packet, + irp = IoBuildDeviceIoControlRequest( code, pdo->parent_fdo, NULL, 0, ¶ms->packet, sizeof(params->packet), TRUE, NULL, NULL ); break; case IOCTL_HID_WRITE_REPORT: @@ -524,7 +523,7 @@ static NTSTATUS hid_device_xfer_report( struct device *ext, ULONG code, IRP *irp case IOCTL_HID_SET_FEATURE: case IOCTL_HID_SET_OUTPUT_REPORT: params->packet.reportBufferLen = report_len - offset; - irp = IoBuildDeviceIoControlRequest( code, ext->u.pdo.parent_fdo, NULL, sizeof(params->packet), + irp = IoBuildDeviceIoControlRequest( code, pdo->parent_fdo, NULL, sizeof(params->packet), ¶ms->packet, 0, TRUE, NULL, NULL ); break; } @@ -537,14 +536,14 @@ static NTSTATUS hid_device_xfer_report( struct device *ext, ULONG code, IRP *irp
IoMarkIrpPending( params->irp ); IoSetCompletionRoutine( irp, xfer_completion, params, TRUE, TRUE, TRUE ); - IoCallDriver( ext->u.pdo.parent_fdo, irp ); + IoCallDriver( pdo->parent_fdo, irp ); return STATUS_PENDING; }
-NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) +NTSTATUS WINAPI pdo_ioctl( DEVICE_OBJECT *device, IRP *irp ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); - struct device *ext = device->DeviceExtension; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); NTSTATUS status = irp->IoStatus.Status; ULONG code, index; const WCHAR *str; @@ -555,9 +554,9 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
TRACE( "device %p code %#lx\n", device, irpsp->Parameters.DeviceIoControl.IoControlCode );
- KeAcquireSpinLock(&ext->u.pdo.lock, &irql); - removed = ext->u.pdo.removed; - KeReleaseSpinLock(&ext->u.pdo.lock, irql); + KeAcquireSpinLock( &pdo->lock, &irql ); + removed = pdo->removed; + KeReleaseSpinLock( &pdo->lock, irql );
if (removed) { @@ -573,6 +572,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) status = STATUS_BUFFER_OVERFLOW; else { + struct device *ext = pdo->parent_fdo->DeviceExtension; *(ULONG *)irp->AssociatedIrp.SystemBuffer = ext->u.fdo.poll_interval; irp->IoStatus.Information = sizeof(ULONG); status = STATUS_SUCCESS; @@ -585,6 +585,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) status = STATUS_BUFFER_TOO_SMALL; else { + struct device *ext = pdo->parent_fdo->DeviceExtension; poll_interval = *(ULONG *)irp->AssociatedIrp.SystemBuffer; if (poll_interval) ext->u.fdo.poll_interval = min( poll_interval, MAX_POLL_INTERVAL_MSEC ); status = STATUS_SUCCESS; @@ -602,7 +603,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) if (code == IOCTL_HID_GET_SERIALNUMBER_STRING) index = HID_STRING_ID_ISERIALNUMBER; if (code == IOCTL_HID_GET_MANUFACTURER_STRING) index = HID_STRING_ID_IMANUFACTURER;
- if ((str = find_device_string( ext->device_id, index ))) + if ((str = find_device_string( pdo->base.device_id, index ))) { irp->IoStatus.Information = (wcslen( str ) + 1) * sizeof(WCHAR); if (irp->IoStatus.Information > output_len) @@ -615,7 +616,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) break; }
- call_minidriver( IOCTL_HID_GET_STRING, ext->u.pdo.parent_fdo, ULongToPtr( index ), + call_minidriver( IOCTL_HID_GET_STRING, pdo->parent_fdo, ULongToPtr( index ), sizeof(index), output_buf, output_len, &irp->IoStatus ); status = irp->IoStatus.Status; break; @@ -627,7 +628,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) status = STATUS_BUFFER_OVERFLOW; else { - memcpy( irp->AssociatedIrp.SystemBuffer, &ext->u.pdo.information, + memcpy( irp->AssociatedIrp.SystemBuffer, &pdo->information, sizeof(HID_COLLECTION_INFORMATION) ); status = STATUS_SUCCESS; } @@ -635,7 +636,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) } case IOCTL_HID_GET_COLLECTION_DESCRIPTOR: { - HIDP_COLLECTION_DESC *desc = ext->u.pdo.collection_desc; + HIDP_COLLECTION_DESC *desc = pdo->collection_desc;
irp->IoStatus.Information = desc->PreparsedDataLength; if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < desc->PreparsedDataLength) @@ -675,7 +676,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) case IOCTL_HID_SET_FEATURE: case IOCTL_HID_GET_INPUT_REPORT: case IOCTL_HID_SET_OUTPUT_REPORT: - status = hid_device_xfer_report( ext, code, irp ); + status = hid_device_xfer_report( pdo, code, irp ); break;
case IOCTL_HID_GET_WINE_RAWINPUT_HANDLE: @@ -683,7 +684,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) status = STATUS_BUFFER_OVERFLOW; else { - *(ULONG *)irp->AssociatedIrp.SystemBuffer = ext->u.pdo.rawinput_handle; + *(ULONG *)irp->AssociatedIrp.SystemBuffer = pdo->rawinput_handle; irp->IoStatus.Information = sizeof(ULONG); status = STATUS_SUCCESS; } @@ -707,19 +708,19 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) return status; }
-NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) +NTSTATUS WINAPI pdo_read( DEVICE_OBJECT *device, IRP *irp ) { struct hid_queue *queue = irp->Tail.Overlay.OriginalFileObject->FsContext; - struct device *ext = device->DeviceExtension; - HIDP_COLLECTION_DESC *desc = ext->u.pdo.collection_desc; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); + HIDP_COLLECTION_DESC *desc = pdo->collection_desc; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); struct hid_report *report; BOOL removed; KIRQL irql;
- KeAcquireSpinLock(&ext->u.pdo.lock, &irql); - removed = ext->u.pdo.removed; - KeReleaseSpinLock(&ext->u.pdo.lock, irql); + KeAcquireSpinLock( &pdo->lock, &irql ); + removed = pdo->removed; + KeReleaseSpinLock( &pdo->lock, irql );
if (removed) { @@ -751,10 +752,10 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp)
}
-NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) +NTSTATUS WINAPI pdo_write( DEVICE_OBJECT *device, IRP *irp ) { - struct device *ext = device->DeviceExtension; - NTSTATUS status = hid_device_xfer_report( ext, IOCTL_HID_WRITE_REPORT, irp ); + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); + NTSTATUS status = hid_device_xfer_report( pdo, IOCTL_HID_WRITE_REPORT, irp ); if (status != STATUS_PENDING) { irp->IoStatus.Status = status; @@ -763,18 +764,18 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) return status; }
-NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp) +NTSTATUS WINAPI pdo_create( DEVICE_OBJECT *device, IRP *irp ) { - struct device *ext = device->DeviceExtension; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); struct hid_queue *queue; BOOL removed; KIRQL irql;
TRACE("Open handle on device %p\n", device);
- KeAcquireSpinLock( &ext->u.pdo.lock, &irql ); - removed = ext->u.pdo.removed; - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeAcquireSpinLock( &pdo->lock, &irql ); + removed = pdo->removed; + KeReleaseSpinLock( &pdo->lock, irql );
if (removed) { @@ -786,9 +787,9 @@ NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp) if (!(queue = hid_queue_create())) irp->IoStatus.Status = STATUS_NO_MEMORY; else { - KeAcquireSpinLock( &ext->u.pdo.lock, &irql ); - list_add_tail( &ext->u.pdo.queues, &queue->entry ); - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeAcquireSpinLock( &pdo->lock, &irql ); + list_add_tail( &pdo->queues, &queue->entry ); + KeReleaseSpinLock( &pdo->lock, irql );
irp->Tail.Overlay.OriginalFileObject->FsContext = queue; irp->IoStatus.Status = STATUS_SUCCESS; @@ -798,18 +799,18 @@ NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp) return STATUS_SUCCESS; }
-NTSTATUS WINAPI pdo_close(DEVICE_OBJECT *device, IRP *irp) +NTSTATUS WINAPI pdo_close( DEVICE_OBJECT *device, IRP *irp ) { struct hid_queue *queue = irp->Tail.Overlay.OriginalFileObject->FsContext; - struct device *ext = device->DeviceExtension; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); BOOL removed; KIRQL irql;
TRACE("Close handle on device %p\n", device);
- KeAcquireSpinLock( &ext->u.pdo.lock, &irql ); - removed = ext->u.pdo.removed; - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeAcquireSpinLock( &pdo->lock, &irql ); + removed = pdo->removed; + KeReleaseSpinLock( &pdo->lock, irql );
if (removed) { @@ -820,9 +821,9 @@ NTSTATUS WINAPI pdo_close(DEVICE_OBJECT *device, IRP *irp)
if (queue) { - KeAcquireSpinLock( &ext->u.pdo.lock, &irql ); + KeAcquireSpinLock( &pdo->lock, &irql ); list_remove( &queue->entry ); - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeReleaseSpinLock( &pdo->lock, irql ); hid_queue_destroy( queue ); }
diff --git a/dlls/hidclass.sys/hid.h b/dlls/hidclass.sys/hid.h index a18ae5f7a92..5acac117224 100644 --- a/dlls/hidclass.sys/hid.h +++ b/dlls/hidclass.sys/hid.h @@ -58,26 +58,6 @@ struct device DEVICE_OBJECT **child_pdos; UINT child_count; } fdo; - - struct - { - DEVICE_OBJECT *parent_fdo; - - HIDP_COLLECTION_DESC *collection_desc; - HID_COLLECTION_INFORMATION information; - - UINT32 rawinput_handle; - UNICODE_STRING link_name; - - KSPIN_LOCK lock; - struct list queues; - BOOL removed; - - BOOL is_mouse; - UNICODE_STRING mouse_link_name; - BOOL is_keyboard; - UNICODE_STRING keyboard_link_name; - } pdo; } u;
/* These are unique to the parent FDO, but stored in the children as well @@ -90,9 +70,31 @@ struct device BOOL is_fdo; };
-static inline struct device *impl_from_DEVICE_OBJECT( DEVICE_OBJECT *device ) +struct phys_device +{ + struct device base; + DEVICE_OBJECT *parent_fdo; + + HIDP_COLLECTION_DESC *collection_desc; + HID_COLLECTION_INFORMATION information; + + UINT32 rawinput_handle; + UNICODE_STRING link_name; + + KSPIN_LOCK lock; + struct list queues; + BOOL removed; + + BOOL is_mouse; + UNICODE_STRING mouse_link_name; + BOOL is_keyboard; + UNICODE_STRING keyboard_link_name; +}; + +static inline struct phys_device *pdo_from_DEVICE_OBJECT( DEVICE_OBJECT *device ) { - return (struct device *)device->DeviceExtension; + struct device *impl = device->DeviceExtension; + return CONTAINING_RECORD( impl, struct phys_device, base ); }
struct hid_report diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index 41228d2628b..f033f45805f 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -111,21 +111,21 @@ static UINT32 alloc_rawinput_handle(void) /* make sure bRawData can hold UsagePage and Usage without requiring additional allocation */ C_ASSERT(offsetof(RAWINPUT, data.hid.bRawData[2 * sizeof(USAGE)]) < sizeof(RAWINPUT));
-static void send_wm_input_device_change(struct device *ext, LPARAM param) +static void send_wm_input_device_change( struct phys_device *pdo, LPARAM param ) { - HIDP_COLLECTION_DESC *desc = ext->u.pdo.collection_desc; + HIDP_COLLECTION_DESC *desc = pdo->collection_desc; INPUT input = {.type = INPUT_HARDWARE}; struct hid_packet hid = {0};
- TRACE("ext %p, lparam %p\n", ext, (void *)param); + TRACE( "pdo %p, lparam %p\n", pdo, (void *)param );
- if (!IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID )) return; + if (!IsEqualGUID( pdo->base.class_guid, &GUID_DEVINTERFACE_HID )) return;
input.hi.uMsg = WM_INPUT_DEVICE_CHANGE; input.hi.wParamH = HIWORD(param); input.hi.wParamL = LOWORD(param);
- hid.head.device = ext->u.pdo.rawinput_handle; + hid.head.device = pdo->rawinput_handle; hid.head.usage = MAKELONG(desc->Usage, desc->UsagePage); NtUserSendHardwareInput(0, 0, &input, (LPARAM)&hid); } @@ -257,8 +257,9 @@ static NTSTATUS initialize_device( minidriver *minidriver, DEVICE_OBJECT *device
static NTSTATUS create_child_pdos( minidriver *minidriver, DEVICE_OBJECT *device ) { - struct device *fdo_ext = device->DeviceExtension, *pdo_ext; - DEVICE_OBJECT *child_pdo; + struct device *fdo_ext = device->DeviceExtension; + DEVICE_OBJECT *child_device; + struct phys_device *pdo; UNICODE_STRING string; WCHAR pdo_name[255]; USAGE page, usage; @@ -275,54 +276,54 @@ static NTSTATUS create_child_pdos( minidriver *minidriver, DEVICE_OBJECT *device fdo_ext->hid.PhysicalDeviceObject );
RtlInitUnicodeString(&string, pdo_name); - if ((status = IoCreateDevice( device->DriverObject, sizeof(*pdo_ext), &string, 0, 0, FALSE, &child_pdo ))) + if ((status = IoCreateDevice( device->DriverObject, sizeof(*pdo), &string, 0, 0, FALSE, &child_device ))) { ERR( "Failed to create child PDO, status %#lx.\n", status ); return status; }
- fdo_ext->u.fdo.child_pdos[i] = child_pdo; + fdo_ext->u.fdo.child_pdos[i] = child_device; fdo_ext->u.fdo.child_count++;
- pdo_ext = child_pdo->DeviceExtension; - pdo_ext->hid = fdo_ext->hid; - pdo_ext->u.pdo.parent_fdo = device; - list_init( &pdo_ext->u.pdo.queues ); - KeInitializeSpinLock( &pdo_ext->u.pdo.lock ); + pdo = pdo_from_DEVICE_OBJECT( child_device ); + pdo->base.hid = fdo_ext->hid; + pdo->parent_fdo = device; + list_init( &pdo->queues ); + KeInitializeSpinLock( &pdo->lock );
- pdo_ext->u.pdo.collection_desc = fdo_ext->u.fdo.device_desc.CollectionDesc + i; + pdo->collection_desc = fdo_ext->u.fdo.device_desc.CollectionDesc + i;
if (fdo_ext->u.fdo.device_desc.CollectionDescLength > 1) { - swprintf( pdo_ext->device_id, ARRAY_SIZE(pdo_ext->device_id), L"%s&Col%02d", - fdo_ext->device_id, pdo_ext->u.pdo.collection_desc->CollectionNumber ); - swprintf( pdo_ext->instance_id, ARRAY_SIZE(pdo_ext->instance_id), L"%u&%s&%x&%u&%04u", + swprintf( pdo->base.device_id, ARRAY_SIZE(pdo->base.device_id), L"%s&Col%02d", + fdo_ext->device_id, pdo->collection_desc->CollectionNumber ); + swprintf( pdo->base.instance_id, ARRAY_SIZE(pdo->base.instance_id), L"%u&%s&%x&%u&%04u", fdo_ext->u.fdo.attrs.VersionNumber, fdo_ext->u.fdo.serial, 0, 0, i ); } else { - wcscpy( pdo_ext->device_id, fdo_ext->device_id ); - wcscpy( pdo_ext->instance_id, fdo_ext->instance_id ); + wcscpy( pdo->base.device_id, fdo_ext->device_id ); + wcscpy( pdo->base.instance_id, fdo_ext->instance_id ); } - wcscpy(pdo_ext->container_id, fdo_ext->container_id); - pdo_ext->class_guid = fdo_ext->class_guid; + wcscpy( pdo->base.container_id, fdo_ext->container_id ); + pdo->base.class_guid = fdo_ext->class_guid;
- pdo_ext->u.pdo.information.VendorID = fdo_ext->u.fdo.attrs.VendorID; - pdo_ext->u.pdo.information.ProductID = fdo_ext->u.fdo.attrs.ProductID; - pdo_ext->u.pdo.information.VersionNumber = fdo_ext->u.fdo.attrs.VersionNumber; - pdo_ext->u.pdo.information.Polled = minidriver->minidriver.DevicesArePolled; - pdo_ext->u.pdo.information.DescriptorSize = pdo_ext->u.pdo.collection_desc->PreparsedDataLength; + pdo->information.VendorID = fdo_ext->u.fdo.attrs.VendorID; + pdo->information.ProductID = fdo_ext->u.fdo.attrs.ProductID; + pdo->information.VersionNumber = fdo_ext->u.fdo.attrs.VersionNumber; + pdo->information.Polled = minidriver->minidriver.DevicesArePolled; + pdo->information.DescriptorSize = pdo->collection_desc->PreparsedDataLength;
- page = pdo_ext->u.pdo.collection_desc->UsagePage; - usage = pdo_ext->u.pdo.collection_desc->Usage; + page = pdo->collection_desc->UsagePage; + usage = pdo->collection_desc->Usage; if (page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_MOUSE) - pdo_ext->u.pdo.rawinput_handle = WINE_MOUSE_HANDLE; + pdo->rawinput_handle = WINE_MOUSE_HANDLE; else if (page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_KEYBOARD) - pdo_ext->u.pdo.rawinput_handle = WINE_KEYBOARD_HANDLE; + pdo->rawinput_handle = WINE_KEYBOARD_HANDLE; else - pdo_ext->u.pdo.rawinput_handle = alloc_rawinput_handle(); + pdo->rawinput_handle = alloc_rawinput_handle();
- TRACE( "created device %p, rawinput handle %#x\n", pdo_ext, pdo_ext->u.pdo.rawinput_handle ); + TRACE( "created pdo %p, rawinput handle %#x\n", pdo, pdo->rawinput_handle ); }
IoInvalidateDeviceRelations( fdo_ext->hid.PhysicalDeviceObject, BusRelations ); @@ -405,9 +406,9 @@ static WCHAR *query_hardware_ids(DEVICE_OBJECT *device) static const WCHAR usage_format[] = L"HID_DEVICE_UP:%04X_U:%04X"; static const WCHAR hid_format[] = L"HID_DEVICE";
- struct device *ext = device->DeviceExtension; - HIDP_COLLECTION_DESC *desc = ext->u.pdo.collection_desc; - HID_COLLECTION_INFORMATION *info = &ext->u.pdo.information; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); + HIDP_COLLECTION_DESC *desc = pdo->collection_desc; + HID_COLLECTION_INFORMATION *info = &pdo->information; WCHAR *dst; DWORD size;
@@ -472,11 +473,11 @@ static WCHAR *query_container_id(DEVICE_OBJECT *device) return dst; }
-static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) +static NTSTATUS pdo_pnp( DEVICE_OBJECT *device, IRP *irp ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); - struct device *ext = device->DeviceExtension; - HIDP_COLLECTION_DESC *desc = ext->u.pdo.collection_desc; + struct phys_device *pdo = pdo_from_DEVICE_OBJECT( device ); + HIDP_COLLECTION_DESC *desc = pdo->collection_desc; NTSTATUS status = irp->IoStatus.Status; struct hid_queue *queue, *next; KIRQL irql; @@ -511,7 +512,7 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) else status = STATUS_SUCCESS; break; case BusQueryContainerID: - if (ext->container_id[0]) + if (pdo->base.container_id[0]) { irp->IoStatus.Information = (ULONG_PTR)query_container_id(device); if (!irp->IoStatus.Information) status = STATUS_NO_MEMORY; @@ -535,9 +536,9 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) }
case IRP_MN_START_DEVICE: - send_wm_input_device_change(ext, GIDC_ARRIVAL); + send_wm_input_device_change( pdo, GIDC_ARRIVAL );
- if ((status = IoRegisterDeviceInterface(device, ext->class_guid, NULL, &ext->u.pdo.link_name))) + if ((status = IoRegisterDeviceInterface( device, pdo->base.class_guid, NULL, &pdo->link_name ))) { ERR( "Failed to register interface, status %#lx.\n", status ); break; @@ -546,40 +547,36 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) /* FIXME: This should probably be done in mouhid.sys. */ if (desc->UsagePage == HID_USAGE_PAGE_GENERIC && desc->Usage == HID_USAGE_GENERIC_MOUSE) { - if (!IoRegisterDeviceInterface(device, &GUID_DEVINTERFACE_MOUSE, NULL, &ext->u.pdo.mouse_link_name)) - ext->u.pdo.is_mouse = TRUE; + if (!IoRegisterDeviceInterface( device, &GUID_DEVINTERFACE_MOUSE, NULL, &pdo->mouse_link_name )) + pdo->is_mouse = TRUE; } if (desc->UsagePage == HID_USAGE_PAGE_GENERIC && desc->Usage == HID_USAGE_GENERIC_KEYBOARD) { - if (!IoRegisterDeviceInterface(device, &GUID_DEVINTERFACE_KEYBOARD, NULL, &ext->u.pdo.keyboard_link_name)) - ext->u.pdo.is_keyboard = TRUE; + if (!IoRegisterDeviceInterface( device, &GUID_DEVINTERFACE_KEYBOARD, NULL, &pdo->keyboard_link_name )) + pdo->is_keyboard = TRUE; }
- IoSetDeviceInterfaceState(&ext->u.pdo.link_name, TRUE); - if (ext->u.pdo.is_mouse) - IoSetDeviceInterfaceState(&ext->u.pdo.mouse_link_name, TRUE); - if (ext->u.pdo.is_keyboard) - IoSetDeviceInterfaceState(&ext->u.pdo.keyboard_link_name, TRUE); + IoSetDeviceInterfaceState( &pdo->link_name, TRUE ); + if (pdo->is_mouse) IoSetDeviceInterfaceState( &pdo->mouse_link_name, TRUE ); + if (pdo->is_keyboard) IoSetDeviceInterfaceState( &pdo->keyboard_link_name, TRUE );
- ext->u.pdo.removed = FALSE; + pdo->removed = FALSE; status = STATUS_SUCCESS; break;
case IRP_MN_REMOVE_DEVICE: - send_wm_input_device_change(ext, GIDC_REMOVAL); + send_wm_input_device_change( pdo, GIDC_REMOVAL );
- IoSetDeviceInterfaceState(&ext->u.pdo.link_name, FALSE); - if (ext->u.pdo.is_mouse) - IoSetDeviceInterfaceState(&ext->u.pdo.mouse_link_name, FALSE); - if (ext->u.pdo.is_keyboard) - IoSetDeviceInterfaceState(&ext->u.pdo.keyboard_link_name, FALSE); + IoSetDeviceInterfaceState( &pdo->link_name, FALSE ); + if (pdo->is_mouse) IoSetDeviceInterfaceState( &pdo->mouse_link_name, FALSE ); + if (pdo->is_keyboard) IoSetDeviceInterfaceState( &pdo->keyboard_link_name, FALSE );
- KeAcquireSpinLock( &ext->u.pdo.lock, &irql ); - LIST_FOR_EACH_ENTRY_SAFE( queue, next, &ext->u.pdo.queues, struct hid_queue, entry ) + KeAcquireSpinLock( &pdo->lock, &irql ); + LIST_FOR_EACH_ENTRY_SAFE( queue, next, &pdo->queues, struct hid_queue, entry ) hid_queue_destroy( queue ); - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeReleaseSpinLock( &pdo->lock, irql );
- RtlFreeUnicodeString(&ext->u.pdo.link_name); + RtlFreeUnicodeString( &pdo->link_name );
irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(irp, IO_NO_INCREMENT); @@ -587,11 +584,11 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) return STATUS_SUCCESS;
case IRP_MN_SURPRISE_REMOVAL: - KeAcquireSpinLock(&ext->u.pdo.lock, &irql); - ext->u.pdo.removed = TRUE; - LIST_FOR_EACH_ENTRY_SAFE( queue, next, &ext->u.pdo.queues, struct hid_queue, entry ) + KeAcquireSpinLock( &pdo->lock, &irql ); + pdo->removed = TRUE; + LIST_FOR_EACH_ENTRY_SAFE( queue, next, &pdo->queues, struct hid_queue, entry ) hid_queue_remove_pending_irps( queue ); - KeReleaseSpinLock( &ext->u.pdo.lock, irql ); + KeReleaseSpinLock( &pdo->lock, irql );
status = STATUS_SUCCESS; break;