2013-06-05 23:16:14 +00:00
/*
* PROJECT : ReactOS kernel - mode tests
* LICENSE : GPLv2 + - See COPYING in the top level directory
* PURPOSE : Kernel - Mode Test Suite Process Notification Routines test
* PROGRAMMER : Constantine Belev ( Moscow State Technical University )
* Denis Grishin ( Moscow State Technical University )
* Egor Sinitsyn ( Moscow State Technical University )
*/
# include <kmt_test.h>
# include <ntifs.h>
# define NDEBUG
# include <debug.h>
2023-05-27 15:19:17 +00:00
// Copied from PspProcessMapping -- although the values don't matter much for
// the most part.
static GENERIC_MAPPING ProcessGenericMapping =
{
STANDARD_RIGHTS_READ | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ ,
STANDARD_RIGHTS_WRITE | PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD |
PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE |
PROCESS_TERMINATE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION |
PROCESS_SUSPEND_RESUME ,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE ,
PROCESS_ALL_ACCESS
} ;
2013-06-05 23:16:14 +00:00
//------------------------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing Functions //
2013-06-05 23:16:14 +00:00
//------------------------------------------------------------------------------//
// Testing function for SQIT
2021-09-13 01:33:14 +00:00
void TestsSeQueryInformationToken ( PACCESS_TOKEN Token )
2013-06-05 23:16:14 +00:00
{
NTSTATUS Status ;
PVOID Buffer = NULL ;
PSID sid ;
PTOKEN_OWNER Towner ;
PTOKEN_DEFAULT_DACL TDefDacl ;
PTOKEN_GROUPS TGroups ;
ULONG GroupCount ;
PACL acl ;
PTOKEN_STATISTICS TStats ;
PTOKEN_TYPE TType ;
PTOKEN_USER TUser ;
2013-06-06 21:54:00 +00:00
BOOLEAN Flag ;
ULONG i ;
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing SeQueryInformationToken with various args //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
ok ( Token ! = NULL , " Token is not captured. Testing SQIT interrupted \n \n " ) ;
if ( Token = = NULL ) return ;
Status = SeQueryInformationToken ( Token , TokenOwner , & Buffer ) ;
2016-11-04 17:52:32 +00:00
ok ( ( Status = = STATUS_SUCCESS ) , " SQIT with TokenOwner arg fails with status 0x%08X \n " , Status ) ;
2013-06-06 09:44:34 +00:00
if ( Status = = STATUS_SUCCESS )
2013-06-05 23:16:14 +00:00
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenOwner arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
{
Towner = ( TOKEN_OWNER * ) Buffer ;
sid = Towner - > Owner ;
ok ( ( RtlValidSid ( sid ) = = TRUE ) , " TokenOwner's SID is not a valid SID \n " ) ;
ExFreePool ( Buffer ) ;
}
2013-06-05 23:16:14 +00:00
}
2013-06-06 09:44:34 +00:00
//----------------------------------------------------------------//
2021-09-13 01:33:14 +00:00
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenDefaultDacl , & Buffer ) ;
2016-11-04 17:52:32 +00:00
ok ( Status = = STATUS_SUCCESS , " SQIT with TokenDefaultDacl fails with status 0x%08X \n " , Status ) ;
2013-06-06 09:44:34 +00:00
if ( Status = = STATUS_SUCCESS )
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenDefaultDacl arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
{
TDefDacl = ( PTOKEN_DEFAULT_DACL ) Buffer ;
acl = TDefDacl - > DefaultDacl ;
ok ( ( ( acl - > AclRevision = = ACL_REVISION | | acl - > AclRevision = = ACL_REVISION_DS ) = = TRUE ) , " DACL is invalid \n " ) ;
ExFreePool ( Buffer ) ;
}
2013-06-05 23:16:14 +00:00
}
2013-06-06 09:44:34 +00:00
//----------------------------------------------------------------//
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenGroups , & Buffer ) ;
2016-11-04 17:52:32 +00:00
ok ( Status = = STATUS_SUCCESS , " SQIT with TokenGroups fails with status 0x%08X \n " , Status ) ;
2013-06-06 09:44:34 +00:00
if ( Status = = STATUS_SUCCESS )
2013-06-05 23:16:14 +00:00
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenGroups arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
2013-06-05 23:16:14 +00:00
{
2013-06-06 09:44:34 +00:00
TGroups = ( PTOKEN_GROUPS ) Buffer ;
GroupCount = TGroups - > GroupCount ;
2013-06-06 21:54:00 +00:00
Flag = TRUE ;
2013-06-06 09:44:34 +00:00
for ( i = 0 ; i < GroupCount ; i + + )
2013-06-05 23:16:14 +00:00
{
2013-06-06 09:44:34 +00:00
sid = TGroups - > Groups [ i ] . Sid ;
if ( ! RtlValidSid ( sid ) )
{
2013-06-06 21:54:00 +00:00
Flag = FALSE ;
2013-06-06 09:44:34 +00:00
break ;
}
2013-06-05 23:16:14 +00:00
}
2013-06-06 21:54:00 +00:00
ok ( ( Flag = = TRUE ) , " TokenGroup's SIDs are not valid \n " ) ;
2013-06-06 09:44:34 +00:00
ExFreePool ( Buffer ) ;
2013-06-05 23:16:14 +00:00
}
}
//----------------------------------------------------------------//
2021-05-08 15:25:33 +00:00
// Call SQIT with TokenImpersonationLevel argument. Although our token
// is not an impersonation token, the call will outright fail.
2013-06-05 23:16:14 +00:00
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenImpersonationLevel , & Buffer ) ;
2021-05-08 15:25:33 +00:00
ok ( Status = = STATUS_INVALID_INFO_CLASS , " SQIT with TokenImpersonationLevel must return STATUS_INVALID_INFO_CLASS but got 0x%08X \n " , Status ) ;
ok ( Buffer = = NULL , " SQIT has failed to query the impersonation level but buffer is not NULL! \n " ) ;
2016-11-04 17:52:32 +00:00
//----------------------------------------------------------------//
// Call SQIT with the 4 classes (TokenOrigin, TokenGroupsAndPrivileges,
// TokenRestrictedSids and TokenSandBoxInert) are not supported by
// SeQueryInformationToken (only NtQueryInformationToken supports them).
//
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenOrigin , & Buffer ) ;
ok ( Status = = STATUS_INVALID_INFO_CLASS , " SQIT with TokenOrigin failed with Status 0x%08X; expected STATUS_INVALID_INFO_CLASS \n " , Status ) ;
ok ( Buffer = = NULL , " Wrong. SQIT call failed. But Buffer != NULL \n " ) ;
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenGroupsAndPrivileges , & Buffer ) ;
ok ( Status = = STATUS_INVALID_INFO_CLASS , " SQIT with TokenGroupsAndPrivileges failed with Status 0x%08X; expected STATUS_INVALID_INFO_CLASS \n " , Status ) ;
ok ( Buffer = = NULL , " Wrong. SQIT call failed. But Buffer != NULL \n " ) ;
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenRestrictedSids , & Buffer ) ;
ok ( Status = = STATUS_INVALID_INFO_CLASS , " SQIT with TokenRestrictedSids failed with Status 0x%08X; expected STATUS_INVALID_INFO_CLASS \n " , Status ) ;
ok ( Buffer = = NULL , " Wrong. SQIT call failed. But Buffer != NULL \n " ) ;
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenSandBoxInert , & Buffer ) ;
ok ( Status = = STATUS_INVALID_INFO_CLASS , " SQIT with TokenSandBoxInert failed with Status 0x%08X; expected STATUS_INVALID_INFO_CLASS \n " , Status ) ;
ok ( Buffer = = NULL , " Wrong. SQIT call failed. But Buffer != NULL \n " ) ;
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenStatistics , & Buffer ) ;
2016-11-04 17:52:32 +00:00
ok ( Status = = STATUS_SUCCESS , " SQIT with TokenStatistics fails with status 0x%08X \n " , Status ) ;
2013-06-06 09:44:34 +00:00
if ( Status = = STATUS_SUCCESS )
2013-06-05 23:16:14 +00:00
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenStatistics arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
{
TStats = ( PTOKEN_STATISTICS ) Buffer ;
2016-11-04 17:52:32 +00:00
// just put 0 into 1st arg or use trace to print TokenStatistics
2021-09-13 01:33:14 +00:00
ok ( 1 , " print statistics: \n \t TokenID = %u_%d \n \t SecurityImperLevel = %d \n \t PrivCount = %d \n \t GroupCount = %d \n \n " , TStats - > TokenId . LowPart ,
TStats - > TokenId . HighPart ,
2013-06-06 09:44:34 +00:00
TStats - > ImpersonationLevel ,
TStats - > PrivilegeCount ,
TStats - > GroupCount
) ;
2016-11-04 17:52:32 +00:00
ExFreePool ( Buffer ) ;
2013-06-06 09:44:34 +00:00
}
} else {
2016-11-04 17:52:32 +00:00
ok ( Buffer = = NULL , " Wrong. SQIT call failed. But Buffer != NULL \n " ) ;
2013-06-05 23:16:14 +00:00
}
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenType , & Buffer ) ;
2016-11-04 17:52:32 +00:00
ok ( Status = = STATUS_SUCCESS , " SQIT with TokenType fails with status 0x%08X \n " , Status ) ;
2013-06-06 09:44:34 +00:00
if ( Status = = STATUS_SUCCESS )
2013-06-05 23:16:14 +00:00
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenType arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
{
TType = ( PTOKEN_TYPE ) Buffer ;
ok ( ( * TType = = TokenPrimary | | * TType = = TokenImpersonation ) , " TokenType in not a primary nor impersonation. FAILED \n " ) ;
2016-11-04 17:52:32 +00:00
ExFreePool ( Buffer ) ;
2013-06-06 09:44:34 +00:00
}
2013-06-05 23:16:14 +00:00
}
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenUser , & Buffer ) ;
ok ( Status = = STATUS_SUCCESS , " SQIT with TokenUser fails \n " ) ;
if ( Status = = STATUS_SUCCESS )
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenUser arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
{
TUser = ( PTOKEN_USER ) Buffer ;
ok ( RtlValidSid ( TUser - > User . Sid ) , " TokenUser has an invalid Sid \n " ) ;
2016-11-04 17:52:32 +00:00
ExFreePool ( Buffer ) ;
2013-06-06 09:44:34 +00:00
}
}
//----------------------------------------------------------------//
2013-06-05 23:16:14 +00:00
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
2013-06-05 23:16:14 +00:00
Status = SeQueryInformationToken ( Token , TokenSandBoxInert , & Buffer ) ;
ok ( Status ! = STATUS_SUCCESS , " SQIT must fail with wrong TOKEN_INFORMATION_CLASS arg \n " ) ;
}
//------------------------------------------------------------------------------//
//------------------------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Body of the main test //
2013-06-05 23:16:14 +00:00
//------------------------------------------------------------------------------//
START_TEST ( SeQueryInfoToken )
{
PACCESS_STATE AccessState ;
ACCESS_MASK AccessMask = MAXIMUM_ALLOWED ;
ACCESS_MASK DesiredAccess = MAXIMUM_ALLOWED ;
NTSTATUS Status = STATUS_SUCCESS ;
PAUX_ACCESS_DATA AuxData = NULL ;
PPRIVILEGE_SET NewPrivilegeSet ;
2023-05-27 18:07:49 +00:00
ULONG InitialPrivilegeCount ;
2013-06-05 23:16:14 +00:00
BOOLEAN Checker ;
PPRIVILEGE_SET Privileges = NULL ;
PSECURITY_SUBJECT_CONTEXT SubjectContext = NULL ;
PACCESS_TOKEN Token = NULL ;
PTOKEN_PRIVILEGES TPrivileges ;
PVOID Buffer ;
2013-06-06 21:54:00 +00:00
ULONG i ;
2013-06-05 23:16:14 +00:00
SubjectContext = ExAllocatePool ( PagedPool , sizeof ( SECURITY_SUBJECT_CONTEXT ) ) ;
SeCaptureSubjectContext ( SubjectContext ) ;
SeLockSubjectContext ( SubjectContext ) ;
Token = SeQuerySubjectContextToken ( SubjectContext ) ;
// Testing SQIT with current Token
TestsSeQueryInformationToken ( Token ) ;
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Creating an ACCESS_STATE structure //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
AccessState = ExAllocatePool ( PagedPool , sizeof ( ACCESS_STATE ) ) ;
2023-05-27 15:19:17 +00:00
// AUX_ACCESS_DATA gets larger in newer Windows version.
// This is the largest known size, found in Windows 10/11.
AuxData = ExAllocatePoolZero ( PagedPool , 0xE0 , ' QSmK ' ) ;
2013-06-05 23:16:14 +00:00
Status = SeCreateAccessState ( AccessState ,
2023-05-27 15:19:17 +00:00
AuxData ,
2013-06-05 23:16:14 +00:00
DesiredAccess ,
2023-05-27 15:19:17 +00:00
& ProcessGenericMapping
2013-06-05 23:16:14 +00:00
) ;
ok ( ( Status = = STATUS_SUCCESS ) , " SeCreateAccessState failed with Status 0x%08X \n " , Status ) ;
SeCaptureSubjectContext ( & AccessState - > SubjectSecurityContext ) ;
SeLockSubjectContext ( & AccessState - > SubjectSecurityContext ) ;
Token = SeQuerySubjectContextToken ( & AccessState - > SubjectSecurityContext ) ;
2013-06-06 09:44:34 +00:00
// Testing SQIT with AccessState Token
2013-06-05 23:16:14 +00:00
TestsSeQueryInformationToken ( Token ) ;
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing other functions //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing SeAppendPrivileges //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
2023-05-27 22:24:29 +00:00
InitialPrivilegeCount = AuxData - > PrivilegesUsed - > PrivilegeCount ;
2023-05-27 18:07:49 +00:00
trace ( " Initial privilege count = %lu \n " , InitialPrivilegeCount ) ;
2013-06-05 23:16:14 +00:00
2013-06-06 09:44:34 +00:00
// Testing SeAppendPrivileges. Must change PrivilegeCount to 2 (1 + 1)
2013-06-05 23:16:14 +00:00
2023-05-27 18:01:44 +00:00
NewPrivilegeSet = ExAllocatePoolZero ( PagedPool ,
FIELD_OFFSET ( PRIVILEGE_SET , Privilege [ 1 ] ) ,
' QSmK ' ) ;
2013-06-05 23:16:14 +00:00
NewPrivilegeSet - > PrivilegeCount = 1 ;
2013-06-06 09:44:34 +00:00
Status = SeAppendPrivileges ( AccessState , NewPrivilegeSet ) ;
ok ( Status = = STATUS_SUCCESS , " SeAppendPrivileges failed \n " ) ;
2023-05-27 22:24:29 +00:00
ok_eq_ulong ( AuxData - > PrivilegesUsed - > PrivilegeCount , InitialPrivilegeCount + 1 ) ;
2023-05-27 18:01:44 +00:00
ExFreePoolWithTag ( NewPrivilegeSet , ' QSmK ' ) ;
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
// Testing SeAppendPrivileges. Must change PrivilegeCount to 6 (2 + 4)
2023-05-27 18:01:44 +00:00
NewPrivilegeSet = ExAllocatePoolZero ( PagedPool ,
FIELD_OFFSET ( PRIVILEGE_SET , Privilege [ 4 ] ) ,
' QSmK ' ) ;
2013-06-05 23:16:14 +00:00
NewPrivilegeSet - > PrivilegeCount = 4 ;
2013-06-06 09:44:34 +00:00
Status = SeAppendPrivileges ( AccessState , NewPrivilegeSet ) ;
ok ( Status = = STATUS_SUCCESS , " SeAppendPrivileges failed \n " ) ;
2023-05-27 22:24:29 +00:00
ok_eq_ulong ( AuxData - > PrivilegesUsed - > PrivilegeCount , InitialPrivilegeCount + 5 ) ;
2023-05-27 18:01:44 +00:00
ExFreePoolWithTag ( NewPrivilegeSet , ' QSmK ' ) ;
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing SePrivilegeCheck //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
// KPROCESSOR_MODE is set to KernelMode ===> Always return TRUE
2023-05-27 22:24:29 +00:00
ok ( SePrivilegeCheck ( AuxData - > PrivilegesUsed , & ( AccessState - > SubjectSecurityContext ) , KernelMode ) , " SePrivilegeCheck failed with KernelMode mode arg \n " ) ;
2013-06-05 23:16:14 +00:00
// and call it again
2023-05-27 22:24:29 +00:00
ok ( SePrivilegeCheck ( AuxData - > PrivilegesUsed , & ( AccessState - > SubjectSecurityContext ) , KernelMode ) , " SePrivilegeCheck failed with KernelMode mode arg \n " ) ;
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
// KPROCESSOR_MODE is set to UserMode. Expect false
2023-05-27 22:24:29 +00:00
ok ( ! SePrivilegeCheck ( AuxData - > PrivilegesUsed , & ( AccessState - > SubjectSecurityContext ) , UserMode ) , " SePrivilegeCheck unexpected success with UserMode arg \n " ) ;
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing SeFreePrivileges //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
2023-05-28 02:37:47 +00:00
// FIXME: KernelMode will automatically get all access granted without
// getting Privileges filled in. For UserMode, Privileges will only get
// filled if either WRITE_OWNER or ACCESS_SYSTEM_SECURITY is requested
// and granted. So this doesn't really test SeFreePrivileges.
2016-11-04 17:52:32 +00:00
Privileges = NULL ;
2013-06-05 23:16:14 +00:00
Checker = SeAccessCheck (
AccessState - > SecurityDescriptor ,
& AccessState - > SubjectSecurityContext ,
FALSE ,
AccessState - > OriginalDesiredAccess ,
AccessState - > PreviouslyGrantedAccess ,
& Privileges ,
2023-05-27 15:19:17 +00:00
& ProcessGenericMapping ,
2013-06-05 23:16:14 +00:00
KernelMode ,
& AccessMask ,
& Status
) ;
ok ( Checker , " Checker is NULL \n " ) ;
2023-05-28 02:37:47 +00:00
ok ( Privileges = = NULL , " Privileges is not NULL \n " ) ;
2016-11-04 17:52:32 +00:00
if ( Privileges )
{
2023-05-27 22:24:29 +00:00
trace ( " AuxData->PrivilegesUsed->PrivilegeCount = %d ; Privileges->PrivilegeCount = %d \n " ,
AuxData - > PrivilegesUsed - > PrivilegeCount , Privileges - > PrivilegeCount ) ;
2016-11-04 17:52:32 +00:00
}
2013-06-05 23:16:14 +00:00
if ( Privileges ) SeFreePrivileges ( Privileges ) ;
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Testing SePrivilegeCheck //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
// I'm trying to make success call of SePrivilegeCheck from UserMode
// If we sets Privileges properly, can we expect true from SePrivilegeCheck?
// answer: yes
// This test demonstrates it
2013-06-06 09:44:34 +00:00
Buffer = NULL ;
Status = SeQueryInformationToken ( Token , TokenPrivileges , & Buffer ) ;
if ( Status = = STATUS_SUCCESS )
2013-06-05 23:16:14 +00:00
{
2016-11-04 17:52:32 +00:00
ok ( Buffer ! = NULL , " Wrong. SQIT call was successful with TokenPrivileges arg. But Buffer == NULL \n " ) ;
2013-06-06 09:44:34 +00:00
if ( Buffer )
{
TPrivileges = ( PTOKEN_PRIVILEGES ) ( Buffer ) ;
//trace("TPCount = %u\n\n", TPrivileges->PrivilegeCount);
2013-06-05 23:16:14 +00:00
2023-05-27 18:01:44 +00:00
NewPrivilegeSet = ExAllocatePoolZero ( PagedPool ,
FIELD_OFFSET ( PRIVILEGE_SET , Privilege [ 14 ] ) ,
' QSmK ' ) ;
2013-06-06 09:44:34 +00:00
NewPrivilegeSet - > PrivilegeCount = 14 ;
2013-06-05 23:16:14 +00:00
2013-06-06 09:44:34 +00:00
ok ( ( SeAppendPrivileges ( AccessState , NewPrivilegeSet ) ) = = STATUS_SUCCESS , " SeAppendPrivileges failed \n " ) ;
2023-05-27 22:24:29 +00:00
ok_eq_ulong ( AuxData - > PrivilegesUsed - > PrivilegeCount , InitialPrivilegeCount + 19 ) ;
2023-05-27 18:01:44 +00:00
ExFreePoolWithTag ( NewPrivilegeSet , ' QSmK ' ) ;
2023-05-27 22:24:29 +00:00
for ( i = 0 ; i < AuxData - > PrivilegesUsed - > PrivilegeCount ; i + + )
2013-06-06 09:44:34 +00:00
{
2023-05-27 22:24:29 +00:00
AuxData - > PrivilegesUsed - > Privilege [ i ] . Attributes = TPrivileges - > Privileges [ i ] . Attributes ;
AuxData - > PrivilegesUsed - > Privilege [ i ] . Luid = TPrivileges - > Privileges [ i ] . Luid ;
2013-06-06 09:44:34 +00:00
}
2023-05-27 22:24:29 +00:00
//trace("AccessState->privCount = %u\n\n", ((PAUX_ACCESS_DATA)(AccessState->AuxData))->PrivilegesUsed->PrivilegeCount);
2013-06-05 23:16:14 +00:00
2023-05-27 22:24:29 +00:00
ok ( SePrivilegeCheck ( AuxData - > PrivilegesUsed , & ( AccessState - > SubjectSecurityContext ) , UserMode ) , " SePrivilegeCheck fails in UserMode, but I wish it will success \n " ) ;
2013-06-06 09:44:34 +00:00
}
2013-06-05 23:16:14 +00:00
}
// Call SeFreePrivileges again
2023-05-28 02:37:47 +00:00
// FIXME: See other SeAccessCheck call above, we're not really testing
// SeFreePrivileges here.
2016-11-04 17:52:32 +00:00
Privileges = NULL ;
2013-06-05 23:16:14 +00:00
Checker = SeAccessCheck (
AccessState - > SecurityDescriptor ,
& AccessState - > SubjectSecurityContext ,
TRUE ,
AccessState - > OriginalDesiredAccess ,
AccessState - > PreviouslyGrantedAccess ,
& Privileges ,
2023-05-27 15:19:17 +00:00
& ProcessGenericMapping ,
2013-06-05 23:16:14 +00:00
KernelMode ,
& AccessMask ,
& Status
) ;
ok ( Checker , " Checker is NULL \n " ) ;
2023-05-28 02:37:47 +00:00
ok ( Privileges = = NULL , " Privileges is not NULL \n " ) ;
2016-11-04 17:52:32 +00:00
if ( Privileges )
{
2023-05-27 22:24:29 +00:00
trace ( " AuxData->PrivilegesUsed->PrivilegeCount = %d ; Privileges->PrivilegeCount = %d \n " ,
AuxData - > PrivilegesUsed - > PrivilegeCount , Privileges - > PrivilegeCount ) ;
2016-11-04 17:52:32 +00:00
}
2013-06-05 23:16:14 +00:00
if ( Privileges ) SeFreePrivileges ( Privileges ) ;
//----------------------------------------------------------------//
2013-06-06 09:44:34 +00:00
// Missing for now //
2013-06-05 23:16:14 +00:00
//----------------------------------------------------------------//
SeUnlockSubjectContext ( & AccessState - > SubjectSecurityContext ) ;
SeUnlockSubjectContext ( SubjectContext ) ;
SeDeleteAccessState ( AccessState ) ;
if ( SubjectContext ) ExFreePool ( SubjectContext ) ;
2023-05-27 15:19:17 +00:00
if ( AuxData ) ExFreePoolWithTag ( AuxData , ' QSmK ' ) ;
2013-06-05 23:16:14 +00:00
if ( AccessState ) ExFreePool ( AccessState ) ;
2021-05-08 15:25:33 +00:00
}