114{
120 HANDLE ImpersonationToken = 0, ProcessToken;
121
123
124
126 {
128 }
129
130
132 {
134 }
135
136
137
138
142 {
144 }
145
146
148 State->OldImpersonationToken = 0;
151
152
154 {
155
157 {
158
159
160
161
164 {
167 }
168 }
169 else
170 {
171
172
173
176 {
179 }
180
181
183
184
187 &ImpersonationToken,
189 }
190 }
191
192
194 {
195
197 {
201 {
203 }
204 }
205 else
206 {
207
208
209
211
214 0,
217
223
224
225 Status = ZwDuplicateToken(ProcessToken,
230 &ImpersonationToken);
232 {
235 }
236
237
240 &ImpersonationToken,
243 {
247 }
248
249
250 State->Token = ImpersonationToken;
252
254 }
255 }
256
257
258
259
260
261
264
265
266 State->NewPrivileges->PrivilegeCount = NumPriv;
267 for (
i = 0;
i < NumPriv; ++
i)
268 {
270 State->NewPrivileges->Privileges[
i].Luid.HighPart = 0;
272 }
273
274
275 OldSize =
sizeof(
State->OldPrivBuffer);
276 do
277 {
281
283 {
284
286 if (
State->OldPrivileges)
287 {
288 DPRINT(
"Allocated old privileges: %p\n",
State->OldPrivileges);
290 continue;
291 }
292 else
293 {
294
296 }
297 }
298
299
301 {
302
303 if (NumPriv == 1)
304 {
306 }
307 }
308
309
311 {
313 }
314 else
315 {
316 *ReturnedState =
State;
317 break;
318 }
320
321 DPRINT(
"RtlAcquirePrivilege succeed!\n");
322
324
326
328 {
330 }
331
332
334 {
337
339 {
341 }
342 }
343
344
346 {
348 }
349
350
352
353 DPRINT(
"RtlAcquirePrivilege() failed with status: %lx\n",
Status);
354
356}
#define STATUS_PRIVILEGE_NOT_HELD
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
@ ThreadImpersonationToken
static const WCHAR Cleanup[]
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
struct _SECURITY_QUALITY_OF_SERVICE SECURITY_QUALITY_OF_SERVICE
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
#define RTL_ACQUIRE_PRIVILEGE_IMPERSONATE
#define RTL_ACQUIRE_PRIVILEGE_PROCESS
_Must_inspect_result_ NTSYSAPI NTSTATUS NTAPI ZwAdjustPrivilegesToken(_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)
#define NtCurrentProcess()
#define STATUS_NOT_ALL_ASSIGNED
NTSTATUS NTAPI RtlpOpenThreadToken(IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle)
#define STATUS_BUFFER_TOO_SMALL
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
#define STATUS_INVALID_PARAMETER
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
_Must_inspect_result_ _In_ ULONG Flags
#define TOKEN_ADJUST_PRIVILEGES
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES
#define TOKEN_IMPERSONATE
#define SE_PRIVILEGE_ENABLED
NTSYSAPI NTSTATUS NTAPI ZwOpenProcessToken(_In_ HANDLE ProcessHandle, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE TokenHandle)
#define NtCurrentThread()