HalpAllocateDmaChannels

char __fastcall HalpAllocateDmaChannels(__int64 a1){
  __int64 v2; 
  __int64 v3; 
  unsigned __int8 CurrentIrql; 
  UINT64 *v5; 
  __int64 v7; 
  __int64 *v8; 
  __int64 **v9; 
  v2 = *(_QWORD *)(a1 + 360);
  v3 = *(_QWORD *)(v2 + 56) + 160i64 * *(unsigned int *)(a1 + 372);
  CurrentIrql = KeGetCurrentIrql();
  __writecr8(*(unsigned __int8 *)(v2 + 176));
  v5 = (UINT64 *)(v2 + 168);
  KxAcquireSpinLock(v5);
  if( *(_BYTE *)(v3 + 5) )
  {
    if( (*(_DWORD *)(*(_QWORD *)(a1 + 344) + 20i64) & 1) == 0 )
    {
      v7 = v3 + 144;
      v8 = (__int64 *)(a1 + 200);
      v9 = *(__int64 ***)(v7 + 8);
      if( *v9 != (__int64 *)v7 )
        __fastfail(3u);
      *v8 = v7;
      v8[1] = (__int64)v9;
      *v9 = v8;
      *(_QWORD *)(v7 + 8) = v8;
    }
    KxReleaseSpinLock(v5);
    __writecr8(CurrentIrql);
    return 0;
  }
  else
  {
    *(_BYTE *)(v3 + 5) = 1;
    *(_DWORD *)(a1 + 384) = 1;
    *(_QWORD *)(v3 + 24) = a1;
    KxReleaseSpinLock(v5);
    __writecr8(CurrentIrql);
    return 1;
  }
}

Referenced by:

HalpAllocateDmaResourcesInternal