KeFlushTb

void __fastcall KeFlushTb(__int64 a1, unsigned int a2){
  int v2; 
  INT64 v4; 
  int v5; 
  INT64 v6; 
  char v7; 
  UINT8 v8; 
  unsigned __int8 CurrentIrql; 
  char v10[8]; 
  __int64 AddressSpace[4]; 
  BYTE v12; 
  v2 = 0;
  AddressSpace[0] = 0i64;
  v4 = a2;
  v12 = 0;
  v5 = a1;
  v10[0] = 0;
  v6 = (unsigned int)a1;
  LOBYTE(a1) = 1;
  v7 = 0;
  if( KiPreprocessFlushTb(a1, v6, v4, &v12) )
  {
    KiFlushCurrentTbOnly((unsigned int)v5);
    __writecr8(0i64);
    v7 = 1;
  }
  if( v12 )
  {
    KiPrepareFlushParameters((unsigned int)v5, (UINT64 *)AddressSpace, v10);
    v8 = (unsigned __int8)KiFlushAffinity(a2);
    KiFlushAddressSpaceTb(AddressSpace[0], v8);
  }
  else if( !v7 )
  {
    if( (_BYTE)KiKvaShadow )
    {
      if( v5 != 1 && (!v5 || v5 == 2) )
      {
LABEL_21:
        KxFlushNonGlobalTb(a2);
        v2 = 1;
        goto LABEL_9;
      }
    }
    else if( v5 && v5 <= 2 )
    {
      goto LABEL_21;
    }
    KxFlushEntireTb(a2);
    v2 = 1;
  }
LABEL_9:
  if( v5 == 1 && *(_QWORD *)(*((_QWORD *)KeGetCurrentThread() + 23) + 992i64) )
    VslFlushSecureAddressSpace();
  if( !v2 && v5 == 4 )
    KeFlushProcessWriteBuffers(1u);
  if( VmTbFlushEnabled )
    VmFlushTb(0, 0i64, v5);
  if( ExTbFlushActive )
  {
    CurrentIrql = KeGetCurrentIrql();
    __writecr8(0xFui64);
    ExFlushTb(0, 0i64, v5);
    __writecr8(CurrentIrql);
  }
}

Referenced by:

MiAgeWorkingSetTail
MiAttachSession
MiFlushEntireTbDueToAttributeChange
MiFlushTbList
MiGetUltraMapping
MiGetWsAndMakePageTablesNx
MiInitializeTbFlush
MiInsertCachedPte
MiSwitchToPfns