KsepResolveShimHooks

INT64 __fastcall KsepResolveShimHooks(INT64 a1, INT64 *a2, INT8 a3){
  __int64 v5; 
  INT64 *v6; 
  int v7; 
  int v8; 
  int v9; 
  void *v10; 
  INT64 result; 
  __int64 v12; 
  int v13; 
  __int64 v14; 
  void *a3a; 
  a3a = 0i64;
  if( a1 && a2 )
  {
    LODWORD(v5) = 0;
    v6 = a2;
    while( 1 )
    {
      v7 = *(_DWORD *)v6;
      if( *(_DWORD *)v6 == 4 )
        return 0i64;
      if( v7 )
      {
        v8 = v7 - 1;
        if( v8 )
        {
          v9 = v8 - 1;
          if( !v9 )
          {
            result = KsepGetModuleInfoByName((const WCHAR *)v6[1], (_DWORD *)a1, &a3a);
            if( (int)result < 0 )
              return result;
            v10 = a3a;
            goto LABEL_15;
          }
          if( v9 != 1 )
            return 3221225485i64;
          v10 = 0i64;
        }
        else
        {
          v10 = *(void **)(a1 + 320);
        }
      }
      else
      {
        v10 = *(void **)(a1 + 24);
      }
      a3a = v10;
LABEL_15:
      v12 = v6[2];
      v13 = 0;
      if( v12 )
      {
        while( *(_DWORD *)v12 != 2 )
        {
          if( !*(_DWORD *)v12 )
          {
            LODWORD(v14) = RtlFindExportedRoutineByName(v10, *(PSTR *)(v12 + 8), a3);
            if( !v14 )
              return 3221225473i64;
            *(_QWORD *)(v12 + 24) = v14;
          }
          v12 = v6[2] + 32i64 * (unsigned int)++v13;
          if( !v12 )
            break;
        }
      }
      v5 = (unsigned int)(v5 + 1);
      v6 = &a2[3 * v5];
      if( !v6 )
        return 0i64;
    }
  }
  return 3221225485i64;
}

Referenced by:

KsepResolveApplicableShimsForDriver