From: Aric Stewart Subject: [PATCH v2 8/8] wineplugplay.sys: Implement IRP_MN_QUERY_DEVICE_RELATIONS Message-Id: Date: Mon, 22 Aug 2016 09:20:14 -0500 Signed-off-by: Aric Stewart --- dlls/wineplugplay.sys/bus_hid_common.c | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/dlls/wineplugplay.sys/bus_hid_common.c b/dlls/wineplugplay.sys/bus_hid_common.c index 3bd4d28..d0417cd 100644 --- a/dlls/wineplugplay.sys/bus_hid_common.c +++ b/dlls/wineplugplay.sys/bus_hid_common.c @@ -185,6 +185,59 @@ void HID_PNP_RemoveDevice(void* device) } } +static NTSTATUS enumerate_devices(DEVICE_RELATIONS **devices) +{ + int i; + pnp_device *ptr; + + *devices = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVICE_RELATIONS) + + list_count(&pnp_devset) * sizeof (void *)); + + if (!*devices) + { + return STATUS_INSUFFICIENT_RESOURCES; + } + + i = 0; + LIST_FOR_EACH_ENTRY(ptr, &pnp_devset, pnp_device, entry) + { + (*devices)->Objects[i] = (DEVICE_OBJECT*)ptr->device; + i++; + } + (*devices)->Count = i; + return STATUS_SUCCESS; +} + +static NTSTATUS Handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp) +{ + NTSTATUS rc = STATUS_SUCCESS; + IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); + + TRACE("IRP_MN_QUERY_DEVICE_RELATIONS"); + switch (irpsp->Parameters.QueryDeviceRelations.Type) + { + case EjectionRelations: + case RemovalRelations: + case TargetDeviceRelation: + case PowerRelations: + FIXME("Unhandled Device Relation %x\n",irpsp->Parameters.QueryDeviceRelations.Type); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + rc = STATUS_NOT_SUPPORTED; + break; + case BusRelations: + rc = enumerate_devices((DEVICE_RELATIONS**)&irp->IoStatus.Information); + irp->IoStatus.u.Status = rc; + break; + default: + FIXME("Unknown Device Relation %x\n",irpsp->Parameters.QueryDeviceRelations.Type); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + rc = STATUS_NOT_SUPPORTED; + break; + } + + return rc; +} + static NTSTATUS Handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp) { NTSTATUS rc = STATUS_NOT_SUPPORTED; @@ -242,6 +295,8 @@ NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp) { case IRP_MN_QUERY_DEVICE_RELATIONS: TRACE("IRP_MN_QUERY_DEVICE_RELATIONS\n"); + rc = Handle_IRP_MN_QUERY_DEVICE_RELATIONS(irp); + irp->IoStatus.u.Status = rc; break; case IRP_MN_QUERY_ID: {