AlpcpInitializeMessageLog

INT64 __stdcall AlpcpInitializeMessageLog(UINT64 MessageCount, UINT64 SnapshotCount){
  unsigned int v2; 
  _QWORD *PoolWithTag; 
  __int64 v7; 
  char *v8; 
  char *v9; 
  PVOID v10; 
  unsigned int v11; 
  __int64 v12; 
  char *v13; 
  char **v14; 
  __int64 v15; 
  char **v16; 
  char *v17; 
  v2 = 0;
  AlpcpMessageLogLock = 0i64;
  qword_140C2A788 = (__int64)&AlpcpMessageLogListHead;
  AlpcpMessageLogListHead = (__int64)&AlpcpMessageLogListHead;
  qword_140C2A778 = (__int64)&AlpcpFreeMessageLogListHead;
  AlpcpFreeMessageLogListHead = (__int64)&AlpcpFreeMessageLogListHead;
  qword_140C2A768 = (__int64)&AlpcpFreeMessageSnapshotListHead;
  AlpcpFreeMessageSnapshotListHead = (__int64)&AlpcpFreeMessageSnapshotListHead;
  if( !MessageCount || !SnapshotCount )
    return 0i64;
  PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x4000ui64, 0x6C4D6C41ui64);
  AlpcpMessageLogLookupTable = PoolWithTag;
  if( PoolWithTag )
  {
    v7 = 1024i64;
    do
    {
      PoolWithTag[1] = PoolWithTag;
      *PoolWithTag = PoolWithTag;
      PoolWithTag += 2;
      --v7;
    }
    while( v7 );
    v8 = (char *)ExAllocatePoolWithTag(PagedPool, MessageCount << 6, 0x6C4D6C41ui64);
    if( !v8 )
    {
      v10 = AlpcpMessageLogLookupTable;
      goto LABEL_11;
    }
    v9 = (char *)ExAllocatePoolWithTag(PagedPool, 120 * SnapshotCount, 0x734D6C41ui64);
    if( !v9 )
    {
      ExFreePoolWithTag(AlpcpMessageLogLookupTable, 0);
      v10 = v8;
LABEL_11:
      ExFreePoolWithTag(v10, 0);
      return 3221225626i64;
    }
    v11 = 0;
    if( MessageCount )
    {
      v12 = 0i64;
      while( 1 )
      {
        v13 = &v8[64 * v12];
        *((_QWORD *)v13 + 7) = v13 + 48;
        *((_QWORD *)v13 + 6) = v13 + 48;
        v14 = (char **)qword_140C2A778;
        if( *(__int64 **)qword_140C2A778 != &AlpcpFreeMessageLogListHead )
          break;
        *((_QWORD *)v13 + 1) = qword_140C2A778;
        ++v11;
        *(_QWORD *)v13 = &AlpcpFreeMessageLogListHead;
        *v14 = v13;
        v12 = v11;
        qword_140C2A778 = (__int64)v13;
        if( v11 >= MessageCount )
          goto LABEL_17;
      }
LABEL_22:
      __fastfail(3u);
    }
LABEL_17:
    if( SnapshotCount )
    {
      v15 = 0i64;
      while( 1 )
      {
        v16 = (char **)qword_140C2A768;
        v17 = &v9[120 * v15];
        if( *(__int64 **)qword_140C2A768 != &AlpcpFreeMessageSnapshotListHead )
          break;
        *(_QWORD *)v17 = &AlpcpFreeMessageSnapshotListHead;
        ++v2;
        *((_QWORD *)v17 + 1) = v16;
        *v16 = v17;
        qword_140C2A768 = (__int64)v17;
        v15 = v2;
        if( v2 >= SnapshotCount )
          return 0i64;
      }
      goto LABEL_22;
    }
    return 0i64;
  }
  return 3221225626i64;
}

Referenced by:

AlpcpInitSystem