ReactOS 0.4.16-dev-2613-g9533ad7
device.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/io/iomgr/device.c
5 * PURPOSE: Device Object Management, including Notifications and Queues.
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Filip Navara (navaraf@reactos.org)
8 * Hervé Poussineau (hpoussin@reactos.org)
9 * Pierre Schweitzer
10 */
11
12/* INCLUDES *******************************************************************/
13
14#include <ntoskrnl.h>
15#define NDEBUG
16#include <debug.h>
17
18/* GLOBALS ********************************************************************/
19
27
28#define DACL_SET 4
29
30/* PRIVATE FUNCTIONS **********************************************************/
31
32VOID
35{
37 PAGED_CODE();
38
39 /* Set the driver as initialized */
40 Driver->Flags |= DRVO_INITIALIZED;
41 DeviceObject = Driver->DeviceObject;
42 while (DeviceObject)
43 {
44 /* Set every device as initialized too */
45 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
46 DeviceObject = DeviceObject->NextDevice;
47 }
48}
49
50VOID
53{
54 PDEVICE_OBJECT DeviceObject = ObjectBody;
56 PAGED_CODE();
57
58 /* Cleanup and free the device node */
59 if (DeviceNode)
61
62 /* Dereference the driver object, referenced in IoCreateDevice */
63 if (DeviceObject->DriverObject)
64 ObDereferenceObject(DeviceObject->DriverObject);
65}
66
67static PDEVICE_OBJECT
72 _Out_opt_ PDEVICE_OBJECT* AttachedToDeviceObject)
73{
74 PDEVICE_OBJECT AttachedDevice;
75 PEXTENDED_DEVOBJ_EXTENSION SourceDeviceExtension;
77
78 /* Lock the device list while attaching the device */
80
81 /* Get the attached device and source extension */
82 AttachedDevice = IoGetAttachedDevice(TargetDevice);
83 SourceDeviceExtension = IoGetDevObjExtension(SourceDevice);
84 ASSERT(SourceDeviceExtension->AttachedTo == NULL);
85
86 /* Make sure that it's in a correct state */
87 if ((AttachedDevice->Flags & DO_DEVICE_INITIALIZING) ||
88 (IoGetDevObjExtension(AttachedDevice)->ExtensionFlags &
91 {
92 /* The device is unloading or being removed */
93 AttachedDevice = NULL;
94 }
95 else
96 {
97 /* Update the attached device fields */
98 AttachedDevice->AttachedDevice = SourceDevice;
99 AttachedDevice->Spare1++;
100
101 /* Update the source with the attached data */
102 SourceDevice->StackSize = AttachedDevice->StackSize + 1;
104 SourceDevice->SectorSize = AttachedDevice->SectorSize;
105
106 /* Check for pending start flag and propagate it */
107 if (IoGetDevObjExtension(AttachedDevice)->ExtensionFlags & DOE_START_PENDING)
109
110 /* Set the attachment in the device extension */
111 SourceDeviceExtension->AttachedTo = AttachedDevice;
112 }
113
114 /* Return the attached device (under the lock) */
115 if (AttachedToDeviceObject)
116 *AttachedToDeviceObject = AttachedDevice;
117
118 /* Release the device list lock */
120
121 return AttachedDevice;
122}
123
124VOID
125NTAPI
127{
128 /* This routine is only used by Driver Verifier to validate shutdown */
129 return;
130}
131
132VOID
133NTAPI
135{
136 PLIST_ENTRY ListEntry;
138 PSHUTDOWN_ENTRY ShutdownEntry;
139 IO_STATUS_BLOCK StatusBlock;
140 PIRP Irp;
143
144 /* Initialize an event to wait on */
146
147 /* What phase? */
148 if (Phase == 0)
149 {
150 /* Shutdown PnP */
152
153 /* Loop first-chance shutdown notifications */
156 while (ListEntry)
157 {
158 /* Get the shutdown entry */
159 ShutdownEntry = CONTAINING_RECORD(ListEntry,
161 ShutdownList);
162
163 /* Get the attached device */
165
166 /* Build the shutdown IRP and call the driver */
169 NULL,
170 0,
171 NULL,
172 &Event,
173 &StatusBlock);
174 if (Irp)
175 {
177 if (Status == STATUS_PENDING)
178 {
179 /* Wait on the driver */
181 }
182 }
183
184 /* Remove the flag */
185 ShutdownEntry->DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
186
187 /* Get rid of our reference to it */
188 ObDereferenceObject(ShutdownEntry->DeviceObject);
189
190 /* Free the shutdown entry and reset the event */
193
194 /* Go to the next entry */
197 }
198 }
199 else if (Phase == 1)
200 {
201 /* Acquire resource forever */
203
204 /* Shutdown disk file systems */
206
207 /* Shutdown cdrom file systems */
209
210 /* Shutdown tape filesystems */
212
213 /* Loop last-chance shutdown notifications */
216 while (ListEntry)
217 {
218 /* Get the shutdown entry */
219 ShutdownEntry = CONTAINING_RECORD(ListEntry,
221 ShutdownList);
222
223 /* Get the attached device */
225
226 /* Build the shutdown IRP and call the driver */
229 NULL,
230 0,
231 NULL,
232 &Event,
233 &StatusBlock);
234 if (Irp)
235 {
237 if (Status == STATUS_PENDING)
238 {
239 /* Wait on the driver */
241 }
242 }
243
244 /* Remove the flag */
245 ShutdownEntry->DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
246
247 /* Get rid of our reference to it */
248 ObDereferenceObject(ShutdownEntry->DeviceObject);
249
250 /* Free the shutdown entry and reset the event */
253
254 /* Go to the next entry */
257 }
258
259 }
260}
261
263NTAPI
268 IN ULONG AttachFlag)
269{
271 IO_STATUS_BLOCK StatusBlock;
272 PFILE_OBJECT LocalFileObject;
275
276 /* Open the Device */
280 NULL,
281 NULL);
285 &StatusBlock,
286 0,
287 FILE_NON_DIRECTORY_FILE | AttachFlag);
288 if (!NT_SUCCESS(Status)) return Status;
289
290 /* Get File Object */
292 0,
295 (PVOID*)&LocalFileObject,
296 NULL);
297 if (NT_SUCCESS(Status))
298 {
299 /* Return the requested data */
300 *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject);
301 *FileObject = LocalFileObject;
302 }
303
304 /* Close the handle */
306
307 return Status;
308}
309
311NTAPI
313{
314 PDEVICE_OBJECT LowestDevice;
315 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
316
317 /* Get the current device and its extension */
318 LowestDevice = DeviceObject;
319 DeviceExtension = IoGetDevObjExtension(LowestDevice);
320
321 /* Keep looping as long as we're attached */
322 while (DeviceExtension->AttachedTo)
323 {
324 /* Get the lowest device and its extension */
325 LowestDevice = DeviceExtension->AttachedTo;
326 DeviceExtension = IoGetDevObjExtension(LowestDevice);
327 }
328
329 /* Return the lowest device */
330 return LowestDevice;
331}
332
333VOID
334NTAPI
338{
339 PDEVICE_OBJECT Previous;
341
342 /* Lock the device list while we edit it */
344
345 /* Check the type of operation */
346 if (Type == IopRemove)
347 {
348 /* Get the current device and check if it's the current one */
349 Previous = DeviceObject->DriverObject->DeviceObject;
350 if (Previous == DeviceObject)
351 {
352 /* It is, simply unlink this one directly */
353 DeviceObject->DriverObject->DeviceObject =
354 DeviceObject->NextDevice;
355 }
356 else
357 {
358 /* It's not, so loop until we find the device */
359 while (Previous->NextDevice != DeviceObject)
360 {
361 /* Not this one, keep moving */
362 if (!Previous->NextDevice)
363 {
364 DPRINT1("Failed to remove PDO %p (not found)\n",
366
367 ASSERT(FALSE);
369 return;
370 }
371 Previous = Previous->NextDevice;
372 }
373
374 /* We found it, now unlink us */
375 Previous->NextDevice = DeviceObject->NextDevice;
376 }
377 }
378 else
379 {
380 /* Link the device object and the driver object */
381 DeviceObject->NextDevice = DriverObject->DeviceObject;
382 DriverObject->DeviceObject = DeviceObject;
383 }
384
385 /* Release the device list lock */
387}
388
389VOID
390NTAPI
392{
395
396 /* Check if deletion is pending */
397 if (ThisExtension->ExtensionFlags & DOE_DELETE_PENDING)
398 {
399 if (DeviceObject->AttachedDevice)
400 {
401 DPRINT("Device object is in the middle of a device stack\n");
402 return;
403 }
404
405 if (DeviceObject->ReferenceCount)
406 {
407 DPRINT("Device object still has %d references\n", DeviceObject->ReferenceCount);
408 return;
409 }
410
411 /* Check if we have a Security Descriptor */
412 if (DeviceObject->SecurityDescriptor)
413 {
414 /* Dereference it */
415 ObDereferenceSecurityDescriptor(DeviceObject->SecurityDescriptor, 1);
416 }
417
418 /* Remove the device from the list */
420
421 /* Dereference the keep-alive */
423 }
424
425 /* We can't unload a non-PnP driver here */
426 if (DriverObject->Flags & DRVO_LEGACY_DRIVER)
427 {
428 DPRINT("Not a PnP driver! '%wZ' will not be unloaded!\n", &DriverObject->DriverName);
429 return;
430 }
431
432 /* Return if we've already called unload (maybe we're in it?) */
433 if (DriverObject->Flags & DRVO_UNLOAD_INVOKED) return;
434
435 /* We can't unload unless there's an unload handler */
436 if (!DriverObject->DriverUnload)
437 {
438 DPRINT1("No DriverUnload function on PnP driver! '%wZ' will not be unloaded!\n", &DriverObject->DriverName);
439 return;
440 }
441
442 /* Bail if there are still devices present */
443 if (DriverObject->DeviceObject)
444 {
445 DPRINT("Devices still present! '%wZ' will not be unloaded!\n", &DriverObject->DriverName);
446 return;
447 }
448
449 DPRINT1("Unloading driver '%wZ' (automatic)\n", &DriverObject->DriverName);
450
451 /* Set the unload invoked flag */
453
454 /* Unload it */
455 DriverObject->DriverUnload(DriverObject);
456
457 /* Make object temporary so it can be deleted */
459}
460
461VOID
462NTAPI
464 IN BOOLEAN ForceUnload)
465{
466 /* Sanity check */
467 ASSERT(DeviceObject->ReferenceCount);
468
469 /* Dereference the device */
470 InterlockedDecrement(&DeviceObject->ReferenceCount);
471
472 /*
473 * Check if we can unload it and it's safe to unload (or if we're forcing
474 * an unload, which is OK too).
475 */
476 ASSERT(!ForceUnload);
477 if (!(DeviceObject->ReferenceCount) &&
479 {
480 /* Unload it */
482 }
483}
484
485VOID
486NTAPI
489 IN ULONG Key)
490{
492 PIRP Irp;
494
495 /* Acquire the cancel lock if this is cancelable */
497
498 /* Clear the current IRP */
499 DeviceObject->CurrentIrp = NULL;
500
501 /* Remove an entry from the queue */
503 if (Entry)
504 {
505 /* Get the IRP and set it */
506 Irp = CONTAINING_RECORD(Entry, IRP, Tail.Overlay.DeviceQueueEntry);
507 DeviceObject->CurrentIrp = Irp;
508
509 /* Check if this is a cancelable packet */
510 if (Cancelable)
511 {
512 /* Check if the caller requested no cancellation */
513 if (IoGetDevObjExtension(DeviceObject)->StartIoFlags &
515 {
516 /* He did, so remove the cancel routine */
517 Irp->CancelRoutine = NULL;
518 }
519
520 /* Release the cancel lock */
522 }
523
524 /* Call the Start I/O Routine */
525 DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp);
526 }
527 else
528 {
529 /* Otherwise, release the cancel lock if we had acquired it */
531 }
532}
533
534VOID
535NTAPI
538{
540 PIRP Irp;
542
543 /* Acquire the cancel lock if this is cancelable */
545
546 /* Clear the current IRP */
547 DeviceObject->CurrentIrp = NULL;
548
549 /* Remove an entry from the queue */
550 Entry = KeRemoveDeviceQueue(&DeviceObject->DeviceQueue);
551 if (Entry)
552 {
553 /* Get the IRP and set it */
554 Irp = CONTAINING_RECORD(Entry, IRP, Tail.Overlay.DeviceQueueEntry);
555 DeviceObject->CurrentIrp = Irp;
556
557 /* Check if this is a cancelable packet */
558 if (Cancelable)
559 {
560 /* Check if the caller requested no cancellation */
561 if (IoGetDevObjExtension(DeviceObject)->StartIoFlags &
563 {
564 /* He did, so remove the cancel routine */
565 Irp->CancelRoutine = NULL;
566 }
567
568 /* Release the cancel lock */
570 }
571
572 /* Call the Start I/O Routine */
573 DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp);
574 }
575 else
576 {
577 /* Otherwise, release the cancel lock if we had acquired it */
579 }
580}
581
582VOID
583NTAPI
585 IN ULONG Key,
586 IN ULONG Flags)
587{
588 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
589 ULONG CurrentKey = Key;
590 ULONG CurrentFlags = Flags;
591
592 /* Get the device extension and start the packet loop */
593 DeviceExtension = IoGetDevObjExtension(DeviceObject);
594 while (TRUE)
595 {
596 /* Increase the count */
597 if (InterlockedIncrement(&DeviceExtension->StartIoCount) > 1)
598 {
599 /*
600 * We've already called the routine once...
601 * All we have to do is save the key and add the new flags
602 */
603 DeviceExtension->StartIoFlags |= CurrentFlags;
604 DeviceExtension->StartIoKey = CurrentKey;
605 }
606 else
607 {
608 /* Mask out the current packet flags and key */
609 DeviceExtension->StartIoFlags &= ~(DOE_SIO_WITH_KEY |
612 DeviceExtension->StartIoKey = 0;
613
614 /* Check if this is a packet start with key */
616 {
617 /* Start the packet with a key */
620 TRUE : FALSE,
621 CurrentKey);
622 }
623 else if (Flags & DOE_SIO_NO_KEY)
624 {
625 /* Start the packet */
628 TRUE : FALSE);
629 }
630 }
631
632 /* Decrease the Start I/O count and check if it's 0 now */
633 if (!InterlockedDecrement(&DeviceExtension->StartIoCount))
634 {
635 /* Get the current active key and flags */
636 CurrentKey = DeviceExtension->StartIoKey;
637 CurrentFlags = DeviceExtension->StartIoFlags & (DOE_SIO_WITH_KEY |
640
641 /* Check if we should still loop */
642 if (!(CurrentFlags & (DOE_SIO_WITH_KEY | DOE_SIO_NO_KEY))) break;
643 }
644 else
645 {
646 /* There are still Start I/Os active, so quit this loop */
647 break;
648 }
649 }
650}
651
653NTAPI
656{
659 PDEVICE_RELATIONS DeviceRelations;
661
663
664 /* Get DeviceObject related to given FileObject */
667
668 /* Define input parameters */
669 Stack.MajorFunction = IRP_MJ_PNP;
670 Stack.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
671 Stack.Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;
672 Stack.FileObject = FileObject;
673
674 /* Call the driver to query all relations (IRP_MJ_PNP) */
676 &Stack,
677 (PVOID)&DeviceRelations);
678 if (!NT_SUCCESS(Status)) return Status;
679
680 /* Make sure it's not NULL and contains only one object */
681 ASSERT(DeviceRelations);
682 ASSERT(DeviceRelations->Count == 1);
683
684 /* Finally get the device node */
685 *DeviceNode = IopGetDeviceNode(DeviceRelations->Objects[0]);
687
688 /* Free the DEVICE_RELATIONS structure, it's not needed anymore */
689 ExFreePool(DeviceRelations);
690
691 return Status;
692}
693
695NTAPI
697 IN PDEVICE_OBJECT TopDeviceObjectHint)
698{
701 PDEVICE_OBJECT LoopObject;
702
703 ASSERT(BaseDeviceObject != NULL);
704
705 Result = FALSE;
706 /* Simply loop on the device stack and try to find our hint */
708 for (LoopObject = BaseDeviceObject; ; LoopObject = LoopObject->AttachedDevice)
709 {
710 /* It was found, it's a success */
711 if (LoopObject == TopDeviceObjectHint)
712 {
713 Result = TRUE;
714 break;
715 }
716
717 /* End of the stack, that's a failure - default */
718 if (LoopObject == NULL)
719 {
720 break;
721 }
722 }
724
725 return Result;
726}
727
729NTAPI
732 OUT PULONG OutputFlags)
733{
734 PACL Dacl;
736
737 /* Select the DACL the caller wants */
738 switch (Type)
739 {
740 case RestrictedPublic:
742 break;
743
746 break;
747
750 break;
751
754 break;
755
756 case SystemDefault:
758 break;
759
760 default:
761 ASSERT(FALSE);
763 }
764
765 /* Create the SD and set the DACL caller wanted */
769
770 /* We've set DACL */
771 if (OutputFlags) *OutputFlags |= DACL_SET;
772
773 /* Done */
774 return Status;
775}
776
778NTAPI
781 IN BOOLEAN HasDeviceName,
783 OUT PACL * OutputDacl,
784 OUT PULONG OutputFlags)
785{
786 PACL Dacl;
787 ULONG AceId;
790 BOOLEAN AdminsSet, WorldSet;
791
792 PAGED_CODE();
793
794 /* Zero our output vars */
795 if (OutputFlags) *OutputFlags = 0;
796
797 *OutputDacl = NULL;
798
799 /* For FSD, easy use SePublicDefaultUnrestrictedDacl */
804 {
807 OutputFlags);
808 goto Quit;
809 }
810 /* For storage devices with a name and floppy attribute,
811 * use SePublicOpenUnrestrictedDacl
812 */
821 {
824 OutputFlags);
825 goto Quit;
826 }
827
828 /* The rest...
829 * We will rely on SePublicDefaultUnrestrictedDacl as well
830 */
832 if (Dacl == NULL)
833 {
834 return NULL;
835 }
836
837 /* Copy our DACL */
839
840 /* Now, browse the DACL to make sure we have everything we want in them,
841 * including permissions
842 */
843 AceId = 0;
844 AdminsSet = FALSE;
845 WorldSet = FALSE;
846 while (NT_SUCCESS(RtlGetAce(Dacl, AceId, (PVOID *)&Ace)))
847 {
848 /* Admins must acess and in RWX, set it */
849 if (RtlEqualSid(SeAliasAdminsSid, &Ace->SidStart))
850 {
852 AdminsSet = TRUE;
853 }
854
855 /* World can read a CD_ROM device */
857 {
858 SetFlag(Ace->Mask, GENERIC_READ);
859 WorldSet = TRUE;
860 }
861
862 ++AceId;
863 }
864
865 /* AdminSid was present and set (otherwise, we have big trouble) */
866 ASSERT(AdminsSet);
867
868 /* If CD_ROM device, we've set world permissions */
869 if (DeviceType == FILE_DEVICE_CD_ROM) ASSERT(WorldSet);
870
871 /* Now our DACL is correct, setup the security descriptor */
874
875 /* We've set DACL */
876 if (OutputFlags) *OutputFlags |= DACL_SET;
877
878 /* Return DACL to allow later freeing */
879 *OutputDacl = Dacl;
881
882Quit:
883 /* Only return SD if we succeed */
884 if (!NT_SUCCESS(Status))
885 {
886 return NULL;
887 }
888
889 return SecurityDescriptor;
890}
891
892/* PUBLIC FUNCTIONS ***********************************************************/
893
894/*
895 * IoAttachDevice
896 *
897 * Layers a device over the highest device in a device stack.
898 *
899 * Parameters
900 * SourceDevice
901 * Device to be attached.
902 *
903 * TargetDevice
904 * Name of the target device.
905 *
906 * AttachedDevice
907 * Caller storage for the device attached to.
908 *
909 * Status
910 * @implemented
911 */
913NTAPI
915 PUNICODE_STRING TargetDeviceName,
916 PDEVICE_OBJECT *AttachedDevice)
917{
921
922 /* Call the helper routine for an attach operation */
923 Status = IopGetDeviceObjectPointer(TargetDeviceName,
925 &FileObject,
928 if (!NT_SUCCESS(Status)) return Status;
929
930 /* Attach the device */
933 AttachedDevice);
934
935 /* Dereference it */
937 return Status;
938}
939
940/*
941 * IoAttachDeviceByPointer
942 *
943 * Status
944 * @implemented
945 */
947NTAPI
950{
951 PDEVICE_OBJECT AttachedDevice;
953
954 /* Do the Attach */
956 if (!AttachedDevice) Status = STATUS_NO_SUCH_DEVICE;
957
958 /* Return the status */
959 return Status;
960}
961
962/*
963 * @implemented
964 */
966NTAPI
969{
970 /* Attach it safely */
973 NULL);
974}
975
976/*
977 * @implemented
978 */
980NTAPI
983 IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
984{
985 /* Call the internal function */
988 AttachedToDeviceObject))
989 {
990 /* Nothing found */
992 }
993
994 /* Success! */
995 return STATUS_SUCCESS;
996}
997
998/*
999 * IoCreateDevice
1000 *
1001 * Allocates memory for and intializes a device object for use for
1002 * a driver.
1003 *
1004 * Parameters
1005 * DriverObject
1006 * Driver object passed by IO Manager when the driver was loaded.
1007 *
1008 * DeviceExtensionSize
1009 * Number of bytes for the device extension.
1010 *
1011 * DeviceName
1012 * Unicode name of device.
1013 *
1014 * DeviceType
1015 * Device type of the new device.
1016 *
1017 * DeviceCharacteristics
1018 * Bit mask of device characteristics.
1019 *
1020 * Exclusive
1021 * TRUE if only one thread can access the device at a time.
1022 *
1023 * DeviceObject
1024 * On successful return this parameter is filled by pointer to
1025 * allocated device object.
1026 *
1027 * Status
1028 * @implemented
1029 */
1031NTAPI
1033 IN ULONG DeviceExtensionSize,
1039{
1040 WCHAR AutoNameBuffer[20];
1041 UNICODE_STRING AutoName;
1042 PDEVICE_OBJECT CreatedDeviceObject;
1043 PDEVOBJ_EXTENSION DeviceObjectExtension;
1046 ULONG AlignedDeviceExtensionSize;
1047 ULONG TotalSize;
1048 HANDLE TempHandle;
1049 PACL Dacl;
1051 PAGED_CODE();
1052
1053 /* Check if we have to generate a name */
1055 {
1056 /* Generate it */
1057 swprintf(AutoNameBuffer,
1058 L"\\Device\\%08lx",
1060
1061 /* Initialize the name */
1062 RtlInitUnicodeString(&AutoName, AutoNameBuffer);
1063 DeviceName = &AutoName;
1064 }
1065
1066 /* Get the security descriptor */
1069 DeviceName != NULL,
1071 &Dacl,
1072 NULL);
1073
1074 /* Initialize the Object Attributes */
1076 DeviceName,
1078 NULL,
1079 ReturnedSD);
1080
1081 /* Honor exclusive flag */
1082 if (Exclusive) ObjectAttributes.Attributes |= OBJ_EXCLUSIVE;
1083
1084 /* Create a permanent object for named devices */
1085 if (DeviceName) ObjectAttributes.Attributes |= OBJ_PERMANENT;
1086
1087 /* Align the Extension Size to 8-bytes */
1088 AlignedDeviceExtensionSize = ALIGN_UP_BY(DeviceExtensionSize,
1090
1091 /* Total Size */
1092 TotalSize = AlignedDeviceExtensionSize +
1093 sizeof(DEVICE_OBJECT) +
1095
1096 /* Create the Device Object */
1097 *DeviceObject = NULL;
1101 KernelMode,
1102 NULL,
1103 TotalSize,
1104 0,
1105 0,
1106 (PVOID*)&CreatedDeviceObject);
1107 if (!NT_SUCCESS(Status))
1108 {
1109 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1110
1111 return Status;
1112 }
1113
1114 /* Clear the whole Object and extension so we don't null stuff manually */
1115 RtlZeroMemory(CreatedDeviceObject, TotalSize);
1116
1117 /*
1118 * Setup the Type and Size. Note that we don't use the aligned size,
1119 * because that's only padding for the DevObjExt and not part of the Object.
1120 */
1121 CreatedDeviceObject->Type = IO_TYPE_DEVICE;
1122 CreatedDeviceObject->Size = sizeof(DEVICE_OBJECT) + (USHORT)DeviceExtensionSize;
1123
1124 /* The kernel extension is after the driver internal extension */
1125 DeviceObjectExtension = (PDEVOBJ_EXTENSION)
1126 ((ULONG_PTR)(CreatedDeviceObject + 1) +
1127 AlignedDeviceExtensionSize);
1128
1129 /* Set the Type and Size. Question: why is Size 0 on Windows? */
1130 DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION;
1131 DeviceObjectExtension->Size = 0;
1132
1133 /* Initialize with Power Manager */
1134 PoInitializeDeviceObject(DeviceObjectExtension);
1135
1136 /* Link the Object and Extension */
1137 DeviceObjectExtension->DeviceObject = CreatedDeviceObject;
1138 CreatedDeviceObject->DeviceObjectExtension = DeviceObjectExtension;
1139
1140 /* Set Device Object Data */
1141 CreatedDeviceObject->DeviceType = DeviceType;
1142 CreatedDeviceObject->Characteristics = DeviceCharacteristics;
1143 CreatedDeviceObject->DeviceExtension = DeviceExtensionSize ?
1144 CreatedDeviceObject + 1 :
1145 NULL;
1146 CreatedDeviceObject->StackSize = 1;
1147 CreatedDeviceObject->AlignmentRequirement = 0;
1148
1149 /* Set the Flags */
1150 CreatedDeviceObject->Flags = DO_DEVICE_INITIALIZING;
1151 if (Exclusive) CreatedDeviceObject->Flags |= DO_EXCLUSIVE;
1152 if (DeviceName) CreatedDeviceObject->Flags |= DO_DEVICE_HAS_NAME;
1153
1154 /* Attach a Vpb for Disks and Tapes, and create the Device Lock */
1155 if ((CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK) ||
1156 (CreatedDeviceObject->DeviceType == FILE_DEVICE_VIRTUAL_DISK) ||
1157 (CreatedDeviceObject->DeviceType == FILE_DEVICE_CD_ROM) ||
1158 (CreatedDeviceObject->DeviceType == FILE_DEVICE_TAPE))
1159 {
1160 /* Create Vpb */
1161 Status = IopCreateVpb(CreatedDeviceObject);
1162 if (!NT_SUCCESS(Status))
1163 {
1164 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1165
1166 /* Dereference the device object and fail */
1167 ObDereferenceObject(CreatedDeviceObject);
1168 return Status;
1169 }
1170
1171 /* Initialize Lock Event */
1172 KeInitializeEvent(&CreatedDeviceObject->DeviceLock,
1174 TRUE);
1175 }
1176
1177 /* Set the right Sector Size */
1178 switch (DeviceType)
1179 {
1180 /* All disk systems */
1182 case FILE_DEVICE_DISK:
1184
1185 /* The default is 512 bytes */
1186 CreatedDeviceObject->SectorSize = 512;
1187 break;
1188
1189 /* CD-ROM file systems */
1191
1192 /* The default is 2048 bytes */
1193 CreatedDeviceObject->SectorSize = 2048;
1194 }
1195
1196 /* Create the Device Queue */
1197 if ((CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) ||
1198 (CreatedDeviceObject->DeviceType == FILE_DEVICE_FILE_SYSTEM) ||
1199 (CreatedDeviceObject->DeviceType == FILE_DEVICE_CD_ROM_FILE_SYSTEM) ||
1200 (CreatedDeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) ||
1201 (CreatedDeviceObject->DeviceType == FILE_DEVICE_TAPE_FILE_SYSTEM))
1202 {
1203 /* Simple FS Devices, they don't need a real Device Queue */
1204 InitializeListHead(&CreatedDeviceObject->Queue.ListEntry);
1205 }
1206 else
1207 {
1208 /* An actual Device, initialize its DQ */
1209 KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue);
1210 }
1211
1212 /* Insert the Object */
1213 Status = ObInsertObject(CreatedDeviceObject,
1214 NULL,
1216 1,
1217 (PVOID*)&CreatedDeviceObject,
1218 &TempHandle);
1219 if (!NT_SUCCESS(Status))
1220 {
1221 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1222
1223 return Status;
1224 }
1225
1226 /* Now do the final linking */
1228 ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0);
1229 CreatedDeviceObject->DriverObject = DriverObject;
1230 IopEditDeviceList(DriverObject, CreatedDeviceObject, IopAdd);
1231
1232 /* Link with the power manager */
1233 if (CreatedDeviceObject->Vpb) PoVolumeDevice(CreatedDeviceObject);
1234
1235 /* Close the temporary handle and return to caller */
1236 ObCloseHandle(TempHandle, KernelMode);
1237 *DeviceObject = CreatedDeviceObject;
1238
1239 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1240
1241 return STATUS_SUCCESS;
1242}
1243
1244/*
1245 * IoDeleteDevice
1246 *
1247 * Status
1248 * @implemented
1249 */
1250VOID
1251NTAPI
1253{
1255
1256 /* Check if the device is registered for shutdown notifications */
1258 {
1259 /* Call the shutdown notifications */
1261 }
1262
1263 /* Check if it has a timer */
1265 if (Timer)
1266 {
1267 /* Remove it and free it */
1270 }
1271
1272 /* Check if the device has a name */
1273 if (DeviceObject->Flags & DO_DEVICE_HAS_NAME)
1274 {
1275 /* It does, make it temporary so we can remove it */
1277 }
1278
1279 /* Set the pending delete flag */
1281
1282 /* Unlink with the power manager */
1284
1285 /* Check if the device object can be unloaded */
1286 if (!DeviceObject->ReferenceCount) IopUnloadDevice(DeviceObject);
1287}
1288
1289/*
1290 * IoDetachDevice
1291 *
1292 * Status
1293 * @implemented
1294 */
1295VOID
1296NTAPI
1298{
1299 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1300
1301 /* Sanity check */
1302 DeviceExtension = IoGetDevObjExtension(TargetDevice->AttachedDevice);
1303 ASSERT(DeviceExtension->AttachedTo == TargetDevice);
1304
1305 /* Remove the attachment */
1306 DeviceExtension->AttachedTo = NULL;
1307 TargetDevice->AttachedDevice = NULL;
1308
1309 /* Check if it's ok to delete this device */
1310 if ((IoGetDevObjExtension(TargetDevice)->ExtensionFlags & DOE_DELETE_PENDING) &&
1311 !(TargetDevice->ReferenceCount))
1312 {
1313 /* It is, do it */
1315 }
1316}
1317
1318/*
1319 * @implemented
1320 */
1322NTAPI
1324 IN PDEVICE_OBJECT *DeviceObjectList,
1325 IN ULONG DeviceObjectListSize,
1326 OUT PULONG ActualNumberDeviceObjects)
1327{
1328 ULONG ActualDevices = 1;
1329 PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject;
1330 KIRQL OldIrql;
1331
1332 /* Lock the device list while we enumerate it */
1334
1335 /* Find out how many devices we'll enumerate */
1336 while ((CurrentDevice = CurrentDevice->NextDevice)) ActualDevices++;
1337
1338 /* Go back to the first */
1339 CurrentDevice = DriverObject->DeviceObject;
1340
1341 /* Start by at least returning this */
1342 *ActualNumberDeviceObjects = ActualDevices;
1343
1344 /* Check if we can support so many */
1345 if ((ActualDevices * sizeof(PDEVICE_OBJECT)) > DeviceObjectListSize)
1346 {
1347 /* Fail because the buffer was too small */
1350 }
1351
1352 /* Check if the caller wanted the device list */
1353 if (DeviceObjectList)
1354 {
1355 /* Loop through all the devices */
1356 while (ActualDevices)
1357 {
1358 /* Reference each Device */
1359 ObReferenceObject(CurrentDevice);
1360
1361 /* Add it to the list */
1362 *DeviceObjectList = CurrentDevice;
1363
1364 /* Go to the next one */
1365 CurrentDevice = CurrentDevice->NextDevice;
1366 ActualDevices--;
1367 DeviceObjectList++;
1368 }
1369 }
1370
1371 /* Release the device list lock */
1373
1374 /* Return the status */
1375 return STATUS_SUCCESS;
1376}
1377
1378/*
1379 * IoGetAttachedDevice
1380 *
1381 * Status
1382 * @implemented
1383 */
1385NTAPI
1387{
1388 /* Get the last attached device */
1389 while (DeviceObject->AttachedDevice)
1390 {
1391 /* Move to the next one */
1392 DeviceObject = DeviceObject->AttachedDevice;
1393 }
1394
1395 /* Return it */
1396 return DeviceObject;
1397}
1398
1399/*
1400 * IoGetAttachedDeviceReference
1401 *
1402 * Status
1403 * @implemented
1404 */
1406NTAPI
1408{
1409 KIRQL OldIrql;
1410
1411 /* Retrieve and reference the attached device under the device list lock */
1416
1417 return DeviceObject;
1418}
1419
1420/*
1421 * @implemented
1422 */
1424NTAPI
1426{
1427 KIRQL OldIrql;
1428
1429 /* Retrieve and reference the lowest attached device under the device list lock */
1434
1435 return DeviceObject;
1436}
1437
1438/*
1439 * IoGetDeviceObjectPointer
1440 *
1441 * Status
1442 * @implemented
1443 */
1445NTAPI
1450{
1451 /* Call the helper routine for a normal operation */
1454 FileObject,
1456 0);
1457}
1458
1459/*
1460 * @implemented
1461 */
1463NTAPI
1466{
1467 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1468 PVPB Vpb;
1469 KIRQL OldIrql;
1471
1472 /* Make sure there's a VPB */
1473 if (!FileSystemDeviceObject->Vpb) return STATUS_INVALID_PARAMETER;
1474
1475 /* Acquire it */
1477
1478 /* Get the Device Extension */
1479 DeviceExtension = IoGetDevObjExtension(FileSystemDeviceObject);
1480
1481 /* Make sure this one has a VPB too */
1482 Vpb = DeviceExtension->Vpb;
1483 if (Vpb)
1484 {
1485 /* Make sure that it's mounted */
1486 if ((Vpb->ReferenceCount) &&
1487 (Vpb->Flags & VPB_MOUNTED))
1488 {
1489 /* Return the Disk Device Object */
1490 *DiskDeviceObject = Vpb->RealDevice;
1491
1492 /* Reference it and return success */
1493 ObReferenceObject(Vpb->RealDevice);
1495 }
1496 else
1497 {
1498 /* It's not, so return failure */
1500 }
1501 }
1502 else
1503 {
1504 /* Fail */
1506 }
1507
1508 /* Release the lock */
1510 return Status;
1511}
1512
1513/*
1514 * @implemented
1515 */
1517NTAPI
1519{
1520 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1522
1523 /* Make sure it's not getting deleted */
1524 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1525 if (!(DeviceExtension->ExtensionFlags &
1528 {
1529 /* Get the Lower Device Object */
1530 LowerDeviceObject = DeviceExtension->AttachedTo;
1531
1532 /* Check that we got a valid device object */
1534 {
1535 /* We did so let's reference it */
1537 }
1538 }
1539
1540 /* Return it */
1541 return LowerDeviceObject;
1542}
1543
1544/*
1545 * @implemented
1546 */
1548NTAPI
1550{
1551 PDEVICE_OBJECT DeviceObject = FileObject->DeviceObject;
1552
1553 /* Check if we have a VPB with a device object */
1554 if ((FileObject->Vpb) && (FileObject->Vpb->DeviceObject))
1555 {
1556 /* Then use the DO from the VPB */
1558 DeviceObject = FileObject->Vpb->DeviceObject;
1559 }
1560 else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) &&
1561 (FileObject->DeviceObject->Vpb) &&
1562 (FileObject->DeviceObject->Vpb->DeviceObject))
1563 {
1564 /* The disk device actually has a VPB, so get the DO from there */
1565 DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject;
1566 }
1567 else
1568 {
1569 /* Otherwise, this was a direct open */
1570 DeviceObject = FileObject->DeviceObject;
1571 }
1572
1573 /* Sanity check */
1575
1576 /* Check if we were attached */
1577 if (DeviceObject->AttachedDevice)
1578 {
1579 /* Check if the file object has an extension present */
1581 {
1582 /* Sanity check, direct open files can't have this */
1584
1585 /* Check if the extension is really present */
1586 if (FileObject->FileObjectExtension)
1587 {
1588 PFILE_OBJECT_EXTENSION FileObjectExtension;
1589
1590 /* Cast the buffer to something we understand */
1591 FileObjectExtension = FileObject->FileObjectExtension;
1592
1593 /* Check if have a valid replacement top level device */
1594 if (FileObjectExtension->TopDeviceObjectHint &&
1596 FileObjectExtension->TopDeviceObjectHint))
1597 {
1598 /* Use this instead of returning the top level device */
1599 return FileObjectExtension->TopDeviceObjectHint;
1600 }
1601 }
1602 }
1603
1604 /* Return the highest attached device */
1606 }
1607
1608 /* Return the DO we found */
1609 return DeviceObject;
1610}
1611
1612/*
1613 * @implemented
1614 */
1616NTAPI
1619{
1622
1623 /* Call the internal helper function */
1626 {
1627 *DeviceObject = DeviceNode->PhysicalDeviceObject;
1628 }
1629 return Status;
1630}
1631
1632/*
1633 * @implemented
1634 */
1636NTAPI
1638{
1640
1641 /*
1642 * If the FILE_OBJECT's VPB is defined,
1643 * get the device from it.
1644 */
1645 if ((FileObject->Vpb) && (FileObject->Vpb->DeviceObject))
1646 {
1647 /* Use the VPB's Device Object's */
1648 DeviceObject = FileObject->Vpb->DeviceObject;
1649 }
1650 else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) &&
1651 (FileObject->DeviceObject->Vpb) &&
1652 (FileObject->DeviceObject->Vpb->DeviceObject))
1653 {
1654 /* Use the VPB's File System Object */
1655 DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject;
1656 }
1657 else
1658 {
1659 /* Use the FO's Device Object */
1660 DeviceObject = FileObject->DeviceObject;
1661 }
1662
1663 /* Return the device object we found */
1665 return DeviceObject;
1666}
1667
1668/*
1669 * @implemented
1670 */
1672NTAPI
1674{
1676
1677 /* Allocate the shutdown entry */
1679 sizeof(SHUTDOWN_ENTRY),
1682
1683 /* Set the DO */
1684 Entry->DeviceObject = DeviceObject;
1685
1686 /* Reference it so it doesn't go away */
1688
1689 /* Insert it into the list */
1691 &Entry->ShutdownList,
1693
1694 /* Set the shutdown registered flag */
1696 return STATUS_SUCCESS;
1697}
1698
1699/*
1700 * @implemented
1701 */
1703NTAPI
1705{
1707
1708 /* Allocate the shutdown entry */
1710 sizeof(SHUTDOWN_ENTRY),
1713
1714 /* Set the DO */
1715 Entry->DeviceObject = DeviceObject;
1716
1717 /* Reference it so it doesn't go away */
1719
1720 /* Insert it into the list */
1722 &Entry->ShutdownList,
1724
1725 /* Set the shutdown registered flag */
1727 return STATUS_SUCCESS;
1728}
1729
1730/*
1731 * @implemented
1732 */
1733VOID
1734NTAPI
1736{
1737 PSHUTDOWN_ENTRY ShutdownEntry;
1738 PLIST_ENTRY NextEntry;
1739 KIRQL OldIrql;
1740
1741 /* Remove the flag */
1742 DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
1743
1744 /* Acquire the shutdown lock and loop the shutdown list */
1746 NextEntry = ShutdownListHead.Flink;
1747 while (NextEntry != &ShutdownListHead)
1748 {
1749 /* Get the entry */
1750 ShutdownEntry = CONTAINING_RECORD(NextEntry,
1752 ShutdownList);
1753
1754 /* Get if the DO matches */
1755 if (ShutdownEntry->DeviceObject == DeviceObject)
1756 {
1757 /* Remove it from the list */
1758 RemoveEntryList(NextEntry);
1759 NextEntry = NextEntry->Blink;
1760
1761 /* Free the entry */
1762 ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
1763
1764 /* Get rid of our reference to it */
1766 }
1767
1768 /* Go to the next entry */
1769 NextEntry = NextEntry->Flink;
1770 }
1771
1772 /* Now loop the last chance list */
1774 while (NextEntry != &LastChanceShutdownListHead)
1775 {
1776 /* Get the entry */
1777 ShutdownEntry = CONTAINING_RECORD(NextEntry,
1779 ShutdownList);
1780
1781 /* Get if the DO matches */
1782 if (ShutdownEntry->DeviceObject == DeviceObject)
1783 {
1784 /* Remove it from the list */
1785 RemoveEntryList(NextEntry);
1786 NextEntry = NextEntry->Blink;
1787
1788 /* Free the entry */
1789 ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
1790
1791 /* Get rid of our reference to it */
1793 }
1794
1795 /* Go to the next entry */
1796 NextEntry = NextEntry->Flink;
1797 }
1798
1799 /* Release the shutdown lock */
1801}
1802
1803/*
1804 * @implemented
1805 */
1806VOID
1807NTAPI
1809 IN BOOLEAN DeferredStartIo,
1810 IN BOOLEAN NonCancelable)
1811{
1812 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1813
1814 /* Get the Device Extension */
1815 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1816
1817 /* Set the flags the caller requested */
1818 DeviceExtension->StartIoFlags |= (DeferredStartIo) ? DOE_SIO_DEFERRED : 0;
1819 DeviceExtension->StartIoFlags |= (NonCancelable) ? DOE_SIO_NO_CANCEL : 0;
1820}
1821
1822/*
1823 * @implemented
1824 */
1825VOID
1826NTAPI
1829 IN ULONG Key)
1830{
1831 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1832
1833 /* Get the Device Extension */
1834 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1835
1836 /* Check if deferred start was requested */
1837 if (DeviceExtension->StartIoFlags & DOE_SIO_DEFERRED)
1838 {
1839 /* Call our internal function to handle the defered case */
1841 Key,
1844 }
1845 else
1846 {
1847 /* Call the normal routine */
1849 }
1850}
1851
1852/*
1853 * @implemented
1854 */
1855VOID
1856NTAPI
1859{
1860 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1861
1862 /* Get the Device Extension */
1863 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1864
1865 /* Check if deferred start was requested */
1866 if (DeviceExtension->StartIoFlags & DOE_SIO_DEFERRED)
1867 {
1868 /* Call our internal function to handle the defered case */
1870 0,
1873 }
1874 else
1875 {
1876 /* Call the normal routine */
1878 }
1879}
1880
1881/*
1882 * @implemented
1883 */
1884VOID
1885NTAPI
1887 IN PIRP Irp,
1888 IN PULONG Key,
1890{
1891 BOOLEAN Stat;
1892 KIRQL OldIrql, CancelIrql;
1893
1894 /* Raise to dispatch level */
1896
1897 /* Check if we should acquire the cancel lock */
1898 if (CancelFunction)
1899 {
1900 /* Acquire and set it */
1901 IoAcquireCancelSpinLock(&CancelIrql);
1902 Irp->CancelRoutine = CancelFunction;
1903 }
1904
1905 /* Check if we have a key */
1906 if (Key)
1907 {
1908 /* Insert by key */
1910 &Irp->Tail.Overlay.DeviceQueueEntry,
1911 *Key);
1912 }
1913 else
1914 {
1915 /* Insert without a key */
1916 Stat = KeInsertDeviceQueue(&DeviceObject->DeviceQueue,
1917 &Irp->Tail.Overlay.DeviceQueueEntry);
1918 }
1919
1920 /* Check if this was a first insert */
1921 if (!Stat)
1922 {
1923 /* Set the IRP */
1924 DeviceObject->CurrentIrp = Irp;
1925
1926 /* Check if this is a cancelable packet */
1927 if (CancelFunction)
1928 {
1929 /* Check if the caller requested no cancellation */
1930 if (IoGetDevObjExtension(DeviceObject)->StartIoFlags &
1932 {
1933 /* He did, so remove the cancel routine */
1934 Irp->CancelRoutine = NULL;
1935 }
1936
1937 /* Release the cancel lock */
1938 IoReleaseCancelSpinLock(CancelIrql);
1939 }
1940
1941 /* Call the Start I/O function */
1942 DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp);
1943 }
1944 else
1945 {
1946 /* The packet was inserted... check if we have a cancel function */
1947 if (CancelFunction)
1948 {
1949 /* Check if the IRP got cancelled */
1950 if (Irp->Cancel)
1951 {
1952 /*
1953 * Set the cancel IRQL, clear the currnet cancel routine and
1954 * call ours
1955 */
1956 Irp->CancelIrql = CancelIrql;
1957 Irp->CancelRoutine = NULL;
1959 }
1960 else
1961 {
1962 /* Otherwise, release the lock */
1963 IoReleaseCancelSpinLock(CancelIrql);
1964 }
1965 }
1966 }
1967
1968 /* Return back to previous IRQL */
1970}
1971
1972#if defined (_WIN64)
1973ULONG
1974NTAPI
1977{
1979 return 0;
1980}
1981#endif
1982
1983/* EOF */
#define PAGED_CODE()
#define ALIGN_UP_BY(size, align)
@ DeviceNode
Definition: Node.h:9
Type
Definition: Type.h:7
unsigned char BOOLEAN
Definition: actypes.h:127
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
@ Ace
Definition: card.h:12
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_In_z_ PCCHAR _In_ PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:983
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
_In_ PIRP Irp
Definition: csq.h:116
PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
Definition: devqueue.c:153
BOOLEAN NTAPI KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, IN ULONG SortKey)
Definition: devqueue.c:83
BOOLEAN NTAPI KeInsertDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry)
Definition: devqueue.c:41
VOID NTAPI KeInitializeDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
Definition: devqueue.c:22
PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN ULONG SortKey)
Definition: devqueue.c:197
#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:33
#define DEVICE_TYPE
Definition: guid.c:10
#define GENERIC_READ
Definition: compat.h:135
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
#define DOE_START_PENDING
Definition: boot.c:37
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define DO_SHUTDOWN_REGISTERED
Definition: env_spec_w32.h:403
struct _DEVICE_OBJECT DEVICE_OBJECT
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DO_EXCLUSIVE
Definition: env_spec_w32.h:395
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_DEVICE_HAS_NAME
Definition: env_spec_w32.h:398
#define NonPagedPool
Definition: env_spec_w32.h:307
ULONG ERESOURCE
Definition: env_spec_w32.h:594
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1544
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1676
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
_Outptr_ PDEVICE_OBJECT * DiskDeviceObject
Definition: fltkernel.h:1672
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
Status
Definition: gdiplustypes.h:25
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
PLIST_ENTRY NTAPI ExInterlockedInsertHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:114
PLIST_ENTRY NTAPI ExInterlockedRemoveHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:166
POBJECT_TYPE IoDeviceObjectType
Definition: iomgr.c:35
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define Stat
Definition: syshdrs.h:78
DeviceType
Definition: mmdrv.h:42
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define FILE_DEVICE_MASS_STORAGE
Definition: imports.h:60
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
#define DOE_SIO_WITH_KEY
Definition: iotypes.h:160
#define DOE_DELETE_PENDING
Definition: iotypes.h:150
#define DOE_SIO_DEFERRED
Definition: iotypes.h:162
#define DOE_SIO_NO_KEY
Definition: iotypes.h:159
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
#define IO_ATTACH_DEVICE_API
Definition: iotypes.h:219
#define DOE_REMOVE_PROCESSED
Definition: iotypes.h:152
#define DOE_SIO_NO_CANCEL
Definition: iotypes.h:163
#define DOE_UNLOAD_PENDING
Definition: iotypes.h:149
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
#define DOE_REMOVE_PENDING
Definition: iotypes.h:151
#define DOE_SIO_CANCELABLE
Definition: iotypes.h:161
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1625
NTSYSAPI NTSTATUS NTAPI RtlGetAce(PACL Acl, ULONG AceIndex, PVOID *Ace)
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
NTSYSAPI BOOLEAN NTAPI RtlEqualSid(_In_ PSID Sid1, _In_ PSID Sid2)
#define _Out_opt_
Definition: no_sal2.h:214
#define _In_
Definition: no_sal2.h:158
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GENERIC_EXECUTE
Definition: nt_native.h:91
#define MEMORY_ALLOCATION_ALIGNMENT
Definition: ntbasedef.h:90
@ NotificationEvent
@ SynchronizationEvent
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
enum _SECURITY_DESCRIPTOR_TYPE SECURITY_DESCRIPTOR_TYPE
VOID NTAPI IopRemoveTimerFromTimerList(IN PIO_TIMER Timer)
Definition: iotimer.c:70
@ RestrictedPublicOpen
Definition: io.h:515
@ RestrictedPublic
Definition: io.h:513
@ UnrestrictedPublicOpen
Definition: io.h:516
@ SystemDefault
Definition: io.h:517
@ UnrestrictedPublic
Definition: io.h:514
VOID NTAPI IopShutdownBaseFileSystems(IN PLIST_ENTRY ListHead)
Definition: volume.c:349
NTSTATUS NTAPI IopCreateVpb(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:158
NTSTATUS IopSynchronousCall(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IoStackLocation, OUT PVOID *Information)
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)
@ IopAdd
Definition: io.h:252
@ IopRemove
Definition: io.h:251
enum _IOP_DEVICE_LIST_OPERATION IOP_DEVICE_LIST_OPERATION
#define IoGetDevObjExtension(DeviceObject)
Definition: io.h:128
PACL SePublicOpenDacl
Definition: acl.c:19
PACL SePublicDefaultUnrestrictedDacl
Definition: acl.c:18
PACL SePublicOpenUnrestrictedDacl
Definition: acl.c:20
PSID SeAliasAdminsSid
Definition: sid.c:41
PSID SeWorldSid
Definition: sid.c:25
PSECURITY_DESCRIPTOR NTAPI IopCreateDefaultDeviceSecurityDescriptor(IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN HasDeviceName, IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PACL *OutputDacl, OUT PULONG OutputFlags)
Definition: device.c:779
NTSTATUS NTAPI IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT *DeviceObjectList, IN ULONG DeviceObjectListSize, OUT PULONG ActualNumberDeviceObjects)
Definition: device.c:1323
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:967
VOID NTAPI IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:391
PDEVICE_OBJECT NTAPI IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1518
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1032
LIST_ENTRY ShutdownListHead
Definition: device.c:21
NTSTATUS NTAPI IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, PDEVICE_OBJECT *AttachedDevice)
Definition: device.c:914
VOID NTAPI IopStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
Definition: device.c:487
VOID NTAPI IoStartPacket(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PULONG Key, IN PDRIVER_CANCEL CancelFunction)
Definition: device.c:1886
NTSTATUS NTAPI IopCreateSecurityDescriptorPerType(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN SECURITY_DESCRIPTOR_TYPE Type, OUT PULONG OutputFlags)
Definition: device.c:730
#define DACL_SET
Definition: device.c:28
NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:981
VOID NTAPI IopStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
Definition: device.c:536
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1549
BOOLEAN NTAPI IopVerifyDeviceObjectOnStack(IN PDEVICE_OBJECT BaseDeviceObject, IN PDEVICE_OBJECT TopDeviceObjectHint)
Definition: device.c:696
NTSTATUS NTAPI IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject, OUT PDEVICE_OBJECT *DiskDeviceObject)
Definition: device.c:1464
VOID NTAPI IopEditDeviceList(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN IOP_DEVICE_LIST_OPERATION Type)
Definition: device.c:335
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:463
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1704
NTSTATUS NTAPI IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1673
KSPIN_LOCK ShutdownListLock
Definition: device.c:22
LIST_ENTRY IopCdRomFileSystemQueueHead
Definition: volume.c:22
NTSTATUS NTAPI IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_NODE *DeviceNode)
Definition: device.c:654
NTSTATUS NTAPI IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1617
ERESOURCE IopDatabaseResource
Definition: volume.c:20
VOID NTAPI IoShutdownPnpDevices(VOID)
Definition: device.c:126
NTSTATUS NTAPI IopGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject, IN ULONG AttachFlag)
Definition: device.c:264
PDEVICE_OBJECT NTAPI IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1637
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1425
ULONG IopDeviceObjectNumber
Definition: device.c:20
VOID NTAPI IoShutdownSystem(IN ULONG Phase)
Definition: device.c:134
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1297
VOID NTAPI IoSetStartIoAttributes(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN DeferredStartIo, IN BOOLEAN NonCancelable)
Definition: device.c:1808
LIST_ENTRY LastChanceShutdownListHead
Definition: device.c:21
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1252
VOID NTAPI IopStartNextPacketByKeyEx(IN PDEVICE_OBJECT DeviceObject, IN ULONG Key, IN ULONG Flags)
Definition: device.c:584
VOID NTAPI IoStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
Definition: device.c:1827
static PDEVICE_OBJECT NTAPI IopAttachDeviceToDeviceStackSafe(_In_ PDEVICE_OBJECT SourceDevice, _In_ PDEVICE_OBJECT TargetDevice, _Out_opt_ PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:69
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1386
NTSTATUS NTAPI IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:948
PDEVICE_OBJECT NTAPI IopGetLowestDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:312
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1446
VOID NTAPI IopDeleteDevice(IN PVOID ObjectBody)
Definition: device.c:52
LIST_ENTRY IopDiskFileSystemQueueHead
Definition: volume.c:21
VOID NTAPI IopReadyDeviceObjects(IN PDRIVER_OBJECT Driver)
Definition: device.c:34
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1407
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1735
VOID NTAPI IoStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
Definition: device.c:1857
LIST_ENTRY IopTapeFileSystemQueueHead
Definition: volume.c:22
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1215
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1204
PACL SePublicDefaultDacl
Definition: acl.c:16
PACL SeSystemDefaultDacl
Definition: acl.c:17
#define STATUS_VOLUME_DISMOUNTED
Definition: ntstatus.h:869
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2935
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:1039
VOID NTAPI ObMakeTemporaryObject(IN PVOID ObjectBody)
Definition: oblife.c:1449
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
VOID NTAPI ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Count)
Definition: obsdcach.c:287
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
VOID NTAPI PoInitializeDeviceObject(IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension)
Definition: povolume.c:361
VOID NTAPI PoVolumeDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: povolume.c:81
VOID NTAPI PoRemoveVolumeDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: povolume.c:103
#define FILE_DEVICE_FILE_SYSTEM
Definition: winioctl.h:54
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:53
#define FILE_DEVICE_TAPE
Definition: winioctl.h:76
#define FILE_DEVICE_TAPE_FILE_SYSTEM
Definition: winioctl.h:77
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:47
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:48
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
Definition: winioctl.h:65
#define FILE_DEVICE_DFS_FILE_SYSTEM
Definition: winioctl.h:98
#define FILE_DEVICE_NETWORK
Definition: winioctl.h:63
#define FILE_DEVICE_DISK
Definition: winioctl.h:52
#define FILE_DEVICE_VIRTUAL_DISK
Definition: winioctl.h:81
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
#define OBJ_PERMANENT
Definition: winternl.h:226
Entry
Definition: section.c:5210
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:73
USHORT AclSize
Definition: ms-dtyp.idl:296
ULONG AlignmentRequirement
Definition: env_spec_w32.h:420
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2165
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2171
PDEVICE_OBJECT AttachedTo
Definition: iotypes.h:1092
PDEVICE_OBJECT TopDeviceObjectHint
Definition: io.h:102
Definition: ketypes.h:630
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: io.h:427
PDEVICE_OBJECT DeviceObject
Definition: io.h:429
Definition: iotypes.h:189
#define TAG_IO_TIMER
Definition: tag.h:93
#define TAG_SHUTDOWN_ENTRY
Definition: tag.h:58
#define STATUS_PENDING
Definition: telnetd.h:14
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#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 IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
_In_ WDFDEVICE _In_ ULONG DeviceCharacteristics
Definition: wdfdevice.h:2781
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:191
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT SourceDevice
Definition: iofuncs.h:690
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:691
#define IoWMIDeviceObjectToProviderId(DeviceObject)
_In_ BOOLEAN Cancelable
Definition: iofuncs.h:1258
_In_ PIRP _In_opt_ PULONG _In_opt_ PDRIVER_CANCEL CancelFunction
Definition: iofuncs.h:1277
@ TargetDeviceRelation
Definition: iotypes.h:2158
#define IO_TYPE_DEVICE
struct _DEVOBJ_EXTENSION * PDEVOBJ_EXTENSION
#define VPB_MOUNTED
Definition: iotypes.h:1807
DRIVER_CANCEL * PDRIVER_CANCEL
Definition: iotypes.h:2761
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define FO_DIRECT_DEVICE_OPEN
Definition: iotypes.h:1787
* PFILE_OBJECT
Definition: iotypes.h:1998
#define IO_TYPE_DEVICE_OBJECT_EXTENSION
#define DRVO_UNLOAD_INVOKED
Definition: iotypes.h:2227
#define IRP_MJ_SHUTDOWN
#define DRVO_INITIALIZED
Definition: iotypes.h:4473
#define DRVO_LEGACY_DRIVER
Definition: iotypes.h:2228
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:467
@ LockQueueIoDatabaseLock
Definition: ketypes.h:720
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58