11{
12#if (NTDDI_VERSION >= NTDDI_VISTA)
20 ULONG PrivilegesToKeep[2];
21
22
25 {
26 ok(0,
"Failed to open current process token with TOKEN_DUPLICATE access (Status code %lx)!\n",
Status);
27 return;
28 }
29
33 {
34 ok(0,
"Failed to duplicate current process token (Status code %lx)!\n",
Status);
35 return;
36 }
37
38
41 {
43 ok(0,
"Failed to retrieve token privileges (Status code %lx)!\n",
Status);
44 return;
45 }
48 {
50 ok(0,
"No enough privileges to run the test (Number of privilege: %lu)!\n",
Privileges->PrivilegeCount);
51 return;
52 }
53
54
55 PrivilegesToKeep[0] =
Privileges->Privileges[1].Luid.LowPart;
56 PrivilegesToKeep[1] =
Privileges->Privileges[2].Luid.LowPart;
58
59
61 {
64 return;
65 }
66
67
70 {
72 ok(0,
"Failed to retrieve token privileges (Status code %lx)!\n",
Status);
73 return;
74 }
76 "Number of privileges after RtlRemovePrivileges is %lu, expected %u\n",
Privileges->PrivilegeCount,
78 ok(PrivilegesToKeep[0] + PrivilegesToKeep[1] ==
80 "Incorrect privileges kept by RtlRemovePrivileges: %lu and %lu, expected %lu and %lu",
81 Privileges->Privileges[0].Luid.LowPart,
Privileges->Privileges[1].Luid.LowPart, PrivilegesToKeep[0],
82 PrivilegesToKeep[1]);
83
84
86
87
89 {
92 return;
93 }
94
95
98 {
100 ok(0,
"Failed to retrieve token privileges (Status code %lx)!\n",
Status);
101 return;
102 }
103 ok(
Privileges->PrivilegeCount == 0,
"There are %lu privileges still exist after RtlRemovePrivileges\n",
105
107 return;
108#else
109 skip(
"RtlRemovePrivileges available on NT6.0+ (NTDDI_VERSION >= NTDDI_VISTA)");
110#endif
111}
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG ReturnLength
#define ok_ntstatus(status, expected)
#define NT_SUCCESS(StatCode)
#define GetCurrentProcess()
#define SE_MIN_WELL_KNOWN_PRIVILEGE
#define SE_MAX_WELL_KNOWN_PRIVILEGE
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
NTSYSAPI NTSTATUS NTAPI RtlRemovePrivileges(_In_ HANDLE TokenHandle, _In_reads_opt_(PrivilegeCount) _When_(PrivilegeCount !=0, _Notnull_) PULONG PrivilegesToKeep, _In_ ULONG PrivilegeCount)
Removes all privileges in the specified access token.
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSTATUS NTAPI NtOpenProcessToken(IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle)
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtQueryInformationToken(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_writes_bytes_to_opt_(TokenInformationLength, *ReturnLength) PVOID TokenInformation, _In_ ULONG TokenInformationLength, _Out_ PULONG ReturnLength)
Queries a specific type of information in regard of an access token based upon the information class....
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtDuplicateToken(_In_ HANDLE ExistingTokenHandle, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, _In_ BOOLEAN EffectiveOnly, _In_ TOKEN_TYPE TokenType, _Out_ PHANDLE NewTokenHandle)
Duplicates a token.
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET * Privileges
struct _TOKEN_PRIVILEGES TOKEN_PRIVILEGES
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES