Add function to consume audit masks
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 30s
Builds / ExectOS (amd64, debug) (push) Failing after 41s
Builds / ExectOS (i686, release) (push) Failing after 29s
Builds / ExectOS (i686, debug) (push) Failing after 39s

This commit is contained in:
2026-07-14 23:22:30 +02:00
parent f99e919cb7
commit 5349bd115e
2 changed files with 73 additions and 0 deletions

View File

@@ -18,6 +18,10 @@ namespace OB
class Security
{
public:
STATIC XTAPI VOID AuditObjectAccess(IN HANDLE Handle,
IN PHANDLE_TABLE_ENTRY_INFO ObjectTableEntryInfo,
IN PUNICODE_STRING ObjectTypeName,
IN ACCESS_MASK DesiredAccess);
STATIC XTAPI XTSTATUS ProcessObjectSecurityDescriptor(IN PVOID Object,
IN SECURITY_OPERATION_CODE OperationCode,
IN PSECURITY_INFORMATION SecurityInformation,

View File

@@ -9,6 +9,75 @@
#include <xtos.hh>
/**
* Consumes the audit mask for a handle table entry and triggers a security audit alarm if the requested access
* rights match the audit requirements.
*
* @param Handle
* Supplies the handle being accessed.
*
* @param ObjectTableEntryInfo
* Supplies a pointer to the extended handle table entry information containing the volatile audit mask.
*
* @param ObjectTypeName
* Supplies a pointer to the Unicode string representing the object's type name.
*
* @param AccessMask
* Supplies the access mask requested by the caller to be evaluated against the audit mask.
*
* @return This routine does not return a value.
*
* @since XT 1.0
*/
XTAPI
VOID
OB::Security::AuditObjectAccess(IN HANDLE Handle,
IN PHANDLE_TABLE_ENTRY_INFO ObjectTableEntryInfo,
IN PUNICODE_STRING ObjectTypeName,
IN ACCESS_MASK AccessMask)
{
ACCESS_MASK BitsToAudit, CurrentAuditMask, PreviousAuditMask, RemainingAuditMask;
/* Enter a CAS loop */
while(ObjectTableEntryInfo->AuditMask)
{
/* Capture the current state of the audit mask */
CurrentAuditMask = ObjectTableEntryInfo->AuditMask;
/* Mask out the access rights */
RemainingAuditMask = CurrentAuditMask & ~AccessMask;
/* Check if the requested access intersects with the audit mask */
if(RemainingAuditMask == CurrentAuditMask)
{
/* No overlapping bits, return */
return;
}
/* Attempt to update the audit mask */
PreviousAuditMask = (ACCESS_MASK)RTL::Atomic::CompareExchange32((VOLATILE PLONG)&ObjectTableEntryInfo->AuditMask,
(LONG)RemainingAuditMask,
(LONG)CurrentAuditMask);
/* Verify if the update succeeded */
if(PreviousAuditMask == CurrentAuditMask)
{
/* Extract the access bits */
BitsToAudit = PreviousAuditMask & AccessMask;
/* Check if there are active bits */
if(BitsToAudit)
{
/* Dispatch the audit event */
SE::Audit::OperationAuditAlarm(NULLPTR, Handle, ObjectTypeName, BitsToAudit, NULLPTR);
}
/* Auditing completed, return */
return;
}
}
}
/**
* Provides the default security procedure for handling object security descriptors.
*