HalpIommuLeaveDmaDomain

_KDEVICE_QUEUE_ENTRY *__stdcall HalpIommuLeaveDmaDomain(_KDEVICE_QUEUE *DeviceQueue, UINT64 SortKey, UINT8 a3){
  int v5; 
  _KDEVICE_QUEUE_ENTRY *result; 
  _LARGE_INTEGER *v7; 
  _LARGE_INTEGER *v8; 

  v7 = 0i64;
  v8 = 0i64;
  if( byte_140C49B2C )
  {
    v5 = ((__int64(__fastcall *)(unsigned __int64, UINT64, UINT8))qword_140C4A2C0)(DeviceQueue->Lock, SortKey, a3);
    if( (_WORD)v5 == 118 )
      v5 = 0;
    if( v5 < 0 )
      KeBugCheckEx(0x1D9u, (PVOID)2, (PVOID)v5, (PVOID)SortKey, 0i64);
    return(_KDEVICE_QUEUE_ENTRY *)(unsigned int)v5;
  }
  LODWORD(result) = HalpIommuGetHardwareDomain(SortKey, (INT64)DeviceQueue->DeviceListHead.Flink, 0, 0, &v8);
  v5 = (int)result;
  if( (int)result < 0 )
    return result;
  if( dword_140C49B28 != 1 || !LOBYTE(DeviceQueue->DeviceListHead.Blink) )
  {
    if( !byte_140C49B2C )
      ((void(__fastcall *)(_LIST_ENTRY *, _QWORD, _QWORD))DeviceQueue->DeviceListHead.Flink[7].Blink)(
        DeviceQueue->DeviceListHead.Flink[1].Flink,
        *(_QWORD *)&DeviceQueue->Type,
        0i64);
    goto LABEL_14;
  }
  LODWORD(result) = HalpIommuGetHardwareDomain(::SortKey, (INT64)DeviceQueue->DeviceListHead.Flink, 0, 0, &v7);
  if( (int)result >= 0 )
  {
    LODWORD(result) = HalpIommuAttachDeviceDomain(
                        (INT64)DeviceQueue->DeviceListHead.Flink,
                        *(_QWORD *)&DeviceQueue->Type,
                        (INT64)&v7[4]);
    v5 = (int)result;
    if( (int)result >= 0 )
    {
LABEL_14:
      if( v8 )
        HalpIommuDereferenceHardwareDomain(SortKey, (INT64 *)v8);
      return(_KDEVICE_QUEUE_ENTRY *)(unsigned int)v5;
    }
  }
  return result;
}

Referenced by:

HalJoinDmaDomain
HalpIommuBlockDevice
HalpLeaveDmaDomain
IommuDomainDetachDevice