MiDereferenceImports

VOID __stdcall MiDereferenceImports(_LOAD_IMPORTS *ImportList){
  _LOAD_IMPORTS *v1; 
  unsigned int v2; 
  __int64 v3; 
  PLDR_DATA_TABLE_ENTRY v4; 
  __int128 v5; 
  if( ImportList != (_LOAD_IMPORTS *)1 )
  {
    v1 = ImportList;
    v5 = 0i64;
    if( ImportList != (_LOAD_IMPORTS *)-2i64 )
    {
      if( ((unsigned __int8)ImportList & 1) != 0 )
      {
        *(_QWORD *)&v5 = 1i64;
        *((_QWORD *)&v5 + 1) = (unsigned __int64)ImportList & 0xFFFFFFFFFFFFFFFEui64;
        v1 = (_LOAD_IMPORTS *)&v5;
      }
      v2 = 0;
      if( v1->Count )
      {
        v3 = 0i64;
        do
        {
          v4 = v1->Entry[v3];
          if( !v4 )
            break;
          if( (unsigned int)MiUnloadApproved((ULONG_PTR)v1->Entry[v3]) == 1 )
            MiUnloadSystemImage(v4, 0xFFFFFFFFui64);
          v3 = ++v2;
        }
        while( v2 < v1->Count );
      }
    }
  }
}

Referenced by:

MiResolveImageReferences
MiUnloadSystemImage