ReactOS 0.4.16-dev-1946-g52006dd
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#if defined(EVENT_TRACING)
26#include "UsbUtil.tmh"
27#endif
28}
29
30VOID
34 __in FX_URB_TYPE FxUrbType,
37 USBD_HANDLE UsbdHandle
38 )
39{
40 FxIrp* irp;
41
42 ASSERT(Urb->UrbHeader.Length >= sizeof(_URB_HEADER));
43
44 irp = Request->GetSubmitFxIrp();
48
49
50
51
52
53 if (FxUrbType == FxUrbTypeUsbdAllocated) {
55 }
56 else {
58 }
59
60 Request->VerifierSetFormatted();
61}
62
65 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
69 __in FX_URB_TYPE FxUrbType,
72 USBD_HANDLE UsbdHandle
73 )
74{
75 FxUsbUrbContext* pContext;
77
78 status = Request->ValidateTarget(Target);
79 if (!NT_SUCCESS(status)) {
81 "FormatUrbRequest: Target %p, Request %p, "
82 "setting target failed, %!STATUS!",
84
85 return status;
86 }
87
88 if (Request->HasContextType(FX_RCT_USB_URB_REQUEST)) {
89 pContext = (FxUsbUrbContext*) Request->GetContext();
90 }
91 else {
92 pContext = new(Target->GetDriverGlobals()) FxUsbUrbContext();
93
94 if (pContext == NULL) {
96 }
97
98 Request->SetContext(pContext);
99 }
100
101 //
102 // Always set the memory after determining the context. This way we can
103 // free a previously referenced memory object if necessary.
104 //
106
107 FxFormatUsbRequest(Request, pContext->m_pUrb, FxUrbType, UsbdHandle);
108
109 return STATUS_SUCCESS;
110}
111
114 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
117 )
118{
119 PUCHAR pCur, pEnd;
120
123
124 while (pCur < pEnd) {
126
127 //
128 // Make sure we can safely deref bLength, bDescriptorType
129 //
130 if (pCur + sizeof(USB_COMMON_DESCRIPTOR) > pEnd) {
132 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
133 "USB Configuration packet contains bad data, expected "
134 "at least %d remaining bytes in config descriptor at "
135 "offset %I64d, total size is %I64d",
138 );
140 }
141
142 //
143 // Make sure bLength is within bounds of the config descriptor
144 //
145 if ((pCur + pDescriptor->bLength) > pEnd) {
147 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
148 "USB Configuration packet contains bad data, descriptor at offset "
149 "%I64d specified bLength %d, only %I64d bytes remaining in config "
150 "descriptor, total size is %I64d",
151 pCur-(PUCHAR)ConfigDescriptor, pDescriptor->bLength, pEnd-pCur,
153 );
155 }
156
157 if (pDescriptor->bLength == 0) {
159 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
160 "USB Configuration packet contains bad data, descriptor at offset "
161 "%I64d contains bLength == 0, this is due to a broken device or driver",
163 );
165 }
166
167
168 pCur += pDescriptor->bLength;
169 }
170
171 return STATUS_SUCCESS;
172}
173
174
178 __in size_t BufferLength,
181 )
182{
184 PUCHAR pCur, pEnd;
185
186 pCur = (PUCHAR) Start;
187 pEnd = ((PUCHAR) Buffer) + BufferLength;
188
189 while (pCur < pEnd) {
190 //
191 // Check to see if the current point is the desired descriptor type
192 //
194
195 if (descriptor->bDescriptorType == DescriptorType) {
196 return descriptor;
197 }
198
199 pCur += descriptor->bLength;
200 }
201
202 //
203 // Iterated to the end and found nothing
204 //
205 return NULL;
206}
207
210 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
213 __in PVOID End,
215 __in size_t SizeToValidate,
217 __in ULONG MaximumNumDescriptorsToValidate
218 )
219/*++
220
221Routine Description:
222 Validates the size of all descriptors within [Start, End] are of the correct
223 size. Correct can either be == or >= SizeToValidate. Furthermore, the caller
224 can specify that validation only occur for the first N descriptors found
225
226Arguments:
227 FxDriverDriverGlobals - client driver globals
228 ConfigDescriptor - the entire config descriptor of the usb device
229 Start - the beginning of the buffer to start to validating descriptors within
230 End - end of the buffer of validation
231 DescriptorType - the type of descriptor to validate
232 SizeToValidate - the size of the descriptor required. Op determines if the
233 check is == or >=
234 Op - the operation, == or >=, to perform for the size validation
235 MaximumNumDescriptorsToValidate - limit of the number of descriptors to validate,
236 if zero, all instances are validated
237
238Return Value:
239 NTSTATUS - !NT_SUCCESS if validation fails, NT_SUCCESS upon success
240
241--*/
242{
243 PUSB_COMMON_DESCRIPTOR pDescriptor = NULL;
244 PVOID pCur = Start;
245 ULONG i = 1;
246
247 while ((pDescriptor = FxUsbFindDescriptorType(Start,
248 (PUCHAR)End-(PUCHAR)Start,
249 pCur,
251 )) != NULL) {
252 //
253 // Make sure bLength is the correct value
254 //
256 if (pDescriptor->bLength != SizeToValidate) {
258 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
259 "USB Configuration packet contains bad data, found descriptor "
260 "#%d of type %d at offset %I64d, expected bLength of %I64d, found %d",
261 i, DescriptorType, ((PUCHAR)pDescriptor)-((PUCHAR)ConfigDescriptor),
262 SizeToValidate, pDescriptor->bLength
263 );
265 }
266 }
267 else if (Op == FxUsbValidateDescriptorOpAtLeast) {
268 if (pDescriptor->bLength < SizeToValidate) {
270 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
271 "USB Configuration packet contains bad data, found descriptor "
272 "#%d of type %d at offset %I64d, expected minimum bLength of %I64d, "
273 "found %d",
274 i, DescriptorType, ((PUCHAR)pDescriptor)-((PUCHAR)ConfigDescriptor),
275 SizeToValidate, pDescriptor->bLength
276 );
278 }
279 }
280
281 //
282 // No need to validate WDF_PTR_ADD_OFFSET(pDescriptor, pDescriptor->bLength) > End
283 // because FxUsbValidateConfigDescriptorHeaders already has done so. End is either
284 // 1) == end of the config descriptor, in which case FxUsbValidateConfigDescriptorHeaders
285 // directly validated bLength
286 // or
287 // 2) End is somewere in the middle of the config descriptor and ASSUMED to be the start
288 // of a common descriptor header. To find that value of End, we would have had to use
289 // pDescriptor->bLength to get to End, we would not overrun
290 //
291
292 //
293 // i is one based, so the current value is Nth descriptor we have validated. If
294 // the caller wants to limit the number of descriptors validated by indicating a
295 // Max > 0, stop with success if the condition is met.
296 //
297 if (MaximumNumDescriptorsToValidate > 0 && i == MaximumNumDescriptorsToValidate) {
298 break;
299 }
300
301 pCur = WDF_PTR_ADD_OFFSET(pDescriptor, pDescriptor->bLength);
302 i++;
303 }
304
305 return STATUS_SUCCESS;
306}
307
313 )
314{
315 PUSB_INTERFACE_DESCRIPTOR found, usbInterface;
316 PVOID pStart;
317
318 found = NULL,
319
320 ASSERT(ConfigDesc->bDescriptorType == USB_CONFIGURATION_DESCRIPTOR_TYPE);
321
322 //
323 // Walk the table of descriptors looking for an interface descriptor with
324 // parameters matching those passed in.
325 //
326 pStart = ConfigDesc;
327
328 do {
329 //
330 // Search for descriptor type 'interface'
331 //
332 usbInterface = (PUSB_INTERFACE_DESCRIPTOR)
333 FxUsbFindDescriptorType(ConfigDesc,
334 ConfigDesc->wTotalLength,
335 pStart,
337
338 //
339 // Check to see if have a matching descriptor by eliminating mismatches
340 //
341 if (usbInterface != NULL) {
342 found = usbInterface;
343
344 if (InterfaceNumber != -1 &&
345 usbInterface->bInterfaceNumber != InterfaceNumber) {
346 found = NULL;
347 }
348
349 if (AlternateSetting != -1 &&
350 usbInterface->bAlternateSetting != AlternateSetting) {
351 found = NULL;
352 }
353
354 pStart = ((PUCHAR)usbInterface) + usbInterface->bLength;
355 }
356
357 if (found != NULL) {
358 break;
359 }
360 } while (usbInterface!= NULL);
361
362 return found;
363}
364
365PURB
367 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
370 __in ULONG DefaultMaxPacketSize
371 )
372{
373 PURB urb;
375 USHORT size;
376
377 //
378 // Our mission here is to construct a URB of the proper
379 // size and format for a select_configuration request.
380 //
381 // This function uses the configuration descriptor as a
382 // reference and builds a URB with interface_information
383 // structures for each interface requested in the interface
384 // list passed in
385 //
386 // NOTE: the config descriptor may contain interfaces that
387 // the caller does not specify in the list -- in this case
388 // the other interfaces will be ignored.
389 //
390
391 //
392 // First figure out how many interfaces we are dealing with
393 //
395
396 //
397 // For a multiple interface configuration, GET_SELECT_CONFIGURATION_REQUEST_SIZE
398 // doesn't work as expected. This is because it subtracts one from totalPipes
399 // to compensate for the embedded USBD_PIPE_INFORMATION in USBD_INTERFACE_INFORMATION.
400 // A multiple interface device will have more then one embedded
401 // USBD_PIPE_INFORMATION in its configuration request and any of these interfaces
402 // might not have any pipes on them.
403 //
404 // To fix, just iterate and compute the size incrementally.
405 //
408
409 while (pList->InterfaceDescriptor != NULL) {
411
412 status = RtlUShortAdd(size,
414 pList->InterfaceDescriptor->bNumEndpoints),
415 &size);
416 if (!NT_SUCCESS(status)) {
418 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
419 "InterfaceList %p, NumEndPoints 0x%x, "
420 "Integer overflow while calculating interface size, %!STATUS!",
422 pList->InterfaceDescriptor->bNumEndpoints,
423 status);
424 return NULL;
425 }
426 pList++;
427 }
428 }
429 else {
431 }
432
433 //
434 // Make sure we are dealing with a value that fits into a USHORT
435 //
436 ASSERT(size <= 0xFFFF);
437
438 urb = (PURB) FxPoolAllocate(FxDriverGlobals, NonPagedPool, size);
439
440 if (urb != NULL) {
441 PUCHAR pCur;
442
443 //
444 // now all we have to do is initialize the urb
445 //
446 RtlZeroMemory(urb, size);
447
449
450 pCur = (PUCHAR) &urb->UrbSelectConfiguration.Interface;
451 while (pList->InterfaceDescriptor != NULL) {
452 PUSB_INTERFACE_DESCRIPTOR pInterfaceDesc;
453 PUSBD_INTERFACE_INFORMATION pInterfaceInfo;
454
455 pInterfaceDesc = pList->InterfaceDescriptor;
456
457 pInterfaceInfo = (PUSBD_INTERFACE_INFORMATION) pCur;
458#pragma prefast(suppress: __WARNING_BUFFER_OVERFLOW, "Esp:675");
459 pInterfaceInfo->InterfaceNumber = pInterfaceDesc->bInterfaceNumber;
460 pInterfaceInfo->AlternateSetting = pInterfaceDesc->bAlternateSetting;
461 pInterfaceInfo->NumberOfPipes = pInterfaceDesc->bNumEndpoints;
462 pInterfaceInfo->Length = (USHORT)
463 GET_USBD_INTERFACE_SIZE(pInterfaceDesc->bNumEndpoints);
464
465 for (LONG j = 0; j < pInterfaceDesc->bNumEndpoints; j++) {
466 pInterfaceInfo->Pipes[j].PipeFlags = 0;
467 pInterfaceInfo->Pipes[j].MaximumTransferSize = DefaultMaxPacketSize;
468 }
469
470 ASSERT(pCur + pInterfaceInfo->Length <= ((PUCHAR) urb) + size);
471
472 pList->Interface = pInterfaceInfo;
473
474 pList++;
475 pCur += pInterfaceInfo->Length;
476 }
477
478 urb->UrbHeader.Length = size;
480 urb->UrbSelectConfiguration.ConfigurationDescriptor = ConfigDesc;
481 }
482
483 return urb;
484}
485
486#if (FX_CORE_MODE == FX_CORE_USER_MODE)
487VOID
491 __in IWudfFile* HostFile,
493 )
494/*++
495
496Routine Description:
497 Formats a request to become a USB request.
498 The next stack location is formatted with the UM URB
499 and dispatcher is set to be the USB dispatcher
500
501Arguments:
502 Request - Request to be formatted
503 Urb - UM URB the Request is to be formatted with
504 the pointer is passed as the header so
505 that SAL checkers don't complain on bigger size usage than what's passed in
506 (Total size of the URB union can be more than the the specific member that is passed in)
507 File - The host file used for internal I/O.
508
509Return Value:
510 None
511
512--*/
513{
514 FX_VERIFY(INTERNAL, CHECK_NOT_NULL(Request));
515 FX_VERIFY(INTERNAL, CHECK_NOT_NULL(Urb));
516 FX_VERIFY(INTERNAL, CHECK_TODO(Urb->Length >= sizeof(_UMURB_HEADER)));
517 FX_VERIFY(INTERNAL, CHECK_NOT_NULL(HostFile));
518
519 IWudfIoIrp* pIoIrp = NULL;
520 IWudfIrp* pIrp = Request->GetSubmitIrp();
521
522 if (Reuse) {
523 //
524 // This allows us to use the same FxSyncRequest
525 // stack object multiple times.
526 //
527 Request->GetSubmitFxIrp()->Reuse(STATUS_SUCCESS);
528 Request->ClearFieldsForReuse();
529 }
530
531 HRESULT hrQI = pIrp->QueryInterface(IID_IWudfIoIrp, (PVOID*)&pIoIrp);
532 FX_VERIFY(INTERNAL, CHECK_QI(hrQI, pIoIrp));
533
534 pIoIrp->SetTypeForNextStackLocation(UMINT::WdfRequestInternalIoctl);
535
536
537
538
539 pIoIrp->SetDeviceIoControlParametersForNextStackLocation(IOCTL_INETRNAL_USB_SUBMIT_UMURB,
540 0,
541 0);
542
543 pIoIrp->SetOtherParametersForNextStackLocation((PVOID*)&Urb,
544 NULL,
545 NULL,
546 NULL);
547
548 pIoIrp->SetFileForNextIrpStackLocation(HostFile);
549
550 //
551 // Release reference taken by QI
552 //
553 SAFE_RELEASE(pIoIrp);
554 Request->VerifierSetFormatted();
555}
556
557VOID
559 __inout PUMURB UmUrb,
560 __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
564 )
565{
566 RtlZeroMemory(UmUrb, sizeof(UMURB));
567
568 UmUrb->UmUrbDescriptorRequest.Hdr.InterfaceHandle = WinUsbHandle;
569 UmUrb->UmUrbDescriptorRequest.Hdr.Function = UMURB_FUNCTION_GET_DESCRIPTOR;
570 UmUrb->UmUrbDescriptorRequest.Hdr.Length = sizeof(_UMURB_DESCRIPTOR_REQUEST);
571
572 UmUrb->UmUrbDescriptorRequest.DescriptorType = DescriptorType;
573 UmUrb->UmUrbDescriptorRequest.Index = 0;
574 UmUrb->UmUrbDescriptorRequest.LanguageID = 0;
575 UmUrb->UmUrbDescriptorRequest.BufferLength = BufferLength;
576 UmUrb->UmUrbDescriptorRequest.Buffer = Buffer;
577}
578
579VOID
581 __inout PUMURB UmUrb,
582 __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
585 )
586{
587 RtlZeroMemory(UmUrb, sizeof(UMURB));
588
589 UmUrb->UmUrbControlTransfer.Hdr.InterfaceHandle = WinUsbHandle;
590 UmUrb->UmUrbControlTransfer.Hdr.Function = UMURB_FUNCTION_CONTROL_TRANSFER;
591 UmUrb->UmUrbControlTransfer.Hdr.Length = sizeof(_UMURB_CONTROL_TRANSFER);
592
593 UmUrb->UmUrbControlTransfer.TransferBufferLength = BufferLength;
594 UmUrb->UmUrbControlTransfer.TransferBuffer = Buffer;
595}
596
597VOID
599 __inout PUMURB UmUrb,
600 __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
603 )
604{
605 RtlZeroMemory(UmUrb, sizeof(UMURB));
606
607 UmUrb->UmUrbDeviceInformation.Hdr.InterfaceHandle = WinUsbHandle;
608 UmUrb->UmUrbDeviceInformation.Hdr.Function = UMURB_FUNCTION_GET_DEVICE_INFORMATION;
609 UmUrb->UmUrbDeviceInformation.Hdr.Length = sizeof(_UMURB_DEVICE_INFORMATION);
610
611 UmUrb->UmUrbDeviceInformation.InformationType = DEVICE_SPEED;
612 UmUrb->UmUrbDeviceInformation.BufferLength = BufferLength;
613 UmUrb->UmUrbDeviceInformation.Buffer = Buffer;
614}
615#endif
616
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:33
#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
return pTarget Start()
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:3997
#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:939
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
VOID USBD_AssignUrbToIoStackLocation(_In_ USBD_HANDLE USBDHandle, _In_ PIO_STACK_LOCATION IoStackLocation, _In_ PURB Urb)
Definition: usbdex.c:28
#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_ PIO_STACK_LOCATION _In_ PURB Urb
Definition: usbdlib.h:267
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:169
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
PUSB_COMMON_DESCRIPTOR FxUsbFindDescriptorType(__in PVOID Buffer, __in size_t BufferLength, __in PVOID Start, __in LONG DescriptorType)
Definition: usbutil.cpp:176
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:209
VOID FxUsbUmInitInformationUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:598
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:64
PUSB_INTERFACE_DESCRIPTOR FxUsbParseConfigurationDescriptor(__in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in UCHAR InterfaceNumber, __in UCHAR AlternateSetting)
Definition: usbutil.cpp:309
VOID FxUsbUmInitDescriptorUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in UCHAR DescriptorType, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:558
NTSTATUS FxUsbValidateConfigDescriptorHeaders(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, __in size_t ConfigDescriptorLength)
Definition: usbutil.cpp:113
PURB FxUsbCreateConfigRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in PUSBD_INTERFACE_LIST_ENTRY InterfaceList, __in ULONG DefaultMaxPacketSize)
Definition: usbutil.cpp:366
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:31
VOID FxUsbUmFormatRequest(__in FxRequestBase *Request, __in_xcount(Urb->Length) PUMURB_HEADER Urb, __in IWudfFile *HostFile, __in BOOLEAN Reuse)
Definition: usbutil.cpp:488
VOID FxUsbUmInitControlTransferUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:580
FxUsbValidateDescriptorOp
Definition: usbutil.hpp:126
@ FxUsbValidateDescriptorOpAtLeast
Definition: usbutil.hpp:128
@ FxUsbValidateDescriptorOpEqual
Definition: usbutil.hpp:127
#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:3777
_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