IovUtilRelateDeviceObjects

VOID __stdcall IovUtilRelateDeviceObjects(
        _DEVICE_OBJECT *FirstDeviceObject,
        _DEVICE_OBJECT *SecondDeviceObject,
        _DEVOBJ_RELATION *DeviceObjectRelation){
  _DEVICE_OBJECT *AttachedTo; 
  UINT8 v6; 
  _DEVICE_OBJECT *AttachedDevice; 

  AttachedTo = FirstDeviceObject;
  if( FirstDeviceObject == SecondDeviceObject )
  {
    *DeviceObjectRelation = 0;
  }
  else
  {
    v6 = KeAcquireQueuedSpinLock(10i64, (INT64)SecondDeviceObject, (INT64)DeviceObjectRelation);
    if( AttachedTo == SecondDeviceObject->AttachedDevice )
    {
      *DeviceObjectRelation = 1;
    }
    else
    {
      AttachedDevice = AttachedTo->AttachedDevice;
      if( AttachedDevice == SecondDeviceObject )
      {
        *DeviceObjectRelation = 2;
      }
      else
      {
        do
        {
          if( AttachedTo == SecondDeviceObject )
            break;
          AttachedTo = AttachedTo->DeviceObjectExtension->AttachedTo;
        }
        while( AttachedTo );
        if( AttachedTo )
        {
          *DeviceObjectRelation = 3;
        }
        else
        {
          while( AttachedDevice && AttachedDevice != SecondDeviceObject )
            AttachedDevice = AttachedDevice->AttachedDevice;
          *DeviceObjectRelation = 5 - (AttachedDevice != 0i64);
        }
      }
    }
    KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, v6);
  }
}

Referenced by:

IovpExamineDevObjForwarding