AlpcpReferenceAndLockTargetPortsAndCommunicationInfo

INT64 __fastcall AlpcpReferenceAndLockTargetPortsAndCommunicationInfo(INT64 a1, INT64 *a2, INT64 *a3){
  INT64 *v4; 
  int v6; 
  int v7; 
  INT64 v8; 
  INT64 v9; 
  INT64 result; 
  v4 = *(INT64 **)(a1 + 16);
  v6 = (*(_DWORD *)(a1 + 416) >> 1) & 3;
  ExAcquirePushLockSharedEx((UINT64)(v4 - 2), 0i64);
  v7 = v6 - 1;
  if( v7 )
  {
    if( v7 == 1 )
    {
      v8 = *v4;
      v9 = v4[1];
      goto LABEL_4;
    }
    v8 = v4[2];
  }
  else
  {
    v8 = *v4;
  }
  v9 = v8;
LABEL_4:
  if( v8 )
    v8 &= -(__int64)(ObReferenceObjectSafe((PVOID)v8) != 0);
  if( v9 )
    v9 &= -(__int64)(ObReferenceObjectSafe((PVOID)v9) != 0);
  if( v8 && v9 )
  {
    ExAcquirePushLockSharedEx(v8 + 352, 0i64);
    if( v9 != v8 )
      ExAcquirePushLockSharedEx(v9 + 352, 0i64);
    if( (*(_DWORD *)(v8 + 416) & 0x20) == 0 && (*(_DWORD *)(v9 + 416) & 0x20) == 0 )
    {
      *a2 = v8;
      result = 0i64;
      *a3 = v9;
      return result;
    }
    AlpcpUnlockAndDereferenceTargetPortsAndCommunicationInfo((INT64)v4, v8, v9);
  }
  else
  {
    if( _InterlockedCompareExchange64(v4 - 2, 0i64, 17i64) != 17 )
      ExfReleasePushLockShared(v4 - 2);
    KeAbPostRelease(v4 - 2);
    if( v8 )
      HalPutDmaAdapter((PADAPTER_OBJECT)v8);
    if( v9 )
      HalPutDmaAdapter((PADAPTER_OBJECT)v9);
  }
  return 3221225527i64;
}

Referenced by:

AlpcpDispatchCloseMessage