KeQuerySpeculationControlInformation

NTSTATUS __stdcall KeQuerySpeculationControlInformation(VOID *a1, size_t Size){
  size_t *v2; 
  size_t v6; 
  unsigned int v7; 
  int v8; 
  unsigned __int64 v9; 
  int v10; 
  int v11; 
  __int64 v12; 
  unsigned int v13; 
  int v14; 
  int v15; 
  int v16; 
  char v17; 
  INT64 Src; 

  if( Size >= 4 )
  {
    v6 = Size;
    if( Size >= 8 )
      v6 = 8;
    *v2 = v6;
    v7 = (((KiSpeculationFeatures & 0x100000) != 0) ^ (unsigned __int8)((unsigned int)KiSpeculationFeatures >> 17)) & 2 ^ ((unsigned int)KiSpeculationFeatures >> 20) & 1;
    Src = ((unsigned __int8)v7 ^ (unsigned __int8)((unsigned int)KiSpeculationFeatures >> 17)) & 4 ^ (unsigned __int64)v7;
    v8 = 16;
    if( (KiSpeculationFeatures & 0x10) != 0 || (KiSpeculationFeatures & 0x40) != 0 )
      LODWORD(Src) = Src | 8;
    if( (KiSpeculationFeatures & 4) != 0 )
      LODWORD(Src) = Src | 0x10;
    if( (KiSpeculationFeatures & 0x100000) != 0 && (KiSpeculationFeatures & 0x200000) != 0 )
      LODWORD(Src) = Src | 0x2000;
    LODWORD(Src) = ((unsigned __int8)Src ^ (unsigned __int8)(2 * KiSpeculationFeatures)) & 0x20 ^ Src;
    LODWORD(Src) = ((unsigned __int8)Src ^ (unsigned __int8)KiSpeculationFeatures) & 0x40 ^ Src;
    LODWORD(Src) = Src & 0xFFFFFF7F | (4 * (KiSpeculationFeatures & 0x20 | 0x40));
    LODWORD(Src) = ((unsigned __int16)Src ^ (unsigned __int16)(4 * KiSpeculationFeatures)) & 0x200 ^ Src;
    LODWORD(Src) = ((unsigned __int16)Src ^ (unsigned __int16)((unsigned int)KiSpeculationFeatures >> 12)) & 0x400 ^ Src;
    LODWORD(Src) = ((unsigned __int16)Src ^ (unsigned __int16)((unsigned int)KiSpeculationFeatures >> 12)) & 0x800 ^ Src;
    LODWORD(Src) = ((unsigned __int16)Src ^ (unsigned __int16)~(16 * KiSpeculationFeatures)) & 0x1000 ^ Src;
    LODWORD(Src) = ((unsigned __int16)Src ^ (unsigned __int16)((unsigned int)KiSpeculationFeatures >> 11)) & 0x4000 ^ Src;
    LODWORD(Src) = (Src ^ ((unsigned int)KiSpeculationFeatures >> 11)) & 0x8000 ^ Src;
    v9 = (unsigned __int64)KeFeatureBits2;
    v17 = KiKvaShadow;
    if( !KiKvaShadow || (v10 = 637534208, ((unsigned __int8)KeFeatureBits2 & 8) == 0) )
      v10 = 603979776;
    v11 = v10 | Src & 0xFCFEFFFF | ((_DWORD)KeFeatureBits2 << 19) & 0x1000000 | ((KiSpeculationFeatures & 1 | 0x80) << 16) & 0xFDFFFFFF;
    v12 = (unsigned __int16)KeFeatureBits2 & 0x8000;
    if( ((unsigned __int16)KeFeatureBits2 & 0x8000) != 0 && KiDisableTsx || !KiTsxSupported )
    {
      v13 = v11 | 0x18000000;
    }
    else if( ((unsigned __int64)KeFeatureBits2 & 0x10000) != 0
           || ((unsigned __int8)KeFeatureBits2 & 0x28) == 8 && KeKvaShadowingActive() )
    {
      v13 = v11 & 0xE7FFFFFF | 0x10000000;
    }
    else if( v12 )
    {
      v13 = v11 & 0xE7FFFFFF | 0x8000000;
    }
    else
    {
      v13 = v11 & 0xE7FFFFFF;
    }
    if( (v9 & 0x10000) != 0 || !KiTsxSupportedAtBoot )
      v14 = 0x40000000;
    else
      v14 = 0;
    LODWORD(Src) = v14 | v13 & 0xBFFFFFFF;
    HvlQueryL1tfMitigationInformation(&Src);
    v15 = HIDWORD(Src) ^ (BYTE4(Src) ^ (unsigned __int8)(v9 >> 19)) & 7;
    if( v17 )
    {
      LOBYTE(v16) = KiIsFbClearSupported();
      if( v16 )
        v8 = 24;
    }
    HIDWORD(Src) = v8 | v15 & 0xFFFFFFF7;
    memset(a1, 0i64, Size);
    memmove(a1, &Src, v6);
    return 0;
  }
  else
  {
    *v2 = 8;
    return -1073741820;
  }
}

Referenced by:

ExpQuerySystemInformation