Binarysharp.MemoryManagement.Memory.MemoryCore.OpenProcess C# (CSharp) Method

OpenProcess() public static method

Opens an existing local process object.
public static OpenProcess ( ProcessAccessFlags accessFlags, int processId ) : SafeMemoryHandle
accessFlags ProcessAccessFlags The access level to the process object.
processId int The identifier of the local process to be opened.
return Binarysharp.MemoryManagement.Native.SafeMemoryHandle
        public static SafeMemoryHandle OpenProcess(ProcessAccessFlags accessFlags, int processId)
        {
            // Get an handle from the remote process
            var handle = NativeMethods.OpenProcess(accessFlags, false, processId);

            // Check whether the handle is valid
            if (!handle.IsInvalid && !handle.IsClosed)
                return handle;

            // Else the handle isn't valid, throws an exception
            throw new Win32Exception(string.Format("Couldn't open the process {0}.", processId));
        }