BOOLEAN FsFilterIsAttachedToDevice( __in PDEVICE_OBJECT DeviceObject ) { PDEVICE_OBJECT nextDevObj = NULL; PDEVICE_OBJECT currentDevObj = IoGetAttachedDeviceReference(DeviceObject); // // Scan down the list to find our device object. // do { if (FsFilterIsMyDeviceObject(currentDevObj)) { ObDereferenceObject(currentDevObj); return TRUE; } // // Get the next attached object. // nextDevObj = IoGetLowerDeviceObject(currentDevObj); // // Dereference our current device object, before moving to the next one. // ObDereferenceObject(currentDevObj); currentDevObj = nextDevObj; } while (NULL != currentDevObj); return FALSE; }
static VOID TestLowerDeviceKernelAPI( IN PDEVICE_OBJECT DeviceObject) { PDEVICE_OBJECT RetObject; RetObject = IoGetLowerDeviceObject(DeviceObject); ok(RetObject == AttachDeviceObject, "Expected an Attached DeviceObject %p, got %p\n", AttachDeviceObject, RetObject); if (RetObject) { ObDereferenceObject(RetObject); } RetObject = IoGetDeviceAttachmentBaseRef(DeviceObject); ok(RetObject == AttachDeviceObject, "Expected an Attached DeviceObject %p, got %p\n", AttachDeviceObject, RetObject); if (RetObject) { ObDereferenceObject(RetObject); } }