SeCopyClientToken
INT64 __fastcall SeCopyClientToken(
VOID *ClientToken,
_SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
CHAR RequestorMode,
UINT8 UseProcessTrust,
VOID *ProcessTrustSid,
VOID **DuplicateToken){
int inserted;
_TOKEN *v8;
VOID *v10;
int appended;
UINT64 ImpersonationLevela;
PADAPTER_OBJECT DmaAdapter;
_OBJECT_ATTRIBUTES ObjectAttributes;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
DmaAdapter = 0i64;
memset(&ObjectAttributes.RootDirectory, 0, 40);
inserted = SepDuplicateToken(
(_TOKEN *)ClientToken,
&ObjectAttributes,
0,
TokenImpersonation,
ImpersonationLevel,
0,
0,
(_TOKEN **)&DmaAdapter);
if( inserted < 0 )
goto LABEL_13;
if( UseProcessTrust )
inserted = SepSetTokenTrust((_TOKEN *)DmaAdapter, ProcessTrustSid);
if( inserted < 0 )
goto LABEL_13;
LODWORD(ImpersonationLevela) = 0;
inserted = ObInsertObjectEx(DmaAdapter, 0i64, 0i64, 0i64, ImpersonationLevela, 0i64, 0i64);
if( inserted < 0 )
goto LABEL_13;
v8 = (_TOKEN *)DmaAdapter;
if( ((__int64)DmaAdapter[12].DmaOperations & 0x4000) != 0 )
{
v10 = *(VOID **)&DmaAdapter[49].Version;
if( v10 )
{
appended = SepAppendAceToTokenObjectAcl((_TOKEN *)DmaAdapter, 0xF01FFui64, v10);
v8 = (_TOKEN *)DmaAdapter;
inserted = appended;
if( appended >= 0 )
goto LABEL_8;
HalPutDmaAdapter(DmaAdapter);
v8 = (_TOKEN *)DmaAdapter;
}
}
if( inserted < 0 )
{
LABEL_13:
*DuplicateToken = 0i64;
return(unsigned int)inserted;
}
LABEL_8:
SepAppendAceToTokenObjectAcl(v8, 8ui64, SeAliasAdminsSid);
*DuplicateToken = DmaAdapter;
return(unsigned int)inserted;
}Referenced by:
PsImpersonateClient
SepCopyClientTokenAndSetSilo
SepCreateClientSecurityEx