ReactOS  0.4.15-dev-1632-g4e289ce
fxdeviceapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDeviceApi.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 #include "fxiotarget.hpp"
27 
28 extern "C" {
29 // #include "FxDeviceApi.tmh"
30 }
31 
35 };
36 
37 #define OFFSET_AND_NAME(type, offset) { #offset, FIELD_OFFSET(type, offset) }
38 
39 //
40 // extern "C" the entire file
41 //
42 extern "C" {
43 
45 WDFDRIVER
46 STDCALL
47 WDFEXPORT(WdfDeviceGetDriver)(
48  __in
50  __in
51  WDFDEVICE Device
52  )
53 /*++
54 
55 Routine Description:
56 
57  Given a Device Handle, return a Handle to the Driver object
58  containing this device.
59 
60 Arguments:
61  Device - WDF Device handle.
62 
63 Returns:
64  WDF Driver handle.
65 
66 --*/
67 
68 {
69  DDI_ENTRY();
70 
72 
74  Device,
76  (PVOID*) &pDevice);
77 
78  //
79  // No need to ref count the driver handle b/c it will be around as long
80  // as the device handle is.
81  //
82  return pDevice->GetDriver()->GetHandle();
83 }
84 
86 WDFIOTARGET
87 STDCALL
88 WDFEXPORT(WdfDeviceGetIoTarget)(
89  __in
91  __in
92  WDFDEVICE Device
93  )
94 {
95  DDI_ENTRY();
96 
99 
101  Device,
103  (PVOID*) &pDeviceBase);
104 
106 
107  if (pTarget != NULL) {
108  return pTarget->GetHandle();
109  }
110 
111  return NULL;
112 }
113 
115 WDFIOTARGET
116 STDCALL
117 WDFEXPORT(WdfDeviceGetSelfIoTarget)(
118  _In_
120  _In_
121  WDFDEVICE Device
122  )
123 
124 /*++
125 
126 Routine Description:
127 
128  Return the handle to the Self IO target for the device. A Self
129  IO target is only created if the client opted for it by calling
130  WdfDeviceInitAllowSelfTarget
131 
132 Arguments:
133 
134  Device - Handle to the Device Object for which Self IO target is needed
135 
136 Returns:
137 
138  WDFIOTARGET handle to the Self IO Target. NULL is returned in case the
139  device does not have an Self IO target.
140 
141 --*/
142 
143 {
144  DDI_ENTRY();
145 
147  FxDevice *pDevice;
148 
150  Device,
152  (PVOID*) &pDevice);
153 
155 
156  if (pTarget != NULL) {
157  return pTarget->GetHandle();
158  }
159 
160  return NULL;
161 }
162 
165 NTSTATUS
166 STDCALL
167 WDFEXPORT(WdfDeviceRetrieveDeviceName)(
168  __in
170  __in
171  WDFDEVICE Device,
172  __in
173  WDFSTRING String
174  )
175 {
176  DDI_ENTRY();
177 
179  FxDevice *pDevice;
182 
184  Device,
186  (PVOID *) &pDevice,
188 
191  return status;
192  }
193 
195  String,
197  (PVOID*) &pString);
198 
201  }
202  else {
206  "Device name for WDFDEVICE 0x%p is NULL. Possibly incorrect "
207  "device handle was passed, %!STATUS!", Device, status);
208  }
209 
210  return status;
211 }
212 
214 VOID
215 STDCALL
216 WDFEXPORT(WdfDeviceSetCharacteristics)(
217  __in
219  __in
220  WDFDEVICE Device,
221  __in
223  )
224 {
225  DDI_ENTRY();
226 
227  FxDevice *pDevice;
229 
231  Device,
233  (PVOID*) &pDevice);
234 
238 }
239 
241 ULONG
242 STDCALL
243 WDFEXPORT(WdfDeviceGetCharacteristics)(
244  __in
246  __in
247  WDFDEVICE Device
248  )
249 {
250  DDI_ENTRY();
251 
252  FxDevice *pDevice;
254 
256  Device,
258  (PVOID*) &pDevice);
259 
261 
263 }
264 
266 ULONG
267 STDCALL
268 WDFEXPORT(WdfDeviceGetAlignmentRequirement)(
269  __in
271  __in
272  WDFDEVICE Device
273  )
274 {
275  DDI_ENTRY();
276 
279 
281  Device,
283  (PVOID*) &pDeviceBase);
284 
286 
288 }
289 
291 VOID
292 STDCALL
293 WDFEXPORT(WdfDeviceSetAlignmentRequirement)(
294  __in
296  __in
297  WDFDEVICE Device,
298  __in
300  )
301 {
302  DDI_ENTRY();
303 
306 
308  Device,
310  (PVOID*) &pDeviceBase);
311 
313 
315 }
316 
319 STDCALL
320 WDFEXPORT(WdfDeviceGetDevicePnpState)(
321  __in
323  __in
324  WDFDEVICE Device
325  )
326 {
327  DDI_ENTRY();
328 
329  FxDevice *pDevice;
330 
332  Device,
334  (PVOID*) &pDevice);
335 
336  return pDevice->GetDevicePnpState();
337 }
338 
341 STDCALL
342 WDFEXPORT(WdfDeviceGetDevicePowerState)(
343  __in
345  __in
346  WDFDEVICE Device
347  )
348 {
349  DDI_ENTRY();
350 
351  FxDevice *pDevice;
352 
354  Device,
356  (PVOID*) &pDevice);
357 
358  return pDevice->GetDevicePowerState();
359 }
360 
363 STDCALL
364 WDFEXPORT(WdfDeviceGetDevicePowerPolicyState)(
365  __in
367  __in
368  WDFDEVICE Device
369  )
370 {
371  DDI_ENTRY();
372 
373  FxDevice *pDevice;
374 
376  Device,
378  (PVOID*) &pDevice);
379 
381 }
382 
385 NTSTATUS
386 STDCALL
387 WDFEXPORT(WdfDeviceAssignS0IdleSettings)(
388  __in
390  __in
391  WDFDEVICE Device,
392  __in
394  )
395 {
396  DDI_ENTRY();
397 
400  FxDevice* pDevice;
401 
403  Device,
405  (PVOID *) &pDevice,
407 
409 
412 
415  "Device 0x%p is not the power policy owner, caller cannot set S0"
416  " idle settings %!STATUS!", Device, status);
417 
418  return status;
419  }
420 
421  //
422  // Validate the Settings parameter
423  //
430  "Expected Settings Size %d, got %d, %!STATUS!",
432  status);
433  return status;
434  }
435  else if (Settings->DxState < PowerDeviceD1 ||
436  Settings->DxState > PowerDeviceMaximum ||
437  Settings->IdleCaps < IdleCannotWakeFromS0 ||
438  Settings->IdleCaps > IdleUsbSelectiveSuspend ||
439  Settings->UserControlOfIdleSettings < IdleDoNotAllowUserControl ||
440  Settings->UserControlOfIdleSettings > IdleAllowUserControl ||
441  Settings->Enabled < WdfFalse ||
442  Settings->Enabled > WdfUseDefault) {
443 
447  "a field (DxState, IdleCaps, Enabled, or UserControlOfIdleSettings)"
448  " is out range, %!STATUS!", status);
449  return status;
450  }
451 
452  //
453  // PowerUpIdleDeviceOnSystemWake is available only on > 1.7 and can be set to true
454  // only when IdleCaps is IdleCannotWakeFromS0
455  //
457  if (Settings->PowerUpIdleDeviceOnSystemWake < WdfFalse ||
458  Settings->PowerUpIdleDeviceOnSystemWake > WdfUseDefault) {
459 
463  "value of field PowerUpIdleDeviceOnSystemWake is out of range,"
464  " %!STATUS!", status);
465  return status;
466  }
467  else if (Settings->IdleCaps != IdleCannotWakeFromS0 &&
468  Settings->PowerUpIdleDeviceOnSystemWake != WdfUseDefault) {
469 
473  "value of field PowerUpIdleDeviceOnSystemWake should be set only when"
474  " IdleCaps is IdleCannotWakeFromS0, %!STATUS!", status);
475  return status;
476  }
477  }
478 
479  //
480  // IdleTimeoutType is available only on > 1.9
481  //
483  if (Settings->IdleTimeoutType > SystemManagedIdleTimeoutWithHint) {
487  "WDFDEVICE %p, value of field IdleTimeoutType is out of range,"
488  " %!STATUS!", Device, status);
489  return status;
490  }
491  }
492 
494 }
495 
498 NTSTATUS
499 STDCALL
500 WDFEXPORT(WdfDeviceAssignSxWakeSettings)(
501  __in
503  __in
504  WDFDEVICE Device,
505  __in
507  )
508 {
509  DDI_ENTRY();
510 
512  FxDevice* pDevice;
516 
518  Device,
520  (PVOID *) &pDevice,
522 
524 
527 
530  "Device 0x%p is not the power policy owner, caller cannot set Sx"
531  " wake settings %!STATUS!", Device, status);
532 
533  return status;
534  }
535 
536  //
537  // Validate the Settings parameter
538  //
539  if (Settings->Size != sizeof(WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS) &&
543  "Expected Settings Size %x, got %x, %!STATUS!",
545  Settings->Size,
546  status);
547  return status;
548  }
549  else if (Settings->DxState < PowerDeviceD1 ||
550  Settings->DxState > PowerDeviceMaximum ||
551  Settings->UserControlOfWakeSettings < WakeDoNotAllowUserControl ||
552  Settings->UserControlOfWakeSettings > WakeAllowUserControl ||
553  Settings->Enabled < WdfFalse ||
554  Settings->Enabled > WdfUseDefault) {
555 
559  "a field (DxState, Enabled, or UserControlOfIdleSettings) is out "
560  "range, %!STATUS!", status);
561  return status;
562  }
563 
564  //
565  // Extract the values from the structure for all the parameters that were
566  // added after v1.5. Since the size of the structure can only grow, get
567  // the values only if we are using a version of the struct after v1.5
568  //
569 
570  //
571  // ArmForWakeIfChildrenAreArmedForWake added after v1.5
572  //
575  Settings->ArmForWakeIfChildrenAreArmedForWake :
576  FALSE;
577 
578  //
579  // IndicateChildWakeOnParentWake added after v1.5
580  //
583  Settings->IndicateChildWakeOnParentWake :
584  FALSE;
585 
587  Settings,
590 }
591 
594 NTSTATUS
595 STDCALL
596 WDFEXPORT(WdfDeviceOpenRegistryKey)(
597  __in
599  __in
600  WDFDEVICE Device,
601  __in
603  __in
605  __in_opt
607  __out
608  WDFKEY* Key
609  )
610 {
611  DDI_ENTRY();
612 
614  FxDevice* pDevice;
616 
618  Device,
620  (PVOID *) &pDevice,
622 
624 
625  *Key = NULL;
626 
628  if (!NT_SUCCESS(status)) {
630  return status;
631  }
632 
635  if (!NT_SUCCESS(status)) {
636 
637  return status;
638  }
639 
641  NULL,
642  pDevice,
646  Key);
647 }
648 
651 NTSTATUS
652 STDCALL
653 WDFEXPORT(WdfDeviceOpenDevicemapKey) (
654  _In_
656  _In_
657  WDFDEVICE Device,
658  _In_
660  _In_
662  _In_opt_
664  _Out_
665  WDFKEY* Key
666  )
667 {
668  DDI_ENTRY();
669 
671  FxDevice* pDevice;
674  WDFKEY keyHandle;
675 
677  Device,
679  (PVOID *) &pDevice,
681 
683 
684  *Key = NULL;
685 
687  if (!NT_SUCCESS(status)) {
688  return status;
689  }
690 
691  if (KeyName->Length == 0) {
695  "The subkey cannot be of length zero, %!STATUS!", status);
696  return status;
697  }
698 
700  if (!NT_SUCCESS(status)) {
702  return status;
703  }
704 
707  if (!NT_SUCCESS(status)) {
708  return status;
709  }
710 
712 
713  if (pKey == NULL) {
717  "Unable to allocate memory for WDFKEY object, %!STATUS!", status);
718  return status;
719  }
720 
722 
725 
727  KeyName,
729  pKey);
730  if (NT_SUCCESS(status)) {
731  *Key = keyHandle;
732  }
733  }
734 
735  if (!NT_SUCCESS(status)) {
737  pKey = NULL;
738  }
739 
740  return status;
741 }
742 
744 VOID
745 STDCALL
746 WDFEXPORT(WdfDeviceGetDeviceState)(
747  __in
749  __in
750  WDFDEVICE Device,
751  __out
753  )
754 {
755  DDI_ENTRY();
756 
757  FxDevice *pDevice;
759 
761  Device,
763  (PVOID *) &pDevice,
765 
767 
768  if (DeviceState->Size != sizeof(WDF_DEVICE_STATE)) {
771  "WDFDEVICE 0x%p DeviceState Size %d, expected %d",
772  Device, DeviceState->Size, sizeof(WDF_DEVICE_STATE));
773 
775 
776  return; // STATUS_INFO_LENGTH_MISMATCH;
777  }
778 
780 }
781 
783 VOID
784 STDCALL
785 WDFEXPORT(WdfDeviceSetDeviceState)(
786  __in
788  __in
789  WDFDEVICE Device,
790  __in
792  )
793 {
794  DDI_ENTRY();
795 
796  FxDevice *pDevice;
799 
800  const static FxOffsetAndName offsets[] = {
802  OFFSET_AND_NAME(WDF_DEVICE_STATE, DontDisplayInUI),
804  OFFSET_AND_NAME(WDF_DEVICE_STATE, NotDisableable),
806  OFFSET_AND_NAME(WDF_DEVICE_STATE, ResourcesChanged),
807  };
808 
810  Device,
812  (PVOID *) &pDevice,
814 
816 
817  if (DeviceState->Size != sizeof(WDF_DEVICE_STATE)) {
820  "WDFDEVICE 0x%p, DeviceState Size %d, expected %d",
821  Device, DeviceState->Size, sizeof(WDF_DEVICE_STATE));
822 
824  return; // STATUS_INFO_LENGTH_MISMATCH;
825  }
826 
827  for (i = 0; i < ARRAY_SIZE(offsets); i++) {
829 
830  //
831  // This check makes prefast happy
832  //
833  if (offsets[i].Offset + sizeof(WDF_TRI_STATE) > sizeof(*DeviceState)) {
834  return;
835  }
836 
838  offsets[i].Offset);
839 
840  switch (value) {
841  case WdfFalse:
842  case WdfTrue:
843  case WdfUseDefault:
844  break;
845 
846  default:
849  "WDFDEVICE 0x%p DeviceState WDF_TRI_STATE %s value out of range, "
850  "value is %d", Device, offsets[i].Name, value);
852 
853  return; // STATUS_INVALID_PARAMETER
854  }
855  }
856 
858 
860 }
861 
862 
865 NTSTATUS
866 STDCALL
867 WDFEXPORT(WdfDeviceCreate)(
868  __in
870 
871 
872  __inout
873 
875  __in_opt
877  __out
878  WDFDEVICE* Device
879  )
880 {
881  DDI_ENTRY();
882 
883  FxDevice* pDevice;
886 
888 
892 
893  //
894  // Use the object's globals, not the caller's globals
895  //
896  pFxDriverGlobals = (*DeviceInit)->DriverGlobals;
897 
898  *Device = NULL;
899 
901  if (!NT_SUCCESS(status)) {
902  return status;
903  }
904 
905  //
906  // Make sure the device attributes is initialized properly if passed in
907  //
913 
914  if (!NT_SUCCESS(status)) {
915  return status;
916  }
917 
918  if ((*DeviceInit)->CreatedDevice != NULL) {
919  //
920  // Already created the device!
921  //
923  "WDFDEVICE 0x%p already created"
924  "STATUS_INVALID_DEVICE_STATE",
925  Device);
926 
928  }
929 
930  //
931  // If security is specified, then the device being created *must* have a
932  // name to apply that security too.
933  //
934  if ((*DeviceInit)->Security.Sddl != NULL || (*DeviceInit)->Security.DeviceClassSet) {
935  if ((*DeviceInit)->HasName()) {
936  //
937  // Driver writer specified a name, all is good
938  //
939  DO_NOTHING();
940  }
941  else {
943 
946  "Device init: has device class or SDDL set, but does not have "
947  "a name, %!STATUS!", status);
948 
949  return status;
950  }
951  }
952 
953  if ((*DeviceInit)->RequiresSelfIoTarget) {
954  if ((*DeviceInit)->InitType != FxDeviceInitTypeFdo) {
958  "Client called WdfDeviceInitAllowSelfTarget. Self "
959  "IO Targets are supported only for FDOs, %!STATUS!", status);
960  return status;
961  }
962  }
963 
965  DeviceInit,
967  &pDevice);
968  if (NT_SUCCESS(status)) {
969  *Device = pDevice->GetHandle();
970  }
971 
972  return status;
973 }
974 
977 NTSTATUS
978 STDCALL
979 WDFEXPORT(WdfDeviceCreateSymbolicLink)(
980  __in
982  __in
983  WDFDEVICE Device,
984  __in
986  )
987 {
988  DDI_ENTRY();
989 
992  FxDevice* pDevice;
994 
996  Device,
998  (PVOID *) &pDevice,
1000 
1002 
1003  if (SymbolicLinkName->Length == 0) {
1005 
1007  "WDFDEVICE %p, SymbolicLinkName has no length, %!STATUS!",
1008  Device, status);
1009 
1010  return status;
1011  }
1012 
1014  if (!NT_SUCCESS(status)) {
1015  return status;
1016  }
1017 
1019  if (!NT_SUCCESS(status)) {
1020  return status;
1021  }
1022 
1025 
1028  "WDFDEVICE %p already has a symbolic link associated with it, %!STATUS!",
1029  Device, status);
1030 
1031  return status;
1032  }
1033 
1035 
1036  return status;
1037 }
1038 
1041 NTSTATUS
1042 STDCALL
1043 WDFEXPORT(WdfDeviceQueryProperty)(
1044  __in
1046  __in
1047  WDFDEVICE Device,
1048  __in
1050  __in
1054  __out
1056  )
1057 /*++
1058 
1059 Routine Description:
1060  Retrieves the requested device property for the given device
1061 
1062 Arguments:
1063  Device - the device whose PDO whose will be queried
1064 
1065  DeviceProperty - the property being queried
1066 
1067  BufferLength - length of PropertyBuffer in bytes
1068 
1069  PropertyBuffer - Buffer which will receive the property being queried
1070 
1071  ResultLength - if STATUS_BUFFER_TOO_SMALL is returned, then this will contain
1072  the required length
1073 
1074 Return Value:
1075  NTSTATUS
1076 
1077  --*/
1079  DDI_ENTRY();
1080 
1082  FxDevice* pDevice;
1083  NTSTATUS status;
1084 
1086  Device,
1088  (PVOID *) &pDevice,
1089  &pFxDriverGlobals);
1090 
1092  if (BufferLength > 0) {
1094  }
1095 
1097  if (!NT_SUCCESS(status)) {
1098  return status;
1099  }
1100 
1101  if (pDevice->IsLegacy()) {
1103 
1105  "WDFDEVICE 0x%p is not a PnP device %!STATUS!",
1106  Device, status);
1107 
1108  return status;
1109  }
1110 
1112  NULL,
1113  pDevice,
1114  NULL,
1116  BufferLength,
1118  ResultLength);
1119 
1121  "exit WDFDEVICE %p, Property %d, %!STATUS!",
1123 
1124  return status;
1125 }
1126 
1129 NTSTATUS
1130 STDCALL
1131 WDFEXPORT(WdfDeviceAllocAndQueryProperty)(
1132  __in
1134  __in
1135  WDFDEVICE Device,
1136  __in
1138  __in
1139  __drv_strictTypeMatch(__drv_typeExpr)
1141  __in_opt
1143  __out
1144  WDFMEMORY* PropertyMemory
1145  )
1146 /*++
1147 
1148 Routine Description:
1149  Allocates and retrieves the requested device property for the given device
1150 
1151 Arguments:
1152  Device - the pnp device whose PDO whose will be queried
1153 
1154  DeviceProperty - the property being queried
1155 
1156  PoolType - what type of pool to allocate
1157 
1158  PropertyMemoryAttributes - attributes to associate with PropertyMemory
1159 
1160  PropertyMemory - handle which will receive the property buffer
1161 
1162 Return Value:
1163  NTSTATUS
1164 
1165  --*/
1167  DDI_ENTRY();
1168 
1170  FxDevice* pDevice;
1171  NTSTATUS status;
1172 
1174  Device,
1176  (PVOID *) &pDevice,
1177  &pFxDriverGlobals);
1178 
1180 
1181  *PropertyMemory = NULL;
1182 
1184  if (!NT_SUCCESS(status)) {
1185  return status;
1186  }
1187 
1189 
1191  if (!NT_SUCCESS(status)) {
1192  return status;
1193  }
1194 
1195  if (pDevice->IsLegacy()) {
1197 
1199  "WDFDEVICE %p is not a PnP device, %!STATUS!",
1200  Device, status);
1201 
1202  return status;
1203  }
1204 
1206  NULL,
1207  pDevice,
1208  NULL,
1210  PoolType,
1212  PropertyMemory);
1213 
1215  "exit WDFDEVICE %p, Property %d, %!STATUS!",
1217 
1218  return status;
1219 }
1220 
1222 VOID
1223 STDCALL
1224 WDFEXPORT(WdfDeviceSetStaticStopRemove)(
1225  __in
1227  __in
1228  WDFDEVICE Device,
1229  __in
1231  )
1233  DDI_ENTRY();
1234 
1235  FxDevice *pDevice;
1236 
1238  Device,
1240  (PVOID*) &pDevice);
1241 
1242  if (Stoppable) {
1243  //
1244  // Stoppable means that query stop / query remove can succeed.
1245  // This means m_DeviceStopCount == 0 (eventually if there are nested
1246  // calls to this function).
1247  //
1250  }
1251  else {
1253  }
1254 
1255  return;
1256 }
1257 
1259 VOID
1260 STDCALL
1261 WDFEXPORT(WdfDeviceSetFailed)(
1262  __in
1264  __in
1265  WDFDEVICE Device,
1266  __in
1268  )
1270  DDI_ENTRY();
1271 
1273  FxDevice *pDevice;
1274 
1276  Device,
1278  (PVOID *) &pDevice,
1279  &pFxDriverGlobals);
1280 
1285  "Invalid FailedAction %d", FailedAction);
1287  return;
1288  }
1289 
1292  "WDFDEVICE %p, !devobj %p SetFailed %!WDF_DEVICE_FAILED_ACTION!",
1294 
1296 }
1297 
1298 __inline
1299 NTSTATUS
1301  __in
1303  __in
1304  WDFDEVICE Device,
1305  __in
1307  __in
1308  PVOID Tag,
1309  __in
1310  LONG Line,
1311  __in
1312  PSTR File
1313  )
1314 {
1316  NTSTATUS status;
1317  FxDevice *pDevice;
1318 
1320  Device,
1322  (PVOID *) &pDevice,
1323  &pFxDriverGlobals);
1324 
1325  if (WaitForD0) {
1327  PASSIVE_LEVEL);
1328  if (!NT_SUCCESS(status)) {
1329  return status;
1330  }
1331  }
1332 
1333 
1338  "WDFDEVICE %p WdfDeviceStopIdle does nothing if you are not the power "
1339  "policy owner for the stack, %!STATUS!", Device, status);
1340  return status;
1341  }
1342 
1344 
1347  "WDFDEVICE %p WdfDeviceStopIdle, WaitForD0 %d %!STATUS!",
1348  Device, WaitForD0, status);
1349 
1350  return status;
1351 }
1352 
1353 __inline
1354 VOID
1356  __in
1358  __in
1359  WDFDEVICE Device,
1360  __in
1361  PVOID Tag,
1362  __in
1363  LONG Line,
1364  __in
1365  PSTR File
1366  )
1367 {
1369  FxDevice *pDevice;
1370 
1372  Device,
1374  (PVOID *) &pDevice,
1375  &pFxDriverGlobals);
1376 
1380  "WdfDeviceResumeIdle does nothing if you are not the power "
1381  "policy owner for the stack");
1382  return;
1383  }
1384 
1386 }
1387 
1391 NTSTATUS
1392 STDCALL
1393 WDFEXPORT(WdfDeviceStopIdleNoTrack)(
1394  __in
1396  __in
1397  WDFDEVICE Device,
1398  __in
1400  )
1402  DDI_ENTRY();
1403 
1404  NTSTATUS status;
1405 
1407  Device,
1408  WaitForD0,
1409  NULL,
1410  0,
1411  NULL);
1412 
1413  return status;
1414 }
1415 
1419 NTSTATUS
1420 STDCALL
1421 WDFEXPORT(WdfDeviceStopIdleActual)(
1422  __in
1424  __in
1425  WDFDEVICE Device,
1426  __in
1428  __in_opt
1429  PVOID Tag,
1430  __in
1431  LONG Line,
1432  __in
1433  PSTR File
1434  )
1436  DDI_ENTRY();
1437 
1438  NTSTATUS status;
1439 
1441  Device,
1442  WaitForD0,
1443  Tag,
1444  Line,
1445  File);
1446 
1447  return status;
1448 }
1449 
1451 VOID
1452 STDCALL
1453 WDFEXPORT(WdfDeviceResumeIdleNoTrack)(
1454  __in
1456  __in
1457  WDFDEVICE Device
1458  )
1459 {
1460  DDI_ENTRY();
1461 
1463  Device,
1464  NULL,
1465  0,
1466  NULL);
1467 }
1468 
1470 VOID
1471 STDCALL
1472 WDFEXPORT(WdfDeviceResumeIdleActual)(
1473  __in
1475  __in
1476  WDFDEVICE Device,
1477  __in_opt
1478  PVOID Tag,
1479  __in
1480  LONG Line,
1481  __in
1482  PSTR File
1483  )
1484 {
1485  DDI_ENTRY();
1486 
1488  Device,
1489  Tag,
1490  Line,
1491  File);
1492 }
1493 
1495 VOID
1496 STDCALL
1497 WDFEXPORT(WdfDeviceSetPnpCapabilities)(
1498  __in
1500  __in
1501  WDFDEVICE Device,
1502  __in
1504  )
1505 /*++
1506 
1507 Routine Description:
1508  Sets the pnp capabilities of the device. This function is usually called
1509  during AddDevice or EvtDevicePrepareHardware since these values are queried
1510  by the stack and pnp during start device processing or immediately afterwards.
1511 
1512 Arguments:
1513  Device - Device being set
1514 
1515  PnpCapabilities - Caps being set
1516 
1517 Return Value:
1518  None
1519 
1520  --*/
1522  DDI_ENTRY();
1523 
1525  FxDevice* pDevice;
1526  ULONG i;
1527 
1528  const static FxOffsetAndName offsets[] = {
1535  OFFSET_AND_NAME(WDF_DEVICE_PNP_CAPABILITIES, SurpriseRemovalOK),
1536  OFFSET_AND_NAME(WDF_DEVICE_PNP_CAPABILITIES, HardwareDisabled),
1538  };
1539 
1541  Device,
1543  (PVOID *) &pDevice,
1544  &pFxDriverGlobals);
1545 
1547 
1551  "WDFDEVICE 0x%p PnpCapabilities Size %d, expected %d",
1554 
1555  return; // STATUS_INFO_LENGTH_MISMATCH;
1556  }
1557  else {
1558  for (i = 0; i < ARRAY_SIZE(offsets); i++) {
1560 
1561  //
1562  // This check makes prefast happy
1563  //
1564  if (offsets[i].Offset + sizeof(WDF_TRI_STATE) >
1565  sizeof(*PnpCapabilities)) {
1566  return;
1567  }
1568 
1570  offsets[i].Offset);
1571  switch (value) {
1572  case WdfFalse:
1573  case WdfTrue:
1574  case WdfUseDefault:
1575  break;
1576 
1577  default:
1580  "WDFDEVICE 0x%p PnpCapabilities WDF_TRI_STATE %s value out "
1581  "of range, value is %d", Device, offsets[i].Name, value);
1583 
1584  return; // STATUS_INVALID_PARAMETER
1585  }
1586  }
1587  }
1588 
1590 }
1591 
1593 VOID
1594 STDCALL
1595 WDFEXPORT(WdfDeviceSetPowerCapabilities)(
1596  __in
1598  __in
1599  WDFDEVICE Device,
1600  __in
1602  )
1603 /*++
1604 
1605 Routine Description:
1606  Sets the power capabilities of the device. This function is usually called
1607  during AddDevice or EvtDevicePrepareHardware since these values are queried
1608  by the stack and power during start device processing or immediately afterwards.
1609 
1610 Arguments:
1611  Device - Device being set
1612 
1613  PowerCapabilities - Caps being set
1614 
1615 Return Value:
1616  None
1617 
1618  --*/
1620  DDI_ENTRY();
1621 
1622  FxDevice* pDevice;
1623  ULONG i;
1625 
1626  const static FxOffsetAndName offsets[] = {
1633  };
1634 
1636  Device,
1638  (PVOID *) &pDevice,
1639  &pFxDriverGlobals);
1640 
1642 
1644 
1647  "WDFDEVICE 0x%p PowerCapabilities Size %d, expected %d",
1648  Device, PowerCapabilities->Size,
1650 
1652 
1653  return; // STATUS_INFO_LENGTH_MISMATCH;
1654  }
1655  else {
1656  for (i = 0; i < ARRAY_SIZE(offsets); i++) {
1658 
1659  //
1660  // This check makes prefast happy
1661  //
1662  if (offsets[i].Offset + sizeof(WDF_TRI_STATE) >
1663  sizeof(*PowerCapabilities)) {
1664  return;
1665  }
1666 
1668  offsets[i].Offset);
1669  switch (value) {
1670  case WdfFalse:
1671  case WdfTrue:
1672  case WdfUseDefault:
1673  break;
1674 
1675  default:
1678  "WDFDEVICE 0x%p PowerCapabilities WDF_TRI_STATE %s value out "
1679  "of range, value is %d",
1680  Device, offsets[i].Name, value);
1682 
1683  return; // STATUS_INVALID_PARAMETER
1684  }
1685  }
1686 
1687  for (i = 0; i < ARRAY_SIZE(PowerCapabilities->DeviceState); i++) {
1688  if (PowerCapabilities->DeviceState[i] < PowerDeviceUnspecified ||
1689  PowerCapabilities->DeviceState[i] > PowerDeviceMaximum) {
1690 
1692  "WDFDEVICE 0x%p PowerCapabilities DeviceState is invalid",
1693  Device);
1694 
1696 
1697  return; // STATUS_INVALID_PARAMETER;
1698  }
1699  }
1700 
1701  if (PowerCapabilities->DeviceWake < PowerDeviceUnspecified ||
1702  PowerCapabilities->DeviceWake > PowerDeviceMaximum) {
1703 
1706  "WDFDEVICE 0x%p PowerCapabilities DeviceWake %d is out of range",
1707  Device, PowerCapabilities->DeviceWake);
1708 
1710 
1711  return; // STATUS_INVALID_PARAMETER;
1712  }
1713 
1714  if (PowerCapabilities->SystemWake < PowerSystemUnspecified ||
1715  PowerCapabilities->SystemWake > PowerSystemMaximum) {
1716 
1719  "WDFDEVICE 0x%p PowerCapabilities SystemWake %d is out of range",
1720  Device, PowerCapabilities->SystemWake);
1721 
1723 
1724  return; // STATUS_INVALID_PARAMETER;
1725  }
1726 
1728  PowerCapabilities->IdealDxStateForSx != PowerDeviceMaximum) {
1731  "WDFDEVICE 0x%p PowerCapabilities IdealDxStateForSx %d can only"
1732  " be set by the power policy owner",
1733  Device, PowerCapabilities->IdealDxStateForSx);
1734 
1736 
1737  return; // STATUS_INVALID_PARAMETER;
1738  }
1739 
1740  //
1741  // D0 is not allowed as an ideal Dx state
1742  //
1743  if (PowerCapabilities->IdealDxStateForSx < PowerDeviceD1 ||
1744  PowerCapabilities->IdealDxStateForSx > PowerDeviceMaximum) {
1745 
1748  "WDFDEVICE 0x%p PowerCapabilities IdealDxStateForSx %d is out "
1749  "of range", Device, PowerCapabilities->IdealDxStateForSx);
1750 
1752 
1753  return; // STATUS_INVALID_PARAMETER;
1754  }
1755  }
1756 
1757 
1759 }
1760 
1763 NTSTATUS
1764 STDCALL
1765 WDFEXPORT(WdfDeviceConfigureRequestDispatching)(
1766  __in
1768  __in
1769  WDFDEVICE Device,
1770  __in
1771  WDFQUEUE Queue,
1772  __in
1773  __drv_strictTypeMatch(__drv_typeCond)
1775  )
1776 
1777 /*++
1778 
1779 Routine Description:
1780 
1781  Configure which IRP_MJ_* requests are automatically
1782  forwarded by the I/O package to the specified Queue.
1783 
1784  By default the I/O package sends all requests to the
1785  devices default queue. This API allows certain requests
1786  to be specified to their own queues under driver control.
1787 
1788 Arguments:
1789 
1790  Device - The device which is handling the IO.
1791 
1792  Queue - I/O Queue object to forward specified request to.
1793 
1794  RequestType - WDF Request type to be forwarded to the queue
1795 
1796 Returns:
1797 
1798  NTSTATUS
1799 
1800 --*/
1801 
1802 {
1803  DDI_ENTRY();
1804 
1806  NTSTATUS status;
1807  FxDevice* pDevice;
1809 
1810  pDevice = NULL;
1811  pFxIoQueue = NULL;
1812 
1814  Device,
1816  (PVOID *) &pDevice,
1817  &pFxDriverGlobals);
1818 
1826  "Invalid RequestType %!WDF_REQUEST_TYPE!, %!STATUS!",
1827  RequestType, status);
1828  return status;
1829  }
1830 
1831  //
1832  // Validate the Queue handle
1833  //
1835  Queue,
1836  FX_TYPE_QUEUE,
1837  (PVOID*)&pFxIoQueue);
1838 
1839  if (pDevice != pFxIoQueue->GetDevice()) {
1841 
1844  "Input WDFQUEUE 0x%p doesn't belong to the WDFDEVICE 0x%p, %!STATUS!",
1845  Queue, Device, status);
1846 
1847  return status;
1848  }
1849 
1850  if (pDevice->IsLegacy()) {
1851  //
1852  // This is a controldevice. Make sure the create is called after the device
1853  // is initialized and ready to accept I/O.
1854  //
1857 
1861  "Queue cannot be configured for automatic dispatching"
1862  " after WdfControlDeviceFinishInitializing"
1863  "is called on the WDFDEVICE %p is called %!STATUS!",
1864  Device,
1865  status);
1866  return status;
1867  }
1868  }
1869  else {
1870  //
1871  // This is either FDO or PDO. Make sure it's not started yet.
1872  //
1877  "Queue cannot be configured for automatic dispatching"
1878  "after the WDFDEVICE %p is started, %!STATUS!",
1879  Device, status);
1880  return status;
1881  }
1882  }
1883 
1886  }
1887  else {
1889  }
1890 
1891  return status;
1892 }
1893 
1895 WDFQUEUE
1896 STDCALL
1897 WDFEXPORT(WdfDeviceGetDefaultQueue)(
1898  __in
1900  __in
1901  WDFDEVICE Device
1902  )
1903 
1904 /*++
1905 
1906 Routine Description:
1907 
1908  Return the handle to the default queue for the device.
1909 
1910 Arguments:
1911 
1912  Device - Handle to the Device Object
1913 
1914 Returns:
1915 
1916  WDFQUEUE
1917 
1918 --*/
1919 
1920 {
1921  DDI_ENTRY();
1922 
1925  FxDevice * pFxDevice;
1927 
1928  pPkgIo = NULL;
1929  pFxIoQueue = NULL;
1930 
1931  //
1932  // Validate the I/O Package handle, and get the FxPkgIo*
1933  //
1935  Device,
1937  (PVOID *) &pFxDevice,
1938  &pFxDriverGlobals);
1939 
1942 
1943  //
1944  // A default queue is optional
1945  //
1946  if (pFxIoQueue == NULL) {
1948  "No default Queue configured "
1949  "for Device 0x%p", Device);
1950  return NULL;
1951  }
1952 
1953  return (WDFQUEUE)pFxIoQueue->GetObjectHandle();;
1954 }
1955 
1958 NTSTATUS
1959 STDCALL
1960 WDFEXPORT(WdfDeviceEnqueueRequest)(
1961  __in
1963  __in
1964  WDFDEVICE Device,
1965  __in
1966  WDFREQUEST Request
1967  )
1968 
1969 /*++
1970 
1971 Routine Description:
1972 
1973  Inserts a request into the I/O Package processing pipeline.
1974 
1975  The given request is processed by the I/O package, forwarding
1976  it to its configured destination or the default queue.
1977 
1978  If an EvtIoInCallerContext is callback is registered, it is not called.
1979 
1980 Arguments:
1981 
1982  Device - Handle to the Device Object
1983 
1984  Request - Request to insert in the processing pipeline
1985 
1986 Return Value:
1987 
1988  STATUS_SUCCESS - Request has been inserted into the I/O processing pipeline
1989 
1990  !NT_SUCCESS(status)
1991  STATUS_WDF_BUSY - Device is not accepting requests, the driver still owns the
1992  the request and must complete it, or correct the conditions.
1993 
1994 --*/
1995 
1997  DDI_ENTRY();
1998 
2000  FxDevice *pDevice;
2002 
2003  //
2004  // Validate the device object handle
2005  //
2007  Device,
2009  (PVOID *) &pDevice,
2010  &pFxDriverGlobals);
2011  //
2012  // Validate Device object handle
2013  //
2015  Device,
2017  (PVOID *) &pDevice);
2018 
2019  //
2020  // Validate the request object handle
2021  //
2023  Request,
2025  (PVOID *) &pRequest);
2026 
2027  //
2028  // Dispatch it to the Io Package object
2029  //
2031 }
2032 
2035 STDCALL
2036 WDFEXPORT(WdfDeviceGetSystemPowerAction)(
2037  __in
2039  __in
2040  WDFDEVICE Device
2041  )
2042 
2043 /*++
2044 
2045 Routine Description:
2046 
2047  This DDI returns the System power action.
2048 
2049  If the DDI is called in the power down path of a device, it will return the
2050  current system power transition type because of which the device is powering
2051  down. If the DDI is called in the power up path of a device, it will return
2052  the system power transition type which initially put the device into a lower
2053  power state. If the DDI is called during the normal functioning of a device
2054  that is not undergoing a power state transition, or if the device is powering
2055  up as part of the system start up, the DDI will return the PowerActionNone
2056  value.
2057 
2058 Arguments:
2059 
2060  Device - Handle to the Device Object
2061 
2062 Return Value:
2063 
2064  Returns a POWER_ACTION enum value that represents the current system power
2065  action with regards to any system power transition underway.
2066 
2067 --*/
2068 
2069 {
2070  DDI_ENTRY();
2071 
2072  FxDevice *pDevice;
2073 
2074  //
2075  // Validate Device object handle
2076  //
2078  Device,
2080  (PVOID*) &pDevice);
2081 
2083 }
2084 
2087 WDFAPI
2088 NTSTATUS
2089 STDCALL
2090 WDFEXPORT(WdfDeviceQueryPropertyEx)(
2091  _In_
2093  _In_
2094  WDFDEVICE Device,
2095  _In_
2097  _In_
2099  _Out_
2101  _Out_
2103  _Out_
2105  )
2106 /*++
2107 
2108 Routine Description:
2109 
2110  This routine queries interface property.
2111 
2112 Arguments:
2113 
2114  DriverGlobals - DriverGlobals pointer
2115 
2116  Device - WDF Device handle.
2117 
2118  DeviceProperty - A pointer to WDF_DEVICE_PROPERTY_ DATA structure.
2119 
2120  BufferLength - The size, in bytes, of the buffer that is pointed to by
2121  PropertyBuffer.
2122 
2123  PropertyBuffer - A caller-supplied pointer to a caller-allocated buffer that
2124  receives the requested information. The pointer can be NULL
2125  if the BufferLength parameter is zero.
2126 
2127  ResultLength - A caller-supplied location that, on return, contains the
2128  size, in bytes, of the information that the method stored in
2129  PropertyBuffer. If the function's return value is
2130  STATUS_BUFFER_TOO_SMALL, this location receives the required
2131  buffer size.
2132 
2133  Type - A pointer to a DEVPROPTYPE variable. If method successfully retrieves
2134  the property data, the routine writes the property type value
2135  to this variable. This value indicates the type of property
2136  data that is in the Data buffer.
2137 
2138 Return Value:
2139 
2140  Method returns an NTSTATUS value. This routine might return one of the
2141  following values.
2142 
2143  STATUS_BUFFER_TOO_SMALL - The supplied buffer is too small to receive the
2144  information. The ResultLength member receives the
2145  size of buffer required.
2146  STATUS_SUCCESS - The operation succeeded.
2147  STATUS_INVALID_PARAMETER - One of the parameters is incorrect.
2148 
2149  The method might return other NTSTATUS values.
2150 
2151 --*/
2152 
2154  DDI_ENTRY();
2155 
2157  FxDevice* pDevice;
2158  NTSTATUS status;
2159 
2161  Device,
2163  (PVOID *) &pDevice,
2164  &pFxDriverGlobals);
2165 
2167 
2168  //
2169  // Validate PropertyData
2170  //
2174  "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
2175  DeviceProperty->Size,
2176  sizeof(WDF_DEVICE_PROPERTY_DATA), status);
2177  return status;
2178  }
2179 
2181  if (!NT_SUCCESS(status)) {
2183  return status;
2184  }
2185 
2188 
2192  "Property buffer size is non-zero, while the buffer is NULL"
2193  ", %!STATUS!", status);
2194  return status;
2195  }
2196 
2200  "Property buffer size is zero, while the buffer is non-NULL"
2201  ", %!STATUS!", status);
2202  return status;
2203  }
2204 
2206  NULL,
2207  pDevice,
2210  BufferLength,
2212  RequiredSize,
2213  Type);
2214  return status;
2215 }
2216 
2219 WDFAPI
2220 NTSTATUS
2221 STDCALL
2222 WDFEXPORT(WdfDeviceAllocAndQueryPropertyEx)(
2223  _In_
2225  _In_
2226  WDFDEVICE Device,
2227  _In_
2229  _In_
2232  _In_opt_
2234  _Out_
2235  WDFMEMORY* PropertyMemory,
2236  _Out_
2238  )
2239 /*++
2240 
2241 Routine Description:
2242 
2243  This routine queries device property.
2244 
2245 Arguments:
2246 
2247  DriverGlobals - DriverGlobals pointer
2248 
2249  Device - WDF Device handle.
2250 
2251  PropertyData - A pointer to WDF_DEVICE_PROPERTY_ DATA structure.
2252 
2253  PoolType - A POOL_TYPE-typed enumerator that specifies the type of memory
2254  to be allocated.
2255 
2256  PropertyMemoryAttributes - optional, A pointer to a caller-allocated
2257  WDF_OBJECT_ATTRIBUTES structure that describes object attributes
2258  for the memory object that the function will allocate. This
2259  parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.
2260 
2261  PropertyMemory - A pointer to a WDFMEMORY-typed location that receives a
2262  handle to a framework memory object.
2263 
2264  Type - A pointer to a DEVPROPTYPE variable. If method successfully retrieves
2265  the property data, the routine writes the property type value to
2266  this variable. This value indicates the type of property data
2267  that is in the Data buffer.
2268 
2269 Return Value:
2270 
2271  Method returns an NTSTATUS value. This routine might return one of the
2272  following values. It might return other NTSTATUS-codes as well.
2273 
2274  STATUS_SUCCESS The operation succeeded.
2275  STATUS_INVALID_PARAMETER One of the parameters is incorrect.
2276 
2277 --*/
2278 {
2279  DDI_ENTRY();
2280 
2282  FxDevice* pDevice;
2283  NTSTATUS status;
2284 
2286  Device,
2288  (PVOID *) &pDevice,
2289  &pFxDriverGlobals);
2290 
2292 
2293  //
2294  // Validate PropertyData
2295  //
2296  if (DeviceProperty->Size != sizeof(WDF_DEVICE_PROPERTY_DATA)) {
2299  "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
2300  DeviceProperty->Size,
2301  sizeof(WDF_DEVICE_PROPERTY_DATA), status);
2302  return status;
2303  }
2304 
2306  if (!NT_SUCCESS(status)) {
2308  return status;
2309  }
2310 
2312 
2315 
2316  *PropertyMemory = NULL;
2317 
2319  if (!NT_SUCCESS(status)) {
2320  return status;
2321  }
2322 
2324  NULL,
2325  pDevice,
2328  PoolType,
2331  Type);
2332  return status;
2333 }
2334 
2337 WDFAPI
2338 NTSTATUS
2339 STDCALL
2340 WDFEXPORT(WdfDeviceAssignProperty)(
2341  _In_
2343  _In_
2344  WDFDEVICE Device,
2345  _In_
2347  _In_
2348  DEVPROPTYPE Type,
2349  _In_
2351  _In_opt_
2353  )
2354 /*++
2355 
2356 Routine Description:
2357 
2358  This routine assigns interface property.
2359 
2360 Arguments:
2361 
2362  DriverGlobals - DriverGlobals pointer
2363 
2364  Device - WDF Device handle.
2365 
2366  PropertyData - A pointer to WDF_DEVICE_PROPERTY_ DATA structure.
2367 
2368  Type - Set this parameter to the DEVPROPTYPE value that specifies the type
2369  of the data that is supplied in the Data buffer.
2370 
2371  BufferLength - Specifies the length, in bytes, of the buffer that
2372  PropertyBuffer points to.
2373 
2374  PropertyBuffer - optional, A pointer to the device interface property data.
2375  Set this parameter to NULL to delete the specified property.
2376 
2377 Return Value:
2378 
2379  Mthod returns an NTSTATUS value. This routine might return one of the
2380  following values. It might return other NTSTATUS-codes as well.
2381 
2382  STATUS_SUCCESS - The operation succeeded.
2383  STATUS_INVALID_PARAMETER - One of the parameters is incorrect.
2384 
2385 --*/
2386 
2387 {
2388  DDI_ENTRY();
2389 
2391  FxDevice *pDevice;
2392  NTSTATUS status;
2393 
2394  //
2395  // Validate the Device object handle and get its FxDevice. Also get the
2396  // driver globals pointer.
2397  //
2399  Device,
2401  (PVOID *) &pDevice,
2402  &pFxDriverGlobals);
2403 
2405 
2406  //
2407  // Validate PropertyData
2408  //
2409  if (DeviceProperty->Size != sizeof(WDF_DEVICE_PROPERTY_DATA)) {
2412  "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
2413  DeviceProperty->Size,
2414  sizeof(WDF_DEVICE_PROPERTY_DATA), status);
2415  return status;
2416  }
2417 
2419  if (!NT_SUCCESS(status)) {
2421  return status;
2422  }
2423 
2424  if (BufferLength == 0 && PropertyBuffer != NULL) {
2427  "Property buffer size is zero, while the buffer is non-NULL"
2428  ", %!STATUS!", status);
2429  return status;
2430  }
2431 
2434  Type,
2435  BufferLength,
2437  );
2438  return status;
2439 }
2440 
2443 WDFAPI
2444 NTSTATUS
2445 STDCALL
2446 WDFEXPORT(WdfDeviceConfigureWdmIrpDispatchCallback)(
2447  _In_
2449  _In_
2450  WDFDEVICE Device,
2451  _In_opt_
2452  WDFDRIVER Driver,
2453  _In_
2455  _In_
2457  _In_opt_
2459  )
2460 
2461 /*++
2462 
2463  Routine Description:
2464 
2465  Configure callbacks for IRP_MJ_READ, IRP_MJ_WRITE, IRP_MJ_DEVICE_CONTROL, and
2466  IRP_MJ_INTERNAL_DEVICE_CONTROL (KMDF only). By default the I/O package sends all requests to
2467  a device's default queue, or to the queues configured with
2468  WdfDeviceConfigureRequestDisaptching. This DDI allows a driver specified
2469  callback to select a different queue dynamically during runtime.
2470 
2471  Arguments:
2472 
2473  Device - The device which is handling the I/O.
2474 
2475  Driver - An optional driver handle. Used to associate the
2476  callback with a specific class extension.
2477 
2478  MajorFunction - IRP major function type to be forwarded to the callback
2479 
2480  EvtDeviceWdmIrpDispatch - Callback invoked when encountering the given major function.
2481 
2482  DriverContext - An optional untyped driver specified context.
2483 
2484  Returns:
2485 
2486  STATUS_SUCCESS on success
2487  STATUS_INVALID_PARAMETER if an incorrect MajorFunction was provided
2488  STATUS_INSUFFICIENT_RESOURCES if insufficient memory was available
2489  STATUS_INVALID_DEVICE_STATE if this DDI was called at an improper time
2490 
2491  --*/
2494  NTSTATUS status;
2495  FxDevice* pDevice;
2498 
2499  pDevice = NULL;
2500  pCxDeviceInfo = NULL;
2501 
2503  Device,
2505  (PVOID *) &pDevice,
2506  &pFxDriverGlobals);
2507 
2508  //
2509  // Validate the MajorFunction provided. Note that
2510  // IRP_MJ_INTERNAL_DEVICE_CONTROL is KMDF only.
2511  //
2512  switch (MajorFunction) {
2513  case IRP_MJ_WRITE:
2514  case IRP_MJ_READ:
2515  case IRP_MJ_DEVICE_CONTROL:
2516 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2518 #endif
2519  break;
2520  default:
2524  "Invalid MajorFunction provided %!IRPMJ!, %!STATUS!",
2526  goto exit;
2527  }
2528 
2529  //
2530  // Validate the driver handle and get (if present) the associated cx info.
2531  //
2532  if (Driver != NULL) {
2533  FxDriver* pDriver;
2534 
2536  Driver,
2538  (PVOID*)&pDriver);
2539 
2540  //
2541  // Find the driver's cx info if it's not the main driver for this device.
2542  // cx struct info can be NULL if cx acts as client driver.
2543  //
2545  }
2546 
2547  //
2548  // Make sure callback is not null.
2549  //
2551 
2552  //
2553  // This callback can only be called during initialization.
2554  //
2555  if (pDevice->IsLegacy()) {
2556 
2557  //
2558  // Extract the device flags from the device object
2559  //
2560 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2562 #else
2563  deviceFlags = pDevice->GetDeviceObject()->GetDeviceObjectWdmFlags();
2564 #endif
2565 
2566  //
2567  // This is a controldevice. Make sure the create is called after the device
2568  // is initialized and ready to accept I/O.
2569  //
2570  if ((deviceFlags & DO_DEVICE_INITIALIZING) == 0x0) {
2574  "Driver cannot set IRP dispatch callback "
2575  "after WdfControlDeviceFinishInitializing "
2576  "is called on the WDFDEVICE %p, %!STATUS!",
2577  pDevice, status);
2578  goto exit;
2579  }
2580  } else {
2581  //
2582  // This is either FDO or PDO. Make sure it's not started yet.
2583  //
2588  "Driver cannot set IRP dispatch callback "
2589  "after the WDFDEVICE %p is started, %!STATUS!",
2590  pDevice, status);
2591  goto exit;
2592  }
2593  }
2594 
2595  //
2596  // Let I/O package do the rest.
2597  //
2599  pCxDeviceInfo,
2601  DriverContext);
2602 exit:
2603  return status;
2604 }
2605 
2607 NTSTATUS
2609  _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
2610  _In_ FxDevice* device,
2611  _In_ MdIrp Irp,
2612  _In_ FxIoQueue* queue,
2613  _In_ ULONG Flags
2614  )
2615 {
2617  UCHAR majorFunction, minorFunction;
2618  FxIrp fxIrp(Irp);
2619 
2621 
2623  minorFunction = fxIrp.GetMinorFunction();
2624 
2626  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
2627  "WDFDEVICE 0x%p !devobj 0x%p %!IRPMJ!, IRP_MN %x, IRP 0x%p",
2628  device->GetHandle(), device->GetDeviceObject(),
2629  majorFunction, minorFunction, Irp);
2630 
2631  //
2632  // Validate Flags. For UMDF, this field is reserved and must be zero.
2633  //
2634 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2636 #else
2638 #endif
2641  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2642  "Flags 0x%x are invalid, %!STATUS!",
2643  Flags, status);
2644  FxVerifierDbgBreakPoint(FxDriverGlobals);
2645  goto Done;
2646  }
2647 
2648  //
2649  // Only read/writes/ctrls/internal_ctrls IRPs are allowed, i.e., the I/O request set.
2650  //
2651  if (device->GetDispatchPackage(majorFunction) != device->m_PkgIo) {
2654  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2655  "Only Read/Write/Control/Internal-Control IRPs can be "
2656  "forwarded to I/O Queue 0x%p, Irp 0x%p, %!IRPMJ!, "
2657  "IRP_MN %x, Device 0x%p, %!STATUS!",
2658  queue->GetHandle(), Irp, majorFunction, minorFunction,
2659  device->GetObjectHandle(), status);
2660  FxVerifierDbgBreakPoint(FxDriverGlobals);
2661  goto Done;
2662  }
2663 
2664  //
2665  // Make sure queue can handle the request.
2666  //
2667  if (FALSE == queue->IsIoEventHandlerRegistered(
2669 
2672  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2673  "I/O Queue 0x%p cannot handle Irp 0x%p, %!IRPMJ!, "
2674  "IRP_MN %x, Device 0x%p, %!STATUS!",
2675  queue->GetHandle(), Irp, majorFunction, minorFunction,
2676  device->GetObjectHandle(), status);
2677  FxVerifierDbgBreakPoint(FxDriverGlobals);
2678  goto Done;
2679  }
2680 
2681  if (device->m_ParentDevice == queue->GetDevice()) {
2682  //
2683  // Send to parent device's queue validation.
2684  //
2685  if (device->m_ParentDevice == NULL) {
2688  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2689  "No parent device for Device 0x%p, %!STATUS!",
2690  device->GetObjectHandle(), status);
2691  FxVerifierDbgBreakPoint(FxDriverGlobals);
2692  goto Done;
2693  }
2694 
2695  //
2696  // Make sure the child device is a PDO
2697  //
2698  ASSERT(device->IsPdo());
2699 
2700  //
2701  // Check if the WdfPdoInitSetForwardRequestToParent was called to
2702  // increase the StackSize of the child Device to include the stack
2703  // size of the parent Device
2704  //
2705  if (device->IsPnp() &&
2706  device->GetPdoPkg()->m_AllowForwardRequestToParent == FALSE) {
2709  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2710  "WdfPdoInitSetForwardRequestToParent not called on "
2711  "Device 0x%p, %!STATUS!",
2712  device->GetObjectHandle(), status);
2713  FxVerifierDbgBreakPoint(FxDriverGlobals);
2714  goto Done;
2715  }
2716  }
2717  else {
2718  //
2719  // Send to current device's queue validation.
2720  //
2721  if (device != queue->GetDevice()) {
2724  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2725  "Cannot forward a request to "
2726  "a different Device 0x%p, %!STATUS!",
2727  queue->GetDevice()->GetObjectHandle(), status);
2728  FxVerifierDbgBreakPoint(FxDriverGlobals);
2729  goto Done;
2730  }
2731  }
2732 
2733 Done:
2734  return status;
2735 }
2736 
2737 } // extern "C"
__in WDFDEVICE Device
Definition: fxdeviceapi.cpp:68
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
enum _WDF_DEVICE_PNP_STATE WDF_DEVICE_PNP_STATE
FxIoTarget * pTarget
Definition: fxdeviceapi.cpp:97
signed char * PCHAR
Definition: retypes.h:7
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
_In_ WDFDEVICE _In_ BOOLEAN Stoppable
Definition: wdfdevice.h:3595
_Must_inspect_result_ __in WDFDEVICE __in ULONG __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFKEY * Key
FxVerifierCheckNxPoolType(pFxDriverGlobals, PoolType, pFxDriverGlobals->Tag)
VOID InvalidateDeviceState(VOID)
_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
__inline NTSTATUS StopIdleWorker(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in WDFDEVICE Device, __in BOOLEAN WaitForD0, __in PVOID Tag, __in LONG Line, __in PSTR File)
#define _Must_inspect_result_
Definition: no_sal2.h:62
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ _Strict_type_match_ POOL_TYPE PoolType
ULONG GetCharacteristics(VOID)
FxIoQueue * queue
#define STATUS_INVALID_SECURITY_DESCR
Definition: ntstatus.h:357
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities
Definition: wdfdevice.h:3883
ULONG m_DeviceStopCount
Definition: fxpkgpnp.hpp:4146
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
ULONG deviceFlags
_Must_inspect_result_ __in WDFDEVICE __in WDFREQUEST Request
FxIoQueue * pFxIoQueue
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
GLint x0
Definition: linetemp.h:95
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
BOOLEAN indicateChildWakeOnParentWake
__nullterminated PCHAR Name
Definition: fxdeviceapi.cpp:33
__in WDFDEVICE __in ULONG DeviceCharacteristics
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
#define __in_opt
Definition: dbghelp.h:38
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
__inline VOID ResumeIdleWorker(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in WDFDEVICE Device, __in PVOID Tag, __in LONG Line, __in PSTR File)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
enum _WDF_TRI_STATE WDF_TRI_STATE
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY DeviceProperty
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
_In_ WDFDEVICE _In_ PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities
Definition: wdfdevice.h:3854
struct _WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_V1_5 WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_V1_5
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH _In_opt_ WDFCONTEXT DriverContext
#define FX_VF_FUNCTION(fnName)
Definition: fxmacros.hpp:47
FxCxDeviceInfo * pCxDeviceInfo
ULONG i
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:1986
LONG NTSTATUS
Definition: precomp.h:26
FxAutoString pdoName
NTSTATUS PowerPolicySetS0IdleSettings(__in PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings)
Definition: fxpkgpnp.cpp:2778
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER Driver
Definition: fxirp.hpp:28
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_Must_inspect_result_ __in WDFDEVICE __in WDFSTRING String
_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
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
VOID SetDeviceBase(__in CfxDeviceBase *DeviceBase)
Definition: fxobject.hpp:797
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
_Must_inspect_result_ __in WDFDEVICE __in PCUNICODE_STRING SymbolicLinkName
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN __in_opt PVOID __in LONG Line
DriverGlobals
VOID SetPnpState(__in PWDF_DEVICE_STATE State)
Definition: fxpkgpnp.cpp:5579
virtual FxIoTarget * GetDefaultIoTarget(VOID)
Definition: fxdevice.hpp:438
ULONG * PDEVPROPTYPE
Definition: devpropdef.h:24
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
__in WDFDEVICE __in PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities
FxDeviceBase * pDeviceBase
Definition: fxdeviceapi.cpp:98
_IRQL_requires_max_(DISPATCH_LEVEL) WDFIOTARGET STDCALL WDFEXPORT(WdfDeviceGetSelfIoTarget)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
Definition: common.c:3557
#define _In_opt_
Definition: no_sal2.h:212
EVT_WDFDEVICE_WDM_IRP_DISPATCH * PFN_WDFDEVICE_WDM_IRP_DISPATCH
Definition: wdfdevice.h:1710
FxDevice * device
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
VOID __inline PowerDereference(__in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxpkgpnp.hpp:3498
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2592
_Must_inspect_result_ __inout PWDFDEVICE_INIT __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFQUEUE _In_ _Strict_type_match_ WDF_REQUEST_TYPE RequestType
Definition: wdfdevice.h:4227
WDFIOTARGET GetHandle(VOID)
Definition: fxiotarget.hpp:307
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR MajorFunction
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
__inline WDF_DEVICE_POWER_STATE GetDevicePowerState()
Definition: fxdevice.hpp:1157
_In_ WDFDEVICE _Out_ PWDF_DEVICE_STATE DeviceState
Definition: wdfdevice.h:1996
_In_ WDFDEVICE _In_ ULONG AlignmentRequirement
Definition: wdfdevice.h:2851
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
_Must_inspect_result_ _Inout_ PWDFDEVICE_INIT _In_opt_ PWDF_OBJECT_ATTRIBUTES DeviceAttributes
Definition: wdfdevice.h:3561
_Must_inspect_result_ NTSTATUS EnqueueRequest(__in CfxDevice *Device, __inout FxRequest *pRequest)
Definition: fxpkgio.cpp:607
long LONG
Definition: pedump.c:60
Definition: devices.h:37
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define WDFAPI
Definition: wdftypes.h:53
return NULL
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN WaitForD0
_In_ WDFDEVICE _In_ ULONG DeviceCharacteristics
Definition: wdfdevice.h:2772
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
#define __out
Definition: dbghelp.h:62
#define PAGED_CODE_LOCKED()
Definition: kefuncs.h:1429
Definition: _queue.h:59
unsigned char BOOLEAN
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
#define _Out_
Definition: no_sal2.h:160
__in WDFDEVICE __in WDF_DEVICE_FAILED_ACTION FailedAction
_Must_inspect_result_ NTSTATUS OpenDevicemapKeyWorker(_In_ PFX_DRIVER_GLOBALS pFxDriverGlobals, _In_ PCUNICODE_STRING KeyName, _In_ ACCESS_MASK DesiredAccess, _In_ FxRegKey *pKey)
Definition: fxdevicekm.cpp:995
IWudfIrp * MdIrp
Definition: mxum.h:103
_Must_inspect_result_ __in WDFDEVICE __in PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
NTSTATUS status
static const FxOffsetAndName offsets[]
FxDevice * pDevice
Definition: fxdeviceapi.cpp:71
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes
Definition: wdfdevice.h:2654
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __in_opt PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
_Must_inspect_result_ NTSTATUS ConfigureForwarding(__in FxIoQueue *FxQueue)
#define OFFSET_AND_NAME(type, offset)
Definition: fxdeviceapi.cpp:37
Definition: arc.h:79
__inline WDFDRIVER GetHandle(VOID)
Definition: fxdriver.hpp:202
_Must_inspect_result_ __in WDFDEVICE __in ULONG DeviceInstanceKeyType
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in ULONG __out_bcount_full(BufferLength) PVOID PropertyBuffer
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDFDEVICE_INIT *DeviceInit, __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes, __out FxDevice **Device)
Definition: fxdevice.cpp:366
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
FxDriver * pDriver
#define TRACINGDEVICE
Definition: dbgtrace.h:58
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__drv_maxIRQL(DISPATCH_LEVEL) WDFDRIVER STDCALL WDFEXPORT(WdfDeviceGetDriver)(__in PWDF_DRIVER_GLOBALS DriverGlobals
#define STDCALL
Definition: wdf.h:45
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ __inout PWDFDEVICE_INIT * DeviceInit
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch
_Must_inspect_result_ NTSTATUS __inline PowerReference(__in BOOLEAN WaitForD0, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxpkgpnp.hpp:3486
INT POOL_TYPE
Definition: typedefs.h:78
Type
Definition: Type.h:6
__in WDFDEVICE __in ULONG AlignmentRequirement
_Must_inspect_result_ NTSTATUS Assign(__in PCWSTR SourceString)
Definition: fxstring.cpp:57
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice)
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
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:2061
VOID SetPnpCaps(__in PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities)
Definition: fxpkgpnp.cpp:5496
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY * PropertyMemory
#define _Strict_type_match_
Definition: no_sal2.h:406
Definition: ncftp.h:79
__in WDFDEVICE __in PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities
BOOLEAN IsPowerPolicyOwner(VOID)
Definition: fxpkgpnp.hpp:3612
__inline FxDriver * GetDriver(VOID)
Definition: fxdevice.hpp:164
unsigned char UCHAR
Definition: xmlstorage.h:181
FxIoTargetSelf * GetSelfIoTarget(VOID)
Definition: fxdevice.cpp:1829
__inline WDF_DEVICE_PNP_STATE GetDevicePnpState()
Definition: fxdevice.hpp:1149
#define InterlockedDecrement
Definition: armddk.h:52
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN WaitForD0
Definition: wdfdevice.h:4003
_Must_inspect_result_ NTSTATUS AssignProperty(_In_ PVOID PropertyData, _In_ FxPropertyType FxPropertyType, _In_ DEVPROPTYPE Type, _In_ ULONG BufferLength, _In_opt_ PVOID PropertyBuffer)
Definition: fxdevicekm.cpp:668
POWER_ACTION
Definition: ntpoapi.h:122
NTSTATUS CreateSymbolicLink(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PCUNICODE_STRING SymbolicLinkName)
Definition: fxdevicekm.cpp:513
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
POWER_ACTION GetSystemPowerAction(VOID)
Definition: fxpkgpnp.hpp:3768
ULONG GetAlignmentRequirement(VOID)
VOID SetPowerCaps(__in PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities)
Definition: fxpkgpnp.cpp:5683
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
#define __inout
Definition: dbghelp.h:50
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
GLsizei const GLfloat * value
Definition: glext.h:6069
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN __in_opt PVOID __in LONG __in PSTR File
#define __nullterminated
Definition: sal.h:2870
_Must_inspect_result_ __in WDFDEVICE __in WDFQUEUE Queue
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __drv_strictTypeMatch(__drv_typeExpr) POOL_TYPE PoolType
MxDeviceObject deviceObject
_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
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
_Must_inspect_result_ __drv_when(WaitForD0==0, __drv_maxIRQL(DISPATCH_LEVEL)) __drv_when(WaitForD0 !=0
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE Type
FxPkgIo * pPkgIo
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice, &pFxDriverGlobals)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
FxRegKey * pKey
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _In_
Definition: no_sal2.h:158
BOOLEAN armForWakeIfChildrenAreArmedForWake
#define TRACINGPNP
Definition: dbgtrace.h:67
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGPNP, "Device name for WDFDEVICE 0x%p is NULL. Possibly incorrect " "device handle was passed, %!STATUS!", Device, status)
FxDevice * pFxDevice
__in WDFDEVICE __in BOOLEAN Stoppable
FxString * pString
VOID SetCharacteristics(ULONG Characteristics)
enum _WDF_DEVICE_FAILED_ACTION WDF_DEVICE_FAILED_ACTION
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define InterlockedIncrement
Definition: armddk.h:53
_Must_inspect_result_ __in WDFDEVICE __in ULONG __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES KeyAttributes
#define ARRAY_SIZE(a)
Definition: main.h:24
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
FxCxDeviceInfo * GetCxDeviceInfo(__in FxDriver *CxDriver)
Definition: fxdevice.hpp:1560
signed char * PSTR
Definition: retypes.h:7
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
VOID SetDeviceFailed(__in WDF_DEVICE_FAILED_ACTION FailedAction)
Definition: fxpkgpnp.cpp:3775
FxIrp fxIrp(Irp)
unsigned int * PULONG
Definition: retypes.h:1
UCHAR majorFunction
_Must_inspect_result_ NTSTATUS ConfigureForwarding(__inout FxIoQueue *TargetQueue, __in WDF_REQUEST_TYPE RequestType)
Definition: fxpkgio.cpp:910
VOID GetPnpState(__out PWDF_DEVICE_STATE State)
Definition: fxpkgpnp.cpp:5549
__inline WDF_DEVICE_POWER_POLICY_STATE GetDevicePowerPolicyState()
Definition: fxdevice.hpp:1165
#define IRP_MJ_READ
Definition: rdpdr.c:46
__inline CfxDevice * GetDevice(VOID)
Definition: fxioqueue.hpp:773
enum _WDF_DEVICE_POWER_POLICY_STATE WDF_DEVICE_POWER_POLICY_STATE
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
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
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
_In_ WDFDEVICE _In_ WDF_DEVICE_FAILED_ACTION FailedAction
Definition: wdfdevice.h:3972
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in ULONG __out PULONG ResultLength
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in ULONG BufferLength
__in WDFDEVICE __out PWDF_DEVICE_STATE DeviceState
VOID SetAlignmentRequirement(_In_ ULONG Value)
FxPointerNotNull(pFxDriverGlobals, Settings)
NTSTATUS PowerPolicySetSxWakeSettings(__in PWDF_DEVICE_POWER_POLICY_WAKE_SETTINGS Settings, __in BOOLEAN ArmForWakeIfChildrenAreArmedForWake, __in BOOLEAN IndicateChildWakeOnParentWake)
Definition: fxpkgpnp.cpp:3245
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
_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
__inline FxIoQueue * GetDefaultQueue(VOID)
Definition: fxpkgio.hpp:243
enum _WDF_DEVICE_POWER_STATE WDF_DEVICE_POWER_STATE
Definition: fbtusb.h:86
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
Definition: File.h:15
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
ULONG GetFlags(VOID)
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
void exit(int exitcode)
Definition: _exit.c:33
_Must_inspect_result_ NTSTATUS FX_VF_FUNCTION() VerifyWdfDeviceWdmDispatchIrpToIoQueue(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ FxDevice *device, _In_ MdIrp Irp, _In_ FxIoQueue *queue, _In_ ULONG Flags)
#define FX_DISPATCH_IRP_TO_IO_QUEUE_FLAGS_MASK
Definition: fxdevice.hpp:93
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN __in_opt PVOID Tag
#define __in
Definition: dbghelp.h:35
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
signed int * PLONG
Definition: retypes.h:5
PFX_DRIVER_GLOBALS pFxDriverGlobals
WDFKEY keyHandle
#define APC_LEVEL
Definition: env_spec_w32.h:695
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT DriverContext
Definition: wdfdevice.h:1697
ULONG ACCESS_MASK
Definition: nt_native.h:40
_Must_inspect_result_ __in WDFDEVICE __in ULONG __in ACCESS_MASK DesiredAccess
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: arc.h:81
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3736
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
FxRequest * pRequest
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97
_Must_inspect_result_ NTSTATUS ConfigureDynamicDispatching(__in UCHAR MajorFunction, __in_opt FxCxDeviceInfo *CxDeviceInfo, __in PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch, __in_opt WDFCONTEXT DriverContext)
Definition: fxpkgio.cpp:786