关于创建和attach设备的一些结构和函数——来自wdk文档(WDK 7600.16385.1)

DEVICE_OBJECT
The DEVICE_OBJECT structure is used by the operating system to represent a device object. A device object represents a logical, virtual, or physical device for which a driver handles I/O requests.

typedef struct _DEVICE_OBJECT {
  CSHORT  Type;
  USHORT  Size;
  LONG  ReferenceCount;
  PDRIVER_OBJECT  DriverObject;
  PDEVICE_OBJECT  NextDevice;
  PDEVICE_OBJECT  AttachedDevice;
  PIRP  CurrentIrp;
  PIO_TIMER  Timer;
  ULONG  Flags;
  ULONG  Characteristics;
  __volatile PVPB  Vpb;
  PVOID  DeviceExtension;
  DEVICE_TYPE  DeviceType;
  CCHAR  StackSize;
  union {
    LIST_ENTRY  ListEntry;
    WAIT_CONTEXT_BLOCK  Wcb;
  } Queue;
  ULONG  AlignmentRequirement;
  KDEVICE_QUEUE  DeviceQueue;
  KDPC  Dpc;
  ULONG  ActiveThreadCount;
  PSECURITY_DESCRIPTOR  SecurityDescriptor;
  KEVENT  DeviceLock;
  USHORT  SectorSize;
  USHORT  Spare1;
  PDEVOBJ_EXTENSION  DeviceObjectExtension;
  PVOID  Reserved;
} DEVICE_OBJECT, *PDEVICE_OBJECT;
Members
Type
Used by the operating system to indicate that an object is a device object. For device objects, the value of this member is 3. This is a read-only member.
Size
Specifies the size, in bytes, of the device object. This size does not include the device object extension, if present (see DeviceExtension later in this topic). This is a read-only member.
ReferenceCount
Used by the I/O manager to track the number of open handles for the device that are associated with the device object. This allows the I/O manager to avoid unloading a driver when there are outstanding handles for the driver's device(s). This is a read-only member.
DriverObject
A pointer to the driver object (DRIVER_OBJECT), that reprensents the loaded image of the driver that was input to the DriverEntry and AddDevice routines. This member is set by the I/O manager upon a successful call to IoCreateDevice or IoCreateDeviceSecure. This is a read-only member.
NextDevice
A pointer to the next device object, if any, that was created by the same driver. The I/O manager updates this list at each successful call to IoCreateDevice or IoCreateDeviceSecure.
A non- Plug and Play (PnP) driver that is being unloaded must traverse (“walk”) the list of its device objects and delete them. A PnP driver does not have to walk this list of device objects. Instead, PnP drivers perform their cleanup during the device removal PnP operation (IRP_MN_REMOVE_DEVICE).

A driver that recreates its device objects dynamically also uses this member. This is a read/write member.

AttachedDevice
A pointer to the attached device object. If there is no attached device object, this member is NULL. The device object that is pointed to by the AttachedDevice member typically is the device object of a filter driver, which intercepts I/O requests originally targeted to the device represent by the device object. For more information, see the IoAttachDevice and IoAttachDeviceByPointer topics. This is an opaque member.
CurrentIrp
A pointer to the current IRP if the driver has a StartIo routine whose entry point was set in the driver object and if the driver is currently processing IRP(s). Otherwise, this member is NULL. For more information, see the IoStartPacket and IoStartNextPacket topics. This is a read-only member.
Timer
A pointer to a timer object. This allows the I/O manager to call a driver-supplied timer routine every second. For more information, see IoInitializeTimer. This is a read/write member.
Flags
Device drivers perform a bitwise OR operation with this member in their newly created device objects by using one or more of the following system-defined values:
DO_BUFFERED_IO or DO_DIRECT_IO
Specifies the type of buffering that is used by the I/O manager for I/O requests that are sent to the device stack. Higher-level drivers OR this member with the same value as the next-lower driver in the stack, except possibly for highest-level drivers.
DO_BUS_ENUMERATED_DEVICE
The operating system sets this flag in each physical device object (PDO). Drivers must not modify this flag.
DO_DEVICE_INITIALIZING
The I/O manager sets this flag when it creates the device object. A device function driver or filter driver clears the flag in its AddDevice routine, after it does the following:
Attaches the device object to the device stack.
Establishes the device power state.
Performs a bitwise OR operation on the member with one of the power flags (if it is necessary).
it and The Plug and Play (PnP) manager checks that the flag is clear after the AddDevice routine returns.

DO_EXCLUSIVE
Indicates that the driver services an exclusive device, such as a video, serial, parallel, or sound device. WDM drivers must not set this flag. For more information, see the Specifying Exclusive Access to Device Objects topic.
DO_MAP_IO_BUFFER
This flag is no longer used. Drivers should not set this flag.
DO_POWER_INRUSH
Drivers of devices that require inrush current when the device is turned on must set this flag. A driver cannot set both this flag and DO_POWER_PAGABLE.
DO_POWER_PAGABLE
Pageable drivers that are compatible with Microsoft Windows 2000 and later versions of Windows, are not part of the paging path, and do not require inrush current must set this flag. The system calls such drivers at IRQL = PASSIVE_LEVEL. Drivers cannot set both this flag and DO_POWER_INRUSH. All drivers for WDM, Microsoft Windows 98, and Windows Millennium Edition must set DO_POWER_PAGABLE.
DO_SHUTDOWN_REGISTERED
Used by the I/O manager to indicate that a driver has registered the device object for shutdown notifications. This flag should not be used by drivers.
DO_VERIFY_VOLUME
Removable-media drivers set this flag while they process transfer requests. Such drivers should also check for this flag in the target for a transfer request before they transfer any data. For more information, see the Supporting Removable Media topic.

For more information about how to set the Flags member, see Initializing a Device Object.
Characteristics
Specifies one or more system-defined constants, combined with a bitwise OR operation, that provide additional information about the driver's device. These constants include the following:
FILE_AUTOGENERATED_DEVICE_NAME
Directs the I/O manager to generate a name for the device, instead of the caller specifying a DeviceName when it calls this routine. The I/O manager makes sure that the name is unique. This characteristic is typically specified by a PnP bus driver to generate a name for a physical device object (PDO) for a child device on the same bus. This characteristic is new starting with Microsoft Windows 2000 and Microsoft Windows 98.
FILE_CHARACTERISTIC_PNP_DEVICE
Indicates that the device object is part of a Plug and Play (PnP) stack. This characteristic is required if a bus driver (or bus filter driver) registers WMI support for a device object that has not yet received the IRP_MN_START_DEVICE request. FILE_CHARACTERISTIC_PNP_DEVICE is also required if a function or filter driver registers for WMI before attaching to its device stack.
FILE_CHARACTERISTIC_TS_DEVICE
Indicates that the device object is part of a Terminal Services device stack. Drivers should not set this characteristic.
FILE_CHARACTERISTIC_WEBDAV_DEVICE
Indicates that a Web-based Distributed Authoring and Versioning (WebDAV) file system is mounted on the device. Drivers should not set this characteristic.
FILE_DEVICE_IS_MOUNTED
Indicates that a file system is mounted on the device. Drivers should not set this characteristic.
FILE_DEVICE_SECURE_OPEN
(Microsoft Windows NT 4.0 with Service Pack 5 (SP5) and later versions of Windows)
Directs the I/O manager to apply the security descriptor of the device object to relative opens and trailing file name opens for the device. For more information, see the Controlling Device Namespace Access topic.

FILE_FLOPPY_DISKETTE
Indicates that the device is a floppy disk device.
FILE_READ_ONLY_DEVICE
Indicates that the device cannot be written to.
FILE_REMOTE_DEVICE
Indicates that the device is remote.
FILE_REMOVABLE_MEDIA
Indicates that the storage device supports removable media. Notice that this characteristic indicates removable media, not a removable device. For example, drivers for JAZ drive devices should specify this characteristic, but drivers for PCMCIA flash disks should not.
FILE_VIRTUAL_VOLUME
Indicates that the volume is virtual. Drivers should not set this characteristic.
FILE_WRITE_ONCE_MEDIA
Indicates that the device supports write-once media. Drivers do not set this member directly. For more information about how to set device characteristics, see the Specifying Device Characteristics topic.
Vpb
A pointer to the volume parameter block (VPB) that is associated with the device object. For file system drivers, the VPB can provide a connection to any unnamed logical device object that represents an instance of a mounted volume. This is an opaque member.
DeviceExtension
A pointer to the device extension. The structure and contents of the device extension are driver-defined. The size is driver-determined, specified in the driver's call to IoCreateDevice or IoCreateDeviceSecure. For more information about device extensions, see Device Extensions. This is a read-only member. However, the object that the member points to can be modified by the driver.
DeviceType
Set by IoCreateDevice and IoCreateDeviceSecure by using the value that is specified for that routine's DeviceType parameter. For more information, see the Specifying Device Types topic.
StackSize
Specifies the minimum number of stack locations in IRPs to be sent to this driver. IoCreateDevice and IoCreateDeviceSecure set this member to 1 in newly created device objects; lowest-level drivers can therefore ignore this member. The I/O manager automatically sets the StackSize member in a higher-level driver's device object to the appropriate value if the driver calls IoAttachDevice or IoAttachDeviceToDeviceStack. Only a higher-level driver that chains itself over another driver with IoGetDeviceObjectPointer must explicitly set the value of StackSize in its own device object(s) to 1 + the StackSize value of the next-lower driver's device object.
Queue
Used internally by the I/O manager to queue the device object when it is required. This is an opaque member.
AlignmentRequirement
Specifies the device's address alignment requirement for data transfers. The value must be one of the FILE_XXX_ALIGNMENT values that are defined in Wdm.h. For more information, see the Initializing a Device Object, GetDmaAlignment, and ZwQueryInformationFile topics.
DeviceQueue
The device queue object for the device object. The device queue object contains any IRPs that are waiting to be processed by the driver that is associated with the device object. For more information, see the Driver-Managed IRP Queues topic. This is an opaque member.
Dpc
The deferred procedure call (DPC) object for the device object. For more information, see the Introduction to DPC Objects topic. This is an opaque member.
ActiveThreadCount
Reserved for future use. This is an opaque member.
SecurityDescriptor
Specifies a security descriptor (SECURITY_DESCRIPTOR) for the device object when the device object is created. If this member is NULL, the device object receives default security settings. This is a read-only member, although the member can be modified through the ZwSetSecurityObjectfunction.
DeviceLock
A synchronization event object that is allocated by the I/O manager. The I/O manager obtains his event object before it dispatches a mount or mount-verify request to a file-system driver. This is an opaque member.
SectorSize
If the device object does not represent a volume, this member is set to zero. If the device object represents a volume, this member specifies the volume’s sector size, in bytes. The I/O manager uses this member to make sure that all read operations, write operations, and set file position operations that are issued are aligned correctly when intermediate buffering is disabled. A default system bytes-per-sector value is used when the device object is created, however, file system drivers; and more rarely, legacy and minifilter drivers, can update this value that is based on the geometry of the underlying volume hardware when a mount occurs. Other drivers should not modify this member.
Spare1
Reserved for system use. This is an opaque member.
DeviceObjectExtension
A pointer to a device object extension that is used by the I/O manager and PnP manager to store information about the state of the device. This is an opaque member.
Reserved
Reserved for system use. This is an opaque member.

Comments
The operating system represents devices by device objects. For more information, see the Device Objects and Device Stacks topic.

Drivers create device objects by using the IoCreateDevice and IoCreateDeviceSecure routines. For more information about how to create device objects, see Creating a Device Object.

A device object is partially opaque. Drivers do not set members of the device object directly, unless otherwise documented. For more information about the members that drivers can modify directly, see Initializing a Device Object. For information about other device object properties, see Properties of Device Objects.

Opaque members within a device object must be considered inaccessible. Drivers that have dependencies on object member locations or access to opaque members might not remain portable and interoperable with other drivers over time.

The system-supplied video port driver sets up the fields of the device objects that it creates on behalf of video miniport drivers.

The system-supplied SCSI port driver sets up the fields of the device objects that it creates on behalf of SCSI miniport drivers.

The system-supplied NDIS library sets up the fields of the device objects that it creates on behalf of NDIS miniport drivers.

Requirements
Headers: Defined in Wdm.h. Include Wdm.h, Ntddk.h, Ntifs.h, or Fltkernel.h.


*************************************************************************************************
IoCreateDevice
The IoCreateDevice routine creates a device object for use by a driver.

NTSTATUS
  IoCreateDevice(
    IN PDRIVER_OBJECT  DriverObject,
    IN ULONG  DeviceExtensionSize,
    IN PUNICODE_STRING  DeviceName  OPTIONAL,
    IN DEVICE_TYPE  DeviceType,
    IN ULONG  DeviceCharacteristics,
    IN BOOLEAN  Exclusive,
    OUT PDEVICE_OBJECT  *DeviceObject
    );


Parameters
DriverObject
Pointer to the driver object for the caller. Each driver receives a pointer to its driver object in a parameter to its DriverEntry routine. WDM function and filter drivers also receive a driver object pointer in their AddDevice routines.
DeviceExtensionSize
Specifies the driver-determined number of bytes to be allocated for the device extension of the device object. The internal structure of the device extension is driver-defined.
DeviceName
Optionally points to a buffer containing a null-terminated Unicode string that names the device object. The string must be a full path name. WDM filter and function drivers do not name their device objects. For more information, see Named Device Objects.
Note  If a device name is not supplied (that is, DeviceName is NULL), the device object created by IoCreateDevice will not (and cannot) have a discretionary access control list (DACL) associated with it. For additional information, see Security Descriptors.

DeviceType
Specifies one of the system-defined FILE_DEVICE_XXX constants that indicate the type of device (such as FILE_DEVICE_DISK, FILE_DEVICE_KEYBOARD, etc.) or a vendor-defined value for a new type of device. For more information, see Specifying Device Types.
DeviceCharacteristics
Specifies one or more system-defined constants, ORed together, that provide additional information about the driver's device. For a list of possible device characteristics, see DEVICE_OBJECT. For more information about how to specify device characteristics, see Specifying Device Characteristics. Most drivers specify FILE_DEVICE_SECURE_OPEN for this parameter.
Exclusive
Specifies if the device object represents an exclusive device. Most drivers set this value to FALSE. For more information about exclusive access, see Specifying Exclusive Access to Device Objects.
DeviceObject
Pointer to a variable that receives a pointer to the newly created DEVICE_OBJECT structure. The DEVICE_OBJECT structure is allocated from nonpaged pool.
Return Value
IoCreateDevice returns STATUS_SUCCESS on success, or the appropriate NTSTATUS error code on failure. A partial list of the failure codes returned by this function include:

STATUS_INSUFFICIENT_RESOURCES

STATUS_OBJECT_NAME_EXISTS

STATUS_OBJECT_NAME_COLLISION

Comments
IoCreateDevice creates a device object and returns a pointer to the object. The caller is responsible for deleting the object when it is no longer needed by calling IoDeleteDevice.

IoCreateDevice can only be used to create an unnamed device object, or a named device object for which a security descriptor is set by an INF file. Otherwise, drivers must use IoCreateDeviceSecure to create named device objects. For more information, see Creating a Device Object. The caller is responsible for setting certain members of the returned device object. For more information, see Initializing a Device Object and the device-type-specific documentation for your device.

Be careful to specify the DeviceType and DeviceCharacteristics values in the correct parameters. Both parameters use system-defined FILE_XXX constants and some driver writers specify the values in the wrong parameters by mistake.

A remote file system that creates a named device object for a network redirector and registers using FsRtlRegisterUncProvider, must specify FILE_REMOTE_DEVICE as one of the options in the DeviceCharacteristics parameter of IoCreateDevice.

Device objects for disks, tapes, CD-ROMs, and RAM disks are given a Volume Parameter Block (VPB) that is initialized to indicate that the volume has never been mounted on the device.

If a driver's call to IoCreateDevice returns an error, the driver should release any resources that it allocated for that device.

Requirements
Versions: Available in Windows 2000 and later versions of Windows.

IRQL: PASSIVE_LEVEL

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

Library: Contained in Ntoskrnl.lib.


*************************************************************************************************************
NTSTATUS IoAttachDevice(
      IN PDEVICE_OBJECT SourceDevice;
      IN PUNICODE_STRING TargetDevice;
      OUT PDEVICE_OBJECT *AttachedDevice
      );
参数:
 SourceDevice:调用者创建的设备对象
 TargetDevice:将要被Attache的对象名称
 AttachedDevice:存放调用者创建的指针的指针,如果成功,指向一个指向TargetDevice的指针。
返回值可能为以下值:
 STATUS_SUCCESS
 STATUS_INBALID_PARAMETER
 STATUS_OBJECT_TYPE_MISMATCH
 STATUS_OBJECT_NAME_INVALID
 STATUS_INSUFFICIENT_RESOURCES
Comments
IoAttachDevice establishes layering between drivers so that the same IRPs can be sent to each driver in the chain.

This routine is used by intermediate drivers during initialization. It allows such a driver to attach its own device object to another device in such a way that any requests being made to the original device are given first to the intermediate driver.

The caller can be layered only at the top of an existing chain of layered drivers. IoAttachDevice searches for the highest device object layered over TargetDevice and attaches to that object (that can be the TargetDevice). Therefore, this routine must not be called if a driver that must be higher-level has already layered itself over the target device.

Note that for file system drivers and drivers in the storage stack, IoAttachDevice opens the target device with FILE_READ_ATTRIBUTES and then calls IoGetRelatedDeviceObject. This does not cause a file system to be mounted. Thus, a successful call to IoAttachDevice returns the device object of the storage driver, not that of the file system driver.

This routine sets the AlignmentRequirement in SourceDevice to the value in the next-lower device object and sets the StackSize to the value in the next-lower object plus one.

Warning:  AttachedDevice must point to a global memory location, such as the driver's device extension. IoAttachDevice opens the file object for the target device, updates AttachedDevice, performs the attach, and then closes the file object. Thus, the source device receives the IRP_MJ_CLEANUP and IRP_MJ_CLOSE requests for the file object before IoAttachDevice returns. The driver must forward these requests to the target device, and AttachedDevice must be a memory location accessible to the driver's DispatchCleanup and DispatchClose routines.


Requirements
Versions: Available in Windows 2000 and later versions of Windows.

IRQL: PASSIVE_LEVEL

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

Library: Contained in Ntoskrnl.lib.
****************************************************************************************************
IoAttachDeviceToDeviceStack
The IoAttachDeviceToDeviceStack routine attaches the caller's device object to the highest device object in the chain and returns a pointer to the previously highest device object.

PDEVICE_OBJECT
  IoAttachDeviceToDeviceStack(
    IN PDEVICE_OBJECT  SourceDevice,
    IN PDEVICE_OBJECT  TargetDevice
    );


Parameters
SourceDevice
Pointer to the caller-created device object.
TargetDevice
Pointer to another driver's device object, such as a pointer returned by a preceding call to IoGetDeviceObjectPointer.
Return Value
IoAttachDeviceToDeviceStack returns a pointer to the device object to which the SourceDevice was attached. The returned device object pointer can differ from TargetDevice if TargetDevice had additional drivers layered on top of it.

IoAttachDeviceToDeviceStack returns NULL if it could not attach the device object because, for example, the target device was being unloaded.

Comments
IoAttachDeviceToDeviceStack establishes layering between drivers so that the same IRPs are sent to each driver in the chain.

An intermediate driver can use this routine during initialization to attach its own device object to another driver's device object. Subsequent I/O requests sent to TargetDevice are sent first to the intermediate driver.

This routine sets the AlignmentRequirement in SourceDevice to the value in the next-lower device object and sets the StackSize to the value in the next-lower-object plus one.

A driver writer must take care to call this routine before any drivers that must layer on top of their driver. IoAttachDeviceToDeviceStack attaches SourceDevice to the highest device object currently layered in the chain and has no way to determine whether drivers are being layered in the correct order.

A driver that acquired a pointer to the target device by calling IoGetDeviceObjectPointer should call ObDereferenceObject with the file object pointer that was returned by IoGetDeviceObjectPointer to release its reference to the file object before it detaches its own device object, for example, when such a higher-level driver is unloaded.

Requirements
Versions: Available in Windows 2000 and later versions of Windows.

IRQL: <=DISPATCH_LEVEL

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

Library: Contained in Ntoskrnl.lib.
***************************************************************************************************
IoAttachDeviceToDeviceStackSafe
The IoAttachDeviceToDeviceStackSafe routine attaches the caller's device object to the topmost device object in a driver stack.

NTSTATUS
  IoAttachDeviceToDeviceStackSafe(
    IN PDEVICE_OBJECT  SourceDevice,
    IN PDEVICE_OBJECT  TargetDevice,
    IN OUT PDEVICE_OBJECT  *AttachedToDeviceObject
    );


Parameters
SourceDevice
Pointer to a caller-created device object.
TargetDevice
Pointer to the device object in the stack to which the SourceDevice object is to be attached.
AttachedToDeviceObject
On input, this parameter specifies the address of SourceDevice->DeviceExtension->AttachedToDeviceObject, which must contain a NULL pointer. On output, this parameter receives a pointer to the device object to which the SourceDevice was attached.

Return Value
IoAttachDeviceToDeviceStackSafe returns STATUS_SUCCESS if SourceDevice is successfully attached above the TargetDevice; otherwise it returns STATUS_NO_SUCH_DEVICE.

Comments
Like IoAttachDeviceToDeviceStack, IoAttachDeviceToDeviceStackSafe establishes layering between drivers so that the same IRPs are sent to each driver in the stack. However, unlike IoAttachDeviceToDeviceStack, IoAttachDeviceToDeviceStackSafe has an additional parameter, AttachedToDeviceObject, which the filter driver uses to pass the address of the SourceDevice object's AttachedToDeviceObject field. IoAttachDeviceToDeviceStackSafe updates this field while holding the I/O system database lock. Because it holds this lock, IoAttachDeviceToDeviceStackSafe avoids a race condition that could otherwise occur if the SourceDevice object received an IRP before its AttachedToDeviceObject field was updated.

A file system filter driver calls IoAttachDeviceToDeviceStackSafe to attach its own filter device object (SourceDevice) above a device object (TargetDevice) belonging to a file system or another filter driver. Subsequent I/O requests sent to AttachedToDeviceObject are received first by the filter driver, which processes them and forwards them down to the next driver in the stack by calling IoCallDriver.

If the device object specified by TargetDevice is currently at the top of the driver stack, the SourceDevice is attached directly to the TargetDevice. In this case, TargetDevice and the returned AttachedToDeviceObject pointer are equal.

If one or more filter device objects are already attached above the TargetDevice in the driver stack, IoAttachDeviceToDeviceStackSafe attaches the SourceDevice to the topmost filter device object. A pointer to the latter is returned in AttachedToDeviceObject.

At the moment immediately after it is attached to the top of the stack, the SourceDevice occupies the top of the driver stack. Note, however, that this does not necessarily mean that the SourceDevice will remain at the top of the driver stack. Other filters can attach their own filter device objects above the SourceDevice in the stack.

IoAttachDeviceToDeviceStackSafe sets the AlignmentRequirement member of the device object pointed to by SourceDevice to the value of the corresponding in the next-lower device object and sets the StackSize in SourceDevice to the value in the next-lower-object plus one.

Requirements
Versions: This routine is available on Update Rollup for Windows 2000 Service Pack 4 (SP4) and on Windows XP and later.

IRQL: <= DISPATCH_LEVEL

Headers: Declared in ntddk.h. Include ntddk.h.
********************************************************************************************************************
IoGetRelatedDeviceObject
Given a file object, the IoGetRelatedDeviceObject routine returns a pointer to the corresponding device object.

PDEVICE_OBJECT
  IoGetRelatedDeviceObject(
    IN PFILE_OBJECT  FileObject
    );


Parameters
FileObject
Pointer to the file object.
Return Value
IoGetRelatedDeviceObject returns a pointer to the device object.

Comments
When called on a file object that represents the underlying storage device, IoGetRelatedDeviceObject returns the highest-level device object in the storage device stack. To obtain the highest-level device object in the file system driver stack, drivers must call IoGetRelatedDeviceObject on a file object that represents the file system's driver stack, and the file system must currently be mounted. (Otherwise, the storage device stack is traversed instead of the file system stack.)

To ensure that the file system is mounted on the storage device, the driver must have specified an appropriate access mask, such as FILE_READ_DATA or FILE_WRITE_ATTRIBUTES, when opening the file or device represented by the file object. Specifying FILE_READ_ATTRIBUTES does not cause the file system to be mounted.

The caller must be running at IRQL <= DISPATCH_LEVEL. Usually, callers of this routine are running at IRQL = PASSIVE_LEVEL.

Requirements
Versions: Available in Windows 2000 and later versions of Windows.

IRQL: <= DISPATCH_LEVEL (see Comments section)

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

Library: Contained in Ntoskrnl.lib.

**************************************************************************************************************************
IoDetachDevice
The IoDetachDevice routine releases an attachment between the caller's device object and a lower driver's device object.

VOID
  IoDetachDevice(
    IN OUT PDEVICE_OBJECT  TargetDevice
    );


Parameters
TargetDevice
Pointer to the lower driver's device object. The caller previously called IoAttachDevice or IoAttachDeviceToDeviceStack successfully to get this pointer.
Return Value
None

Comments
IoDetachDevice decrements the reference count of the TargetDevice object. If the reference count goes to zero and the lower driver has been marked for an unload operation, the lower driver is unloaded.

Requirements
Versions: Available in Windows 2000 and later versions of Windows.

IRQL: PASSIVE_LEVEL

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

Library: Contained in Ntoskrnl.lib.


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值