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 codes 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..d5aaebe388e 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 +{ + /* DBT_DEVTYP_DEVICEINTERFACE */ + BROADCAST_DEVICE_TYPE_DEVICEINTERFACE = 5, + /* DBT_DEVTYP_HANDLE */ + BROADCAST_DEVICE_TYPE_HANDLE = 6 +} 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; + [string] LPWSTR name; + DWORD data_size; + [unique, size_is(data_size)] BYTE *data; +} device_broadcast_handle; + +typedef union _device_broadcast switch (broadcast_device_type devicetype) event +{ + case BROADCAST_DEVICE_TYPE_DEVICEINTERFACE: device_broadcast_deviceinterface device_interface; + case BROADCAST_DEVICE_TYPE_HANDLE: device_broadcast_handle handle; +} device_broadcast; + [ uuid(57c680ac-7bce-4f39-97fd-ffea566754d5), endpoint("ncacn_np:[\pipe\wine_plugplay]"),