KiGetSystemServiceTraceTable

INT64 __stdcall KiGetSystemServiceTraceTable(){
  VOID *PoolWithTag; 
  signed __int64 v1; 
  UINT64 *v2; 
  __int64 v3; 
  signed __int64 v4; 
  UINT64 v5; 
  unsigned __int64 v6; 
  bool v7; 
  int v8; 
  unsigned __int64 v9; 
  if( !KiSystemServiceTraceCallbackTable )
  {
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x75D0ui64, 0x7454694Bui64);
    v1 = (signed __int64)PoolWithTag;
    if( PoolWithTag )
    {
      memset((INT64)PoolWithTag, 0i64);
      v2 = (UINT64 *)&off_140988DD8;
      v3 = 471i64;
      v4 = v1 + 40;
      do
      {
        *(_DWORD *)(v4 + 12) = *((_DWORD *)v2 - 2);
        v5 = *v2;
        *(_QWORD *)v4 = *v2;
        *(_DWORD *)(v4 + 8) = *((_DWORD *)v2 - 1);
        v6 = *(_QWORD *)v1;
        if( (*(_BYTE *)(v1 + 8) & 1) != 0 && v6 )
          v6 ^= v1;
        v7 = 0;
        v8 = *(_BYTE *)(v1 + 8) & 1;
        if( v6 )
        {
          while( 1 )
          {
            if( (int)KiSystemServiceTraceTableCompareFunction(v5, v6) < 0 )
            {
              v9 = *(_QWORD *)v6;
              if( v8 )
              {
                if( !v9 )
                  goto LABEL_19;
                v9 ^= v6;
              }
              if( !v9 )
              {
LABEL_19:
                v7 = 0;
                break;
              }
            }
            else
            {
              v9 = *(_QWORD *)(v6 + 8);
              if( v8 )
              {
                if( !v9 )
                  goto LABEL_13;
                v9 ^= v6;
              }
              if( !v9 )
              {
LABEL_13:
                v7 = 1;
                break;
              }
            }
            v6 = v9;
          }
        }
        RtlRbInsertNodeEx((unsigned __int64 *)v1, v6, v7, v4 - 24);
        v4 += 64i64;
        v2 += 2;
        --v3;
      }
      while( v3 );
      if( _InterlockedCompareExchange64(&KiSystemServiceTraceCallbackTable, v1, 0i64) )
        ExFreePoolWithTag((PVOID)v1, 0x7454694Bu);
    }
  }
  return KiSystemServiceTraceCallbackTable;
}

Referenced by:

KeSetSystemServiceCallback