ReactOS 0.4.17-dev-1218-gfae4549
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
63
64 /* Dereference the driver object, referenced in IoCreateDevice */
65 if (DeviceObject->DriverObject)
66 ObDereferenceObject(DeviceObject->DriverObject);
67}
68
69static PDEVICE_OBJECT
74 _Out_opt_ PDEVICE_OBJECT* AttachedToDeviceObject)
75{
76 PDEVICE_OBJECT AttachedDevice;
77 PEXTENDED_DEVOBJ_EXTENSION SourceDeviceExtension;
79
80 /* Lock the device list while attaching the device */
82
83 /* Get the attached device and source extension */
84 AttachedDevice = IoGetAttachedDevice(TargetDevice);
85 SourceDeviceExtension = IoGetDevObjExtension(SourceDevice);
86 ASSERT(SourceDeviceExtension->AttachedTo == NULL);
87
88 /* Make sure that it's in a correct state */
89 if ((AttachedDevice->Flags & DO_DEVICE_INITIALIZING) ||
90 (IoGetDevObjExtension(AttachedDevice)->ExtensionFlags &
93 {
94 /* The device is unloading or being removed */
95 AttachedDevice = NULL;
96 }
97 else
98 {
99 /* Update the attached device fields */
100 AttachedDevice->AttachedDevice = SourceDevice;
101 AttachedDevice->Spare1++;
102
103 /* Update the source with the attached data */
104 SourceDevice->StackSize = AttachedDevice->StackSize + 1;
106 SourceDevice->SectorSize = AttachedDevice->SectorSize;
107
108 /* Check for pending start flag and propagate it */
109 if (IoGetDevObjExtension(AttachedDevice)->ExtensionFlags & DOE_START_PENDING)
111
112 /* Set the attachment in the device extension */
113 SourceDeviceExtension->AttachedTo = AttachedDevice;
114 }
115
116 /* Return the attached device (under the lock) */
117 if (AttachedToDeviceObject)
118 *AttachedToDeviceObject = AttachedDevice;
119
120 /* Release the device list lock */
122
123 return AttachedDevice;
124}
125
126VOID
127NTAPI
129{
130 /* This routine is only used by Driver Verifier to validate shutdown */
131 return;
132}
133
134VOID
135NTAPI
137{
138 PLIST_ENTRY ListEntry;
140 PSHUTDOWN_ENTRY ShutdownEntry;
141 IO_STATUS_BLOCK StatusBlock;
142 PIRP Irp;
145
146 /* Initialize an event to wait on */
148
149 /* What phase? */
150 if (Phase == 0)
151 {
152 /* Shutdown PnP */
154
155 /* Loop first-chance shutdown notifications */
158 while (ListEntry)
159 {
160 /* Get the shutdown entry */
161 ShutdownEntry = CONTAINING_RECORD(ListEntry,
163 ShutdownList);
164
165 /* Get the attached device */
167
168 /* Build the shutdown IRP and call the driver */
171 NULL,
172 0,
173 NULL,
174 &Event,
175 &StatusBlock);
176 if (Irp)
177 {
179 if (Status == STATUS_PENDING)
180 {
181 /* Wait on the driver */
183 }
184 }
185
186 /* Remove the flag */
187 ShutdownEntry->DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
188
189 /* Get rid of our reference to it */
190 ObDereferenceObject(ShutdownEntry->DeviceObject);
191
192 /* Free the shutdown entry and reset the event */
195
196 /* Go to the next entry */
199 }
200 }
201 else if (Phase == 1)
202 {
203 /* Acquire resource forever */
205
206 /* Shutdown disk file systems */
208
209 /* Shutdown cdrom file systems */
211
212 /* Shutdown tape filesystems */
214
215 /* Loop last-chance shutdown notifications */
218 while (ListEntry)
219 {
220 /* Get the shutdown entry */
221 ShutdownEntry = CONTAINING_RECORD(ListEntry,
223 ShutdownList);
224
225 /* Get the attached device */
227
228 /* Build the shutdown IRP and call the driver */
231 NULL,
232 0,
233 NULL,
234 &Event,
235 &StatusBlock);
236 if (Irp)
237 {
239 if (Status == STATUS_PENDING)
240 {
241 /* Wait on the driver */
243 }
244 }
245
246 /* Remove the flag */
247 ShutdownEntry->DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
248
249 /* Get rid of our reference to it */
250 ObDereferenceObject(ShutdownEntry->DeviceObject);
251
252 /* Free the shutdown entry and reset the event */
255
256 /* Go to the next entry */
259 }
260
261 }
262}
263
265NTAPI
270 IN ULONG AttachFlag)
271{
273 IO_STATUS_BLOCK StatusBlock;
274 PFILE_OBJECT LocalFileObject;
277
278 /* Open the Device */
282 NULL,
283 NULL);
284
285 /* Honor the internal I/O System case (in)sensitivity */
287
291 &StatusBlock,
292 0,
293 FILE_NON_DIRECTORY_FILE | AttachFlag);
294 if (!NT_SUCCESS(Status)) return Status;
295
296 /* Get File Object */
298 0,
301 (PVOID*)&LocalFileObject,
302 NULL);
303 if (NT_SUCCESS(Status))
304 {
305 /* Return the requested data */
306 *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject);
307 *FileObject = LocalFileObject;
308 }
309
310 /* Close the handle */
312
313 return Status;
314}
315
317NTAPI
319{
320 PDEVICE_OBJECT LowestDevice;
321 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
322
323 /* Get the current device and its extension */
324 LowestDevice = DeviceObject;
325 DeviceExtension = IoGetDevObjExtension(LowestDevice);
326
327 /* Keep looping as long as we're attached */
328 while (DeviceExtension->AttachedTo)
329 {
330 /* Get the lowest device and its extension */
331 LowestDevice = DeviceExtension->AttachedTo;
332 DeviceExtension = IoGetDevObjExtension(LowestDevice);
333 }
334
335 /* Return the lowest device */
336 return LowestDevice;
337}
338
339VOID
340NTAPI
344{
345 PDEVICE_OBJECT Previous;
347
348 /* Lock the device list while we edit it */
350
351 /* Check the type of operation */
352 if (Type == IopRemove)
353 {
354 /* Get the current device and check if it's the current one */
355 Previous = DeviceObject->DriverObject->DeviceObject;
356 if (Previous == DeviceObject)
357 {
358 /* It is, simply unlink this one directly */
359 DeviceObject->DriverObject->DeviceObject =
360 DeviceObject->NextDevice;
361 }
362 else
363 {
364 /* It's not, so loop until we find the device */
365 while (Previous->NextDevice != DeviceObject)
366 {
367 /* Not this one, keep moving */
368 if (!Previous->NextDevice)
369 {
370 DPRINT1("Failed to remove PDO %p (not found)\n",
372
373 ASSERT(FALSE);
375 return;
376 }
377 Previous = Previous->NextDevice;
378 }
379
380 /* We found it, now unlink us */
381 Previous->NextDevice = DeviceObject->NextDevice;
382 }
383 }
384 else
385 {
386 /* Link the device object and the driver object */
387 DeviceObject->NextDevice = DriverObject->DeviceObject;
388 DriverObject->DeviceObject = DeviceObject;
389 }
390
391 /* Release the device list lock */
393}
394
395VOID
396NTAPI
398{
401
402 /* Check if deletion is pending */
403 if (ThisExtension->ExtensionFlags & DOE_DELETE_PENDING)
404 {
405 if (DeviceObject->AttachedDevice)
406 {
407 DPRINT("Device object is in the middle of a device stack\n");
408 return;
409 }
410
411 if (DeviceObject->ReferenceCount)
412 {
413 DPRINT("Device object still has %d references\n", DeviceObject->ReferenceCount);
414 return;
415 }
416
417 /* Check if we have a Security Descriptor */
418 if (DeviceObject->SecurityDescriptor)
419 {
420 /* Dereference it */
421 ObDereferenceSecurityDescriptor(DeviceObject->SecurityDescriptor, 1);
422 }
423
424 /* Remove the device from the list */
426
427 /* Dereference the keep-alive */
429 }
430
431 /* We can't unload a non-PnP driver here */
432 if (DriverObject->Flags & DRVO_LEGACY_DRIVER)
433 {
434 DPRINT("Not a PnP driver! '%wZ' will not be unloaded!\n", &DriverObject->DriverName);
435 return;
436 }
437
438 /* Return if we've already called unload (maybe we're in it?) */
439 if (DriverObject->Flags & DRVO_UNLOAD_INVOKED) return;
440
441 /* We can't unload unless there's an unload handler */
442 if (!DriverObject->DriverUnload)
443 {
444 DPRINT1("No DriverUnload function on PnP driver! '%wZ' will not be unloaded!\n", &DriverObject->DriverName);
445 return;
446 }
447
448 /* Bail if there are still devices present */
449 if (DriverObject->DeviceObject)
450 {
451 DPRINT("Devices still present! '%wZ' will not be unloaded!\n", &DriverObject->DriverName);
452 return;
453 }
454
455 DPRINT1("Unloading driver '%wZ' (automatic)\n", &DriverObject->DriverName);
456
457 /* Set the unload invoked flag */
459
460 /* Unload it */
461 DriverObject->DriverUnload(DriverObject);
462
463 /* Make object temporary so it can be deleted */
465}
466
467VOID
468NTAPI
470 IN BOOLEAN ForceUnload)
471{
472 /* Sanity check */
473 ASSERT(DeviceObject->ReferenceCount);
474
475 /* Dereference the device */
476 InterlockedDecrement(&DeviceObject->ReferenceCount);
477
478 /*
479 * Check if we can unload it and it's safe to unload (or if we're forcing
480 * an unload, which is OK too).
481 */
482 ASSERT(!ForceUnload);
483 if (!(DeviceObject->ReferenceCount) &&
485 {
486 /* Unload it */
488 }
489}
490
491VOID
492NTAPI
495 IN ULONG Key)
496{
498 PIRP Irp;
500
501 /* Acquire the cancel lock if this is cancelable */
503
504 /* Clear the current IRP */
505 DeviceObject->CurrentIrp = NULL;
506
507 /* Remove an entry from the queue */
509 if (Entry)
510 {
511 /* Get the IRP and set it */
512 Irp = CONTAINING_RECORD(Entry, IRP, Tail.Overlay.DeviceQueueEntry);
513 DeviceObject->CurrentIrp = Irp;
514
515 /* Check if this is a cancelable packet */
516 if (Cancelable)
517 {
518 /* Check if the caller requested no cancellation */
519 if (IoGetDevObjExtension(DeviceObject)->StartIoFlags &
521 {
522 /* He did, so remove the cancel routine */
523 Irp->CancelRoutine = NULL;
524 }
525
526 /* Release the cancel lock */
528 }
529
530 /* Call the Start I/O Routine */
531 DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp);
532 }
533 else
534 {
535 /* Otherwise, release the cancel lock if we had acquired it */
537 }
538}
539
540VOID
541NTAPI
544{
546 PIRP Irp;
548
549 /* Acquire the cancel lock if this is cancelable */
551
552 /* Clear the current IRP */
553 DeviceObject->CurrentIrp = NULL;
554
555 /* Remove an entry from the queue */
556 Entry = KeRemoveDeviceQueue(&DeviceObject->DeviceQueue);
557 if (Entry)
558 {
559 /* Get the IRP and set it */
560 Irp = CONTAINING_RECORD(Entry, IRP, Tail.Overlay.DeviceQueueEntry);
561 DeviceObject->CurrentIrp = Irp;
562
563 /* Check if this is a cancelable packet */
564 if (Cancelable)
565 {
566 /* Check if the caller requested no cancellation */
567 if (IoGetDevObjExtension(DeviceObject)->StartIoFlags &
569 {
570 /* He did, so remove the cancel routine */
571 Irp->CancelRoutine = NULL;
572 }
573
574 /* Release the cancel lock */
576 }
577
578 /* Call the Start I/O Routine */
579 DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp);
580 }
581 else
582 {
583 /* Otherwise, release the cancel lock if we had acquired it */
585 }
586}
587
588VOID
589NTAPI
591 IN ULONG Key,
592 IN ULONG Flags)
593{
594 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
595 ULONG CurrentKey = Key;
596 ULONG CurrentFlags = Flags;
597
598 /* Get the device extension and start the packet loop */
599 DeviceExtension = IoGetDevObjExtension(DeviceObject);
600 while (TRUE)
601 {
602 /* Increase the count */
603 if (InterlockedIncrement(&DeviceExtension->StartIoCount) > 1)
604 {
605 /*
606 * We've already called the routine once...
607 * All we have to do is save the key and add the new flags
608 */
609 DeviceExtension->StartIoFlags |= CurrentFlags;
610 DeviceExtension->StartIoKey = CurrentKey;
611 }
612 else
613 {
614 /* Mask out the current packet flags and key */
615 DeviceExtension->StartIoFlags &= ~(DOE_SIO_WITH_KEY |
618 DeviceExtension->StartIoKey = 0;
619
620 /* Check if this is a packet start with key */
622 {
623 /* Start the packet with a key */
626 TRUE : FALSE,
627 CurrentKey);
628 }
629 else if (Flags & DOE_SIO_NO_KEY)
630 {
631 /* Start the packet */
634 TRUE : FALSE);
635 }
636 }
637
638 /* Decrease the Start I/O count and check if it's 0 now */
639 if (!InterlockedDecrement(&DeviceExtension->StartIoCount))
640 {
641 /* Get the current active key and flags */
642 CurrentKey = DeviceExtension->StartIoKey;
643 CurrentFlags = DeviceExtension->StartIoFlags & (DOE_SIO_WITH_KEY |
646
647 /* Check if we should still loop */
648 if (!(CurrentFlags & (DOE_SIO_WITH_KEY | DOE_SIO_NO_KEY))) break;
649 }
650 else
651 {
652 /* There are still Start I/Os active, so quit this loop */
653 break;
654 }
655 }
656}
657
659NTAPI
662{
665 PDEVICE_RELATIONS DeviceRelations;
667
669
670 /* Get DeviceObject related to given FileObject */
673
674 /* Define input parameters */
675 Stack.MajorFunction = IRP_MJ_PNP;
676 Stack.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
677 Stack.Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;
678 Stack.FileObject = FileObject;
679
680 /* Call the driver to query all relations (IRP_MJ_PNP) */
682 &Stack,
683 (PVOID)&DeviceRelations);
684 if (!NT_SUCCESS(Status)) return Status;
685
686 /* Make sure it's not NULL and contains only one object */
687 ASSERT(DeviceRelations);
688 ASSERT(DeviceRelations->Count == 1);
689
690 /* Finally get the device node */
691 *DeviceNode = IopGetDeviceNode(DeviceRelations->Objects[0]);
693
694 /* Free the DEVICE_RELATIONS structure, it's not needed anymore */
695 ExFreePool(DeviceRelations);
696
697 return Status;
698}
699
701NTAPI
703 IN PDEVICE_OBJECT TopDeviceObjectHint)
704{
707 PDEVICE_OBJECT LoopObject;
708
709 ASSERT(BaseDeviceObject != NULL);
710
711 Result = FALSE;
712 /* Simply loop on the device stack and try to find our hint */
714 for (LoopObject = BaseDeviceObject; ; LoopObject = LoopObject->AttachedDevice)
715 {
716 /* It was found, it's a success */
717 if (LoopObject == TopDeviceObjectHint)
718 {
719 Result = TRUE;
720 break;
721 }
722
723 /* End of the stack, that's a failure - default */
724 if (LoopObject == NULL)
725 {
726 break;
727 }
728 }
730
731 return Result;
732}
733
735NTAPI
738 OUT PULONG OutputFlags)
739{
740 PACL Dacl;
742
743 /* Select the DACL the caller wants */
744 switch (Type)
745 {
746 case RestrictedPublic:
748 break;
749
752 break;
753
756 break;
757
760 break;
761
762 case SystemDefault:
764 break;
765
766 default:
767 ASSERT(FALSE);
769 }
770
771 /* Create the SD and set the DACL caller wanted */
775
776 /* We've set DACL */
777 if (OutputFlags) *OutputFlags |= DACL_SET;
778
779 /* Done */
780 return Status;
781}
782
784NTAPI
787 IN BOOLEAN HasDeviceName,
789 OUT PACL * OutputDacl,
790 OUT PULONG OutputFlags)
791{
792 PACL Dacl;
793 ULONG AceId;
796 BOOLEAN AdminsSet, WorldSet;
797
798 PAGED_CODE();
799
800 /* Zero our output vars */
801 if (OutputFlags) *OutputFlags = 0;
802
803 *OutputDacl = NULL;
804
805 /* For FSD, easy use SePublicDefaultUnrestrictedDacl */
810 {
813 OutputFlags);
814 goto Quit;
815 }
816 /* For storage devices with a name and floppy attribute,
817 * use SePublicOpenUnrestrictedDacl
818 */
827 {
830 OutputFlags);
831 goto Quit;
832 }
833
834 /* The rest...
835 * We will rely on SePublicDefaultUnrestrictedDacl as well
836 */
838 if (Dacl == NULL)
839 {
840 return NULL;
841 }
842
843 /* Copy our DACL */
845
846 /* Now, browse the DACL to make sure we have everything we want in them,
847 * including permissions
848 */
849 AceId = 0;
850 AdminsSet = FALSE;
851 WorldSet = FALSE;
852 while (NT_SUCCESS(RtlGetAce(Dacl, AceId, (PVOID *)&Ace)))
853 {
854 /* Admins must acess and in RWX, set it */
855 if (RtlEqualSid(SeAliasAdminsSid, &Ace->SidStart))
856 {
858 AdminsSet = TRUE;
859 }
860
861 /* World can read a CD_ROM device */
863 {
864 SetFlag(Ace->Mask, GENERIC_READ);
865 WorldSet = TRUE;
866 }
867
868 ++AceId;
869 }
870
871 /* AdminSid was present and set (otherwise, we have big trouble) */
872 ASSERT(AdminsSet);
873
874 /* If CD_ROM device, we've set world permissions */
875 if (DeviceType == FILE_DEVICE_CD_ROM) ASSERT(WorldSet);
876
877 /* Now our DACL is correct, setup the security descriptor */
880
881 /* We've set DACL */
882 if (OutputFlags) *OutputFlags |= DACL_SET;
883
884 /* Return DACL to allow later freeing */
885 *OutputDacl = Dacl;
887
888Quit:
889 /* Only return SD if we succeed */
890 if (!NT_SUCCESS(Status))
891 {
892 return NULL;
893 }
894
895 return SecurityDescriptor;
896}
897
898/* PUBLIC FUNCTIONS ***********************************************************/
899
900/*
901 * IoAttachDevice
902 *
903 * Layers a device over the highest device in a device stack.
904 *
905 * Parameters
906 * SourceDevice
907 * Device to be attached.
908 *
909 * TargetDevice
910 * Name of the target device.
911 *
912 * AttachedDevice
913 * Caller storage for the device attached to.
914 *
915 * Status
916 * @implemented
917 */
919NTAPI
921 PUNICODE_STRING TargetDeviceName,
922 PDEVICE_OBJECT *AttachedDevice)
923{
927
928 /* Call the helper routine for an attach operation */
929 Status = IopGetDeviceObjectPointer(TargetDeviceName,
931 &FileObject,
934 if (!NT_SUCCESS(Status)) return Status;
935
936 /* Attach the device */
939 AttachedDevice);
940
941 /* Dereference it */
943 return Status;
944}
945
946/*
947 * IoAttachDeviceByPointer
948 *
949 * Status
950 * @implemented
951 */
953NTAPI
956{
957 PDEVICE_OBJECT AttachedDevice;
959
960 /* Do the Attach */
962 if (!AttachedDevice) Status = STATUS_NO_SUCH_DEVICE;
963
964 /* Return the status */
965 return Status;
966}
967
968/*
969 * @implemented
970 */
972NTAPI
975{
976 /* Attach it safely */
979 NULL);
980}
981
982/*
983 * @implemented
984 */
986NTAPI
989 IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
990{
991 /* Call the internal function */
994 AttachedToDeviceObject))
995 {
996 /* Nothing found */
998 }
999
1000 /* Success! */
1001 return STATUS_SUCCESS;
1002}
1003
1004/*
1005 * IoCreateDevice
1006 *
1007 * Allocates memory for and intializes a device object for use for
1008 * a driver.
1009 *
1010 * Parameters
1011 * DriverObject
1012 * Driver object passed by IO Manager when the driver was loaded.
1013 *
1014 * DeviceExtensionSize
1015 * Number of bytes for the device extension.
1016 *
1017 * DeviceName
1018 * Unicode name of device.
1019 *
1020 * DeviceType
1021 * Device type of the new device.
1022 *
1023 * DeviceCharacteristics
1024 * Bit mask of device characteristics.
1025 *
1026 * Exclusive
1027 * TRUE if only one thread can access the device at a time.
1028 *
1029 * DeviceObject
1030 * On successful return this parameter is filled by pointer to
1031 * allocated device object.
1032 *
1033 * Status
1034 * @implemented
1035 */
1037NTAPI
1039 IN ULONG DeviceExtensionSize,
1045{
1046 WCHAR AutoNameBuffer[20];
1047 UNICODE_STRING AutoName;
1048 PDEVICE_OBJECT CreatedDeviceObject;
1049 PDEVOBJ_EXTENSION DeviceObjectExtension;
1052 ULONG AlignedDeviceExtensionSize;
1053 ULONG TotalSize;
1054 HANDLE TempHandle;
1055 PACL Dacl;
1057 PAGED_CODE();
1058
1059 /* Check if we have to generate a name */
1061 {
1062 /* Generate it */
1063 _swprintf(AutoNameBuffer,
1064 L"\\Device\\%08lx",
1066
1067 /* Initialize the name */
1068 RtlInitUnicodeString(&AutoName, AutoNameBuffer);
1069 DeviceName = &AutoName;
1070 }
1071
1072 /* Get the security descriptor */
1075 DeviceName != NULL,
1077 &Dacl,
1078 NULL);
1079
1080 /* Initialize the Object Attributes */
1082 DeviceName,
1084 NULL,
1085 ReturnedSD);
1086
1087 /* Honor the internal I/O System case (in)sensitivity */
1089
1090 /* Honor the exclusive flag */
1091 if (Exclusive) ObjectAttributes.Attributes |= OBJ_EXCLUSIVE;
1092
1093 /* Create a permanent object for named devices */
1094 if (DeviceName) ObjectAttributes.Attributes |= OBJ_PERMANENT;
1095
1096 /* Align the Extension Size to 8-bytes */
1097 AlignedDeviceExtensionSize = ALIGN_UP_BY(DeviceExtensionSize,
1099
1100 /* Total Size */
1101 TotalSize = AlignedDeviceExtensionSize +
1102 sizeof(DEVICE_OBJECT) +
1104
1105 /* Create the Device Object */
1106 *DeviceObject = NULL;
1110 KernelMode,
1111 NULL,
1112 TotalSize,
1113 0,
1114 0,
1115 (PVOID*)&CreatedDeviceObject);
1116 if (!NT_SUCCESS(Status))
1117 {
1118 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1119
1120 return Status;
1121 }
1122
1123 /* Clear the whole Object and extension so we don't null stuff manually */
1124 RtlZeroMemory(CreatedDeviceObject, TotalSize);
1125
1126 /*
1127 * Setup the Type and Size. Note that we don't use the aligned size,
1128 * because that's only padding for the DevObjExt and not part of the Object.
1129 */
1130 CreatedDeviceObject->Type = IO_TYPE_DEVICE;
1131 CreatedDeviceObject->Size = sizeof(DEVICE_OBJECT) + (USHORT)DeviceExtensionSize;
1132
1133 /* The kernel extension is after the driver internal extension */
1134 DeviceObjectExtension = (PDEVOBJ_EXTENSION)
1135 ((ULONG_PTR)(CreatedDeviceObject + 1) +
1136 AlignedDeviceExtensionSize);
1137
1138 /* Set the Type and Size. Question: why is Size 0 on Windows? */
1139 DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION;
1140 DeviceObjectExtension->Size = 0;
1141
1142 /* Initialize with Power Manager */
1143 PoInitializeDeviceObject(DeviceObjectExtension);
1144
1145 /* Link the Object and Extension */
1146 DeviceObjectExtension->DeviceObject = CreatedDeviceObject;
1147 CreatedDeviceObject->DeviceObjectExtension = DeviceObjectExtension;
1148
1149 /* Set Device Object Data */
1150 CreatedDeviceObject->DeviceType = DeviceType;
1151 CreatedDeviceObject->Characteristics = DeviceCharacteristics;
1152 CreatedDeviceObject->DeviceExtension = DeviceExtensionSize ?
1153 CreatedDeviceObject + 1 :
1154 NULL;
1155 CreatedDeviceObject->StackSize = 1;
1156 CreatedDeviceObject->AlignmentRequirement = 0;
1157
1158 /* Set the Flags */
1159 CreatedDeviceObject->Flags = DO_DEVICE_INITIALIZING;
1160 if (Exclusive) CreatedDeviceObject->Flags |= DO_EXCLUSIVE;
1161 if (DeviceName) CreatedDeviceObject->Flags |= DO_DEVICE_HAS_NAME;
1162
1163 /* Attach a Vpb for Disks and Tapes, and create the Device Lock */
1164 if ((CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK) ||
1165 (CreatedDeviceObject->DeviceType == FILE_DEVICE_VIRTUAL_DISK) ||
1166 (CreatedDeviceObject->DeviceType == FILE_DEVICE_CD_ROM) ||
1167 (CreatedDeviceObject->DeviceType == FILE_DEVICE_TAPE))
1168 {
1169 /* Create Vpb */
1170 Status = IopCreateVpb(CreatedDeviceObject);
1171 if (!NT_SUCCESS(Status))
1172 {
1173 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1174
1175 /* Dereference the device object and fail */
1176 ObDereferenceObject(CreatedDeviceObject);
1177 return Status;
1178 }
1179
1180 /* Initialize Lock Event */
1181 KeInitializeEvent(&CreatedDeviceObject->DeviceLock,
1183 TRUE);
1184 }
1185
1186 /* Set the right Sector Size */
1187 switch (DeviceType)
1188 {
1189 /* All disk systems */
1191 case FILE_DEVICE_DISK:
1193
1194 /* The default is 512 bytes */
1195 CreatedDeviceObject->SectorSize = 512;
1196 break;
1197
1198 /* CD-ROM file systems */
1200
1201 /* The default is 2048 bytes */
1202 CreatedDeviceObject->SectorSize = 2048;
1203 }
1204
1205 /* Create the Device Queue */
1206 if ((CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) ||
1207 (CreatedDeviceObject->DeviceType == FILE_DEVICE_FILE_SYSTEM) ||
1208 (CreatedDeviceObject->DeviceType == FILE_DEVICE_CD_ROM_FILE_SYSTEM) ||
1209 (CreatedDeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) ||
1210 (CreatedDeviceObject->DeviceType == FILE_DEVICE_TAPE_FILE_SYSTEM))
1211 {
1212 /* Simple FS Devices, they don't need a real Device Queue */
1213 InitializeListHead(&CreatedDeviceObject->Queue.ListEntry);
1214 }
1215 else
1216 {
1217 /* An actual Device, initialize its DQ */
1218 KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue);
1219 }
1220
1221 /* Insert the Object */
1222 Status = ObInsertObject(CreatedDeviceObject,
1223 NULL,
1225 1,
1226 (PVOID*)&CreatedDeviceObject,
1227 &TempHandle);
1228 if (!NT_SUCCESS(Status))
1229 {
1230 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1231
1232 return Status;
1233 }
1234
1235 /* Now do the final linking */
1237 ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0);
1238 CreatedDeviceObject->DriverObject = DriverObject;
1239 IopEditDeviceList(DriverObject, CreatedDeviceObject, IopAdd);
1240
1241 /* Link with the power manager */
1242 if (CreatedDeviceObject->Vpb) PoVolumeDevice(CreatedDeviceObject);
1243
1244 /* Close the temporary handle and return to caller */
1245 ObCloseHandle(TempHandle, KernelMode);
1246 *DeviceObject = CreatedDeviceObject;
1247
1248 if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
1249
1250 return STATUS_SUCCESS;
1251}
1252
1253/*
1254 * IoDeleteDevice
1255 *
1256 * Status
1257 * @implemented
1258 */
1259VOID
1260NTAPI
1262{
1264
1265 /* Check if the device is registered for shutdown notifications */
1267 {
1268 /* Call the shutdown notifications */
1270 }
1271
1272 /* Check if it has a timer */
1274 if (Timer)
1275 {
1276 /* Remove it and free it */
1279 }
1280
1281 /* Check if the device has a name */
1282 if (DeviceObject->Flags & DO_DEVICE_HAS_NAME)
1283 {
1284 /* It does, make it temporary so we can remove it */
1286 }
1287
1288 /* Set the pending delete flag */
1290
1291 /* Unlink with the power manager */
1293
1294 /* Check if the device object can be unloaded */
1295 if (!DeviceObject->ReferenceCount) IopUnloadDevice(DeviceObject);
1296}
1297
1298/*
1299 * IoDetachDevice
1300 *
1301 * Status
1302 * @implemented
1303 */
1304VOID
1305NTAPI
1307{
1308 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1309
1310 /* Sanity check */
1311 DeviceExtension = IoGetDevObjExtension(TargetDevice->AttachedDevice);
1312 ASSERT(DeviceExtension->AttachedTo == TargetDevice);
1313
1314 /* Remove the attachment */
1315 DeviceExtension->AttachedTo = NULL;
1316 TargetDevice->AttachedDevice = NULL;
1317
1318 /* Check if it's ok to delete this device */
1319 if ((IoGetDevObjExtension(TargetDevice)->ExtensionFlags & DOE_DELETE_PENDING) &&
1320 !(TargetDevice->ReferenceCount))
1321 {
1322 /* It is, do it */
1324 }
1325}
1326
1327/*
1328 * @implemented
1329 */
1331NTAPI
1333 IN PDEVICE_OBJECT *DeviceObjectList,
1334 IN ULONG DeviceObjectListSize,
1335 OUT PULONG ActualNumberDeviceObjects)
1336{
1337 ULONG ActualDevices = 1;
1338 PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject;
1339 KIRQL OldIrql;
1340
1341 /* Lock the device list while we enumerate it */
1343
1344 /* Find out how many devices we'll enumerate */
1345 while ((CurrentDevice = CurrentDevice->NextDevice)) ActualDevices++;
1346
1347 /* Go back to the first */
1348 CurrentDevice = DriverObject->DeviceObject;
1349
1350 /* Start by at least returning this */
1351 *ActualNumberDeviceObjects = ActualDevices;
1352
1353 /* Check if we can support so many */
1354 if ((ActualDevices * sizeof(PDEVICE_OBJECT)) > DeviceObjectListSize)
1355 {
1356 /* Fail because the buffer was too small */
1359 }
1360
1361 /* Check if the caller wanted the device list */
1362 if (DeviceObjectList)
1363 {
1364 /* Loop through all the devices */
1365 while (ActualDevices)
1366 {
1367 /* Reference each Device */
1368 ObReferenceObject(CurrentDevice);
1369
1370 /* Add it to the list */
1371 *DeviceObjectList = CurrentDevice;
1372
1373 /* Go to the next one */
1374 CurrentDevice = CurrentDevice->NextDevice;
1375 ActualDevices--;
1376 DeviceObjectList++;
1377 }
1378 }
1379
1380 /* Release the device list lock */
1382
1383 /* Return the status */
1384 return STATUS_SUCCESS;
1385}
1386
1387/*
1388 * IoGetAttachedDevice
1389 *
1390 * Status
1391 * @implemented
1392 */
1394NTAPI
1396{
1397 /* Get the last attached device */
1398 while (DeviceObject->AttachedDevice)
1399 {
1400 /* Move to the next one */
1401 DeviceObject = DeviceObject->AttachedDevice;
1402 }
1403
1404 /* Return it */
1405 return DeviceObject;
1406}
1407
1408/*
1409 * IoGetAttachedDeviceReference
1410 *
1411 * Status
1412 * @implemented
1413 */
1415NTAPI
1417{
1418 KIRQL OldIrql;
1419
1420 /* Retrieve and reference the attached device under the device list lock */
1425
1426 return DeviceObject;
1427}
1428
1429/*
1430 * @implemented
1431 */
1433NTAPI
1435{
1436 KIRQL OldIrql;
1437
1438 /* Retrieve and reference the lowest attached device under the device list lock */
1443
1444 return DeviceObject;
1445}
1446
1447/*
1448 * IoGetDeviceObjectPointer
1449 *
1450 * Status
1451 * @implemented
1452 */
1454NTAPI
1459{
1460 /* Call the helper routine for a normal operation */
1463 FileObject,
1465 0);
1466}
1467
1468/*
1469 * @implemented
1470 */
1472NTAPI
1475{
1476 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1477 PVPB Vpb;
1478 KIRQL OldIrql;
1480
1481 /* Make sure there's a VPB */
1482 if (!FileSystemDeviceObject->Vpb) return STATUS_INVALID_PARAMETER;
1483
1484 /* Acquire it */
1486
1487 /* Get the Device Extension */
1488 DeviceExtension = IoGetDevObjExtension(FileSystemDeviceObject);
1489
1490 /* Make sure this one has a VPB too */
1491 Vpb = DeviceExtension->Vpb;
1492 if (Vpb)
1493 {
1494 /* Make sure that it's mounted */
1495 if ((Vpb->ReferenceCount) &&
1496 (Vpb->Flags & VPB_MOUNTED))
1497 {
1498 /* Return the Disk Device Object */
1499 *DiskDeviceObject = Vpb->RealDevice;
1500
1501 /* Reference it and return success */
1502 ObReferenceObject(Vpb->RealDevice);
1504 }
1505 else
1506 {
1507 /* It's not, so return failure */
1509 }
1510 }
1511 else
1512 {
1513 /* Fail */
1515 }
1516
1517 /* Release the lock */
1519 return Status;
1520}
1521
1522/*
1523 * @implemented
1524 */
1526NTAPI
1528{
1529 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1531
1532 /* Make sure it's not getting deleted */
1533 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1534 if (!(DeviceExtension->ExtensionFlags &
1537 {
1538 /* Get the Lower Device Object */
1539 LowerDeviceObject = DeviceExtension->AttachedTo;
1540
1541 /* Check that we got a valid device object */
1543 {
1544 /* We did so let's reference it */
1546 }
1547 }
1548
1549 /* Return it */
1550 return LowerDeviceObject;
1551}
1552
1553/*
1554 * @implemented
1555 */
1557NTAPI
1559{
1560 PDEVICE_OBJECT DeviceObject = FileObject->DeviceObject;
1561
1562 /* Check if we have a VPB with a device object */
1563 if ((FileObject->Vpb) && (FileObject->Vpb->DeviceObject))
1564 {
1565 /* Then use the DO from the VPB */
1567 DeviceObject = FileObject->Vpb->DeviceObject;
1568 }
1569 else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) &&
1570 (FileObject->DeviceObject->Vpb) &&
1571 (FileObject->DeviceObject->Vpb->DeviceObject))
1572 {
1573 /* The disk device actually has a VPB, so get the DO from there */
1574 DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject;
1575 }
1576 else
1577 {
1578 /* Otherwise, this was a direct open */
1579 DeviceObject = FileObject->DeviceObject;
1580 }
1581
1582 /* Sanity check */
1584
1585 /* Check if we were attached */
1586 if (DeviceObject->AttachedDevice)
1587 {
1588 /* Check if the file object has an extension present */
1590 {
1591 /* Sanity check, direct open files can't have this */
1593
1594 /* Check if the extension is really present */
1595 if (FileObject->FileObjectExtension)
1596 {
1597 PFILE_OBJECT_EXTENSION FileObjectExtension;
1598
1599 /* Cast the buffer to something we understand */
1600 FileObjectExtension = FileObject->FileObjectExtension;
1601
1602 /* Check if have a valid replacement top level device */
1603 if (FileObjectExtension->TopDeviceObjectHint &&
1605 FileObjectExtension->TopDeviceObjectHint))
1606 {
1607 /* Use this instead of returning the top level device */
1608 return FileObjectExtension->TopDeviceObjectHint;
1609 }
1610 }
1611 }
1612
1613 /* Return the highest attached device */
1615 }
1616
1617 /* Return the DO we found */
1618 return DeviceObject;
1619}
1620
1621/*
1622 * @implemented
1623 */
1625NTAPI
1628{
1631
1632 /* Call the internal helper function */
1635 {
1636 *DeviceObject = DeviceNode->PhysicalDeviceObject;
1637 }
1638 return Status;
1639}
1640
1641/*
1642 * @implemented
1643 */
1645NTAPI
1647{
1649
1650 /*
1651 * If the FILE_OBJECT's VPB is defined,
1652 * get the device from it.
1653 */
1654 if ((FileObject->Vpb) && (FileObject->Vpb->DeviceObject))
1655 {
1656 /* Use the VPB's Device Object's */
1657 DeviceObject = FileObject->Vpb->DeviceObject;
1658 }
1659 else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) &&
1660 (FileObject->DeviceObject->Vpb) &&
1661 (FileObject->DeviceObject->Vpb->DeviceObject))
1662 {
1663 /* Use the VPB's File System Object */
1664 DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject;
1665 }
1666 else
1667 {
1668 /* Use the FO's Device Object */
1669 DeviceObject = FileObject->DeviceObject;
1670 }
1671
1672 /* Return the device object we found */
1674 return DeviceObject;
1675}
1676
1677/*
1678 * @implemented
1679 */
1681NTAPI
1683{
1685
1686 /* Allocate the shutdown entry */
1688 sizeof(SHUTDOWN_ENTRY),
1691
1692 /* Set the DO */
1693 Entry->DeviceObject = DeviceObject;
1694
1695 /* Reference it so it doesn't go away */
1697
1698 /* Insert it into the list */
1700 &Entry->ShutdownList,
1702
1703 /* Set the shutdown registered flag */
1705 return STATUS_SUCCESS;
1706}
1707
1708/*
1709 * @implemented
1710 */
1712NTAPI
1714{
1716
1717 /* Allocate the shutdown entry */
1719 sizeof(SHUTDOWN_ENTRY),
1722
1723 /* Set the DO */
1724 Entry->DeviceObject = DeviceObject;
1725
1726 /* Reference it so it doesn't go away */
1728
1729 /* Insert it into the list */
1731 &Entry->ShutdownList,
1733
1734 /* Set the shutdown registered flag */
1736 return STATUS_SUCCESS;
1737}
1738
1739/*
1740 * @implemented
1741 */
1742VOID
1743NTAPI
1745{
1746 PSHUTDOWN_ENTRY ShutdownEntry;
1747 PLIST_ENTRY NextEntry;
1748 KIRQL OldIrql;
1749
1750 /* Remove the flag */
1751 DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED;
1752
1753 /* Acquire the shutdown lock and loop the shutdown list */
1755 NextEntry = ShutdownListHead.Flink;
1756 while (NextEntry != &ShutdownListHead)
1757 {
1758 /* Get the entry */
1759 ShutdownEntry = CONTAINING_RECORD(NextEntry,
1761 ShutdownList);
1762
1763 /* Get if the DO matches */
1764 if (ShutdownEntry->DeviceObject == DeviceObject)
1765 {
1766 /* Remove it from the list */
1767 RemoveEntryList(NextEntry);
1768 NextEntry = NextEntry->Blink;
1769
1770 /* Free the entry */
1771 ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
1772
1773 /* Get rid of our reference to it */
1775 }
1776
1777 /* Go to the next entry */
1778 NextEntry = NextEntry->Flink;
1779 }
1780
1781 /* Now loop the last chance list */
1783 while (NextEntry != &LastChanceShutdownListHead)
1784 {
1785 /* Get the entry */
1786 ShutdownEntry = CONTAINING_RECORD(NextEntry,
1788 ShutdownList);
1789
1790 /* Get if the DO matches */
1791 if (ShutdownEntry->DeviceObject == DeviceObject)
1792 {
1793 /* Remove it from the list */
1794 RemoveEntryList(NextEntry);
1795 NextEntry = NextEntry->Blink;
1796
1797 /* Free the entry */
1798 ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
1799
1800 /* Get rid of our reference to it */
1802 }
1803
1804 /* Go to the next entry */
1805 NextEntry = NextEntry->Flink;
1806 }
1807
1808 /* Release the shutdown lock */
1810}
1811
1812/*
1813 * @implemented
1814 */
1815VOID
1816NTAPI
1818 IN BOOLEAN DeferredStartIo,
1819 IN BOOLEAN NonCancelable)
1820{
1821 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1822
1823 /* Get the Device Extension */
1824 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1825
1826 /* Set the flags the caller requested */
1827 DeviceExtension->StartIoFlags |= (DeferredStartIo) ? DOE_SIO_DEFERRED : 0;
1828 DeviceExtension->StartIoFlags |= (NonCancelable) ? DOE_SIO_NO_CANCEL : 0;
1829}
1830
1831/*
1832 * @implemented
1833 */
1834VOID
1835NTAPI
1838 IN ULONG Key)
1839{
1840 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1841
1842 /* Get the Device Extension */
1843 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1844
1845 /* Check if deferred start was requested */
1846 if (DeviceExtension->StartIoFlags & DOE_SIO_DEFERRED)
1847 {
1848 /* Call our internal function to handle the defered case */
1850 Key,
1853 }
1854 else
1855 {
1856 /* Call the normal routine */
1858 }
1859}
1860
1861/*
1862 * @implemented
1863 */
1864VOID
1865NTAPI
1868{
1869 PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
1870
1871 /* Get the Device Extension */
1872 DeviceExtension = IoGetDevObjExtension(DeviceObject);
1873
1874 /* Check if deferred start was requested */
1875 if (DeviceExtension->StartIoFlags & DOE_SIO_DEFERRED)
1876 {
1877 /* Call our internal function to handle the defered case */
1879 0,
1882 }
1883 else
1884 {
1885 /* Call the normal routine */
1887 }
1888}
1889
1890/*
1891 * @implemented
1892 */
1893VOID
1894NTAPI
1896 IN PIRP Irp,
1897 IN PULONG Key,
1899{
1900 BOOLEAN Stat;
1901 KIRQL OldIrql, CancelIrql;
1902
1903 /* Raise to dispatch level */
1905
1906 /* Check if we should acquire the cancel lock */
1907 if (CancelFunction)
1908 {
1909 /* Acquire and set it */
1910 IoAcquireCancelSpinLock(&CancelIrql);
1911 Irp->CancelRoutine = CancelFunction;
1912 }
1913
1914 /* Check if we have a key */
1915 if (Key)
1916 {
1917 /* Insert by key */
1919 &Irp->Tail.Overlay.DeviceQueueEntry,
1920 *Key);
1921 }
1922 else
1923 {
1924 /* Insert without a key */
1925 Stat = KeInsertDeviceQueue(&DeviceObject->DeviceQueue,
1926 &Irp->Tail.Overlay.DeviceQueueEntry);
1927 }
1928
1929 /* Check if this was a first insert */
1930 if (!Stat)
1931 {
1932 /* Set the IRP */
1933 DeviceObject->CurrentIrp = Irp;
1934
1935 /* Check if this is a cancelable packet */
1936 if (CancelFunction)
1937 {
1938 /* Check if the caller requested no cancellation */
1939 if (IoGetDevObjExtension(DeviceObject)->StartIoFlags &
1941 {
1942 /* He did, so remove the cancel routine */
1943 Irp->CancelRoutine = NULL;
1944 }
1945
1946 /* Release the cancel lock */
1947 IoReleaseCancelSpinLock(CancelIrql);
1948 }
1949
1950 /* Call the Start I/O function */
1951 DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp);
1952 }
1953 else
1954 {
1955 /* The packet was inserted... check if we have a cancel function */
1956 if (CancelFunction)
1957 {
1958 /* Check if the IRP got cancelled */
1959 if (Irp->Cancel)
1960 {
1961 /*
1962 * Set the cancel IRQL, clear the currnet cancel routine and
1963 * call ours
1964 */
1965 Irp->CancelIrql = CancelIrql;
1966 Irp->CancelRoutine = NULL;
1968 }
1969 else
1970 {
1971 /* Otherwise, release the lock */
1972 IoReleaseCancelSpinLock(CancelIrql);
1973 }
1974 }
1975 }
1976
1977 /* Return back to previous IRQL */
1979}
1980
1981#if defined (_WIN64)
1982ULONG
1983NTAPI
1986{
1988 return 0;
1989}
1990#endif
1991
1992/* 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
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
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
#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 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:24
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
_In_ PIRP Irp
Definition: kse.h:79
#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 _swprintf(buf, format,...)
Definition: sprintf.c:56
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
#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:164
#define DOE_DELETE_PENDING
Definition: iotypes.h:154
#define DOE_SIO_DEFERRED
Definition: iotypes.h:166
#define DOE_SIO_NO_KEY
Definition: iotypes.h:163
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:148
#define IO_ATTACH_DEVICE_API
Definition: iotypes.h:223
#define DOE_REMOVE_PROCESSED
Definition: iotypes.h:156
#define DOE_SIO_NO_CANCEL
Definition: iotypes.h:167
#define DOE_UNLOAD_PENDING
Definition: iotypes.h:153
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:142
#define DOE_REMOVE_PENDING
Definition: iotypes.h:155
#define DOE_SIO_CANCELABLE
Definition: iotypes.h:165
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
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
ULONG ACCESS_MASK
Definition: nt_native.h:40
#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
ULONG IopCaseInsensitive
Definition: iomgr.c:38
@ 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
VOID PiPropReleaseDevice(_In_ PDEVICE_OBJECT DeviceObject)
Definition: pnpprop.c:1731
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:785
NTSTATUS NTAPI IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT *DeviceObjectList, IN ULONG DeviceObjectListSize, OUT PULONG ActualNumberDeviceObjects)
Definition: device.c:1332
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:973
VOID NTAPI IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:397
PDEVICE_OBJECT NTAPI IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1527
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:1038
LIST_ENTRY ShutdownListHead
Definition: device.c:21
NTSTATUS NTAPI IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, PDEVICE_OBJECT *AttachedDevice)
Definition: device.c:920
VOID NTAPI IopStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
Definition: device.c:493
VOID NTAPI IoStartPacket(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PULONG Key, IN PDRIVER_CANCEL CancelFunction)
Definition: device.c:1895
NTSTATUS NTAPI IopCreateSecurityDescriptorPerType(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN SECURITY_DESCRIPTOR_TYPE Type, OUT PULONG OutputFlags)
Definition: device.c:736
#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:987
VOID NTAPI IopStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
Definition: device.c:542
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1558
BOOLEAN NTAPI IopVerifyDeviceObjectOnStack(IN PDEVICE_OBJECT BaseDeviceObject, IN PDEVICE_OBJECT TopDeviceObjectHint)
Definition: device.c:702
NTSTATUS NTAPI IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject, OUT PDEVICE_OBJECT *DiskDeviceObject)
Definition: device.c:1473
VOID NTAPI IopEditDeviceList(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN IOP_DEVICE_LIST_OPERATION Type)
Definition: device.c:341
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:469
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1713
NTSTATUS NTAPI IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1682
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:660
NTSTATUS NTAPI IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1626
ERESOURCE IopDatabaseResource
Definition: volume.c:20
VOID NTAPI IoShutdownPnpDevices(VOID)
Definition: device.c:128
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:266
PDEVICE_OBJECT NTAPI IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1646
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1434
ULONG IopDeviceObjectNumber
Definition: device.c:20
VOID NTAPI IoShutdownSystem(IN ULONG Phase)
Definition: device.c:136
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1306
VOID NTAPI IoSetStartIoAttributes(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN DeferredStartIo, IN BOOLEAN NonCancelable)
Definition: device.c:1817
LIST_ENTRY LastChanceShutdownListHead
Definition: device.c:21
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261
VOID NTAPI IopStartNextPacketByKeyEx(IN PDEVICE_OBJECT DeviceObject, IN ULONG Key, IN ULONG Flags)
Definition: device.c:590
VOID NTAPI IoStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
Definition: device.c:1836
static PDEVICE_OBJECT NTAPI IopAttachDeviceToDeviceStackSafe(_In_ PDEVICE_OBJECT SourceDevice, _In_ PDEVICE_OBJECT TargetDevice, _Out_opt_ PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:71
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1395
NTSTATUS NTAPI IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:954
PDEVICE_OBJECT NTAPI IopGetLowestDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:318
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1455
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:1416
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1744
VOID NTAPI IoStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
Definition: device.c:1866
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:1101
#define IoCallDriver
Definition: irp.c:1257
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:3411
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:2962
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:1049
VOID NTAPI ObMakeTemporaryObject(IN PVOID ObjectBody)
Definition: oblife.c:1459
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:493
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_CASE_INSENSITIVE
Definition: winternl.h:228
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
#define OBJ_PERMANENT
Definition: winternl.h:226
Entry
Definition: section.c:5216
#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:1096
PDEVICE_OBJECT TopDeviceObjectHint
Definition: io.h:102
Definition: ketypes.h:646
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:94
#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
_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:2774
#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:2240
#define IRP_MJ_SHUTDOWN
#define DRVO_INITIALIZED
Definition: iotypes.h:4486
#define DRVO_LEGACY_DRIVER
Definition: iotypes.h:2241
_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:736
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58