Process Hacker displays this information.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/system.c | 1 + server/process.c | 1 + server/protocol.def | 2 ++ server/trace.c | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 29c133e6562..051bd37fa3d 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -2140,6 +2140,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class, memset(nt_process, 0, sizeof(*nt_process)); if (i < process_count - 1) nt_process->NextEntryOffset = proc_len; + nt_process->CreationTime.QuadPart = server_process->start_time; nt_process->dwThreadCount = server_process->thread_count; nt_process->dwBasePriority = server_process->priority; nt_process->UniqueProcessId = UlongToHandle(server_process->pid); diff --git a/server/process.c b/server/process.c index 9482da98be5..8d57879cc19 100644 --- a/server/process.c +++ b/server/process.c @@ -1829,6 +1829,7 @@ DECL_HANDLER(list_processes)
pos = (pos + 7) & ~7; process_info = (struct process_info *)(buffer + pos); + process_info->start_time = process->start_time; process_info->name_len = exe ? exe->namelen : 0; process_info->thread_count = process->running_threads; process_info->priority = process->priority; diff --git a/server/protocol.def b/server/protocol.def index bad8fef7903..bf91637e9de 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1870,6 +1870,7 @@ struct thread_info
struct process_info { + timeout_t start_time; data_size_t name_len; int thread_count; int priority; @@ -1877,6 +1878,7 @@ struct process_info process_id_t parent_pid; int handle_count; int unix_pid; + int __pad; /* VARARG(name,unicode_str,name_len); */ /* VARARG(threads,struct thread_info,thread_count); */ }; diff --git a/server/trace.c b/server/trace.c index dfb39300668..288dad718df 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1113,7 +1113,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 ); - fprintf( stderr, "{thread_count=%u,priority=%d,pid=%04x,parent_pid=%04x,handle_count=%u,unix_pid=%d,", + 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 ); pos += sizeof(*process);
Process Hacker displays this information.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/system.c | 2 +- server/process.c | 1 + server/protocol.def | 1 + server/trace.c | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 051bd37fa3d..a80d3c4fd4a 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -2156,7 +2156,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
if (len <= size) { - nt_process->ti[j].CreateTime.QuadPart = 0xdeadbeef; + nt_process->ti[j].CreateTime.QuadPart = server_thread->start_time; nt_process->ti[j].ClientId.UniqueProcess = UlongToHandle(server_process->pid); nt_process->ti[j].ClientId.UniqueThread = UlongToHandle(server_thread->tid); nt_process->ti[j].dwCurrentPriority = server_thread->current_priority; diff --git a/server/process.c b/server/process.c index 8d57879cc19..5e587b28cbe 100644 --- a/server/process.c +++ b/server/process.c @@ -1850,6 +1850,7 @@ DECL_HANDLER(list_processes) { struct thread_info *thread_info = (struct thread_info *)(buffer + pos);
+ thread_info->start_time = thread->creation_time; thread_info->tid = thread->id; thread_info->base_priority = thread->priority; thread_info->current_priority = thread->priority; /* FIXME */ diff --git a/server/protocol.def b/server/protocol.def index bf91637e9de..943c1ade1a4 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1862,6 +1862,7 @@ enum char_info_mode
struct thread_info { + timeout_t start_time; thread_id_t tid; int base_priority; int current_priority; diff --git a/server/trace.c b/server/trace.c index 288dad718df..55d7bd85dd6 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1128,7 +1128,8 @@ static void dump_varargs_process_info( const char *prefix, data_size_t size ) const struct thread_info *thread = (const struct thread_info *)((const char *)cur_data + pos); if (size - pos < sizeof(*thread)) break; if (i) fputc( ',', stderr ); - fprintf( stderr, "{tid=%04x,base_priority=%d,current_priority=%d,unix_tid=%d}", + dump_timeout( "{start_time=", &thread->start_time ); + fprintf( stderr, ",tid=%04x,base_priority=%d,current_priority=%d,unix_tid=%d}", thread->tid, thread->base_priority, thread->current_priority, thread->unix_tid ); pos += sizeof(*thread); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/unix/process.c | 19 ++++++----- server/process.c | 69 +++++++++++++++++++++------------------ server/protocol.def | 13 +++++--- server/trace.c | 12 +++++++ tools/make_requests | 1 + 5 files changed, 70 insertions(+), 44 deletions(-)
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 7061d8864db..8c0b97922d2 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -1057,6 +1057,16 @@ 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 ) +{ + to->PeakVirtualSize = from->peak_virtual_size; + to->VirtualSize = from->virtual_size; + to->PeakWorkingSetSize = from->peak_working_set_size; + to->WorkingSetSize = from->working_set_size; + to->PagefileUsage = from->pagefile_usage; + to->PeakPagefileUsage = from->peak_pagefile_usage; +} + #define UNIMPLEMENTED_INFO_CLASS(c) \ case c: \ FIXME( "(process=%p) Unimplemented information class: " #c "\n", handle); \ @@ -1178,14 +1188,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class { req->handle = wine_server_obj_handle( handle ); if (!(ret = wine_server_call( req ))) - { - pvmi.PeakVirtualSize = reply->peak_virtual_size; - pvmi.VirtualSize = reply->virtual_size; - pvmi.PeakWorkingSetSize = reply->peak_working_set_size; - pvmi.WorkingSetSize = reply->working_set_size; - pvmi.PagefileUsage = reply->pagefile_usage; - pvmi.PeakPagefileUsage = reply->peak_pagefile_usage; - } + vm_counters_from_server( &pvmi, &reply->counters ); } SERVER_END_REQ; if (ret) break; diff --git a/server/process.c b/server/process.c index 5e587b28cbe..7d3429d9635 100644 --- a/server/process.c +++ b/server/process.c @@ -1086,6 +1086,42 @@ int set_process_debug_flag( struct process *process, int flag ) return write_process_memory( process, process->peb + 2, 1, &data ); }
+void get_vm_counters( vm_counters_t *counters, struct process *process ) +{ +#ifdef linux + if (process->unix_pid != -1) + { + FILE *f; + char proc_path[32], line[256]; + unsigned long value; + + sprintf( proc_path, "/proc/%u/status", process->unix_pid ); + if ((f = fopen( proc_path, "r" ))) + { + while (fgets( line, sizeof(line), f )) + { + if (sscanf( line, "VmPeak: %lu", &value )) + counters->peak_virtual_size = (mem_size_t)value * 1024; + else if (sscanf( line, "VmSize: %lu", &value )) + counters->virtual_size = (mem_size_t)value * 1024; + else if (sscanf( line, "VmHWM: %lu", &value )) + counters->peak_working_set_size = (mem_size_t)value * 1024; + else if (sscanf( line, "VmRSS: %lu", &value )) + counters->working_set_size = (mem_size_t)value * 1024; + else if (sscanf( line, "RssAnon: %lu", &value )) + counters->pagefile_usage += (mem_size_t)value * 1024; + else if (sscanf( line, "VmSwap: %lu", &value )) + counters->pagefile_usage += (mem_size_t)value * 1024; + } + counters->peak_pagefile_usage = counters->pagefile_usage; + fclose( f ); + } + else set_error( STATUS_ACCESS_DENIED ); + } + else set_error( STATUS_ACCESS_DENIED ); +#endif +} + /* create a new process */ DECL_HANDLER(new_process) { @@ -1430,38 +1466,7 @@ DECL_HANDLER(get_process_vm_counters) struct process *process = get_process_from_handle( req->handle, PROCESS_QUERY_LIMITED_INFORMATION );
if (!process) return; -#ifdef linux - if (process->unix_pid != -1) - { - FILE *f; - char proc_path[32], line[256]; - unsigned long value; - - sprintf( proc_path, "/proc/%u/status", process->unix_pid ); - if ((f = fopen( proc_path, "r" ))) - { - while (fgets( line, sizeof(line), f )) - { - if (sscanf( line, "VmPeak: %lu", &value )) - reply->peak_virtual_size = (mem_size_t)value * 1024; - else if (sscanf( line, "VmSize: %lu", &value )) - reply->virtual_size = (mem_size_t)value * 1024; - else if (sscanf( line, "VmHWM: %lu", &value )) - reply->peak_working_set_size = (mem_size_t)value * 1024; - else if (sscanf( line, "VmRSS: %lu", &value )) - reply->working_set_size = (mem_size_t)value * 1024; - else if (sscanf( line, "RssAnon: %lu", &value )) - reply->pagefile_usage += (mem_size_t)value * 1024; - else if (sscanf( line, "VmSwap: %lu", &value )) - reply->pagefile_usage += (mem_size_t)value * 1024; - } - reply->peak_pagefile_usage = reply->pagefile_usage; - fclose( f ); - } - else set_error( STATUS_ACCESS_DENIED ); - } - else set_error( STATUS_ACCESS_DENIED ); -#endif + get_vm_counters( &reply->counters, process ); release_object( process ); }
diff --git a/server/protocol.def b/server/protocol.def index 943c1ade1a4..9f5cd3bc79e 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -918,16 +918,21 @@ struct rawinput_device @END
-/* Retrieve information about a process memory usage */ -@REQ(get_process_vm_counters) - obj_handle_t handle; /* process handle */ -@REPLY +typedef struct +{ mem_size_t peak_virtual_size; /* peak virtual memory in bytes */ mem_size_t virtual_size; /* virtual memory in bytes */ mem_size_t peak_working_set_size; /* peak real memory in bytes */ mem_size_t working_set_size; /* real memory in bytes */ mem_size_t pagefile_usage; /* commit charge in bytes */ mem_size_t peak_pagefile_usage; /* peak commit charge in bytes */ +} vm_counters_t; + +/* Retrieve information about a process memory usage */ +@REQ(get_process_vm_counters) + obj_handle_t handle; /* process handle */ +@REPLY + vm_counters_t counters; @END
diff --git a/server/trace.c b/server/trace.c index 55d7bd85dd6..8e73af239d2 100644 --- a/server/trace.c +++ b/server/trace.c @@ -410,6 +410,18 @@ static void dump_hw_input( const char *prefix, const hw_input_t *input ) } }
+static void dump_vm_counters( const char *prefix, const vm_counters_t *counters ) +{ + fprintf( stderr, "%s{", prefix ); + dump_uint64( "peak_virtual_size=", &counters->peak_virtual_size ); + dump_uint64( ", virtual_size=", &counters->virtual_size ); + dump_uint64( ", peak_working_set_size=", &counters->peak_working_set_size ); + dump_uint64( ", working_set_size=", &counters->working_set_size ); + dump_uint64( ", pagefile_usage=", &counters->pagefile_usage ); + dump_uint64( ", peak_pagefile_usage=", &counters->peak_pagefile_usage ); + fputc( '}', stderr ); +} + static void dump_luid( const char *prefix, const luid_t *luid ) { fprintf( stderr, "%s%d.%u", prefix, luid->high_part, luid->low_part ); diff --git a/tools/make_requests b/tools/make_requests index 60324d07989..354e70866c0 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -54,6 +54,7 @@ my %formats = "ioctl_code_t" => [ 4, 4, "&dump_ioctl_code" ], "client_cpu_t" => [ 4, 4, "&dump_client_cpu" ], "hw_input_t" => [ 32, 8, "&dump_hw_input" ], + "vm_counters_t" => [ 48, 8, "&dump_vm_counters" ], );
my @requests = ();
Zebediah Figura z.figura12@gmail.com writes:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/ntdll/unix/process.c | 19 ++++++----- server/process.c | 69 +++++++++++++++++++++------------------ server/protocol.def | 13 +++++--- server/trace.c | 12 +++++++ tools/make_requests | 1 + 5 files changed, 70 insertions(+), 44 deletions(-)
It may be better to move this to the client side, following the example of the thread times.
Process Hacker displays this information.
Signed-off-by: Zebediah Figura z.figura12@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 );