@@ -3947,6 +3947,20 @@ pub const PSAPI_WS_WATCH_INFORMATION = extern struct {
39473947 FaultingVa : LPVOID ,
39483948};
39493949
3950+ pub const VM_COUNTERS = extern struct {
3951+ PeakVirtualSize : SIZE_T ,
3952+ VirtualSize : SIZE_T ,
3953+ PageFaultCount : ULONG ,
3954+ PeakWorkingSetSize : SIZE_T ,
3955+ WorkingSetSize : SIZE_T ,
3956+ QuotaPeakPagedPoolUsage : SIZE_T ,
3957+ QuotaPagedPoolUsage : SIZE_T ,
3958+ QuotaPeakNonPagedPoolUsage : SIZE_T ,
3959+ QuotaNonPagedPoolUsage : SIZE_T ,
3960+ PagefileUsage : SIZE_T ,
3961+ PeakPagefileUsage : SIZE_T ,
3962+ };
3963+
39503964pub const PROCESS_MEMORY_COUNTERS = extern struct {
39513965 cb : DWORD ,
39523966 PageFaultCount : DWORD ,
@@ -3974,6 +3988,37 @@ pub const PROCESS_MEMORY_COUNTERS_EX = extern struct {
39743988 PrivateUsage : SIZE_T ,
39753989};
39763990
3991+ pub const GetProcessMemoryInfoError = error {
3992+ AccessDenied ,
3993+ InvalidHandle ,
3994+ Unexpected ,
3995+ };
3996+
3997+ pub fn GetProcessMemoryInfo (hProcess : HANDLE , out : * PROCESS_MEMORY_COUNTERS ) GetProcessMemoryInfoError ! void {
3998+ var vmc : VM_COUNTERS = undefined ;
3999+ const rc = ntdll .NtQueryInformationProcess (hProcess , .ProcessVmCounters , & vmc , @sizeOf (VM_COUNTERS ), null );
4000+ switch (rc ) {
4001+ .SUCCESS = > {
4002+ out .* = PROCESS_MEMORY_COUNTERS {
4003+ .cb = @sizeOf (PROCESS_MEMORY_COUNTERS ),
4004+ .PageFaultCount = vmc .PageFaultCount ,
4005+ .PeakWorkingSetSize = vmc .PeakWorkingSetSize ,
4006+ .WorkingSetSize = vmc .WorkingSetSize ,
4007+ .QuotaPeakPagedPoolUsage = vmc .QuotaPeakPagedPoolUsage ,
4008+ .QuotaPagedPoolUsage = vmc .QuotaPagedPoolUsage ,
4009+ .QuotaPeakNonPagedPoolUsage = vmc .QuotaPeakNonPagedPoolUsage ,
4010+ .QuotaNonPagedPoolUsage = vmc .QuotaNonPagedPoolUsage ,
4011+ .PagefileUsage = vmc .PagefileUsage ,
4012+ .PeakPagefileUsage = vmc .PeakPagefileUsage ,
4013+ };
4014+ },
4015+ .ACCESS_DENIED = > return error .AccessDenied ,
4016+ .INVALID_HANDLE = > return error .InvalidHandle ,
4017+ .INVALID_PARAMETER = > unreachable ,
4018+ else = > return unexpectedStatus (rc ),
4019+ }
4020+ }
4021+
39774022pub const PERFORMANCE_INFORMATION = extern struct {
39784023 cb : DWORD ,
39794024 CommitTotal : SIZE_T ,
0 commit comments