ReactOS 0.4.15-dev-7674-gc0b4db1
NtAdjustPrivilegesToken.c File Reference
#include "precomp.h"
Include dependency graph for NtAdjustPrivilegesToken.c:

Go to the source code of this file.

Functions

static BOOL IsPrivilegeEnabled (_In_ HANDLE TokenHandle, _In_ ULONG Privilege)
 
static VOID AdjustEnableDefaultPriv (VOID)
 
 START_TEST (NtAdjustPrivilegesToken)
 

Function Documentation

◆ AdjustEnableDefaultPriv()

static VOID AdjustEnableDefaultPriv ( VOID  )
static

Definition at line 39 of file NtAdjustPrivilegesToken.c.

40{
45 LUID PrivLuid;
46
49 &Token);
50 if (!Success)
51 {
52 skip("OpenProcessToken() has failed to get the process' token (error code: %lu)!\n", GetLastError());
53 return;
54 }
55
56 Success = LookupPrivilegeValueW(NULL, L"SeImpersonatePrivilege", &PrivLuid);
57 if (!Success)
58 {
59 skip("LookupPrivilegeValueW() has failed to locate the privilege value (error code: %lu)!\n", GetLastError());
60 return;
61 }
62
63 Priv.PrivilegeCount = 1;
64 Priv.Privileges[0].Luid = PrivLuid;
65 Priv.Privileges[0].Attributes = 0;
66
68 trace("The privilege is %s!\n", IsEnabled ? "enabled" : "disabled");
69
71 FALSE,
72 &Priv,
73 0,
74 NULL,
75 NULL);
77
79 trace("The privilege is %s!\n", IsEnabled ? "enabled" : "disabled");
80
82}
static BOOL IsPrivilegeEnabled(_In_ HANDLE TokenHandle, _In_ ULONG Privilege)
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
return pProvider IsEnabled(ProviderControl)
Status
Definition: gdiplustypes.h:25
#define SE_IMPERSONATE_PRIVILEGE
Definition: security.c:683
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtAdjustPrivilegesToken(_In_ HANDLE TokenHandle, _In_ BOOLEAN DisableAllPrivileges, _In_opt_ PTOKEN_PRIVILEGES NewState, _In_ ULONG BufferLength, _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, _When_(PreviousState!=NULL, _Out_) PULONG ReturnLength)
Removes a certain amount of privileges of a token based upon the request by the caller.
Definition: tokenadj.c:451
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_READ
Definition: setypes.h:951

Referenced by START_TEST().

◆ IsPrivilegeEnabled()

static BOOL IsPrivilegeEnabled ( _In_ HANDLE  TokenHandle,
_In_ ULONG  Privilege 
)
static

Definition at line 12 of file NtAdjustPrivilegesToken.c.

15{
16 PRIVILEGE_SET PrivSet;
18 LUID Priv;
19
21
22 PrivSet.PrivilegeCount = 1;
24 PrivSet.Privilege[0].Luid = Priv;
25 PrivSet.Privilege[0].Attributes = 0;
26
28 if (!Success)
29 {
30 skip("Failed to check the privilege (error code: %lu)\n", GetLastError());
31 return FALSE;
32 }
33
34 return Result;
35}
BOOL WINAPI PrivilegeCheck(HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
Definition: security.c:2066
#define ConvertPrivLongToLuid(PrivilegeVal, ConvertedPrivLuid)
Definition: precomp.h:44
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
Definition: psfuncs.h:718
LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]
Definition: setypes.h:88
$ULONG Control
Definition: setypes.h:87
$ULONG PrivilegeCount
Definition: setypes.h:86
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
_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 PRIVILEGE_SET_ALL_NECESSARY
Definition: setypes.h:83

Referenced by AdjustEnableDefaultPriv().

◆ START_TEST()

START_TEST ( NtAdjustPrivilegesToken  )

Definition at line 84 of file NtAdjustPrivilegesToken.c.

85{
87}
static VOID AdjustEnableDefaultPriv(VOID)