From ea95a47bb54741215811c535d7a46102422be041 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Thu, 6 Oct 2016 07:19:27 -0500 Subject: [PATCH] winebus.sys: Implement IOCTL_HID_GET_DEVICE_ATTRIBUTES for hid devices. Signed-off-by: Aric Stewart Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- dlls/winebus.sys/bus.h | 1 + dlls/winebus.sys/bus_udev.c | 1 + dlls/winebus.sys/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 099558b5ff2..342a66b8fa6 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -34,3 +34,4 @@ DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, const GUID *class, const platform_vtbl *vtbl, DWORD platform_data_size) DECLSPEC_HIDDEN; DEVICE_OBJECT *bus_find_hid_device(const platform_vtbl *vtbl, void *platform_dev) DECLSPEC_HIDDEN; void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; +NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 93e56f35555..a01d88e2529 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -299,6 +299,7 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry udev_driver_obj = driver; driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch; + driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch; if (!(events[0] = CreateEventW(NULL, TRUE, FALSE, NULL))) goto error; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 09a59d61b0d..eaa0b937fe2 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -30,7 +30,9 @@ #include "winternl.h" #include "winreg.h" #include "setupapi.h" +#include "winioctl.h" #include "ddk/wdm.h" +#include "ddk/hidport.h" #include "wine/debug.h" #include "wine/unicode.h" #include "wine/list.h" @@ -346,6 +348,50 @@ NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) return status; } +NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) +{ + NTSTATUS status = irp->IoStatus.u.Status; + IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); + struct device_extension *extension = (struct device_extension *)device->DeviceExtension; + + TRACE("(%p, %p)\n", device, irp); + + switch (irpsp->Parameters.DeviceIoControl.IoControlCode) + { + case IOCTL_HID_GET_DEVICE_ATTRIBUTES: + { + HID_DEVICE_ATTRIBUTES *attr = (HID_DEVICE_ATTRIBUTES *)irp->UserBuffer; + TRACE("IOCTL_HID_GET_DEVICE_ATTRIBUTES\n"); + + if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(*attr)) + { + irp->IoStatus.u.Status = status = STATUS_BUFFER_TOO_SMALL; + break; + } + + memset(attr, 0, sizeof(*attr)); + attr->Size = sizeof(HID_DEVICE_ATTRIBUTES); + attr->VendorID = extension->vid; + attr->ProductID = extension->pid; + attr->VersionNumber = extension->version; + irp->IoStatus.u.Status = status = STATUS_SUCCESS; + irp->IoStatus.Information = sizeof(HID_DEVICE_ATTRIBUTES); + break; + } + default: + { + 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); + break; + } + } + + IoCompleteRequest(irp, IO_NO_INCREMENT); + + return status; +} + NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) { static const WCHAR udevW[] = {'\\','D','r','i','v','e','r','\\','U','D','E','V',0}; -- 2.11.4.GIT