#ifndef _NTLPCAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
NtImpersonateClientOfPort(
    _In_ HANDLE PortHandle,
    _In_ PPORT_MESSAGE Message
    );
View code on GitHub#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwImpersonateClientOfPort(
    _In_ HANDLE PortHandle,
    _In_ PPORT_MESSAGE Message
    );
View code on GitHubNtImpersonateClientOfPort is called by LPC server process to get security context of client. That means: client's Token Object is associated with calling server thread (like NtSetInformationThread with ThreadImpersonationToken information class).
HANDLE to Port Object opened with NtAcceptConnectPort call.
Pointer to LPC_MESSAGE structure contains reason of impersonation.