@@ -3947,6 +3947,20 @@ pub const PSAPI_WS_WATCH_INFORMATION = extern struct {
3947
3947
FaultingVa : LPVOID ,
3948
3948
};
3949
3949
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
+
3950
3964
pub const PROCESS_MEMORY_COUNTERS = extern struct {
3951
3965
cb : DWORD ,
3952
3966
PageFaultCount : DWORD ,
@@ -3974,6 +3988,37 @@ pub const PROCESS_MEMORY_COUNTERS_EX = extern struct {
3974
3988
PrivateUsage : SIZE_T ,
3975
3989
};
3976
3990
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
+
3977
4022
pub const PERFORMANCE_INFORMATION = extern struct {
3978
4023
cb : DWORD ,
3979
4024
CommitTotal : SIZE_T ,
0 commit comments