ReactOS  0.4.15-dev-3712-gf1ad684
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)
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
#define ok(value,...)
Definition: atltest.h:57
BOOLEAN Expected

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)
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
#define ok(value,...)
Definition: atltest.h:57

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;
21  BOOL Result;
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),
32  &ReturnLength);
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),
44  &ReturnLength);
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 }
LUID AuthenticationId
Definition: setypes.h:1065
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define CloseHandle
Definition: compat.h:598
$ULONG GroupCount
Definition: setypes.h:1071
$ULONG DynamicCharged
Definition: setypes.h:1069
#define ok_luid_notequal(Luid, Comparand)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ok_luid_equal(Luid, Expected)
unsigned int BOOL
Definition: ntddk_ex.h:94
_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:426
TOKEN_TYPE TokenType
Definition: setypes.h:1067
#define TOKEN_QUERY
Definition: setypes.h:906
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: setypes.h:1068
unsigned long DWORD
Definition: ntddk_ex.h:95
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:3517
#define ok_size_t(expression, result)
Definition: atltest.h:115
#define TOKEN_DUPLICATE
Definition: setypes.h:904
#define GetCurrentProcess()
Definition: compat.h:618
$ULONG PrivilegeCount
Definition: setypes.h:1072
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
$ULONG DynamicAvailable
Definition: setypes.h:1070
#define ok_dec(expression, result)
Definition: atltest.h:101