TtmpDispatchCreateEventQueue

INT64 __fastcall TtmpDispatchCreateEventQueue(INT64 a1, VOID **a2){
  VOID *v2; 
  struct _DMA_ADAPTER *v4; 
  int inserted; 
  unsigned int v6; 
  INT64 v7; 
  int v8; 
  __int64 a5[2]; 
  INT64 a4; 
  PVOID Object; 
  PVOID Handle; 
  v2 = *(VOID **)(a1 + 8);
  a4 = 0i64;
  a5[0] = 0i64;
  v4 = 0i64;
  Handle = 0i64;
  Object = 0i64;
  inserted = TtmpAcquireSessionFromTerminalHandle(v2, 1, 0, &a4, a5);
  v6 = inserted;
  if( inserted < 0 )
  {
    v7 = 307i64;
LABEL_3:
    TtmiLogError((PSTR)"TtmpDispatchCreateEventQueue", v7, (unsigned int)inserted, (unsigned int)inserted);
    goto LABEL_11;
  }
  v8 = TtmiCreateEventQueue(a4, &Object);
  v6 = v8;
  if( v8 >= 0 )
  {
    v4 = (struct _DMA_ADAPTER *)Object;
    inserted = TtmiWriteEnumerationEventsToQueue(a4, (INT64)Object);
    v6 = inserted;
    if( inserted < 0 )
    {
      v7 = 323i64;
      goto LABEL_3;
    }
    inserted = ObInsertObject(v4, 0i64, 0x1F0000ui64, 0i64, 0i64, &Handle);
    v4 = 0i64;
    v6 = inserted;
    if( inserted < 0 )
    {
      v7 = 342i64;
      goto LABEL_3;
    }
    v6 = 0;
    *a2 = Handle;
  }
  else
  {
    TtmiLogError((PSTR)"TtmpDispatchCreateEventQueue", 313i64, (unsigned int)v8, (unsigned int)v8);
    v4 = (struct _DMA_ADAPTER *)Object;
  }
LABEL_11:
  if( a4 )
  {
    ExReleaseResourceLite(&TtmpSessionLock);
    KeLeaveCriticalRegion();
  }
  if( a5[0] )
    HalPutDmaAdapter((PADAPTER_OBJECT)a5[0]);
  if( v4 )
    HalPutDmaAdapter(v4);
  return v6;
}

Referenced by:

TtmDispatchApi