[PATCH 4/4] ntdll: Fill the VM counters in NtQuerySystemInformation(SystemProcessInformation).

Zebediah Figura z.figura12 at gmail.com
Tue Jul 7 18:58:36 CDT 2020


Process Hacker displays this information.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntdll/unix/process.c      | 2 +-
 dlls/ntdll/unix/system.c       | 1 +
 dlls/ntdll/unix/unix_private.h | 1 +
 server/process.c               | 1 +
 server/protocol.def            | 1 +
 server/trace.c                 | 3 ++-
 6 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index 8c0b97922d2..362292b66b3 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -1057,7 +1057,7 @@ static void fill_VM_COUNTERS( VM_COUNTERS_EX *pvmi )
 
 #endif
 
-static void vm_counters_from_server( VM_COUNTERS_EX *to, const vm_counters_t *from )
+void vm_counters_from_server( VM_COUNTERS_EX *to, const vm_counters_t *from )
 {
     to->PeakVirtualSize = from->peak_virtual_size;
     to->VirtualSize = from->virtual_size;
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index a80d3c4fd4a..cc150e5ddf9 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -2147,6 +2147,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
                 nt_process->ParentProcessId = UlongToHandle(server_process->parent_pid);
                 nt_process->HandleCount = server_process->handle_count;
                 get_thread_times( server_process->unix_pid, -1, &nt_process->KernelTime, &nt_process->UserTime );
+                vm_counters_from_server( &nt_process->vmCounters, &server_process->vm_counters );
             }
 
             pos = (pos + 7) & ~7;
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 82806463e53..1a555b33836 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -187,6 +187,7 @@ extern NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOO
 extern NTSTATUS get_thread_context( HANDLE handle, context_t *context, unsigned int flags, BOOL *self ) DECLSPEC_HIDDEN;
 extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
                                          data_size_t *ret_len ) DECLSPEC_HIDDEN;
+extern void vm_counters_from_server( VM_COUNTERS_EX *to, const vm_counters_t *from ) DECLSPEC_HIDDEN;
 
 extern void virtual_init(void) DECLSPEC_HIDDEN;
 extern NTSTATUS virtual_map_ntdll( int fd, void **module ) DECLSPEC_HIDDEN;
diff --git a/server/process.c b/server/process.c
index 7d3429d9635..17c9c3a1b17 100644
--- a/server/process.c
+++ b/server/process.c
@@ -1834,6 +1834,7 @@ DECL_HANDLER(list_processes)
 
         pos = (pos + 7) & ~7;
         process_info = (struct process_info *)(buffer + pos);
+        get_vm_counters( &process_info->vm_counters, process );
         process_info->start_time = process->start_time;
         process_info->name_len = exe ? exe->namelen : 0;
         process_info->thread_count = process->running_threads;
diff --git a/server/protocol.def b/server/protocol.def
index 9f5cd3bc79e..99397fb3a88 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1876,6 +1876,7 @@ struct thread_info
 
 struct process_info
 {
+    vm_counters_t   vm_counters;
     timeout_t       start_time;
     data_size_t     name_len;
     int             thread_count;
diff --git a/server/trace.c b/server/trace.c
index 8e73af239d2..28021b33903 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1125,7 +1125,8 @@ static void dump_varargs_process_info( const char *prefix, data_size_t size )
         process = (const struct process_info *)((const char *)cur_data + pos);
         if (size - pos < sizeof(*process)) break;
         if (pos) fputc( ',', stderr );
-        dump_timeout( "{start_time=", &process->start_time );
+        dump_vm_counters( "{counters=", &process->vm_counters );
+        dump_timeout( ",start_time=", &process->start_time );
         fprintf( stderr, ",thread_count=%u,priority=%d,pid=%04x,parent_pid=%04x,handle_count=%u,unix_pid=%d,",
                  process->thread_count, process->priority, process->pid,
                  process->parent_pid, process->handle_count, process->unix_pid );
-- 
2.27.0




More information about the wine-devel mailing list