From a696f85479fb7b3b6d298c4da2028b81c010f14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 10 Aug 2004 20:13:42 +0000 Subject: [PATCH] Implement TokenOrigin class for GetTokenInformation svn path=/trunk/; revision=10487 --- reactos/include/ntos/security.h | 13 ++++++++- reactos/ntoskrnl/se/token.c | 48 +++++++++++++++++++++++++++++++-- reactos/w32api/include/winnt.h | 18 ++++++++++++- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/reactos/include/ntos/security.h b/reactos/include/ntos/security.h index 929be26a1b7..0e766bfc1d9 100644 --- a/reactos/include/ntos/security.h +++ b/reactos/include/ntos/security.h @@ -176,7 +176,14 @@ typedef enum _TOKEN_INFORMATION_CLASS TokenSource, TokenType, TokenImpersonationLevel, - TokenStatistics + TokenStatistics, + TokenRestrictedSids, + TokenSessionId, + TokenGroupsAndPrivileges, + TokenSessionReference, + TokenSandBoxInert, + TokenAuditPolicy, + TokenOrigin } TOKEN_INFORMATION_CLASS; typedef ULONG SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL; @@ -343,6 +350,10 @@ typedef struct _TOKEN_STATISTICS LUID ModifiedId; } TOKEN_STATISTICS, *PTOKEN_STATISTICS; +typedef struct _TOKEN_ORIGIN { + LUID OriginatingLogonSession; +} TOKEN_ORIGIN, *PTOKEN_ORIGIN; + typedef struct _GENERIC_MAPPING { ACCESS_MASK GenericRead; diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index bbe245bdac6..c1b61ae7767 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -1,4 +1,4 @@ -/* $Id: token.c,v 1.38 2004/08/03 19:20:39 ion Exp $ +/* $Id: token.c,v 1.39 2004/08/10 20:13:42 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -569,7 +569,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, IN ULONG TokenInformationLength, OUT PULONG ReturnLength) { - NTSTATUS Status; + NTSTATUS Status, LengthStatus; PVOID UnusedInfo; PVOID EndMem; PACCESS_TOKEN Token; @@ -807,6 +807,50 @@ NtQueryInformationToken(IN HANDLE TokenHandle, Status = STATUS_SUCCESS; } break; + + case TokenOrigin: + DPRINT1("NtQueryInformationToken(TokenOrigin)\n"); + if (TokenInformationLength < sizeof(TOKEN_ORIGIN)) + { + Status = STATUS_BUFFER_TOO_SMALL; + } + else + { + Status = MmCopyToCaller(&((PTOKEN_ORIGIN)TokenInformation)->OriginatingLogonSession, + &Token->AuthenticationId, sizeof(LUID)); + } + Length = sizeof(TOKEN_ORIGIN); + LengthStatus = MmCopyToCaller(ReturnLength, &Length, sizeof(ULONG)); + if (NT_SUCCESS(Status)) + { + Status = LengthStatus; + } + break; + + case TokenGroupsAndPrivileges: + DPRINT1("NtQueryInformationToken(TokenGroupsAndPrivileges) not implemented\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + + case TokenRestrictedSids: + DPRINT1("NtQueryInformationToken(TokenRestrictedSids) not implemented\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + + case TokenSandBoxInert: + DPRINT1("NtQueryInformationToken(TokenSandboxInert) not implemented\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + + case TokenSessionId: + DPRINT1("NtQueryInformationToken(TokenSessionId) not implemented\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + + default: + DPRINT1("NtQueryInformationToken(%d) invalid parameter\n"); + Status = STATUS_INVALID_PARAMETER; + break; } ObDereferenceObject(Token); diff --git a/reactos/w32api/include/winnt.h b/reactos/w32api/include/winnt.h index d637e2029cd..56f3ef0c540 100644 --- a/reactos/w32api/include/winnt.h +++ b/reactos/w32api/include/winnt.h @@ -2063,6 +2063,21 @@ typedef struct _TOKEN_GROUPS { DWORD GroupCount; SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; } TOKEN_GROUPS,*PTOKEN_GROUPS,*LPTOKEN_GROUPS; +typedef struct _TOKEN_GROUPS_AND_PRIVILEGES { + ULONG SidCount; + ULONG SidLength; + PSID_AND_ATTRIBUTES Sids; + ULONG RestrictedSidCount; + ULONG RestrictedSidLength; + PSID_AND_ATTRIBUTES RestrictedSids; + ULONG PrivilegeCount; + ULONG PrivilegeLength; + PLUID_AND_ATTRIBUTES Privileges; + LUID AuthenticationId; +} TOKEN_GROUPS_AND_PRIVILEGES, *PTOKEN_GROUPS_AND_PRIVILEGES; +typedef struct _TOKEN_ORIGIN { + LUID OriginatingLogonSession; +} TOKEN_ORIGIN, *PTOKEN_ORIGIN; typedef struct _TOKEN_OWNER { PSID Owner; } TOKEN_OWNER,*PTOKEN_OWNER; @@ -2107,7 +2122,8 @@ typedef enum _TOKEN_INFORMATION_CLASS { TokenUser=1,TokenGroups,TokenPrivileges,TokenOwner, TokenPrimaryGroup,TokenDefaultDacl,TokenSource,TokenType, TokenImpersonationLevel,TokenStatistics,TokenRestrictedSids, - TokenSessionId + TokenSessionId,TokenGroupsAndPrivileges,TokenSessionReference, + TokenSandBoxInert,TokenAuditPolicy,TokenOrigin, } TOKEN_INFORMATION_CLASS; typedef enum _SID_NAME_USE { SidTypeUser=1,SidTypeGroup,SidTypeDomain,SidTypeAlias,