public static extern bool DuplicateTokenEx( IntPtr hExistingToken, TOKEN_ACCESS dwDesiredAccess, ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);
public static extern bool OpenProcessToken(IntPtr ProcessHandle, TOKEN_ACCESS DesiredAccess, out IntPtr TokenHandle);
public static extern bool OpenThreadToken( IntPtr ThreadHandle, TOKEN_ACCESS DesiredAccess, bool OpenAsSelf, out IntPtr TokenHandle);