Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "OpenThread" in [All]

Enums

.

    public const int CO_E_FAILEDTOOPENTHREADTOKEN = unchecked((int)0x80010125);

.

    Public Const CO_E_FAILEDTOOPENTHREADTOKEN As Integer = CInt(&H80010125UI)

userenv

.

in Token for the user, which is returned by the LogonUser, CreateRestrictedToken, DuplicateToken, OpenProcessToken, or OpenThreadToken function. The token must have TOKEN_QUERY and TOKEN_IMPERSONATE and TOKEN_DUPLICATE access. For more information, see Access Rights for Access-Token Objects.

Constants

.

        public const int CO_E_FAILEDTOOPENTHREADTOKEN = (int)(0x80010125 - 0x100000000);

advapi32

.

static extern bool OpenThreadToken(

.

Declare Function OpenThreadToken Lib "advapi32.dll" (

.

    private static extern bool OpenThreadToken(IntPtr ThreadHandle,

.

    if (!OpenThreadToken(GetCurrentThread(), TOKEN_READ | TOKEN_IMPERSONATE, true, out hToken))

.

        System.Diagnostics.Trace.WriteLine("Unexpected error 0x" + dw.ToString("x4") + " on OpenThreadToken", "Impersonation");

.
Documentation
[OpenThreadToken] on MSDN

kernel32

.

This does not return a real handle, but a fixed value which is interpreted as the current, calling thread by any function which requires a thread handle. To get the real handle, you need to call GetCurrentThreadId, then OpenThread with the returned value along with the necessary permissions and what-not. Then close the handle when you're done with it.

.

     static extern IntPtr OpenThread(uint dwDesiredAccess, bool bInheritHandle,

.

     IntPtr hThread = OpenThread(GET_CONTEXT, false, threadId);

.
Summary
.

static extern Microsoft.Win32.SafeHandles.SafeAccessTokenHandle OpenThread(

.

static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle,

.

def OpenThread(dwDesiredAccess as int, bInheritHandle as bool, dwThreadId as int) as IntPtr:

.

           OpenThread(

.

          SuspendThread(pOpenThread);

.
Documentation
[OpenThread] on MSDN
.

           IntPtr threadHandle = OpenThread(THREADACCESS_SUSPEND_RESUME, false, (uint)thd.Id); // Open thread with required permissions

.

           if (threadHandle == IntPtr.Zero) // If thread pointer is zero, means that the 'OpenThread' function has failed


 
Access PInvoke.net directly from VS: