MiCompressImportList

UINT64 *__fastcall MiCompressImportList(UINT64 *P){
  UINT64 v1; 
  __int64 v2; 
  unsigned int v3; 
  unsigned int v4; 
  __int64 v6; 
  UINT64 v7; 
  _LOAD_IMPORTS **v8; 
  __int64 v9; 
  __int64 v10; 
  UINT64 v11; 
  __int64 v12; 
  unsigned int v13; 
  __int64 v14; 
  UINT64 v15; 
  v1 = *P;
  v2 = 0i64;
  v3 = 0;
  v4 = 0;
  if( !*P )
    goto LABEL_18;
  v6 = 0i64;
  do
  {
    v7 = P[v6 + 1];
    v8 = (_LOAD_IMPORTS **)v3;
    v9 = v7 | 1;
    if( !v7 )
      v9 = v2;
    v2 = v9;
    v3 = (_DWORD)v8 + 1;
    if( !v7 )
      v3 = (unsigned int)v8;
    v6 = ++v4;
  }
  while( v4 < v1 );
  if( !v3 )
  {
LABEL_18:
    v2 = -2i64;
    goto LABEL_17;
  }
  if( v3 == 1 )
  {
LABEL_17:
    ExFreePoolWithTag(P, 0);
    return(UINT64 *)v2;
  }
  if( v3 != v1 )
  {
    LODWORD(v10) = MiAllocateImportList((_IMAGE_IMPORT_DESCRIPTOR *)v3, v8);
    v2 = v10;
    if( v10 )
    {
      v11 = *P;
      v12 = 0i64;
      v13 = 0;
      if( *P )
      {
        v14 = 0i64;
        do
        {
          v15 = P[v14 + 1];
          if( v15 )
          {
            *(_QWORD *)(v2 + 8 * v12 + 8) = v15;
            v12 = (unsigned int)(v12 + 1);
          }
          v14 = ++v13;
        }
        while( v13 < v11 );
      }
      goto LABEL_17;
    }
  }
  return P;
}

Referenced by:

MiAddEntryToImportList
MiResolveImageReferences