Binarysharp.MemoryManagement.Helpers.HandleManipulator.HandleToProcessId C# (CSharp) Method

HandleToProcessId() public static method

Converts an handle into a process id assuming this is a process handle.
public static HandleToProcessId ( SafeMemoryHandle processHandle ) : int
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A valid handle to an opened process.
return int
        public static int HandleToProcessId(SafeMemoryHandle processHandle)
        {
            // Check if the handle is valid
            ValidateAsArgument(processHandle, "processHandle");

            // Find the process id
            var ret = NativeMethods.GetProcessId(processHandle);

            // If the process id is valid
            if (ret != 0)
                return ret;

            // Else the function failed, throws an exception
            throw new Win32Exception("Couldn't find the process id of the specified handle.");
        }