ReactOS 0.4.17-dev-1281-g065abb3
desccheck.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for desccheck.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HubDescContext
 
struct  HubLpmInfo
 
struct  HubMsOs20SetInfo
 
struct  HubPlatformFeatures
 
struct  HubMsOs20Common
 
struct  HubMsOs20SetHeader
 
struct  HubMsOs20Subset
 
struct  HubMsOs20CompatibleId
 
struct  HubMsOs20Registry
 
struct  HubMsOs20ResumeTime
 
struct  HubMsOs20ModelId
 
struct  HubMsOs20Ccgp
 
struct  HubMsOsString
 
struct  HubMsOsHeader
 
struct  HubMsOsContainerId
 
struct  HubMsOsExtConfigHeader
 
struct  HubMsOsExtConfigFunction
 
struct  HubMsOsExtConfig
 
struct  HubBosInfo
 
struct  HubMsOs20Info
 

Macros

#define HUB_DESC_BITMAP_ULONGS   8
 
#define HUB_BOS_SUPERSPEED_CAPABLE   0x00000001
 
#define HUB_BOS_ENHANCED_SUPERSPEED_CAPABLE   0x00000002
 
#define HUB_BOS_CHARGING_POLICY   0x00000004
 
#define HUB_MSOS20_SET_INFO   0x00000001
 
#define HUB_MSOS20_SET_HEADER   0x00000002
 
#define HUB_MSOS20_ALT_ENUM   0x00000004
 
#define HUB_MSOS20_CONFIG_SUBSET   0x00000008
 
#define HUB_MSOS20_FUNCTION_SUBSET   0x00000010
 
#define HUB_MSOS20_COMPATIBLE_ID   0x00000020
 
#define HUB_MSOS20_REGISTRY   0x00000040
 
#define HUB_MSOS20_RESUME_TIME   0x00000080
 
#define HUB_MSOS20_MODEL_ID   0x00000100
 
#define HUB_MSOS20_CCGP   0x00000200
 

Typedefs

typedef VOID(NTAPI * PFN_HUB_DESC_LOG) (_In_opt_ PVOID Context, _In_ HubDescCode Code, _In_ BOOLEAN Warning)
 

Enumerations

enum class  HubDescCode : ULONG {
  Hub20LengthTooLarge = 0 , Hub20LengthTooSmall = 1 , Hub20Null = 2 , Hub20BufferTooSmall = 3 ,
  Hub20RemovableMissingPort = 4 , Hub20RemovableReserved = 5 , Hub20WrongType = 6 , Hub20NoPorts = 7 ,
  Hub20PowerMaskNotOnes = 8 , Hub20CharacteristicsReserved = 9 , Hub30DecodeLatencyReserved = 10 , Hub30LengthTooLarge = 11 ,
  Hub30LengthTooSmall = 12 , Hub30BufferTooSmall = 13 , Hub30RemovableMissingPort = 14 , Hub30RemovableReserved = 15 ,
  Hub30WrongType = 16 , Hub30TooManyPorts = 17 , Hub30NoPorts = 18 , Hub30CharacteristicsReserved = 19 ,
  BosLengthTooLarge = 20 , BosLengthTooSmall = 21 , BosBufferLargerThanTotal = 22 , BosBufferTooSmall = 23 ,
  BosWrongType = 24 , BosCapCountMismatch = 25 , BosNoSuperSpeedCap = 26 , BosNull = 27 ,
  BosUnknownType = 28 , BosTotalLengthTooSmall = 29 , BulkAtLowSpeed = 30 , BulkAttributesReserved = 31 ,
  BulkMaxPacket = 32 , CompanionBulkReserved = 33 , CompanionBulkBurst = 34 , CompanionBulkStreams = 35 ,
  CompanionBulkBytesPerInterval = 36 , CompanionControlAttributes = 37 , CompanionControlBurst = 38 , CompanionControlBytesPerInterval = 39 ,
  CompanionNotSuperSpeed = 40 , CompanionUnexpected = 41 , CompanionLengthTooLarge = 42 , CompanionLengthTooSmall = 43 ,
  CompanionBufferTooSmall = 44 , CompanionInterruptBurst = 45 , CompanionInterruptBurstPacket = 46 , CompanionInterruptAttributes = 47 ,
  CompanionInterruptBytesPerInterval = 48 , CompanionIsochReserved = 49 , CompanionIsochBurst = 50 , CompanionIsochBurstPacket = 51 ,
  CompanionIsochMult = 52 , CompanionIsochBytesPerInterval = 53 , ConfigLengthTooLarge = 54 , ConfigLengthTooSmall = 55 ,
  ConfigBufferTooSmall = 56 , ConfigBufferTooSmallForInterfaces = 57 , ConfigWrongType = 58 , ConfigMissingCompanion = 59 ,
  ConfigNull = 60 , ConfigTotalLengthTooLarge = 61 , ConfigTotalLengthTooSmall = 62 , ContainerIdLengthTooLarge = 63 ,
  ContainerIdLengthTooSmall = 64 , ContainerIdBufferTooSmall = 65 , ContainerIdReserved = 66 , ControlAttributesReserved = 67 ,
  ControlMaxPacket = 68 , DeviceVersionNotBcd = 69 , DeviceLengthTooSmall = 70 , DeviceBufferTooSmall = 71 ,
  CapLengthTooSmall = 72 , CapBufferTooSmall = 73 , CapMultipleContainerId = 74 , CapMultipleSuperSpeed = 75 ,
  CapMultipleUsb20 = 76 , DeviceWrongType = 77 , DeviceMaxPacket0 = 78 , DeviceNull = 79 ,
  EndpointLengthTooLarge = 80 , EndpointLengthTooSmall = 81 , EndpointAttributesReserved = 82 , EndpointBufferTooSmall = 83 ,
  EndpointAddressReserved = 84 , EndpointBeforeInterface = 85 , EndpointNumberZero = 86 , HeaderPastBuffer = 87 ,
  HeaderPastTotalLength = 88 , HeaderLengthTooSmall = 89 , HeaderBufferTooSmall = 90 , HeaderLengthZero = 91 ,
  IadLengthTooLarge = 92 , IadLengthTooSmall = 93 , IadBufferTooSmall = 94 , IadCountTooLarge = 95 ,
  IadCountZero = 96 , IadFirstInterfaceTooLarge = 97 , InterfaceLengthTooLarge = 98 , InterfaceLengthTooSmall = 99 ,
  InterfaceBufferTooSmall = 100 , DuplicateAlternate = 101 , DuplicateEndpoint = 102 , DuplicateInterface = 103 ,
  FirstAlternateNotZero = 104 , AlternateOutOfOrder = 105 , InterfaceOutOfOrder = 106 , EndpointCountMismatch = 107 ,
  InterruptAttributesReserved = 108 , InterruptInterval = 109 , InterruptMaxPacket = 110 , IsochAtLowSpeed = 111 ,
  IsochInterval = 112 , IsochMaxPacket = 113 , MsOsContainerIdZero = 114 , MsOsContainerIdVersion = 115 ,
  MsOsContainerIdIndex = 116 , MsOsContainerIdBufferSize = 117 , MsOsContainerIdLength = 118 , MsOsExtConfigFirstInterface = 119 ,
  MsOsExtConfigVersion = 120 , MsOsExtConfigCount = 121 , MsOsExtConfigBufferSize = 122 , MsOsExtConfigCompatibleId = 123 ,
  MsOsExtConfigSubCompatibleId = 124 , MsOsExtConfigIndex = 125 , MsOsExtConfigBufferVsLength = 126 , MsOsExtConfigLengthVsCount = 127 ,
  StringLengthOdd = 128 , StringLengthTooLarge = 129 , StringLengthTooSmall = 130 , StringBufferTooSmall = 131 ,
  SerialNumberBadCharacter = 132 , StringWrongType = 133 , StringLengthVsBytes = 134 , SsCapLengthTooLarge = 135 ,
  SsCapLengthTooSmall = 136 , SsCapAttributesReserved = 137 , SsCapU1TooLarge = 138 , SsCapU2TooLarge = 139 ,
  SsCapBufferTooSmall = 140 , SsCapFunctionalityNotInSpeeds = 141 , SsCapFunctionalityReserved = 142 , SsCapSpeedsReserved = 143 ,
  SsCapNoSpeeds = 144 , Usb20CapLengthTooLarge = 145 , Usb20CapLengthTooSmall = 146 , Usb20CapReserved = 147 ,
  Usb20CapBufferTooSmall = 148 , BaselineBeslZero = 149 , BeslWithoutLpm = 150 , DeepBeslNotAboveBaseline = 151 ,
  DeepBeslZero = 152 , BosContainerIdZero = 153 , MsOs20MultipleSetHeaders = 154 , MsOs20SetHeaderLength = 155 ,
  ConfigSubsetLength = 156 , ConfigSubsetTotalTooSmall = 157 , ConfigSubsetTotalTooLarge = 158 , ConfigSubsetMisplacedFeature = 159 ,
  ConfigSubsetFeatureLength = 160 , FunctionSubsetLength = 161 , FunctionSubsetTotalTooSmall = 162 , FunctionSubsetTotalTooLarge = 163 ,
  FunctionSubsetMisplacedFeature = 164 , FunctionSubsetFeatureLength = 165 , MsOs20MultipleCompatibleId = 166 , MsOs20CompatibleIdLength = 167 ,
  MsOs20CompatibleIdAfterNull = 168 , MsOs20RegistryTooSmall = 169 , MsOs20RegistryNameTooLarge = 170 , MsOs20RegistryNameOddOrZero = 171 ,
  MsOs20RegistryDataTooLarge = 172 , MsOs20RegistryDataZero = 173 , MsOs20RegistryType = 174 , MsOs20MultipleResumeTime = 175 ,
  MsOs20ResumeTimeLength = 176 , MsOs20ResumeRecovery = 177 , MsOs20ResumeSignaling = 178 , MsOs20MultipleModelId = 181 ,
  MsOs20ModelIdLength = 182 , MsOs20ModelIdZero = 183 , MsOs20BytesVsSetInfo = 188 , MsOs20BytesTooSmall = 189 ,
  MsOs20HeaderLength = 190 , MsOs20TotalLengthMismatch = 191 , MsOs20VersionMismatch = 192 , MsOs20FeatureOutOfOrder = 193 ,
  MsOs20PastEnd = 194 , PlatformReserved = 195 , PlatformUuidZero = 196 , MsOs20MultiplePlatform = 197 ,
  MsOs20PlatformLength = 198 , MsOs20DuplicateVersion = 199 , MsOs20NoVersionMatch = 200 , MsOs20MultipleCcgp = 201 ,
  MsOs20CcgpLength = 202 , CapMultipleSuperSpeedPlus = 203 , CompanionIsochBytesNotOne = 204 , SspCompanionNotSuperSpeed = 205 ,
  SspCompanionUnexpected = 206 , SspCompanionLengthTooLarge = 207 , SspCompanionLengthTooSmall = 208 , SspCompanionBufferTooSmall = 209 ,
  SspCompanionReserved = 210 , SspCompanionBytesRange = 211 , ConfigMissingSspCompanion = 212 , SspCapLengthInvalid = 213 ,
  SspCapLengthTooSmall = 214 , SspCapAttributesReserved = 215 , SspCapFunctionalityReserved = 216 , SspCapBufferTooSmall = 217 ,
  SspCapReservedByte = 218 , SspCapReservedWord = 219 , SspAttrNotRx = 220 , SspAttrNotTx = 221 ,
  SspAttrTxMissing = 222 , SspAttrPairMismatch = 223 , SspAttrSymmetricMismatch = 224 , SspMinLaneMismatch = 225 ,
  SspSpeedIdDuplicate = 226 , SspSpeedIdCount = 227 , SspMinSpeedMissing = 228 , PdLengthTooLarge = 229 ,
  PdLengthTooSmall = 230 , PdBufferTooSmall = 231 , PdReserved = 232 , IsochPacketInAlternate0 = 233 ,
  DuplicateSerialNumber = 234 , BillboardLengthTooSmall = 235 , BillboardLengthInvalid = 236 , BillboardBufferTooSmall = 237 ,
  BillboardNoModes = 238 , BillboardTooManyModes = 239 , BillboardPreferredInvalid = 241 , CapMultipleBillboard = 245 ,
  BillboardDeviceVersion = 246 , PlatformFeaturesLength = 247 , PlatformFeaturesMultiple = 248 , PlatformFeaturesVersion = 249 ,
  PlatformFeaturesTooSmall = 250 , PlatformLengthTooSmall = 251 , PlatformBufferTooSmall = 253 , Count = 254
}
 

Functions

 C_ASSERT (sizeof(HubMsOs20SetInfo)==8)
 
 C_ASSERT (sizeof(HubPlatformFeatures)==26)
 
 C_ASSERT (sizeof(HubMsOs20SetHeader)==10)
 
 C_ASSERT (sizeof(HubMsOs20Subset)==8)
 
 C_ASSERT (sizeof(HubMsOs20CompatibleId)==20)
 
 C_ASSERT (sizeof(HubMsOsString)==18)
 
 C_ASSERT (sizeof(HubMsOsContainerId)==24)
 
 C_ASSERT (sizeof(HubMsOsExtConfigHeader)==16)
 
 C_ASSERT (sizeof(HubMsOsExtConfig)==40)
 
VOID NTAPI HubDescInitDeviceContext (_Out_ HubDescContext *Context, _In_ USHORT BcdUsb, _In_ USB_DEVICE_SPEED Speed, _In_ BOOLEAN Win8Behavior, _In_ ULONG SspIsochBurstCount, _In_opt_ PULONG Bitmap)
 
VOID NTAPI HubDescInitHubContext (_Out_ HubDescContext *Context, _In_ USHORT BcdUsb, _In_ USB_DEVICE_SPEED Speed)
 
PCSTR NTAPI HubDescCodeName (_In_ HubDescCode Code)
 
VOID NTAPI HubDescLog (_In_ const HubDescContext *Context, _In_ HubDescCode Code, _In_ BOOLEAN Warning)
 
BOOLEAN NTAPI HubDescCheckDevice (_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_DEVICE_DESCRIPTOR Descriptor, _In_ ULONG Length, _Inout_opt_ PBOOLEAN IsBillboard)
 
BOOLEAN NTAPI HubDescCheckConfiguration (_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_CONFIGURATION_DESCRIPTOR Descriptor, _In_ ULONG Length, _Out_opt_ PBOOLEAN SupportsStreams)
 
BOOLEAN NTAPI HubDescCheckBosHeader (_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_BOS_DESCRIPTOR Descriptor, _In_ ULONG Length)
 
 _IRQL_requires_ (PASSIVE_LEVEL) BOOLEAN NTAPI HubDescCheckBos(_In_ const HubDescContext *Context
 
 _Inout_updates_bytes_ (Length) PUSB_BOS_DESCRIPTOR Descriptor
 
BOOLEAN NTAPI HubDescCheckString (_In_ const HubDescContext *Context, _In_reads_bytes_(Length) PUSB_STRING_DESCRIPTOR Descriptor, _In_ ULONG Length, _Out_opt_ PULONG AdjustedLength)
 
BOOLEAN NTAPI HubDescCheckSerialNumber (_In_ const HubDescContext *Context, _In_reads_bytes_(*Length) PUSB_STRING_DESCRIPTOR Descriptor, _Inout_ PULONG Length)
 
BOOLEAN NTAPI HubDescCheckMsOsString (_In_ const HubDescContext *Context, _In_ const HubMsOsString *Descriptor)
 
BOOLEAN NTAPI HubDescCheckMsOsContainerIdHeader (_In_ const HubDescContext *Context, _In_reads_bytes_(Length) const HubMsOsHeader *Descriptor, _In_ ULONG Length)
 
BOOLEAN NTAPI HubDescCheckMsOsContainerId (_In_ const HubDescContext *Context, _In_reads_bytes_(Length) const HubMsOsContainerId *Descriptor, _In_ ULONG Length)
 
BOOLEAN NTAPI HubDescCheckMsOsExtConfigHeader (_In_ const HubDescContext *Context, _In_reads_bytes_(Length) const HubMsOsExtConfigHeader *Descriptor, _In_ ULONG Length)
 
BOOLEAN NTAPI HubDescCheckMsOsExtConfig (_In_ const HubDescContext *Context, _In_reads_bytes_(sizeof(HubMsOsExtConfig)) const HubMsOsExtConfig *Descriptor, _In_ ULONG Length)
 
 _In_reads_bytes_ (Length) PVOID Set
 
BOOLEAN NTAPI HubDescCheck20Hub (_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_HUB_DESCRIPTOR Descriptor, _In_ ULONG Length)
 
BOOLEAN NTAPI HubDescCheck30Hub (_In_ const HubDescContext *Context, _In_reads_bytes_opt_(Length) PUSB_30_HUB_DESCRIPTOR Descriptor, _In_ ULONG Length)
 
PUSB_COMMON_DESCRIPTOR NTAPI HubDescFind (_In_reads_bytes_(TotalLength) PVOID Buffer, _In_ ULONG TotalLength, _In_ PVOID Position, _In_ UCHAR Type)
 
PUSB_INTERFACE_DESCRIPTOR NTAPI HubDescFindInterface (_In_ PUSB_CONFIGURATION_DESCRIPTOR Config, _In_ PVOID Position, _In_ LONG Number, _In_ LONG Alternate, _In_ LONG Class, _In_ LONG SubClass, _In_ LONG Protocol, _Out_opt_ PBOOLEAN HasAlternates)
 
BOOLEAN NTAPI HubDescNextMsOs20 (_In_ PUCHAR End, _Inout_ HubMsOs20Common **Current)
 

Variables

_In_ ULONG Length
 
_In_ ULONG _Out_opt_ HubBosInfo * Info
 
_In_ ULONG _Out_opt_ HubBosInfo _Out_opt_ PUSHORT U1ExitLatency
 
_In_ ULONG _Out_opt_ HubBosInfo _Out_opt_ PUSHORT _Out_opt_ PUSHORT U2ExitLatency
 
_In_ ULONG _Out_opt_ HubBosInfo _Out_opt_ PUSHORT _Out_opt_ PUSHORT _Inout_opt_ PBOOLEAN LtmCapable
 
_In_ ULONG _Out_opt_ HubBosInfo _Out_opt_ PUSHORT _Out_opt_ PUSHORT _Inout_opt_ PBOOLEAN _Inout_opt_ HubLpmInfo * Lpm
 
_In_ ULONG _Out_opt_ HubBosInfo _Out_opt_ PUSHORT _Out_opt_ PUSHORT _Inout_opt_ PBOOLEAN _Inout_opt_ HubLpmInfo _Inout_opt_ PULONG DeviceFlags
 
_In_ ULONG _In_ const HubMsOs20SetInfo * SetInfo
 

Macro Definition Documentation

◆ HUB_BOS_CHARGING_POLICY

#define HUB_BOS_CHARGING_POLICY   0x00000004

Definition at line 318 of file desccheck.h.

◆ HUB_BOS_ENHANCED_SUPERSPEED_CAPABLE

#define HUB_BOS_ENHANCED_SUPERSPEED_CAPABLE   0x00000002

Definition at line 317 of file desccheck.h.

◆ HUB_BOS_SUPERSPEED_CAPABLE

#define HUB_BOS_SUPERSPEED_CAPABLE   0x00000001

Definition at line 316 of file desccheck.h.

◆ HUB_DESC_BITMAP_ULONGS

#define HUB_DESC_BITMAP_ULONGS   8

Definition at line 263 of file desccheck.h.

◆ HUB_MSOS20_ALT_ENUM

#define HUB_MSOS20_ALT_ENUM   0x00000004

Definition at line 490 of file desccheck.h.

◆ HUB_MSOS20_CCGP

#define HUB_MSOS20_CCGP   0x00000200

Definition at line 497 of file desccheck.h.

◆ HUB_MSOS20_COMPATIBLE_ID

#define HUB_MSOS20_COMPATIBLE_ID   0x00000020

Definition at line 493 of file desccheck.h.

◆ HUB_MSOS20_CONFIG_SUBSET

#define HUB_MSOS20_CONFIG_SUBSET   0x00000008

Definition at line 491 of file desccheck.h.

◆ HUB_MSOS20_FUNCTION_SUBSET

#define HUB_MSOS20_FUNCTION_SUBSET   0x00000010

Definition at line 492 of file desccheck.h.

◆ HUB_MSOS20_MODEL_ID

#define HUB_MSOS20_MODEL_ID   0x00000100

Definition at line 496 of file desccheck.h.

◆ HUB_MSOS20_REGISTRY

#define HUB_MSOS20_REGISTRY   0x00000040

Definition at line 494 of file desccheck.h.

◆ HUB_MSOS20_RESUME_TIME

#define HUB_MSOS20_RESUME_TIME   0x00000080

Definition at line 495 of file desccheck.h.

◆ HUB_MSOS20_SET_HEADER

#define HUB_MSOS20_SET_HEADER   0x00000002

Definition at line 489 of file desccheck.h.

◆ HUB_MSOS20_SET_INFO

#define HUB_MSOS20_SET_INFO   0x00000001

Definition at line 488 of file desccheck.h.

Typedef Documentation

◆ PFN_HUB_DESC_LOG

typedef VOID(NTAPI * PFN_HUB_DESC_LOG) (_In_opt_ PVOID Context, _In_ HubDescCode Code, _In_ BOOLEAN Warning)

Logging hook. Called for every finding after the bitmap bit is set.

Definition at line 267 of file desccheck.h.

Enumeration Type Documentation

◆ HubDescCode

Enumerator
Hub20LengthTooLarge 
Hub20LengthTooSmall 
Hub20Null 
Hub20BufferTooSmall 
Hub20RemovableMissingPort 
Hub20RemovableReserved 
Hub20WrongType 
Hub20NoPorts 
Hub20PowerMaskNotOnes 
Hub20CharacteristicsReserved 
Hub30DecodeLatencyReserved 
Hub30LengthTooLarge 
Hub30LengthTooSmall 
Hub30BufferTooSmall 
Hub30RemovableMissingPort 
Hub30RemovableReserved 
Hub30WrongType 
Hub30TooManyPorts 
Hub30NoPorts 
Hub30CharacteristicsReserved 
BosLengthTooLarge 
BosLengthTooSmall 
BosBufferLargerThanTotal 
BosBufferTooSmall 
BosWrongType 
BosCapCountMismatch 
BosNoSuperSpeedCap 
BosNull 
BosUnknownType 
BosTotalLengthTooSmall 
BulkAtLowSpeed 
BulkAttributesReserved 
BulkMaxPacket 
CompanionBulkReserved 
CompanionBulkBurst 
CompanionBulkStreams 
CompanionBulkBytesPerInterval 
CompanionControlAttributes 
CompanionControlBurst 
CompanionControlBytesPerInterval 
CompanionNotSuperSpeed 
CompanionUnexpected 
CompanionLengthTooLarge 
CompanionLengthTooSmall 
CompanionBufferTooSmall 
CompanionInterruptBurst 
CompanionInterruptBurstPacket 
CompanionInterruptAttributes 
CompanionInterruptBytesPerInterval 
CompanionIsochReserved 
CompanionIsochBurst 
CompanionIsochBurstPacket 
CompanionIsochMult 
CompanionIsochBytesPerInterval 
ConfigLengthTooLarge 
ConfigLengthTooSmall 
ConfigBufferTooSmall 
ConfigBufferTooSmallForInterfaces 
ConfigWrongType 
ConfigMissingCompanion 
ConfigNull 
ConfigTotalLengthTooLarge 
ConfigTotalLengthTooSmall 
ContainerIdLengthTooLarge 
ContainerIdLengthTooSmall 
ContainerIdBufferTooSmall 
ContainerIdReserved 
ControlAttributesReserved 
ControlMaxPacket 
DeviceVersionNotBcd 
DeviceLengthTooSmall 
DeviceBufferTooSmall 
CapLengthTooSmall 
CapBufferTooSmall 
CapMultipleContainerId 
CapMultipleSuperSpeed 
CapMultipleUsb20 
DeviceWrongType 
DeviceMaxPacket0 
DeviceNull 
EndpointLengthTooLarge 
EndpointLengthTooSmall 
EndpointAttributesReserved 
EndpointBufferTooSmall 
EndpointAddressReserved 
EndpointBeforeInterface 
EndpointNumberZero 
HeaderPastBuffer 
HeaderPastTotalLength 
HeaderLengthTooSmall 
HeaderBufferTooSmall 
HeaderLengthZero 
IadLengthTooLarge 
IadLengthTooSmall 
IadBufferTooSmall 
IadCountTooLarge 
IadCountZero 
IadFirstInterfaceTooLarge 
InterfaceLengthTooLarge 
InterfaceLengthTooSmall 
InterfaceBufferTooSmall 
DuplicateAlternate 
DuplicateEndpoint 
DuplicateInterface 
FirstAlternateNotZero 
AlternateOutOfOrder 
InterfaceOutOfOrder 
EndpointCountMismatch 
InterruptAttributesReserved 
InterruptInterval 
InterruptMaxPacket 
IsochAtLowSpeed 
IsochInterval 
IsochMaxPacket 
MsOsContainerIdZero 
MsOsContainerIdVersion 
MsOsContainerIdIndex 
MsOsContainerIdBufferSize 
MsOsContainerIdLength 
MsOsExtConfigFirstInterface 
MsOsExtConfigVersion 
MsOsExtConfigCount 
MsOsExtConfigBufferSize 
MsOsExtConfigCompatibleId 
MsOsExtConfigSubCompatibleId 
MsOsExtConfigIndex 
MsOsExtConfigBufferVsLength 
MsOsExtConfigLengthVsCount 
StringLengthOdd 
StringLengthTooLarge 
StringLengthTooSmall 
StringBufferTooSmall 
SerialNumberBadCharacter 
StringWrongType 
StringLengthVsBytes 
SsCapLengthTooLarge 
SsCapLengthTooSmall 
SsCapAttributesReserved 
SsCapU1TooLarge 
SsCapU2TooLarge 
SsCapBufferTooSmall 
SsCapFunctionalityNotInSpeeds 
SsCapFunctionalityReserved 
SsCapSpeedsReserved 
SsCapNoSpeeds 
Usb20CapLengthTooLarge 
Usb20CapLengthTooSmall 
Usb20CapReserved 
Usb20CapBufferTooSmall 
BaselineBeslZero 
BeslWithoutLpm 
DeepBeslNotAboveBaseline 
DeepBeslZero 
BosContainerIdZero 
MsOs20MultipleSetHeaders 
MsOs20SetHeaderLength 
ConfigSubsetLength 
ConfigSubsetTotalTooSmall 
ConfigSubsetTotalTooLarge 
ConfigSubsetMisplacedFeature 
ConfigSubsetFeatureLength 
FunctionSubsetLength 
FunctionSubsetTotalTooSmall 
FunctionSubsetTotalTooLarge 
FunctionSubsetMisplacedFeature 
FunctionSubsetFeatureLength 
MsOs20MultipleCompatibleId 
MsOs20CompatibleIdLength 
MsOs20CompatibleIdAfterNull 
MsOs20RegistryTooSmall 
MsOs20RegistryNameTooLarge 
MsOs20RegistryNameOddOrZero 
MsOs20RegistryDataTooLarge 
MsOs20RegistryDataZero 
MsOs20RegistryType 
MsOs20MultipleResumeTime 
MsOs20ResumeTimeLength 
MsOs20ResumeRecovery 
MsOs20ResumeSignaling 
MsOs20MultipleModelId 
MsOs20ModelIdLength 
MsOs20ModelIdZero 
MsOs20BytesVsSetInfo 
MsOs20BytesTooSmall 
MsOs20HeaderLength 
MsOs20TotalLengthMismatch 
MsOs20VersionMismatch 
MsOs20FeatureOutOfOrder 
MsOs20PastEnd 
PlatformReserved 
PlatformUuidZero 
MsOs20MultiplePlatform 
MsOs20PlatformLength 
MsOs20DuplicateVersion 
MsOs20NoVersionMatch 
MsOs20MultipleCcgp 
MsOs20CcgpLength 
CapMultipleSuperSpeedPlus 
CompanionIsochBytesNotOne 
SspCompanionNotSuperSpeed 
SspCompanionUnexpected 
SspCompanionLengthTooLarge 
SspCompanionLengthTooSmall 
SspCompanionBufferTooSmall 
SspCompanionReserved 
SspCompanionBytesRange 
ConfigMissingSspCompanion 
SspCapLengthInvalid 
SspCapLengthTooSmall 
SspCapAttributesReserved 
SspCapFunctionalityReserved 
SspCapBufferTooSmall 
SspCapReservedByte 
SspCapReservedWord 
SspAttrNotRx 
SspAttrNotTx 
SspAttrTxMissing 
SspAttrPairMismatch 
SspAttrSymmetricMismatch 
SspMinLaneMismatch 
SspSpeedIdDuplicate 
SspSpeedIdCount 
SspMinSpeedMissing 
PdLengthTooLarge 
PdLengthTooSmall 
PdBufferTooSmall 
PdReserved 
IsochPacketInAlternate0 
DuplicateSerialNumber 
BillboardLengthTooSmall 
BillboardLengthInvalid 
BillboardBufferTooSmall 
BillboardNoModes 
BillboardTooManyModes 
BillboardPreferredInvalid 
CapMultipleBillboard 
BillboardDeviceVersion 
PlatformFeaturesLength 
PlatformFeaturesMultiple 
PlatformFeaturesVersion 
PlatformFeaturesTooSmall 
PlatformLengthTooSmall 
PlatformBufferTooSmall 
Count 

Definition at line 14 of file desccheck.h.

15{
18 Hub20Null = 2,
23 Hub20NoPorts = 7,
32 Hub30WrongType = 16,
34 Hub30NoPorts = 18,
40 BosWrongType = 24,
43 BosNull = 27,
44 BosUnknownType = 28,
46 BulkAtLowSpeed = 30,
48 BulkMaxPacket = 32,
74 ConfigWrongType = 58,
76 ConfigNull = 60,
93 DeviceWrongType = 77,
95 DeviceNull = 79,
103 HeaderPastBuffer = 87,
107 HeaderLengthZero = 91,
111 IadCountTooLarge = 95,
112 IadCountZero = 96,
117 DuplicateAlternate = 101,
118 DuplicateEndpoint = 102,
119 DuplicateInterface = 103,
125 InterruptInterval = 109,
126 InterruptMaxPacket = 110,
127 IsochAtLowSpeed = 111,
128 IsochInterval = 112,
129 IsochMaxPacket = 113,
137 MsOsExtConfigCount = 121,
141 MsOsExtConfigIndex = 125,
144 StringLengthOdd = 128,
149 StringWrongType = 133,
154 SsCapU1TooLarge = 138,
155 SsCapU2TooLarge = 139,
160 SsCapNoSpeeds = 144,
163 Usb20CapReserved = 147,
165 BaselineBeslZero = 149,
166 BeslWithoutLpm = 150,
168 DeepBeslZero = 152,
169 BosContainerIdZero = 153,
172 ConfigSubsetLength = 156,
190 MsOs20RegistryType = 174,
197 MsOs20ModelIdZero = 183,
200 MsOs20HeaderLength = 190,
204 MsOs20PastEnd = 194,
205 PlatformReserved = 195,
206 PlatformUuidZero = 196,
211 MsOs20MultipleCcgp = 201,
212 MsOs20CcgpLength = 202,
228 SspCapReservedByte = 218,
229 SspCapReservedWord = 219,
230 SspAttrNotRx = 220,
231 SspAttrNotTx = 221,
232 SspAttrTxMissing = 222,
235 SspMinLaneMismatch = 225,
237 SspSpeedIdCount = 227,
238 SspMinSpeedMissing = 228,
239 PdLengthTooLarge = 229,
240 PdLengthTooSmall = 230,
241 PdBufferTooSmall = 231,
242 PdReserved = 232,
248 BillboardNoModes = 238,
259 Count = 254
260};
@ MsOs20PlatformLength
@ ConfigBufferTooSmall
@ PlatformBufferTooSmall
@ SspCapAttributesReserved
@ ConfigTotalLengthTooLarge
@ FunctionSubsetLength
@ CompanionControlBytesPerInterval
@ PlatformFeaturesVersion
@ MsOs20ResumeTimeLength
@ MsOs20MultiplePlatform
@ CapMultipleBillboard
@ InterfaceBufferTooSmall
@ SspCompanionLengthTooSmall
@ BillboardPreferredInvalid
@ Hub20RemovableReserved
@ MsOsContainerIdIndex
@ MsOs20MultipleResumeTime
@ IadFirstInterfaceTooLarge
@ ConfigLengthTooSmall
@ Hub20RemovableMissingPort
@ MsOsExtConfigBufferSize
@ FunctionSubsetMisplacedFeature
@ FirstAlternateNotZero
@ BosBufferLargerThanTotal
@ DeviceBufferTooSmall
@ SsCapAttributesReserved
@ EndpointCountMismatch
@ MsOsExtConfigCompatibleId
@ SspCompanionBytesRange
@ MsOs20RegistryNameTooLarge
@ ConfigSubsetMisplacedFeature
@ FunctionSubsetTotalTooLarge
@ CompanionBulkReserved
@ MsOsExtConfigFirstInterface
@ SspCompanionNotSuperSpeed
@ PlatformFeaturesTooSmall
@ BosTotalLengthTooSmall
@ MsOs20RegistryDataTooLarge
@ Hub30RemovableMissingPort
@ MsOs20RegistryTooSmall
@ MsOsContainerIdVersion
@ DeepBeslNotAboveBaseline
@ ConfigMissingCompanion
@ BillboardDeviceVersion
@ ConfigLengthTooLarge
@ CompanionIsochReserved
@ MsOs20BytesVsSetInfo
@ MsOs20NoVersionMatch
@ CompanionInterruptBurst
@ SspCapBufferTooSmall
@ EndpointBeforeInterface
@ EndpointAddressReserved
@ FunctionSubsetFeatureLength
@ SsCapFunctionalityReserved
@ BillboardTooManyModes
@ BillboardBufferTooSmall
@ ContainerIdLengthTooLarge
@ CompanionInterruptBytesPerInterval
@ CompanionInterruptAttributes
@ IsochPacketInAlternate0
@ CapMultipleContainerId
@ CompanionIsochBytesPerInterval
@ MsOs20ResumeSignaling
@ BulkAttributesReserved
@ FunctionSubsetTotalTooSmall
@ SspCompanionLengthTooLarge
@ MsOs20CompatibleIdAfterNull
@ MsOs20CompatibleIdLength
@ PlatformLengthTooSmall
@ EndpointAttributesReserved
@ CompanionLengthTooSmall
@ CompanionControlBurst
@ DeviceLengthTooSmall
@ MsOsExtConfigBufferVsLength
@ MsOs20RegistryNameOddOrZero
@ SspCapFunctionalityReserved
@ InterfaceLengthTooLarge
@ InterfaceLengthTooSmall
@ MsOsExtConfigSubCompatibleId
@ InterruptAttributesReserved
@ PlatformFeaturesLength
@ CompanionControlAttributes
@ SsCapFunctionalityNotInSpeeds
@ MsOsContainerIdBufferSize
@ HeaderPastTotalLength
@ ConfigSubsetFeatureLength
@ Usb20CapBufferTooSmall
@ MsOs20SetHeaderLength
@ Hub30CharacteristicsReserved
@ SspCompanionBufferTooSmall
@ StringLengthTooSmall
@ ConfigTotalLengthTooSmall
@ MsOs20MultipleSetHeaders
@ MsOs20FeatureOutOfOrder
@ CompanionLengthTooLarge
@ MsOsExtConfigLengthVsCount
@ CompanionBulkStreams
@ MsOsContainerIdLength
@ SspCompanionUnexpected
@ EndpointLengthTooLarge
@ BillboardLengthInvalid
@ ContainerIdBufferTooSmall
@ CompanionBufferTooSmall
@ PlatformFeaturesMultiple
@ Usb20CapLengthTooSmall
@ DuplicateSerialNumber
@ ContainerIdLengthTooSmall
@ CompanionInterruptBurstPacket
@ Usb20CapLengthTooLarge
@ CompanionBulkBytesPerInterval
@ Hub30RemovableReserved
@ BillboardLengthTooSmall
@ StringLengthTooLarge
@ ConfigSubsetTotalTooSmall
@ ConfigSubsetTotalTooLarge
@ HeaderLengthTooSmall
@ CompanionIsochBurstPacket
@ ConfigMissingSspCompanion
@ StringBufferTooSmall
@ MsOs20RegistryDataZero
@ EndpointLengthTooSmall
@ MsOs20ResumeRecovery
@ MsOs20TotalLengthMismatch
@ MsOs20MultipleModelId
@ SerialNumberBadCharacter
@ ControlAttributesReserved
@ HeaderBufferTooSmall
@ Hub30DecodeLatencyReserved
@ Hub20PowerMaskNotOnes
@ CompanionNotSuperSpeed
@ SspCompanionReserved
@ Hub20CharacteristicsReserved
@ MsOsExtConfigVersion
@ CapMultipleSuperSpeedPlus
@ SspAttrSymmetricMismatch
@ CapMultipleSuperSpeed
@ MsOs20MultipleCompatibleId
@ MsOs20VersionMismatch
@ EndpointBufferTooSmall
@ CompanionIsochBytesNotOne
@ SspCapLengthTooSmall
@ ConfigBufferTooSmallForInterfaces
@ MsOs20DuplicateVersion

Function Documentation

◆ _In_reads_bytes_()

_In_reads_bytes_ ( Length  )

◆ _Inout_updates_bytes_()

_Inout_updates_bytes_ ( Length  )

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  ) const

Whole BOS set. Outputs are filled even on FALSE, and a Billboard capability with bLength 40 or 44 gets its bLength fixed in the buffer.

MS OS 2.0 descriptor set. SetInfo is the entry the BOS walk selected; on failure Info->Flags is cleared.

◆ C_ASSERT() [1/9]

C_ASSERT ( sizeof(HubMsOs20CompatibleId)  = =20)

◆ C_ASSERT() [2/9]

C_ASSERT ( sizeof(HubMsOs20SetHeader)  = =10)

◆ C_ASSERT() [3/9]

C_ASSERT ( sizeof(HubMsOs20SetInfo)  = =8)

◆ C_ASSERT() [4/9]

C_ASSERT ( sizeof(HubMsOs20Subset)  = =8)

◆ C_ASSERT() [5/9]

C_ASSERT ( sizeof(HubMsOsContainerId)  = =24)

◆ C_ASSERT() [6/9]

C_ASSERT ( sizeof(HubMsOsExtConfig)  = =40)

◆ C_ASSERT() [7/9]

C_ASSERT ( sizeof(HubMsOsExtConfigHeader)  = =16)

◆ C_ASSERT() [8/9]

C_ASSERT ( sizeof(HubMsOsString)  = =18)

◆ C_ASSERT() [9/9]

C_ASSERT ( sizeof(HubPlatformFeatures)  = =26)

◆ HubDescCheck20Hub()

BOOLEAN NTAPI HubDescCheck20Hub ( _In_ const HubDescContext *  Context,
_In_reads_bytes_opt_(Length) PUSB_HUB_DESCRIPTOR  Descriptor,
_In_ ULONG  Length 
)

USB 2.0 hub descriptor. Hub ParseHubDescriptor for Full and High speed hubs.

Definition at line 3198 of file desccheck.cpp.

3202{
3204 ULONG Fixed = FIELD_OFFSET(USB_HUB_DESCRIPTOR, bRemoveAndPowerMask);
3205 ULONG Ports;
3206 ULONG RemovableBytes;
3207 ULONG PowerBytes;
3209 ULONG Used;
3210 UCHAR Spare;
3211 ULONG i;
3212
3213 if (Descriptor == NULL)
3214 {
3216 return FALSE;
3217 }
3218
3219 if (Length < Fixed)
3220 {
3222 return FALSE;
3223 }
3224
3225 Ports = Descriptor->bNumberOfPorts;
3226 if (Ports == 0)
3228
3229 /* DeviceRemovable has a reserved bit 0 plus one bit per port; the power mask is legacy */
3230 RemovableBytes = (Ports + 8) / 8;
3231 PowerBytes = (Ports + 7) / 8;
3232 Expected = Fixed + RemovableBytes + PowerBytes;
3233
3234 if (Descriptor->bDescriptorLength < Expected)
3236
3237 if (Descriptor->bDescriptorLength > Expected)
3239
3240 if (Descriptor->bDescriptorType != USB_20_HUB_DESCRIPTOR_TYPE)
3242
3243 if (Descriptor->wHubCharacteristics & 0x0002)
3245
3246 if (Descriptor->wHubCharacteristics & 0xFF00)
3248
3249 if (Descriptor->bRemoveAndPowerMask[0] & 0x01)
3251
3252 /* Bits past the last port in the last DeviceRemovable byte */
3253 Used = (Ports + 1) % 8;
3254 if (Used != 0)
3255 {
3256 Spare = (UCHAR)(0xFF << Used);
3257 if (Descriptor->bRemoveAndPowerMask[RemovableBytes - 1] & Spare)
3259 }
3260
3261 for (i = 0; i < PowerBytes; i++)
3262 {
3263 if (Descriptor->bRemoveAndPowerMask[RemovableBytes + i] != 0xFF)
3265 }
3266
3267 return Result == Verdict::Ok;
3268}
BOOLEAN Expected
Verdict
Definition: desccheck.cpp:15
@ Versioned
@ NewRule
@ Always
@ Reserved
Verdict Result
Definition: desccheck.cpp:2226
VOID NTAPI HubDescLog(_In_ const HubDescContext *Context, _In_ HubDescCode Code, _In_ BOOLEAN Warning)
Definition: desccheck.cpp:383
return FALSE
Definition: desccheck.cpp:3191
static VOID NTAPI Note(_In_ const HubDescContext *Ctx, _Inout_ Verdict *Result, _In_ HubDescCode Code, _In_ Gate Kind)
Definition: desccheck.cpp:463
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static PS2_PORT Ports[PS2_PORTS]
Definition: ps2.c:52
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
#define USB_20_HUB_DESCRIPTOR_TYPE
Definition: usb200.h:280
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by HubCheckUsb2HubDescriptor().

◆ HubDescCheck30Hub()

BOOLEAN NTAPI HubDescCheck30Hub ( _In_ const HubDescContext *  Context,
_In_reads_bytes_opt_(Length) PUSB_30_HUB_DESCRIPTOR  Descriptor,
_In_ ULONG  Length 
)

USB 3.0 hub descriptor. Hub ParseHubDescriptor for SuperSpeed hubs.

Definition at line 3272 of file desccheck.cpp.

3276{
3278 ULONG Ports;
3279 ULONG Spare;
3280
3281 if (Descriptor == NULL)
3282 {
3283 DPRINT1("Hub %p has no SuperSpeed hub descriptor\n", Context->LogContext);
3284 return FALSE;
3285 }
3286
3287 if (Length < sizeof(USB_COMMON_DESCRIPTOR))
3288 {
3290 return FALSE;
3291 }
3292
3293 if (Descriptor->bLength < sizeof(*Descriptor))
3295
3296 if (Descriptor->bLength > sizeof(*Descriptor))
3298
3299 if (Descriptor->bDescriptorType != USB_30_HUB_DESCRIPTOR_TYPE)
3301
3302 Ports = Descriptor->bNumberOfPorts;
3303 if (Ports > 15)
3305
3306 if (Ports == 0)
3308
3309 if (Descriptor->wHubCharacteristics & 0x0002)
3311
3312 if (Descriptor->wHubCharacteristics & 0xFFE0)
3314
3315 if (Descriptor->bHubHdrDecLat >= 11)
3317
3318 if (Descriptor->DeviceRemovable & 0x0001)
3320
3321 /* Bits above the last port; with 15 or more ports none are left */
3322 Spare = (Ports + 1 < 16) ? (0xFFFFUL << (Ports + 1)) & 0xFFFF : 0;
3323 if (Descriptor->DeviceRemovable & Spare)
3325
3326 return Result == Verdict::Ok;
3327}
#define DPRINT1
Definition: precomp.h:8
#define USB_30_HUB_DESCRIPTOR_TYPE
Definition: usb200.h:281

Referenced by HubCheckUsb3HubDescriptor().

◆ HubDescCheckBosHeader()

BOOLEAN NTAPI HubDescCheckBosHeader ( _In_ const HubDescContext *  Context,
_In_reads_bytes_opt_(Length) PUSB_BOS_DESCRIPTOR  Descriptor,
_In_ ULONG  Length 
)

The 5 byte BOS header on its own. BosHeaderValid.

Definition at line 2197 of file desccheck.cpp.

2201{
2203 PUCHAR End;
2204 ULONG Advance;
2205
2207 return Result == Verdict::Ok;
2208}
PUCHAR End
Definition: desccheck.cpp:2229
static VOID NTAPI CheckBosFixedPart(_In_ const HubDescContext *Ctx, _In_opt_ PUSB_BOS_DESCRIPTOR Bos, _In_ ULONG Length, _Out_ PUCHAR *End, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:1466
ULONG Advance
Definition: desccheck.cpp:2231
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by DeviceMachine::BosHeaderValid().

◆ HubDescCheckConfiguration()

BOOLEAN NTAPI HubDescCheckConfiguration ( _In_ const HubDescContext *  Context,
_In_reads_bytes_opt_(Length) PUSB_CONFIGURATION_DESCRIPTOR  Descriptor,
_In_ ULONG  Length,
_Out_opt_ PBOOLEAN  SupportsStreams 
)

Whole configuration descriptor set. SupportsStreams reflects the last companion.

Definition at line 1237 of file desccheck.cpp.

1242{
1245 BOOLEAN Valid = TRUE;
1246 PUCHAR Cursor;
1247
1248 if (SupportsStreams != NULL)
1250
1251 if (Descriptor == NULL)
1252 {
1254 return FALSE;
1255 }
1256
1257 if (Length < sizeof(*Descriptor))
1258 {
1260 return FALSE;
1261 }
1262
1263 RtlZeroMemory(&Walk, sizeof(Walk));
1264 Walk.Ctx = Context;
1267 Walk.End = Walk.Base + Length;
1268 Walk.Config = Descriptor;
1269 Walk.SupportsStreams = SupportsStreams;
1270
1273 if (Result == Verdict::Fatal)
1274 return FALSE;
1275
1276 if (Result != Verdict::Ok)
1277 Valid = FALSE;
1278
1279 /* QUIRK: the walk starts after the 9 fixed bytes even when bLength is larger */
1280 Cursor = Walk.Base + sizeof(*Descriptor);
1281 while (Cursor < Walk.End)
1282 {
1284 ULONG Advance;
1285
1288 if (Result == Verdict::Fatal)
1289 return FALSE;
1290
1291 /* Compatibility mode lets header findings pass here (a Cypress mouse needs it) */
1292 if (Result == Verdict::Failed && !Context->Win8Behavior)
1293 Valid = FALSE;
1294
1296 switch (Desc->bDescriptorType)
1297 {
1299 Walk.WantCompanion = FALSE;
1300 Walk.WantSspCompanion = FALSE;
1302 break;
1303
1305 Walk.WantSspCompanion = FALSE;
1307 break;
1308
1310 Walk.WantSspCompanion = FALSE;
1312 break;
1313
1317 &Advance,
1318 &Result);
1319 break;
1320
1322 Walk.WantCompanion = FALSE;
1323 Walk.WantSspCompanion = FALSE;
1325 break;
1326
1327 default:
1328 Walk.WantCompanion = FALSE;
1329 Walk.WantSspCompanion = FALSE;
1330 break;
1331 }
1332
1333 if (Result == Verdict::Fatal)
1334 return FALSE;
1335
1336 if (Result == Verdict::Failed)
1337 Valid = FALSE;
1338
1339 /* Zero padding at the end of the set is tolerated */
1340 if (Desc->bLength == 0)
1341 break;
1342
1343 Cursor += Advance;
1344 }
1345
1348 if (Result != Verdict::Ok)
1349 Valid = FALSE;
1350
1351 /* No validation code for this one */
1352 if (Walk.InterfacesFound != Descriptor->bNumInterfaces && GateApplies(Context, Gate::Legacy))
1353 {
1354 DPRINT1("%s %p configuration has %lu interfaces, bNumInterfaces %u\n",
1355 Context->ForHub ? "Hub" : "Device", Context->LogContext,
1356 Walk.InterfacesFound, Descriptor->bNumInterfaces);
1357 Valid = FALSE;
1358 }
1359
1360 return Valid;
1361}
unsigned char BOOLEAN
Definition: actypes.h:127
@ Legacy
static VOID NTAPI CheckIad(_Inout_ ConfigWalk *Walk, _In_ PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR Desc, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:1193
static VOID NTAPI CheckInterface(_Inout_ ConfigWalk *Walk, _In_ PUSB_INTERFACE_DESCRIPTOR Desc, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:735
static VOID NTAPI CheckConfigFixedPart(_Inout_ ConfigWalk *Walk, _Inout_ Verdict *Result)
Definition: desccheck.cpp:636
static VOID NTAPI CheckSspCompanion(_Inout_ ConfigWalk *Walk, _In_ PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR Desc, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:1141
static VOID NTAPI CheckHeader(_In_ const HubDescContext *Ctx, _In_ PUCHAR Base, _In_ ULONG BufferLength, _In_ PUCHAR End, _In_ PUSB_COMMON_DESCRIPTOR Desc, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:591
static BOOLEAN NTAPI GateApplies(_In_ const HubDescContext *Ctx, _In_ Gate Kind)
Definition: desccheck.cpp:418
TRUE
Definition: desccheck.cpp:2267
static VOID NTAPI CheckCompanion(_Inout_ ConfigWalk *Walk, _In_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Desc, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:1007
_In_ ULONG Length
Definition: desccheck.cpp:2216
PUCHAR Cursor
Definition: desccheck.cpp:2228
static VOID NTAPI CheckPreviousInterface(_Inout_ ConfigWalk *Walk, _Inout_ Verdict *Result)
Definition: desccheck.cpp:712
BosWalk Walk
Definition: desccheck.cpp:2225
BOOLEAN Valid
Definition: desccheck.cpp:2227
static VOID NTAPI CheckEndpoint(_Inout_ ConfigWalk *Walk, _In_ PUSB_ENDPOINT_DESCRIPTOR Desc, _Out_ PULONG Advance, _Inout_ Verdict *Result)
Definition: desccheck.cpp:945
PUCHAR Base
Definition: desccheck.cpp:78
const HubDescContext * Ctx
Definition: desccheck.cpp:77
ULONG BufferLength
Definition: desccheck.cpp:79
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define USB_ENDPOINT_DESCRIPTOR_TYPE
Definition: usb100.h:53
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE
Definition: usb200.h:118
#define USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR_TYPE
Definition: usb300.h:20
#define USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE
Definition: usb300.h:19

Referenced by DeviceMachine::ConfigDescriptorValid(), HubCheckConfigDescriptor(), and HubValidateHubConfiguration().

◆ HubDescCheckDevice()

BOOLEAN NTAPI HubDescCheckDevice ( _In_ const HubDescContext *  Context,
_In_reads_bytes_opt_(Length) PUSB_DEVICE_DESCRIPTOR  Descriptor,
_In_ ULONG  Length,
_Inout_opt_ PBOOLEAN  IsBillboard 
)

Device descriptor. Length is the bytes returned; IsBillboard is only ever set TRUE.

Definition at line 1367 of file desccheck.cpp.

1372{
1375 ULONG Packet0;
1376 ULONG i;
1377
1378 if (Descriptor == NULL)
1379 {
1381 return FALSE;
1382 }
1383
1384 if (Length < sizeof(USB_COMMON_DESCRIPTOR))
1385 {
1387 return FALSE;
1388 }
1389
1390 if (Descriptor->bLength < sizeof(*Descriptor))
1392
1393 if (Descriptor->bDescriptorType != USB_DEVICE_DESCRIPTOR_TYPE)
1395
1396 if (Length < 8)
1397 {
1399 return FALSE;
1400 }
1401
1402 /* Skipped on the 8 byte read, where these bytes are stale */
1404 {
1405 for (i = 0; i < 16; i += 4)
1406 {
1407 if (((Descriptor->bcdDevice >> i) & 0xF) > 9)
1408 {
1410 break;
1411 }
1412 }
1413 }
1414
1415 /* The gates use the context version; this one is the descriptor's own */
1416 Version = Descriptor->bcdUSB;
1417 if (Descriptor->bDeviceClass == USB_DEVICE_CLASS_BILLBOARD &&
1418 Descriptor->bDeviceSubClass == 0 &&
1419 Descriptor->bDeviceProtocol == 0)
1420 {
1421 if (Version > 0x0200 && Version < 0x0300)
1422 {
1423 if (IsBillboard != NULL)
1424 *IsBillboard = TRUE;
1425 }
1426 else
1427 {
1428 /* QUIRK: a USB 3.x Billboard device fails enumeration */
1430 }
1431 }
1432
1433 Packet0 = Descriptor->bMaxPacketSize0;
1434 switch (Context->Speed)
1435 {
1436 /* QUIRK: low and high speed can log the code twice */
1437 case UsbLowSpeed:
1438 case UsbHighSpeed:
1439 if (Packet0 != (Context->Speed == UsbLowSpeed ? 8UL : 64UL))
1440 {
1442 if (!IsSmallPacket(Packet0))
1444 }
1445 break;
1446
1447 case UsbFullSpeed:
1448 if (!IsSmallPacket(Packet0))
1450 break;
1451
1452 case UsbSuperSpeed:
1453 if (Packet0 != 9)
1455 break;
1456 }
1457
1458 return Result == Verdict::Ok;
1459}
@ Warning
static BOOLEAN NTAPI IsSmallPacket(_In_ ULONG Size)
Definition: desccheck.cpp:569
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
unsigned short USHORT
Definition: pedump.c:61
#define USB_DEVICE_DESCRIPTOR_TYPE
Definition: usb100.h:49
@ UsbSuperSpeed
Definition: usb200.h:45
@ UsbHighSpeed
Definition: usb200.h:44
@ UsbLowSpeed
Definition: usb200.h:42
@ UsbFullSpeed
Definition: usb200.h:43
#define USB_DEVICE_CLASS_BILLBOARD
Definition: usb200.h:308
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

Referenced by DeviceMachine::DeviceDescriptorValid(), and DeviceMachine::FirstDescriptorValid().

◆ HubDescCheckMsOsContainerId()

BOOLEAN NTAPI HubDescCheckMsOsContainerId ( _In_ const HubDescContext *  Context,
_In_reads_bytes_(Length) const HubMsOsContainerId *  Descriptor,
_In_ ULONG  Length 
)

MS OS 1.0 container ID. ContainerIdKnown.

Definition at line 2541 of file desccheck.cpp.

2545{
2546 if (Length != sizeof(*Descriptor))
2547 {
2549 return FALSE;
2550 }
2551
2552 if (IsAllZero(Descriptor->ContainerId, sizeof(Descriptor->ContainerId)))
2553 {
2555 return FALSE;
2556 }
2557
2558 return TRUE;
2559}
static BOOLEAN NTAPI IsAllZero(_In_reads_bytes_(Length) const VOID *Buffer, _In_ ULONG Length)
Definition: desccheck.cpp:549

Referenced by DeviceMachine::ContainerIdKnown().

◆ HubDescCheckMsOsContainerIdHeader()

BOOLEAN NTAPI HubDescCheckMsOsContainerIdHeader ( _In_ const HubDescContext *  Context,
_In_reads_bytes_(Length) const HubMsOsHeader *  Descriptor,
_In_ ULONG  Length 
)

MS OS 1.0 container ID header. ContainerIdHeaderValid.

Definition at line 2505 of file desccheck.cpp.

2509{
2510 BOOLEAN Valid = TRUE;
2511
2512 if (Length != sizeof(*Descriptor))
2513 {
2515 return FALSE;
2516 }
2517
2518 if (Descriptor->bcdVersion != 0x0100)
2519 {
2521 Valid = FALSE;
2522 }
2523
2524 if (Descriptor->wIndex != 6)
2525 {
2527 Valid = FALSE;
2528 }
2529
2530 if (Descriptor->dwLength != sizeof(HubMsOsContainerId))
2531 {
2533 Valid = FALSE;
2534 }
2535
2536 return Valid;
2537}

Referenced by DeviceMachine::ContainerIdHeaderValid().

◆ HubDescCheckMsOsExtConfig()

BOOLEAN NTAPI HubDescCheckMsOsExtConfig ( _In_ const HubDescContext *  Context,
_In_reads_bytes_(sizeof(HubMsOsExtConfig)) const HubMsOsExtConfig *  Descriptor,
_In_ ULONG  Length 
)

MS OS 1.0 extended configuration. The buffer must hold the 40 bytes the validated header promised, whatever Length says.

Definition at line 2606 of file desccheck.cpp.

2610{
2611 const HubMsOsExtConfigFunction* Function = &Descriptor->Function[0];
2613
2614 if (Length != Descriptor->Header.dwLength)
2616
2617 /* Interface numbers are not compared with the configuration */
2618 if (!IsMsOs10IdValid(Function->CompatibleId))
2619 {
2621 return FALSE;
2622 }
2623
2624 if (!IsMsOs10IdValid(Function->SubCompatibleId))
2625 {
2627 return FALSE;
2628 }
2629
2630 return Result == Verdict::Ok;
2631}
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
static BOOLEAN NTAPI IsMsOs10IdValid(_In_reads_(8) const UCHAR *Id)
Definition: desccheck.cpp:2471

Referenced by DeviceMachine::ExtendedConfigValid().

◆ HubDescCheckMsOsExtConfigHeader()

BOOLEAN NTAPI HubDescCheckMsOsExtConfigHeader ( _In_ const HubDescContext *  Context,
_In_reads_bytes_(Length) const HubMsOsExtConfigHeader *  Descriptor,
_In_ ULONG  Length 
)

MS OS 1.0 extended configuration header. ExtendedConfigHeaderValid.

Definition at line 2563 of file desccheck.cpp.

2567{
2568 BOOLEAN Valid = TRUE;
2569
2570 if (Length != sizeof(*Descriptor))
2571 {
2573 return FALSE;
2574 }
2575
2576 if (Descriptor->bcdVersion != 0x0100)
2577 {
2579 Valid = FALSE;
2580 }
2581
2582 if (Descriptor->wIndex != 4)
2583 {
2585 Valid = FALSE;
2586 }
2587
2588 /* Only single function devices are supported */
2589 if (Descriptor->bCount != 1)
2590 {
2592 return FALSE;
2593 }
2594
2595 if (Descriptor->dwLength != sizeof(*Descriptor) + Descriptor->bCount * sizeof(HubMsOsExtConfigFunction))
2596 {
2598 return FALSE;
2599 }
2600
2601 return Valid;
2602}

Referenced by DeviceMachine::ExtendedConfigHeaderValid().

◆ HubDescCheckMsOsString()

BOOLEAN NTAPI HubDescCheckMsOsString ( _In_ const HubDescContext *  Context,
_In_ const HubMsOsString *  Descriptor 
)

MS OS string descriptor (index 0xEE): signature only. MsOsDescriptorValid.

Definition at line 2490 of file desccheck.cpp.

2493{
2494 static const WCHAR Expected[7] = { 'M', 'S', 'F', 'T', '1', '0', '0' };
2495
2496 if (RtlEqualMemory(Descriptor->Signature, Expected, sizeof(Expected)))
2497 return TRUE;
2498
2499 DPRINT1("Device %p MS OS string has the wrong signature\n", Context->LogContext);
2500 return FALSE;
2501}
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
short WCHAR
Definition: pedump.c:58

Referenced by DeviceMachine::MsOsDescriptorValid().

◆ HubDescCheckSerialNumber()

BOOLEAN NTAPI HubDescCheckSerialNumber ( _In_ const HubDescContext *  Context,
_In_reads_bytes_ *Length PUSB_STRING_DESCRIPTOR  Descriptor,
_Inout_ PULONG  Length 
)

Serial number string. Length is the bytes returned on entry and the string bytes plus room for a NUL on success.

Definition at line 2418 of file desccheck.cpp.

2422{
2423 ULONG Adjusted;
2424 ULONG Chars;
2425 ULONG i;
2426 BOOLEAN Valid = TRUE;
2427
2428 if (CheckStringCore(Context, Descriptor, *Length, &Adjusted) != Verdict::Ok)
2429 return FALSE;
2430
2431 *Length = Descriptor->bLength - sizeof(USB_COMMON_DESCRIPTOR);
2432 Chars = *Length / sizeof(WCHAR);
2433 for (i = 0; i < Chars; i++)
2434 {
2435 WCHAR Ch = Descriptor->bString[i];
2436
2437 if (Ch == 0)
2438 break;
2439
2440 /* Printable ASCII only, and no comma since it separates instance ID parts */
2441 if (Ch < L' ' || Ch > 0x7F || Ch == L',')
2442 {
2444 Valid = FALSE;
2445 }
2446 }
2447
2448 if (!Valid)
2449 return FALSE;
2450
2451 /* Room for a terminating NUL */
2452 *Length += sizeof(WCHAR);
2453 return TRUE;
2454}
static Verdict NTAPI CheckStringCore(_In_ const HubDescContext *Ctx, _In_reads_bytes_(Length) PUSB_STRING_DESCRIPTOR Desc, _In_ ULONG Length, _Out_ PULONG Adjusted)
Definition: desccheck.cpp:2354
#define L(x)
Definition: resources.c:13
ULONG Chars
Definition: hubtunnel.cpp:833
struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR

Referenced by DeviceMachine::SerialNumberValid().

◆ HubDescCheckString()

BOOLEAN NTAPI HubDescCheckString ( _In_ const HubDescContext *  Context,
_In_reads_bytes_(Length) PUSB_STRING_DESCRIPTOR  Descriptor,
_In_ ULONG  Length,
_Out_opt_ PULONG  AdjustedLength 
)

String descriptor. AdjustedLength is the usable byte count.

Definition at line 2400 of file desccheck.cpp.

2405{
2406 ULONG Adjusted;
2408
2410 if (AdjustedLength != NULL)
2411 *AdjustedLength = Adjusted;
2412
2413 return Result == Verdict::Ok;
2414}

Referenced by DeviceMachine::AltModeStringValid(), DeviceMachine::BillboardStringValid(), and HubCacheString().

◆ HubDescCodeName()

PCSTR NTAPI HubDescCodeName ( _In_ HubDescCode  Code)

Name of a finding for debug prints.

Definition at line 128 of file desccheck.cpp.

130{
131 switch (Code)
132 {
373
374 default:
375 return "Unknown";
376 }
377}
#define HUB_DESC_NAME(Code)
Definition: desccheck.cpp:124
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1707

Referenced by HubDescLog(), and HubLogHubFinding().

◆ HubDescFind()

PUSB_COMMON_DESCRIPTOR NTAPI HubDescFind ( _In_reads_bytes_(TotalLength) PVOID  Buffer,
_In_ ULONG  TotalLength,
_In_ PVOID  Position,
_In_ UCHAR  Type 
)

First descriptor of Type at or after Position, or NULL. Stops on a zero bLength.

Definition at line 3333 of file desccheck.cpp.

3338{
3340 PUCHAR At = (PUCHAR)Position;
3341
3342 /* bLength is trusted; only the two header bytes are kept inside the buffer */
3343 while (At + sizeof(USB_COMMON_DESCRIPTOR) <= End)
3344 {
3346
3347 if (Desc->bLength == 0)
3348 return NULL;
3349
3350 if (Desc->bDescriptorType == Type)
3351 return Desc;
3352
3353 At += Desc->bLength;
3354 }
3355
3356 return NULL;
3357}
Type
Definition: Type.h:7
Definition: bufpool.h:45
static COORD Position
Definition: mouse.c:34
_In_ ULONG TotalLength
Definition: usbdlib.h:185

Referenced by HubDescFindInterface().

◆ HubDescFindInterface()

PUSB_INTERFACE_DESCRIPTOR NTAPI HubDescFindInterface ( _In_ PUSB_CONFIGURATION_DESCRIPTOR  Config,
_In_ PVOID  Position,
_In_ LONG  Number,
_In_ LONG  Alternate,
_In_ LONG  Class,
_In_ LONG  SubClass,
_In_ LONG  Protocol,
_Out_opt_ PBOOLEAN  HasAlternates 
)

First matching interface at or after Position; -1 matches anything. HasAlternates is TRUE when that interface number has other settings.

Definition at line 3371 of file desccheck.cpp.

3380{
3383 ULONG SameNumber = 0;
3384 PUCHAR At = (PUCHAR)Position;
3385
3386 if (HasAlternates != NULL)
3387 *HasAlternates = FALSE;
3388
3389 if (Config->bLength < sizeof(*Config) ||
3390 Config->bDescriptorType != USB_CONFIGURATION_DESCRIPTOR_TYPE ||
3391 Config->wTotalLength < sizeof(*Config))
3392 {
3393 return NULL;
3394 }
3395
3396 for (;;)
3397 {
3399 if (Match == NULL)
3400 return NULL;
3401
3402 /* Only the 2 byte header is known to be inside wTotalLength */
3403 if ((PUCHAR)Match + sizeof(*Match) > (PUCHAR)Config + Config->wTotalLength)
3404 return NULL;
3405
3406 At = (PUCHAR)Match + Match->bLength;
3407
3408 /* Every interface with the requested number counts, matching or not */
3409 if (Number != -1 && Match->bInterfaceNumber == Number)
3410 SameNumber++;
3411
3412 if (FieldMatches(Number, Match->bInterfaceNumber) &&
3413 FieldMatches(Alternate, Match->bAlternateSetting) &&
3415 FieldMatches(SubClass, Match->bInterfaceSubClass) &&
3417 {
3418 break;
3419 }
3420 }
3421
3422 if (HasAlternates == NULL)
3423 return Match;
3424
3425 /* QUIRK: only the very next interface is looked at, and never for a wildcard number */
3426 if (SameNumber <= 1)
3427 {
3429 if (Next != NULL && Number != -1 &&
3430 (PUCHAR)Next + sizeof(*Next) <= (PUCHAR)Config + Config->wTotalLength &&
3431 Next->bInterfaceNumber == Number)
3432 SameNumber++;
3433 }
3434
3435 if (SameNumber > 1)
3436 *HasAlternates = TRUE;
3437
3438 return Match;
3439}
if(Length< sizeof(*Descriptor))
Definition: desccheck.cpp:2245
static BOOLEAN NTAPI FieldMatches(_In_ LONG Wanted, _In_ UCHAR Actual)
Definition: desccheck.cpp:3362
PUSB_COMMON_DESCRIPTOR NTAPI HubDescFind(_In_reads_bytes_(TotalLength) PVOID Buffer, _In_ ULONG TotalLength, _In_ PVOID Position, _In_ UCHAR Type)
Definition: desccheck.cpp:3333
_In_ ULONG Number
Definition: haltypes.h:1940
PACPI_METHOD_ARGUMENT Next
Definition: slotdev.cpp:96
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR

Referenced by HubPickCompatIdInterface(), DeviceMachine::PrepareConfigLists(), and DeviceMachine::PrepareInterfaceLists().

◆ HubDescInitDeviceContext()

VOID NTAPI HubDescInitDeviceContext ( _Out_ HubDescContext *  Context,
_In_ USHORT  BcdUsb,
_In_ USB_DEVICE_SPEED  Speed,
_In_ BOOLEAN  Win8Behavior,
_In_ ULONG  SspIsochBurstCount,
_In_opt_ PULONG  Bitmap 
)

Device context: reads the global strictness flags. Set Log and LogContext afterwards.

Definition at line 91 of file desccheck.cpp.

98{
99 RtlZeroMemory(Context, sizeof(*Context));
100 Context->BcdUsb = BcdUsb;
101 Context->Speed = Speed;
105 Context->Win8Behavior = Win8Behavior;
106 Context->SspIsochBurstCount = SspIsochBurstCount;
107 Context->Bitmap = Bitmap;
108}
HubDriverState HubDriver
Definition: entry.cpp:13
@ StrictDescriptorChecks
@ EnableExtendedValidation
@ CheckReservedFields
BOOLEAN HasFlag(_In_ HubGlobal Flag) const
Definition: hubdriver.h:119

Referenced by HubCheckConfigDescriptor(), HubDeviceDescContext(), and DeviceMachine::SerialNumberValid().

◆ HubDescInitHubContext()

VOID NTAPI HubDescInitHubContext ( _Out_ HubDescContext *  Context,
_In_ USHORT  BcdUsb,
_In_ USB_DEVICE_SPEED  Speed 
)

Hub context: version and speed only, global flags are never applied.

Definition at line 112 of file desccheck.cpp.

116{
117 RtlZeroMemory(Context, sizeof(*Context));
118 Context->BcdUsb = BcdUsb;
119 Context->Speed = Speed;
120 Context->ForHub = TRUE;
121}

Referenced by HubBuildDescContext().

◆ HubDescLog()

VOID NTAPI HubDescLog ( _In_ const HubDescContext *  Context,
_In_ HubDescCode  Code,
_In_ BOOLEAN  Warning 
)

Records one finding: sets the bitmap bit and calls the log hook.

Definition at line 383 of file desccheck.cpp.

387{
388 ULONG Bit = (ULONG)Code;
389
390 /* Warnings set the same bit as errors */
391 if (Context->Bitmap != NULL && Bit < HUB_DESC_BITMAP_ULONGS * 32)
392 Context->Bitmap[Bit / 32] |= 1UL << (Bit % 32);
393
394 if (Context->Log != NULL)
395 {
396 Context->Log(Context->LogContext, Code, Warning);
397 return;
398 }
399
400 /* Warning also covers findings whose gate does not apply to this device */
401 if (Warning)
402 {
403 DPRINT("%s %p descriptor check %s (%lu) ignored\n",
404 Context->ForHub ? "Hub" : "Device", Context->LogContext, HubDescCodeName(Code), Bit);
405 }
406 else
407 {
408 DPRINT1("%s %p descriptor check %s (%lu) failed\n",
409 Context->ForHub ? "Hub" : "Device", Context->LogContext, HubDescCodeName(Code), Bit);
410 }
411}
PCSTR NTAPI HubDescCodeName(_In_ HubDescCode Code)
Definition: desccheck.cpp:128
#define HUB_DESC_BITMAP_ULONGS
Definition: desccheck.h:263
#define DPRINT
Definition: sndvol32.h:73

Referenced by CheckBillboardCap(), CheckHeader(), CheckMsOs20Ccgp(), CheckMsOs20CompatibleId(), CheckMsOs20Id(), CheckMsOs20ModelId(), CheckMsOs20Platform(), CheckMsOs20Registry(), CheckMsOs20ResumeTime(), CheckMsOs20SetHeader(), CheckMsOs20Subset(), DeviceMachine::ConfigDescriptorValid(), HubDescCheck20Hub(), HubDescCheck30Hub(), HubDescCheckConfiguration(), HubDescCheckDevice(), HubDescCheckMsOsContainerId(), HubDescCheckMsOsContainerIdHeader(), HubDescCheckMsOsExtConfig(), HubDescCheckMsOsExtConfigHeader(), HubDescCheckSerialNumber(), HubLogConfigTotalLengthMismatch(), if(), Note(), NoteFatal(), WalkMsOs20Set(), and while().

◆ HubDescNextMsOs20()

BOOLEAN NTAPI HubDescNextMsOs20 ( _In_ PUCHAR  End,
_Inout_ HubMsOs20Common **  Current 
)

Steps to the next MS OS 2.0 descriptor, or NULL at End. FALSE when a length runs past End.

Definition at line 2647 of file desccheck.cpp.

2650{
2651 HubMsOs20Common* Desc = *Current;
2652 PUCHAR At = (PUCHAR)Desc;
2653 PUCHAR Next;
2654
2655 *Current = NULL;
2656
2657 /* The current descriptor must itself fit before End */
2658 if (At + Desc->wLength > End)
2659 return FALSE;
2660
2663 {
2664 HubMsOs20Subset* Subset = (HubMsOs20Subset*)Desc;
2665
2666 if (Subset->wLength < sizeof(*Subset) || Subset->wTotalLength < sizeof(*Subset) + sizeof(*Desc))
2667 return FALSE;
2668
2669 Next = At + Subset->wTotalLength;
2670 }
2671 else
2672 {
2673 if (Desc->wLength < sizeof(*Desc))
2674 return FALSE;
2675
2676 Next = At + Desc->wLength;
2677 }
2678
2679 if (Next == End)
2680 return TRUE;
2681
2682 if (Next > End || Next + sizeof(*Desc) > End)
2683 return FALSE;
2684
2685 if (Next + ((HubMsOs20Common*)Next)->wLength > End)
2686 return FALSE;
2687
2689 return TRUE;
2690}
#define HUB_MSOS20_TYPE_FUNCTION_SUBSET
Definition: desccheck.cpp:2638
#define HUB_MSOS20_TYPE_CONFIG_SUBSET
Definition: desccheck.cpp:2637
HubUxdSettings Current
USHORT wLength
Definition: desccheck.h:347
USHORT wDescriptorType
Definition: desccheck.h:348
USHORT wTotalLength
Definition: desccheck.h:366
USHORT wLength
Definition: desccheck.h:362

Referenced by CheckMsOs20Subset(), DeviceMachine::InstallMsOs20Values(), and WalkMsOs20Set().

Variable Documentation

◆ DeviceFlags

◆ Info

◆ Length

Definition at line 582 of file desccheck.h.

◆ Lpm

◆ LtmCapable

◆ SetInfo

Definition at line 663 of file desccheck.h.

◆ U1ExitLatency

Definition at line 584 of file desccheck.h.

◆ U2ExitLatency

Definition at line 585 of file desccheck.h.