KeCpuSetReportParkedProcessors
VOID __stdcall KeCpuSetReportParkedProcessors(_KAFFINITY_EX *CoreParkingMask, UINT8 OldIrql){
unsigned int v2;
UINT8 v3;
int v5;
unsigned __int16 v6;
int v7;
unsigned __int64 v8;
UINT64 v9;
unsigned __int64 v10;
unsigned __int64 v11;
unsigned __int64 v12;
unsigned __int16 i;
__int64 v14;
struct _KPRCB *CurrentPrcb;
ULONG_PTR v16;
bool v17;
unsigned __int64 v18;
__int64 v19;
__int64 v20;
__int64 v21;
__int64 v22;
UINT64 v23;
unsigned __int64 v24;
_SINGLE_LIST_ENTRY *Next;
__int64 v26;
unsigned __int64 v27;
unsigned __int64 v28;
int v29;
__int64 v30;
__int64 v31;
__int64 v32;
__int64 v33;
int v35;
unsigned int v36;
SINGLE_LIST_ENTRY ReadyList;
int v38;
UINT64 SpinCount[20];
v2 = (unsigned __int16)KiActiveGroups;
v3 = OldIrql;
v38 = 0;
v36 = (unsigned __int16)KiActiveGroups;
_m_prefetchw(KiCpuSetAffinities);
_m_prefetchw(KiCpuSetAffinitiesShadow);
if( CoreParkingMask )
KxAcquireSpinLock(&KiCpuSetLock);
v5 = 0;
v35 = 0;
v6 = 0;
if( v2 )
{
v7 = 0;
while( 1 )
{
v8 = KeActiveProcessors.Bitmap[v6];
if( CoreParkingMask )
{
if( v6 >= CoreParkingMask->Count )
v18 = 0i64;
else
v18 = CoreParkingMask->Bitmap[v6];
v9 = v8 ^ v18;
*(UINT64 *)((char *)&SpinCount[v6] + 4) = v9;
if( KiNonParkedCpuSets[v6] == v9 )
goto LABEL_53;
}
else
{
v9 = KiNonParkedCpuSets[v6];
*(UINT64 *)((char *)&SpinCount[v6] + 4) = v9;
}
v35 = 1;
v10 = v8 & v9;
v5 = 1;
v11 = v8 ^ v8 & v9;
if( (v8 & v9) != 0 )
{
do
{
_BitScanForward64(&v12, v10);
v38 = v12;
v10 ^= 1i64 << v12;
*(_QWORD *)&KiCpuSetAffinitiesShadow[8 * (unsigned int)((v7 << 6) + v12)] = 1i64 << v12;
}
while( v10 );
v2 = v36;
v5 = 1;
}
if( !v11 )
goto LABEL_11;
v19 = qword_140CFCA78[2 * v6];
v20 = v19 & -(__int64)((v9 & (v8 ^ v19)) != 0 && (v9 & v19) != 0);
v21 = (v8 ^ v19) & -(__int64)((v9 & (v8 ^ v19)) != 0 && (v9 & v19) != 0);
v22 = v8 ^ KiSystemAllowedCpuSets[2 * v6];
ReadyList.Next = (_SINGLE_LIST_ENTRY *)v21;
v23 = v22 & v9;
if( v22 )
{
if( v23 )
{
v24 = v11 & v22;
v11 ^= v24;
if( v24 )
{
Next = ReadyList.Next;
do
{
_BitScanForward64((unsigned __int64 *)&v26, v24);
v24 &= ~(1i64 << v26);
if( _bittest64(&v20, (unsigned int)v26) )
{
v27 = v23 & v20;
if( (v23 & v20) == 0 )
v27 = v23;
}
else
{
v27 = v23;
if( (v23 & (unsigned __int64)Next) != 0 )
v27 = v23 & (unsigned __int64)Next;
}
*(_QWORD *)&KiCpuSetAffinitiesShadow[8 * (unsigned int)((v7 << 6) + v26)] = v27;
}
while( v24 );
v2 = v36;
v21 = (__int64)ReadyList.Next;
}
}
}
if( v11 )
{
v28 = v8 & ~v23;
if( (v9 & v28) == 0 )
v28 = v8;
v29 = v7 << 6;
do
{
_BitScanForward64((unsigned __int64 *)&v30, v11);
v31 = v28;
v11 &= ~(1i64 << v30);
if( _bittest64(&v20, (unsigned int)v30) )
{
v31 = v20 & v28;
if( (v28 & v9 & v20) == 0 )
v31 = v28;
}
else if( (v9 & v21 & v28) != 0 )
{
v31 = v28 & v21;
}
*(_QWORD *)&KiCpuSetAffinitiesShadow[8 * (unsigned int)(v29 + v30)] = v31;
}
while( v11 );
}
LABEL_53:
v5 = v35;
LABEL_11:
v7 = ++v6;
if( v6 >= v2 )
{
v3 = OldIrql;
break;
}
}
}
ReadyList.Next = 0i64;
if( v5 )
{
RtlWriteAcquireTickLock(&KiCpuSetSequence);
for( i = 0; i < v2; KiNonParkedCpuSets[v14] = *(UINT64 *)((char *)&SpinCount[v14] + 4) )
v14 = i++;
memmove(KiCpuSetAffinities, KiCpuSetAffinitiesShadow, (unsigned int)KiCpuSetAffinitySize);
++KiCpuSetSequence;
KiUpdateGlobalCpuSetConfiguration(&ReadyList);
}
KxReleaseSpinLock(&KiCpuSetLock);
CurrentPrcb = KeGetCurrentPrcb();
KiReadyDeferredReadyList(CurrentPrcb, &ReadyList);
if( v3 >= 2u )
{
if( *((_QWORD *)CurrentPrcb + 2) && !*((_BYTE *)CurrentPrcb + 12586) )
KiRequestSoftwareInterrupt(CurrentPrcb, 2);
}
else
{
v16 = *((_QWORD *)CurrentPrcb + 1);
if( *((_QWORD *)CurrentPrcb + 2) )
{
KiAbProcessContextSwitch(*((_KTHREAD **)CurrentPrcb + 1), 0i64);
LODWORD(SpinCount[0]) = 0;
while( _interlockedbittestandset64((volatile signed __int32 *)CurrentPrcb + 12, 0i64) )
{
do
KeYieldProcessorEx(SpinCount);
while( *((_QWORD *)CurrentPrcb + 6) );
}
v32 = *((_QWORD *)CurrentPrcb + 2);
*((_QWORD *)CurrentPrcb + 2) = 0i64;
_disable();
KiEndThreadCycleAccumulation(CurrentPrcb, (_KTHREAD *)v16, 0i64);
_enable();
*((_QWORD *)CurrentPrcb + 1) = v32;
if( *(_BYTE *)(v32 + 388) == 1 )
{
v33 = (unsigned int)(*(_DWORD *)(v32 + 132) - *(_DWORD *)(v32 + 436));
*(_DWORD *)(v32 + 132) = v33 + KUSER_SHARED_DATA.TickCount.LowPart;
}
*(_BYTE *)(v32 + 388) = 2;
*(_BYTE *)(v16 + 643) = 32;
*(_BYTE *)(v16 + 390) = v3;
KiQueueReadyThread((__int64)CurrentPrcb, v16, v33);
v17 = !KiSwapContext((PKTHREAD)v16, (PKTHREAD)v32);
}
else
{
v17 = (*(_DWORD *)(v16 + 116) & 0x40) == 0;
}
if( !v17 )
{
__writecr8(1ui64);
*(_DWORD *)(v16 + 116) &= ~0x40u;
KiDeliverApc(0, 0i64, 0i64);
}
__writecr8(v3);
}
}Referenced by:
KeSetSystemAllowedCpuSets
PpmParkReportMask