简体   繁体   中英

How to find the memory used by a process from kernel mode in Windows

I am trying to get the memory used by a process in kernel mode of Windows.

I tried using the GetProcessMemoryInfo API through PSAPI.h . but this is a USER mode function, and it's not giving me data.

Is there any other way to get the memory details?

you need use ProcessVmCounters and ProcessIoCounters with ZwQueryInformationProcess or NtQueryInformationProcess dependent on previous mode

ULONG rcb;
union {
    VM_COUNTERS vmc;
    VM_COUNTERS_EX vmcex;
};
IO_COUNTERS ioc;
ZwQueryInformationProcess(NtCurrentProcess(), ProcessVmCounters, &vmc, sizeof(vmc), &rcb);
ZwQueryInformationProcess(NtCurrentProcess(), ProcessVmCounters, &vmcex, sizeof(vmcex), &rcb);
ZwQueryInformationProcess(NtCurrentProcess(), ProcessIoCounters, &ioc, sizeof(ioc), &rcb);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM