ReactOS 0.4.15-dev-7961-gdcf9eb0
fxusbdeviceapi.cpp File Reference
#include "fxusbpch.hpp"
#include "FxUsbDeviceAPI.tmh"
Include dependency graph for fxusbdeviceapi.cpp:

Go to the source code of this file.

Functions

_Must_inspect_result_ __drv_maxIRQL (PASSIVE_LEVEL) NTSTATUS WDFAPI FxUsbTargetDeviceCreate(__in PFX_DRIVER_GLOBALS FxDriverGlobals
 
 FxPointerNotNull (FxDriverGlobals, UsbDevice)
 
 if (!NT_SUCCESS(status))
 
 if (pUsbDevice==NULL)
 
 if (NT_SUCCESS(status))
 
 FxObjectHandleGetPtrAndGlobals (GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE_BASE,(PVOID *)&pDevice, &pFxDriverGlobals)
 
return FxUsbTargetDeviceCreate (pFxDriverGlobals, pDevice, USBD_CLIENT_CONTRACT_VERSION_INVALID, Attributes, UsbDevice)
 
 FxPointerNotNull (pFxDriverGlobals, Config)
 
 if (Config->Size !=sizeof(WDF_USB_DEVICE_CREATE_CONFIG))
 
return FxUsbTargetDeviceCreate (pFxDriverGlobals, pDevice, Config->USBDClientContractVersion, Attributes, UsbDevice)
 
_Must_inspect_result_ __drv_maxIRQL (DISPATCH_LEVEL) NTSTATUS WDFAPI WDFEXPORT(WdfUsbTargetDeviceRetrieveInformation)(__in PWDF_DRIVER_GLOBALS DriverGlobals
 
 FxObjectHandleGetPtrAndGlobals (GetFxDriverGlobals(DriverGlobals), UsbDevice, FX_TYPE_IO_TARGET_USB_DEVICE,(PVOID *) &pUsbDevice, &pFxDriverGlobals)
 
 FxPointerNotNull (pFxDriverGlobals, Information)
 
 if (Information->Size !=sizeof(WDF_USB_DEVICE_INFORMATION))
 
pUsbDevice GetInformation (Information)
 
 FxPointerNotNull (pFxDriverGlobals, UsbDeviceDescriptor)
 
pUsbDevice CopyDeviceDescriptor (UsbDeviceDescriptor)
 
 FxPointerNotNull (pFxDriverGlobals, ConfigDescriptorLength)
 
return pUsbDevice GetConfigDescriptor (ConfigDescriptor, ConfigDescriptorLength)
 
 FxPointerNotNull (pFxDriverGlobals, NumCharacters)
 
 FxPointerNotNull (pFxDriverGlobals, StringMemory)
 
 if (NumCharacters !=NULL)
 
 if (NT_SUCCESS(status) &&numChars > 0)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p, StringIndex %d, LandID 0x%x", UsbDevice, Request, Memory, StringIndex, LangID)
 
 FxObjectHandleGetPtr (pFxDriverGlobals, Memory, IFX_TYPE_MEMORY,(PVOID *) &pMemory)
 
 FxObjectHandleGetPtr (pFxDriverGlobals, Request, FX_TYPE_REQUEST,(PVOID *) &pRequest)
 
buf SetMemory (pMemory, Offset)
 
 if ((bufferSize % sizeof(WCHAR)) !=0)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p, %!STATUS!", UsbDevice, Request, Memory, status)
 
 FxPointerNotNull (pFxDriverGlobals, Params)
 
 if (Params->Size !=sizeof(WDF_USB_DEVICE_SELECT_CONFIG_PARAMS))
 
 if (Params->Type< WdfUsbTargetDeviceSelectConfigTypeDeconfig||Params->Type > WdfUsbTargetDeviceSelectConfigTypeUrb)
 
 if ((Params->Type==WdfUsbTargetDeviceSelectConfigTypeDeconfig)||(Params->Type==WdfUsbTargetDeviceSelectConfigTypeUrb)||(Params->Type==WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor))
 
 if (pUsbDevice->HasMismatchedInterfacesInConfigDescriptor())
 
 switch (Params->Type)
 
 FxObjectHandleGetPtr (GetFxDriverGlobals(DriverGlobals), UsbDevice, FX_TYPE_IO_TARGET_USB_DEVICE,(PVOID *) &pUsbDevice)
 
return pUsbDevice GetNumInterfaces ()
 
return pUsbDevice GetConfigHandle ()
 
FxSyncRequest request (pFxDriverGlobals, &context, Request)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p control transfer sync", UsbDevice)
 
 FxPointerNotNull (pFxDriverGlobals, SetupPacket)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, %!STATUS!", UsbDevice, status)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p", UsbDevice, Request, TransferMemory)
 
 if (TransferMemory !=NULL)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "format control request WDFUSBDEVICE %p, WDFREQWUEST %p, WDFMEMORY %p, %!STATUS!", UsbDevice, Request, TransferMemory, status)
 
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __in ULONG __out WDFMEMORY __deref_opt_out_bcount (GET_ISOCH_URB_SIZE(NumberOfIsochPackets)) PURB *Urb)
 
 if (pUsbInterface !=NULL)
 
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __drv_when (CapabilityBufferLength==0, __out_opt) __drv_when(CapabilityBufferLength !=0 &&ResultLength
 
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __out_bcount (CapabilityBufferLength)) __drv_when(CapabilityBufferLength !=0 &&ResultLength !
 
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __out_bcount_part_opt (CapabilityBufferLength, *ResultLength)) PVOID CapabilityBuffer
 
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __out_opt __drv_when (ResultLength !=NULL, __deref_out_range(<=, CapabilityBufferLength)) PULONG ResultLength)
 

Variables

_Must_inspect_result_ __in FxDeviceBaseDevice
 
_Must_inspect_result_ __in FxDeviceBase __in ULONG USBDClientContractVersion
 
_Must_inspect_result_ __in FxDeviceBase __in ULONG __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
 
_Must_inspect_result_ __in FxDeviceBase __in ULONG __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFUSBDEVICE * UsbDevice
 
NTSTATUS status = FxVerifierCheckIrqlLevel(FxDriverGlobals, PASSIVE_LEVEL)
 
 pUsbDevice = new(FxDriverGlobals, Attributes) FxUsbDevice(FxDriverGlobals)
 
PFX_DRIVER_GLOBALS pFxDriverGlobals
 
FxDeviceBasepDevice
 
__checkReturn __in WDFDEVICE __in PWDF_USB_DEVICE_CREATE_CONFIG Config
 
_Must_inspect_result_ __in WDFUSBDEVICE __out PWDF_USB_DEVICE_INFORMATION Information
 
return STATUS_SUCCESS
 
__in WDFUSBDEVICE __out PUSB_DEVICE_DESCRIPTOR UsbDeviceDescriptor
 
_Must_inspect_result_ __in WDFUSBDEVICE __out_bcount_part_opt ConfigDescriptorLength PVOID ConfigDescriptor
 
_Must_inspect_result_ __in WDFUSBDEVICE __out_bcount_part_opt ConfigDescriptorLength PVOID __inout PUSHORT ConfigDescriptorLength
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST Request
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __out_ecount_opt NumCharacters PUSHORT String
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __out_ecount_opt NumCharacters PUSHORT __inout PUSHORT NumCharacters
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __out_ecount_opt NumCharacters PUSHORT __inout PUSHORT __in UCHAR StringIndex
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __out_ecount_opt NumCharacters PUSHORT __inout PUSHORT __in UCHAR __in_opt USHORT LangID
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES StringMemoryAttributes
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY * StringMemory = NULL
 
WDFMEMORY hMemory
 
USHORT numChars = 0
 
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY Memory
 
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY __in_opt PWDFMEMORY_OFFSET Offset
 
IFxMemorypMemory
 
FxRequestBuffer buf
 
FxRequestpRequest
 
size_t bufferSize = buf.GetBufferLength()
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES PipesAttributes
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __inout PWDF_USB_DEVICE_SELECT_CONFIG_PARAMS Params
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __in PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __in PWDF_USB_CONTROL_SETUP_PACKET __in_opt PWDF_MEMORY_DESCRIPTOR MemoryDescriptor
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __in PWDF_USB_CONTROL_SETUP_PACKET __in_opt PWDF_MEMORY_DESCRIPTOR __out_opt PULONG BytesTransferred
 
FxUsbDeviceControlContext context (FxUrbTypeLegacy)
 
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in PWDF_USB_CONTROL_SETUP_PACKET __in_opt WDFMEMORY TransferMemory
 
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in PWDF_USB_CONTROL_SETUP_PACKET __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET TransferOffset
 
 else
 
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __in ULONG NumberOfIsochPackets
 
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __in ULONG __out WDFMEMORY * UrbMemory
 
__in WDFUSBDEVICE __in UCHAR InterfaceIndex
 
FxUsbInterfacepUsbInterface = pUsbDevice->GetInterfaceFromIndex(InterfaceIndex)
 
return NULL
 
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUIDCapabilityType
 
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG CapabilityBufferLength
 

Function Documentation

◆ __deref_opt_out_bcount()

__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __in ULONG __out WDFMEMORY __deref_opt_out_bcount ( GET_ISOCH_URB_SIZE(NumberOfIsochPackets )

Definition at line 1236 of file fxusbdeviceapi.cpp.

1267{
1268 DDI_ENTRY();
1269
1273
1275 UsbDevice,
1277 (PVOID*) &pUsbDevice,
1279
1280 //
1281 // Basic parameter validation
1282 //
1284
1285 if (pUsbDevice->GetUSBDHandle() == NULL) {
1287
1290 "USBDEVICE Must have been created with Client Contract Verion Info, %!STATUS!",
1291 status);
1292
1293 return status;
1294 }
1295
1296 status = pUsbDevice->CreateIsochUrb(Attributes,
1298 UrbMemory,
1299 Urb);
1300
1301 return status;
1302}
LONG NTSTATUS
Definition: precomp.h:26
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ FX_TYPE_IO_TARGET_USB_DEVICE
Definition: fxtypes.h:102
return NULL
pUsbDevice
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p, StringIndex %d, LandID 0x%x", UsbDevice, Request, Memory, StringIndex, LangID)
NTSTATUS status
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE_BASE,(PVOID *)&pDevice, &pFxDriverGlobals)
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ WDFREQUEST _In_ WDFMEMORY UrbMemory
Definition: wdfusb.h:1576
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFUSBDEVICE * UsbDevice
Definition: wdfusb.h:906
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ ULONG NumberOfIsochPackets
Definition: wdfusb.h:1703

◆ __drv_maxIRQL() [1/2]

◆ __drv_maxIRQL() [2/2]

_Must_inspect_result_ __drv_maxIRQL ( PASSIVE_LEVEL  )

◆ __drv_when() [1/2]

_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __drv_when ( CapabilityBufferLength  = = 0,
__out_opt   
) &&
pure virtual

◆ __drv_when() [2/2]

Definition at line 1374 of file fxusbdeviceapi.cpp.

1404{
1405 DDI_ENTRY();
1406
1410
1412 UsbDevice,
1414 (PVOID*) &pUsbDevice,
1416
1417 if (CapabilityBufferLength > 0) {
1418 FxPointerNotNull(pFxDriverGlobals, CapabilityBuffer);
1419 }
1420
1421 status = pUsbDevice->QueryUsbCapability(CapabilityType,
1423 CapabilityBuffer,
1424 ResultLength);
1425 return status;
1426}
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID _In_ ULONG CapabilityBufferLength
Definition: wdfusb.h:1615
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID * CapabilityType
Definition: wdfusb.h:1613

◆ __out_bcount()

_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __out_bcount ( CapabilityBufferLength  ) &&
pure virtual

◆ __out_bcount_part_opt()

_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG __out_bcount_part_opt ( CapabilityBufferLength  ,
ResultLength 
)

◆ CopyDeviceDescriptor()

pUsbDevice CopyDeviceDescriptor ( UsbDeviceDescriptor  )

◆ DoTraceLevelMessage() [1/6]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"format control request WDFUSBDEVICE %  p,
WDFREQWUEST %  p,
WDFMEMORY %  p,
%!STATUS!"  ,
UsbDevice  ,
Request  ,
TransferMemory  ,
status   
)

◆ DoTraceLevelMessage() [2/6]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %p control transfer sync"  ,
UsbDevice   
)

◆ DoTraceLevelMessage() [3/6]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %  p,
%!STATUS!"  ,
UsbDevice  ,
status   
)

◆ DoTraceLevelMessage() [4/6]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %  p,
WDFREQUEST %  p,
WDFMEMORY %p"  ,
UsbDevice  ,
Request  ,
TransferMemory   
)

◆ DoTraceLevelMessage() [5/6]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %  p,
WDFREQUEST %  p,
WDFMEMORY %  p,
%!STATUS!"  ,
UsbDevice  ,
Request  ,
Memory  ,
status   
)

◆ DoTraceLevelMessage() [6/6]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %  p,
WDFREQUEST %  p,
WDFMEMORY %  p,
StringIndex d,
LandID 0x%x"  ,
UsbDevice  ,
Request  ,
Memory  ,
StringIndex  ,
LangID   
)

Referenced by __deref_opt_out_bcount(), if(), and switch().

◆ FxObjectHandleGetPtr() [1/3]

FxObjectHandleGetPtr ( GetFxDriverGlobals(DriverGlobals ,
UsbDevice  ,
FX_TYPE_IO_TARGET_USB_DEVICE  ,
(PVOID *) &  pUsbDevice 
)

◆ FxObjectHandleGetPtr() [2/3]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
Memory  ,
IFX_TYPE_MEMORY  ,
(PVOID *) &  pMemory 
)

Referenced by if(), and switch().

◆ FxObjectHandleGetPtr() [3/3]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
Request  ,
FX_TYPE_REQUEST  ,
(PVOID *) &  pRequest 
)

◆ FxObjectHandleGetPtrAndGlobals() [1/2]

FxObjectHandleGetPtrAndGlobals ( GetFxDriverGlobals(DriverGlobals ,
Device  ,
FX_TYPE_DEVICE_BASE  ,
(PVOID *)&  pDevice,
pFxDriverGlobals 
)

◆ FxObjectHandleGetPtrAndGlobals() [2/2]

FxObjectHandleGetPtrAndGlobals ( GetFxDriverGlobals(DriverGlobals ,
UsbDevice  ,
FX_TYPE_IO_TARGET_USB_DEVICE  ,
(PVOID *) &  pUsbDevice,
pFxDriverGlobals 
)

◆ FxPointerNotNull() [1/9]

FxPointerNotNull ( FxDriverGlobals  ,
UsbDevice   
)

◆ FxPointerNotNull() [2/9]

FxPointerNotNull ( pFxDriverGlobals  ,
Config   
)

◆ FxPointerNotNull() [3/9]

FxPointerNotNull ( pFxDriverGlobals  ,
ConfigDescriptorLength   
)

◆ FxPointerNotNull() [4/9]

FxPointerNotNull ( pFxDriverGlobals  ,
Information   
)

◆ FxPointerNotNull() [5/9]

FxPointerNotNull ( pFxDriverGlobals  ,
NumCharacters   
)

◆ FxPointerNotNull() [6/9]

FxPointerNotNull ( pFxDriverGlobals  ,
Params   
)

◆ FxPointerNotNull() [7/9]

FxPointerNotNull ( pFxDriverGlobals  ,
SetupPacket   
)

◆ FxPointerNotNull() [8/9]

FxPointerNotNull ( pFxDriverGlobals  ,
StringMemory   
)

◆ FxPointerNotNull() [9/9]

FxPointerNotNull ( pFxDriverGlobals  ,
UsbDeviceDescriptor   
)

◆ FxUsbTargetDeviceCreate() [1/2]

return FxUsbTargetDeviceCreate ( pFxDriverGlobals  ,
pDevice  ,
Config->  USBDClientContractVersion,
Attributes  ,
UsbDevice   
)

◆ FxUsbTargetDeviceCreate() [2/2]

return FxUsbTargetDeviceCreate ( pFxDriverGlobals  ,
pDevice  ,
USBD_CLIENT_CONTRACT_VERSION_INVALID  ,
Attributes  ,
UsbDevice   
)

◆ GetConfigDescriptor()

return pUsbDevice GetConfigDescriptor ( ConfigDescriptor  ,
ConfigDescriptorLength   
)

◆ GetConfigHandle()

return pUsbDevice GetConfigHandle ( )

◆ GetInformation()

pUsbDevice GetInformation ( Information  )

◆ GetNumInterfaces()

return pUsbDevice GetNumInterfaces ( )

Referenced by DECLARE_INTERFACE().

◆ if() [1/14]

if ( NT_SUCCESSstatus)

Definition at line 80 of file fxusbdeviceapi.cpp.

80 {
81 return status;
82 }

◆ if() [2/14]

if ( (bufferSize % sizeof(WCHAR)) !  = 0)

Definition at line 600 of file fxusbdeviceapi.cpp.

600 {
602
605 "WDFMEMORY %p length must be even number of WCHARs, but is %I64d in "
606 "length, %!STATUS!",
608
609 return status;
610 }
size_t bufferSize
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169

◆ if() [3/14]

Definition at line 700 of file fxusbdeviceapi.cpp.

702 {
704
706 "Params Type %d not supported for UMDF, %!STATUS!",
707 Params->Type, status);
708
709 return status;
710
711 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

◆ if() [4/14]

Definition at line 232 of file fxusbdeviceapi.cpp.

232 {
234
237 "WDF_USB_DEVICE_CREATE_CONFIG Size 0x%x, expected 0x%x, %!STATUS!",
239
240 return status;
241 }
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476

◆ if() [5/14]

Definition at line 277 of file fxusbdeviceapi.cpp.

277 {
280 "Information size %d, expected %d %!STATUS!",
282 status);
283 return status;
284 }
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

◆ if() [6/14]

if ( NT_SUCCESS(status) &&  numChars,
 
)

Definition at line 474 of file fxusbdeviceapi.cpp.

474 {
476
481 numChars * sizeof(WCHAR),
482 &pBuffer);
483
484 if (!NT_SUCCESS(status)) {
486 }
487
489 (WDFOBJECT*)&hMemory);
490
491 if (NT_SUCCESS(status)) {
492 status = pUsbDevice->GetString((PUSHORT) pBuffer->GetBuffer(),
493 &numChars,
495 LangID);
496
497 if (NT_SUCCESS(status)) {
498 if (NumCharacters != NULL) {
500 }
502 }
503 }
504
505 if (!NT_SUCCESS(status)) {
506 //
507 // There can only be one context on this object right now,
508 // so just clear out the one.
509 //
510 pBuffer->DeleteFromFailedCreate();
511 }
512 }
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Object)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NonPagedPool
Definition: env_spec_w32.h:307
USHORT numChars
WDFMEMORY hMemory
PVOID pBuffer
uint16_t * PUSHORT
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES StringMemoryAttributes
Definition: wdfusb.h:1123
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT NumCharacters
Definition: wdfusb.h:1078
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR StringIndex
Definition: wdfusb.h:1080
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFMEMORY * StringMemory
Definition: wdfusb.h:1125
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ if() [7/14]

if ( NT_SUCCESS(status )

Definition at line 102 of file fxusbdeviceapi.cpp.

102 {
104
105 device = NULL;
106
108
109 if (NT_SUCCESS(status)) {
110 status = pUsbDevice->CreateInterfaces();
111 }
112
113 if (NT_SUCCESS(status)) {
114 status = Device->AddIoTarget(pUsbDevice);
115 }
116
117 if (NT_SUCCESS(status)) {
119 }
120
121 if (NT_SUCCESS(status)) {
122 *UsbDevice = (WDFUSBDEVICE) device;
123 }
124 }
_Must_inspect_result_ __in FxDeviceBase __in ULONG USBDClientContractVersion
Definition: devices.h:37
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

◆ if() [8/14]

if ( NumCharacters = NULL)

Definition at line 458 of file fxusbdeviceapi.cpp.

458 {
459 *NumCharacters = 0;
460 }

◆ if() [9/14]

◆ if() [10/14]

Definition at line 686 of file fxusbdeviceapi.cpp.

688 {
689
691
693 "Params Type %d not a valid value, %!STATUS!",
694 Params->Size, status);
695
696 return status;
697 }

◆ if() [11/14]

else if ( pUsbDevice->  HasMismatchedInterfacesInConfigDescriptor() = = 0)

Definition at line 721 of file fxusbdeviceapi.cpp.

721 {
722 //
723 // Config descriptor reported zero interfaces, but we found an
724 // interface descriptor in it.
725 //
727
730 "WDFUSBDEVICE %p number of interfaces found in the config descriptor "
731 "does not match bNumInterfaces in config descriptor, failing config "
732 "operation %!WdfUsbTargetDeviceSelectConfigType!, %!STATUS!",
733 UsbDevice, Params->Type, status);
734
735 return status;
736 }
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138

◆ if() [12/14]

if ( pUsbDevice  = NULL)

Definition at line 92 of file fxusbdeviceapi.cpp.

92 {
94 }

◆ if() [13/14]

if ( pUsbInterface = NULL)

Definition at line 1342 of file fxusbdeviceapi.cpp.

1342 {
1343 return pUsbInterface->GetHandle();
1344 }
WDFUSBINTERFACE GetHandle(VOID)
FxUsbInterface * pUsbInterface

◆ if() [14/14]

if ( TransferMemory = NULL)

Definition at line 1139 of file fxusbdeviceapi.cpp.

1139 {
1143 (PVOID*) &pMemory);
1144
1146 if (!NT_SUCCESS(status)) {
1147 return status;
1148 }
1149
1150 buf.SetMemory(pMemory, TransferOffset);
1151 }
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets(__in_opt PWDFMEMORY_OFFSET Offsets)
Definition: ifxmemory.hpp:105
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
FxObjectHandleGetPtr(pFxDriverGlobals, Memory, IFX_TYPE_MEMORY,(PVOID *) &pMemory)
IFxMemory * pMemory
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ WDFREQUEST _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ WDFMEMORY _In_opt_ PWDFMEMORY_OFFSET TransferOffset
Definition: wdfusb.h:1387
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ WDFREQUEST _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ WDFMEMORY TransferMemory
Definition: wdfusb.h:1384

◆ request()

FxSyncRequest request ( pFxDriverGlobals  ,
context,
Request   
)

◆ SetMemory()

buf SetMemory ( pMemory  ,
Offset   
)

◆ switch()

switch ( Params->  Type)

Definition at line 752 of file fxusbdeviceapi.cpp.

752 {
753
754#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
755
757 status = pUsbDevice->Deconfig();
758 break;
759
761 if (Params->Types.Descriptor.InterfaceDescriptors == NULL ||
762 Params->Types.Descriptor.NumInterfaceDescriptors == 0) {
766 "Either InterfaceDescriptor is NULL or NumInterfaceDescriptors is zero "
767 "WDFUSBDEVICE %p InterfaceDescriptor %p NumInterfaceDescriptors 0x%x"
768 "%!WdfUsbTargetDeviceSelectConfigType! %!STATUS!", UsbDevice,
769 Params->Types.Descriptor.InterfaceDescriptors,
770 Params->Types.Descriptor.NumInterfaceDescriptors,
771 Params->Type,
772 status);
773
774 }
775 else {
776 status = pUsbDevice->SelectConfigDescriptor(
778 Params);
779 }
780 break;
781
783 //
784 // Since the USBD macro's dont include the USBD_PIPE_INFORMATION for 0 EP's,
785 // make the length check to use
786 // sizeof(struct _URB_SELECT_CONFIGURATION) - sizeof(USBD_PIPE_INFORMATION)
787 //
788 if (Params->Types.Urb.Urb == NULL ||
789 Params->Types.Urb.Urb->UrbHeader.Function != URB_FUNCTION_SELECT_CONFIGURATION ||
790 Params->Types.Urb.Urb->UrbHeader.Length <
791 (sizeof(struct _URB_SELECT_CONFIGURATION) - sizeof(USBD_PIPE_INFORMATION))) {
795 "Either URB passed in was NULL or the URB Function or Length was invalid "
796 " WDFUSBDEVICE %p Urb 0x%p "
797 "%!WdfUsbTargetDeviceSelectConfigType!"
798 " %!STATUS!", UsbDevice,
799 Params->Types.Urb.Urb,
800 Params->Type,
801 status);
802
803 }
804 else {
805 status = pUsbDevice->SelectConfig(
807 Params->Types.Urb.Urb,
809 NULL);
810 }
811 break;
812
813#endif
814
815
816
817
818
820 if (Params->Types.MultiInterface.Pairs == NULL) {
822
825 "WDFUSBDEVICE %p SettingPairs Array passed is NULL, %!STATUS!",
826 pUsbDevice->GetHandle(),status);
827
828 break;
829 }
830 else if (Params->Types.MultiInterface.NumberInterfaces !=
831 pUsbDevice->GetNumInterfaces()) {
833
836 "WDFUSBDEVICE %p MultiInterface.NumberInterfaces %d != %d "
837 "(reported num interfaces), %!STATUS!",
838 pUsbDevice->GetHandle(),
839 Params->Types.MultiInterface.NumberInterfaces,
840 pUsbDevice->GetNumInterfaces(), status);
841
842 break;
843 }
844
845 // || || Fall through || ||
846 // \/ \/ \/ \/
848
849 //
850 // Validate SettingIndexes passed-in
851 //
852 for (ULONG i = 0;
853 i < Params->Types.MultiInterface.NumberInterfaces;
854 i++) {
855
858 UCHAR numSettings;
859
860 pair = &(Params->Types.MultiInterface.Pairs[i]);
861
863 pair->UsbInterface,
865 (PVOID*) &pUsbInterface);
866
867 numSettings = pUsbInterface->GetNumSettings();
868
869 if (pair->SettingIndex >= numSettings) {
871
874 "WDFUSBDEVICE %p SettingPairs contains invalid SettingIndex"
875 " for WDFUSBINTERFACE %p. Setting index passed in: %d, "
876 "max index: %d, returning %!STATUS!",
877 pUsbDevice->GetHandle(),
878 pair->UsbInterface,
879 pair->SettingIndex,
881 status);
882
883 return status;
884 }
885 }
886
887 status = pUsbDevice->SelectConfigMulti(
889 Params);
890 break;
891
893 status = pUsbDevice->SelectConfigSingle( //vm changed name from SelectConfigAuto
895 Params);
896 break;
897
898 default:
900 }
UCHAR GetNumSettings(VOID)
@ FX_TYPE_USB_INTERFACE
Definition: fxtypes.h:104
@ FxUrbTypeLegacy
Definition: fxusbdevice.hpp:27
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
Definition: _pair.h:47
uint32_t ULONG
Definition: typedefs.h:59
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
@ WdfUsbTargetDeviceSelectConfigTypeUrb
Definition: wdfusb.h:132
@ WdfUsbTargetDeviceSelectConfigTypeInterfacesPairs
Definition: wdfusb.h:130
@ WdfUsbTargetDeviceSelectConfigTypeSingleInterface
Definition: wdfusb.h:128
@ WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor
Definition: wdfusb.h:131
@ WdfUsbTargetDeviceSelectConfigTypeDeconfig
Definition: wdfusb.h:127
@ WdfUsbTargetDeviceSelectConfigTypeMultiInterface
Definition: wdfusb.h:129
_Must_inspect_result_ _In_ WDFUSBINTERFACE _In_opt_ PWDF_OBJECT_ATTRIBUTES PipesAttributes
Definition: wdfusb.h:2390
unsigned char UCHAR
Definition: xmlstorage.h:181

Variable Documentation

◆ Attributes

◆ buf

Definition at line 561 of file fxusbdeviceapi.cpp.

◆ bufferSize

◆ BytesTransferred

◆ CapabilityBufferLength

◆ CapabilityType

Definition at line 1366 of file fxusbdeviceapi.cpp.

◆ Config

◆ ConfigDescriptor

◆ ConfigDescriptorLength

◆ context

◆ Device

Definition at line 41 of file fxusbdeviceapi.cpp.

◆ else

else
Initial value:

Definition at line 1152 of file fxusbdeviceapi.cpp.

◆ hMemory

WDFMEMORY hMemory

Definition at line 444 of file fxusbdeviceapi.cpp.

Referenced by if().

◆ Information

Initial value:

Definition at line 260 of file fxusbdeviceapi.cpp.

◆ InterfaceIndex

__in WDFUSBDEVICE __in UCHAR InterfaceIndex
Initial value:

Definition at line 1313 of file fxusbdeviceapi.cpp.

◆ LangID

Initial value:

Definition at line 383 of file fxusbdeviceapi.cpp.

◆ Memory

_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY Memory

Definition at line 528 of file fxusbdeviceapi.cpp.

◆ MemoryDescriptor

◆ NULL

return NULL

Definition at line 1352 of file fxusbdeviceapi.cpp.

Referenced by __deref_opt_out_bcount(), if(), and switch().

◆ NumberOfIsochPackets

◆ NumCharacters

◆ numChars

◆ Offset

Definition at line 530 of file fxusbdeviceapi.cpp.

◆ Params

◆ pDevice

FxDeviceBase* pDevice

Definition at line 170 of file fxusbdeviceapi.cpp.

◆ pFxDriverGlobals

PFX_DRIVER_GLOBALS pFxDriverGlobals

Definition at line 169 of file fxusbdeviceapi.cpp.

Referenced by __deref_opt_out_bcount(), __drv_when(), if(), and switch().

◆ PipesAttributes

◆ pMemory

IFxMemory* pMemory

Definition at line 559 of file fxusbdeviceapi.cpp.

Referenced by if().

◆ pRequest

FxRequest* pRequest

Definition at line 562 of file fxusbdeviceapi.cpp.

◆ pUsbDevice

FxUsbDevice * pUsbDevice = new(FxDriverGlobals, Attributes) FxUsbDevice(FxDriverGlobals)

Definition at line 91 of file fxusbdeviceapi.cpp.

Referenced by __deref_opt_out_bcount(), __drv_when(), if(), and switch().

◆ pUsbInterface

◆ Request

_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST Request

Definition at line 373 of file fxusbdeviceapi.cpp.

◆ RequestOptions

◆ SetupPacket

◆ status

Definition at line 70 of file fxusbdeviceapi.cpp.

Referenced by __deref_opt_out_bcount(), __drv_when(), if(), and switch().

◆ STATUS_SUCCESS

return STATUS_SUCCESS

Definition at line 288 of file fxusbdeviceapi.cpp.

◆ String

◆ StringIndex

Definition at line 381 of file fxusbdeviceapi.cpp.

◆ StringMemory

Definition at line 432 of file fxusbdeviceapi.cpp.

◆ StringMemoryAttributes

◆ TransferMemory

Definition at line 1091 of file fxusbdeviceapi.cpp.

◆ TransferOffset

◆ UrbMemory

Definition at line 1235 of file fxusbdeviceapi.cpp.

◆ USBDClientContractVersion

_Must_inspect_result_ __in FxDeviceBase __in ULONG USBDClientContractVersion

Definition at line 43 of file fxusbdeviceapi.cpp.

Referenced by if(), USBD_CreateHandle(), and WDF_USB_DEVICE_CREATE_CONFIG_INIT().

◆ UsbDevice

Initial value:

Definition at line 47 of file fxusbdeviceapi.cpp.

◆ UsbDeviceDescriptor

Initial value:

Definition at line 300 of file fxusbdeviceapi.cpp.