IoGetAttachedDevice 获得设备所在栈最顶层的设备


2012-05-19 13:01


获得设备所在设备栈最顶层的设备。
PDEVICE_OBJECT
   IoGetAttachedDevice(
     IN PDEVICE_OBJECT  
     ); 

Parameters

DeviceObject
                     Pointer to the device object for which the topmost attached device is to be returned.       

Return Value
IoGetAttachedDevice returns the highest-level device attached to the specified device.
Comments
If the device object specified by DeviceObject has no other device objects attached to it, DeviceObject and the returned pointer are equal.
IoGetAttachedDevice differs from IoGetAttachedDeviceReference in the following respects:
 
• IoGetAttachedDevice does not increment the reference count on the device object. (Thus no matching call to ObDereferenceObject is required.)
• Callers of IoGetAttachedDevice must ensure that no device objects are added to or removed from the stack while IoGetAttachedDevice is executing. Callers that cannot do this must use IoGetAttachedDeviceReference instead.

Requirements
IRQL: <= DISPATCH_LEVEL
Headers: Declared in ntifs.h. Include ntifs.h.