ReactOS 0.4.15-dev-7842-g558ab78
usbutil.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 usbutil.cpp
8
9Abstract:
10
11
12Author:
13
14Environment:
15
16 Both kernel and user mode
17
18Revision History:
19
20--*/
21
22#include "fxusbpch.hpp"
23
24extern "C" {
25#include "UsbUtil.tmh"
26}
27
28VOID
31 __in PURB Urb,
32 __in FX_URB_TYPE FxUrbType,
35 USBD_HANDLE UsbdHandle
36 )
37{
38 FxIrp* irp;
39
40 ASSERT(Urb->UrbHeader.Length >= sizeof(_URB_HEADER));
41
42 irp = Request->GetSubmitFxIrp();
46
47
48
49
50
51 if (FxUrbType == FxUrbTypeUsbdAllocated) {
53 }
54 else {
56 }
57
58 Request->VerifierSetFormatted();
59}
60
63 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
67 __in FX_URB_TYPE FxUrbType,
70 USBD_HANDLE UsbdHandle
71 )
72{
73 FxUsbUrbContext* pContext;
75
76 status = Request->ValidateTarget(Target);
77 if (!NT_SUCCESS(status)) {
79 "FormatUrbRequest: Target %p, Request %p, "
80 "setting target failed, %!STATUS!",
82
83 return status;
84 }
85
86 if (Request->HasContextType(FX_RCT_USB_URB_REQUEST)) {
87 pContext = (FxUsbUrbContext*) Request->GetContext();
88 }
89 else {
90 pContext = new(Target->GetDriverGlobals()) FxUsbUrbContext();
91
92 if (pContext == NULL) {
94 }
95
96 Request->SetContext(pContext);
97 }
98
99 //
100 // Always set the memory after determining the context. This way we can
101 // free a previously referenced memory object if necessary.
102 //
104
105 FxFormatUsbRequest(Request, pContext->m_pUrb, FxUrbType, UsbdHandle);
106
107 return STATUS_SUCCESS;
108}
109
112 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
115 )
116{
117 PUCHAR pCur, pEnd;
118
121
122 while (pCur < pEnd) {
124
125 //
126 // Make sure we can safely deref bLength, bDescriptorType
127 //
128 if (pCur + sizeof(USB_COMMON_DESCRIPTOR) > pEnd) {
130 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
131 "USB Configuration packet contains bad data, expected "
132 "at least %d remaining bytes in config descriptor at "
133 "offset %I64d, total size is %I64d",
136 );
138 }
139
140 //
141 // Make sure bLength is within bounds of the config descriptor
142 //
143 if ((pCur + pDescriptor->bLength) > pEnd) {
145 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
146 "USB Configuration packet contains bad data, descriptor at offset "
147 "%I64d specified bLength %d, only %I64d bytes remaining in config "
148 "descriptor, total size is %I64d",
149 pCur-(PUCHAR)ConfigDescriptor, pDescriptor->bLength, pEnd-pCur,
151 );
153 }
154
155 if (pDescriptor->bLength == 0) {
157 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
158 "USB Configuration packet contains bad data, descriptor at offset "
159 "%I64d contains bLength == 0, this is due to a broken device or driver",
161 );
163 }
164
165
166 pCur += pDescriptor->bLength;
167 }
168
169 return STATUS_SUCCESS;
170}
171
172
176 __in size_t BufferLength,
179 )
180{
182 PUCHAR pCur, pEnd;
183
184 pCur = (PUCHAR) Start;
185 pEnd = ((PUCHAR) Buffer) + BufferLength;
186
187 while (pCur < pEnd) {
188 //
189 // Check to see if the current point is the desired descriptor type
190 //
192
193 if (descriptor->bDescriptorType == DescriptorType) {
194 return descriptor;
195 }
196
197 pCur += descriptor->bLength;
198 }
199
200 //
201 // Iterated to the end and found nothing
202 //
203 return NULL;
204}
205
208 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
211 __in PVOID End,
213 __in size_t SizeToValidate,
215 __in ULONG MaximumNumDescriptorsToValidate
216 )
217/*++
218
219Routine Description:
220 Validates the size of all descriptors within [Start, End] are of the correct
221 size. Correct can either be == or >= SizeToValidate. Furthermore, the caller
222 can specify that validation only occur for the first N descriptors found
223
224Arguments:
225 FxDriverDriverGlobals - client driver globals
226 ConfigDescriptor - the entire config descriptor of the usb device
227 Start - the beginning of the buffer to start to validating descriptors within
228 End - end of the buffer of validation
229 DescriptorType - the type of descriptor to validate
230 SizeToValidate - the size of the descriptor required. Op determines if the
231 check is == or >=
232 Op - the operation, == or >=, to perform for the size validation
233 MaximumNumDescriptorsToValidate - limit of the number of descriptors to validate,
234 if zero, all instances are validated
235
236Return Value:
237 NTSTATUS - !NT_SUCCESS if validation fails, NT_SUCCESS upon success
238
239--*/
240{
241 PUSB_COMMON_DESCRIPTOR pDescriptor = NULL;
242 PVOID pCur = Start;
243 ULONG i = 1;
244
245 while ((pDescriptor = FxUsbFindDescriptorType(Start,
246 (PUCHAR)End-(PUCHAR)Start,
247 pCur,
249 )) != NULL) {
250 //
251 // Make sure bLength is the correct value
252 //
254 if (pDescriptor->bLength != SizeToValidate) {
256 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
257 "USB Configuration packet contains bad data, found descriptor "
258 "#%d of type %d at offset %I64d, expected bLength of %I64d, found %d",
259 i, DescriptorType, ((PUCHAR)pDescriptor)-((PUCHAR)ConfigDescriptor),
260 SizeToValidate, pDescriptor->bLength
261 );
263 }
264 }
265 else if (Op == FxUsbValidateDescriptorOpAtLeast) {
266 if (pDescriptor->bLength < SizeToValidate) {
268 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
269 "USB Configuration packet contains bad data, found descriptor "
270 "#%d of type %d at offset %I64d, expected minimum bLength of %I64d, "
271 "found %d",
272 i, DescriptorType, ((PUCHAR)pDescriptor)-((PUCHAR)ConfigDescriptor),
273 SizeToValidate, pDescriptor->bLength
274 );
276 }
277 }
278
279 //
280 // No need to validate WDF_PTR_ADD_OFFSET(pDescriptor, pDescriptor->bLength) > End
281 // because FxUsbValidateConfigDescriptorHeaders already has done so. End is either
282 // 1) == end of the config descriptor, in which case FxUsbValidateConfigDescriptorHeaders
283 // directly validated bLength
284 // or
285 // 2) End is somewere in the middle of the config descriptor and ASSUMED to be the start
286 // of a common descriptor header. To find that value of End, we would have had to use
287 // pDescriptor->bLength to get to End, we would not overrun
288 //
289
290 //
291 // i is one based, so the current value is Nth descriptor we have validated. If
292 // the caller wants to limit the number of descriptors validated by indicating a
293 // Max > 0, stop with success if the condition is met.
294 //
295 if (MaximumNumDescriptorsToValidate > 0 && i == MaximumNumDescriptorsToValidate) {
296 break;
297 }
298
299 pCur = WDF_PTR_ADD_OFFSET(pDescriptor, pDescriptor->bLength);
300 i++;
301 }
302
303 return STATUS_SUCCESS;
304}
305
311 )
312{
313 PUSB_INTERFACE_DESCRIPTOR found, usbInterface;
314 PVOID pStart;
315
316 found = NULL,
317
318 ASSERT(ConfigDesc->bDescriptorType == USB_CONFIGURATION_DESCRIPTOR_TYPE);
319
320 //
321 // Walk the table of descriptors looking for an interface descriptor with
322 // parameters matching those passed in.
323 //
324 pStart = ConfigDesc;
325
326 do {
327 //
328 // Search for descriptor type 'interface'
329 //
330 usbInterface = (PUSB_INTERFACE_DESCRIPTOR)
331 FxUsbFindDescriptorType(ConfigDesc,
332 ConfigDesc->wTotalLength,
333 pStart,
335
336 //
337 // Check to see if have a matching descriptor by eliminating mismatches
338 //
339 if (usbInterface != NULL) {
340 found = usbInterface;
341
342 if (InterfaceNumber != -1 &&
343 usbInterface->bInterfaceNumber != InterfaceNumber) {
344 found = NULL;
345 }
346
347 if (AlternateSetting != -1 &&
348 usbInterface->bAlternateSetting != AlternateSetting) {
349 found = NULL;
350 }
351
352 pStart = ((PUCHAR)usbInterface) + usbInterface->bLength;
353 }
354
355 if (found != NULL) {
356 break;
357 }
358 } while (usbInterface!= NULL);
359
360 return found;
361}
362
363PURB
365 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
368 __in ULONG DefaultMaxPacketSize
369 )
370{
371 PURB urb;
373 USHORT size;
374
375 //
376 // Our mission here is to construct a URB of the proper
377 // size and format for a select_configuration request.
378 //
379 // This function uses the configuration descriptor as a
380 // reference and builds a URB with interface_information
381 // structures for each interface requested in the interface
382 // list passed in
383 //
384 // NOTE: the config descriptor may contain interfaces that
385 // the caller does not specify in the list -- in this case
386 // the other interfaces will be ignored.
387 //
388
389 //
390 // First figure out how many interfaces we are dealing with
391 //
393
394 //
395 // For a multiple interface configuration, GET_SELECT_CONFIGURATION_REQUEST_SIZE
396 // doesn't work as expected. This is because it subtracts one from totalPipes
397 // to compensate for the embedded USBD_PIPE_INFORMATION in USBD_INTERFACE_INFORMATION.
398 // A multiple interface device will have more then one embedded
399 // USBD_PIPE_INFORMATION in its configuration request and any of these interfaces
400 // might not have any pipes on them.
401 //
402 // To fix, just iterate and compute the size incrementally.
403 //
406
407 while (pList->InterfaceDescriptor != NULL) {
409
410 status = RtlUShortAdd(size,
412 pList->InterfaceDescriptor->bNumEndpoints),
413 &size);
414 if (!NT_SUCCESS(status)) {
416 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
417 "InterfaceList %p, NumEndPoints 0x%x, "
418 "Integer overflow while calculating interface size, %!STATUS!",
420 pList->InterfaceDescriptor->bNumEndpoints,
421 status);
422 return NULL;
423 }
424 pList++;
425 }
426 }
427 else {
429 }
430
431 //
432 // Make sure we are dealing with a value that fits into a USHORT
433 //
434 ASSERT(size <= 0xFFFF);
435
436 urb = (PURB) FxPoolAllocate(FxDriverGlobals, NonPagedPool, size);
437
438 if (urb != NULL) {
439 PUCHAR pCur;
440
441 //
442 // now all we have to do is initialize the urb
443 //
444 RtlZeroMemory(urb, size);
445
447
448 pCur = (PUCHAR) &urb->UrbSelectConfiguration.Interface;
449 while (pList->InterfaceDescriptor != NULL) {
450 PUSB_INTERFACE_DESCRIPTOR pInterfaceDesc;
451 PUSBD_INTERFACE_INFORMATION pInterfaceInfo;
452
453 pInterfaceDesc = pList->InterfaceDescriptor;
454
455 pInterfaceInfo = (PUSBD_INTERFACE_INFORMATION) pCur;
456#pragma prefast(suppress: __WARNING_BUFFER_OVERFLOW, "Esp:675");
457 pInterfaceInfo->InterfaceNumber = pInterfaceDesc->bInterfaceNumber;
458 pInterfaceInfo->AlternateSetting = pInterfaceDesc->bAlternateSetting;
459 pInterfaceInfo->NumberOfPipes = pInterfaceDesc->bNumEndpoints;
460 pInterfaceInfo->Length = (USHORT)
461 GET_USBD_INTERFACE_SIZE(pInterfaceDesc->bNumEndpoints);
462
463 for (LONG j = 0; j < pInterfaceDesc->bNumEndpoints; j++) {
464 pInterfaceInfo->Pipes[j].PipeFlags = 0;
465 pInterfaceInfo->Pipes[j].MaximumTransferSize = DefaultMaxPacketSize;
466 }
467
468 ASSERT(pCur + pInterfaceInfo->Length <= ((PUCHAR) urb) + size);
469
470 pList->Interface = pInterfaceInfo;
471
472 pList++;
473 pCur += pInterfaceInfo->Length;
474 }
475
476 urb->UrbHeader.Length = size;
478 urb->UrbSelectConfiguration.ConfigurationDescriptor = ConfigDesc;
479 }
480
481 return urb;
482}
483
484#if (FX_CORE_MODE == FX_CORE_USER_MODE)
485VOID
488 __in_xcount(Urb->Length) PUMURB_HEADER Urb,
489 __in IWudfFile* HostFile,
491 )
492/*++
493
494Routine Description:
495 Formats a request to become a USB request.
496 The next stack location is formatted with the UM URB
497 and dispatcher is set to be the USB dispatcher
498
499Arguments:
500 Request - Request to be formatted
501 Urb - UM URB the Request is to be formatted with
502 the pointer is passed as the header so
503 that SAL checkers don't complain on bigger size usage than what's passed in
504 (Total size of the URB union can be more than the the specific member that is passed in)
505 File - The host file used for internal I/O.
506
507Return Value:
508 None
509
510--*/
511{
512 FX_VERIFY(INTERNAL, CHECK_NOT_NULL(Request));
513 FX_VERIFY(INTERNAL, CHECK_NOT_NULL(Urb));
514 FX_VERIFY(INTERNAL, CHECK_TODO(Urb->Length >= sizeof(_UMURB_HEADER)));
515 FX_VERIFY(INTERNAL, CHECK_NOT_NULL(HostFile));
516
517 IWudfIoIrp* pIoIrp = NULL;
518 IWudfIrp* pIrp = Request->GetSubmitIrp();
519
520 if (Reuse) {
521 //
522 // This allows us to use the same FxSyncRequest
523 // stack object multiple times.
524 //
525 Request->GetSubmitFxIrp()->Reuse(STATUS_SUCCESS);
526 Request->ClearFieldsForReuse();
527 }
528
529 HRESULT hrQI = pIrp->QueryInterface(IID_IWudfIoIrp, (PVOID*)&pIoIrp);
530 FX_VERIFY(INTERNAL, CHECK_QI(hrQI, pIoIrp));
531
532 pIoIrp->SetTypeForNextStackLocation(UMINT::WdfRequestInternalIoctl);
533
534
535
536
537 pIoIrp->SetDeviceIoControlParametersForNextStackLocation(IOCTL_INETRNAL_USB_SUBMIT_UMURB,
538 0,
539 0);
540
541 pIoIrp->SetOtherParametersForNextStackLocation((PVOID*)&Urb,
542 NULL,
543 NULL,
544 NULL);
545
546 pIoIrp->SetFileForNextIrpStackLocation(HostFile);
547
548 //
549 // Release reference taken by QI
550 //
551 SAFE_RELEASE(pIoIrp);
552 Request->VerifierSetFormatted();
553}
554
555VOID
557 __inout PUMURB UmUrb,
558 __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
562 )
563{
564 RtlZeroMemory(UmUrb, sizeof(UMURB));
565
566 UmUrb->UmUrbDescriptorRequest.Hdr.InterfaceHandle = WinUsbHandle;
567 UmUrb->UmUrbDescriptorRequest.Hdr.Function = UMURB_FUNCTION_GET_DESCRIPTOR;
568 UmUrb->UmUrbDescriptorRequest.Hdr.Length = sizeof(_UMURB_DESCRIPTOR_REQUEST);
569
570 UmUrb->UmUrbDescriptorRequest.DescriptorType = DescriptorType;
571 UmUrb->UmUrbDescriptorRequest.Index = 0;
572 UmUrb->UmUrbDescriptorRequest.LanguageID = 0;
573 UmUrb->UmUrbDescriptorRequest.BufferLength = BufferLength;
574 UmUrb->UmUrbDescriptorRequest.Buffer = Buffer;
575}
576
577VOID
579 __inout PUMURB UmUrb,
580 __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
583 )
584{
585 RtlZeroMemory(UmUrb, sizeof(UMURB));
586
587 UmUrb->UmUrbControlTransfer.Hdr.InterfaceHandle = WinUsbHandle;
588 UmUrb->UmUrbControlTransfer.Hdr.Function = UMURB_FUNCTION_CONTROL_TRANSFER;
589 UmUrb->UmUrbControlTransfer.Hdr.Length = sizeof(_UMURB_CONTROL_TRANSFER);
590
591 UmUrb->UmUrbControlTransfer.TransferBufferLength = BufferLength;
592 UmUrb->UmUrbControlTransfer.TransferBuffer = Buffer;
593}
594
595VOID
597 __inout PUMURB UmUrb,
598 __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
601 )
602{
603 RtlZeroMemory(UmUrb, sizeof(UMURB));
604
605 UmUrb->UmUrbDeviceInformation.Hdr.InterfaceHandle = WinUsbHandle;
606 UmUrb->UmUrbDeviceInformation.Hdr.Function = UMURB_FUNCTION_GET_DEVICE_INFORMATION;
607 UmUrb->UmUrbDeviceInformation.Hdr.Length = sizeof(_UMURB_DEVICE_INFORMATION);
608
609 UmUrb->UmUrbDeviceInformation.InformationType = DEVICE_SPEED;
610 UmUrb->UmUrbDeviceInformation.BufferLength = BufferLength;
611 UmUrb->UmUrbDeviceInformation.Buffer = Buffer;
612}
613#endif
614
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
Definition: bufpool.h:45
Definition: fxirp.hpp:28
VOID SetMajorFunction(__in UCHAR MajorFunction)
Definition: fxirpum.cpp:905
VOID SetParameterIoctlCode(__in ULONG DeviceIoControlCode)
Definition: fxirpum.cpp:1157
PIO_STACK_LOCATION GetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:387
VOID ClearNextStackLocation(VOID)
Definition: fxirpum.cpp:1581
VOID SetNextStackParameterOthersArgument1(__in PVOID Argument1)
Definition: fxirpum.cpp:1411
VOID Reuse(__in NTSTATUS Status=STATUS_SUCCESS)
Definition: fxirpum.cpp:661
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_when(cond, annotes)
Definition: driverspecs.h:335
#define NonPagedPool
Definition: env_spec_w32.h:307
FX_VERIFY(INTERNAL, CHECK_NOT_NULL(LoaderInterface->pIWudfHost))
HRESULT hrQI
Definition: framework.cpp:106
FxChildList * pList
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
SINGLE_LIST_ENTRY * pCur
FxIrp * pIrp
return pRequest Reuse(ReuseParams)
FxIrp * irp
@ FX_RCT_USB_URB_REQUEST
@ FxUrbTypeUsbdAllocated
Definition: fxusbdevice.hpp:28
enum _FX_URB_TYPE FX_URB_TYPE
GLsizeiptr size
Definition: glext.h:5919
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
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 GLint GLint j
Definition: glfuncs.h:250
#define ASSERT(a)
Definition: mode.c:44
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
descriptor
Definition: scsi.h:3951
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __in_xcount(size)
Definition: specstrings.h:109
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
virtual VOID StoreAndReferenceMemory(__in FxRequestBuffer *Buffer)
Definition: fxusbpipe.cpp:937
IN USHORT Length
Definition: umusb.h:64
Definition: umusb.h:173
Definition: usb.h:529
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
Definition: usb.h:533
struct _URB_HEADER UrbHeader
Definition: usb.h:531
USBD_PIPE_INFORMATION Pipes[1]
Definition: usb.h:286
Definition: usbdlib.h:7
ULONG MaximumTransferSize
Definition: usb.h:265
Definition: ps.c:97
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define UMURB_FUNCTION_CONTROL_TRANSFER
Definition: umusb.h:16
#define IOCTL_INETRNAL_USB_SUBMIT_UMURB
Definition: umusb.h:259
#define UMURB_FUNCTION_GET_DEVICE_INFORMATION
Definition: umusb.h:55
#define UMURB_FUNCTION_GET_DESCRIPTOR
Definition: umusb.h:56
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
struct _URB * PURB
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
#define GET_USBD_INTERFACE_SIZE(numEndpoints)
Definition: usbdlib.h:121
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:160
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:170
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:169
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
VOID USBD_AssignUrbToIoStackLocation(_In_ USBD_HANDLE USBDHandle, _In_ PIO_STACK_LOCATION IoStackLocation, _In_ PURB Urb)
Definition: usbstubum.cpp:136
PUSB_COMMON_DESCRIPTOR FxUsbFindDescriptorType(__in PVOID Buffer, __in size_t BufferLength, __in PVOID Start, __in LONG DescriptorType)
Definition: usbutil.cpp:174
NTSTATUS FxUsbValidateDescriptorType(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, __in PVOID Start, __in PVOID End, __in LONG DescriptorType, __in size_t SizeToValidate, __in FxUsbValidateDescriptorOp Op, __in ULONG MaximumNumDescriptorsToValidate)
Definition: usbutil.cpp:207
VOID FxUsbUmInitInformationUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:596
NTSTATUS FxFormatUrbRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxIoTarget *Target, __in FxRequestBase *Request, __in FxRequestBuffer *Buffer, __in FX_URB_TYPE FxUrbType, __drv_when(FxUrbType==FxUrbTypeUsbdAllocated, __in) __drv_when(FxUrbType !=FxUrbTypeUsbdAllocated, __in_opt) USBD_HANDLE UsbdHandle)
Definition: usbutil.cpp:62
PUSB_INTERFACE_DESCRIPTOR FxUsbParseConfigurationDescriptor(__in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in UCHAR InterfaceNumber, __in UCHAR AlternateSetting)
Definition: usbutil.cpp:307
VOID FxUsbUmInitDescriptorUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in UCHAR DescriptorType, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:556
NTSTATUS FxUsbValidateConfigDescriptorHeaders(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, __in size_t ConfigDescriptorLength)
Definition: usbutil.cpp:111
PURB FxUsbCreateConfigRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in PUSBD_INTERFACE_LIST_ENTRY InterfaceList, __in ULONG DefaultMaxPacketSize)
Definition: usbutil.cpp:364
VOID FxFormatUsbRequest(__in FxRequestBase *Request, __in PURB Urb, __in FX_URB_TYPE FxUrbType, __drv_when(FxUrbType==FxUrbTypeUsbdAllocated, __in) __drv_when(FxUrbType !=FxUrbTypeUsbdAllocated, __in_opt) USBD_HANDLE UsbdHandle)
Definition: usbutil.cpp:29
VOID FxUsbUmFormatRequest(__in FxRequestBase *Request, __in_xcount(Urb->Length) PUMURB_HEADER Urb, __in IWudfFile *HostFile, __in BOOLEAN Reuse)
Definition: usbutil.cpp:486
VOID FxUsbUmInitControlTransferUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:578
FxUsbValidateDescriptorOp
Definition: usbutil.hpp:126
@ FxUsbValidateDescriptorOpAtLeast
Definition: usbutil.hpp:128
@ FxUsbValidateDescriptorOpEqual
Definition: usbutil.hpp:127
@ Start
Definition: partlist.h:33
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: wdfusb.h:2334
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID ConfigDescriptor
Definition: wdfusb.h:1036
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID _Inout_ PUSHORT ConfigDescriptorLength
Definition: wdfusb.h:1040
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define SAFE_RELEASE(p)
unsigned char UCHAR
Definition: xmlstorage.h:181