Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DuplicateAccessToken() [1/2]

static SafeAccessTokenHandle System.Security.Principal.WindowsIdentity.DuplicateAccessToken ( IntPtr accessToken)
inlinestaticprivate

Definition at line 451 of file WindowsIdentity.cs.

452 {
453 if (accessToken == IntPtr.Zero)
454 {
456 }
457 uint ReturnLength = 4u;
458 if (!global::Interop.Advapi32.GetTokenInformation(accessToken, 8u, IntPtr.Zero, 0u, out ReturnLength) && Marshal.GetLastWin32Error() == 6)
459 {
461 }
463 IntPtr currentProcess = global::Interop.Kernel32.GetCurrentProcess();
464 if (!global::Interop.Kernel32.DuplicateHandle(currentProcess, accessToken, currentProcess, ref lpTargetHandle, 0u, bInheritHandle: true, 2u))
465 {
466 throw new SecurityException(new Win32Exception().Message);
467 }
468 return lpTargetHandle;
469 }
static string Argument_TokenZero
Definition SR.cs:26
static string Argument_InvalidImpersonationToken
Definition SR.cs:22
Definition SR.cs:7

References System.SR.Argument_InvalidImpersonationToken, System.SR.Argument_TokenZero, System.Runtime.Serialization.Dictionary, System.Runtime.InteropServices.Marshal.GetLastWin32Error(), Microsoft.Win32.SafeHandles.SafeAccessTokenHandle.InvalidHandle, and System.IntPtr.Zero.

Referenced by System.Security.Principal.WindowsIdentity.CreateFromToken(), System.Security.Principal.WindowsIdentity.DuplicateAccessToken(), and System.Security.Principal.WindowsIdentity.RunImpersonatedInternal().