HalpDmaDereferenceDomainObject

NTSTATUS __stdcall HalpDmaDereferenceDomainObject(PVOID BugCheckParameter3){
  UINT64 v1; 
  char v3; 
  char v4; 
  __int64 *v5; 
  unsigned __int8 v6; 
  unsigned __int64 v7; 
  INT64 v8; 
  int v9; 
  bool v10; 
  _QWORD *v11; 
  PVOID *v12; 
  v3 = 0;
  v4 = 0;
  KeAcquireSpinLockRaiseToDpc(&HalpDmaDomainListLock, v1);
  v5 = (__int64 *)HalpDmaDomainList;
  v7 = v6;
  while( v5 != &HalpDmaDomainList )
  {
    if( BugCheckParameter3 == v5 )
    {
      v10 = (*((_DWORD *)BugCheckParameter3 + 32))-- == 1;
      v4 = 1;
      if( v10 )
      {
        v11 = *(_QWORD **)BugCheckParameter3;
        v12 = (PVOID *)*((_QWORD *)BugCheckParameter3 + 1);
        if( *(PVOID *)(*(_QWORD *)BugCheckParameter3 + 8i64) != BugCheckParameter3 || *v12 != BugCheckParameter3 )
          __fastfail(3u);
        *v12 = v11;
        v3 = 1;
        v11[1] = v12;
      }
      break;
    }
    v5 = (__int64 *)*v5;
  }
  KxReleaseSpinLock(&HalpDmaDomainListLock);
  __writecr8(v7);
  if( v3 )
  {
    if( *((_DWORD *)BugCheckParameter3 + 16) )
    {
      v9 = HalpIommuFreeDmaDomain(*((_QWORD *)BugCheckParameter3 + 5));
      if( v9 < 0 )
        KeBugCheckEx(0x1D9u, 0i64, v9, (ULONG_PTR)BugCheckParameter3, 0i64);
      v8 = *((_QWORD *)BugCheckParameter3 + 6);
      if( v8 )
        HalpLaFreeState(v8);
    }
    HalpMmAllocCtxFree(v8, (__int64)BugCheckParameter3);
  }
  return v4 == 0 ? 0xC000000D : 0;
}

Referenced by:

HalAllocateCommonBufferVector
HalFreeCommonBufferThin
HalFreeCommonBufferV3
HalFreeCommonBufferVector
HalJoinDmaDomain
HalpAllocateCommonBufferThin
HalpAllocateDomainCommonBufferInternal
HalpDmaIsAutomaticDomain
HalpLeaveDmaDomain