Skip to content

Commit bac67a6

Browse files
committed
[NTOS:SE] Implement SepGetSidFromAce
This function will be used to retrieve a security identifier from a valid access control entry in the kernel. Mostly and exclusively used within access checks related code and such.
1 parent c93bf84 commit bac67a6

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

ntoskrnl/se/sid.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,77 @@ SepReleaseSid(
412412
}
413413
}
414414

415+
/**
416+
* @brief
417+
* Captures a security identifier from a
418+
* given access control entry. This identifier
419+
* is valid for the whole of its lifetime.
420+
*
421+
* @param[in] AceType
422+
* The type of an access control entry. This
423+
* type that is given by the calling thread
424+
* must coincide with the actual ACE that is
425+
* given in the second parameter otherwise this
426+
* can potentially lead to UNDEFINED behavior!
427+
*
428+
* @param[in] Ace
429+
* A pointer to an access control entry, which
430+
* can be obtained from a DACL.
431+
*
432+
* @return
433+
* Returns a pointer to a security identifier (SID),
434+
* otherwise NULL is returned if an unsupported ACE
435+
* type was given to the function.
436+
*/
437+
PSID
438+
NTAPI
439+
SepGetSidFromAce(
440+
_In_ UCHAR AceType,
441+
_In_ PACE Ace)
442+
{
443+
PSID Sid;
444+
PAGED_CODE();
445+
446+
/* Sanity check */
447+
ASSERT(Ace);
448+
449+
/* Initialize the SID */
450+
Sid = NULL;
451+
452+
/* Obtain the SID based upon ACE type */
453+
switch (AceType)
454+
{
455+
case ACCESS_DENIED_ACE_TYPE:
456+
{
457+
Sid = (PSID)&((PACCESS_DENIED_ACE)Ace)->SidStart;
458+
break;
459+
}
460+
461+
case ACCESS_ALLOWED_ACE_TYPE:
462+
{
463+
Sid = (PSID)&((PACCESS_ALLOWED_ACE)Ace)->SidStart;
464+
break;
465+
}
466+
467+
case ACCESS_DENIED_OBJECT_ACE_TYPE:
468+
{
469+
Sid = (PSID)&((PACCESS_DENIED_OBJECT_ACE)Ace)->SidStart;
470+
break;
471+
}
472+
473+
case ACCESS_ALLOWED_OBJECT_ACE_TYPE:
474+
{
475+
Sid = (PSID)&((PACCESS_ALLOWED_OBJECT_ACE)Ace)->SidStart;
476+
break;
477+
}
478+
479+
default:
480+
break;
481+
}
482+
483+
return Sid;
484+
}
485+
415486
/**
416487
* @brief
417488
* Captures a SID with attributes.

0 commit comments

Comments
 (0)