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));
}