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
= ZwCreateDirectoryObject(&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
= ZwCreateEvent(&EventHandle
,
107 SynchronizationEvent
,
109 if (!NT_SUCCESS(Status
))
111 DPRINT1("Failed to create 'LSA_AUTHENTICATION_INITALIZED' event!\n");
112 NtClose(DirectoryHandle
);
116 ZwClose(EventHandle
);
117 ZwClose(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
)
197 SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext
)
201 BOOLEAN EffectiveOnly
;
203 Thread
= PsGetCurrentThread();
206 SubjectContext
->ProcessAuditId
= 0;
207 SubjectContext
->PrimaryToken
= NULL
;
208 SubjectContext
->ClientToken
= NULL
;
209 SubjectContext
->ImpersonationLevel
= 0;
213 SubjectContext
->ProcessAuditId
= Thread
->ThreadsProcess
;
214 SubjectContext
->ClientToken
=
215 PsReferenceImpersonationToken(Thread
,
218 &SubjectContext
->ImpersonationLevel
);
219 SubjectContext
->PrimaryToken
= PsReferencePrimaryToken(Thread
->ThreadsProcess
);
228 SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext
)
230 KeEnterCriticalRegion();
231 ExAcquireResourceExclusiveLite(&SepSubjectContextLock
, TRUE
);
239 SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext
)
241 ExReleaseResourceLite(&SepSubjectContextLock
);
242 KeLeaveCriticalRegion();
250 SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext
)
252 if (SubjectContext
->PrimaryToken
!= NULL
)
254 ObDereferenceObject(SubjectContext
->PrimaryToken
);
257 if (SubjectContext
->ClientToken
!= NULL
)
259 ObDereferenceObject(SubjectContext
->ClientToken
);
268 SeDeassignSecurity(PSECURITY_DESCRIPTOR
*SecurityDescriptor
)
270 if (*SecurityDescriptor
!= NULL
)
272 ExFreePool(*SecurityDescriptor
);
273 *SecurityDescriptor
= NULL
;
276 return STATUS_SUCCESS
;
284 SeAssignSecurityEx(IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL
,
285 IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL
,
286 OUT PSECURITY_DESCRIPTOR
*NewDescriptor
,
287 IN GUID
*ObjectType OPTIONAL
,
288 IN BOOLEAN IsDirectoryObject
,
289 IN ULONG AutoInheritFlags
,
290 IN PSECURITY_SUBJECT_CONTEXT SubjectContext
,
291 IN PGENERIC_MAPPING GenericMapping
,
292 IN POOL_TYPE PoolType
)
295 return STATUS_NOT_IMPLEMENTED
;
300 * FUNCTION: Creates a security descriptor for a new object.
303 * ExplicitDescriptor =
305 * IsDirectoryObject =
314 SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL
,
315 PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL
,
316 PSECURITY_DESCRIPTOR
*NewDescriptor
,
317 BOOLEAN IsDirectoryObject
,
318 PSECURITY_SUBJECT_CONTEXT SubjectContext
,
319 PGENERIC_MAPPING GenericMapping
,
322 PSECURITY_DESCRIPTOR Descriptor
;
324 ULONG OwnerLength
= 0;
325 ULONG GroupLength
= 0;
326 ULONG DaclLength
= 0;
327 ULONG SaclLength
= 0;
336 /* Lock subject context */
337 SeLockSubjectContext(SubjectContext
);
339 if (SubjectContext
->ClientToken
!= NULL
)
341 Token
= SubjectContext
->ClientToken
;
345 Token
= SubjectContext
->PrimaryToken
;
349 /* Inherit the Owner SID */
350 if (ExplicitDescriptor
!= NULL
&& ExplicitDescriptor
->Owner
!= NULL
)
352 DPRINT("Use explicit owner sid!\n");
353 Owner
= ExplicitDescriptor
->Owner
;
354 if (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
)
356 Owner
= (PSID
)(((ULONG_PTR
)Owner
) + (ULONG_PTR
)ExplicitDescriptor
);
363 DPRINT("Use token owner sid!\n");
364 Owner
= Token
->UserAndGroups
[Token
->DefaultOwnerIndex
].Sid
;
368 DPRINT("Use default owner sid!\n");
369 Owner
= SeLocalSystemSid
;
372 Control
|= SE_OWNER_DEFAULTED
;
375 OwnerLength
= ROUND_UP(RtlLengthSid(Owner
), 4);
378 /* Inherit the Group SID */
379 if (ExplicitDescriptor
!= NULL
&& ExplicitDescriptor
->Group
!= NULL
)
381 DPRINT("Use explicit group sid!\n");
382 Group
= ExplicitDescriptor
->Group
;
383 if (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
)
385 Group
= (PSID
)(((ULONG_PTR
)Group
) + (ULONG_PTR
)ExplicitDescriptor
);
392 DPRINT("Use token group sid!\n");
393 Group
= Token
->PrimaryGroup
;
397 DPRINT("Use default group sid!\n");
398 Group
= SeLocalSystemSid
;
401 Control
|= SE_OWNER_DEFAULTED
;
404 GroupLength
= ROUND_UP(RtlLengthSid(Group
), 4);
407 /* Inherit the DACL */
408 if (ExplicitDescriptor
!= NULL
&&
409 (ExplicitDescriptor
->Control
& SE_DACL_PRESENT
) &&
410 !(ExplicitDescriptor
->Control
& SE_DACL_DEFAULTED
))
412 DPRINT("Use explicit DACL!\n");
413 Dacl
= ExplicitDescriptor
->Dacl
;
414 if (Dacl
!= NULL
&& (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
))
416 Dacl
= (PACL
)(((ULONG_PTR
)Dacl
) + (ULONG_PTR
)ExplicitDescriptor
);
419 Control
|= SE_DACL_PRESENT
;
421 else if (ParentDescriptor
!= NULL
&&
422 (ParentDescriptor
->Control
& SE_DACL_PRESENT
))
424 DPRINT("Use parent DACL!\n");
426 Dacl
= ParentDescriptor
->Dacl
;
427 if (Dacl
!= NULL
&& (ParentDescriptor
->Control
& SE_SELF_RELATIVE
))
429 Dacl
= (PACL
)(((ULONG_PTR
)Dacl
) + (ULONG_PTR
)ParentDescriptor
);
431 Control
|= (SE_DACL_PRESENT
| SE_DACL_DEFAULTED
);
433 else if (Token
!= NULL
&& Token
->DefaultDacl
!= NULL
)
435 DPRINT("Use token default DACL!\n");
437 Dacl
= Token
->DefaultDacl
;
438 Control
|= (SE_DACL_PRESENT
| SE_DACL_DEFAULTED
);
442 DPRINT("Use NULL DACL!\n");
444 Control
|= (SE_DACL_PRESENT
| SE_DACL_DEFAULTED
);
447 DaclLength
= (Dacl
!= NULL
) ? ROUND_UP(Dacl
->AclSize
, 4) : 0;
450 /* Inherit the SACL */
451 if (ExplicitDescriptor
!= NULL
&&
452 (ExplicitDescriptor
->Control
& SE_SACL_PRESENT
) &&
453 !(ExplicitDescriptor
->Control
& SE_SACL_DEFAULTED
))
455 DPRINT("Use explicit SACL!\n");
456 Sacl
= ExplicitDescriptor
->Sacl
;
457 if (Sacl
!= NULL
&& (ExplicitDescriptor
->Control
& SE_SELF_RELATIVE
))
459 Sacl
= (PACL
)(((ULONG_PTR
)Sacl
) + (ULONG_PTR
)ExplicitDescriptor
);
462 Control
|= SE_SACL_PRESENT
;
464 else if (ParentDescriptor
!= NULL
&&
465 (ParentDescriptor
->Control
& SE_SACL_PRESENT
))
467 DPRINT("Use parent SACL!\n");
469 Sacl
= ParentDescriptor
->Sacl
;
470 if (Sacl
!= NULL
&& (ParentDescriptor
->Control
& SE_SELF_RELATIVE
))
472 Sacl
= (PACL
)(((ULONG_PTR
)Sacl
) + (ULONG_PTR
)ParentDescriptor
);
474 Control
|= (SE_SACL_PRESENT
| SE_SACL_DEFAULTED
);
477 SaclLength
= (Sacl
!= NULL
) ? ROUND_UP(Sacl
->AclSize
, 4) : 0;
480 /* Allocate and initialize the new security descriptor */
481 Length
= sizeof(SECURITY_DESCRIPTOR
) +
482 OwnerLength
+ GroupLength
+ DaclLength
+ SaclLength
;
484 DPRINT("L: sizeof(SECURITY_DESCRIPTOR) %d OwnerLength %d GroupLength %d DaclLength %d SaclLength %d\n",
485 sizeof(SECURITY_DESCRIPTOR
),
491 Descriptor
= ExAllocatePool(NonPagedPool
,
493 RtlZeroMemory( Descriptor
, Length
);
495 if (Descriptor
== NULL
)
497 DPRINT1("ExAlloctePool() failed\n");
498 /* FIXME: Unlock subject context */
499 return STATUS_INSUFFICIENT_RESOURCES
;
502 RtlCreateSecurityDescriptor(Descriptor
,
503 SECURITY_DESCRIPTOR_REVISION
);
505 Descriptor
->Control
= Control
| SE_SELF_RELATIVE
;
507 Current
= (ULONG_PTR
)Descriptor
+ sizeof(SECURITY_DESCRIPTOR
);
511 RtlCopyMemory((PVOID
)Current
,
514 Descriptor
->Sacl
= (PACL
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
515 Current
+= SaclLength
;
520 RtlCopyMemory((PVOID
)Current
,
523 Descriptor
->Dacl
= (PACL
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
524 Current
+= DaclLength
;
527 if (OwnerLength
!= 0)
529 RtlCopyMemory((PVOID
)Current
,
532 Descriptor
->Owner
= (PSID
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
533 Current
+= OwnerLength
;
534 DPRINT("Owner of %x at %x\n", Descriptor
, Descriptor
->Owner
);
537 DPRINT("Owner of %x is zero length\n", Descriptor
);
539 if (GroupLength
!= 0)
541 memmove((PVOID
)Current
,
544 Descriptor
->Group
= (PSID
)((ULONG_PTR
)Current
- (ULONG_PTR
)Descriptor
);
547 /* Unlock subject context */
548 SeUnlockSubjectContext(SubjectContext
);
550 *NewDescriptor
= Descriptor
;
552 DPRINT("Descrptor %x\n", Descriptor
);
553 ASSERT(RtlLengthSecurityDescriptor(Descriptor
));
555 return STATUS_SUCCESS
;
560 SepSidInToken(PACCESS_TOKEN _Token
,
564 PTOKEN Token
= (PTOKEN
)_Token
;
566 if (Token
->UserAndGroupCount
== 0)
571 for (i
=0; i
<Token
->UserAndGroupCount
; i
++)
573 if (RtlEqualSid(Sid
, Token
->UserAndGroups
[i
].Sid
))
575 if (Token
->UserAndGroups
[i
].Attributes
& SE_GROUP_ENABLED
)
589 * FUNCTION: Determines whether the requested access rights can be granted
590 * to an object protected by a security descriptor and an object owner
592 * SecurityDescriptor = Security descriptor protecting the object
593 * SubjectSecurityContext = Subject's captured security context
594 * SubjectContextLocked = Indicates the user's subject context is locked
595 * DesiredAccess = Access rights the caller is trying to acquire
596 * PreviouslyGrantedAccess = Specified the access rights already granted
598 * GenericMapping = Generic mapping associated with the object
599 * AccessMode = Access mode used for the check
600 * GrantedAccess (OUT) = On return specifies the access granted
601 * AccessStatus (OUT) = Status indicating why access was denied
602 * RETURNS: If access was granted, returns TRUE
607 SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
608 IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext
,
609 IN BOOLEAN SubjectContextLocked
,
610 IN ACCESS_MASK DesiredAccess
,
611 IN ACCESS_MASK PreviouslyGrantedAccess
,
612 OUT PPRIVILEGE_SET
* Privileges
,
613 IN PGENERIC_MAPPING GenericMapping
,
614 IN KPROCESSOR_MODE AccessMode
,
615 OUT PACCESS_MASK GrantedAccess
,
616 OUT PNTSTATUS AccessStatus
)
618 LUID_AND_ATTRIBUTES Privilege
;
619 ACCESS_MASK CurrentAccess
;
629 CurrentAccess
= PreviouslyGrantedAccess
;
631 if (SubjectContextLocked
== FALSE
)
633 SeLockSubjectContext(SubjectSecurityContext
);
636 Token
= SubjectSecurityContext
->ClientToken
?
637 SubjectSecurityContext
->ClientToken
: SubjectSecurityContext
->PrimaryToken
;
640 Status
= RtlGetDaclSecurityDescriptor(SecurityDescriptor
,
644 if (!NT_SUCCESS(Status
))
646 if (SubjectContextLocked
== FALSE
)
648 SeUnlockSubjectContext(SubjectSecurityContext
);
651 *AccessStatus
= Status
;
655 /* RULE 1: Grant desired access if the object is unprotected */
656 if (Present
== TRUE
&& Dacl
== NULL
)
658 if (SubjectContextLocked
== FALSE
)
660 SeUnlockSubjectContext(SubjectSecurityContext
);
663 *GrantedAccess
= DesiredAccess
;
664 *AccessStatus
= STATUS_SUCCESS
;
668 CurrentAccess
= PreviouslyGrantedAccess
;
670 /* RULE 2: Check token for 'take ownership' privilege */
671 Privilege
.Luid
= SeTakeOwnershipPrivilege
;
672 Privilege
.Attributes
= SE_PRIVILEGE_ENABLED
;
674 if (SepPrivilegeCheck(Token
,
677 PRIVILEGE_SET_ALL_NECESSARY
,
680 CurrentAccess
|= WRITE_OWNER
;
681 if (DesiredAccess
== CurrentAccess
)
683 if (SubjectContextLocked
== FALSE
)
685 SeUnlockSubjectContext(SubjectSecurityContext
);
688 *GrantedAccess
= CurrentAccess
;
689 *AccessStatus
= STATUS_SUCCESS
;
694 /* RULE 3: Check whether the token is the owner */
695 Status
= RtlGetOwnerSecurityDescriptor(SecurityDescriptor
,
698 if (!NT_SUCCESS(Status
))
700 DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status
);
701 if (SubjectContextLocked
== FALSE
)
703 SeUnlockSubjectContext(SubjectSecurityContext
);
706 *AccessStatus
= Status
;
710 if (SepSidInToken(Token
, Sid
))
712 CurrentAccess
|= (READ_CONTROL
| WRITE_DAC
);
713 if (DesiredAccess
== CurrentAccess
)
715 if (SubjectContextLocked
== FALSE
)
717 SeUnlockSubjectContext(SubjectSecurityContext
);
720 *GrantedAccess
= CurrentAccess
;
721 *AccessStatus
= STATUS_SUCCESS
;
726 /* Fail if DACL is absent */
727 if (Present
== FALSE
)
729 if (SubjectContextLocked
== FALSE
)
731 SeUnlockSubjectContext(SubjectSecurityContext
);
735 *AccessStatus
= STATUS_ACCESS_DENIED
;
739 /* RULE 4: Grant rights according to the DACL */
740 CurrentAce
= (PACE
)(Dacl
+ 1);
741 for (i
= 0; i
< Dacl
->AceCount
; i
++)
743 Sid
= (PSID
)(CurrentAce
+ 1);
744 if (CurrentAce
->Header
.AceType
== ACCESS_DENIED_ACE_TYPE
)
746 if (SepSidInToken(Token
, Sid
))
748 if (SubjectContextLocked
== FALSE
)
750 SeUnlockSubjectContext(SubjectSecurityContext
);
754 *AccessStatus
= STATUS_ACCESS_DENIED
;
759 if (CurrentAce
->Header
.AceType
== ACCESS_ALLOWED_ACE_TYPE
)
761 if (SepSidInToken(Token
, Sid
))
763 CurrentAccess
|= CurrentAce
->AccessMask
;
768 if (SubjectContextLocked
== FALSE
)
770 SeUnlockSubjectContext(SubjectSecurityContext
);
773 DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n",
774 CurrentAccess
, DesiredAccess
);
776 *GrantedAccess
= CurrentAccess
& DesiredAccess
;
779 (*GrantedAccess
== DesiredAccess
) ? STATUS_SUCCESS
: STATUS_ACCESS_DENIED
;
786 NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
787 IN HANDLE TokenHandle
,
788 IN ACCESS_MASK DesiredAccess
,
789 IN PGENERIC_MAPPING GenericMapping
,
790 OUT PPRIVILEGE_SET PrivilegeSet
,
791 OUT PULONG ReturnLength
,
792 OUT PACCESS_MASK GrantedAccess
,
793 OUT PNTSTATUS AccessStatus
)
795 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext
;
796 KPROCESSOR_MODE PreviousMode
;
800 DPRINT("NtAccessCheck() called\n");
802 PreviousMode
= KeGetPreviousMode();
803 if (PreviousMode
== KernelMode
)
805 *GrantedAccess
= DesiredAccess
;
806 *AccessStatus
= STATUS_SUCCESS
;
807 return STATUS_SUCCESS
;
810 Status
= ObReferenceObjectByHandle(TokenHandle
,
816 if (!NT_SUCCESS(Status
))
818 DPRINT1("Failed to reference token (Status %lx)\n", Status
);
822 /* Check token type */
823 if (Token
->TokenType
!= TokenImpersonation
)
825 DPRINT1("No impersonation token\n");
826 ObDereferenceObject(Token
);
827 return STATUS_ACCESS_VIOLATION
;
830 /* Check impersonation level */
831 if (Token
->ImpersonationLevel
< SecurityAnonymous
)
833 DPRINT1("Invalid impersonation level\n");
834 ObDereferenceObject(Token
);
835 return STATUS_ACCESS_VIOLATION
;
838 RtlZeroMemory(&SubjectSecurityContext
,
839 sizeof(SECURITY_SUBJECT_CONTEXT
));
840 SubjectSecurityContext
.ClientToken
= Token
;
841 SubjectSecurityContext
.ImpersonationLevel
= Token
->ImpersonationLevel
;
843 /* Lock subject context */
844 SeLockSubjectContext(&SubjectSecurityContext
);
846 if (SeAccessCheck(SecurityDescriptor
,
847 &SubjectSecurityContext
,
857 Status
= *AccessStatus
;
861 Status
= STATUS_ACCESS_DENIED
;
864 /* Unlock subject context */
865 SeUnlockSubjectContext(&SubjectSecurityContext
);
867 ObDereferenceObject(Token
);
869 DPRINT("NtAccessCheck() done\n");