Implement privilege check functions
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 34s
Builds / ExectOS (i686, debug) (push) Successful in 39s
Builds / ExectOS (i686, release) (push) Successful in 49s
Builds / ExectOS (amd64, release) (push) Successful in 52s

This commit is contained in:
2026-08-18 23:18:12 +02:00
parent 61218ad742
commit b33b6b2131
2 changed files with 85 additions and 0 deletions

View File

@@ -19,8 +19,18 @@ namespace SE
{
public:
STATIC XTAPI BOOLEAN CheckPrivilege(IN OUT PPRIVILEGE_SET RequiredPrivileges,
IN PSECURITY_SUBJECT_CONTEXT SecurityContext,
IN KPROCESSOR_MODE ProcessorMode);
STATIC XTAPI BOOLEAN CheckSinglePrivilege(LUID PrivilegeValue,
KPROCESSOR_MODE ProcessorMode);
private:
STATIC XTAPI BOOLEAN CheckPrivilege(IN PTOKEN Token,
IN OUT PLUID_AND_ATTRIBUTES Privileges,
IN ULONG PrivilegeCount,
IN ULONG PrivilegeSet,
IN KPROCESSOR_MODE ProcessorMode);
};
}

View File

@@ -9,6 +9,81 @@
#include <xtos.hh>
/**
* Performs a privilege check against a specific access token.
*
* @param Token
* Supplies a pointer to the access token being queried.
*
* @param Privileges
* Supplies a pointer to an array of privileges and their attributes.
*
* @param PrivilegeCount
* Supplies the number of privileges in the array.
*
* @param PrivilegeSet
* Supplies the control flags specifying how the privileges are evaluated.
*
* @param ProcessorMode
* Supplies the processor mode from which the request originated.
*
* @return This routine returns TRUE if the required privileges are held, or FALSE otherwise.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
SE::Privileges::CheckPrivilege(IN PTOKEN Token,
IN OUT PLUID_AND_ATTRIBUTES Privileges,
IN ULONG PrivilegeCount,
IN ULONG PrivilegeSet,
IN KPROCESSOR_MODE ProcessorMode)
{
UNIMPLEMENTED;
/* Return TRUE */
return TRUE;
}
/**
* Checks whether the specified privileges are held by the security context.
*
* @param RequiredPrivileges
* Supplies a pointer to the privilege set that specifies the privileges to check.
*
* @param SecurityContext
* Supplies a pointer to the security subject context representing the caller.
*
* @param ProcessorMode
* Supplies the processor mode of the caller.
*
* @return This routine returns TRUE if the required privileges are held, or FALSE otherwise.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
SE::Privileges::CheckPrivilege(IN OUT PPRIVILEGE_SET RequiredPrivileges,
IN PSECURITY_SUBJECT_CONTEXT SecurityContext,
IN KPROCESSOR_MODE ProcessorMode)
{
PACCESS_TOKEN Token;
/* Verify that an existing client token has a sufficient impersonation level */
if((SecurityContext->ClientToken != NULLPTR) && (SecurityContext->ImpersonationLevel < SecurityImpersonation))
{
/* The impersonation level is too low to perform privilege checks, return FALSE */
return FALSE;
}
/* Select the effective access token based on the presence of a client impersonation token */
Token = SecurityContext->ClientToken ? SecurityContext->ClientToken : SecurityContext->PrimaryToken;
/* Dispatch the privilege check and return the result */
return CheckPrivilege((PTOKEN)Token, RequiredPrivileges->Privilege, RequiredPrivileges->PrivilegeCount,
RequiredPrivileges->Control, ProcessorMode);
}
/**
* Checks if the current thread's access token holds a specific privilege.
*