1 /* $Id: semgr.c,v 1.44 2004/09/14 11:04:48 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Security manager
6 * FILE: kernel/se/semgr.c
9 * 26/07/98: Added stubs for security functions
12 /* INCLUDES *****************************************************************/
16 #include <internal/debug.h>
18 #define TAG_SXPT TAG('S', 'X', 'P', 'T')
21 /* GLOBALS ******************************************************************/
23 PSE_EXPORTS EXPORTED SeExports
= NULL
;
25 static ERESOURCE SepSubjectContextLock
;
28 /* PROTOTYPES ***************************************************************/
30 static BOOLEAN
SepInitExports(VOID
);
33 /* FUNCTIONS ****************************************************************/
40 if (!SepInitSecurityIDs())
51 if (!SepInitExports())
54 /* Initialize the subject context lock */
55 ExInitializeResource(&SepSubjectContextLock
);
64 SepInitializeTokenImplementation();
73 OBJECT_ATTRIBUTES ObjectAttributes
;
75 HANDLE DirectoryHandle
;
79 /* Create '\Security' directory */
80 RtlInitUnicodeString(&Name
,
82 InitializeObjectAttributes(&ObjectAttributes
,
87 Status
= NtCreateDirectoryObject(&DirectoryHandle
,
90 if (!NT_SUCCESS(Status
))
92 DPRINT1("Failed to create 'Security' directory!\n");
96 /* Create 'LSA_AUTHENTICATION_INITALIZED' event */
97 RtlInitUnicodeString(&Name
,
98 L
"\\LSA_AUTHENTICATION_INITALIZED");
99 InitializeObjectAttributes(&ObjectAttributes
,
104 Status
= NtCreateEvent(&EventHandle
,
109 if (!NT_SUCCESS(Status
))
111 DPRINT1("Failed to create 'LSA_AUTHENTICATION_INITALIZED' event!\n");
112 NtClose(DirectoryHandle
);
116 NtClose(EventHandle
);
117 NtClose(DirectoryHandle
);
119 /* FIXME: Create SRM port and listener thread */
125 static BOOLEAN INIT_FUNCTION
128 SeExports
= ExAllocatePoolWithTag(NonPagedPool
,
131 if (SeExports
== NULL
)
134 SeExports
->SeCreateTokenPrivilege
= SeCreateTokenPrivilege
;
135 SeExports
->SeAssignPrimaryTokenPrivilege
= SeAssignPrimaryTokenPrivilege
;
136 SeExports
->SeLockMemoryPrivilege
= SeLockMemoryPrivilege
;
137 SeExports
->SeIncreaseQuotaPrivilege
= SeIncreaseQuotaPrivilege
;
138 SeExports
->SeUnsolicitedInputPrivilege
= SeUnsolicitedInputPrivilege
;
139 SeExports
->SeTcbPrivilege
= SeTcbPrivilege
;
140 SeExports
->SeSecurityPrivilege
= SeSecurityPrivilege
;
141 SeExports
->SeTakeOwnershipPrivilege
= SeTakeOwnershipPrivilege
;
142 SeExports
->SeLoadDriverPrivilege
= SeLoadDriverPrivilege
;
143 SeExports
->SeCreatePagefilePrivilege
= SeCreatePagefilePrivilege
;
144 SeExports
->SeIncreaseBasePriorityPrivilege
= SeIncreaseBasePriorityPrivilege
;
145 SeExports
->SeSystemProfilePrivilege
= SeSystemProfilePrivilege
;
146 SeExports
->SeSystemtimePrivilege
= SeSystemtimePrivilege
;
147 SeExports
->SeProfileSingleProcessPrivilege
= SeProfileSingleProcessPrivilege
;
148 SeExports
->SeCreatePermanentPrivilege
= SeCreatePermanentPrivilege
;
149 SeExports
->SeBackupPrivilege
= SeBackupPrivilege
;
150 SeExports
->SeRestorePrivilege
= SeRestorePrivilege
;
151 SeExports
->SeShutdownPrivilege
= SeShutdownPrivilege
;
152 SeExports
->SeDebugPrivilege
= SeDebugPrivilege
;
153 SeExports
->SeAuditPrivilege
= SeAuditPrivilege
;
154 SeExports
->SeSystemEnvironmentPrivilege
= SeSystemEnvironmentPrivilege
;
155 SeExports
->SeChangeNotifyPrivilege
= SeChangeNotifyPrivilege
;
156 SeExports
->SeRemoteShutdownPrivilege
= SeRemoteShutdownPrivilege
;
158 SeExports
->SeNullSid
= SeNullSid
;
159 SeExports
->SeWorldSid
= SeWorldSid
;
160 SeExports
->SeLocalSid
= SeLocalSid
;
161 SeExports
->SeCreatorOwnerSid
= SeCreatorOwnerSid
;
162 SeExports
->SeCreatorGroupSid
= SeCreatorGroupSid
;
163 SeExports
->SeNtAuthoritySid
= SeNtAuthoritySid
;
164 SeExports
->SeDialupSid
= SeDialupSid
;
165 SeExports
->SeNetworkSid
= SeNetworkSid
;
166 SeExports
->SeBatchSid
= SeBatchSid
;
167 SeExports
->SeInteractiveSid
= SeInteractiveSid
;
168 SeExports
->SeLocalSystemSid
= SeLocalSystemSid
;
169 SeExports
->SeAliasAdminsSid
= SeAliasAdminsSid
;
170 SeExports
->SeAliasUsersSid
= SeAliasUsersSid
;
171 SeExports
->SeAliasGuestsSid
= SeAliasGuestsSid
;
172 SeExports
->SeAliasPowerUsersSid
= SeAliasPowerUsersSid
;
173 SeExports
->SeAliasAccountOpsSid
= SeAliasAccountOpsSid
;
174 SeExports
->SeAliasSystemOpsSid
= SeAliasSystemOpsSid
;
175 SeExports
->SeAliasPrintOpsSid
= SeAliasPrintOpsSid
;
176 SeExports
->SeAliasBackupOpsSid
= SeAliasBackupOpsSid
;
182 VOID
SepReferenceLogonSession(PLUID AuthenticationId
)
187 VOID
SepDeReferenceLogonSession(PLUID AuthenticationId
)
198 NtAllocateUuids(PULARGE_INTEGER Time
,
203 return(STATUS_NOT_IMPLEMENTED
);
211 SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext
)
215 BOOLEAN EffectiveOnly
;
217 Thread
= PsGetCurrentThread();
220 SubjectContext
->ProcessAuditId
= 0;
221 SubjectContext
->PrimaryToken
= NULL
;
222 SubjectContext
->ClientToken
= NULL
;
223 SubjectContext
->ImpersonationLevel
= 0;
227 SubjectContext
->ProcessAuditId
= Thread
->ThreadsProcess
;
228 SubjectContext
->ClientToken
=
229 PsReferenceImpersonationToken(Thread
,
232 &SubjectContext
->ImpersonationLevel
);
233 SubjectContext
->PrimaryToken
= PsReferencePrimaryToken(Thread
->ThreadsProcess
);
242 SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext
)
244 ExAcquireResourceExclusiveLite(&SepSubjectContextLock
, TRUE
);
252 SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext
)
254 ExReleaseResourceLite(&SepSubjectContextLock
);
262 SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext
)
264 if (SubjectContext
->PrimaryToken
!= NULL
)
266 ObDereferenceObject(SubjectContext
->PrimaryToken
);
269 if (SubjectContext
->ClientToken
!= NULL
)
271 ObDereferenceObject(SubjectContext
->ClientToken
);
280 SeDeassignSecurity(PSECURITY_DESCRIPTOR
*SecurityDescriptor
)
282 if (*SecurityDescriptor
!= NULL
)
284 ExFreePool(*SecurityDescriptor
);
285 *SecurityDescriptor
= NULL
;
288 return STATUS_SUCCESS
;
296 SeAssignSecurityEx(IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL
,
297 IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL
,
298 OUT PSECURITY_DESCRIPTOR
*NewDescriptor
,
299 IN GUID
*ObjectType OPTIONAL
,
300 IN BOOLEAN IsDirectoryObject
,
301 IN ULONG AutoInheritFlags
,
302 IN PSECURITY_SUBJECT_CONTEXT SubjectContext
,
303 IN PGENERIC_MAPPING GenericMapping
,
304 IN POOL_TYPE PoolType
)
307 return STATUS_NOT_IMPLEMENTED
;
312 * FUNCTION: Creates a security descriptor for a new object.
315 * ExplicitDescriptor =
317 * IsDirectoryObject =
326 SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL
,
327 PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL
,
328 PSECURITY_DESCRIPTOR
*NewDescriptor
,
329 BOOLEAN IsDirectoryObject
,
330 PSECURITY_SUBJECT_CONTEXT SubjectContext
,
331 PGENERIC_MAPPING GenericMapping
,
334 PSECURITY_DESCRIPTOR Descriptor
;
336 ULONG OwnerLength
= 0;
337 ULONG GroupLength
= 0;
338 ULONG DaclLength
= 0;
339 ULONG SaclLength
= 0;
348 /* Lock subject context */
349 SeLockSubjectContext(SubjectContext
);
351 if (SubjectContext
->ClientToken
!= NULL
)
353 Token
= SubjectContext
->ClientToken
;
357 Token
= SubjectContext
->PrimaryToken
;
361 /* Inherit the Owner SID */
362 if (ExplicitDescriptor
!= NULL
&& ExplicitDescriptor
->Owner
!= NULL
)
364 DPRINT("Use explicit owner sid!\n");
365 Owner
= ExplicitDescriptor
->Owner
;
366 if (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
)
368 Owner
= (PSID
)(((ULONG_PTR
)Owner
) + (ULONG_PTR
)ExplicitDescriptor
);
375 DPRINT("Use token owner sid!\n");
376 Owner
= Token
->UserAndGroups
[Token
->DefaultOwnerIndex
].Sid
;
380 DPRINT("Use default owner sid!\n");
381 Owner
= SeLocalSystemSid
;
384 Control
|= SE_OWNER_DEFAULTED
;
387 OwnerLength
= ROUND_UP(RtlLengthSid(Owner
), 4);
390 /* Inherit the Group SID */
391 if (ExplicitDescriptor
!= NULL
&& ExplicitDescriptor
->Group
!= NULL
)
393 DPRINT("Use explicit group sid!\n");
394 Group
= ExplicitDescriptor
->Group
;
395 if (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
)
397 Group
= (PSID
)(((ULONG_PTR
)Group
) + (ULONG_PTR
)ExplicitDescriptor
);
404 DPRINT("Use token group sid!\n");
405 Group
= Token
->PrimaryGroup
;
409 DPRINT("Use default group sid!\n");
410 Group
= SeLocalSystemSid
;
413 Control
|= SE_OWNER_DEFAULTED
;
416 GroupLength
= ROUND_UP(RtlLengthSid(Group
), 4);
419 /* Inherit the DACL */
420 if (ExplicitDescriptor
!= NULL
&&
421 (ExplicitDescriptor
->Control
& SE_DACL_PRESENT
) &&
422 !(ExplicitDescriptor
->Control
& SE_DACL_DEFAULTED
))
424 DPRINT("Use explicit DACL!\n");
425 Dacl
= ExplicitDescriptor
->Dacl
;
426 if (Dacl
!= NULL
&& (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
))
428 Dacl
= (PACL
)(((ULONG_PTR
)Dacl
) + (ULONG_PTR
)ExplicitDescriptor
);
431 Control
|= SE_DACL_PRESENT
;
433 else if (ParentDescriptor
!= NULL
&&
434 (ParentDescriptor
->Control
& SE_DACL_PRESENT
))
436 DPRINT("Use parent DACL!\n");
438 Dacl
= ParentDescriptor
->Dacl
;
439 if (Dacl
!= NULL
&& (ParentDescriptor
->Control
& SE_SELF_RELATIVE
))
441 Dacl
= (PACL
)(((ULONG_PTR
)Dacl
) + (ULONG_PTR
)ParentDescriptor
);
443 Control
|= (SE_DACL_PRESENT
& SE_DACL_DEFAULTED
);
445 else if (Token
!= NULL
&& Token
->DefaultDacl
!= NULL
)
447 DPRINT("Use token default DACL!\n");
449 Dacl
= Token
->DefaultDacl
;
450 Control
|= (SE_DACL_PRESENT
& SE_DACL_DEFAULTED
);
454 DPRINT("Use NULL DACL!\n");
456 Control
|= (SE_DACL_PRESENT
& SE_DACL_DEFAULTED
);
459 DaclLength
= (Dacl
!= NULL
) ? ROUND_UP(Dacl
->AclSize
, 4) : 0;
462 /* Inherit the SACL */
463 if (ExplicitDescriptor
!= NULL
&&
464 (ExplicitDescriptor
->Control
& SE_SACL_PRESENT
) &&
465 !(ExplicitDescriptor
->Control
& SE_SACL_DEFAULTED
))
467 DPRINT("Use explicit SACL!\n");
468 Sacl
= ExplicitDescriptor
->Sacl
;
469 if (Sacl
!= NULL
&& (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
))
471 Sacl
= (PACL
)(((ULONG_PTR
)Sacl
) + (ULONG_PTR
)ExplicitDescriptor
);
474 Control
|= SE_SACL_PRESENT
;
476 else if (ParentDescriptor
!= NULL
&&
477 (ParentDescriptor
->Control
& SE_SACL_PRESENT
))
479 DPRINT("Use parent SACL!\n");
481 Sacl
= ParentDescriptor
->Sacl
;
482 if (Sacl
!= NULL
&& (ParentDescriptor
->Control
& SE_SELF_RELATIVE
))
484 Sacl
= (PACL
)(((ULONG_PTR
)Sacl
) + (ULONG_PTR
)ParentDescriptor
);
486 Control
|= (SE_SACL_PRESENT
& SE_SACL_DEFAULTED
);
489 SaclLength
= (Sacl
!= NULL
) ? ROUND_UP(Sacl
->AclSize
, 4) : 0;
492 /* Allocate and initialize the new security descriptor */
493 Length
= sizeof(SECURITY_DESCRIPTOR
) + OwnerLength
+ GroupLength
+ DaclLength
+ SaclLength
;
495 Descriptor
= ExAllocatePool(NonPagedPool
,
497 if (Descriptor
== NULL
)
499 DPRINT1("ExAlloctePool() failed\n");
500 /* FIXME: Unlock subject context */
501 return STATUS_INSUFFICIENT_RESOURCES
;
504 RtlCreateSecurityDescriptor(Descriptor
,
505 SECURITY_DESCRIPTOR_REVISION
);
507 Descriptor
->Control
= Control
| SE_SELF_RELATIVE
;
509 Current
= (ULONG_PTR
)Descriptor
+ sizeof(SECURITY_DESCRIPTOR
);
513 RtlCopyMemory((PVOID
)Current
,
516 Descriptor
->Sacl
= (PACL
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
517 Current
+= SaclLength
;
522 RtlCopyMemory((PVOID
)Current
,
525 Descriptor
->Dacl
= (PACL
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
526 Current
+= DaclLength
;
529 if (OwnerLength
!= 0)
531 RtlCopyMemory((PVOID
)Current
,
534 Descriptor
->Owner
= (PSID
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
535 Current
+= OwnerLength
;
538 if (GroupLength
!= 0)
540 memmove((PVOID
)Current
,
543 Descriptor
->Group
= (PSID
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
546 /* Unlock subject context */
547 SeUnlockSubjectContext(SubjectContext
);
549 *NewDescriptor
= Descriptor
;
551 return STATUS_SUCCESS
;
556 SepSidInToken(PACCESS_TOKEN Token
,
561 if (Token
->UserAndGroupCount
== 0)
566 for (i
=0; i
<Token
->UserAndGroupCount
; i
++)
568 if (RtlEqualSid(Sid
, Token
->UserAndGroups
[i
].Sid
))
570 if (Token
->UserAndGroups
[i
].Attributes
& SE_GROUP_ENABLED
)
584 * FUNCTION: Determines whether the requested access rights can be granted
585 * to an object protected by a security descriptor and an object owner
587 * SecurityDescriptor = Security descriptor protecting the object
588 * SubjectSecurityContext = Subject's captured security context
589 * SubjectContextLocked = Indicates the user's subject context is locked
590 * DesiredAccess = Access rights the caller is trying to acquire
591 * PreviouslyGrantedAccess = Specified the access rights already granted
593 * GenericMapping = Generic mapping associated with the object
594 * AccessMode = Access mode used for the check
595 * GrantedAccess (OUT) = On return specifies the access granted
596 * AccessStatus (OUT) = Status indicating why access was denied
597 * RETURNS: If access was granted, returns TRUE
602 SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
603 IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext
,
604 IN BOOLEAN SubjectContextLocked
,
605 IN ACCESS_MASK DesiredAccess
,
606 IN ACCESS_MASK PreviouslyGrantedAccess
,
607 OUT PPRIVILEGE_SET
* Privileges
,
608 IN PGENERIC_MAPPING GenericMapping
,
609 IN KPROCESSOR_MODE AccessMode
,
610 OUT PACCESS_MASK GrantedAccess
,
611 OUT PNTSTATUS AccessStatus
)
613 LUID_AND_ATTRIBUTES Privilege
;
614 ACCESS_MASK CurrentAccess
;
624 CurrentAccess
= PreviouslyGrantedAccess
;
626 if (SubjectContextLocked
== FALSE
)
628 SeLockSubjectContext(SubjectSecurityContext
);
631 Token
= SubjectSecurityContext
->ClientToken
?
632 SubjectSecurityContext
->ClientToken
: SubjectSecurityContext
->PrimaryToken
;
635 Status
= RtlGetDaclSecurityDescriptor(SecurityDescriptor
,
639 if (!NT_SUCCESS(Status
))
641 if (SubjectContextLocked
== FALSE
)
643 SeUnlockSubjectContext(SubjectSecurityContext
);
646 *AccessStatus
= Status
;
650 /* RULE 1: Grant desired access if the object is unprotected */
651 if (Present
== TRUE
&& Dacl
== NULL
)
653 if (SubjectContextLocked
== FALSE
)
655 SeUnlockSubjectContext(SubjectSecurityContext
);
658 *GrantedAccess
= DesiredAccess
;
659 *AccessStatus
= STATUS_SUCCESS
;
663 CurrentAccess
= PreviouslyGrantedAccess
;
665 /* RULE 2: Check token for 'take ownership' privilege */
666 Privilege
.Luid
= SeTakeOwnershipPrivilege
;
667 Privilege
.Attributes
= SE_PRIVILEGE_ENABLED
;
669 if (SepPrivilegeCheck(Token
,
672 PRIVILEGE_SET_ALL_NECESSARY
,
675 CurrentAccess
|= WRITE_OWNER
;
676 if (DesiredAccess
== CurrentAccess
)
678 if (SubjectContextLocked
== FALSE
)
680 SeUnlockSubjectContext(SubjectSecurityContext
);
683 *GrantedAccess
= CurrentAccess
;
684 *AccessStatus
= STATUS_SUCCESS
;
689 /* RULE 3: Check whether the token is the owner */
690 Status
= RtlGetOwnerSecurityDescriptor(SecurityDescriptor
,
693 if (!NT_SUCCESS(Status
))
695 DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status
);
696 if (SubjectContextLocked
== FALSE
)
698 SeUnlockSubjectContext(SubjectSecurityContext
);
701 *AccessStatus
= Status
;
705 if (SepSidInToken(Token
, Sid
))
707 CurrentAccess
|= (READ_CONTROL
| WRITE_DAC
);
708 if (DesiredAccess
== CurrentAccess
)
710 if (SubjectContextLocked
== FALSE
)
712 SeUnlockSubjectContext(SubjectSecurityContext
);
715 *GrantedAccess
= CurrentAccess
;
716 *AccessStatus
= STATUS_SUCCESS
;
721 /* Fail if DACL is absent */
722 if (Present
== FALSE
)
724 if (SubjectContextLocked
== FALSE
)
726 SeUnlockSubjectContext(SubjectSecurityContext
);
730 *AccessStatus
= STATUS_ACCESS_DENIED
;
734 /* RULE 4: Grant rights according to the DACL */
735 CurrentAce
= (PACE
)(Dacl
+ 1);
736 for (i
= 0; i
< Dacl
->AceCount
; i
++)
738 Sid
= (PSID
)(CurrentAce
+ 1);
739 if (CurrentAce
->Header
.AceType
== ACCESS_DENIED_ACE_TYPE
)
741 if (SepSidInToken(Token
, Sid
))
743 if (SubjectContextLocked
== FALSE
)
745 SeUnlockSubjectContext(SubjectSecurityContext
);
749 *AccessStatus
= STATUS_ACCESS_DENIED
;
754 if (CurrentAce
->Header
.AceType
== ACCESS_ALLOWED_ACE_TYPE
)
756 if (SepSidInToken(Token
, Sid
))
758 CurrentAccess
|= CurrentAce
->AccessMask
;
763 if (SubjectContextLocked
== FALSE
)
765 SeUnlockSubjectContext(SubjectSecurityContext
);
768 DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n",
769 CurrentAccess
, DesiredAccess
);
771 *GrantedAccess
= CurrentAccess
& DesiredAccess
;
774 (*GrantedAccess
== DesiredAccess
) ? STATUS_SUCCESS
: STATUS_ACCESS_DENIED
;
781 NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
782 IN HANDLE TokenHandle
,
783 IN ACCESS_MASK DesiredAccess
,
784 IN PGENERIC_MAPPING GenericMapping
,
785 OUT PPRIVILEGE_SET PrivilegeSet
,
786 OUT PULONG ReturnLength
,
787 OUT PACCESS_MASK GrantedAccess
,
788 OUT PNTSTATUS AccessStatus
)
790 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext
;
791 KPROCESSOR_MODE PreviousMode
;
795 DPRINT("NtAccessCheck() called\n");
797 PreviousMode
= KeGetPreviousMode();
798 if (PreviousMode
== KernelMode
)
800 *GrantedAccess
= DesiredAccess
;
801 *AccessStatus
= STATUS_SUCCESS
;
802 return STATUS_SUCCESS
;
805 Status
= ObReferenceObjectByHandle(TokenHandle
,
811 if (!NT_SUCCESS(Status
))
813 DPRINT1("Failed to reference token (Status %lx)\n", Status
);
817 /* Check token type */
818 if (Token
->TokenType
!= TokenImpersonation
)
820 DPRINT1("No impersonation token\n");
821 ObDereferenceObject(Token
);
822 return STATUS_ACCESS_VIOLATION
;
825 /* Check impersonation level */
826 if (Token
->ImpersonationLevel
< SecurityAnonymous
)
828 DPRINT1("Invalid impersonation level\n");
829 ObDereferenceObject(Token
);
830 return STATUS_ACCESS_VIOLATION
;
833 RtlZeroMemory(&SubjectSecurityContext
,
834 sizeof(SECURITY_SUBJECT_CONTEXT
));
835 SubjectSecurityContext
.ClientToken
= Token
;
836 SubjectSecurityContext
.ImpersonationLevel
= Token
->ImpersonationLevel
;
838 /* Lock subject context */
839 SeLockSubjectContext(&SubjectSecurityContext
);
841 if (!SeAccessCheck(SecurityDescriptor
,
842 &SubjectSecurityContext
,
852 Status
= *AccessStatus
;
856 Status
= STATUS_ACCESS_DENIED
;
859 /* Unlock subject context */
860 SeUnlockSubjectContext(&SubjectSecurityContext
);
862 ObDereferenceObject(Token
);
864 DPRINT("NtAccessCheck() done\n");