ZwQuerySystemInformation | SystemProcessInformation

Arsium ***** 331 Reputation points
2021-01-20T09:57:34.93+00:00

So my problem is :

  int nHandleInfoSize = 0x10000;

            void* ipHandlePointer = (void*)Marshal.AllocHGlobal((IntPtr)nHandleInfoSize);
            int nLength = 0;


            while (ZwQuerySystemInformation(Enumerations._SYSTEM_INFORMATION_CLASS.SystemProcessInformation, ipHandlePointer, nHandleInfoSize, out nLength) == NtDll.NTSTATUS.STATUS_INFO_LENGTH_MISMATCH)
            {
                nHandleInfoSize = nLength;
                Marshal.FreeHGlobal((IntPtr)ipHandlePointer);
                ipHandlePointer = (void*)Marshal.AllocHGlobal(nLength);

            }
            //          MessageBox.Show(RtlGetNativeSystemInformation(Enumerations._SYSTEM_INFORMATION_CLASS.SystemBasicInformation, ipHandlePointer, nHandleInfoSize, out nLength).ToString());

            Structures._SYSTEM_PROCESS_INFORMATION* strstr = (Structures._SYSTEM_PROCESS_INFORMATION*)ipHandlePointer;


            MessageBox.Show(nLength.ToString());
            MessageBox.Show(strstr-> UniqueProcessId.ToString());

When I try this code, I got success with NTSTATUS of my function , I got the lenght of information , but when I try to read information , some of them got 0 like UniqueProcessId but NumberOfThreads returned a number any idea or advice ?

Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Arsium ***** 331 Reputation points
    2021-01-20T11:18:15.66+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.