91 AttachedDevice =
NULL;
97 AttachedDevice->Spare1++;
115 SourceDeviceExtension->
AttachedTo = AttachedDevice;
119 if (AttachedToDeviceObject) *AttachedToDeviceObject = AttachedDevice;
120 return AttachedDevice;
294 (
PVOID*)&LocalFileObject,
361 if (!Previous->NextDevice)
363 DPRINT1(
"Failed to remove PDO %p (not found)\n",
370 Previous = Previous->NextDevice;
400 DPRINT(
"Device object is in the middle of a device stack\n");
437 DPRINT1(
"No DriverUnload function on PnP driver! '%wZ' will not be unloaded!\n", &
DriverObject->DriverName);
444 DPRINT(
"Devices still present! '%wZ' will not be unloaded!\n", &
DriverObject->DriverName);
676 (
PVOID)&DeviceRelations);
707 for (LoopObject = BaseDeviceObject; ; LoopObject = LoopObject->AttachedDevice)
710 if (LoopObject == TopDeviceObjectHint)
717 if (LoopObject ==
NULL)
770 if (OutputFlags) *OutputFlags |=
DACL_SET;
794 if (OutputFlags) *OutputFlags = 0;
875 if (OutputFlags) *OutputFlags |=
DACL_SET;
987 AttachedToDeviceObject))
1039 WCHAR AutoNameBuffer[20];
1045 ULONG AlignedDeviceExtensionSize;
1087 AlignedDeviceExtensionSize =
ALIGN_UP_BY(DeviceExtensionSize,
1091 TotalSize = AlignedDeviceExtensionSize +
1105 (
PVOID*)&CreatedDeviceObject);
1126 AlignedDeviceExtensionSize);
1130 DeviceObjectExtension->
Size = 0;
1136 DeviceObjectExtension->
DeviceObject = CreatedDeviceObject;
1137 CreatedDeviceObject->DeviceObjectExtension = DeviceObjectExtension;
1140 CreatedDeviceObject->DeviceType =
DeviceType;
1143 CreatedDeviceObject + 1 :
1185 CreatedDeviceObject->SectorSize = 512;
1192 CreatedDeviceObject->SectorSize = 2048;
1216 (
PVOID*)&CreatedDeviceObject,
1232 if (CreatedDeviceObject->Vpb)
PoVolumeDevice(CreatedDeviceObject);
1324 IN ULONG DeviceObjectListSize,
1327 ULONG ActualDevices = 1;
1335 while ((CurrentDevice = CurrentDevice->NextDevice)) ActualDevices++;
1341 *ActualNumberDeviceObjects = ActualDevices;
1344 if ((ActualDevices *
sizeof(
PDEVICE_OBJECT)) > DeviceObjectListSize)
1352 if (DeviceObjectList)
1355 while (ActualDevices)
1361 *DeviceObjectList = CurrentDevice;
1364 CurrentDevice = CurrentDevice->NextDevice;
1471 Vpb = DeviceExtension->
Vpb;
1475 if ((
Vpb->ReferenceCount) &&
1552 (
FileObject->DeviceObject->Vpb->DeviceObject))
1581 FileObjectExtension =
FileObject->FileObjectExtension;
1642 (
FileObject->DeviceObject->Vpb->DeviceObject))
1681 &
Entry->ShutdownList,
1712 &
Entry->ShutdownList,
1749 NextEntry = NextEntry->
Blink;
1759 NextEntry = NextEntry->
Flink;
1776 NextEntry = NextEntry->
Blink;
1786 NextEntry = NextEntry->
Flink;
1900 &
Irp->Tail.Overlay.DeviceQueueEntry,
1907 &
Irp->Tail.Overlay.DeviceQueueEntry);
1946 Irp->CancelIrql = CancelIrql;
#define ALIGN_UP_BY(size, align)
#define InterlockedIncrement
#define InterlockedDecrement
#define FILE_NON_DIRECTORY_FILE
_In_z_ PCCHAR _In_ PDEVICE_OBJECT LowerDeviceObject
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
BOOLEAN NTAPI KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, IN ULONG SortKey)
BOOLEAN NTAPI KeInsertDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry)
VOID NTAPI KeInitializeDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN ULONG SortKey)
#define NT_SUCCESS(StatCode)
#define DOE_START_PENDING
#define RemoveEntryList(Entry)
#define DO_SHUTDOWN_REGISTERED
struct _DEVICE_OBJECT DEVICE_OBJECT
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeRaiseIrql(irql, oldIrql)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeReleaseSpinLock(sl, irql)
#define KeLowerIrql(oldIrql)
#define KeAcquireSpinLock(sl, irql)
#define ExAcquireResourceExclusiveLite(res, wait)
#define DO_DEVICE_INITIALIZING
#define DO_DEVICE_HAS_NAME
#define InitializeListHead(ListHead)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
#define InterlockedIncrementUL(Addend)
#define BooleanFlagOn(F, SF)
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
_Outptr_ PDEVICE_OBJECT * DiskDeviceObject
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
#define OBJ_KERNEL_HANDLE
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
PLIST_ENTRY NTAPI ExInterlockedInsertHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
PLIST_ENTRY NTAPI ExInterlockedRemoveHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
POBJECT_TYPE IoDeviceObjectType
POBJECT_TYPE IoFileObjectType
#define ExFreePoolWithTag(_P, _T)
#define FILE_DEVICE_MASS_STORAGE
#define InitializeObjectAttributes(p, n, a, r, s)
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_DELETE_PENDING
#define FO_FILE_OBJECT_HAS_EXTENSION
#define IO_ATTACH_DEVICE_API
#define DOE_REMOVE_PROCESSED
#define DOE_SIO_NO_CANCEL
#define DOE_UNLOAD_PENDING
#define FILE_AUTOGENERATED_DEVICE_NAME
#define DOE_REMOVE_PENDING
#define DOE_SIO_CANCELABLE
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
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 FILE_READ_ATTRIBUTES
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_FLOPPY_DISKETTE
#define MEMORY_ALLOCATION_ALIGNMENT
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
enum _SECURITY_DESCRIPTOR_TYPE SECURITY_DESCRIPTOR_TYPE
VOID NTAPI IopRemoveTimerFromTimerList(IN PIO_TIMER Timer)
VOID NTAPI IopShutdownBaseFileSystems(IN PLIST_ENTRY ListHead)
NTSTATUS NTAPI IopCreateVpb(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS IopSynchronousCall(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IoStackLocation, OUT PVOID *Information)
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)
enum _IOP_DEVICE_LIST_OPERATION IOP_DEVICE_LIST_OPERATION
#define IoGetDevObjExtension(DeviceObject)
PACL SePublicDefaultUnrestrictedDacl
PACL SePublicOpenUnrestrictedDacl
PSECURITY_DESCRIPTOR NTAPI IopCreateDefaultDeviceSecurityDescriptor(IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN HasDeviceName, IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PACL *OutputDacl, OUT PULONG OutputFlags)
NTSTATUS NTAPI IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT *DeviceObjectList, IN ULONG DeviceObjectListSize, OUT PULONG ActualNumberDeviceObjects)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
PDEVICE_OBJECT NTAPI IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject)
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)
LIST_ENTRY ShutdownListHead
PDEVICE_OBJECT NTAPI IopAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, OUT PDEVICE_OBJECT *AttachedToDeviceObject OPTIONAL)
NTSTATUS NTAPI IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, PDEVICE_OBJECT *AttachedDevice)
VOID NTAPI IopStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
VOID NTAPI IoStartPacket(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PULONG Key, IN PDRIVER_CANCEL CancelFunction)
NTSTATUS NTAPI IopCreateSecurityDescriptorPerType(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN SECURITY_DESCRIPTOR_TYPE Type, OUT PULONG OutputFlags)
NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
VOID NTAPI IopStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
BOOLEAN NTAPI IopVerifyDeviceObjectOnStack(IN PDEVICE_OBJECT BaseDeviceObject, IN PDEVICE_OBJECT TopDeviceObjectHint)
NTSTATUS NTAPI IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject, OUT PDEVICE_OBJECT *DiskDeviceObject)
VOID NTAPI IopEditDeviceList(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN IOP_DEVICE_LIST_OPERATION Type)
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject)
KSPIN_LOCK ShutdownListLock
LIST_ENTRY IopCdRomFileSystemQueueHead
NTSTATUS NTAPI IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_NODE *DeviceNode)
NTSTATUS NTAPI IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
ERESOURCE IopDatabaseResource
VOID NTAPI IoShutdownPnpDevices(VOID)
NTSTATUS NTAPI IopGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject, IN ULONG AttachFlag)
PDEVICE_OBJECT NTAPI IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
ULONG IopDeviceObjectNumber
VOID NTAPI IoShutdownSystem(IN ULONG Phase)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoSetStartIoAttributes(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN DeferredStartIo, IN BOOLEAN NonCancelable)
LIST_ENTRY LastChanceShutdownListHead
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI IopStartNextPacketByKeyEx(IN PDEVICE_OBJECT DeviceObject, IN ULONG Key, IN ULONG Flags)
VOID NTAPI IoStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
PDEVICE_OBJECT NTAPI IopGetLowestDevice(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
VOID NTAPI IopDeleteDevice(IN PVOID ObjectBody)
LIST_ENTRY IopDiskFileSystemQueueHead
VOID NTAPI IopReadyDeviceObjects(IN PDRIVER_OBJECT Driver)
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
VOID NTAPI IoStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
LIST_ENTRY IopTapeFileSystemQueueHead
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)
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
#define STATUS_VOLUME_DISMOUNTED
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
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)
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)
VOID NTAPI ObMakeTemporaryObject(IN PVOID ObjectBody)
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)
VOID NTAPI ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Count)
VOID NTAPI PoInitializeDeviceObject(IN OUT PDEVOBJ_EXTENSION DeviceObjectExtension)
VOID NTAPI PoVolumeDevice(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI PoRemoveVolumeDevice(IN PDEVICE_OBJECT DeviceObject)
#define FILE_DEVICE_FILE_SYSTEM
#define FILE_DEVICE_DISK_FILE_SYSTEM
#define FILE_DEVICE_TAPE_FILE_SYSTEM
#define FILE_DEVICE_CD_ROM
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
#define FILE_DEVICE_DFS_FILE_SYSTEM
#define FILE_DEVICE_NETWORK
#define FILE_DEVICE_VIRTUAL_DISK
#define STATUS_BUFFER_TOO_SMALL
PULONG MinorVersion OPTIONAL
base of all file and directory entries
ULONG AlignmentRequirement
PDEVICE_OBJECT Objects[1]
PDEVICE_OBJECT DeviceObject
PDEVICE_OBJECT AttachedTo
PDEVICE_OBJECT TopDeviceObjectHint
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
PDEVICE_OBJECT DeviceObject
#define TAG_SHUTDOWN_ENTRY
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_PARAMETER
#define STATUS_NO_SUCH_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
_Must_inspect_result_ _In_ WDFDRIVER Driver
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_In_ WDFDEVICE _In_ ULONG AlignmentRequirement
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_In_ WDFDEVICE _In_ ULONG DeviceCharacteristics
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
_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
_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
_Must_inspect_result_ _In_ ULONG Flags
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT SourceDevice
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
#define IoWMIDeviceObjectToProviderId(DeviceObject)
_In_ PIRP _In_opt_ PULONG _In_opt_ PDRIVER_CANCEL CancelFunction
struct _DEVOBJ_EXTENSION * PDEVOBJ_EXTENSION
DRIVER_CANCEL * PDRIVER_CANCEL
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define FO_DIRECT_DEVICE_OPEN
#define IO_TYPE_DEVICE_OBJECT_EXTENSION
#define DRVO_UNLOAD_INVOKED
#define DRVO_LEGACY_DRIVER
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
@ LockQueueIoDatabaseLock
#define ObDereferenceObject
#define ObReferenceObject
#define SECURITY_DESCRIPTOR_REVISION