SePrivilegePolicyCheck
NTSTATUS __stdcall SePrivilegePolicyCheck(
UINT64 *RemainingDesiredAccess,
UINT64 *PreviouslyGrantedAccess,
SECURITY_SUBJECT_CONTEXT *SubjectSecurityContext,
PVOID ExplicitToken,
PRIVILEGE_SET **PrivilegeSet,
INT8 PreviousMode){
unsigned int v6;
char v7;
unsigned int v11;
int v12;
char v13;
char v14;
UINT64 v16;
char v17;
PRIVILEGE_SET *PoolWithTag;
unsigned int v19;
__int64 v20;
__int64 v21;
__int64 v22;
INT64 v23;
int v24;
v6 = 0;
v7 = 0;
v11 = 0;
if( SubjectSecurityContext )
{
ExplicitToken = SubjectSecurityContext->ClientToken;
if( !SubjectSecurityContext->ClientToken )
ExplicitToken = SubjectSecurityContext->PrimaryToken;
}
v12 = *(_DWORD *)RemainingDesiredAccess;
if( (*(_DWORD *)RemainingDesiredAccess & 0x1000000) != 0 )
{
v23 = *(_QWORD *)SeSecurityPrivilege;
v24 = 0;
if( !SepPrivilegeCheck((INT64)ExplicitToken, (INT64)&v23, 1ui64, 1, PreviousMode) )
return -1073741727;
*(_DWORD *)RemainingDesiredAccess &= ~0x1000000u;
v11 = v19;
*(_DWORD *)PreviouslyGrantedAccess |= 0x1000000u;
v7 = v19;
v12 = *(_DWORD *)RemainingDesiredAccess;
}
if( (v12 & 0x80000) == 0 )
goto LABEL_4;
v23 = SeTakeOwnershipPrivilege;
v24 = 0;
if( SepPrivilegeCheck((INT64)ExplicitToken, (INT64)&v23, 1ui64, 1, PreviousMode) )
{
*(_DWORD *)RemainingDesiredAccess &= ~0x80000u;
++v11;
*(_DWORD *)PreviouslyGrantedAccess |= 0x80000u;
v14 = v16;
v13 = 0;
goto LABEL_6;
}
v23 = SeRelabelPrivilege;
v24 = 0;
if( SepPrivilegeCheck((INT64)ExplicitToken, (INT64)&v23, v16, v16, PreviousMode) )
{
*(_DWORD *)RemainingDesiredAccess &= ~0x80000u;
++v11;
*(_DWORD *)PreviouslyGrantedAccess |= 0x80000u;
v13 = v17;
}
else
{
LABEL_4:
v13 = 0;
}
v14 = 0;
LABEL_6:
if( !v11 )
return 0;
PoolWithTag = (PRIVILEGE_SET *)ExAllocatePoolWithTag(PagedPool, 12 * v11 + 8, 0x72506553ui64);
*PrivilegeSet = PoolWithTag;
if( PoolWithTag )
{
PoolWithTag->PrivilegeCount = v11;
(*PrivilegeSet)->Control = 0;
if( v14 )
{
v6 = 1;
(*PrivilegeSet)->Privilege[0].Luid = (_LUID)SeTakeOwnershipPrivilege;
(*PrivilegeSet)->Privilege[0].Attributes = 0x80000000;
}
if( v7 )
{
v20 = v6++;
v21 = v20;
(*PrivilegeSet)->Privilege[v21].Luid = *(_LUID *)SeSecurityPrivilege;
(*PrivilegeSet)->Privilege[v21].Attributes = 0x80000000;
}
if( v13 )
{
v22 = v6;
(*PrivilegeSet)->Privilege[v22].Luid = (_LUID)SeRelabelPrivilege;
(*PrivilegeSet)->Privilege[v22].Attributes = 0x80000000;
}
return 0;
}
return -1073741670;
}Referenced by:
SeAccessCheckByTypeWithAdminlessChecks
SepAccessCheckAndAuditAlarmWithAdminlessChecks