AlpcpPortQueryServerSessionInfo

INT64 __fastcall AlpcpPortQueryServerSessionInfo(INT64 a1, _DWORD *a2, UINT64 a3, _DWORD *a4){
  unsigned int v5; 
  _ALPC_PORT *v7; 
  struct _DMA_ADAPTER *v8; 
  INT64 *v9; 
  _DMA_OPERATIONS *DmaOperations; 
  int AllocateCommonBufferEx; 
  int SessionId; 
  INT64 result; 
  v5 = a3;
  if( !a1 )
    return 3221225485i64;
  v7 = AlpcpReferenceConnectedPort((_ALPC_PORT *)a1);
  v8 = (struct _DMA_ADAPTER *)v7;
  if( !v7 )
    return 3221225485i64;
  v9 = (INT64 *)((char *)v7 + 352);
  ExAcquirePushLockSharedEx((UINT64)v7 + 352, 0i64);
  DmaOperations = 0i64;
  if( ((__int64)v8[1].DmaOperations & 1) == 0 )
    DmaOperations = v8[1].DmaOperations;
  if( DmaOperations )
    ObfReferenceObjectWithTag(DmaOperations, 0x63706C41u);
  if( _InterlockedCompareExchange64(v9, 0i64, 17i64) != 17 )
    ExfReleasePushLockShared(v9);
  KeAbPostRelease(v9);
  HalPutDmaAdapter(v8);
  if( !DmaOperations )
    return 3221225485i64;
  AllocateCommonBufferEx = (int)DmaOperations[3].AllocateCommonBufferEx;
  SessionId = MmGetSessionIdEx((INT64)DmaOperations);
  ObfDereferenceObjectWithTag(DmaOperations, 0x63706C41ui64);
  result = v5 < 8 ? 0xC0000004 : 0;
  if( v5 >= 8 )
  {
    *a2 = SessionId;
    a2[1] = AllocateCommonBufferEx;
  }
  if( a4 )
    *a4 = 8;
  return result;
}

Referenced by:

NtAlpcQueryInformation