RtlImpersonateSelf - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H

NTSYSAPI
NTSTATUS
NTAPI
RtlImpersonateSelf(
    _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
    );

#endif

View code on GitHub

Impersonates a copy of the current process's token on the current thread.

Parameters

Implementation details

The function opens the current process token via NtOpenProcessTokenEx, duplicates it via NtDuplicateToken, and then impersonates it via NtSetInformationThread with ThreadImpersonationToken.

Remarks

To reset impersonation, use NtSetInformationThread with ThreadImpersonationToken info class and a NULL token handle.

Related Win32 API

See also