IoGetAttachedDeviceReferenceWithTag

NTSTATUS __stdcall IoGetAttachedDeviceReferenceWithTag(PDEVICE_OBJECT DeviceObject, UINT32 Tag){
  INT64 v2; 
  UINT8 v5; 
  VOID *v6; 

  v5 = KeAcquireQueuedSpinLock(10i64, *(INT64 *)&Tag, v2);
  LODWORD(v6) = IoGetAttachedDevice((INT64)DeviceObject);
  LODWORD(DeviceObject) = (_DWORD)v6;
  ObfReferenceObjectWithTag(v6, Tag);
  KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, v5);
  return(int)DeviceObject;
}

Referenced by:

IopEjectDevice
IopSynchronousCall
PiControlGetDeviceStack
PipCallDriverAddDevice
PnpAsynchronousCall
PnpQueryInterface
PopAllocateIrp
PopFxRegisterDevice