Example #1
0
    internal static T QueryInformation <T>(this Process process, ProcessInformationType informationType) where T : unmanaged
    {
        Span <byte> informationBytes = stackalloc byte[Unsafe.SizeOf <T>()];

        var status = Ntdll.NtQueryInformationProcess(process.SafeHandle, informationType, out informationBytes[0], informationBytes.Length, IntPtr.Zero);

        if (status != NtStatus.Success)
        {
            throw new Win32Exception(Ntdll.RtlNtStatusToDosError(status));
        }

        return(MemoryMarshal.Read <T>(informationBytes));
    }
Example #2
0
 internal static extern NtStatus NtQueryInformationProcess(SafeProcessHandle processHandle, ProcessInformationType informationType, out byte information, int informationSize, IntPtr returnLength);
Example #3
0
 public static extern int NtQueryInformationProcess(SafeProcessHandle processHandle, ProcessInformationType informationType, out byte information, int informationSize, out int returnLength);