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

Referenced by:

HalJoinDmaDomain
HalpIommuBlockDevice
HalpLeaveDmaDomain
IommuDomainDetachDevice