ReactOS  0.4.15-dev-2945-g7100a24
fxdeviceinitapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDeviceInitApi.cpp
8 
9 Abstract:
10 
11  This module exposes the "C" interface to the FxDevice object.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 --*/
24 
25 #include "coreprivshared.hpp"
26 
27 extern "C" {
28 // #include "FxDeviceInitApi.tmh"
29 }
30 
32  //
33  // Size of this structure in bytes
34  //
35  ULONG Size;
36 
38 
40 
42 
44 
46 
48 
50 
52 
54 
56 
58 
60 
62 
64 
66 
68 
70 
71 
73  //
74  // Size of this structure in bytes
75  //
76  ULONG Size;
77 
79 
81 
83 
85 
87 
89 
91 
92 typedef struct _WDF_PDO_EVENT_CALLBACKS_V1_9 {
93  //
94  // The size of this structure in bytes
95  //
96  ULONG Size;
97 
98  //
99  // Called in response to IRP_MN_QUERY_RESOURCES
100  //
102 
103  //
104  // Called in response to IRP_MN_QUERY_RESOURCE_REQUIREMENTS
105  //
107 
108  //
109  // Called in response to IRP_MN_EJECT
110  //
112 
113  //
114  // Called in response to IRP_MN_SET_LOCK
115  //
117 
118  //
119  // Called in response to the power policy owner sending a wait wake to the
120  // PDO. Bus generic arming shoulding occur here.
121  //
123 
124  //
125  // Called in response to the power policy owner sending a wait wake to the
126  // PDO. Bus generic disarming shoulding occur here.
127  //
129 
131 
132 
133 //
134 // Extern "C" the entire file
135 //
136 extern "C" {
137 
139 VOID
140 STDCALL
141 WDFEXPORT(WdfDeviceInitFree)(
142  __in
144  __in
146  )
147 {
148  DDI_ENTRY();
149 
151 
152  if (DeviceInit->CreatedOnStack == FALSE) {
153  delete DeviceInit;
154  }
155 }
156 
158 VOID
159 STDCALL
160 WDFEXPORT(WdfDeviceInitSetIoType)(
161  __in
163  __in
165  __in
167  )
168 {
169  DDI_ENTRY();
170 
172 
174 
177 
179 }
180 
182 WDFAPI
183 VOID
184 STDCALL
185 WDFEXPORT(WdfDeviceInitSetIoTypeEx)(
186  _In_
188  _In_
190  _In_
192  )
193 {
194  DDI_ENTRY();
195 
198 
200 
202 
203  if (IoTypeConfig->Size != sizeof(WDF_IO_TYPE_CONFIG)) {
206  "IoTypeConfig size (%d) incorrect, expected %d, %!STATUS!",
207  IoTypeConfig->Size,
208  sizeof(WDF_IO_TYPE_CONFIG), status);
209  return;
210  }
211 
212  DeviceInit->AssignIoType(IoTypeConfig);
213 }
214 
216 VOID
217 STDCALL
218 WDFEXPORT(WdfDeviceInitSetExclusive)(
219  __in
221  __in
223  __in
225  )
226 {
227  DDI_ENTRY();
228 
230 
231  DeviceInit->Exclusive = Exclusive;
232 }
233 
235 VOID
236 STDCALL
237 WDFEXPORT(WdfDeviceInitSetDeviceType)(
238  __in
240  __in
242  __in
244  )
245 {
246  DDI_ENTRY();
247 
249 
250  DeviceInit->DeviceType = DeviceType;
251 }
252 
254 VOID
255 STDCALL
256 WDFEXPORT(WdfDeviceInitSetPowerNotPageable)(
257  __in
259  __in
261  )
262 {
263  DDI_ENTRY();
264 
266 
267  DeviceInit->PowerPageable = FALSE;
268 }
269 
271 VOID
272 STDCALL
273 WDFEXPORT(WdfDeviceInitSetPowerPageable)(
274  __in
276  __in
278  )
279 {
280  DDI_ENTRY();
281 
283 
284  DeviceInit->PowerPageable = TRUE;
285 }
286 
288 VOID
289 STDCALL
290 WDFEXPORT(WdfDeviceInitSetPowerInrush)(
291  __in
293  __in
295  )
296 {
297  DDI_ENTRY();
298 
300 
301  //
302  // If you are inrush, there is no way you can be power pageable
303  //
304  DeviceInit->Inrush = TRUE;
305  DeviceInit->PowerPageable = FALSE;
306 }
307 
310 NTSTATUS
311 STDCALL
312 WDFEXPORT(WdfDeviceInitAssignName)(
313  __in
315  __in
317  __in_opt
319  )
320 {
321  DDI_ENTRY();
322 
324 
326 
327  status = FxVerifierCheckIrqlLevel(DeviceInit->DriverGlobals,
328  PASSIVE_LEVEL);
330  return status;
331  }
332 
333  if (DeviceName != NULL) {
334  status = FxValidateUnicodeString(DeviceInit->DriverGlobals,
335  DeviceName);
336  if (!NT_SUCCESS(status)) {
337  return status;
338  }
339  }
340 
341  if (DeviceName == NULL) {
342  if (DeviceInit->DeviceName != NULL) {
343  DeviceInit->DeviceName->RELEASE(NULL);
344  DeviceInit->DeviceName = NULL;
345  }
346 
347  if (DeviceInit->IsPdoInit()) {
348  //
349  // Make sure a PDO has a name
350  //
351  DeviceInit->Characteristics |= FILE_AUTOGENERATED_DEVICE_NAME;
352  }
353 
354  return STATUS_SUCCESS;
355  }
356 
357  return DeviceInit->AssignName(DeviceInit->DriverGlobals, DeviceName);
358 
359 }
360 
362 VOID
363 STDCALL
364 WDFEXPORT(WdfDeviceInitSetCharacteristics)(
365  __in
367  __in
369  __in
371  __in
373  )
374 {
375  DDI_ENTRY();
376 
378 
379  if (OrInValues) {
381  }
382  else {
384  }
385 
386  //
387  // If the autogenerate flag is on, clear out the device name
388  //
390  DeviceInit->DeviceName != NULL) {
391  DeviceInit->DeviceName->RELEASE(NULL);
392  DeviceInit->DeviceName = NULL;
393  }
394 }
395 
397 VOID
398 STDCALL
399 WDFEXPORT(WdfDeviceInitSetFileObjectConfig)(
400  __in
402  __in
404  __in
406  __in_opt
408  )
409 
410 /*++
411 
412 Routine Description:
413 
414  Registers callbacks for file object support.
415 
416  Defaults to WdfDeviceFileObjectNoFsContext.
417 
418 Arguments:
419 
420 Returns:
421 
422 --*/
423 
424 {
425  DDI_ENTRY();
426 
431 
433  pFxDriverGlobals = DeviceInit->DriverGlobals;
434 
436 
437  if (FileObjectConfig->Size != sizeof(WDF_FILEOBJECT_CONFIG)) {
440  "Invalid FileObjectConfig Size %d, expected %d",
441  FileObjectConfig->Size, sizeof(WDF_FILEOBJECT_CONFIG));
442 
444  return;
445  }
446 
453  );
454 
455  if (!NT_SUCCESS(status)) {
457  return;
458  }
459 
460  //
461  // Validate AutoForwardCleanupClose
462  //
463  switch (FileObjectConfig->AutoForwardCleanupClose) {
464  case WdfTrue:
465  case WdfFalse:
466  case WdfUseDefault:
467  break;
468 
469  default:
472  "Invalid FileObjectConfig->AutoForwardCleanupClose value 0x%x, "
473  "expected WDF_TRI_STATE value", FileObjectConfig->AutoForwardCleanupClose);
474 
476  return;
477  }
478 
479  DeviceInit->FileObject.Set = TRUE;
480 
481  DeviceInit->FileObject.AutoForwardCleanupClose =
482  FileObjectConfig->AutoForwardCleanupClose;
483 
484  fileClass = FileObjectConfig->FileObjectClass;
485 
486  //
487  // Remove bit flags and validate file object class value.
488  //
490 
495  "Out of range FileObjectConfig->FileObjectClass %d",
496  fileClass);
498  return;
499  }
500 
501  //
502  // UMDF doesn't support storing object handle at FsContext or FxContxt2.
503  // Update the class to WdfFileObjectWdfCannotUseFsContexts for UMDF.
504  //
508 
509  //
510  // update the FileObjectClass value
511  //
512  BOOLEAN canBeOptional =
514 
516  if (canBeOptional) {
519  }
520 
523  "FileObjectConfig->FileObjectClass value (%d) has been updated"
524  " to a UMDF-supported value %d", normalizedFileClass,
526 
527  //
528  // re-obtain the normalized class
529  //
531  }
532 
533  //
534  // The optional flag can only be combined with a subset of values.
535  //
537  switch(normalizedFileClass) {
541  break;
542 
543  default:
546  "Invalid FileObjectConfig->FileObjectClass %d",
547  fileClass);
549  return;
550  break; // just in case static verification tools complain.
551  }
552  }
553 
554  DeviceInit->FileObject.Class = fileClass;
555 
556  RtlCopyMemory(&DeviceInit->FileObject.Callbacks,
558  sizeof(DeviceInit->FileObject.Callbacks));
559 
561  RtlCopyMemory(&DeviceInit->FileObject.Attributes,
563  sizeof(DeviceInit->FileObject.Attributes));
564  }
565 }
566 
568 VOID
569 STDCALL
570 WDFEXPORT(WdfDeviceInitSetRequestAttributes)(
571  __in
573  __in
575  __in
577  )
578 {
579  DDI_ENTRY();
580 
583 
585  pFxDriverGlobals = DeviceInit->DriverGlobals;
586 
588 
589  //
590  // Parent of all requests created from WDFDEVICE are parented by the
591  // WDFDEVICE.
592  //
596 
597  if (!NT_SUCCESS(status)) {
599  return;
600  }
601 
602  RtlCopyMemory(&DeviceInit->RequestAttributes,
604  sizeof(WDF_OBJECT_ATTRIBUTES));
605 }
606 
609 NTSTATUS
610 STDCALL
611 WDFEXPORT(WdfDeviceInitAssignSDDLString)(
612  __in
614  __in
616  __in_opt
618  )
619 {
620  DDI_ENTRY();
621 
624 
626  pFxDriverGlobals = DeviceInit->DriverGlobals;
627 
629  if (!NT_SUCCESS(status)) {
630  return status;
631  }
632 
633  if (SDDLString == NULL) {
634  //
635  // Since we require the SDDL on control device creation, you can't
636  // clear it!
637  //
638  if (DeviceInit->IsControlDeviceInit()) {
640  }
641 
642  if (DeviceInit->Security.Sddl != NULL) {
643  DeviceInit->Security.Sddl->RELEASE(NULL);
644  DeviceInit->Security.Sddl = NULL;
645  }
646 
647  return STATUS_SUCCESS;
648  }
649 
651  if (!NT_SUCCESS(status)) {
652  return status;
653  }
654 
655  if (DeviceInit->Security.Sddl == NULL) {
656  DeviceInit->Security.Sddl = new(pFxDriverGlobals,
659 
660  if (DeviceInit->Security.Sddl == NULL) {
663  "Couldn't create Security descriptor"
664  " STATUS_INSUFFICIENT_RESOURCES ");
665 
667  }
668  }
669 
670  return DeviceInit->Security.Sddl->Assign(SDDLString);
671 }
672 
674 VOID
675 STDCALL
676 WDFEXPORT(WdfDeviceInitSetDeviceClass)(
677  __in
679  __in
681  __in
683  )
684 {
685  DDI_ENTRY();
686 
688 
690  pFxDriverGlobals = DeviceInit->DriverGlobals;
691 
693 
694  DeviceInit->Security.DeviceClassSet = TRUE;
695  RtlCopyMemory(&DeviceInit->Security.DeviceClass,
697  sizeof(GUID));
698 }
699 
701 VOID
702 STDCALL
703 WDFEXPORT(WdfDeviceInitSetPnpPowerEventCallbacks)(
704  __in
706  __in
708  __in
710  )
711 {
712  DDI_ENTRY();
713 
715 
717  pFxDriverGlobals = DeviceInit->DriverGlobals;
718 
720 
723 
726  "PnpPowerEventCallbacks size %d is invalid, exptected %d",
728  );
729 
731 
732  return;
733  }
734 
735  //
736  // Make sure only one of the callbacks EvtDeviceUsageNotification or
737  // EvtDeviceUsageNotificationEx is provided by driver for >V1.9.
738  //
740  PnpPowerEventCallbacks->EvtDeviceUsageNotification != NULL &&
741  PnpPowerEventCallbacks->EvtDeviceUsageNotificationEx != NULL) {
742 
745  "Driver can provide either EvtDeviceUsageNotification or "
746  "EvtDeviceUsageNotificationEx callback but not both");
747 
749 
750  return;
751  }
752 
753  //
754  // Driver's PnpPowerEventCallbacks structure may be from a previous
755  // version and therefore may be different in size than the current version
756  // that framework is using. Therefore, copy only PnpPowerEventCallbacks->Size
757  // bytes and not sizeof(PnpPowerEventCallbacks) bytes.
758  //
759  RtlCopyMemory(&DeviceInit->PnpPower.PnpPowerEventCallbacks,
761  PnpPowerEventCallbacks->Size);
762 }
763 
765 VOID
766 STDCALL
767 WDFEXPORT(WdfDeviceInitSetPowerPolicyEventCallbacks)(
768  __in
770  __in
772  __in
774  )
775 {
776  DDI_ENTRY();
777 
779 
781  pFxDriverGlobals = DeviceInit->DriverGlobals;
782 
784 
785  //
786  // The WDF_POWER_POLICY_EVENT_CALLBACKS structure size increased after v1.5.
787  // Since this api is backwards compatible, it can accept either the current
788  // structure or the older version. Validate the size of the structure here
789  // so that it is one of the two supported sizes.
790  //
795  "PowerPolicyEventCallbacks size %d is invalid, expected %d",
797  );
798 
800  return;
801  }
802 
803  //
804  // Only one of EvtDeviceArmWakeFromSx and EvtDeviceArmWakeFromSxWithReason
805  // callbacks should be specified if the given power policy callbacks structure
806  // is from a version after v1.5
807  //
809  PowerPolicyEventCallbacks->EvtDeviceArmWakeFromSx != NULL &&
810  PowerPolicyEventCallbacks->EvtDeviceArmWakeFromSxWithReason != NULL) {
813  "PowerPolicyEventCallbacks can have either EvtDeviceArmWakeFromSx "
814  "or EvtDeviceArmWakeFromSxWithReason callback pointer, but not both"
815  );
816 
818  return;
819  }
820 
821  RtlCopyMemory(&DeviceInit->PnpPower.PolicyEventCallbacks,
824 }
825 
827 VOID
828 STDCALL
829 WDFEXPORT(WdfDeviceInitSetPowerPolicyOwnership)(
830  __in
832  __in
834  __in
836  )
837 {
838  DDI_ENTRY();
839 
841 
842  DeviceInit->PnpPower.PowerPolicyOwner = IsPowerPolicyOwner ? WdfTrue : WdfFalse;
843 }
844 
847 NTSTATUS
848 STDCALL
849 WDFEXPORT(WdfDeviceInitRegisterPnpStateChangeCallback)(
850  __in
852  __in
854  __in
856  __in
858  __in
860  )
861 {
862  DDI_ENTRY();
863 
868 
870  pFxDriverGlobals = DeviceInit->DriverGlobals;
871 
873 
875 
877  if (!NT_SUCCESS(status)) {
878  return status;
879  }
880 
881  if (normalizedState < WdfDevStatePnpObjectCreated || normalizedState > WdfDevStatePnpNull) {
883 
885  "Pnp State is invalid %!STATUS!", status);
886 
887  return status;
888  }
889 
891  CallbackTypes == 0x0) {
893 
895  "CallbackTypes is invalid %!STATUS!", status);
896 
897  return status;
898  }
899 
900  if (DeviceInit->PnpPower.PnpStateCallbacks == NULL) {
901 
902  DeviceInit->PnpPower.PnpStateCallbacks =
904 
905  if (DeviceInit->PnpPower.PnpStateCallbacks == NULL) {
907 
910  "Couldn't create object PnpStateCallbacks %!STATUS!", status);
911 
912  return status;
913  }
914  }
915 
916  pCallback = &DeviceInit->PnpPower.PnpStateCallbacks->m_Methods[
918 
921 
923 }
924 
927 NTSTATUS
928 STDCALL
929 WDFEXPORT(WdfDeviceInitRegisterPowerStateChangeCallback)(
930  __in
932  __in
934  __in
936  __in
938  __in
940  )
941 {
942  DDI_ENTRY();
943 
948 
950  pFxDriverGlobals = DeviceInit->DriverGlobals;
951 
953 
955 
957  if (!NT_SUCCESS(status)) {
958  return status;
959  }
960 
964 
966  "PowerState State is invalid %!STATUS!", status);
967 
968  return status;
969  }
970 
972  CallbackTypes == 0x0) {
974 
976  "CallbackTypes is invalid %!STATUS!"
977  "STATUS_INVALID_PARAMETER", status);
978 
979  return status;
980  }
981 
982  if (DeviceInit->PnpPower.PowerStateCallbacks == NULL) {
983  DeviceInit->PnpPower.PowerStateCallbacks =
985 
986  if (DeviceInit->PnpPower.PowerStateCallbacks == NULL) {
988 
991  "Couldn't create object PowerStateCallbacks %!STATUS!", status);
992 
993  return status;
994  }
995  }
996 
997  pCallback = &DeviceInit->PnpPower.PowerStateCallbacks->m_Methods[
999 
1002 
1003  return STATUS_SUCCESS;
1004 }
1005 
1008 NTSTATUS
1009 STDCALL
1010 WDFEXPORT(WdfDeviceInitRegisterPowerPolicyStateChangeCallback)(
1011  __in
1013  __in
1015  __in
1017  __in
1019  __in
1021  )
1022 {
1023  DDI_ENTRY();
1024 
1028  NTSTATUS status;
1029 
1031  pFxDriverGlobals = DeviceInit->DriverGlobals;
1032 
1034 
1036 
1038  if (!NT_SUCCESS(status)) {
1039  return status;
1040  }
1041 
1045 
1048  "PowerPolicyState State is invalid %!STATUS!", status);
1049 
1050  return status;
1051  }
1052 
1053  if ((CallbackTypes & ~StateNotificationAllStates) != 0 ||
1054  CallbackTypes == 0x0) {
1056 
1058  "CallbackTypes is invalid %!STATUS!", status);
1059 
1060  return status;
1061  }
1062 
1063  if (DeviceInit->PnpPower.PowerPolicyStateCallbacks == NULL) {
1064  DeviceInit->PnpPower.PowerPolicyStateCallbacks =
1066 
1067  if (DeviceInit->PnpPower.PowerPolicyStateCallbacks == NULL) {
1069 
1072  "Couldn't create object PowerPolicyStateCallbacks %!STATUS!", status);
1073 
1074  return status;
1075  }
1076  }
1077 
1078  pCallback = &DeviceInit->PnpPower.PowerPolicyStateCallbacks->m_Methods[
1080 
1083 
1084  return STATUS_SUCCESS;
1085 }
1086 
1089 WDFAPI
1090 NTSTATUS
1091 STDCALL
1092 WDFEXPORT(WdfDeviceInitAssignWdmIrpPreprocessCallback)(
1093  __in
1095  __in
1097  __in
1099  __in
1104  __in
1106  )
1108  DDI_ENTRY();
1109 
1111 
1113  pFxDriverGlobals = DeviceInit->DriverGlobals;
1114 
1116 
1119  }
1120 
1121  //
1122  // ARRAY_SIZE(DeviceInit->PreprocessInfo->Dispatch) just returns a constant
1123  // size, it does not actually deref PreprocessInfo (which could be NULL)
1124  //
1125  if (MajorFunction >= ARRAY_SIZE(DeviceInit->PreprocessInfo->Dispatch)) {
1127  "MajorFunction is invalid"
1128  "STATUS_INVALID_PARAMETER"
1129  );
1130 
1131  return STATUS_INVALID_PARAMETER;
1132  }
1133 
1134  if (DeviceInit->PreprocessInfo == NULL) {
1135  DeviceInit->PreprocessInfo = new(pFxDriverGlobals) FxIrpPreprocessInfo();
1136 
1137  if (DeviceInit->PreprocessInfo == NULL) {
1139  "Couldn't create object PreprocessInfo"
1140  "STATUS_INSUFFICIENT_RESOURCES"
1141  );
1142 
1143 
1145  }
1146  }
1147 
1148  if (NumMinorFunctions > 0) {
1149  if (DeviceInit->PreprocessInfo->Dispatch[MajorFunction].NumMinorFunctions != 0) {
1150 
1152  "Already assigned Minorfunctions"
1153  "STATUS_INVALID_DEVICE_REQUEST"
1154  );
1156  }
1157 
1158  DeviceInit->PreprocessInfo->Dispatch[MajorFunction].MinorFunctions =
1159  (PUCHAR) FxPoolAllocate(pFxDriverGlobals,
1160  NonPagedPool,
1161  sizeof(UCHAR) * NumMinorFunctions);
1162 
1163  if (DeviceInit->PreprocessInfo->Dispatch[MajorFunction].MinorFunctions == NULL) {
1164 
1166  "Couldn't create object MinorFunctions"
1167  "STATUS_INSUFFICIENT_RESOURCES"
1168  );
1169 
1171  }
1172 
1173  RtlCopyMemory(
1174  &DeviceInit->PreprocessInfo->Dispatch[MajorFunction].MinorFunctions[0],
1175  &MinorFunctions[0],
1177  );
1178 
1179  DeviceInit->PreprocessInfo->Dispatch[MajorFunction].NumMinorFunctions =
1181  }
1182 
1185 
1186  return STATUS_SUCCESS;
1187 }
1188 
1189 
1191 VOID
1192 STDCALL
1193 WDFEXPORT(WdfDeviceInitSetIoInCallerContextCallback)(
1194  __in
1196  __in
1198  __in
1200  )
1201 
1202 /*++
1203 
1204 Routine Description:
1205 
1206  Registers an I/O pre-processing callback for the device.
1207 
1208  If registered, any I/O for the device is first presented to this
1209  callback function before being placed in any I/O Queue's.
1210 
1211  The callback is invoked in the thread and/or DPC context of the
1212  original WDM caller as presented to the I/O package. No framework
1213  threading, locking, synchronization, or queuing occurs, and
1214  responsibility for synchronization is up to the device driver.
1215 
1216  This API is intended to support METHOD_NEITHER IRP_MJ_DEVICE_CONTROL's
1217  which must access the user buffer in the original callers context. The
1218  driver would probe and lock the buffer pages from within this event
1219  handler using the functions supplied on the WDFREQUEST object, storing
1220  any required mapped buffers and/or pointers on the WDFREQUEST context
1221  whose size is set by the RequestContextSize of the WDF_DRIVER_CONFIG structure.
1222 
1223  It is the responsibility of this routine to either complete the request, or
1224  pass it on to the I/O package through WdfDeviceEnqueueRequest(Device, Request).
1225 
1226 Arguments:
1227  DeviceInit - Device initialization structure
1228 
1229  EvtIoInCallerContext - Pointer to driver supplied callback function
1230 
1231 Return Value:
1232 
1233 --*/
1235  DDI_ENTRY();
1236 
1239 
1240  DeviceInit->IoInCallerContextCallback = EvtIoInCallerContext;
1241 
1242  return;
1243 }
1244 
1246 VOID
1247 STDCALL
1248 WDFEXPORT(WdfDeviceInitSetRemoveLockOptions)(
1249  __in
1251  __in
1253  __in
1255  )
1257  DDI_ENTRY();
1258 
1261 
1263 
1265 
1267  //
1268  // Size is wrong, bail out
1269  //
1271  "RemoveLockOptions %p Size incorrect, expected %d, "
1272  "got %d",
1274  RemoveLockOptions->Size);
1275 
1277  goto Done;
1278  }
1279 
1280  if ((RemoveLockOptions->Flags & ~validFlags) != 0) {
1281  //
1282  // Invalid flag
1283  //
1285  "RemoveLockOptions %p Flags 0x%x invalid, "
1286  "valid mask is 0x%x",
1288  validFlags);
1289 
1291  goto Done;
1292  }
1293 
1295  //
1296  // At this time this feature is not supported on control-devices.
1297  //
1299  "WdfDeviceInitSetRemoveLockOptions is not "
1300  "supported on control devices");
1301 
1303  goto Done;
1304  }
1305 
1306  DeviceInit->RemoveLockOptionFlags = RemoveLockOptions->Flags;
1307 Done:
1308  return;
1309 }
1310 
1312 VOID
1313 STDCALL
1314 WDFEXPORT(WdfDeviceInitSetReleaseHardwareOrderOnFailure)(
1315  __in
1317  __in
1319  __in
1321  )
1323  DDI_ENTRY();
1324 
1326 
1332  DeviceInit->DriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
1333  "Out of range WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE %d",
1335  FxVerifierDbgBreakPoint(DeviceInit->DriverGlobals);
1336  return;
1337  }
1338 
1339  DeviceInit->ReleaseHardwareOrderOnFailure = ReleaseHardwareOrderOnFailure;
1340 }
1341 
1343 VOID
1344 STDCALL
1345 WDFEXPORT(WdfDeviceInitAllowSelfIoTarget)(
1346  _In_
1348  _In_
1350  )
1351 /*++
1352 
1353 Routine Description:
1354 
1355  A client or Cx calls this API to indicate that it would like to leverage an
1356  Self IO target.
1357 
1358  For now the Self targets are not supported for PDOs, Miniport Device,
1359  or non pnp Devices.
1360 
1361 Arguments:
1362 
1363  DeviceInit - Pointer to the WDFDEVICE_INIT structure
1364 
1365 Returns:
1366 
1367  VOID
1368 
1369 --*/
1370 {
1371  DDI_ENTRY();
1372 
1374 
1375  DeviceInit->RequiresSelfIoTarget = TRUE;
1376 }
1377 
1378 
1379 
1380 //
1381 // BEGIN FDO specific functions
1382 //
1383 
1386 STDCALL
1387 WDFEXPORT(WdfFdoInitWdmGetPhysicalDevice)(
1388  __in
1390  __in
1392  )
1393 {
1394  DDI_ENTRY();
1395 
1397 
1398  if (DeviceInit->IsNotFdoInit()) {
1400  DeviceInit->DriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
1401  "Not a PWDFDEVICE_INIT for an FDO"
1402  );
1403 
1404  return NULL;
1405  }
1406 
1407  return reinterpret_cast<PDEVICE_OBJECT>(DeviceInit->Fdo.PhysicalDevice);
1408 }
1409 
1412 NTSTATUS
1413 STDCALL
1414 WDFEXPORT(WdfFdoInitOpenRegistryKey)(
1415  __in
1417  __in
1419  __in
1421  __in
1423  __in_opt
1425  __out
1426  WDFKEY* Key
1427  )
1429  DDI_ENTRY();
1430 
1432  NTSTATUS status;
1433 
1435  pFxDriverGlobals = DeviceInit->DriverGlobals;
1436 
1438 
1439  *Key = NULL;
1440 
1441  if (DeviceInit->IsNotFdoInit()) {
1444  "Not a PWDFDEVICE_INIT for an FDO, %!STATUS!",
1445  status);
1446  return status;
1447  }
1448 
1450  if (!NT_SUCCESS(status)) {
1451  return status;
1452  }
1453 
1455  DeviceInit,
1456  NULL,
1458  DesiredAccess,
1459  KeyAttributes,
1460  Key);
1461 }
1462 
1464 VOID
1465 STDCALL
1466 WDFEXPORT(WdfFdoInitSetFilter)(
1467  __in
1469  __in
1471  )
1472 {
1473  DDI_ENTRY();
1474 
1476 
1478  pFxDriverGlobals = DeviceInit->DriverGlobals;
1479 
1481  PASSIVE_LEVEL))) {
1482  return;
1483  }
1484  if (DeviceInit->IsNotFdoInit()) {
1487  "Not a PWDFDEVICE_INIT for an FDO");
1488 
1490  return;
1491  }
1492 
1493  DeviceInit->Fdo.Filter = TRUE;
1494 }
1495 
1498 NTSTATUS
1499 STDCALL
1500 WDFEXPORT(WdfFdoInitQueryProperty)(
1501  __in
1503  __in
1505  __in
1507  __in
1511  __out
1513  )
1514 /*++
1515 
1516 Routine Description:
1517  Retrieves the requested device property for the given device
1518 
1519 Arguments:
1520  DeviceInit - Device initialization structure
1521 
1522  DeviceProperty - the property being queried
1523 
1524  BufferLength - length of PropertyBuffer in bytes
1525 
1526  PropertyBuffer - Buffer which will receive the property being queried
1527 
1528  ResultLength - if STATUS_BUFFER_TOO_SMALL is returned, then this will contain
1529  the required length
1530 
1531 Return Value:
1532  NTSTATUS
1533 
1534  --*/
1536  DDI_ENTRY();
1537 
1539  NTSTATUS status;
1540 
1542  pFxDriverGlobals = DeviceInit->DriverGlobals;
1543 
1545  if (BufferLength > 0) {
1547  }
1548 
1550  if (!NT_SUCCESS(status)) {
1551  return status;
1552  }
1553 
1554  if (DeviceInit->IsNotFdoInit()) {
1557  "Not a PWDFDEVICE_INIT for an FDO, %!STATUS!",
1558  status);
1559  return status;
1560  }
1561 
1563  DeviceInit,
1564  NULL,
1565  NULL,
1567  BufferLength,
1569  ResultLength);
1570  return status;
1571 }
1572 
1575 NTSTATUS
1576 STDCALL
1577 WDFEXPORT(WdfFdoInitAllocAndQueryProperty)(
1578  __in
1580  __in
1582  __in
1584  __in
1585  __drv_strictTypeMatch(__drv_typeExpr)
1587  __in_opt
1589  __out
1590  WDFMEMORY* PropertyMemory
1591  )
1592 /*++
1593 
1594 Routine Description:
1595  Allocates and retrieves the requested device property for the given device init
1596 
1597 Arguments:
1598  DeviceInit - Device initialization structure
1599 
1600  DeviceProperty - the property being queried
1601 
1602  PoolType - what type of pool to allocate
1603 
1604  PropertyMemoryAttributes - attributes to associate with PropertyMemory
1605 
1606  PropertyMemory - handle which will receive the property buffer
1607 
1608 Return Value:
1609  NTSTATUS
1610 
1611  --*/
1613  DDI_ENTRY();
1614 
1616  NTSTATUS status;
1617 
1619  pFxDriverGlobals = DeviceInit->DriverGlobals;
1620 
1622 
1623  *PropertyMemory = NULL;
1624 
1626  if (!NT_SUCCESS(status)) {
1627  return status;
1628  }
1629 
1631 
1633  if (!NT_SUCCESS(status)) {
1634  return status;
1635  }
1636 
1637  if (DeviceInit->IsNotFdoInit()) {
1639 
1641  "Not a PWDFDEVICE_INIT for an FDO, %!STATUS!",
1642  status);
1643 
1644  return status;
1645  }
1646 
1648  DeviceInit,
1649  NULL,
1650  NULL,
1652  PoolType,
1654  PropertyMemory);
1655  return status;
1656 }
1657 
1659 VOID
1660 STDCALL
1661 WDFEXPORT(WdfFdoInitSetEventCallbacks)(
1662  __in
1664  __in
1666  __in
1668  )
1670  DDI_ENTRY();
1671 
1673 
1675  pFxDriverGlobals = DeviceInit->DriverGlobals;
1676 
1678 
1680  return;
1681  }
1682 
1683  if (DeviceInit->IsNotFdoInit()) {
1685  "Not a PWDFDEVICE_INIT for an FDO");
1687  return;
1688  }
1689 
1693  "FdoEventCallbacks size %d is invalid, expected %d",
1695  );
1697  return;
1698  }
1699 
1700  if (FdoEventCallbacks->EvtDeviceFilterAddResourceRequirements != NULL &&
1701  FdoEventCallbacks->EvtDeviceRemoveAddedResources == NULL) {
1702  //
1703  // Not allowed to add resources without filtering them out later
1704  //
1707  "Must set EvtDeviceRemoveAddedResources if "
1708  "EvtDeviceFilterAddResourceRequirements (%p) is set",
1709  FdoEventCallbacks->EvtDeviceFilterAddResourceRequirements);
1710 
1712  return;
1713  }
1714 
1715  RtlCopyMemory(&DeviceInit->Fdo.EventCallbacks,
1717  sizeof(DeviceInit->Fdo.EventCallbacks));
1718 }
1719 
1721 VOID
1722 STDCALL
1723 WDFEXPORT(WdfFdoInitSetDefaultChildListConfig)(
1724  __in
1726  __inout
1728  __in
1730  __in_opt
1732  )
1734  DDI_ENTRY();
1735 
1737  NTSTATUS status;
1739 
1741  pFxDriverGlobals = DeviceInit->DriverGlobals;
1743 
1745 
1747  if (!NT_SUCCESS(status)) {
1748  return;
1749  }
1750 
1751  if (DeviceInit->IsNotFdoInit()) {
1753  "Not a PWDFDEVICE_INIT for an FDO");
1755  return;
1756  }
1757 
1759  Config,
1761  if (!NT_SUCCESS(status)) {
1763  return;
1764  }
1765 
1770  if (!NT_SUCCESS(status)) {
1772  return;
1773  }
1774 
1775  RtlCopyMemory(&DeviceInit->Fdo.ListConfigAttributes,
1777  sizeof(DeviceInit->Fdo.ListConfigAttributes));
1778  }
1779 
1780  RtlCopyMemory(&DeviceInit->Fdo.ListConfig,
1781  Config,
1782  sizeof(WDF_CHILD_LIST_CONFIG));
1783 }
1784 
1787 WDFAPI
1788 NTSTATUS
1789 STDCALL
1790 WDFEXPORT(WdfFdoInitQueryPropertyEx)(
1791  _In_
1793  _In_
1795  _In_
1797  _In_
1799  _Out_
1801  _Out_
1803  _Out_
1805  )
1806 /*++
1807 
1808 Routine Description:
1809 
1810  This routine queries device property.
1811 
1812 Arguments:
1813 
1814  DriverGlobals - DriverGlobals pointer
1815 
1816  DeviceInit - WDF DeviceInit structure pointer.
1817 
1818  DeviceProperty - A pointer to WDF_DEVICE_PROPERTY_DATA structure.
1819 
1820  BufferLength - The size, in bytes, of the buffer that is pointed to by
1821  PropertyBuffer.
1822 
1823  PropertyBuffer - A caller-supplied pointer to a caller-allocated buffer that
1824  receives the requested information. The pointer can be NULL
1825  if the BufferLength parameter is zero.
1826 
1827  ResultLength - A caller-supplied location that, on return, contains the
1828  size, in bytes, of the information that the method stored in
1829  PropertyBuffer. If the function's return value is
1830  STATUS_BUFFER_TOO_SMALL, this location receives the required
1831  buffer size.
1832 
1833  Type - A pointer to a DEVPROPTYPE variable. If method successfully retrieves
1834  the property data, the routine writes the property type value
1835  to this variable. This value indicates the type of property
1836  data that is in the Data buffer.
1837 
1838 Return Value:
1839 
1840  Method returns an NTSTATUS value. This routine might return one of the
1841  following values.
1842 
1843  STATUS_BUFFER_TOO_SMALL - The supplied buffer is too small to receive the
1844  information. The ResultLength member receives the
1845  size of buffer required.
1846  STATUS_SUCCESS - The operation succeeded.
1847  STATUS_INVALID_PARAMETER - One of the parameters is incorrect.
1848 
1849  The method might return other NTSTATUS values.
1850 
1851 --*/
1852 
1854  DDI_ENTRY();
1855 
1857  NTSTATUS status;
1858 
1860  pFxDriverGlobals = DeviceInit->DriverGlobals;
1861 
1863 
1867  "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
1868  DeviceProperty->Size,
1869  sizeof(WDF_DEVICE_PROPERTY_DATA), status);
1870  return status;
1871  }
1872 
1874  if (BufferLength > 0) {
1876  }
1877 
1879  if (!NT_SUCCESS(status)) {
1880  return status;
1881  }
1882 
1883  if (DeviceInit->IsNotFdoInit()) {
1886  "Not a PWDFDEVICE_INIT for an FDO, %!STATUS!",
1887  status);
1888  return status;
1889  }
1890 
1892  DeviceInit,
1893  NULL,
1896  BufferLength,
1898  ResultLength,
1899  Type);
1900  return status;
1901 }
1902 
1905 WDFAPI
1906 NTSTATUS
1907 STDCALL
1908 WDFEXPORT(WdfFdoInitAllocAndQueryPropertyEx)(
1909  _In_
1911  _In_
1913  _In_
1915  _In_
1918  _In_opt_
1920  _Out_
1921  WDFMEMORY* PropertyMemory,
1922  _Out_
1924  )
1925 /*++
1926 
1927 Routine Description:
1928 
1929  This routine queries device property.
1930 
1931 Arguments:
1932 
1933  DriverGlobals - DriverGlobals pointer
1934 
1935  DeviceInit - WDF DeviceInit pointer.
1936 
1937  PropertyData - A pointer to WDF_DEVICE_PROPERTY_ DATA structure.
1938 
1939  PoolType - A POOL_TYPE-typed enumerator that specifies the type of memory
1940  to be allocated.
1941 
1942  PropertyMemoryAttributes - optional, A pointer to a caller-allocated
1943  WDF_OBJECT_ATTRIBUTES structure that describes object attributes
1944  for the memory object that the function will allocate. This
1945  parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.
1946 
1947  PropertyMemory - A pointer to a WDFMEMORY-typed location that receives a
1948  handle to a framework memory object.
1949 
1950  Type - A pointer to a DEVPROPTYPE variable. If method successfully retrieves
1951  the property data, the routine writes the property type value to
1952  this variable. This value indicates the type of property data
1953  that is in the Data buffer.
1954 
1955 Return Value:
1956 
1957  Method returns an NTSTATUS value. This routine might return one of the
1958  following values. It might return other NTSTATUS-codes as well.
1959 
1960  STATUS_SUCCESS The operation succeeded.
1961  STATUS_INVALID_PARAMETER One of the parameters is incorrect.
1962 
1963 --*/
1964 {
1965  DDI_ENTRY();
1966 
1968  NTSTATUS status;
1969 
1971  pFxDriverGlobals = DeviceInit->DriverGlobals;
1972 
1974 
1975  if (DeviceProperty->Size != sizeof(WDF_DEVICE_PROPERTY_DATA)) {
1978  "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
1979  DeviceProperty->Size,
1980  sizeof(WDF_DEVICE_PROPERTY_DATA), status);
1981  return status;
1982  }
1983 
1985 
1986  *PropertyMemory = NULL;
1987 
1989  if (!NT_SUCCESS(status)) {
1990  return status;
1991  }
1992 
1994 
1996  if (!NT_SUCCESS(status)) {
1997  return status;
1998  }
1999 
2000  if (DeviceInit->IsNotFdoInit()) {
2002 
2004  "Not a PWDFDEVICE_INIT for an FDO, %!STATUS!",
2005  status);
2006 
2007  return status;
2008  }
2009 
2011  DeviceInit,
2012  NULL,
2015  PoolType,
2018  Type);
2019  return status;
2020 }
2021 
2022 //
2023 // END FDO specific functions
2024 //
2025 
2026 //
2027 // BEGIN PDO specific functions
2028 //
2032 STDCALL
2033 WDFEXPORT(WdfPdoInitAllocate)(
2034  __in
2036  __in
2037  WDFDEVICE ParentDevice
2038  )
2040  DDI_ENTRY();
2041 
2045  NTSTATUS status;
2046 
2048  ParentDevice,
2050  (PVOID*) &pDevice,
2051  &pFxDriverGlobals);
2052 
2054  if (!NT_SUCCESS(status)) {
2055  return NULL;
2056  }
2057 
2058  if (pDevice->IsFdo() == FALSE) {
2061  "Parent device is not a FDO (must use WDFCHILDLIST to use a PDO as a parent)"
2062  );
2063 
2064  return NULL;
2065  }
2066 
2068  if (pInit == NULL) {
2070  "Couldn't create WDFDEVICE_INIT object");
2071 
2072  return NULL;
2073  }
2074 
2075  pInit->SetPdo(pDevice);
2076 
2077  //
2078  // Dynamically created PDOs are not created with this API, rather they go
2079  // through WDFCHILDLIST's callback.
2080  //
2082 
2083  return pInit;
2084 }
2085 
2087 VOID
2088 STDCALL
2089 WDFEXPORT(WdfPdoInitSetEventCallbacks)(
2090  __in
2092  __in
2094  __in
2096  )
2098  DDI_ENTRY();
2099 
2101 
2103  pFxDriverGlobals = DeviceInit->DriverGlobals;
2104 
2106 
2108  return;
2109  }
2110 
2111  if (DeviceInit->IsNotPdoInit()) {
2113  "Not a PWDFDEVICE_INIT for a PDO");
2115  return;
2116  }
2117 
2118  if (DispatchTable->Size != sizeof(WDF_PDO_EVENT_CALLBACKS) &&
2119  DispatchTable->Size != sizeof(WDF_PDO_EVENT_CALLBACKS_V1_9)) {
2121  "DispatchTable size %d is invalid, expected %d",
2122  DispatchTable->Size, sizeof(WDF_PDO_EVENT_CALLBACKS));
2124  return; // STATUS_INFO_LENGTH_MISMATCH;
2125  }
2126 
2127  RtlCopyMemory(&DeviceInit->Pdo.EventCallbacks,
2128  DispatchTable,
2129  sizeof(WDF_PDO_EVENT_CALLBACKS));
2130 }
2131 
2134 NTSTATUS
2135 STDCALL
2136 WDFEXPORT(WdfPdoInitAssignDeviceID)(
2137  __in
2139  __in
2141  __in
2143  )
2145  DDI_ENTRY();
2146 
2148  NTSTATUS status;
2149 
2151  pFxDriverGlobals = DeviceInit->DriverGlobals;
2152 
2154 
2156  if (!NT_SUCCESS(status)) {
2157  return status;
2158  }
2159 
2161  if (!NT_SUCCESS(status)) {
2162  return status;
2163  }
2164 
2165  if (DeviceInit->IsNotPdoInit()) {
2168  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2169  status);
2170  return status;
2171  }
2172 
2173  if (DeviceInit->Pdo.DeviceID == NULL) {
2176 
2177  if (DeviceInit->Pdo.DeviceID == NULL) {
2180  "Couldn't allocate DeviceID object, %!STATUS!",
2181  status);
2182  return status;
2183  }
2184  }
2185 
2186  status = DeviceInit->Pdo.DeviceID->Assign(DeviceID);
2187 
2188  return status;
2189 }
2190 
2193 NTSTATUS
2194 STDCALL
2195 WDFEXPORT(WdfPdoInitAssignInstanceID)(
2196  __in
2198  __in
2200  __in
2202  )
2204  DDI_ENTRY();
2205 
2207  NTSTATUS status;
2208 
2210  pFxDriverGlobals = DeviceInit->DriverGlobals;
2211 
2213 
2215  if (!NT_SUCCESS(status)) {
2216  return status;
2217  }
2218 
2220  if (!NT_SUCCESS(status)) {
2221  return status;
2222  }
2223 
2224  if (DeviceInit->IsNotPdoInit()) {
2227  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2228  status);
2229  return status;
2230  }
2231 
2232  if (DeviceInit->Pdo.InstanceID == NULL) {
2233  DeviceInit->Pdo.InstanceID = new(pFxDriverGlobals, WDF_NO_OBJECT_ATTRIBUTES)
2235 
2236  if (DeviceInit->Pdo.InstanceID == NULL) {
2239  "Couldn't allocate InstanceID object, %!STATUS!",
2240  status);
2241  return status;
2242  }
2243  }
2244 
2245  status = DeviceInit->Pdo.InstanceID->Assign(InstanceID);
2246 
2247  return status;
2248 }
2249 
2252 NTSTATUS
2253 STDCALL
2254 WDFEXPORT(WdfPdoInitAddHardwareID)(
2255  __in
2257  __in
2259  __in
2261  )
2263  DDI_ENTRY();
2264 
2267  NTSTATUS status;
2268 
2270  pFxDriverGlobals = DeviceInit->DriverGlobals;
2271 
2273 
2275  if (!NT_SUCCESS(status)) {
2276  return status;
2277  }
2278 
2280  if (!NT_SUCCESS(status)) {
2281  return status;
2282  }
2283 
2284  if (DeviceInit->IsNotPdoInit()) {
2287  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2288  status);
2289  return status;
2290  }
2291 
2293  if (pID == NULL) {
2297  "Couldn't allocate String object %!STATUS!", status);
2298  return status;
2299  }
2300 
2303  status = (DeviceInit->Pdo.HardwareIDs.Add(pFxDriverGlobals, pID)) ?
2305  }
2306 
2307  //
2308  // Upon success, the FxCollection will have taken a reference.
2309  // Upon failure, this is object cleanup.
2310  //
2311  pID->Release();
2312 
2313  return status;
2314 }
2315 
2318 NTSTATUS
2319 STDCALL
2320 WDFEXPORT(WdfPdoInitAddCompatibleID)(
2321  __in
2323  __in
2325  __in
2327  )
2329  DDI_ENTRY();
2330 
2332  FxString* pID;
2333  NTSTATUS status;
2334 
2336  pFxDriverGlobals = DeviceInit->DriverGlobals;
2337 
2339 
2341  if (!NT_SUCCESS(status)) {
2342  return status;
2343  }
2344 
2346  if (!NT_SUCCESS(status)) {
2347  return status;
2348  }
2349 
2350  if (DeviceInit->IsNotPdoInit()) {
2353  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2354  status);
2355  return status;
2356  }
2357 
2359  if (pID == NULL) {
2361  "Couldn't allocate String object"
2362  "STATUS_INSUFFICIENT_RESOURCES "
2363  );
2365  }
2366 
2368  if (NT_SUCCESS(status)) {
2369  status = (DeviceInit->Pdo.CompatibleIDs.Add(pFxDriverGlobals, pID)) ?
2371  }
2372 
2373  //
2374  // Upon success, the FxCollection will have taken a reference. Upon failure,
2375  // this is object cleanup.
2376  //
2377  pID->Release();
2378 
2379  return status;
2380 }
2381 
2384 NTSTATUS
2385 STDCALL
2386 WDFEXPORT(WdfPdoInitAssignContainerID)(
2387  __in
2389  __in
2391  __in
2393  )
2395  DDI_ENTRY();
2396 
2398  NTSTATUS status;
2399 
2401  pFxDriverGlobals = DeviceInit->DriverGlobals;
2402 
2404 
2406  if (!NT_SUCCESS(status)) {
2407  return status;
2408  }
2409 
2411  if (!NT_SUCCESS(status)) {
2412  return status;
2413  }
2414 
2415  if (DeviceInit->IsNotPdoInit()) {
2418  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2419  status);
2420  return status;
2421  }
2422 
2423  if (DeviceInit->Pdo.ContainerID == NULL) {
2424  DeviceInit->Pdo.ContainerID = new(pFxDriverGlobals,
2427 
2428  if (DeviceInit->Pdo.ContainerID == NULL) {
2431  "Couldn't allocate ContainerID object, %!STATUS!",
2432  status);
2433 
2434  return status;
2435  }
2436  }
2437 
2438  status = DeviceInit->Pdo.ContainerID->Assign(ContainerID);
2439 
2440  return status;
2441 }
2442 
2445 NTSTATUS
2446 STDCALL
2447 WDFEXPORT(WdfPdoInitAddDeviceText)(
2448  __in
2450  __in
2452  __in
2454  __in
2456  __in
2457  LCID LocaleId
2458  )
2460  DDI_ENTRY();
2461 
2464  NTSTATUS status;
2465 
2467  pFxDriverGlobals = DeviceInit->DriverGlobals;
2468 
2471 
2473  if (!NT_SUCCESS(status)) {
2474  return status;
2475  }
2476 
2478  if (!NT_SUCCESS(status)) {
2479  return status;
2480  }
2481 
2483  if (!NT_SUCCESS(status)) {
2484  return status;
2485  }
2486 
2487  if (DeviceInit->IsNotPdoInit()) {
2490  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!", status);
2491  return status;
2492  }
2493 
2495 
2496  if (pDeviceText == NULL) {
2498 
2501  "Couldn't allocate DeviceText object, %!STATUS!", status);
2502 
2503  return status;
2504  }
2505 
2507 
2510 
2513 
2516  "Couldn't allocate DeviceDescription string, %!STATUS!", status);
2517 
2518  goto Done;
2519  }
2520 
2523 
2526 
2529  "Couldn't allocate DeviceLocation string, %!STATUS!", status);
2530 
2531  goto Done;
2532  }
2533 
2534  //
2535  // Insert at the end of the list and update end of the list
2536  //
2537  *DeviceInit->Pdo.LastDeviceTextEntry = &pDeviceText->m_Entry;
2538  DeviceInit->Pdo.LastDeviceTextEntry = &pDeviceText->m_Entry.Next;
2539 
2540 Done:
2541  if (!NT_SUCCESS(status)) {
2542  delete pDeviceText;
2543  }
2544 
2545  return status;
2546 }
2547 
2549 VOID
2550 STDCALL
2551 WDFEXPORT(WdfPdoInitSetDefaultLocale)(
2552  __in
2554  __in
2556  __in
2557  LCID LocaleId
2558  )
2559 {
2560  DDI_ENTRY();
2561 
2563 
2565  pFxDriverGlobals = DeviceInit->DriverGlobals;
2566 
2568  PASSIVE_LEVEL))) {
2569  return;
2570  }
2571 
2572  if (DeviceInit->IsNotPdoInit()) {
2575  "Not a PWDFDEVICE_INIT for a PDO");
2577  return;
2578  }
2579 
2580  DeviceInit->Pdo.DefaultLocale = LocaleId;
2581 }
2582 
2585 NTSTATUS
2586 STDCALL
2587 WDFEXPORT(WdfPdoInitAssignRawDevice)(
2588  __in
2590  __in
2592  __in
2594  )
2595 {
2596  DDI_ENTRY();
2597 
2599  NTSTATUS status;
2600 
2602  pFxDriverGlobals = DeviceInit->DriverGlobals;
2603 
2605 
2607  if (!NT_SUCCESS(status)) {
2608  return status;
2609  }
2610 
2611  if (DeviceInit->IsNotPdoInit()) {
2614  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2615  status);
2616  return status;
2617  }
2618 
2619  DeviceInit->Pdo.Raw = TRUE;
2620  DeviceInit->Security.DeviceClassSet = TRUE;
2621  RtlCopyMemory(&DeviceInit->Security.DeviceClass,
2623  sizeof(GUID));
2624 
2625  return STATUS_SUCCESS;
2626 }
2627 
2629 VOID
2630 STDCALL
2631 WDFEXPORT(WdfPdoInitAllowForwardingRequestToParent)(
2632  __in
2634  __in
2636  )
2637 {
2638  DDI_ENTRY();
2639 
2641  NTSTATUS status;
2642 
2644  pFxDriverGlobals = DeviceInit->DriverGlobals;
2645 
2647  if (!NT_SUCCESS(status)) {
2648  return;
2649  }
2650 
2651  if (DeviceInit->IsNotPdoInit()) {
2653  "Not a PWDFDEVICE_INIT for a PDO, %!STATUS!",
2654  status);
2656  return;
2657  }
2658 
2659  DeviceInit->Pdo.ForwardRequestToParent = TRUE;
2660  return ;
2661 }
2662 
2663 
2664 
2665 //
2666 // END PDO specific functions
2667 //
2668 
2669 //
2670 // BEGIN CONTROL DEVICE specific functions
2671 //
2672 
2676 STDCALL
2677 WDFEXPORT(WdfControlDeviceInitAllocate)(
2678  __in
2680  __in
2681  WDFDRIVER Driver,
2682  __in
2684  )
2685 {
2686  DDI_ENTRY();
2687 
2690  NTSTATUS status;
2691 
2693  Driver,
2695  (PVOID*) &pDriver,
2696  &pFxDriverGlobals);
2697 
2699 
2701  if (!NT_SUCCESS(status)) {
2702  return NULL;
2703  }
2704 
2706  if (!NT_SUCCESS(status)) {
2707  return NULL;
2708  }
2709 
2711 }
2712 
2714 VOID
2715 STDCALL
2716 WDFEXPORT(WdfControlDeviceInitSetShutdownNotification)(
2717  __in
2719  __in
2721  __in
2723  __in
2724  UCHAR Flags
2725  )
2727  DDI_ENTRY();
2728 
2730 
2732  pFxDriverGlobals = DeviceInit->DriverGlobals;
2733 
2735 
2736  if (DeviceInit->IsNotControlDeviceInit()) {
2738  "Not a PWDFDEVICE_INIT for a control device");
2740  return;
2741  }
2742 
2745  "WdfDeviceShutdown Flags 0x%x are invalid", Flags);
2747  return;
2748  }
2749 
2750  DeviceInit->Control.ShutdownNotification = Notification;
2752 }
2753 
2754 //
2755 // END CONTROL DEVICE specific functions
2756 //
2757 
2758 } // extern "C"
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING ContainerID
enum _WDF_DEVICE_PNP_STATE WDF_DEVICE_PNP_STATE
PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION Callback
EVT_WDF_DEVICE_DISARM_WAKE_FROM_S0 * PFN_WDF_DEVICE_DISARM_WAKE_FROM_S0
Definition: wdfdevice.h:1117
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_PNP_STATE _In_ PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION EvtDevicePnpStateChange
Definition: wdfdevice.h:2993
#define __in_bcount(x)
Definition: dbghelp.h:41
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_POWER_POLICY_STATE __in PFN_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION EvtDevicePowerPolicyStateChange
EVT_WDF_DEVICE_ENABLE_WAKE_AT_BUS * PFN_WDF_DEVICE_ENABLE_WAKE_AT_BUS
Definition: wdfpdo.h:123
PFN_WDF_DEVICE_SURPRISE_REMOVAL EvtDeviceSurpriseRemoval
Definition: wdf19.h:725
PFN_WDF_DEVICE_DISARM_WAKE_FROM_SX EvtDeviceDisarmWakeFromSx
Definition: wdf15.h:640
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
PFN_WDF_DEVICE_USAGE_NOTIFICATION EvtDeviceUsageNotification
Definition: wdf19.h:731
__in PWDFDEVICE_INIT __in ULONG __in BOOLEAN OrInValues
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
EVT_WDFDEVICE_WDM_IRP_PREPROCESS * PFN_WDFDEVICE_WDM_IRP_PREPROCESS
Definition: wdfdevice.h:1685
return STATUS_SUCCESS
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
__in PWDFDEVICE_INIT __in PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION __in UCHAR Flags
__inout PWDFDEVICE_INIT __in PWDF_CHILD_LIST_CONFIG __in_opt PWDF_OBJECT_ATTRIBUTES DefaultDeviceListAttributes
PFN_WDFDEVICE_WDM_IRP_PREPROCESS EvtDevicePreprocess
_Must_inspect_result_ __in PWDFDEVICE_INIT __in ULONG DeviceInstanceKeyType
__inout PWDFDEVICE_INIT __in PWDF_CHILD_LIST_CONFIG Config
__drv_maxIRQL(DISPATCH_LEVEL) VOID STDCALL WDFEXPORT(WdfDeviceInitFree)(__in PWDF_DRIVER_GLOBALS DriverGlobals
#define _In_opt_
Definition: ms_sal.h:309
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY * PFN_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY
Definition: wdfpdo.h:80
EVT_WDF_DEVICE_RESOURCES_QUERY * PFN_WDF_DEVICE_RESOURCES_QUERY
Definition: wdfpdo.h:65
GLint x0
Definition: linetemp.h:95
FORCEINLINE VOID WDF_IO_TYPE_CONFIG_INIT(_Out_ PWDF_IO_TYPE_CONFIG IoTypeConfig)
Definition: wdfdevice.h:1888
#define _Out_
Definition: ms_sal.h:345
PFN_WDF_DEVICE_SELF_MANAGED_IO_RESTART EvtDeviceSelfManagedIoRestart
Definition: wdf19.h:723
#define __in_opt
Definition: dbghelp.h:38
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PFN_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP EvtDeviceSelfManagedIoCleanup
Definition: wdf19.h:715
EVT_WDF_DEVICE_ARM_WAKE_FROM_S0 * PFN_WDF_DEVICE_ARM_WAKE_FROM_S0
Definition: wdfdevice.h:1074
__in PWDFDEVICE_INIT __in PWDF_FILEOBJECT_CONFIG FileObjectConfig
EVT_WDF_DEVICE_DISABLE_WAKE_AT_BUS * PFN_WDF_DEVICE_DISABLE_WAKE_AT_BUS
Definition: wdfpdo.h:136
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_PNP_STATE __in PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION __in ULONG CallbackTypes
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING __in PCUNICODE_STRING DeviceLocation
PWCHAR m_Description
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY __in ULONG BufferLength
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PFN_WDFDEVICE_WDM_IRP_PREPROCESS _In_ UCHAR _In_opt_ PUCHAR MinorFunctions
Definition: wdfdevice.h:3465
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PFN_WDFDEVICE_WDM_IRP_PREPROCESS EvtDeviceWdmIrpPreprocess
static _Must_inspect_result_ NTSTATUS _AllocAndQueryProperty(_In_ PFX_DRIVER_GLOBALS Globals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ POOL_TYPE PoolType, _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes, _Out_ WDFMEMORY *PropertyMemory)
Definition: fxdevice.cpp:1988
LONG NTSTATUS
Definition: precomp.h:26
PFN_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY EvtDeviceResourceRequirementsQuery
Definition: wdf19.h:1590
EVT_WDF_DEVICE_SHUTDOWN_NOTIFICATION * PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION
Definition: wdfcontrol.h:62
_In_ PWDFDEVICE_INIT _In_ PWDF_IO_TYPE_CONFIG IoTypeConfig
enum _WDF_DEVICE_IO_TYPE WDF_DEVICE_IO_TYPE
FxDeviceText * pDeviceText
__in PWDFDEVICE_INIT __in ULONG DeviceCharacteristics
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFMEMORY * PropertyMemory
Definition: wdfdevice.h:3810
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
SINGLE_LIST_ENTRY m_Entry
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_POWER_STATE __in PFN_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION EvtDevicePowerStateChange
#define TRACINGAPIERROR
Definition: dbgtrace.h:60
DWORD LCID
Definition: nls.h:13
WDF_DEVICE_IO_TYPE ReadWriteIoType
Definition: wdfdevice.h:1856
DriverGlobals
_Must_inspect_result_ __in PWDFDEVICE_INIT __in ULONG __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES KeyAttributes
PFN_WDF_DEVICE_SELF_MANAGED_IO_INIT EvtDeviceSelfManagedIoInit
Definition: wdf19.h:719
ULONG * PDEVPROPTYPE
Definition: devpropdef.h:24
PWCHAR m_LocationInformation
EVT_WDF_DEVICE_PREPARE_HARDWARE * PFN_WDF_DEVICE_PREPARE_HARDWARE
Definition: wdfdevice.h:893
_In_ PWDFDEVICE_INIT _In_ WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE ReleaseHardwareOrderOnFailure
Definition: wdfdevice.h:4362
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_POWER_POLICY_STATE PowerPolicyState
ULONG validFlags
enum _WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING ContainerID
Definition: wdfpdo.h:399
BOOLEAN IsUserModeDriver
Definition: fxglobals.h:488
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_POLICY_STATE PowerPolicyState
Definition: wdfdevice.h:3071
EVT_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND * PFN_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND
Definition: wdfdevice.h:960
EVT_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION * PFN_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION
Definition: wdfdevice.h:799
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PFN_WDFDEVICE_WDM_IRP_PREPROCESS __in UCHAR MajorFunction
_Must_inspect_result_ _In_ WDFDEVICE ParentDevice
Definition: wdfpdo.h:220
PFN_WDF_DEVICE_SELF_MANAGED_IO_FLUSH EvtDeviceSelfManagedIoFlush
Definition: wdf19.h:717
PFN_WDF_DEVICE_DISABLE_WAKE_AT_BUS EvtDeviceDisableWakeAtBus
Definition: wdf19.h:1612
_Must_inspect_result_ __in WDFDEVICE ParentDevice
PFN_WDF_DEVICE_ENABLE_WAKE_AT_BUS EvtDeviceEnableWakeAtBus
Definition: wdf19.h:1606
_In_ PWDFDEVICE_INIT _In_ PWDF_FILEOBJECT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES FileObjectAttributes
Definition: wdfdevice.h:3395
__in PWDFDEVICE_INIT __in PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY __in __in_opt PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
__in PWDFDEVICE_INIT __in PWDF_FILEOBJECT_CONFIG __in_opt PWDF_OBJECT_ATTRIBUTES FileObjectAttributes
PFN_WDF_DEVICE_PREPARE_HARDWARE EvtDevicePrepareHardware
Definition: wdf19.h:711
static _Must_inspect_result_ NTSTATUS _QueryPropertyEx(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ ULONG BufferLength, _Out_ PVOID PropertyBuffer, _Out_ PULONG ResultLength, _Out_ PDEVPROPTYPE PropertyType)
Definition: fxdevicekm.cpp:859
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:430
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_PNP_STATE _In_ PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION _In_ ULONG CallbackTypes
Definition: wdfdevice.h:2993
EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED * PFN_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED
Definition: wdfdevice.h:876
PFN_WDF_DEVICE_QUERY_STOP EvtDeviceQueryStop
Definition: wdf19.h:729
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
__inline BOOLEAN IsFdo(VOID)
Definition: fxdevice.hpp:1227
__in PWDFDEVICE_INIT __in BOOLEAN IsPowerPolicyOwner
PFN_WDF_DEVICE_RELATIONS_QUERY EvtDeviceRelationsQuery
Definition: wdf19.h:733
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define WDFAPI
Definition: wdftypes.h:53
_Must_inspect_result_ PWCHAR FxDuplicateUnicodeStringToString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Source)
Definition: stringutil.cpp:287
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3428
struct _WDF_PNPPOWER_EVENT_CALLBACKS_V1_9 WDF_PNPPOWER_EVENT_CALLBACKS_V1_9
__in PWDFDEVICE_INIT __in PWDF_FDO_EVENT_CALLBACKS FdoEventCallbacks
EVT_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION * PFN_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION
Definition: wdfdevice.h:814
__in PWDFDEVICE_INIT __in PWDF_REMOVE_LOCK_OPTIONS RemoveLockOptions
enum _WDF_FILEOBJECT_CLASS WDF_FILEOBJECT_CLASS
_Must_inspect_result_ __in PWDFDEVICE_INIT __in_opt PCUNICODE_STRING DeviceName
PFN_WDF_DEVICE_D0_ENTRY EvtDeviceD0Entry
Definition: wdf19.h:703
_In_ WDFDEVICE _In_ ULONG DeviceCharacteristics
Definition: wdfdevice.h:2772
#define __out
Definition: dbghelp.h:62
_IRQL_requires_max_(PASSIVE_LEVEL) WDFAPI VOID STDCALL WDFEXPORT(WdfDeviceInitSetIoTypeEx)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
Definition: Messaging.c:64
unsigned char BOOLEAN
PFN_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED EvtDeviceWakeFromS0Triggered
Definition: wdf15.h:636
WDF_FILEOBJECT_CLASS normalizedFileClass
#define _In_
Definition: ms_sal.h:308
__in PWDFDEVICE_INIT __in DEVICE_TYPE DeviceType
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING CompatibleID
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY __in __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY * PropertyMemory
EVT_WDF_DEVICE_EJECT * PFN_WDF_DEVICE_EJECT
Definition: wdfpdo.h:93
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes
Definition: wdfdevice.h:2654
PFN_WDF_DEVICE_D0_EXIT EvtDeviceD0Exit
Definition: wdf19.h:707
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_PNP_STATE PnpState
Definition: wdfdevice.h:2993
PFX_DRIVER_GLOBALS pFxDriverGlobals
EVT_WDF_DEVICE_D0_EXIT * PFN_WDF_DEVICE_D0_EXIT
Definition: wdfdevice.h:861
_In_ PWDFDEVICE_INIT _In_ PWDF_FILEOBJECT_CONFIG FileObjectConfig
Definition: wdfdevice.h:3395
FxIrpPreprocessInfo * PreprocessInfo
struct _WDF_PDO_EVENT_CALLBACKS_V1_9 * PWDF_PDO_EVENT_CALLBACKS_V1_9
PFN_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED EvtDeviceWakeFromSxTriggered
Definition: wdf15.h:642
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
FxDriver * pDriver
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT * PFN_WDF_DEVICE_SELF_MANAGED_IO_INIT
Definition: wdfdevice.h:947
#define TRACINGDEVICE
Definition: dbgtrace.h:58
EVT_WDF_DEVICE_ARM_WAKE_FROM_SX * PFN_WDF_DEVICE_ARM_WAKE_FROM_SX
Definition: wdfdevice.h:1087
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN __inline FxIsFileObjectOptional(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:112
struct _WDF_PNPPOWER_EVENT_CALLBACKS_V1_9 * PWDF_PNPPOWER_EVENT_CALLBACKS_V1_9
#define STDCALL
Definition: wdf.h:45
EVT_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP * PFN_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP
Definition: wdfdevice.h:921
_In_ PWDFDEVICE_INIT _In_ PWDF_PNPPOWER_EVENT_CALLBACKS PnpPowerEventCallbacks
Definition: wdfdevice.h:2905
static _Must_inspect_result_ PWDFDEVICE_INIT _AllocateControlDeviceInit(__in FxDriver *Driver, __in const UNICODE_STRING *SDDLString)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__in PWDFDEVICE_INIT __in PWDF_OBJECT_ATTRIBUTES RequestAttributes
EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED * PFN_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED
Definition: wdfdevice.h:846
INT POOL_TYPE
Definition: typedefs.h:78
_In_ PWDFDEVICE_INIT _In_ PWDF_IO_TYPE_CONFIG IoTypeConfig
Definition: wdfdevice.h:4391
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), ParentDevice, FX_TYPE_DEVICE,(PVOID *) &pDevice, &pFxDriverGlobals)
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE Type
WDF_FILEOBJECT_CLASS __inline FxFileObjectClassNormalize(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:103
_Must_inspect_result_ __in PWDFDEVICE_INIT __in ULONG __in ACCESS_MASK DesiredAccess
__in PWDFDEVICE_INIT __in CONST GUID * DeviceClassGuid
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG DeviceInstanceKeyType
Definition: wdfdevice.h:2654
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE _In_ PFN_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION EvtDevicePowerStateChange
Definition: wdfdevice.h:3032
Type
Definition: Type.h:6
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
_Must_inspect_result_ NTSTATUS Assign(__in PCWSTR SourceString)
Definition: fxstring.cpp:57
EVT_WDF_DEVICE_SELF_MANAGED_IO_RESTART * PFN_WDF_DEVICE_SELF_MANAGED_IO_RESTART
Definition: wdfdevice.h:973
NTSTATUS status
static _Must_inspect_result_ NTSTATUS _AllocAndQueryPropertyEx(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ POOL_TYPE PoolType, _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes, _Out_ WDFMEMORY *PropertyMemory, _Out_ PDEVPROPTYPE PropertyType)
Definition: fxdevice.cpp:2063
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING InstanceID
Definition: wdfpdo.h:306
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__in PWDFDEVICE_INIT __in PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext
FxString * pID
__inline FxDriver * GetDriver(VOID)
Definition: fxdevice.hpp:164
EVT_WDF_DEVICE_DISARM_WAKE_FROM_SX * PFN_WDF_DEVICE_DISARM_WAKE_FROM_SX
Definition: wdfdevice.h:1130
PFN_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND EvtDeviceSelfManagedIoSuspend
Definition: wdf19.h:721
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
VOID SetPdo(__in FxDevice *Parent)
#define _Strict_type_match_
Definition: ms_sal.h:2954
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
VOID AssignIoType(_In_ PWDF_IO_TYPE_CONFIG IoTypeConfig)
__in PWDFDEVICE_INIT __in WDF_DEVICE_IO_TYPE IoType
_Must_inspect_result_ __in PWDFDEVICE_INIT __in ULONG __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFKEY * Key
__in PWDFDEVICE_INIT __in PWDF_PNPPOWER_EVENT_CALLBACKS PnpPowerEventCallbacks
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_POLICY_STATE _In_ PFN_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION EvtDevicePowerPolicyStateChange
Definition: wdfdevice.h:3071
#define __inout
Definition: dbghelp.h:50
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING DeviceID
PFN_WDF_DEVICE_ARM_WAKE_FROM_S0 EvtDeviceArmWakeFromS0
Definition: wdf15.h:632
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
Definition: wdfpdo.h:275
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define _Must_inspect_result_
Definition: ms_sal.h:558
PFN_WDF_DEVICE_SET_LOCK EvtDeviceSetLock
Definition: wdf19.h:1600
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
Definition: wdfdevice.h:3810
ControlInit Control
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:474
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY DeviceProperty
FxPointerNotNull(GetFxDriverGlobals(DriverGlobals), DeviceInit)
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_PNP_STATE PnpState
PFN_WDF_DEVICE_QUERY_REMOVE EvtDeviceQueryRemove
Definition: wdf19.h:727
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_In_ PWDFDEVICE_INIT _In_ BOOLEAN IsPowerPolicyOwner
Definition: wdfdevice.h:2963
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING InstanceID
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PFN_WDFDEVICE_WDM_IRP_PREPROCESS EvtDeviceWdmIrpPreprocess
Definition: wdfdevice.h:3458
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING __in PCUNICODE_STRING __in LCID LocaleId
PFX_DRIVER_GLOBALS fxDriverGlobals
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY __in ULONG __out_bcount_full_opt(BufferLength) PVOID PropertyBuffer
return reinterpret_cast< PDEVICE_OBJECT >(DeviceInit->Fdo.PhysicalDevice)
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
EVT_WDF_DEVICE_SELF_MANAGED_IO_FLUSH * PFN_WDF_DEVICE_SELF_MANAGED_IO_FLUSH
Definition: wdfdevice.h:934
EVT_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION * PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION
Definition: wdfdevice.h:784
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_PNP_STATE __in PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION EvtDevicePnpStateChange
PWDFDEVICE_INIT pInit
#define TRACINGPNP
Definition: dbgtrace.h:67
_In_ PWDFDEVICE_INIT _In_ ULONG _In_ BOOLEAN OrInValues
Definition: wdfdevice.h:3362
PFN_WDF_DEVICE_RESOURCES_QUERY EvtDeviceResourcesQuery
Definition: wdf19.h:1585
FORCEINLINE ULONG WdfDevStateNormalize(_In_ ULONG State)
Definition: wdfdevice.h:1225
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING CompatibleID
Definition: wdfpdo.h:368
EVT_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED * PFN_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED
Definition: wdfdevice.h:1156
FxDevice * pDevice
PFN_WDF_DEVICE_EJECT EvtDeviceEject
Definition: wdf19.h:1595
_In_ PWDFDEVICE_INIT _In_ CONST GUID * DeviceClassGuid
Definition: wdfdevice.h:3333
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY __in ULONG __out PULONG ResultLength
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PFN_WDFDEVICE_WDM_IRP_PREPROCESS _In_ UCHAR _In_opt_ PUCHAR _In_ ULONG NumMinorFunctions
Definition: wdfdevice.h:3465
#define ARRAY_SIZE(a)
Definition: main.h:24
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
_Must_inspect_result_ __in PWDFDEVICE_INIT __in_opt PCUNICODE_STRING SDDLString
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3032
_In_ PWDFDEVICE_INIT _In_ PWDF_FDO_EVENT_CALLBACKS FdoEventCallbacks
Definition: wdffdo.h:373
FxVerifierCheckNxPoolType(pFxDriverGlobals, PoolType, pFxDriverGlobals->Tag)
EVT_WDF_DEVICE_SET_LOCK * PFN_WDF_DEVICE_SET_LOCK
Definition: wdfpdo.h:108
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING DeviceLocation
Definition: wdfpdo.h:430
#define DEVICE_TYPE
Definition: guid.c:10
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING HardwareID
unsigned int * PULONG
Definition: retypes.h:1
struct _WDF_POWER_POLICY_EVENT_CALLBACKS_V1_5 * PWDF_POWER_POLICY_EVENT_CALLBACKS_V1_5
#define NULL
Definition: types.h:112
FxPnpStateCallbackInfo * pCallback
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext
Definition: wdfdevice.h:3502
EVT_WDF_DEVICE_D0_ENTRY * PFN_WDF_DEVICE_D0_ENTRY
Definition: wdfdevice.h:831
_Must_inspect_result_ _In_ WDFDRIVER _In_ CONST UNICODE_STRING * SDDLString
Definition: wdfcontrol.h:83
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING HardwareID
Definition: wdfpdo.h:337
enum _WDF_DEVICE_POWER_POLICY_STATE WDF_DEVICE_POWER_POLICY_STATE
static _Must_inspect_result_ NTSTATUS _QueryProperty(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_opt_ PULONG ResultLength)
Definition: fxdevicekm.cpp:939
EVT_WDF_DEVICE_QUERY_REMOVE * PFN_WDF_DEVICE_QUERY_REMOVE
Definition: wdfdevice.h:999
static _Must_inspect_result_ NTSTATUS _OpenKey(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_ ULONG DeviceInstanceKeyType, _In_ ACCESS_MASK DesiredAccess, _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes, _Out_ WDFKEY *Key)
Definition: fxdevicekm.cpp:731
EVT_WDF_DEVICE_RELATIONS_QUERY * PFN_WDF_DEVICE_RELATIONS_QUERY
Definition: wdfdevice.h:1061
EVT_WDF_DEVICE_QUERY_STOP * PFN_WDF_DEVICE_QUERY_STOP
Definition: wdfdevice.h:986
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PWDF_DEVICE_PROPERTY_DATA _In_ _Strict_type_match_ POOL_TYPE PoolType
unsigned int ULONG
Definition: retypes.h:1
Info Dispatch[IRP_MJ_MAXIMUM_FUNCTION+1]
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
__in PWDFDEVICE_INIT DeviceInit
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PFN_WDFDEVICE_WDM_IRP_PREPROCESS __in UCHAR __in_opt PUCHAR __in ULONG NumMinorFunctions
enum _WDF_DEVICE_POWER_STATE WDF_DEVICE_POWER_STATE
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
EVT_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED * PFN_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED
Definition: wdfdevice.h:1143
WDF_IO_TYPE_CONFIG ioTypeConfig
size_t totalDescriptionSize
static _Must_inspect_result_ NTSTATUS _ValidateConfig(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_CHILD_LIST_CONFIG Config, __in size_t *TotalDescriptionSize)
struct _WDF_POWER_POLICY_EVENT_CALLBACKS_V1_5 WDF_POWER_POLICY_EVENT_CALLBACKS_V1_5
_Must_inspect_result_ __in PWDFDEVICE_INIT __in WDF_DEVICE_POWER_STATE PowerState
__in PWDFDEVICE_INIT __in PWDF_PDO_EVENT_CALLBACKS DispatchTable
_Must_inspect_result_ __in PWDFDEVICE_INIT __in DEVICE_REGISTRY_PROPERTY __in __drv_strictTypeMatch(__drv_typeExpr) POOL_TYPE PoolType
__in PWDFDEVICE_INIT __in PWDF_POWER_POLICY_EVENT_CALLBACKS PowerPolicyEventCallbacks
EVT_WDF_DEVICE_SURPRISE_REMOVAL * PFN_WDF_DEVICE_SURPRISE_REMOVAL
Definition: wdfdevice.h:1012
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
PFN_WDF_DEVICE_ARM_WAKE_FROM_SX EvtDeviceArmWakeFromSx
Definition: wdf15.h:638
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PCUNICODE_STRING DeviceDescription
#define __in
Definition: dbghelp.h:35
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
EVT_WDF_IO_IN_CALLER_CONTEXT * PFN_WDF_IO_IN_CALLER_CONTEXT
Definition: wdfdevice.h:1728
PFN_WDF_DEVICE_RELEASE_HARDWARE EvtDeviceReleaseHardware
Definition: wdf19.h:713
struct _WDF_PDO_EVENT_CALLBACKS_V1_9 WDF_PDO_EVENT_CALLBACKS_V1_9
#define CONST
Definition: pedump.c:81
ULONG ACCESS_MASK
Definition: nt_native.h:40
EVT_WDF_DEVICE_RELEASE_HARDWARE * PFN_WDF_DEVICE_RELEASE_HARDWARE
Definition: wdfdevice.h:908
_Must_inspect_result_ __in PWDFDEVICE_INIT __in PFN_WDFDEVICE_WDM_IRP_PREPROCESS __in UCHAR __drv_when(NumMinorFunctions > 0, __in_bcount(NumMinorFunctions)) __drv_when(NumMinorFunctions
EVT_WDF_DEVICE_USAGE_NOTIFICATION * PFN_WDF_DEVICE_USAGE_NOTIFICATION
Definition: wdfdevice.h:1029
_Must_inspect_result_ __in WDFDRIVER Driver
PFN_WDF_DEVICE_DISARM_WAKE_FROM_S0 EvtDeviceDisarmWakeFromS0
Definition: wdf15.h:634
FxVerifierDbgBreakPoint(pFxDriverGlobals)
PFN_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED EvtDeviceD0ExitPreInterruptsDisabled
Definition: wdf19.h:709
_In_ PWDFDEVICE_INIT _In_ PWDF_POWER_POLICY_EVENT_CALLBACKS PowerPolicyEventCallbacks
Definition: wdfdevice.h:2934
ULONG normalizedState
PFN_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED EvtDeviceD0EntryPostInterruptsEnabled
Definition: wdf19.h:705
__in PWDFDEVICE_INIT __in WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE ReleaseHardwareOrderOnFailure
Definition: ps.c:97
WDF_FILEOBJECT_CLASS fileClass