Exemple #1
0
            public static Process GetParentProcess(IntPtr handle)
            {
                Imports.ParentProcessUtilities processInformation = new Imports.ParentProcessUtilities();
                int returnLength;
                int error = Imports.ParentProcessUtilities.NtQueryInformationProcess(handle, 0, ref processInformation, Marshal.SizeOf((object)processInformation), out returnLength);

                if (error != 0)
                {
                    throw new Win32Exception(error);
                }
                try
                {
                    return(Process.GetProcessById(processInformation.InheritedFromUniqueProcessId.ToInt32()));
                }
                catch (ArgumentException ex)
                {
                    return((Process)null);
                }
            }
Exemple #2
0
 private static extern int NtQueryInformationProcess(
     IntPtr processHandle,
     int processInformationClass,
     ref Imports.ParentProcessUtilities processInformation,
     int processInformationLength,
     out int returnLength);