ReactOS 0.4.15-dev-7934-g1dc8d80
fxdevice.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDevice.cpp
8
9Abstract:
10
11 This is the class implementation for the base Device class.
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23--*/
24
25#include "coreprivshared.hpp"
26
27extern "C" {
28// #include "FxDevice.tmh"
29}
30
31//
32// This table contains the mapping between device type and the
33// default priority boost used by the the framework when
34// an I/O request is completed. The DeviceObject->DeviceType
35// is used as an index into this table.
36//
38 IO_NO_INCREMENT, // FILE_DEVICE_UNDEFINED 0x00000000
39 IO_NO_INCREMENT, // FILE_DEVICE_BEEP 0x00000001
40 IO_CD_ROM_INCREMENT, // FILE_DEVICE_CD_ROM 0x00000002
41 IO_CD_ROM_INCREMENT, // FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
42 IO_NO_INCREMENT, // FILE_DEVICE_CONTROLLER 0x00000004
43 IO_NO_INCREMENT, // FILE_DEVICE_DATALINK 0x00000005
44 IO_NO_INCREMENT, // FILE_DEVICE_DFS 0x00000006
45 IO_DISK_INCREMENT, // FILE_DEVICE_DISK 0x00000007
46 IO_DISK_INCREMENT, // FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
47 IO_NO_INCREMENT, // FILE_DEVICE_FILE_SYSTEM 0x00000009
48 IO_NO_INCREMENT, // FILE_DEVICE_INPORT_PORT 0x0000000a
49 IO_KEYBOARD_INCREMENT, // FILE_DEVICE_KEYBOARD 0x0000000b
50 IO_MAILSLOT_INCREMENT, // FILE_DEVICE_MAILSLOT 0x0000000c
51 IO_SOUND_INCREMENT, // FILE_DEVICE_MIDI_IN 0x0000000d
52 IO_SOUND_INCREMENT, // FILE_DEVICE_MIDI_OUT 0x0000000e
53 IO_MOUSE_INCREMENT, // FILE_DEVICE_MOUSE 0x0000000f
54 IO_NO_INCREMENT, // FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
55 IO_NAMED_PIPE_INCREMENT,// FILE_DEVICE_NAMED_PIPE 0x00000011
56 IO_NETWORK_INCREMENT, // FILE_DEVICE_NETWORK 0x00000012
57 IO_NETWORK_INCREMENT, // FILE_DEVICE_NETWORK_BROWSER 0x00000013
58 IO_NETWORK_INCREMENT, // FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
59 IO_NO_INCREMENT, // FILE_DEVICE_NULL 0x00000015
60 IO_PARALLEL_INCREMENT, // FILE_DEVICE_PARALLEL_PORT 0x00000016
61 IO_NETWORK_INCREMENT, // FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
62 IO_NO_INCREMENT, // FILE_DEVICE_PRINTER 0x00000018
63 IO_NO_INCREMENT, // FILE_DEVICE_SCANNER 0x00000019
64 IO_SERIAL_INCREMENT, // FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
65 IO_SERIAL_INCREMENT, // FILE_DEVICE_SERIAL_PORT 0x0000001b
66 IO_VIDEO_INCREMENT, // FILE_DEVICE_SCREEN 0x0000001c
67 IO_SOUND_INCREMENT, // FILE_DEVICE_SOUND 0x0000001d
68 IO_SOUND_INCREMENT, // FILE_DEVICE_STREAMS 0x0000001e
69 IO_NO_INCREMENT, // FILE_DEVICE_TAPE 0x0000001f
70 IO_NO_INCREMENT, // FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
71 IO_NO_INCREMENT, // FILE_DEVICE_TRANSPORT 0x00000021
72 IO_NO_INCREMENT, // FILE_DEVICE_UNKNOWN 0x00000022
73 IO_VIDEO_INCREMENT, // FILE_DEVICE_VIDEO 0x00000023
74 IO_DISK_INCREMENT, // FILE_DEVICE_VIRTUAL_DISK 0x00000024
75 IO_SOUND_INCREMENT, // FILE_DEVICE_WAVE_IN 0x00000025
76 IO_SOUND_INCREMENT, // FILE_DEVICE_WAVE_OUT 0x00000026
77 IO_KEYBOARD_INCREMENT, // FILE_DEVICE_8042_PORT 0x00000027
78 IO_NETWORK_INCREMENT, // FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
79 IO_NO_INCREMENT, // FILE_DEVICE_BATTERY 0x00000029
80 IO_NO_INCREMENT, // FILE_DEVICE_BUS_EXTENDER 0x0000002a
81 IO_SERIAL_INCREMENT, // FILE_DEVICE_MODEM 0x0000002b
82 IO_NO_INCREMENT, // FILE_DEVICE_VDM 0x0000002c
83 IO_DISK_INCREMENT, // FILE_DEVICE_MASS_STORAGE 0x0000002d
84 IO_NETWORK_INCREMENT, // FILE_DEVICE_SMB 0x0000002e
85 IO_SOUND_INCREMENT, // FILE_DEVICE_KS 0x0000002f
86 IO_NO_INCREMENT, // FILE_DEVICE_CHANGER 0x00000030
87 IO_NO_INCREMENT, // FILE_DEVICE_SMARTCARD 0x00000031
88 IO_NO_INCREMENT, // FILE_DEVICE_ACPI 0x00000032
89 IO_NO_INCREMENT, // FILE_DEVICE_DVD 0x00000033
90 IO_VIDEO_INCREMENT, // FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
91 IO_NO_INCREMENT, // FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
92 IO_NO_INCREMENT, // FILE_DEVICE_DFS_VOLUME 0x00000036
93 IO_SERIAL_INCREMENT, // FILE_DEVICE_SERENUM 0x00000037
94 IO_NO_INCREMENT, // FILE_DEVICE_TERMSRV 0x00000038
95 IO_NO_INCREMENT, // FILE_DEVICE_KSEC 0x00000039
96 IO_NO_INCREMENT, // FILE_DEVICE_FIPS 0x0000003A
97 IO_NO_INCREMENT, // FILE_DEVICE_INFINIBAND 0x0000003B
98};
99
103 __in MdIrp Irp,
105 )
106/*++
107
108Routine Description:
109
110 A completion routine for the IRPs for which we acquired opt-in remove lock.
111
112Arguments:
113 DeviceObject - Pointer to deviceobject
114 Irp - Pointer to the Irp for which we acquired opt-in remove lock.
115 Context - NULL
116Return Value:
117
118 NT Status is returned.
119
120--*/
121
122{
123 FxIrp irp(Irp);
124
126
127 //
128 // Let the irp continue on its way.
129 //
131
132#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
134 DeviceObject))->IoRemoveLock), Irp);
135#else
137#endif
138
140}
141
142
144 __in FxDriver *ArgDriver
145 ) :
146 FxDeviceBase(ArgDriver->GetDriverGlobals(), ArgDriver, FX_TYPE_DEVICE, sizeof(FxDevice)),
147 m_ParentDevice(NULL)
148{
150}
151
152VOID
154 VOID
155 )
156{
157 //
158 // Set the initial device state
159 //
163
164 //
165 // Set the default IO type to "buffered"
166 //
168
172
173 m_Filter = FALSE;
177 m_Legacy = FALSE;
180 m_Legacy = FALSE;
184
185 //
186 // Clear all packages by default
187 //
188
189 m_PkgIo = NULL;
190 m_PkgPnp = NULL;
192 m_PkgWmi = NULL;
194
197
198#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
200#else // UMDF
201 //
202 // In UMDF file object is always required. So indicate that now.
203 //
205#endif
206
208
210
214
215#if (FX_CORE_MODE == FX_CORE_USER_MODE)
216 //
217 // Init UMDF specific members
218 //
226
227 m_RetrievalMode = UMINT::WdfDeviceIoBufferRetrievalDeferred;
230
236#endif
237}
238
240{
242
243 // Make it always present right now even on free builds
244 if (IsDisposed() == FALSE) {
247 "FxDevice 0x%p not disposed: this maybe a driver reference count "
248 "problem with WDFDEVICE %p", this, GetObjectHandleUnchecked());
249
253 (ULONG_PTR) this);
254 }
255
256 //
257 // Execute mode-specific destructor. Noop for KMDF, but does
258 // does detach and delete of UM device object for UMDF. Therefore
259 // can be done before other cleanup.
260 //
262
263 //
264 // If the device has been initialized but hasn't yet been
265 // destroyed, destroy it now.
266 //
267
268
269
270
271
272
273
275
277
278#if FX_CORE_MODE == FX_CORE_KERNEL_MODE
279 //
280 // Assert only applicable to KM because FxDevice can get destroyed in UMDF
281 // without going through normal pnp remove path, for example, when an
282 // AddDevice failure is done in reflector, after all um drivers have
283 // succeeded AddDevice. KMDF and host use fake remove irp to handle
284 // AddDevice failure in KMDF and host respectively, but reflector does not
285 // do that for AddDevice failure that happens in reflector.
286 // Note that symbolicName buffer will anyway be deleted in this destructor
287 // later on so the symbolic link buffer doesn't leak out.
288 //
290#endif
291
293
294 if (m_PkgIo != NULL) {
295 m_PkgIo->RELEASE(NULL);
296 m_PkgIo = NULL;
297 }
298
299 if (m_PkgPnp != NULL) {
300 m_PkgPnp->RELEASE(NULL);
301 m_PkgPnp = NULL;
302 }
303
304 if (m_PkgGeneral != NULL) {
305 m_PkgGeneral->RELEASE(NULL);
307 }
308
309 if (m_PkgWmi != NULL) {
310 m_PkgWmi->RELEASE(NULL);
311 m_PkgWmi = NULL;
312 }
313
314 if (m_PkgDefault != NULL) {
315 m_PkgDefault->RELEASE(NULL);
317 }
318
324 delete info;
325 }
326
332 delete info;
333 }
334
335 //
336 // Clean up any referenced objects
337 //
338 if (m_DeviceName.Buffer != NULL) {
341 }
342
344
348 }
349
350 //
351 // m_RequestLookasideListElementSize will be set to non zero if we have
352 // initialized the request lookaside list.
353 //
357 }
358
359 if (m_ParentDevice != NULL) {
360 m_ParentDevice->RELEASE(this);
361 }
362}
363
367 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
371 )
372{
377 PLIST_ENTRY pNext;
378 PWDFCXDEVICE_INIT pCxInit;
379 FxWdmDeviceExtension* wdmDeviceExtension;
380
381 *Device = NULL;
382 pInit = *DeviceInit;
383
384 pDevice = new (FxDriverGlobals, DeviceAttributes)
386
387 if (pDevice == NULL) {
389 goto Done;
390 }
391
393 if (!NT_SUCCESS(status)) {
394 goto Done;
395 }
396
397 switch (pInit->InitType) {
400 break;
401
404 break;
405
408 break;
409
410 default:
411 //
412 // Should not drop here
413 //
414 ASSERT(FALSE);
415 break;
416 }
417 if (!NT_SUCCESS(status)) {
418 goto Done;
419 }
420
421 //
422 // Ok, we have created the device. Now lets create a handle for it.
423 //
425 if (!NT_SUCCESS(status)) {
426 goto Done;
427 }
428
429 //
430 // Can't use the PDO's FxDevice m_Parent as the object hierarchy parent
431 // because the Fx object hierarchy lifetime rules do not match the
432 // rules for a pnp PDO lifetime vs its FDO.
433 //
435 &object,
436 pDevice->GetDriver());
437 if (!NT_SUCCESS(status)) {
438 goto Done;
439 }
440
441 //
442 // NOTE: ---> DO NOT FAIL FROM HERE FORWARD <---
443 //
444
445 //
446 // Up until now we have not reassigned any of the allocations in pInit
447 // and assigned them to the underlying objects. We are now at the point
448 // of "no return", ie we cannot fail. If we reassigned the allocations
449 // before this point and the driver retried to create the device (let's
450 // say with a different name), we would have freed those allocations
451 // and the driver writer would have thought that particular settings
452 // we valid, but were not b/c we freed them on error. So, to avoid a
453 // huge tracking mess, we only grab the allocations once we know for
454 // *sure* we are going to return success.
455 //
456 if (pInit->DeviceName != NULL) {
458 }
459
460 //
461 // Check for driver preprocess requirements.
462 //
463 if (pInit->PreprocessInfo != NULL) {
469
470 //
471 // If the driver is preprocessing requests on this device, they need
472 // their own stack location so that they can set their own completion
473 // routine.
474 //
476 }
477
478#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
479 wdmDeviceExtension = _GetFxWdmExtension(pDevice->GetDeviceObject());
480 if (wdmDeviceExtension->RemoveLockOptionFlags &
482 //
483 // We will use a completion routine for remlock maintenance
484 //
486 }
487
488 //
489 // Note: In case of UMDF StackSize is incremented prior to attaching
490 // the device to stack. See the comment in FxDeviceUm.cpp
491 //
494 }
495
496#else
497 UNREFERENCED_PARAMETER(wdmDeviceExtension);
498#endif
499
500 //
501 // Check for any class-extensions' preprocess requirements.
502 //
503 for (pNext = pInit->CxDeviceInitListHead.Flink;
504 pNext != &pInit->CxDeviceInitListHead;
505 pNext = pNext->Flink) {
506
507 pCxInit = CONTAINING_RECORD(pNext, WDFCXDEVICE_INIT, ListEntry);
508
509 if (pCxInit->PreprocessInfo != NULL) {
512 &pCxInit->PreprocessInfo->ListEntry);
513 pCxInit->PreprocessInfo = NULL;
514
515 //
516 // If the class extension is preprocessing requests on this
517 // device, it needs its own stack location so that it can
518 // set its own completion routine.
519 //
521 }
522 }
523
524 if (pDevice->IsPnp()) {
525 //
526 // Take all of the allocations out of pInit related to pnp. This
527 // will also transition the pnp state machine into the added state.
528 //
530 }
531
533
534 //
535 // Clear out the pointer, we freed it on behalf of the caller
536 //
537 *DeviceInit = NULL;
538
539 if (pInit->CreatedOnStack == FALSE) {
540 delete pInit;
541 }
542
543Done:
544 if (!NT_SUCCESS(status) && pDevice != NULL) {
545 //
546 // We want to propagate the original error code
547 //
549 pDevice = NULL;
550 }
551
552 *Device = pDevice;
553
554 return status;
555}
556
560 __in NTSTATUS FailedStatus,
561 __in BOOLEAN UseStateMachine
562 )
563{
564 //
565 // Cleanup the device, the driver may have allocated resources
566 // associated with the WDFDEVICE
567 //
570 "WDFDEVICE %p !devobj %p created, but EvtDriverDeviceAdd returned "
571 "status %!STATUS! or failure in creation",
572 GetObjectHandleUnchecked(), GetDeviceObject(), FailedStatus);
573
574 //
575 // We do not let filters affect the building of the rest of the stack.
576 // If they return error, we convert it to STATUS_SUCCESS, remove the
577 // attached device from the stack, and cleanup.
578 //
579 if (IsFilter()) {
582 "WDFDEVICE %p, !devobj %p is a filter, converting %!STATUS! to"
583 " STATUS_SUCCESS", GetObjectHandleUnchecked(), GetDeviceObject(),
584 FailedStatus);
585 FailedStatus = STATUS_SUCCESS;
586 }
587
588 if (UseStateMachine) {
589 MxEvent waitEvent;
590
591 //
592 // See comments for m_CleanupFromFailedCreate in class definition file
593 // for use of this statement.
594 //
596
597
598
599
600
603 }
604 else {
605 //
606 // Upon certain types of failure, like STATUS_OBJECT_NAME_COLLISION, we
607 // could keep the pDevice around and the caller retry after changing
608 // a property, but the simpler route for now is to just recreate
609 // everything from scratch on the retry.
610 //
611 // Usually the pnp state machine will do this and the FxDevice destructor
612 // relies on it running b/c it does some cleanup.
613 //
614 EarlyDispose();
616
617 //
618 // Wait for all children to drain out and cleanup.
619 //
620 if (m_DisposeList != NULL) {
622 }
623
624 //
625 // We keep a reference on m_PkgPnp which is released in the destructor
626 // so we can safely touch m_PkgPnp after destroying all of the child
627 // objects.
628 //
629 if (m_PkgPnp != NULL) {
631 }
632 }
633
634 //
635 // This will detach and delete the device object
636 //
637 Destroy();
638
639 return FailedStatus;
640}
641
645 __in NTSTATUS FailedStatus,
646 __in BOOLEAN UseStateMachine
647 )
648{
650
651 status = DeleteDeviceFromFailedCreateNoDelete(FailedStatus, UseStateMachine);
652
653 //
654 // Delete the Fx object now
655 //
656 DeleteObject();
657
658 return status;
659}
660
666 )
667/*++
668
669Routine Description:
670 Generic initialization for an FxDevice regardless of role (pdo, fdo, control).
671
672Arguments:
673
674
675Return Value:
676
677
678 --*/
679
680{
684 size_t reqCtxSize;
685 PWDFCXDEVICE_INIT cxInit;
686 CCHAR cxIndex;
687 FxCxDeviceInfo* cxDeviceInfo;
688
690 m_Exclusive = DeviceInit->Exclusive;
691 cxIndex = 0;
692
694
695 //
696 // Configure device constraints.
697 //
699 if (!NT_SUCCESS(status)) {
700 return status;
701 }
702
703 //
704 // Generic catch all
705 //
707 if (m_PkgDefault == NULL) {
709 }
710
712
713 if (DeviceInit->InitType == FxDeviceInitTypeControlDevice) {
714 m_Legacy = TRUE;
715 }
716
717 //
718 // Size will be set to a non zero if the driver wants request attributes
719 // associated with each created request.
720 //
721 if (DeviceInit->RequestAttributes.Size != 0) {
722 ASSERT(DeviceInit->RequestAttributes.Size == sizeof(WDF_OBJECT_ATTRIBUTES));
724 &DeviceInit->RequestAttributes,
725 sizeof(DeviceInit->RequestAttributes));
726 }
727
729
730 //
731 // If present, setup a I/O class extensions info chain.
732 //
733 for (next = DeviceInit->CxDeviceInitListHead.Flink;
734 next != &DeviceInit->CxDeviceInitListHead;
735 next = next->Flink) {
736
737 cxInit = CONTAINING_RECORD(next, WDFCXDEVICE_INIT, ListEntry);
738
739 cxDeviceInfo = new(pGlobals) FxCxDeviceInfo(pGlobals);
740 if (NULL == cxDeviceInfo) {
742 }
743
744 cxDeviceInfo->Index = ++cxIndex; // 1-based.
745 cxDeviceInfo->Driver = cxInit->CxDriverGlobals->Driver;
746 cxDeviceInfo->IoInCallerContextCallback.m_Method =
748 cxDeviceInfo->RequestAttributes = cxInit->RequestAttributes;
749
751
752 //
753 // Set weak ref to this run-time cx struct to help file-object logic later on.
754 //
755 cxInit->CxDeviceInfo = cxDeviceInfo;
756
757 //
758 // Find the max size for the request context. Used below.
759 //
760 ASSERT(cxInit->RequestAttributes.Size == 0 ||
761 cxInit->RequestAttributes.Size == sizeof(WDF_OBJECT_ATTRIBUTES));
762
763 reqCtxSize = MAX(FxGetContextSize(&cxInit->RequestAttributes),
764 reqCtxSize);
765 }
766
767 //
768 // Memory layout for memory backing FxRequest which is allocated from the
769 // lookaside list:
770 //
771 // If we are tracking memory, the allocation layout is
772 // 0x0 - FX_POOL_TRACKER
773 // 0x0 + sizeof(FX_POOL_TRACKER) - FX_POOL_HEADER
774 // 0x0 + sizeof(FX_POOL_TRACKER) + FX_POOL_HEADER_SIZE - start of FxRequest
775 //
776 // if no tracking is occuring, the allocation layout is
777 // 0x0 - FX_POOL_HEADER
778 // 0x0 + FX_POOL_HEADER_SIZE - start of FxRequest
779 //
780 // NOTE: If the computation of m_RequestLookasideListElementSize changes,
781 // FxDevice::AllocateRequestMemory and FxDevice::FreeRequestMemory will also
782 // need to be updated to reflect the changes made.
783 //
785 sizeof(FxRequest),
786 0,
787 reqCtxSize,
789 if (!NT_SUCCESS(status)) {
790 return status;
791 }
792
796
797 if (!NT_SUCCESS(status)) {
798 //
799 // FxPoolAddHeaderSize will log to the IFR on error
800 //
801 return status;
802 }
803
805 NULL,
806 NULL,
807 0,
809 pGlobals->Tag,
810 0);
811 //
812 // Init device's auto_forward_cleanup_close.
813 //
815
816 //
817 // Create, close, cleanup, shutdown
818 //
820 if (m_PkgGeneral == NULL) {
822 }
823
825
826#if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
827
828
829
830
831
832
833 // m_PkgWmi = new(pGlobals) FxWmiIrpHandler(pGlobals, this); __REACTOS__
834 // if (m_PkgWmi == NULL) {
835 // return STATUS_INSUFFICIENT_RESOURCES;
836 // }
837 // InstallPackage(m_PkgWmi);
838#endif
839
840 //
841 // IO package handles reads, writes, internal and external IOCTLs
842 //
843 m_PkgIo = new(pGlobals) FxPkgIo(pGlobals, (CfxDevice*) this);
844
845 if (m_PkgIo == NULL) {
847 }
848
850
851 //
852 // Configure I/O package.
853 //
854 m_PkgIo->SetIoInCallerContextCallback(DeviceInit->IoInCallerContextCallback);
855
856 if (DeviceInit->RequiresSelfIoTarget) {
858 }
859
860 return STATUS_SUCCESS;
861}
862
863VOID
866 )
867{
868 WDF_TRI_STATE autoForwardCleanupClose;
870 BOOLEAN checkClientDriver;
871
872 autoForwardCleanupClose = WdfUseDefault;
873 checkClientDriver = TRUE;
874
875 //
876 // Device-wide configuration for auto forwarding cleanup and close requests:
877 // . Use WdfFalse if one of the devices in the chain use this setting with a create
878 // callback (this means it will complete all create IRPs).
879 // . Else use lowest driver's setting in the chain (order of cx chain: lower to higher).
880 // . If no settings are present, use default.
881 //
882 for (next = DeviceInit->CxDeviceInitListHead.Blink;
883 next != &DeviceInit->CxDeviceInitListHead;
884 next = next->Blink) {
885
886 PWDFCXDEVICE_INIT cxInit;
887
888 cxInit = CONTAINING_RECORD(next, WDFCXDEVICE_INIT, ListEntry);
889
890 if (cxInit->FileObject.Set) {
891 autoForwardCleanupClose = cxInit->FileObject.AutoForwardCleanupClose;
892
893 if (autoForwardCleanupClose == WdfFalse &&
895
896 checkClientDriver = FALSE;
897 break;
898 }
899 }
900 }
901
902 if (checkClientDriver && DeviceInit->FileObject.Set) {
903 autoForwardCleanupClose = DeviceInit->FileObject.AutoForwardCleanupClose;
904 }
905
906 switch (autoForwardCleanupClose) {
907 case WdfTrue:
908
910 //
911 // If the device is legacy then set it to false because you can't forward
912 // requests.
913 //
914 if(m_Legacy) {
916 }
917 break;
918
919 case WdfFalse:
921 break;
922
923 case WdfUseDefault:
924 //
925 // For filters (which must be FDOs), we default to TRUE. All other
926 // device roles (FDO, PDO, control) default to FALSE. We cannot check
927 // m_Filter yet because it is set in FdoInitialize which occurs later.
928 //
929 if (DeviceInit->IsFdoInit() && DeviceInit->Fdo.Filter) {
931 }
932 else {
934 }
935 }
936}
937
941 VOID
942 )
943{
945
949
950 return status;
951}
952
953
954
955
956
957
958
959
960#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
961
966 )
967{
968 MdDeviceObject pNewDeviceObject;
969 ULONG characteristics;
971 DEVICE_TYPE devType;
972
974 if (!NT_SUCCESS(status)) {
975 return status;
976 }
977
978 devType = DeviceInit->DeviceType;
979 if (devType < ARRAY_SIZE(m_PriorityBoosts)) {
981 }
982
983 characteristics = DeviceInit->Characteristics;
984
985 //
986 // You can only create secure device objects which have a name. All other
987 // device objects rely on the PDO's security
988 //
989 if (DeviceInit->ShouldCreateSecure()) {
990 PUNICODE_STRING pName, pSddl;
991 LPGUID pGuid;
992
993 if (DeviceInit->DeviceName != NULL) {
994 pName = DeviceInit->DeviceName->GetUnicodeString();
995 }
996 else {
997 pName = NULL;
998 }
999
1000 if (DeviceInit->Security.DeviceClassSet) {
1001 pGuid = &DeviceInit->Security.DeviceClass;
1002 }
1003 else {
1004 pGuid = NULL;
1005 }
1006
1007 if (DeviceInit->Security.Sddl != NULL) {
1008 pSddl = DeviceInit->Security.Sddl->GetUnicodeString();
1009 }
1010 else {
1011 //
1012 // Always provide an SDDL if one is not supplied.
1013 //
1014 // SDDL_DEVOBJ_SYS_ALL_ADM_ALL = "D:P(A;;GA;;;SY)(A;;GA;;;BA)"
1015 //
1016 // SDDL_DEVOBJ_SYS_ALL_ADM_ALL allows the kernel, system, and
1017 // administrator complete control over the device. No other users
1018 // may access the device.
1019 //
1020 // pSddl = (PUNICODE_STRING) &SDDL_DEVOBJ_SYS_ALL_ADM_ALL;
1021 pSddl = NULL; // __REACTOS__ : wdmsec.lib is not supported
1022 }
1023
1026 sizeof(FxWdmDeviceExtension),
1027 pName,
1028 devType,
1029 characteristics,
1031 pSddl,
1032 pGuid,
1033 &pNewDeviceObject);
1034 }
1035 else {
1038 sizeof(FxWdmDeviceExtension),
1039 NULL,
1040 devType,
1041 characteristics,
1043 &pNewDeviceObject);
1044 }
1045
1046 if (NT_SUCCESS(status)) {
1047 FxWdmDeviceExtension* pWdmExt;
1048
1049 pWdmExt = _GetFxWdmExtension(pNewDeviceObject);
1050
1051 //
1052 // We reassign DeviceExtension below and then use the knowledge that
1053 // we can always retrieve DeviceExtension by adding sizeof(DEVICE_OBJECT)
1054 // to pNewDeviceObject. ASSERT that this assumption is correct.
1055 //
1056 MxDeviceObject newDeviceObject(pNewDeviceObject);
1057 ASSERT(pWdmExt == newDeviceObject.GetDeviceExtension());
1058
1061 0, // max min
1062 0 // highwater mark
1063 );
1064
1065 //
1066 // Option for remove lock is stored in device extension
1067 // since this option may be examined after FxDevice is destroyed
1068 // (if an Irp is sent after removal of device).
1069 // We combine the flags from DeviceInit with what's set through registry
1070 //
1071 pWdmExt->RemoveLockOptionFlags = DeviceInit->RemoveLockOptionFlags |
1073
1074 //
1075 // We assign the first context assigned to this object as the
1076 // DeviceExtension for compatibility reasons. This allows existing
1077 // WDM extensions to work as well as any stack which exports a known
1078 // structure for the extension (ie the FDO knows the extension of its
1079 // PDO and casts it and accesses it directly).
1080 //
1081 newDeviceObject.SetDeviceExtension(&GetContextHeader()->Context[0]);
1082 m_DeviceObject.SetObject(pNewDeviceObject);
1083
1084 //
1085 // Set some device object flags based on properties of DeviceInit.
1086 //
1087 // If we are a filter, we will set these flags later
1088 // (in FxDevice::FdoInitialize) based on the device we are attached to.
1089 //
1090 if (m_Filter == FALSE) {
1091 if (DeviceInit->ReadWriteIoType == WdfDeviceIoBuffered) {
1093 }
1094 else if (DeviceInit->ReadWriteIoType == WdfDeviceIoDirect) {
1096 }
1097
1098 m_ReadWriteIoType = DeviceInit->ReadWriteIoType;
1099 m_PowerPageableCapable = DeviceInit->PowerPageable;
1100 }
1101 }
1102
1103 return status;
1104}
1105
1106#endif // (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
1107
1108VOID
1110 VOID
1111 )
1112
1113/*++
1114
1115Routine Description:
1116
1117 This routine is called when the device is completely initialized.
1118
1119Arguments:
1120
1121 none.
1122
1123Returns:
1124
1125 none.
1126
1127--*/
1128
1129{
1130
1132}
1133
1134VOID
1136 VOID
1137 )
1138/*++
1139
1140Routine Description:
1141 Virtual override of an FxObject::DeleteObject. For PDOs which are created
1142 statically and then deleted before being reported to WDF, we must simulate
1143 a pnp remove event to trigger cleanup.
1144
1145Arguments:
1146 None
1147
1148Return Value:
1149 None
1150
1151 --*/
1152{
1153 if (IsPnp() && IsPdo()) {
1155 KIRQL irql;
1157
1158 remove = FALSE;
1159
1160 pPkgPdo = GetPdoPkg();
1161
1162 pPkgPdo->Lock(&irql);
1163
1165 //
1166 // Since no pnp action has been taken since the child was created, we
1167 // should be in the initial state.
1168 //
1170 //
1171 // A PDO in this state should be deletable
1172 //
1174
1175 remove = TRUE;
1176 }
1177 else {
1178 //
1179 // If we are not in the init state, we should be in the created
1180 // state. This means we are failing from FxDevice::CreateDevice.
1181 //
1183 }
1184 }
1185
1187
1188 if (remove) {
1189 //
1190 // Cleanup the device and then let the super class delete the object.
1191 //
1194 }
1195 }
1196 else if (IsLegacy() && m_PkgGeneral != NULL && m_DeviceObject.GetObject() != NULL) {
1197 //
1198 // We allow tracing devices to go through a normal DeleteObject() path
1199 // where we do not prematurely delete the device object.
1200 //
1202
1204
1205 //
1206 // This reference will be released in Destroy().
1207 //
1209
1210 if (m_PkgWmi != NULL) {
1211 //
1212 // Since a legacy NT4 driver does not have an explicit WMI
1213 // deregistration DDI, we do it for them on deletion.
1214 //
1215 // This is done in DeleteObject because we need to deregister before
1216 // we delete the device object, otherwise we can bugcheck when
1217 // running under driver verifier.
1218 //
1219 // m_PkgWmi->Deregister(); __REACTOS__
1220 }
1221
1222 //
1223 // By deleting the device object now, we prevent any new creates from
1224 // being sent to the device (the io manager enforces this).
1225 //
1227
1229 //
1230 // Delay the actual destruction of the device until the last open
1231 // handle has been closed. ControlDeviceDelete() will perform the
1232 // destruction later.
1233 //
1234 return;
1235 }
1236 }
1237
1238 FxDeviceBase::DeleteObject(); // __super call
1239}
1240
1241BOOLEAN
1243 VOID
1244 )
1245{
1247
1248 if (m_Legacy) {
1249 if (m_PkgWmi != NULL) {
1250 //
1251 // We deregister in Dispose() (as well as DeleteObject()) for
1252 // control devices which are implicitly destroyed when the driver
1253 // unloads and FxDriver is being deleted.
1254 //
1255 // Since a legacy NT4 driver does not have an explicit WMI
1256 // deregistration DDI, we do it for them on destruction.
1257 //
1258 // This is done in Dispose because we are guaranteed to be at
1259 // passive level here. Even though m_PkgWmi was already
1260 // Dispose()'ed (because it is a child of this object), it is still
1261 // valid to reference the pointer because there is an explicit
1262 // reference on the object that was taken when we created this object.
1263 //
1264 // m_PkgWmi->Deregister(); __REACTOS__
1265 }
1266
1267 //
1268 // Important that the cleanup routine be called while the PDEVICE_OBJECT
1269 // is valid!
1270 //
1271 CallCleanup();
1272
1273 //
1274 // Manually destroy the children now so that by the time we wait on the
1275 // dispose empty out, all of the children will have been added to it.
1276 //
1278
1279 if (m_DisposeList != NULL) {
1281 }
1282
1283 //
1284 // Now delete the device object
1285 //
1286 Destroy();
1287
1288 return FALSE;
1289 }
1290
1291 return FxDeviceBase::Dispose(); // __super call
1292}
1293
1298 __in MdIrp Irp
1299 )
1300{
1302 FxIrp irp(Irp);
1303
1304 FxWdmDeviceExtension * wdmDeviceExtension =
1306
1307 if (wdmDeviceExtension->RemoveLockOptionFlags &
1309
1310 status = Mx::MxAcquireRemoveLock(&(wdmDeviceExtension->IoRemoveLock), Irp);
1311
1312 if (!NT_SUCCESS(status)) {
1313 return status;
1314 }
1315
1317
1322 TRUE,
1323 TRUE,
1324 TRUE
1325 );
1326
1328 }
1329
1330 return STATUS_SUCCESS;
1331}
1332
1335STDCALL
1338 __in MdIrp Irp
1339 )
1340{
1342 FxIrp irp(Irp);
1343
1345 irp.GetMinorFunction())) {
1346
1349 &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1350 Irp
1351 );
1352
1353 if (!NT_SUCCESS(status)) {
1356
1357 return status;
1358 }
1359
1360 break;
1361
1365 Irp
1366 );
1367
1368 if (!NT_SUCCESS(status)) {
1371
1372 return status;
1373 }
1374
1375 break;
1376
1378 //
1379 // Try to Acquire and Release the RemLock. If acquiring the lock
1380 // fails then it is not safe to process the IRP and the IRP should
1381 // be completed immediately.
1382 //
1384 &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1385 Irp
1386 );
1387
1388 if (!NT_SUCCESS(status)) {
1391
1392 return status;
1393 }
1394
1396 &_GetFxWdmExtension(DeviceObject)->IoRemoveLock,
1397 Irp
1398 );
1399 break;
1400 }
1401
1402 return Dispatch(DeviceObject, Irp);
1403}
1404
1406__inline
1407BOOLEAN
1409 __in MdIrp Irp,
1411 )
1412{
1413 UCHAR major, minor;
1414 BOOLEAN preprocess;
1415 FxIrp irp(Irp);
1416
1419
1420 preprocess = FALSE;
1421
1422 if (Info->Dispatch[major].EvtDevicePreprocess != NULL) {
1423 if (Info->Dispatch[major].NumMinorFunctions == 0) {
1424 //
1425 // If the driver is not interested in particular minor codes,
1426 // just give the irp to it.
1427 //
1428 preprocess = TRUE;
1429 }
1430 else {
1431 ULONG i;
1432
1433 //
1434 // Try to match up to a minor code.
1435 //
1436 for (i = 0; i < Info->Dispatch[major].NumMinorFunctions; i++) {
1437 if (Info->Dispatch[major].MinorFunctions[i] == minor) {
1438 preprocess = TRUE;
1439 break;
1440 }
1441 }
1442 }
1443 }
1444
1445 return preprocess;
1446}
1447
1449__inline
1453 __in MdIrp Irp,
1456 )
1457{
1459 UCHAR major, minor;
1460 FxIrp irp(Irp);
1461
1464
1465 //
1466 // If this is a pnp remove irp, this object could be deleted by the time
1467 // EvtDevicePreprocess returns. To not touch freed pool, capture all
1468 // values we will need before preprocessing.
1469 //
1470
1471 if (Info->ClassExtension == FALSE) {
1472 status = Info->Dispatch[major].EvtDevicePreprocess( Device->GetHandle(),
1473 Irp);
1474 }
1475 else {
1476 status = Info->Dispatch[major].EvtCxDevicePreprocess(
1477 Device->GetHandle(),
1478 Irp,
1480 }
1481
1482 //
1483 // If we got this far, we handed the irp off to EvtDevicePreprocess, so we
1484 // must now do our remlock maintainance if necessary.
1485 //
1487 //
1488 // Keep the remove lock active until after we call into the driver.
1489 // If the driver redispatches the irp to the framework, we will
1490 // reacquire the remove lock at that point in time.
1491 //
1492 // Touching pDevObj after sending the pnp remove irp to the framework
1493 // is OK b/c we have acquired the remlock previously and that will
1494 // prevent this irp's processing racing with the pnp remove irp
1495 // processing.
1496 //
1497 Mx::MxReleaseRemoveLock(Device->GetRemoveLock(),
1498 Irp);
1499 }
1500
1501 return status;
1502}
1503
1505__inline
1509 __in MdIrp Irp,
1511 )
1512{
1514 FxIrp irp(Irp);
1515
1517
1520
1521 //
1522 // Check for any driver/class-extensions' preprocess requirements.
1523 //
1524 while (next != &Device->m_PreprocessInfoListHead) {
1526
1528
1529 //
1530 // Advance to next node.
1531 //
1532 next = next->Flink;
1533
1534 if (IsPreprocessIrp(Irp, info)) {
1535 return PreprocessIrp(Device, Irp, info, next);
1536 }
1537 }
1538
1539 //
1540 // No preprocess requirements, directly dispatch the IRP.
1541 //
1542 return Device->GetDispatchPackage(
1544 )->Dispatch(Irp);
1545}
1546
1547
1550STDCALL
1553 __in MdIrp Irp
1554 )
1555{
1557 return DispatchWorker(device,
1558 Irp,
1559 device->m_PreprocessInfoListHead.Flink);
1560}
1561
1565 __in MdIrp Irp,
1567 )
1568{
1570 UCHAR major, minor;
1571 FxIrp irp(Irp);
1572
1573 //
1574 // The contract for this DDI is just like IoCallDriver. The caller sets up
1575 // their stack location and then the DDI advances to the next stack location.
1576 // This means that the caller either has to call IoSkipCurrentIrpStackLocation
1577 // or IoCopyCurrentIrpStackLocationToNext before calling this DDI.
1578 //
1580
1583
1584 //
1585 // FxPkgPnp and FxWmiIrpHandler expect that there will be a remove lock
1586 // acquired for all power irps. We release the remlock when we called
1587 // Evt(Ext)DevicePreprocessIrp.
1588 //
1591 GetRemoveLock(),
1592 Irp
1593 );
1594
1595 if (!NT_SUCCESS(status)) {
1596 goto Done;
1597 }
1598 }
1599
1600 return DispatchWorker(this, Irp, DispatchContext);
1601
1602Done:
1606
1607 return status;
1608}
1609
1610VOID
1612 __inout FxPackage *Package
1613 )
1614
1615{
1616 //
1617 // Add this package as an association on FxDevice
1618 // so its children get Dispose notifications.
1619 //
1620 // Note: This assumes a transfer of the controlling reference
1621 // count which it will dereference on FxDevice teardown.
1622 // We need to add an extra one here since packages have
1623 // an existing reference count model.
1624 //
1625 Package->AddRef();
1626 Package->AssignParentObject(this);
1627}
1628
1629PVOID
1632 )
1633/*++
1634
1635Routine Description:
1636 Allocates enough memory for an FxRequest* plus any additonal memory required
1637 for the device's specific context memory.
1638
1639 If we are tracking memory, the allocation layout is
1640 0x0 - FX_POOL_TRACKER
1641 0x0 + sizeof(FX_POOL_TRACKER) - FX_POOL_HEADER
1642 0x0 + sizeof(FX_POOL_TRACKER) + FX_POOL_HEADER_SIZE - start of FxRequest
1643
1644 if no tracking is occuring, the allocation layout is
1645 0x0 - FX_POOL_HEADER
1646 0x0 + FX_POOL_HEADER_SIZE - start of FxRequest
1647
1648 the total size is precomputed in m_RequestLookasideListElementSize during
1649 FxDevice::Initialize
1650
1651Arguments:
1652 RequestAttributes - Attributes setting for the request.
1653
1654Return Value:
1655 valid ptr or NULL
1656
1657 --*/
1658
1659{
1661 PFX_POOL_TRACKER pTracker;
1663 PVOID ptr, pTrueBase;
1664
1666 ptr = NULL;
1667
1668 if (IsPdo() && GetPdoPkg()->IsForwardRequestToParentEnabled()) {
1670 }
1671 else {
1674 }
1675
1676 if (pTrueBase != NULL) {
1677 if (pGlobals->IsPoolTrackingOn()) {
1678 pTracker = (PFX_POOL_TRACKER) pTrueBase;
1679 pHeader = WDF_PTR_ADD_OFFSET_TYPE(pTrueBase,
1680 sizeof(FX_POOL_TRACKER),
1682
1683 //
1684 // Format and insert the Tracker in the NonPagedHeader list.
1685 //
1687 pTracker,
1689 pGlobals->Tag,
1690 _ReturnAddress());
1691 }
1692 else {
1693 pHeader = (PFX_POOL_HEADER) pTrueBase;
1694 }
1695
1696 //
1697 // Common init
1698 //
1699 pHeader->Base = pTrueBase;
1700 pHeader->FxDriverGlobals = pGlobals;
1701
1702 ptr = &pHeader->AllocationStart[0];
1703
1704 if (RequestAttributes == NULL) {
1706 }
1707
1709 pGlobals,
1710 ptr,
1711 COMPUTE_OBJECT_SIZE(sizeof(FxRequest), 0),
1714 );
1715
1716#if FX_VERBOSE_TRACE
1718 "Allocating FxRequest* %p, WDFREQUEST %p",
1719 ptr, _ToHandle((FxObject*) ptr));
1720#endif
1721 return ptr;
1722 }
1723
1724 return NULL;
1725}
1726
1727VOID
1730 )
1731{
1733
1734#if FX_VERBOSE_TRACE
1736 "Free FxRequest* %p memory", Request);
1737#endif
1738
1739 //
1740 // Remove the request from the list of outstanding requests against this
1741 // driver.
1742 //
1744 if (IsPdo() && GetPdoPkg()->IsForwardRequestToParentEnabled()) {
1746 }
1747 else {
1749 }
1750}
1751
1756 )
1757{
1758 switch (Params->Type) {
1759 case FX_TYPE_DEVICE:
1760 *Params->Object = (FxDevice*) this;
1761 break;
1762
1763 default:
1764 return FxDeviceBase::QueryInterface(Params); // __super call
1765 }
1766
1767 return STATUS_SUCCESS;
1768}
1769
1774 )
1775{
1777
1779 &IoTarget->m_TransactionedEntry);
1780
1781 if (NT_SUCCESS(status)) {
1782 IoTarget->m_AddedToDeviceList = TRUE;
1783 IoTarget->ADDREF(this);
1784 }
1785
1786 return status;
1787}
1788
1789VOID
1792 )
1793{
1795 &IoTarget->m_TransactionedEntry);
1796
1797 //
1798 // Assumes that the caller has its own reference on the IoTarget
1799 //
1800 IoTarget->RELEASE(this);
1801}
1802
1806 VOID
1807 )
1808{
1809 if (IsPnp()) {
1810 return m_PkgPnp->AllocateEnumInfo();
1811 }
1812 else {
1813 return STATUS_SUCCESS;
1814 }
1815}
1816
1819 VOID
1820 )
1821{
1822 if (IsPnp() && IsFdo()) {
1823 return GetFdoPkg()->m_DefaultTarget;
1824 }
1825 else {
1826 return NULL;
1827 }
1828}
1829
1832 VOID
1833 )
1834/*++
1835Routine Description:
1836 Returns the Self IO target for this FxDevice.
1837 Currently Self IO Target is supported only for a Pnp FDO.
1838 If the Self IO Target has not been established, it returns NULL.
1839--*/
1840{
1841 if (IsPnp() && IsFdo()) {
1842 return GetFdoPkg()->m_SelfTarget;
1843 }
1844 else {
1845 return NULL;
1846 }
1847}
1848
1853 )
1854{
1856
1857 ASSERT(IsFdo());
1858
1860
1861 if (NT_SUCCESS(status) && m_PkgPnp != NULL) {
1863 }
1864
1865 if (NT_SUCCESS(status)) {
1866 m_Filter = Value;
1867 }
1868
1869 return status;
1870}
1871
1872VOID
1874 VOID
1875 )
1876{
1877 FxIoTarget * ioTarget;
1878 FxTransactionedEntry * targetsList = NULL;
1879
1880 ASSERT(IsFilter());
1881
1883
1884 //
1885 // m_AttachedDevice can be NULL for UMDF, so check for NULL
1886 //
1887 if (m_AttachedDevice.GetObject() != NULL) {
1890 }
1891
1894 }
1895 else if (m_DeviceObject.GetFlags() & DO_DIRECT_IO) {
1897 }
1898 else {
1900 }
1901
1902 //
1903 // We also need to propagate these settings to any io targets that
1904 // have already been created
1905 //
1906
1908
1909 targetsList = m_IoTargetsList.GetNextEntry(targetsList);
1910
1911 while (targetsList != NULL) {
1912
1913 ioTarget = (FxIoTarget *) targetsList->GetTransactionedObject();
1914
1915 if (ioTarget->GetTargetPDO() == GetPhysicalDevice()) {
1916 ioTarget->UpdateTargetIoType();
1917 }
1918
1919 targetsList = m_IoTargetsList.GetNextEntry(targetsList);
1920 }
1921
1923}
1924
1925BOOLEAN
1929 )
1930{
1932 BOOLEAN found = FALSE;
1933
1935
1936 //
1937 // Iterate over the interfaces and see if we have a match
1938 //
1940 FxDeviceInterface *pDI;
1941
1943
1945 if (RefString != NULL) {
1946 if ((RefString->Length == pDI->m_ReferenceString.Length)
1947 &&
1948 (RtlCompareMemory(RefString->Buffer,
1950 RefString->Length) == RefString->Length)) {
1951 //
1952 // They match, carry on
1953 //
1954 DO_NOTHING();
1955 }
1956 else {
1957 //
1958 // The ref strings do not match, continue on in the search
1959 // of the collection.
1960 //
1961 continue;
1962 }
1963 }
1964 else if (pDI->m_ReferenceString.Length > 0) {
1965 //
1966 // Caller didn't specify a ref string but this interface has
1967 // one, continue on in the search through the collection.
1968 //
1969 continue;
1970 }
1971
1972 //
1973 // Set the state and break out of the loop because we found our
1974 // interface.
1975 //
1976 found = TRUE;
1977 break;
1978 }
1979 }
1980
1982
1983 return found;
1984}
1985
1992 _In_opt_ MdDeviceObject RemotePdo,
1996 _Out_ WDFMEMORY* PropertyMemory
1997 )
1998{
2001 ULONG length = 0;
2002
2004 DeviceInit,
2005 Device,
2006 RemotePdo,
2008 0,
2009 NULL,
2010 &length);
2013 "Could not retrieve property %d length, %!STATUS!",
2016 return status;
2017 }
2018
2021 PoolType,
2022 Globals->Tag,
2023 length,
2024 &pMemory);
2025 if (!NT_SUCCESS(status)) {
2027 "Could not allocate WDFMEMORY, %!STATUS!", status);
2028 return status;
2029 }
2030
2032 DeviceInit,
2033 Device,
2034 RemotePdo,
2036 length,
2037 pMemory->GetBuffer(),
2038 &length);
2039 if (!NT_SUCCESS(status)) {
2041 "Could not query for full buffer, size %d, for "
2042 "property %d, %!STATUS!",
2045 return status;
2046 }
2047
2050
2051 if (!NT_SUCCESS(status)) {
2053 "Could not commit memory object, %!STATUS!",
2054 status);
2056 }
2057
2058 return status;
2059}
2060
2071 _Out_ WDFMEMORY* PropertyMemory,
2073 )
2074{
2077 ULONG length = 0;
2078 DEVPROPTYPE propType;
2079 ULONG requiredLength;
2080
2082 DeviceInit,
2083 Device,
2086 0,
2087 NULL,
2088 &requiredLength,
2089 &propType);
2092 "Could not retrieve property, %!STATUS!",
2093 status);
2095 return status;
2096 }
2097
2099 *PropertyType = 0;
2100
2101 length = requiredLength;
2104 PoolType,
2105 DriverGlobals->Tag,
2106 length,
2107 &pMemory);
2108 if (!NT_SUCCESS(status)) {
2110 "Could not allocate WDFMEMORY, %!STATUS!", status);
2111 return status;
2112 }
2113
2115 DeviceInit,
2116 Device,
2119 length,
2120 pMemory->GetBuffer(),
2121 &requiredLength,
2122 &propType);
2123 if (!NT_SUCCESS(status)) {
2125 "Could not query for full buffer, size %d, for "
2126 "property, %!STATUS!",
2127 length, status);
2129 return status;
2130 }
2131
2134
2135 if (!NT_SUCCESS(status)) {
2137 "Could not commit memory object, %!STATUS!",
2138 status);
2140 }
2141 else {
2143 *PropertyType = propType;
2144 }
2145
2146 return status;
2147}
2148
2152 _In_ PFX_DRIVER_GLOBALS FxDriverGlobals,
2155 )
2156{
2158
2159 //
2160 // This function should be called with exactly one valid WDFDEVICE_INIT
2161 // or one valid FxDevice object. Supplying neither or both is an error.
2162 //
2163 if ((DeviceInit == NULL && Device == NULL) ||
2164 (DeviceInit != NULL && Device != NULL)) {
2165
2168 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
2169 "Device OpenKey/QueryProperty was called with invalid "
2170 "DeviceInit and Device parameters, %!STATUS!", status);
2171 FxVerifierDbgBreakPoint(FxDriverGlobals);
2172 }
2173
2174 return status;
2175}
2176
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define MAX(x, y)
Definition: rdesktop.h:175
#define ARRAY_SIZE(A)
Definition: main.h:33
MxDeviceObject m_AttachedDevice
Definition: fxdevice.hpp:472
NTSTATUS ConfigureConstraints(__in_opt PWDF_OBJECT_ATTRIBUTES ObjectAttributes)
MxDeviceObject m_DeviceObject
Definition: fxdevice.hpp:471
__inline FxDriver * GetDriver(VOID)
Definition: fxdevice.hpp:164
_Must_inspect_result_ NTSTATUS QueryInterface(__inout FxQueryInterfaceParams *Params)
FxDriver * m_Driver
Definition: fxdevice.hpp:469
FxDisposeList * m_DisposeList
Definition: fxdevice.hpp:466
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
static FxDeviceInterface * _FromEntry(__in PSINGLE_LIST_ENTRY Entry)
UNICODE_STRING m_ReferenceString
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
size_t m_RequestLookasideListElementSize
Definition: fxdevice.hpp:653
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
USHORT m_DeviceTelemetryInfoFlags
Definition: fxdevice.hpp:617
WDF_DEVICE_POWER_STATE m_CurrentPowerState
Definition: fxdevice.hpp:508
BOOLEAN m_PdoKnown
Definition: fxdevice.hpp:599
WDF_REGISTER_ACCESS_MODE_TYPE m_RegisterAccessMode
Definition: fxdevice.hpp:783
virtual _Must_inspect_result_ NTSTATUS AddIoTarget(__inout FxIoTarget *IoTarget)
Definition: fxdevice.cpp:1772
FxWmiIrpHandler * m_PkgWmi
Definition: fxdevice.hpp:672
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
~FxDevice(VOID)
Definition: fxdevice.cpp:239
BOOLEAN m_Legacy
Definition: fxdevice.hpp:547
VOID DeleteSymbolicLink(VOID)
VOID DestructorInternal(VOID)
Definition: fxdevicekm.cpp:390
_Must_inspect_result_ NTSTATUS SetFilter(__in BOOLEAN Value)
Definition: fxdevice.cpp:1851
__inline FxPkgFdo * GetFdoPkg(VOID)
Definition: fxdevice.hpp:1236
virtual FxIoTarget * GetDefaultIoTarget(VOID)
Definition: fxdevice.cpp:1818
BOOLEAN m_Exclusive
Definition: fxdevice.hpp:540
__inline CHAR GetStackSize(VOID)
Definition: fxdevice.hpp:1824
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
WDF_DEVICE_IO_TYPE m_IoctlIoType
Definition: fxdevice.hpp:771
WDF_DEVICE_PNP_STATE m_CurrentPnpState
Definition: fxdevice.hpp:507
_Must_inspect_result_ NTSTATUS DispatchPreprocessedIrp(__in MdIrp Irp, __in PVOID DispatchContext)
Definition: fxdevice.cpp:1564
static FxDeviceRemLockAction __inline _RequiresRemLock(__in UCHAR MajorCode, __in UCHAR MinorCode)
Definition: fxdevice.hpp:933
static MdCompletionRoutineType _CompletionRoutineForRemlockMaintenance
Definition: fxdevice.hpp:831
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
VOID ConfigureAutoForwardCleanupClose(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevice.cpp:864
WDF_OBJECT_ATTRIBUTES m_RequestAttributes
Definition: fxdevice.hpp:659
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit, __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes)
Definition: fxdevice.cpp:663
FxInterruptThreadpool * m_InteruptThreadpool
Definition: fxdevice.hpp:798
FxDefaultIrpHandler * m_PkgDefault
Definition: fxdevice.hpp:673
static FxDevice * GetFxDevice(__in MdDeviceObject DeviceObject)
Definition: fxdeviceum.cpp:60
CHAR m_DefaultPriorityBoost
Definition: fxdevice.hpp:561
virtual VOID DeleteObject(VOID)
Definition: fxdevice.cpp:1135
NPAGED_LOOKASIDE_LIST m_RequestLookasideList
Definition: fxdevice.hpp:648
VOID Destroy(VOID)
Definition: fxdevicekm.cpp:329
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
VOID SetCleanupFromFailedCreate(BOOLEAN Value)
Definition: fxdevice.hpp:1877
UNICODE_STRING m_MofResourceName
Definition: fxdevice.hpp:585
_Must_inspect_result_ NTSTATUS PdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:221
FxMessageDispatch * m_Dispatcher
Definition: fxdevice.hpp:738
VOID FinishInitializing(VOID)
Definition: fxdevice.cpp:1109
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
Definition: fxdevicekm.hpp:30
static _Must_inspect_result_ NTSTATUS _AcquireOptinRemoveLock(__in MdDeviceObject DeviceObject, __in MdIrp Irp)
Definition: fxdevice.cpp:1296
PWSTR m_KernelDeviceName
Definition: fxdevice.hpp:758
static _Must_inspect_result_ NTSTATUS _ValidateOpenKeyParams(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device)
Definition: fxdevice.cpp:2151
BOOLEAN m_ParentWaitingOnChild
Definition: fxdevice.hpp:535
FxIoTargetSelf * GetSelfIoTarget(VOID)
Definition: fxdevice.cpp:1831
ULONG m_DirectTransferThreshold
Definition: fxdevice.hpp:772
WDF_DEVICE_IO_TYPE m_ReadWriteIoType
Definition: fxdevice.hpp:514
MdRemoveLock GetRemoveLock(VOID)
Definition: fxdevicekm.hpp:47
VOID InstallPackage(__inout FxPackage *Package)
Definition: fxdevice.cpp:1611
LIST_ENTRY m_FileObjectListHead
Definition: fxdevice.hpp:643
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
BOOLEAN m_Filter
Definition: fxdevice.hpp:522
_Must_inspect_result_ NTSTATUS PostInitialize(VOID)
Definition: fxdevice.cpp:940
virtual VOID RemoveIoTarget(__inout FxIoTarget *IoTarget)
Definition: fxdevice.cpp:1790
static _Must_inspect_result_ NTSTATUS STDCALL DispatchWithLock(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1336
VOID SetFilterIoType(VOID)
Definition: fxdevice.cpp:1873
WDF_FILEOBJECT_CLASS m_FileObjectClass
Definition: fxdevice.hpp:621
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreateNoDelete(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:559
BOOLEAN m_DeviceObjectDeleted
Definition: fxdevice.hpp:553
BOOLEAN IsInterfaceRegistered(_In_ const GUID *InterfaceClassGUID, _In_opt_ PCUNICODE_STRING RefString)
Definition: fxdevice.cpp:1926
LIST_ENTRY m_PreprocessInfoListHead
Definition: fxdevice.hpp:630
virtual BOOLEAN Dispose(VOID)
Definition: fxdevice.cpp:1242
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
__inline BOOLEAN IsFilter()
Definition: fxdevice.hpp:1408
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
FxDevice(__in FxDriver *ArgDriver)
Definition: fxdevice.cpp:143
PVOID AllocateRequestMemory(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: fxdevice.cpp:1630
UNICODE_STRING m_SymbolicLinkName
Definition: fxdevice.hpp:580
BOOLEAN m_SelfIoTargetNeeded
Definition: fxdevice.hpp:611
PWSTR m_DeviceKeyPath
Definition: fxdevice.hpp:753
BOOLEAN m_CleanupFromFailedCreate
Definition: fxdevice.hpp:732
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
HKEY m_PdoDevKey
Definition: fxdevice.hpp:748
WDF_FILE_OBJECT_POLICY_TYPE m_FileObjectPolicy
Definition: fxdevice.hpp:788
IWudfDeviceStack * m_DevStack
Definition: fxdevice.hpp:743
virtual _Must_inspect_result_ NTSTATUS AllocateEnumInfo(VOID)
Definition: fxdevice.cpp:1805
_Must_inspect_result_ NTSTATUS FdoInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:33
__inline VOID SetStackSize(_In_ CHAR Size)
Definition: fxdevice.hpp:1833
FxSpinLockTransactionedList m_IoTargetsList
Definition: fxdevice.hpp:623
_Must_inspect_result_ NTSTATUS CreateDevice(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevice.cpp:964
WDF_FS_CONTEXT_USE_POLICY_TYPE m_FsContextUsePolicy
Definition: fxdevice.hpp:793
WDF_DEVICE_POWER_POLICY_STATE m_CurrentPowerPolicyState
Definition: fxdevice.hpp:509
BOOLEAN m_PowerPageableCapable
Definition: fxdevice.hpp:530
__inline FxPkgPdo * GetPdoPkg(VOID)
Definition: fxdevice.hpp:1254
PWSTR m_DeviceInstanceId
Definition: fxdevice.hpp:763
LIST_ENTRY m_CxDeviceInfoListHead
Definition: fxdevice.hpp:635
UMINT::WDF_DEVICE_IO_BUFFER_RETRIEVAL m_RetrievalMode
Definition: fxdevice.hpp:770
WDF_DIRECT_HARDWARE_ACCESS_TYPE m_DirectHardwareAccess
Definition: fxdevice.hpp:777
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreate(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:644
_Must_inspect_result_ NTSTATUS ControlDeviceInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxdevicekm.cpp:399
VOID FreeRequestMemory(__in FxRequest *Request)
Definition: fxdevice.cpp:1728
BOOLEAN m_AutoForwardCleanupClose
Definition: fxdevice.hpp:605
static _Must_inspect_result_ NTSTATUS STDCALL Dispatch(__in MdDeviceObject DeviceObject, __in MdIrp OriginalIrp)
Definition: fxdevice.cpp:1551
VOID SetInitialState(VOID)
Definition: fxdevice.cpp:153
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__inout FxQueryInterfaceParams *Params)
Definition: fxdevice.cpp:1754
static const CHAR m_PriorityBoosts[]
Definition: fxdevice.hpp:563
static NTSTATUS _Create(PFX_DRIVER_GLOBALS FxDriverGlobals, PVOID WdmObject, FxDisposeList **pObject)
VOID WaitForEmpty(VOID)
MxDriverObject m_DriverObject
Definition: fxdriver.hpp:62
PFN_WDF_IO_IN_CALLER_CONTEXT m_Method
VOID UpdateTargetIoType(VOID)
__inline MdDeviceObject GetTargetPDO(VOID)
Definition: fxiotarget.hpp:281
Definition: fxirp.hpp:28
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID SetCompletionRoutineEx(__in MdDeviceObject DeviceObject, __in MdCompletionRoutine CompletionRoutine, __in PVOID Context, __in BOOLEAN InvokeOnSuccess=TRUE, __in BOOLEAN InvokeOnError=TRUE, __in BOOLEAN InvokeOnCancel=TRUE)
Definition: fxirpum.cpp:104
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
VOID PropagatePendingReturned(VOID)
Definition: fxirpum.cpp:443
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
VOID CopyCurrentIrpStackLocationToNext(VOID)
Definition: fxirpum.cpp:209
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in POOL_TYPE PoolType, __in ULONG PoolTag, __in size_t BufferSize, __out FxMemoryObject **Object)
virtual WDFMEMORY GetHandle(VOID)
BOOLEAN IsNoDeleteDDI(VOID)
Definition: fxobject.hpp:1135
virtual VOID DeleteObject(VOID)
BOOLEAN IsDisposed(VOID)
Definition: fxobject.hpp:1241
PVOID __inline GetObjectHandleUnchecked(VOID)
Definition: fxobject.hpp:446
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
VOID __inline DestroyChildren(VOID)
Definition: fxobject.hpp:464
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
BOOLEAN EarlyDispose(VOID)
virtual BOOLEAN Dispose(VOID)
static PVOID __inline _ToHandle(__in FxObject *Object)
Definition: fxobject.hpp:659
__inline FxContextHeader * GetContextHeader(VOID)
Definition: fxobject.hpp:720
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
static PFX_POOL_HEADER _CleanupPointer(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
Definition: fxobject.hpp:1273
_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
__inline VOID CallCleanup(VOID)
Definition: fxobject.hpp:815
FxIoTargetSelf * m_SelfTarget
Definition: fxpkgfdo.hpp:53
_Must_inspect_result_ NTSTATUS SetFilter(__in BOOLEAN Value)
Definition: fxpkgfdo.cpp:892
FxIoTarget * m_DefaultTarget
Definition: fxpkgfdo.hpp:47
BOOLEAN CanDestroyControlDevice(VOID)
_Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
_Must_inspect_result_ NTSTATUS SetFilter(__in BOOLEAN Value)
Definition: fxpkgio.cpp:1120
__inline VOID SetIoInCallerContextCallback(__inout PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext)
Definition: fxpkgio.hpp:193
BOOLEAN m_AddedToStaticList
Definition: fxpkgpdo.hpp:63
BOOLEAN m_Static
Definition: fxpkgpdo.hpp:61
_Must_inspect_result_ NTSTATUS AllocateEnumInfo(VOID)
Definition: fxpkgpnp.cpp:4920
SINGLE_LIST_ENTRY m_DeviceInterfaceHead
Definition: fxpkgpnp.hpp:4126
FxWaitLockInternal m_DeviceInterfaceLock
Definition: fxpkgpnp.hpp:4124
VOID CleanupStateMachines(__in BOOLEAN ClenaupPnp)
Definition: fxpkgpnp.cpp:2066
VOID CleanupDeviceFromFailedCreate(__in MxEvent *WaitEvent)
Definition: fxpkgpnp.cpp:2190
virtual VOID FinishInitialize(__inout PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgpnp.cpp:1240
VOID __inline ReleaseString(__out PUNICODE_STRING ReleaseTo)
Definition: fxstring.hpp:47
_Must_inspect_result_ FxTransactionedEntry * GetNextEntry(__in_opt FxTransactionedEntry *Entry)
VOID UnlockFromEnum(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
NTSTATUS Add(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
VOID LockForEnum(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
VOID Remove(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
virtual PVOID GetBuffer(VOID)=0
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
PVOID GetDeviceExtension(VOID)
ULONG GetFlags(VOID)
__inline MdDeviceObject GetObject(VOID)
VOID SetDeviceExtension(PVOID Value)
VOID SetFlags(ULONG Flags)
__inline MdDriverObject GetObject(VOID)
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in EVENT_TYPE Type, __in BOOLEAN InitialState)
Definition: mxeventkm.h:55
MxEvent * GetSelfPointer(VOID)
Definition: mxevent.h:110
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
static __inline VOID MxInitializeRemoveLock(__in MdRemoveLock Lock, __in ULONG AllocateTag, __in ULONG MaxLockedMinutes, __in ULONG HighWatermark)
Definition: mxgeneralkm.h:256
static __inline NTSTATUS MxCreateDevice(_In_ MdDriverObject DriverObject, _In_ ULONG DeviceExtensionSize, _In_opt_ PUNICODE_STRING DeviceName, _In_ DEVICE_TYPE DeviceType, _In_ ULONG DeviceCharacteristics, _In_ BOOLEAN Exclusive, _Out_ MdDeviceObject *DeviceObject)
Definition: mxgeneralkm.h:557
static __inline NTSTATUS MxCreateDeviceSecure(_In_ MdDriverObject DriverObject, _In_ ULONG DeviceExtensionSize, _In_opt_ PUNICODE_STRING DeviceName, _In_ DEVICE_TYPE DeviceType, _In_ ULONG DeviceCharacteristics, _In_ BOOLEAN Exclusive, _In_ PCUNICODE_STRING DefaultSDDLString, _In_opt_ LPCGUID DeviceClassGuid, _Out_ MdDeviceObject *DeviceObject)
Definition: mxgeneralkm.h:521
static __inline VOID MxReleaseRemoveLock(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:278
static __inline VOID MxDeleteNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST LookasideList)
Definition: mxgeneralkm.h:433
static __inline VOID MxDeleteDevice(_In_ MdDeviceObject Device)
Definition: mxgeneralkm.h:493
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
static __inline VOID MxInitializeNPagedLookasideList(_Out_ PNPAGED_LOOKASIDE_LIST Lookaside, _In_opt_ PALLOCATE_FUNCTION Allocate, _In_opt_ PFREE_FUNCTION Free, _In_ ULONG Flags, _In_ SIZE_T Size, _In_ ULONG Tag, _In_ USHORT Depth)
Definition: mxgeneralkm.h:451
_In_z_ PCCHAR _In_ PDEVICE_OBJECT _In_ BOOLEAN IsFdo
Definition: classpnp.h:984
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
_In_ PIRP Irp
Definition: csq.h:116
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define TRACINGREQUEST
Definition: dbgtrace.h:65
#define TRACINGPNP
Definition: dbgtrace.h:67
#define TRACINGDEVICE
Definition: dbgtrace.h:58
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
ULONG * PDEVPROPTYPE
Definition: devpropdef.h:24
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DEVICE_TYPE
Definition: guid.c:10
KIRQL irql
Definition: wave.h:1
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
FxDevice * pDevice
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_Must_inspect_result_ __inline NTSTATUS DispatchWorker(__in FxDevice *Device, __in MdIrp Irp, __in WDFCONTEXT DispatchContext)
Definition: fxdevice.cpp:1507
_Must_inspect_result_ __inline BOOLEAN IsPreprocessIrp(__in MdIrp Irp, __in FxIrpPreprocessInfo *Info)
Definition: fxdevice.cpp:1408
_Must_inspect_result_ __inline NTSTATUS PreprocessIrp(__in FxDevice *Device, __in MdIrp Irp, __in FxIrpPreprocessInfo *Info, __in PVOID DispatchContext)
Definition: fxdevice.cpp:1451
FxPropertyType
Definition: fxdevice.hpp:85
@ FxDeviceRemLockRequired
Definition: fxdevice.hpp:80
@ FxDeviceRemLockTestValid
Definition: fxdevice.hpp:81
@ FxDeviceRemLockOptIn
Definition: fxdevice.hpp:82
return pDevice GetPhysicalDevice()
return pDevice GetDeviceObject()
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE PropertyType
@ FxDeviceInitTypeControlDevice
@ FxDeviceInitTypeFdo
@ FxDeviceInitTypePdo
PWDFDEVICE_INIT pInit
__in WDFDEVICE __in CONST GUID __in_opt PCUNICODE_STRING RefString
PSINGLE_LIST_ENTRY ple
FxVerifierDbgBreakPoint(pFxDriverGlobals)
FxPkgPdo * pPkgPdo
#define FX_FILE_OBJECT_POLICY_DEFAULT
Definition: fxdeviceum.hpp:39
#define FX_FS_CONTEXT_USE_POLICY_DEFAULT
Definition: fxdeviceum.hpp:42
#define FX_REGISTER_ACCESS_MODE_DEFAULT
Definition: fxdeviceum.hpp:36
#define FX_DIRECT_HARDWARE_ACCESS_DEFAULT
Definition: fxdeviceum.hpp:33
DriverGlobals
_Must_inspect_result_ BOOLEAN __inline FxIsEqualGuid(__in CONST GUID *Lhs, __in CONST GUID *Rhs)
Definition: fxglobals.h:977
__inline PVOID FxAllocateFromNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST Lookaside, _In_opt_ size_t ElementSize=0)
Definition: fxglobalskm.h:565
__inline VOID FxFreeToNPagedLookasideList(__in PNPAGED_LOOKASIDE_LIST Lookaside, __in PVOID Entry)
Definition: fxglobalskm.h:611
__inline VOID FxFreeToNPagedLookasideListNoTracking(__in PNPAGED_LOOKASIDE_LIST Lookaside, __in PVOID Entry)
Definition: fxglobalskm.h:528
_Must_inspect_result_ __inline PVOID FxAllocateFromNPagedLookasideListNoTracking(__in PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: fxglobalskm.h:487
PVOID FxObjectAndHandleHeaderInit(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID AllocationStart, __in USHORT ObjectSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObjectType ObjectType)
Definition: handleapi.cpp:292
size_t FxGetContextSize(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: handleapi.cpp:38
_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize2(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT RawObjectSize, __in USHORT ExtraSize, __in size_t ContextSize, __out size_t *Total)
Definition: handleapi.cpp:73
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)
Definition: fxhandle.h:107
PFX_DRIVER_GLOBALS pGlobals
FxMemoryObject * pMemory
@ ObjectDoNotLock
Definition: fxobject.hpp:128
@ FxObjectTypeExternal
Definition: fxobject.hpp:120
#define FX_IN_DISPATCH_CALLBACK
Definition: fxpkgio.hpp:39
FX_POOL_TRACKER * PFX_POOL_TRACKER
Definition: fxpool.h:109
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
FX_POOL_HEADER * PFX_POOL_HEADER
Definition: fxpool.h:51
_Must_inspect_result_ NTSTATUS __inline FxPoolAddHeaderSize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in size_t AllocationSize, __out size_t *NewSize)
VOID __inline FxPoolInsertNonPagedAllocateTracker(__in PFX_POOL Pool, __in PFX_POOL_TRACKER Tracker, __in SIZE_T Size, __in ULONG Tag, __in PVOID Caller)
pKey DeleteObject()
FxIrp * irp
@ FX_TYPE_DEVICE
Definition: fxtypes.h:47
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FxContextHeader * pHeader
Definition: handleapi.cpp:604
nsrefcnt AddRef()
#define _ReturnAddress()
Definition: intrin_arm.h:35
#define ASSERT(a)
Definition: mode.c:44
static PVOID ptr
Definition: dispmode.c:27
static LPSTR pName
Definition: security.c:75
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define _Analysis_assume_(expr)
Definition: ms_sal.h:2901
int remove
Definition: msacm.c:1366
#define DO_NOTHING()
Definition: mxgeneral.h:32
IWudfIrp * MdIrp
Definition: mxum.h:103
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
@ SynchronizationEvent
#define minor(rdev)
Definition: propsheet.cpp:929
#define major(rdev)
Definition: propsheet.cpp:928
static unsigned __int64 next
Definition: rand_nt.c:6
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
WDFCX_FILEOBJECT_CONFIG Callbacks
WDF_TRI_STATE AutoForwardCleanupClose
LIST_ENTRY ListEntry
FxIoInCallerContext IoInCallerContextCallback
FxDriver * Driver
WDF_OBJECT_ATTRIBUTES RequestAttributes
FxObject * GetTransactionedObject(VOID)
ULONG RemoveLockOptionFlags
Definition: fxdevice.hpp:38
WUDF_IO_REMOVE_LOCK IoRemoveLock
Definition: fxdevice.hpp:34
PFN_WDF_IO_IN_CALLER_CONTEXT IoInCallerContextCallback
CxFileObjectInit FileObject
WDF_OBJECT_ATTRIBUTES RequestAttributes
FxIrpPreprocessInfo * PreprocessInfo
FxCxDeviceInfo * CxDeviceInfo
PFX_DRIVER_GLOBALS CxDriverGlobals
FxString * DeviceName
FxDeviceInitType InitType
LIST_ENTRY CxDeviceInitListHead
FxDriver * Driver
BOOLEAN CreatedOnStack
FxIrpPreprocessInfo * PreprocessInfo
FxDevice * CreatedDevice
ULONG RemoveLockOptionFlags
Definition: fxglobals.h:494
FxDriver * Driver
Definition: fxglobals.h:374
FX_POOL FxPoolFrameworks
Definition: fxglobals.h:388
BOOLEAN IsPoolTrackingOn(VOID)
Definition: fxglobals.h:215
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: ntbasedef.h:628
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
PFN_WDFCX_DEVICE_FILE_CREATE EvtCxDeviceFileCreate
Definition: wdfcx.h:28
Definition: devices.h:37
Definition: ps.c:97
struct _LIST_ENTRY * PLIST_ENTRY
INT POOL_TYPE
Definition: typedefs.h:78
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
char CCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STDCALL
Definition: wdf.h:45
@ WDF_OBJECT_ERROR
Definition: wdfbugcodes.h:64
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
#define WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, _type)
Definition: wdfcore.h:141
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
@ WdfDevStatePnpInit
Definition: wdfdevice.h:69
@ WdfDevStatePnpObjectCreated
Definition: wdfdevice.h:64
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
Definition: wdfdevice.h:3817
_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:3820
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1708
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3431
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
@ WDF_REMOVE_LOCK_OPTION_ACQUIRE_FOR_IO
Definition: wdfdevice.h:1639
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3769
_Must_inspect_result_ _Inout_ PWDFDEVICE_INIT _In_opt_ PWDF_OBJECT_ATTRIBUTES DeviceAttributes
Definition: wdfdevice.h:3563
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID * InterfaceClassGUID
Definition: wdfdevice.h:3627
@ WdfFileObjectNotRequired
Definition: wdfdevice.h:460
@ WdfFileObjectWdfCannotUseFsContexts
Definition: wdfdevice.h:463
@ WdfDeviceIoNeither
Definition: wdfdevice.h:451
@ WdfDeviceIoBuffered
Definition: wdfdevice.h:452
@ WdfDeviceIoDirect
Definition: wdfdevice.h:453
@ WdfDevStatePwrPolObjectCreated
Definition: wdfdevice.h:232
@ WdfDevStatePowerObjectCreated
Definition: wdfdevice.h:130
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:368
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
@ WdfTrue
Definition: wdftypes.h:88
@ WdfUseDefault
Definition: wdftypes.h:89
@ WdfFalse
Definition: wdftypes.h:87
enum _WDF_TRI_STATE WDF_TRI_STATE
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:188
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define STATUS_CONTINUE_COMPLETION
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IO_SOUND_INCREMENT
Definition: iotypes.h:608
#define IO_CD_ROM_INCREMENT
Definition: iotypes.h:599
#define IO_NAMED_PIPE_INCREMENT
Definition: iotypes.h:604
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
#define IO_PARALLEL_INCREMENT
Definition: iotypes.h:606
#define IO_DISK_INCREMENT
Definition: iotypes.h:600
#define IO_MOUSE_INCREMENT
Definition: iotypes.h:603
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:609
#define IO_MAILSLOT_INCREMENT
Definition: iotypes.h:602
#define IO_SERIAL_INCREMENT
Definition: iotypes.h:607
#define IO_KEYBOARD_INCREMENT
Definition: iotypes.h:601
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175