From: Vibhav Pant vibhavp@gmail.com
Instead of sending and receiving events from plugplay as single array of bytes, introduce a new union, DEVICE_BROADCAST. The union currently supports the types DEVICE_BROADCAST_HANDLE and DEVICE_BROADCAST_DEVICEINTERFACE for the DBT_DEVTYP_HANDLE and DBT_DEVTYP_DEVICEINTERFACE event code respectively, and define individual fields corresponding to their equivalent structs in dbt.h.
While this introduces some additional complexity while converting from a DEVICE_BROADCAST to a DEV_BROADCAST_* type, it also allows support for DBT_DEVTYP_HANDLE events to be sent, which was not supported with the previous raw-bytes method, as the DEV_BROADCAST_HANDLE struct was identified with a HANDLE to the originating device file. --- include/wine/plugplay.idl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/include/wine/plugplay.idl b/include/wine/plugplay.idl index a3e7b04bf30..6dc63cbaa38 100644 --- a/include/wine/plugplay.idl +++ b/include/wine/plugplay.idl @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 Zebediah Figura for CodeWeavers + * Copyright (C) 2024 Vibhav Pant * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,6 +19,42 @@
import "wtypes.idl";
+typedef enum _BROADCAST_DEVICE_TYPE +{ + BROADCAST_DEVICE_TYPE_DEVICEINTERFACE = 0, + BROADCAST_DEVICE_TYPE_HANDLE = 1 +} BROADCAST_DEVICE_TYPE; + +typedef struct _DEVICE_BROADCAST_HEADER +{ + DWORD reserved; +} DEVICE_BROADCAST_HEADER; + +typedef struct _DEVICE_BROADCAST_DEVICEINTERFACE +{ + DEVICE_BROADCAST_HEADER header; + GUID class_guid; + [string] LPWSTR name; +} DEVICE_BROADCAST_DEVICEINTERFACE; + +typedef struct _DEVICE_BROADCAST_HANDLE +{ + DEVICE_BROADCAST_HEADER header; + LPWSTR handle_file_path; + GUID event_guid; + [unique, string] LPWSTR name; + DWORD data_size; + [unique, size_is(data_size)] BYTE *data; +} DEVICE_BROADCAST_HANDLE; + +typedef union _DEVICE_BROADCAST switch (DWORD devicetype) event +{ + /* DBT_DEVTYP_DEVICEINTERFACE */ + case 5: DEVICE_BROADCAST_DEVICEINTERFACE device_interface; + /* DBT_DEVTYP_HANDLE */ + case 6: DEVICE_BROADCAST_HANDLE handle; +} DEVICE_BROADCAST; + [ uuid(57c680ac-7bce-4f39-97fd-ffea566754d5), endpoint("ncacn_np:[\pipe\wine_plugplay]"),