KeFlushMultipleRangeTb
VOID __stdcall KeFlushMultipleRangeTb(
UINT64 Number,
_KTB_FLUSH_VA *Virtual,
_KTBFLUSH_TYPE FlushType,
_KTBFLUSH_TARGET ProcessorSet){
int v4;
__int64 v7;
char v9;
unsigned __int8 CurrentIrql;
struct _KPRCB *CurrentPrcb;
_IPI_TYPE v12;
_KAFFINITY_EX *p_KeFlushTbAffinity;
UINT64 v14;
unsigned __int16 v15;
_EPROCESS *Process;
unsigned __int16 Count;
__int64 v18;
unsigned int v19;
__int64 v20;
__int64 v21;
unsigned int v22;
unsigned __int64 v23;
unsigned __int16 v24;
unsigned __int64 v25;
_KAFFINITY_EX *v26;
unsigned __int8 v27;
char v28;
char v29;
_KTB_FLUSH_VA *v30;
__int64 v31;
unsigned __int8 v32;
int v33[8];
UINT64 RequestType;
UINT64 v35;
_KTB_FLUSH_VA *v36;
char Global[8];
UINT64 AddressSpace;
UINT64 Parameter;
int v40;
_KTBFLUSH_TYPE v41;
char v42;
unsigned __int8 v43;
v4 = 0;
v7 = (unsigned int)Number;
AddressSpace = 0i64;
v42 = 0;
Global[0] = 0;
v43 = 0;
RequestType = (UINT64)&v43;
v9 = 0;
if( KiPreprocessFlushTb(0i64, (unsigned int)FlushType, (unsigned int)ProcessorSet, &v42) )
{
if( (_DWORD)v7 )
{
v30 = Virtual;
v31 = v7;
do
{
KiFlushRangeTb((_KTB_FLUSH_VA)v30->u1.0);
++v30;
--v31;
}
while( v31 );
}
__writecr8(v43);
v9 = 1;
}
if( FlushType == FlushUser
&& Virtual->u1.VaLong <= 0x7FFFFFFEFFFFi64
&& *(_QWORD *)&KeGetCurrentThread()->ApcState.Process->Pcb.SecureState
|| v42 )
{
KiPrepareFlushParameters(FlushType, &AddressSpace, (UINT8 *)Global);
LODWORD(v26) = KiFlushAffinity((unsigned int)ProcessorSet);
v36 = Virtual;
LODWORD(v35) = v7;
LOBYTE(RequestType) = v28;
HvlFlushRangeListTb(AddressSpace, v26, Global[0], v27, (VOID **)RequestType);
v9 |= v29;
}
if( !v9 )
{
Parameter = (UINT64)Virtual;
v40 = v7;
v41 = FlushType;
CurrentIrql = KeGetCurrentIrql();
__writecr8(0xCui64);
CurrentPrcb = KeGetCurrentPrcb();
if( ProcessorSet )
{
v12 = IpiAllButSelf;
p_KeFlushTbAffinity = 0i64;
if( (unsigned int)KeNumberProcessors_0 > 1 )
{
LABEL_9:
v14 = 2147483652i64;
if( ProcessorSet != FlushAllAwakeProcessors )
v14 = 4i64;
KiIpiSendRequest(CurrentPrcb, v12, p_KeFlushTbAffinity, (UINT64)&Parameter, v14, v35);
KiFlushRangeWorker((INT64)&Parameter);
while( CurrentPrcb->PacketBarrier )
{
++v4;
_mm_pause();
}
goto LABEL_23;
}
}
else
{
_InterlockedOr(v33, 0);
p_KeFlushTbAffinity = &CurrentPrcb->StaticAffinity.KeFlushTbAffinity;
v15 = 0;
Process = CurrentPrcb->CurrentThread->Tcb.ApcState.Process;
Count = Process->Pcb.ActiveProcessors.Count;
CurrentPrcb->StaticAffinity.KeFlushTbAffinity.Count = Count;
CurrentPrcb->StaticAffinity.KeFlushTbAffinity.Size = Process->Pcb.ActiveProcessors.Size;
CurrentPrcb->StaticAffinity.KeFlushTbAffinity.Reserved = 0;
if( Process->Pcb.ActiveProcessors.Count )
{
do
{
v18 = v15++;
p_KeFlushTbAffinity->Bitmap[v18] = Process->Pcb.ActiveProcessors.Bitmap[v18];
}
while( v15 < Process->Pcb.ActiveProcessors.Count );
Count = p_KeFlushTbAffinity->Count;
}
v19 = Count;
v20 = CurrentPrcb->Number;
v21 = (unsigned int)KiProcessorIndexToNumberMappingTable[v20] >> 6;
v22 = KiProcessorIndexToNumberMappingTable[v20] & 0x3F;
if( v19 > (unsigned int)v21 )
{
v23 = p_KeFlushTbAffinity->Bitmap[v21];
_bittestandreset64((__int64 *)&v23, v22);
p_KeFlushTbAffinity->Bitmap[v21] = v23;
LOWORD(v19) = p_KeFlushTbAffinity->Count;
}
v12 = IpiAffinity;
v24 = 0;
if( (_WORD)v19 )
{
do
{
v25 = p_KeFlushTbAffinity->Bitmap[v24];
if( v25 )
{
if( v24 != CurrentPrcb->Group || v25 != CurrentPrcb->GroupSetMember )
goto LABEL_9;
}
}
while( ++v24 < p_KeFlushTbAffinity->Count );
}
}
KiFlushRangeWorker((INT64)&Parameter);
LABEL_23:
__writecr8(CurrentIrql);
goto LABEL_24;
}
if( FlushType == 4 )
KeFlushProcessWriteBuffers(1u);
LABEL_24:
if( VmTbFlushEnabled )
VmFlushTb((_MEMORY_CACHING_TYPE_ORIG)v7, (UINT64 *)Virtual, (unsigned int)FlushType);
if( *(&stru_140CF2E80 + 1830) )
{
v32 = KeGetCurrentIrql();
__writecr8(0xFui64);
ExFlushTb((unsigned int)v7, Virtual, FlushType);
__writecr8(v32);
}
}Referenced by:
MiAgeWorkingSetTail
MiFlushTbList