PsSetCpuQuotaInformation
NTSTATUS __stdcall PsSetCpuQuotaInformation(PVOID SystemInformation, UINT64 SystemInformationLength, INT8 PreviousMode){
__int64 v4;
__int64 v7;
_QWORD *PoolWithQuotaTag;
_QWORD *v9;
INT64 v10;
INT64 v11;
__int64 i;
int v13;
int v14;
__int64 j;
void *v16;
PVOID v17;
INT64 SessionSchedulingGroup;
PVOID Object;
v4 = (unsigned int)SystemInformationLength;
if( !PsCpuFairShareEnabled )
return -1073741823;
if( (unsigned int)SystemInformationLength < 0x10 || (SystemInformationLength & 0xF) != 0 )
return -1073741820;
if( PreviousMode )
{
if( !SeSinglePrivilegeCheck(*(_QWORD *)&SeIncreaseQuotaPrivilege, PreviousMode) )
return -1073741727;
if( PreviousMode )
{
if( ((unsigned __int8)SystemInformation & 7) != 0 )
ExRaiseDatatypeMisalignment();
if( (unsigned __int64)SystemInformation + v4 > 0x7FFFFFFF0000i64
|| (char *)SystemInformation + v4 < SystemInformation )
{
MEMORY[0x7FFFFFFF0000] = 0;
}
}
}
v7 = (unsigned int)v4 >> 4;
if( (unsigned __int64)(24 * v7) > 0xFFFFFFFF )
return -1073741675;
PoolWithQuotaTag = ExAllocatePoolWithQuotaTag((POOL_TYPE)520, (unsigned int)(24 * v7), 0x63537350ui64);
v9 = PoolWithQuotaTag;
if( !PoolWithQuotaTag )
return -1073741670;
v10 = (INT64)&PoolWithQuotaTag[v7];
v11 = v10 + 8 * v7;
for( i = 0i64; (unsigned int)i < (unsigned int)v7; i = (unsigned int)(i + 1) )
{
v9[i] = *((_QWORD *)SystemInformation + 2 * (unsigned int)i);
*(_DWORD *)(v11 + 8 * i + 4) = 0;
v13 = *((_DWORD *)SystemInformation + 4 * (unsigned int)i + 2);
*(_DWORD *)(v11 + 8 * i) = v13;
if( (unsigned __int16)(v13 - 1) > 8u )
{
v14 = -1073740712;
goto LABEL_32;
}
}
v14 = 0;
for( j = 0i64; (unsigned int)j < (unsigned int)v7; j = (unsigned int)(j + 1) )
{
v16 = (void *)v9[j];
Object = 0i64;
v14 = ObReferenceObjectByHandle(v16, 2u, MmSessionObjectType, PreviousMode, &Object, 0i64);
v17 = Object;
v9[j] = Object;
if( v14 < 0 )
goto LABEL_30;
SessionSchedulingGroup = MmGetSessionSchedulingGroup((INT64)v17);
*(_QWORD *)(v10 + 8 * j) = SessionSchedulingGroup;
if( !SessionSchedulingGroup )
{
v14 = -1073740715;
goto LABEL_30;
}
}
KeSetSchedulingGroupWeights((unsigned int)v7, v10, v10 + 8 * v7);
LABEL_30:
while( (_DWORD)j )
{
j = (unsigned int)(j - 1);
ObfDereferenceObjectWithTag((PVOID)v9[j], 0x746C6644ui64);
}
LABEL_32:
ExFreePoolWithTag(v9, 0x63537350u);
return v14;
}Referenced by:
NtSetSystemInformation