Alexandre Julliard : server: Store a copy of the image file name in the process.
Alexandre Julliard
julliard at winehq.org
Thu Mar 11 15:59:35 CST 2021
Module: wine
Branch: master
Commit: 3c9b5379d1a57f69fa14f87f64f2079171becb6c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3c9b5379d1a57f69fa14f87f64f2079171becb6c
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Mar 11 21:51:37 2021 +0100
server: Store a copy of the image file name in the process.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/process.c | 2 --
server/mapping.c | 3 +++
server/process.c | 21 +++++++++------------
server/process.h | 2 ++
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 1c47f8a3b64..3e450c09849 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -4192,9 +4192,7 @@ static void test_dead_process(void)
memset( data, 0, sizeof(data) );
status = NtQueryInformationProcess( pi.hProcess, ProcessImageFileName, data, sizeof(data), NULL);
ok( !status, "ProcessImageFileName failed %x\n", status );
- todo_wine
ok( ((UNICODE_STRING *)data)->Length, "ProcessImageFileName not set\n" );
- todo_wine
ok( ((UNICODE_STRING *)data)->Buffer[0] == '\\', "ProcessImageFileName not set\n" );
memset( prio, 0xcc, sizeof(*prio) );
diff --git a/server/mapping.c b/server/mapping.c
index 17c7ca26b3a..ebf3e057c75 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -353,6 +353,7 @@ struct memory_view *get_exe_view( struct process *process )
static void add_process_view( struct thread *thread, struct memory_view *view )
{
struct process *process = thread->process;
+ struct unicode_str name;
if (view->flags & SEC_IMAGE)
{
@@ -362,6 +363,8 @@ static void add_process_view( struct thread *thread, struct memory_view *view )
{
/* main exe */
list_add_head( &process->views, &view->entry );
+ if (get_view_nt_name( view, &name ) && (process->image = memdup( name.str, name.len )))
+ process->imagelen = name.len;
return;
}
}
diff --git a/server/process.c b/server/process.c
index 0d550328312..90ea44515ec 100644
--- a/server/process.c
+++ b/server/process.c
@@ -536,6 +536,8 @@ struct process *create_process( int fd, struct process *parent, int inherit_all,
process->is_system = 0;
process->debug_children = 1;
process->is_terminating = 0;
+ process->imagelen = 0;
+ process->image = NULL;
process->job = NULL;
process->console = NULL;
process->startup_state = STARTUP_IN_PROGRESS;
@@ -649,6 +651,7 @@ static void process_destroy( struct object *obj )
if (process->id) free_ptid( process->id );
if (process->token) release_object( process->token );
free( process->dir_cache );
+ free( process->image );
}
/* dump a process on stdout for debugging purposes */
@@ -1381,13 +1384,12 @@ DECL_HANDLER(get_process_debug_info)
/* fetch the name of the process image */
DECL_HANDLER(get_process_image_name)
{
- struct unicode_str name;
- struct memory_view *view;
struct process *process = get_process_from_handle( req->handle, PROCESS_QUERY_LIMITED_INFORMATION );
if (!process) return;
- if ((view = get_exe_view( process )) && get_view_nt_name( view, &name ))
+ if (process->image)
{
+ struct unicode_str name = { process->image, process->imagelen };
/* skip the \??\ prefix */
if (req->win32 && name.len > 6 * sizeof(WCHAR) && name.str[5] == ':')
{
@@ -1724,7 +1726,6 @@ DECL_HANDLER(list_processes)
{
struct process *process;
struct thread *thread;
- struct unicode_str nt_name;
unsigned int pos = 0;
char *buffer;
@@ -1733,10 +1734,8 @@ DECL_HANDLER(list_processes)
LIST_FOR_EACH_ENTRY( process, &process_list, struct process, entry )
{
- struct memory_view *view = get_exe_view( process );
- if (!view || !get_view_nt_name( view, &nt_name )) nt_name.len = 0;
reply->info_size = (reply->info_size + 7) & ~7;
- reply->info_size += sizeof(struct process_info) + nt_name.len;
+ reply->info_size += sizeof(struct process_info) + process->imagelen;
reply->info_size = (reply->info_size + 7) & ~7;
reply->info_size += process->running_threads * sizeof(struct thread_info);
reply->process_count++;
@@ -1754,13 +1753,11 @@ DECL_HANDLER(list_processes)
LIST_FOR_EACH_ENTRY( process, &process_list, struct process, entry )
{
struct process_info *process_info;
- struct memory_view *view = get_exe_view( process );
pos = (pos + 7) & ~7;
- if (!view || !get_view_nt_name( view, &nt_name )) nt_name.len = 0;
process_info = (struct process_info *)(buffer + pos);
process_info->start_time = process->start_time;
- process_info->name_len = nt_name.len;
+ process_info->name_len = process->imagelen;
process_info->thread_count = process->running_threads;
process_info->priority = process->priority;
process_info->pid = process->id;
@@ -1768,8 +1765,8 @@ DECL_HANDLER(list_processes)
process_info->handle_count = get_handle_table_count(process);
process_info->unix_pid = process->unix_pid;
pos += sizeof(*process_info);
- memcpy( buffer + pos, nt_name.str, nt_name.len );
- pos += nt_name.len;
+ memcpy( buffer + pos, process->image, process->imagelen );
+ pos += process->imagelen;
pos = (pos + 7) & ~7;
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
{
diff --git a/server/process.h b/server/process.h
index c8be5640a54..0997a759330 100644
--- a/server/process.h
+++ b/server/process.h
@@ -64,6 +64,8 @@ struct process
unsigned int is_system:1; /* is it a system process? */
unsigned int debug_children:1;/* also debug all child processes */
unsigned int is_terminating:1;/* is process terminating? */
+ data_size_t imagelen; /* length of image path in bytes */
+ WCHAR *image; /* main exe image full path */
struct job *job; /* job object ascoicated with this process */
struct list job_entry; /* list entry for job object */
struct list asyncs; /* list of async object owned by the process */
More information about the wine-cvs
mailing list