Beispiel #1
0
        // In the BCL an equivalent method to this appears in the private class System.Diagnostics.NtProcessManager
        private static int GetParentProcessId()
        {
            NtProcessBasicInfo info    = new NtProcessBasicInfo();
            Process            process = Process.GetCurrentProcess();
            int       returnedSize;
            HandleRef href   = new HandleRef(process, process.Handle);
            int       result = NativeMethods.NtQueryInformationProcess(href, 0, ref info, Marshal.SizeOf(info.GetType()), out returnedSize);

            if (result != 0)
            {
                throw new InvalidOperationException(
                          "Unable to retrieve the parent process id", new Win32Exception(result));
            }

            return((int)info.InheritedFromUniqueProcessId);
        }
 public static extern int NtQueryInformationProcess(SafeProcessHandle processHandle, int query, NtProcessBasicInfo info, int size, int[] returnedSize);
Beispiel #3
0
 public static extern int NtQueryInformationProcess(
     HandleRef processHandle, int query, ref NtProcessBasicInfo info, int size, out int returnedSize);
Beispiel #4
0
 public static extern int NtQueryInformationProcess(SafeProcessHandle processHandle, int query, NtProcessBasicInfo info, int size, int[] returnedSize);