From 56c5a46095ea2abc963888de7c56a08916cd3878 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 23 Jan 2018 21:25:55 +0100 Subject: [PATCH] winusb: cleanup DeviceInterfaceGUIDs usage --- winusb.c | 8 ++++---- winusb_defs.h | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/winusb.c b/winusb.c index d5e6a13884..1ba2f96845 100644 --- a/winusb.c +++ b/winusb.c @@ -67,10 +67,10 @@ static const struct winusb_extended_properties_descriptor guid = { { .dwLength = sizeof(struct winusb_extended_properties_feature_descriptor), .dwPropertyDataType = WINUSB_EXTENDED_PROPERTIES_MULTISZ_DATA_TYPE, - .wNameLength = sizeof(u"DeviceInterfaceGUIDs"), - .name = u"DeviceInterfaceGUIDs", - .dwPropertyDataLength = (WINUSB_EXTENDED_PROPERTIES_GUIDS_SIZE_C), - .propertyData = WINUSB_EXTENDED_PROPERTIES_RANDOM_GUID, + .wNameLength = WINUSB_EXTENDED_PROPERTIES_GUID_NAME_SIZE_C, + .name = WINUSB_EXTENDED_PROPERTIES_GUID_NAME, + .dwPropertyDataLength = WINUSB_EXTENDED_PROPERTIES_GUID_DATA_SIZE_C, + .propertyData = WINUSB_EXTENDED_PROPERTIES_GUID_DATA, }, } }; diff --git a/winusb_defs.h b/winusb_defs.h index 3b249dd5a4..830e6b1545 100644 --- a/winusb_defs.h +++ b/winusb_defs.h @@ -28,14 +28,17 @@ #define WINUSB_REQ_GET_EXTENDED_PROPERTIES_OS_FEATURE_DESCRIPTOR 0x05 #define WINUSB_BCD_VERSION 0x0100 -#define WINUSB_EXTENDED_PROPERTIES_GUID_NAME_SIZE_C (sizeof(u"DeviceInterfaceGUIDs")) -#define WINUSB_EXTENDED_PROPERTIES_GUID_NAME_SIZE_U (sizeof("DeviceInterfaceGUIDs")) -#define WINUSB_EXTENDED_PROPERTIES_RANDOM_GUID u"{0263b512-88cb-4136-9613-5c8e109d8ef5}\0" -// double null is intentional - it's an array of guids with 1 item +// Apparently using DeviceInterfaceGUID does not always work on Windows 7. +// DeviceInterfaceGUIDs does seem to work. +#define WINUSB_EXTENDED_PROPERTIES_GUID_NAME u"DeviceInterfaceGUIDs" +#define WINUSB_EXTENDED_PROPERTIES_GUID_NAME_SIZE_C sizeof(WINUSB_EXTENDED_PROPERTIES_GUID_NAME) +#define WINUSB_EXTENDED_PROPERTIES_GUID_NAME_SIZE_U (sizeof(WINUSB_EXTENDED_PROPERTIES_GUID_NAME) / 2) -#define WINUSB_EXTENDED_PROPERTIES_GUIDS_SIZE_C sizeof(WINUSB_EXTENDED_PROPERTIES_RANDOM_GUID) -#define WINUSB_EXTENDED_PROPERTIES_GUIDS_SIZE_U (sizeof(WINUSB_EXTENDED_PROPERTIES_RANDOM_GUID) / 2) -#define WINUSB_EXTENDED_PROPERTIES_MULTISZ_DATA_TYPE 7 +// extra null is intentional - it's an array of GUIDs with 1 item +#define WINUSB_EXTENDED_PROPERTIES_GUID_DATA u"{0263b512-88cb-4136-9613-5c8e109d8ef5}\x00" +#define WINUSB_EXTENDED_PROPERTIES_GUID_DATA_SIZE_C sizeof(WINUSB_EXTENDED_PROPERTIES_GUID_DATA) +#define WINUSB_EXTENDED_PROPERTIES_GUID_DATA_SIZE_U (sizeof(WINUSB_EXTENDED_PROPERTIES_GUID_DATA) / 2) +#define WINUSB_EXTENDED_PROPERTIES_MULTISZ_DATA_TYPE 7 #define WINUSB_EXTRA_STRING_INDEX 0xee @@ -68,7 +71,7 @@ struct winusb_extended_properties_feature_descriptor { uint16_t wNameLength; uint16_t name[WINUSB_EXTENDED_PROPERTIES_GUID_NAME_SIZE_U]; uint32_t dwPropertyDataLength; - uint16_t propertyData[WINUSB_EXTENDED_PROPERTIES_GUIDS_SIZE_U]; + uint16_t propertyData[WINUSB_EXTENDED_PROPERTIES_GUID_DATA_SIZE_U]; } __attribute__((packed)); struct winusb_extended_properties_descriptor_header {