KiIdleLoop
VOID __fastcall __noreturn KiIdleLoop(INT64 a1, INT64 a2, INT64 a3, INT64 a4){
struct _KPRCB *CurrentPrcb;
__int64 v5;
int v6;
__int64 v7;
unsigned __int64 v8;
unsigned __int64 v9;
unsigned __int64 v10;
void *retaddr;
if( (_BYTE)KeSmapEnabled )
__clac();
retaddr = 0i64;
CurrentPrcb = KeGetCurrentPrcb();
while( 1 )
{
while( 1 )
{
if( HvlEnableIdleYield )
_mm_pause();
_enable();
_disable();
if( (*((_BYTE *)CurrentPrcb + 12588) & 0x3F) != 0 )
KiRetireDpcList(CurrentPrcb);
if( *((_BYTE *)CurrentPrcb + 12585) )
{
*((_BYTE *)CurrentPrcb + 12585) = 0;
_enable();
KiQuantumEnd();
_disable();
}
_InterlockedOr8((volatile signed __int8 *)CurrentPrcb + 7, 1u);
if( !*((_QWORD *)CurrentPrcb + 2) )
break;
*((_BYTE *)CurrentPrcb + 7) = 0;
_enable();
v5 = *((_QWORD *)CurrentPrcb + 3);
if( _interlockedbittestandset64((volatile signed __int32 *)CurrentPrcb + 12, 0i64) )
{
v6 = 0;
do
{
do
{
++v6;
_mm_pause();
}
while( (*((_QWORD *)CurrentPrcb + 6) & 1i64) != 0 );
}
while( _interlockedbittestandset64((volatile signed __int32 *)CurrentPrcb + 12, 0i64) );
}
v7 = *((_QWORD *)CurrentPrcb + 2);
*((_QWORD *)CurrentPrcb + 2) = 0i64;
if( v7 != v5 )
{
_disable();
++*((_BYTE *)CurrentPrcb + 32);
v8 = __rdtsc();
v9 = (unsigned __int64)HIDWORD(v8) << 32;
v10 = (v9 | (unsigned int)v8) - *((_QWORD *)CurrentPrcb + 4056);
*(_QWORD *)(v5 + 72) += v10;
*((_QWORD *)CurrentPrcb + 4056) += v10;
_enable();
*((_QWORD *)CurrentPrcb + 1) = v7;
*(_BYTE *)(v7 + 388) = 2;
_InterlockedAnd64((volatile signed __int64 *)CurrentPrcb + 6, 0i64);
goto LABEL_23;
}
*((_QWORD *)CurrentPrcb + 6) = 0i64;
}
if( *((_BYTE *)CurrentPrcb + 12587) )
{
*((_BYTE *)CurrentPrcb + 7) = 0;
_enable();
if( KiIdleSchedule((UINT64)CurrentPrcb) )
{
LABEL_23:
*((_BYTE *)CurrentPrcb + 6) |= (*((_BYTE *)CurrentPrcb + 12588) & 0x2F) != 0;
if( (_BYTE)KeSmapEnabled )
__stac();
SwapContext((_KTHREAD *)1, (_KTHREAD *)v9, a3);
if( (_BYTE)KeSmapEnabled )
__clac();
}
}
else
{
if( (*((_BYTE *)CurrentPrcb + 12588) & 0x3F) == 0 )
{
if( (_BYTE)KeSmapEnabled )
__stac();
__writecr8(0i64);
PoIdle((ULONG_PTR)CurrentPrcb);
_enable();
__writecr8(2ui64);
if( (_BYTE)KeSmapEnabled )
__clac();
}
*((_BYTE *)CurrentPrcb + 7) = 0;
}
}
}Referenced by:
KiSystemStartup