ReactOS 0.4.15-dev-7924-g5949c20
DuplicateTokenEx.c File Reference
#include "precomp.h"
Include dependency graph for DuplicateTokenEx.c:

Go to the source code of this file.

Macros

#define ok_luid_equal(Luid, Expected)
 
#define ok_luid_notequal(Luid, Comparand)
 

Functions

 START_TEST (DuplicateTokenEx)
 

Macro Definition Documentation

◆ ok_luid_equal

#define ok_luid_equal (   Luid,
  Expected 
)
Value:
ok(RtlEqualLuid((Luid), (Expected)), "Got wrong LUID %08lx%08lx, expected (%08lx%08lx).\n", \
(Luid)->HighPart, (Luid)->LowPart, (Expected)->HighPart, (Expected)->LowPart)
BOOLEAN Expected
#define ok(value,...)
Definition: atltest.h:57
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301

Definition at line 10 of file DuplicateTokenEx.c.

◆ ok_luid_notequal

#define ok_luid_notequal (   Luid,
  Comparand 
)
Value:
ok(!RtlEqualLuid((Luid), (Comparand)), "LUID is %08lx%08lx and should not be.\n", \
(Luid)->HighPart, (Luid)->LowPart)

Definition at line 13 of file DuplicateTokenEx.c.

Function Documentation

◆ START_TEST()

START_TEST ( DuplicateTokenEx  )

Definition at line 17 of file DuplicateTokenEx.c.

18{
19 HANDLE ProcessToken, TokenDup;
20 TOKEN_STATISTICS ProcessTokenStats, TokenDupStats;
23
24 /* Get the current process token */
26 ok(Result, "OpenProcessToken failed. GLE: %lu.\n", GetLastError());
27 /* And its statistics */
28 Result = GetTokenInformation(ProcessToken,
30 &ProcessTokenStats,
31 sizeof(ProcessTokenStats),
33 ok(Result, "GetTokenInformation failed. GLE: %lu.\n", GetLastError());
34 ok_size_t(ReturnLength, sizeof(ProcessTokenStats));
35
36 /* Duplicate it as primary token with the same access rights. */
37 Result = DuplicateTokenEx(ProcessToken, 0, NULL, SecurityImpersonation, TokenPrimary, &TokenDup);
38 ok(Result, "DuplicateTokenEx failed. GLE: %lu.\n", GetLastError());
39 /* Get the stats */
40 Result = GetTokenInformation(TokenDup,
42 &TokenDupStats,
43 sizeof(ProcessTokenStats),
45 ok(Result, "GetTokenInformation failed. GLE: %lu.\n", GetLastError());
46 ok_size_t(ReturnLength, sizeof(ProcessTokenStats));
47 /* And test them */
48 ok_luid_notequal(&TokenDupStats.TokenId, &ProcessTokenStats.TokenId);
49 ok_luid_equal(&TokenDupStats.AuthenticationId, &ProcessTokenStats.AuthenticationId);
50 ok(TokenDupStats.TokenType == TokenPrimary, "Duplicate token type is %d.\n", TokenDupStats.TokenType);
52 "Duplicate token impersonation level is %d.\n", TokenDupStats.ImpersonationLevel);
53 ok_dec(TokenDupStats.DynamicCharged, ProcessTokenStats.DynamicCharged);
54 ok_dec(TokenDupStats.DynamicAvailable, ProcessTokenStats.DynamicAvailable);
55 ok_dec(TokenDupStats.GroupCount, ProcessTokenStats.GroupCount);
56 ok_dec(TokenDupStats.PrivilegeCount, ProcessTokenStats.PrivilegeCount);
57 ok_luid_equal(&TokenDupStats.ModifiedId, &ProcessTokenStats.ModifiedId);
58
59 CloseHandle(ProcessToken);
60 CloseHandle(TokenDup);
61}
#define ok_luid_notequal(Luid, Comparand)
#define ok_luid_equal(Luid, Expected)
#define ok_size_t(expression, result)
Definition: atltest.h:115
#define ok_dec(expression, result)
Definition: atltest.h:101
#define NULL
Definition: types.h:112
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI DuplicateTokenEx(IN HANDLE ExistingTokenHandle, IN DWORD dwDesiredAccess, IN LPSECURITY_ATTRIBUTES lpTokenAttributes OPTIONAL, IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, IN TOKEN_TYPE TokenType, OUT PHANDLE DuplicateTokenHandle)
Definition: security.c:3859
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SecurityImpersonation
Definition: lsa.idl:57
@ TokenPrimary
Definition: imports.h:273
LUID AuthenticationId
Definition: setypes.h:1087
TOKEN_TYPE TokenType
Definition: setypes.h:1089
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: setypes.h:1090
$ULONG DynamicAvailable
Definition: setypes.h:1092
$ULONG PrivilegeCount
Definition: setypes.h:1094
$ULONG DynamicCharged
Definition: setypes.h:1091
$ULONG GroupCount
Definition: setypes.h:1093
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
#define TOKEN_DUPLICATE
Definition: setypes.h:926
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenStatistics
Definition: setypes.h:975