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

NtQueryInformationProcess() public static method

etrieves information about the specified process.
public static NtQueryInformationProcess ( SafeMemoryHandle processHandle ) : ProcessBasicInformation
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process to query.
return Binarysharp.MemoryManagement.Native.ProcessBasicInformation
        public static ProcessBasicInformation NtQueryInformationProcess(SafeMemoryHandle processHandle)
        {
            // Check if the handle is valid
            HandleManipulator.ValidateAsArgument(processHandle, "processHandle");

            // Create a structure to store process info
            var info = new ProcessBasicInformation();

            // Get the process info
            var ret = NativeMethods.NtQueryInformationProcess(processHandle, ProcessInformationClass.ProcessBasicInformation, ref info, info.Size, IntPtr.Zero);

            // If the function succeeded
            if (ret == 0)
                return info;

            // Else, couldn't get the process info, throws an exception
            throw new ApplicationException(string.Format("Couldn't get the information from the process, error code '{0}'.", ret));
        }