1 #pragma once 2 3 #define _USBBUSIF_ 4 5 #ifndef USB_BUSIFFN 6 #define USB_BUSIFFN __stdcall 7 #endif 8 9 #if (NTDDI_VERSION >= NTDDI_WINXP) 10 11 #if !defined(_HUBBUSIF_) 12 typedef PVOID PUSB_DEVICE_HANDLE; 13 #endif 14 15 typedef 16 _Must_inspect_result_ 17 NTSTATUS 18 (USB_BUSIFFN *PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB) ( 19 _In_ PVOID, 20 _In_ PURB); 21 22 #define USB_HCD_CAPS_SUPPORTS_RT_THREADS 0x00000001 23 24 typedef VOID 25 (USB_BUSIFFN *PUSB_BUSIFFN_GETUSBDI_VERSION) ( 26 _In_ PVOID, 27 _Out_opt_ PUSBD_VERSION_INFORMATION, 28 _Out_opt_ PULONG); 29 30 typedef 31 _Must_inspect_result_ 32 NTSTATUS 33 (USB_BUSIFFN *PUSB_BUSIFFN_QUERY_BUS_TIME) ( 34 _In_ PVOID, 35 _Out_opt_ PULONG); 36 37 typedef NTSTATUS 38 (USB_BUSIFFN *PUSB_BUSIFFN_ENUM_LOG_ENTRY) ( 39 _In_ PVOID, 40 _In_ ULONG, 41 _In_ ULONG, 42 _In_ ULONG, 43 _In_ ULONG); 44 45 typedef struct _USB_BUS_INFORMATION_LEVEL_0 { 46 ULONG TotalBandwidth; 47 ULONG ConsumedBandwidth; 48 } USB_BUS_INFORMATION_LEVEL_0, *PUSB_BUS_INFORMATION_LEVEL_0; 49 50 typedef struct _USB_BUS_INFORMATION_LEVEL_1 { 51 ULONG TotalBandwidth; 52 ULONG ConsumedBandwidth; 53 ULONG ControllerNameLength; 54 WCHAR ControllerNameUnicodeString[1]; 55 } USB_BUS_INFORMATION_LEVEL_1, *PUSB_BUS_INFORMATION_LEVEL_1; 56 57 typedef 58 _Must_inspect_result_ 59 NTSTATUS 60 (USB_BUSIFFN *PUSB_BUSIFFN_QUERY_BUS_INFORMATION) ( 61 _In_ PVOID, 62 _In_ ULONG, 63 _Inout_ PVOID, 64 _Out_ PULONG, 65 _Out_opt_ PULONG); 66 67 typedef 68 _Must_inspect_result_ 69 BOOLEAN 70 (USB_BUSIFFN *PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED) ( 71 _In_opt_ PVOID); 72 73 #define USB_BUSIF_USBDI_VERSION_0 0x0000 74 #define USB_BUSIF_USBDI_VERSION_1 0x0001 75 #define USB_BUSIF_USBDI_VERSION_2 0x0002 76 #define USB_BUSIF_USBDI_VERSION_3 0x0003 77 78 DEFINE_GUID(USB_BUS_INTERFACE_USBDI_GUID, 79 0xb1a96a13, 0x3de0, 0x4574, 0x9b, 0x1, 0xc0, 0x8f, 0xea, 0xb3, 0x18, 0xd6); 80 81 typedef struct _USB_BUS_INTERFACE_USBDI_V0 { 82 USHORT Size; 83 USHORT Version; 84 PVOID BusContext; 85 PINTERFACE_REFERENCE InterfaceReference; 86 PINTERFACE_DEREFERENCE InterfaceDereference; 87 PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion; 88 PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime; 89 PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb; 90 PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation; 91 } USB_BUS_INTERFACE_USBDI_V0, *PUSB_BUS_INTERFACE_USBDI_V0; 92 93 typedef struct _USB_BUS_INTERFACE_USBDI_V1 { 94 USHORT Size; 95 USHORT Version; 96 PVOID BusContext; 97 PINTERFACE_REFERENCE InterfaceReference; 98 PINTERFACE_DEREFERENCE InterfaceDereference; 99 PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion; 100 PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime; 101 PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb; 102 PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation; 103 PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed; 104 } USB_BUS_INTERFACE_USBDI_V1, *PUSB_BUS_INTERFACE_USBDI_V1; 105 106 typedef struct _USB_BUS_INTERFACE_USBDI_V2 { 107 USHORT Size; 108 USHORT Version; 109 PVOID BusContext; 110 PINTERFACE_REFERENCE InterfaceReference; 111 PINTERFACE_DEREFERENCE InterfaceDereference; 112 PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion; 113 PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime; 114 PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb; 115 PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation; 116 PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed; 117 PUSB_BUSIFFN_ENUM_LOG_ENTRY EnumLogEntry; 118 } USB_BUS_INTERFACE_USBDI_V2, *PUSB_BUS_INTERFACE_USBDI_V2; 119 120 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 121 122 #if (NTDDI_VERSION >= NTDDI_VISTA) 123 124 typedef 125 _Must_inspect_result_ 126 NTSTATUS 127 (USB_BUSIFFN *PUSB_BUSIFFN_QUERY_BUS_TIME_EX) ( 128 _In_opt_ PVOID, 129 _Out_opt_ PULONG); 130 131 typedef 132 _Must_inspect_result_ 133 NTSTATUS 134 (USB_BUSIFFN *PUSB_BUSIFFN_QUERY_CONTROLLER_TYPE) ( 135 _In_opt_ PVOID, 136 _Out_opt_ PULONG, 137 _Out_opt_ PUSHORT, 138 _Out_opt_ PUSHORT, 139 _Out_opt_ PUCHAR, 140 _Out_opt_ PUCHAR, 141 _Out_opt_ PUCHAR, 142 _Out_opt_ PUCHAR); 143 144 typedef struct _USB_BUS_INTERFACE_USBDI_V3 { 145 USHORT Size; 146 USHORT Version; 147 PVOID BusContext; 148 PINTERFACE_REFERENCE InterfaceReference; 149 PINTERFACE_DEREFERENCE InterfaceDereference; 150 PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion; 151 PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime; 152 PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb; 153 PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation; 154 PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed; 155 PUSB_BUSIFFN_ENUM_LOG_ENTRY EnumLogEntry; 156 PUSB_BUSIFFN_QUERY_BUS_TIME_EX QueryBusTimeEx; 157 PUSB_BUSIFFN_QUERY_CONTROLLER_TYPE QueryControllerType; 158 } USB_BUS_INTERFACE_USBDI_V3, *PUSB_BUS_INTERFACE_USBDI_V3; 159 160 DEFINE_GUID(USB_BUS_INTERFACE_USBC_CONFIGURATION_GUID, 161 0x893b6a96, 0xb7f, 0x4d4d, 0xbd, 0xb4, 0xbb, 0xd4, 0xce, 0xeb, 0xb3, 0x1c); 162 163 #define USBC_FUNCTION_FLAG_APPEND_ID 0x1 164 165 typedef struct _USBC_FUNCTION_DESCRIPTOR{ 166 UCHAR FunctionNumber; 167 UCHAR NumberOfInterfaces; 168 PUSB_INTERFACE_DESCRIPTOR *InterfaceDescriptorList; 169 UNICODE_STRING HardwareId; 170 UNICODE_STRING CompatibleId; 171 UNICODE_STRING FunctionDescription; 172 ULONG FunctionFlags; 173 PVOID Reserved; 174 } USBC_FUNCTION_DESCRIPTOR, *PUSBC_FUNCTION_DESCRIPTOR; 175 176 typedef 177 _Must_inspect_result_ 178 NTSTATUS 179 (USB_BUSIFFN *USBC_START_DEVICE_CALLBACK)( 180 _In_ PUSB_DEVICE_DESCRIPTOR DeviceDescriptor, 181 _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, 182 _Outptr_result_bytebuffer_maybenull_(*FunctionDescriptorBufferLength) 183 PUSBC_FUNCTION_DESCRIPTOR *FunctionDescriptorBuffer, 184 _Out_ PULONG FunctionDescriptorBufferLength, 185 _In_ PDEVICE_OBJECT FdoDeviceObject, 186 _In_ PDEVICE_OBJECT PdoDeviceObject); 187 188 typedef 189 _Must_inspect_result_ 190 BOOLEAN 191 (USB_BUSIFFN *USBC_PDO_ENABLE_CALLBACK)( 192 _In_ PVOID Context, 193 _In_ USHORT FirstInterfaceNumber, 194 _In_ USHORT NumberOfInterfaces, 195 _In_ UCHAR FunctionClass, 196 _In_ UCHAR FunctionSubClass, 197 _In_ UCHAR FunctionProtocol); 198 199 #define USBC_DEVICE_CONFIGURATION_INTERFACE_VERSION_1 0x0001 200 201 typedef struct _USBC_DEVICE_CONFIGURATION_INTERFACE_V1 { 202 USHORT Size; 203 USHORT Version; 204 PVOID Context; 205 PINTERFACE_REFERENCE InterfaceReference; 206 PINTERFACE_DEREFERENCE InterfaceDereference; 207 USBC_START_DEVICE_CALLBACK StartDeviceCallback; 208 USBC_PDO_ENABLE_CALLBACK PdoEnableCallback; 209 PVOID Reserved[7]; 210 } USBC_DEVICE_CONFIGURATION_INTERFACE_V1, *PUSBC_DEVICE_CONFIGURATION_INTERFACE_V1; 211 212 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 213 214