ReactOS 0.4.15-dev-5672-gf73ac17
fxusbdeviceapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxUsbDeviceAPI.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 "FxUsbDeviceAPI.tmh"
26}
27
28//
29// Extern "C" all APIs
30//
31extern "C" {
32
38 __in
39 PFX_DRIVER_GLOBALS FxDriverGlobals,
40 __in
42 __in
46 __out
47 WDFUSBDEVICE* UsbDevice
48 )
49/*++
50
51Routine Description:
52 Creates a WDFUSBDEVICE handle for the client.
53
54Arguments:
55
56 Device - FxDeviceBase object
57
58 USBDClientContractVersion - The USBD Client Contract version of the client driver
59
60 UsbDevice - Pointer which will receive the created handle
61
62Return Value:
63 STATUS_SUCCESS - success
64 STATUS_INSUFFICIENT_RESOURCES - no memory available
65 ...
66
67 --*/
68{
71
72 //
73 // Basic parameter validation
74 //
75
76 FxPointerNotNull(FxDriverGlobals, UsbDevice);
77 *UsbDevice = NULL;
78
81 return status;
82 }
83
84 status = FxValidateObjectAttributes(FxDriverGlobals,
87 if (!NT_SUCCESS(status)) {
88 return status;
89 }
90
91 pUsbDevice = new(FxDriverGlobals, Attributes) FxUsbDevice(FxDriverGlobals);
92 if (pUsbDevice == NULL) {
94 }
95
96 //
97 // Perform all init and handle creation functions. Check for error at the
98 // end and clean up there.
99 //
100 status = pUsbDevice->Init(Device);
101
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 }
125
126 if (!NT_SUCCESS(status)) {
127 //
128 // And now free it
129 //
130 pUsbDevice->DeleteFromFailedCreate();
131 }
132
133 return status;
134}
135
139WDFAPI
140WDFEXPORT(WdfUsbTargetDeviceCreate)(
141 __in
143 __in
144 WDFDEVICE Device,
147 __out
148 WDFUSBDEVICE* UsbDevice
149 )
150/*++
151
152Routine Description:
153 Creates a WDFUSBDEVICE handle for the client.
154
155Arguments:
156 Device - WDFDEVICE handle to which we are attaching the WDFUSBDEVICE handle
157 to
158 PUsbDevice - Pointer which will receive the created handle
159
160Return Value:
161 STATUS_SUCCESS - success
162 STATUS_INSUFFICIENT_RESOURCES - no memory available
163 ...
164
165 --*/
166{
167 DDI_ENTRY();
168
171
173 Device,
175 (PVOID*)&pDevice,
177
179 pDevice,
182 UsbDevice);
183}
184
188WDFAPI
189WDFEXPORT(WdfUsbTargetDeviceCreateWithParameters)(
190 __in
192 __in
193 WDFDEVICE Device,
194 __in
198 __out
199 WDFUSBDEVICE* UsbDevice
200 )
201/*++
202
203Routine Description:
204 Creates a WDFUSBDEVICE handle for the client.
205
206Arguments:
207 Device - WDFDEVICE handle to which we are attaching the WDFUSBDEVICE handle
208 to
209 PUsbDevice - Pointer which will receive the created handle
210
211Return Value:
212 STATUS_SUCCESS - success
213 STATUS_INSUFFICIENT_RESOURCES - no memory available
214 ...
215
216 --*/
217{
218 DDI_ENTRY();
219
223
225 Device,
227 (PVOID*)&pDevice,
229
231
232 if (Config->Size != sizeof(WDF_USB_DEVICE_CREATE_CONFIG)) {
234
237 "WDF_USB_DEVICE_CREATE_CONFIG Size 0x%x, expected 0x%x, %!STATUS!",
239
240 return status;
241 }
242
244 pDevice,
245 Config->USBDClientContractVersion,
247 UsbDevice);
248}
249
253WDFAPI
254WDFEXPORT(WdfUsbTargetDeviceRetrieveInformation)(
255 __in
257 __in
258 WDFUSBDEVICE UsbDevice,
259 __out
261 )
262{
263 DDI_ENTRY();
264
268
270 UsbDevice,
272 (PVOID*) &pUsbDevice,
274
276
280 "Information size %d, expected %d %!STATUS!",
282 status);
283 return status;
284 }
285
286 pUsbDevice->GetInformation(Information);
287
289}
290
292VOID
293WDFAPI
294WDFEXPORT(WdfUsbTargetDeviceGetDeviceDescriptor)(
295 __in
297 __in
298 WDFUSBDEVICE UsbDevice,
299 __out
301 )
302{
303 DDI_ENTRY();
304
308
310 UsbDevice,
312 (PVOID*) &pUsbDevice,
314
316
318 if (!NT_SUCCESS(status)) {
319 return;
320 }
321
322 pUsbDevice->CopyDeviceDescriptor(UsbDeviceDescriptor);
323}
324
328WDFAPI
329WDFEXPORT(WdfUsbTargetDeviceRetrieveConfigDescriptor)(
330 __in
332 __in
333 WDFUSBDEVICE UsbDevice,
336 __inout
338 )
339{
340 DDI_ENTRY();
341
345
347 UsbDevice,
349 (PVOID*) &pUsbDevice,
351
353
355 if (!NT_SUCCESS(status)) {
356 return status;
357 }
358
359 return pUsbDevice->GetConfigDescriptor(ConfigDescriptor,
361}
362
366WDFAPI
367WDFEXPORT(WdfUsbTargetDeviceQueryString)(
368 __in
370 __in
371 WDFUSBDEVICE UsbDevice,
373 WDFREQUEST Request,
378 __inout
380 __in
384 )
385{
386 DDI_ENTRY();
387
391
393 UsbDevice,
395 (PVOID*) &pUsbDevice,
397
399
401 if (!NT_SUCCESS(status)) {
402 return status;
403 }
404
406 if (!NT_SUCCESS(status)) {
407 return status;
408 }
409
410 status = pUsbDevice->GetString(String,
413 LangID,
414 Request,
416
417 return status;
418}
419
423WDFAPI
424WDFEXPORT(WdfUsbTargetDeviceAllocAndQueryString)(
425 __in
427 __in
428 WDFUSBDEVICE UsbDevice,
431 __out
432 WDFMEMORY* StringMemory,
435 __in
439 )
440{
441 DDI_ENTRY();
442
444 WDFMEMORY hMemory;
448
450 UsbDevice,
452 (PVOID*) &pUsbDevice,
454
456
459 *NumCharacters = 0;
460 }
461
463 if (!NT_SUCCESS(status)) {
464 return status;
465 }
466
468 if (!NT_SUCCESS(status)) {
469 return status;
470 }
471
473
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 }
513
514 return status;
515}
516
520WDFEXPORT(WdfUsbTargetDeviceFormatRequestForString)(
521 __in
523 __in
524 WDFUSBDEVICE UsbDevice,
525 __in
526 WDFREQUEST Request,
527 __in
528 WDFMEMORY Memory,
531 __in
535 )
536/*++
537
538Routine Description:
539 Formats a request so that it can be used to query for a string from the
540 device.
541
542Arguments:
543 UsbDevice - device to be queried
544
545 Request - request to format
546
547 Memory - memory to write the string into
548
549
550Return Value:
551
552
553 --*/
554
555{
556 DDI_ENTRY();
557
565
567 UsbDevice,
569 (PVOID*) &pUsbDevice,
571
574 "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p, StringIndex %d, LandID 0x%x",
576
578 Memory,
580 (PVOID*) &pMemory);
581
583 Request,
585 (PVOID*) &pRequest);
586
588 if (!NT_SUCCESS(status)) {
589 return status;
590 }
591
592 buf.SetMemory(pMemory, Offset);
593
594 bufferSize = buf.GetBufferLength();
595
596 //
597 // the string descriptor is array of WCHARs so the buffer being used must be
598 // of an integral number of them.
599 //
600 if ((bufferSize % sizeof(WCHAR)) != 0) {
602
605 "WDFMEMORY %p length must be even number of WCHARs, but is %I64d in "
606 "length, %!STATUS!",
608
609 return status;
610 }
611
612 //
613 // While the length in the descriptor (bLength) is a byte, so the requested
614 // buffer cannot be bigger then that, do not check the bufferSize < 0xFF.
615 // We don't check because the driver can be using the WDFMEMORY as a part
616 // of a larger structure.
617 //
618
619 //
620 // Format the request
621 //
622 status = pUsbDevice->FormatStringRequest(pRequest, &buf, StringIndex, LangID);
623
624 if (NT_SUCCESS(status)) {
625 FxUsbDeviceStringContext* pContext;
626
629 pContext->m_UsbParameters.Parameters.DeviceString.StringIndex = StringIndex;
631 }
632
634 "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p, %!STATUS!",
636
637 return status;
638}
639
643WDFAPI
644WDFEXPORT(WdfUsbTargetDeviceSelectConfig)(
645 __in
647 __in
648 WDFUSBDEVICE UsbDevice,
651 __inout
653 )
654{
655 DDI_ENTRY();
656
660
662 UsbDevice,
664 (PVOID*) &pUsbDevice,
666
668
670 if (!NT_SUCCESS(status)) {
671 return status;
672 }
673
677 "Params size %d, expected %d %!STATUS!",
679 status);
680 return status;
681 }
682
683 //
684 // Sanity check the Type value as well to be in range.
685 //
687 ||
689
691
693 "Params Type %d not a valid value, %!STATUS!",
694 Params->Size, status);
695
696 return status;
697 }
698
699#if (FX_CORE_MODE == FX_CORE_USER_MODE)
704
706 "Params Type %d not supported for UMDF, %!STATUS!",
707 Params->Type, status);
708
709 return status;
710
711 }
712#endif
713
717 if (!NT_SUCCESS(status)) {
718 return status;
719 }
720
721 if (pUsbDevice->HasMismatchedInterfacesInConfigDescriptor()) {
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 }
737 else if (pUsbDevice->GetNumInterfaces() == 0) {
738 //
739 // Special case the zero interface case and exit early
740 //
742
745 "WDFUSBDEVICE %p succeeding config operation "
746 "%!WdfUsbTargetDeviceSelectConfigType! on zero interfaces "
747 "immediately, %!STATUS!", UsbDevice, Params->Type, status);
748
749 return status;
750 }
751
752 switch (Params->Type) {
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 }
901
902 return status;
903}
904
905
907UCHAR
908WDFAPI
909WDFEXPORT(WdfUsbTargetDeviceGetNumInterfaces)(
910 __in
912 __in
913 WDFUSBDEVICE UsbDevice
914 )
915{
916 DDI_ENTRY();
917
919
921 UsbDevice,
923 (PVOID*) &pUsbDevice);
924
925 return pUsbDevice->GetNumInterfaces();
926}
927
928
931WDFAPI
932WDFEXPORT(WdfUsbTargetDeviceWdmGetConfigurationHandle)(
933 __in
935 __in
936 WDFUSBDEVICE UsbDevice
937 )
938{
939 DDI_ENTRY();
940
942
944 UsbDevice,
946 (PVOID*) &pUsbDevice);
947
948 return pUsbDevice->GetConfigHandle();
949}
950
954WDFEXPORT(WdfUsbTargetDeviceSendControlTransferSynchronously)(
955 __in
957 __in
958 WDFUSBDEVICE UsbDevice,
960 WDFREQUEST Request,
963 __in
969 )
970/*++
971
972Routine Description:
973 Synchronously sends a control transfer to the default control pipe on the
974 device.
975
976Arguments:
977 UsbDevice - the target representing the device
978
979 Request - Request whose PIRP to use
980
981 RequestOptions - options to use when sending the request
982
983 SetupPacket - control setup packet to be used in the transfer
984
985 MemoryDescriptor - memory to use in the transfer after the setup packet
986
987 BytesTransferred - number of bytes sent to or by the device
988
989Return Value:
990 NTSTATUS
991
992 --*/
993{
994 DDI_ENTRY();
995
1000
1002 UsbDevice,
1004 (PVOID*) &pUsbDevice,
1006
1008
1010
1011 //
1012 // FxSyncRequest always succeesds for KM but can fail for UM.
1013 //
1014 status = request.Initialize();
1015 if (!NT_SUCCESS(status)) {
1017 "Failed to initialize FxSyncRequest");
1018 return status;
1019 }
1020
1022 "WDFUSBDEVICE %p control transfer sync", UsbDevice);
1023
1025
1027 if (!NT_SUCCESS(status)) {
1028 return status;
1029 }
1030
1032 if (!NT_SUCCESS(status)) {
1033 return status;
1034 }
1035
1036 status = buf.ValidateMemoryDescriptor(
1040 );
1041
1042 if (!NT_SUCCESS(status)) {
1043 return status;
1044 }
1045
1046 status = pUsbDevice->FormatControlRequest(request.m_TrueRequest,
1048 &buf);
1049
1050 if (NT_SUCCESS(status)) {
1053 "WDFUSBDEVICE %p, WDFREQUEST %p being submitted",
1054 UsbDevice, request.m_TrueRequest->GetTraceObjectHandle());
1055
1056 status = pUsbDevice->SubmitSync(request.m_TrueRequest, RequestOptions);
1057
1058 if (BytesTransferred != NULL) {
1059 if (NT_SUCCESS(status)) {
1060#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
1061 *BytesTransferred = context.m_Urb->TransferBufferLength;
1062#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
1063 *BytesTransferred = context.m_UmUrb.UmUrbControlTransfer.TransferBufferLength;
1064#endif
1065 }
1066 else {
1067 *BytesTransferred = 0;
1068 }
1069 }
1070 }
1071
1073 "WDFUSBDEVICE %p, %!STATUS!", UsbDevice, status);
1074
1075 return status;
1076}
1077
1081WDFEXPORT(WdfUsbTargetDeviceFormatRequestForControlTransfer)(
1082 __in
1084 __in
1085 WDFUSBDEVICE UsbDevice,
1086 __in
1087 WDFREQUEST Request,
1088 __in
1090 __in_opt
1092 __in_opt
1094 )
1095/*++
1096
1097Routine Description:
1098 Formats a request so that a control transfer can be sent to the device
1099 after this call returns successfully.
1100
1101Arguments:
1102 UsbDevice - the target representing the device
1103
1104 Request - Request to format
1105
1106 SetupPacket - control setup packet to be used in the transfer
1107
1108 TransferMemory - memory to use in the transfer after the setup packet
1109
1110 TransferOffset - offset into TransferMemory and size override for transfer
1111 length
1112
1113Return Value:
1114 NTSTATUS
1115
1116 --*/
1117{
1118 DDI_ENTRY();
1119
1126
1128 UsbDevice,
1130 (PVOID*) &pUsbDevice,
1132
1134 "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p",
1136
1138
1143 (PVOID*) &pMemory);
1144
1146 if (!NT_SUCCESS(status)) {
1147 return status;
1148 }
1149
1150 buf.SetMemory(pMemory, TransferOffset);
1151 }
1152 else {
1153 pMemory = NULL;
1154 }
1155
1157 Request,
1159 (PVOID*) &pRequest);
1160
1161 status = pUsbDevice->FormatControlRequest(pRequest, SetupPacket, &buf);
1162
1163 if (NT_SUCCESS(status)) {
1164 FxUsbDeviceControlContext* pContext;
1165
1167
1169 &pContext->m_UsbParameters.Parameters.DeviceControlTransfer.SetupPacket,
1171 sizeof(*SetupPacket)
1172 );
1173
1174 if (pMemory != NULL) {
1177 }
1178 }
1179
1181 "format control request WDFUSBDEVICE %p, WDFREQWUEST %p, WDFMEMORY %p, %!STATUS!",
1183
1184 return status;
1185}
1186
1190WDFAPI
1191WDFEXPORT(WdfUsbTargetDeviceResetPortSynchronously)(
1192 __in
1194 __in
1195 WDFUSBDEVICE UsbDevice
1196 )
1197{
1198 DDI_ENTRY();
1199
1203
1205 UsbDevice,
1207 (PVOID*) &pUsbDevice,
1209
1211 if (!NT_SUCCESS(status)) {
1212 return status;
1213 }
1214
1215 status = pUsbDevice->Reset();
1216
1217 return status;
1218}
1219
1220#pragma warning(disable:28285)
1224WDFAPI
1225WDFEXPORT(WdfUsbTargetDeviceCreateIsochUrb)(
1226 __in
1228 __in
1229 WDFUSBDEVICE UsbDevice,
1230 __in_opt
1232 __in
1234 __out
1235 WDFMEMORY* UrbMemory,
1237 PURB* Urb
1238 )
1239/*++
1240
1241Routine Description:
1242 Creates a WDFUSBDEVICE handle for the client.
1243
1244Arguments:
1245 Attributes - Attributes associated with this object
1246
1247 NumberOfIsochPacket - Maximum number of Isoch packets that will be programmed into this Urb
1248
1249 UrbMemory - The returned handle to the caller for the allocated Urb
1250
1251 Urb - (opt) Pointer to the associated urb buffer.
1252
1253Return Value:
1254 STATUS_INVALID_PARAMETER - any required parameters are not present/invalid
1255
1256 STATUS_INVALID_DEVICE_STATE - If the client did not specify a client contract verion while
1257 creating the WDFUSBDEVICE
1258
1259 STATUS_INSUFFICIENT_RESOURCES - could not allocated the object that backs
1260 the handle
1261
1262 STATUS_SUCCESS - success
1263
1264 ...
1265
1266 --*/
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}
1303
1305WDFUSBINTERFACE
1306WDFAPI
1307WDFEXPORT(WdfUsbTargetDeviceGetInterface)(
1308 __in
1310 __in
1311 WDFUSBDEVICE UsbDevice,
1312 __in
1314 )
1315/*++
1316
1317Routine Description:
1318
1319
1320Arguments:
1321
1322Return Value:
1323
1324
1325 --*/
1326
1327{
1328 DDI_ENTRY();
1329
1333
1335 UsbDevice,
1337 (PVOID*) &pUsbDevice,
1339
1340 pUsbInterface = pUsbDevice->GetInterfaceFromIndex(InterfaceIndex);
1341
1343 return pUsbInterface->GetHandle();
1344 }
1345 else {
1348 "WDFUSBDEVICE %p has %d interfaces, index %d requested, returning "
1349 "NULL handle",
1350 UsbDevice, pUsbDevice->GetNumInterfaces(), InterfaceIndex);
1351
1352 return NULL;
1353 }
1354}
1355
1359WDFAPI
1360WDFEXPORT(WdfUsbTargetDeviceQueryUsbCapability)(
1361 __in
1363 __in
1364 WDFUSBDEVICE UsbDevice,
1365 __in
1367 __in
1372 PVOID CapabilityBuffer,
1373 __out_opt
1376 )
1377/*++
1378
1379Routine Description:
1380 Queries USB capability for the device. Such capabilities are available
1381 only with USB 3.0 stack. On earlier stacks this API will fail with
1382 STATUS_NOT_IMPLEMENTED
1383
1384Arguments:
1385 UsbDevice - Device whose capability is to be queried.
1386
1387 CapabilityType - Type of capability as defined by
1388 IOCTL_INTERNAL_USB_GET_USB_CAPABILITY
1389
1390 CapabilityBufferLength - Length of Capability buffer
1391
1392 CapabilityBuffer - Buffer for capability. Can be NULL if
1393 CapabilitiyBufferLength is 0
1394
1395 ResultLength - Actual length of the capability. This parameter is optional.
1396
1397Return Value:
1398 STATUS_SUCCESS - success
1399 STATUS_NOT_IMPLEMENTED - Capabilties are not supported by USB stack
1400 STATUS_INSUFFICIENT_RESOURCES - no memory available
1401 ...
1402
1403 --*/
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}
1427
1428} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
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)
__inline FxRequestContext * GetContext(VOID)
UCHAR GetNumSettings(VOID)
WDFUSBINTERFACE GetHandle(VOID)
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets(__in_opt PWDFMEMORY_OFFSET Offsets)
Definition: ifxmemory.hpp:105
#define __out_opt
Definition: dbghelp.h:65
#define __in
Definition: dbghelp.h:35
#define __out_bcount(x)
Definition: dbghelp.h:68
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define __out_ecount_opt(x)
Definition: dbghelp.h:77
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_when(cond, annotes)
Definition: driverspecs.h:334
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:290
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NonPagedPool
Definition: env_spec_w32.h:307
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ MemoryDescriptorNullAllowed
@ MemoryDescriptorNoBufferAllowed
NTSTATUS __inline FxValidateRequestOptions(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PWDF_REQUEST_SEND_OPTIONS Options, _In_opt_ FxRequestBase *Request=NULL)
@ FX_TYPE_USB_INTERFACE
Definition: fxtypes.h:104
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
@ FX_TYPE_REQUEST
Definition: fxtypes.h:53
@ FX_TYPE_IO_TARGET_USB_DEVICE
Definition: fxtypes.h:102
@ FX_TYPE_DEVICE_BASE
Definition: fxtypes.h:83
@ FxUrbTypeLegacy
Definition: fxusbdevice.hpp:27
return FxUsbTargetDeviceCreate(pFxDriverGlobals, pDevice, USBD_CLIENT_CONTRACT_VERSION_INVALID, Attributes, UsbDevice)
FxUsbInterface * pUsbInterface
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES PipesAttributes
return NULL
_Must_inspect_result_ __in WDFUSBDEVICE __out PWDF_USB_DEVICE_INFORMATION Information
FxUsbDeviceControlContext context(FxUrbTypeLegacy)
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __out_ecount_opt NumCharacters PUSHORT __inout PUSHORT __in UCHAR StringIndex
FxObjectHandleGetPtr(pFxDriverGlobals, Memory, IFX_TYPE_MEMORY,(PVOID *) &pMemory)
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __in ULONG __out WDFMEMORY * UrbMemory
pUsbDevice
_Must_inspect_result_ __in FxDeviceBase * Device
_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 Request
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, WDFREQUEST %p, WDFMEMORY %p, StringIndex %d, LandID 0x%x", UsbDevice, Request, Memory, StringIndex, LangID)
__in WDFUSBDEVICE __in UCHAR InterfaceIndex
_Must_inspect_result_ __in FxDeviceBase __in ULONG USBDClientContractVersion
return STATUS_SUCCESS
FxDeviceBase * pDevice
FxRequestBuffer buf
_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 WDFREQUEST __in WDFMEMORY Memory
NTSTATUS status
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES StringMemoryAttributes
USHORT numChars
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID __in ULONG CapabilityBufferLength
IFxMemory * pMemory
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE_BASE,(PVOID *)&pDevice, &pFxDriverGlobals)
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __in ULONG NumberOfIsochPackets
FxRequest * pRequest
_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 WDFREQUEST __in PWDF_USB_CONTROL_SETUP_PACKET __in_opt WDFMEMORY TransferMemory
_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
__checkReturn __in WDFDEVICE __in PWDF_USB_DEVICE_CREATE_CONFIG Config
_Must_inspect_result_ __in WDFUSBDEVICE __in CONST GUID * CapabilityType
_Must_inspect_result_ __in FxDeviceBase __in ULONG __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFUSBDEVICE * UsbDevice
WDFMEMORY hMemory
size_t bufferSize
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY __in_opt PWDFMEMORY_OFFSET Offset
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY * StringMemory
__in WDFUSBDEVICE __out PUSB_DEVICE_DESCRIPTOR UsbDeviceDescriptor
_Must_inspect_result_ __in FxDeviceBase __in ULONG __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in PWDF_USB_CONTROL_SETUP_PACKET __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET TransferOffset
_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 __out_ecount_opt NumCharacters PUSHORT __inout PUSHORT __in UCHAR __in_opt USHORT LangID
PFX_DRIVER_GLOBALS pFxDriverGlobals
@ FX_VALIDATE_OPTION_PARENT_NOT_ALLOWED
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
#define __checkReturn
Definition: ms_sal.h:2873
#define __out_bcount_part_opt(size, length)
Definition: ms_sal.h:2726
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define __deref_opt_out_bcount(size)
Definition: ms_sal.h:2812
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define CONST
Definition: pedump.c:81
unsigned short USHORT
Definition: pedump.c:61
PVOID pBuffer
#define __deref_out_range(x, y)
Definition: sal_old.h:220
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
WDF_USB_REQUEST_COMPLETION_PARAMS m_UsbParameters
Definition: usb.h:529
union _WDF_USB_REQUEST_COMPLETION_PARAMS::@3701 Parameters
struct _WDF_USB_REQUEST_COMPLETION_PARAMS::@3701::@3702 DeviceString
struct _WDF_USB_REQUEST_COMPLETION_PARAMS::@3701::@3703 DeviceControlTransfer
Definition: http.c:7252
Definition: devices.h:37
Definition: _pair.h:47
Definition: tftpd.h:86
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
#define USBD_CLIENT_CONTRACT_VERSION_INVALID
Definition: usbdlib.h:99
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS RequestOptions
Definition: wdfiotarget.h:867
_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
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
#define WDFAPI
Definition: wdftypes.h:53
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID _In_ ULONG CapabilityBufferLength
Definition: wdfusb.h:1615
_In_ WDFUSBDEVICE _Out_ PUSB_DEVICE_DESCRIPTOR UsbDeviceDescriptor
Definition: wdfusb.h:1008
_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 _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID ConfigDescriptor
Definition: wdfusb.h:1036
_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_opt_ PWDF_OBJECT_ATTRIBUTES _In_ ULONG NumberOfIsochPackets
Definition: wdfusb.h:1703
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES StringMemoryAttributes
Definition: wdfusb.h:1123
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID _Inout_ PUSHORT ConfigDescriptorLength
Definition: wdfusb.h:1040
_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
Definition: wdfusb.h:1339
_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_ CONST GUID * CapabilityType
Definition: wdfusb.h:1613
_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
@ 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_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFMEMORY * StringMemory
Definition: wdfusb.h:1125
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ WDFREQUEST _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ WDFMEMORY TransferMemory
Definition: wdfusb.h:1384
_In_ WDFUSBDEVICE _In_ UCHAR InterfaceIndex
Definition: wdfusb.h:2462
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
Definition: wdfusb.h:1337
_Must_inspect_result_ _In_ WDFUSBINTERFACE _In_opt_ PWDF_OBJECT_ATTRIBUTES PipesAttributes
Definition: wdfusb.h:2390
_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
Definition: wdfusb.h:1342
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180