Exemplo n.º 1
0
 internal AccessTokenHandle(ThreadHandle threadHandle, TokenAccessRights tokenAccessRights)
     : base(true)
 {
     if (!NativeMethods.OpenThreadToken(threadHandle, tokenAccessRights, true, ref handle))
     {
         var error = Marshal.GetLastWin32Error();
         if (error == NativeMethods.ErrorNoToken)
         {
             SetHandleAsInvalid();
         }
         else
         {
             throw new Win32Exception(error);
         }
     }
 }
Exemplo n.º 2
0
 internal static extern bool OpenThreadToken(
     [In] ThreadHandle processHandle,
     [In] TokenAccessRights desiredAccess,
     [In] bool openAsSelf,
     [In, Out] ref IntPtr tokenHandle);