|
37 | 37 | #include "wine/debug.h" |
38 | 38 | #include "wine/list.h" |
39 | 39 | #include "wine/unixlib.h" |
| 40 | +#include "ole2.h" |
40 | 41 |
|
41 | 42 | #include "unixlib.h" |
42 | 43 |
|
@@ -198,6 +199,36 @@ static WCHAR *get_instance_id(DEVICE_OBJECT *device) |
198 | 199 | return dst; |
199 | 200 | } |
200 | 201 |
|
| 202 | +static WCHAR *get_container_id(DEVICE_OBJECT *device) |
| 203 | +{ |
| 204 | + struct device_extension *ext = (struct device_extension *)device->DeviceExtension; |
| 205 | + UINT len = (38+1)*sizeof(WCHAR); |
| 206 | + WCHAR *dst; |
| 207 | + GUID guid; |
| 208 | + const char *p; |
| 209 | + |
| 210 | + if (!ext->desc.container_syspath[0]) |
| 211 | + return NULL; |
| 212 | + |
| 213 | + memset(&guid, 0, sizeof(GUID)); |
| 214 | + guid.Data1 = (ext->desc.vid << 16) | ext->desc.pid; |
| 215 | + |
| 216 | + /* Get just the USB bus-devpath part */ |
| 217 | + p = strrchr(ext->desc.container_syspath, '/'); |
| 218 | + if (!p || (p - ext->desc.container_syspath) <= 12) |
| 219 | + return NULL; |
| 220 | + |
| 221 | + for (int i = 0; p[i]; i++) { |
| 222 | + ((char *) &guid)[4 + i % 12] ^= p[i]; |
| 223 | + } |
| 224 | + |
| 225 | + if (!(dst = ExAllocatePool(PagedPool, len))) |
| 226 | + return NULL; |
| 227 | + |
| 228 | + StringFromGUID2(&guid, dst, len); |
| 229 | + return dst; |
| 230 | +} |
| 231 | + |
201 | 232 | static WCHAR *get_device_id(DEVICE_OBJECT *device) |
202 | 233 | { |
203 | 234 | static const WCHAR input_format[] = L"&MI_%02u"; |
@@ -522,6 +553,10 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp) |
522 | 553 | TRACE("BusQueryInstanceID\n"); |
523 | 554 | irp->IoStatus.Information = (ULONG_PTR)get_instance_id(device); |
524 | 555 | break; |
| 556 | + case BusQueryContainerID: |
| 557 | + TRACE("BusQueryContainerID\n"); |
| 558 | + irp->IoStatus.Information = (ULONG_PTR)get_container_id(device); |
| 559 | + break; |
525 | 560 | default: |
526 | 561 | FIXME("Unhandled type %08x\n", type); |
527 | 562 | return status; |
|
0 commit comments