Beispiel #1
0
 internal unsafe T QueryObjectInformation <T>(ObjectInformationClass infoClass, ref T buff) where T : unmanaged
 {
     fixed(void *buffP = &buff)
     {
         PInvoke.NTSTATUS status = NtQueryObject(handle, infoClass, buffP, (uint)sizeof(T), out _);
         if (status.Severity != PInvoke.NTSTATUS.SeverityCode.STATUS_SEVERITY_SUCCESS)
         {
             throw new PInvoke.NTStatusException(status);
         }
         return(buff);
     }
 }
Beispiel #2
0
        internal unsafe T[] QueryInformationProcessArrayInternal <T>(ProcessInformationClass infoClass, ref T[] buff, ref uint validItemCount) where T : unmanaged
        {
            uint returnSize = 0;

            fixed(void *buffP = buff)
            {
                try {
                    PInvoke.NTSTATUS status = NtQueryInformationProcess(handle, infoClass, buffP, (uint)sizeof(T) * validItemCount, out returnSize);
                    if (status.Severity != PInvoke.NTSTATUS.SeverityCode.STATUS_SEVERITY_SUCCESS)
                    {
                        throw new PInvoke.NTStatusException(status);
                    }
                    return(buff);
                } finally {
                    validItemCount = returnSize / ((uint)sizeof(T));
                }
            }
        }