From: Claire Girka claire@sitedethib.com
--- dlls/winebus.sys/Makefile.in | 2 +- dlls/winebus.sys/main.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/dlls/winebus.sys/Makefile.in b/dlls/winebus.sys/Makefile.in index da02ae06870..9677d3b908e 100644 --- a/dlls/winebus.sys/Makefile.in +++ b/dlls/winebus.sys/Makefile.in @@ -1,6 +1,6 @@ MODULE = winebus.sys UNIXLIB = winebus.so -IMPORTS = ntoskrnl hidparse +IMPORTS = ntoskrnl hidparse ole32 UNIX_LIBS = $(IOKIT_LIBS) $(UDEV_LIBS) $(PTHREAD_LIBS) $(INOTIFY_LIBS) UNIX_CFLAGS = $(UDEV_CFLAGS) $(SDL2_CFLAGS)
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 1037295c955..c3a97413d01 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -37,6 +37,7 @@ #include "wine/debug.h" #include "wine/list.h" #include "wine/unixlib.h" +#include "ole2.h"
#include "unixlib.h"
@@ -197,6 +198,36 @@ static WCHAR *get_instance_id(DEVICE_OBJECT *device) return dst; }
+static WCHAR *get_container_id(DEVICE_OBJECT *device) +{ + struct device_extension *ext = (struct device_extension *)device->DeviceExtension; + UINT len = (38+1)*sizeof(WCHAR); + WCHAR *dst; + GUID guid; + const char *p; + + if (!ext->desc.container_syspath[0]) + return NULL; + + memset(&guid, 0, sizeof(GUID)); + guid.Data1 = (ext->desc.vid << 16) | ext->desc.pid; + + /* Get just the USB bus-devpath part */ + p = strrchr(ext->desc.container_syspath, '/'); + if (!p || (p - ext->desc.container_syspath) <= 12) + return NULL; + + for (int i = 0; p[i]; i++) { + ((char *) &guid)[4 + i % 12] ^= p[i]; + } + + if (!(dst = ExAllocatePool(PagedPool, len))) + return NULL; + + StringFromGUID2(&guid, dst, len); + return dst; +} + static WCHAR *get_device_id(DEVICE_OBJECT *device) { static const WCHAR input_format[] = L"&MI_%02u"; @@ -507,6 +538,10 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp) TRACE("BusQueryInstanceID\n"); irp->IoStatus.Information = (ULONG_PTR)get_instance_id(device); break; + case BusQueryContainerID: + TRACE("BusQueryContainerID\n"); + irp->IoStatus.Information = (ULONG_PTR)get_container_id(device); + break; default: FIXME("Unhandled type %08x\n", type); return status;