Пример #1
0
        /// <summary>
        /// Gets the thread information for the given thread
        /// </summary>
        /// <param name="thread">The ID of the thread to query for information</param>
        /// <returns>
        /// Returns a valid proc_threadinfo struct for valid threads that the caller
        /// has permissions to access; otherwise, returns null
        /// </returns>
        internal static unsafe proc_threadinfo?GetThreadInfoById(int pid, ulong thread)
        {
            // Negative PIDs are invalid
            if (pid < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pid));
            }

            // Negative TIDs are invalid
            if (thread < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(thread));
            }

            // Get the thread information for the specified thread in the specified process
            int             size   = sizeof(proc_threadinfo);
            proc_threadinfo info   = default(proc_threadinfo);
            int             result = proc_pidinfo(pid, PROC_PIDTHREADINFO, (ulong)thread, &info, size);

            return(result == size ? new proc_threadinfo?(info) : null);
        }
Пример #2
0
 private static unsafe extern int proc_pidinfo(
     int pid,
     int flavor,
     ulong arg,
     proc_threadinfo* buffer,
     int bufferSize);