/// <summary> /// Tries to get the underlying thread ID for a given handle. /// </summary> /// <remarks> /// This is not always possible. The handle has to be opened with <c>THREAD_QUERY_INFORMATION</c> /// access. /// </remarks> /// <param name="InThreadHandle">A valid thread handle.</param> /// <returns>A valid thread ID associated with the given thread handle.</returns> /// <exception cref="AccessViolationException"> /// The given handle was not opened with <c>THREAD_QUERY_INFORMATION</c> access.</exception> /// <exception cref="ArgumentException"> /// The handle is invalid. /// </exception> /// <exception cref="NotSupportedException"> /// Should never occur and just notifies you that a handle to thread ID conversion is not /// available on the current platform. /// </exception> public static Int32 GetThreadIdByHandle(IntPtr InThreadHandle) { Int32 Result; NativeAPI.DbgGetThreadIdByHandle(InThreadHandle, out Result); return(Result); }