ReactOS  0.4.15-dev-3453-gff89651
NtAdjustGroupsToken.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API tests
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Tests for the NtAdjustGroupsToken API
5  * COPYRIGHT: Copyright 2021 George BiČ™oc <george.bisoc@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 static
11 HANDLE
13  _In_ DWORD Access)
14 {
15  BOOL Success;
16  HANDLE Token;
17 
19  if (!Success)
20  {
21  skip("Failed to open the process' token (error code: %lu)!\n", GetLastError());
22  return NULL;
23  }
24 
25  return Token;
26 }
27 
29 {
32 
33  /* Get the token from current process but with incorrect rights */
35 
36  /* We give an invalid handle */
38  TRUE,
39  NULL,
40  0,
41  NULL,
42  NULL);
44 
45  /* We're trying to adjust the token's groups with wrong rights */
47  TRUE,
48  NULL,
49  0,
50  NULL,
51  NULL);
53 
54  /* Close our handle and open a new one with right access right */
57 
58  /* We don't give a list of groups to be adjusted in token */
60  FALSE,
61  NULL,
62  0,
63  NULL,
64  NULL);
66 
67  /* Reset the groups of an access token to default */
69  TRUE,
70  NULL,
71  0,
72  NULL,
73  NULL);
75 
77 }
#define CloseHandle
Definition: compat.h:598
static HANDLE GetProcessToken(_In_ DWORD Access)
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ok_hex(expression, result)
Definition: atltest.h:94
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _In_
Definition: ms_sal.h:308
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
Definition: psfuncs.h:715
Status
Definition: gdiplustypes.h:24
#define TOKEN_ADJUST_GROUPS
Definition: setypes.h:909
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define TOKEN_DUPLICATE
Definition: setypes.h:904
#define GetCurrentProcess()
Definition: compat.h:618
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define skip(...)
Definition: atltest.h:64
NTSTATUS NTAPI NtAdjustGroupsToken(_In_ HANDLE TokenHandle, _In_ BOOLEAN ResetToDefault, _In_ PTOKEN_GROUPS NewState, _In_ ULONG BufferLength, _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_GROUPS PreviousState, _When_(PreviousState !=NULL, _Out_) PULONG ReturnLength)
Changes the list of groups by enabling or disabling them in an access token. Unlike NtAdjustPrivilege...
Definition: token.c:5276
#define STATUS_SUCCESS
Definition: shellext.h:65
START_TEST(NtAdjustGroupsToken)