DbgGetProcessIdByHandle() public static method

public static DbgGetProcessIdByHandle ( IntPtr InProcessHandle, Int32 &OutProcessId ) : void
InProcessHandle System.IntPtr
OutProcessId System.Int32
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Tries to get the underlying process ID for a given handle.
        /// </summary>
        /// <remarks>
        /// This is not always possible. The handle has to be opened with <c>PROCESS_QUERY_INFORMATION</c>
        /// access.
        /// </remarks>
        /// <param name="InProcessHandle">A valid process handle.</param>
        /// <returns>A valid process ID associated with the given process handle.</returns>
        /// <exception cref="AccessViolationException">
        /// The given handle was not opened with <c>PROCESS_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 GetProcessIdByHandle(IntPtr InProcessHandle)
        {
            Int32 Result;

            NativeAPI.DbgGetProcessIdByHandle(InProcessHandle, out Result);

            return(Result);
        }