PpmEstimateIdleDuration
UINT64 *__fastcall PpmEstimateIdleDuration(
INT64 a1,
CHAR a2,
UINT8 a3,
UINT64 a4,
UINT64 a5,
UINT64 *a6,
UINT64 *a7,
INT64 *a8,
INT64 *a9){
__int64 v13;
UINT64 v14;
CHAR v15;
int v16;
unsigned int v17;
unsigned int v18;
unsigned int i;
unsigned __int64 v20;
ULONG v21;
UINT64 v22;
__int64 v23;
UINT64 v24;
UINT64 *v25;
UINT64 ProcessorNumber;
INT64 v27;
UINT64 *v28;
UINT64 *v29;
unsigned __int16 *v30[2];
__int16 v31;
int v32;
__int16 v33;
_KAFFINITY_EX result;
v29 = a6;
v28 = a7;
v32 = 0;
v33 = 0;
memset((INT64)&result, 0i64);
v13 = *(_QWORD *)(a1 + 0x8000);
v14 = -1i64;
v27 = 0i64;
LODWORD(ProcessorNumber) = 0;
v15 = *(_BYTE *)(v13 + 540);
v16 = 0;
*(_DWORD *)a9 = 0;
if( *(_BYTE *)(a1 + 33) )
{
v16 = 8;
*(_DWORD *)a9 = 8;
}
if( a2 )
*(_DWORD *)a9 = v16 | 4;
KeEstimateClockTickDuration(a1, v15, a2, a3, a4, &v27, a8);
v17 = *(_DWORD *)(a1 + 11684);
v18 = 0;
for( i = v17; i; i >>= 4 )
v18 += KeMaximumIncrement;
v20 = v18;
if( !a2 && v17 )
{
v21 = KeMaximumIncrement / (v17 + 1);
if( !v21 )
v21 = 1;
v14 = v21;
}
if( v27 <= v14 )
{
v14 = v27;
v20 = v27;
}
else
{
if( v27 < (unsigned __int64)v18 )
v20 = v27;
*(_DWORD *)a9 |= 1u;
}
if( PpmIdleDurationExpirationTimeout && *(_BYTE *)(a1 + 33) && (unsigned __int8)PpmGetIdleConstrainedMask(&result) )
{
v22 = 0i64;
v30[1] = (unsigned __int16 *)result.Bitmap[0];
v30[0] = (unsigned __int16 *)&result;
v31 = 0;
while( !(unsigned int)KeEnumerateNextProcessor(&ProcessorNumber, v30) )
{
KeGetPrcb((unsigned int)ProcessorNumber);
v24 = *(_QWORD *)(v23 + 32808);
if( v24 != -1i64 && v24 > v22 )
v22 = *(_QWORD *)(v23 + 32808);
}
if( v22 && v20 + a4 > v22 )
{
*(_DWORD *)a9 |= 0x2000u;
v20 = v22 > a4 ? (unsigned int)(v22 - a4) : 1i64;
if( v20 < v14 )
v14 = v20;
}
}
if( v14 < a5 )
{
*(_DWORD *)a9 |= 0x1000u;
v14 = a5;
v20 = a5;
}
*v28 = v20;
v25 = v29;
*v29 = v14;
return v25;
}Referenced by:
PpmIdleSelectStates