Alexandre Julliard : server: Store the process exe module in the standard dll list.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Feb 16 05:34:17 CST 2006


Module: wine
Branch: refs/heads/master
Commit: e6374cbea784e7e3ad6b5dbe5b6e04159cb74f2c
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=e6374cbea784e7e3ad6b5dbe5b6e04159cb74f2c

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Feb 16 12:13:01 2006 +0100

server: Store the process exe module in the standard dll list.

---

 server/debugger.c |   13 +++++++------
 server/process.c  |   49 +++++++++++++++----------------------------------
 server/process.h  |    7 ++++++-
 server/snapshot.c |    7 ++++---
 4 files changed, 32 insertions(+), 44 deletions(-)

diff --git a/server/debugger.c b/server/debugger.c
index e326516..c32b9b1 100644
--- a/server/debugger.c
+++ b/server/debugger.c
@@ -130,6 +130,7 @@ static int fill_create_process_event( st
     struct process *debugger = event->debugger->process;
     struct thread *thread = event->sender;
     struct process *process = thread->process;
+    struct process_dll *exe_module = get_process_exe_module( process );
     obj_handle_t handle;
 
     /* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */
@@ -145,9 +146,9 @@ static int fill_create_process_event( st
     event->data.info.create_process.thread = handle;
 
     handle = 0;
-    if (process->exe.file &&
+    if (exe_module->file &&
         /* the doc says write access too, but this doesn't seem a good idea */
-        !(handle = alloc_handle( debugger, process->exe.file, GENERIC_READ, 0 )))
+        !(handle = alloc_handle( debugger, exe_module->file, GENERIC_READ, 0 )))
     {
         close_handle( debugger, event->data.info.create_process.process, NULL );
         close_handle( debugger, event->data.info.create_process.thread, NULL );
@@ -155,11 +156,11 @@ static int fill_create_process_event( st
     }
     event->data.info.create_process.file       = handle;
     event->data.info.create_process.teb        = thread->teb;
-    event->data.info.create_process.base       = process->exe.base;
+    event->data.info.create_process.base       = exe_module->base;
     event->data.info.create_process.start      = arg;
-    event->data.info.create_process.dbg_offset = process->exe.dbg_offset;
-    event->data.info.create_process.dbg_size   = process->exe.dbg_size;
-    event->data.info.create_process.name       = process->exe.name;
+    event->data.info.create_process.dbg_offset = exe_module->dbg_offset;
+    event->data.info.create_process.dbg_size   = exe_module->dbg_size;
+    event->data.info.create_process.name       = exe_module->name;
     event->data.info.create_process.unicode    = 1;
     return 1;
 }
diff --git a/server/process.c b/server/process.c
index e738bb2..a593ad2 100644
--- a/server/process.c
+++ b/server/process.c
@@ -252,11 +252,6 @@ struct thread *create_process( int fd )
     process->ldt_copy        = NULL;
     process->winstation      = 0;
     process->desktop         = 0;
-    process->exe.file        = NULL;
-    process->exe.dbg_offset  = 0;
-    process->exe.dbg_size    = 0;
-    process->exe.namelen     = 0;
-    process->exe.filename    = NULL;
     process->token           = token_create_admin();
     list_init( &process->thread_list );
     list_init( &process->locks );
@@ -392,8 +387,6 @@ static void process_destroy( struct obje
     list_remove( &process->entry );
     if (process->idle_event) release_object( process->idle_event );
     if (process->queue) release_object( process->queue );
-    if (process->exe.file) release_object( process->exe.file );
-    if (process->exe.filename) free( process->exe.filename );
     if (process->id) free_ptid( process->id );
     if (process->token) release_object( process->token );
 }
@@ -480,8 +473,6 @@ static inline struct process_dll *find_p
 {
     struct process_dll *dll;
 
-    if (process->exe.base == base) return &process->exe;
-
     LIST_FOR_EACH_ENTRY( dll, &process->dlls, struct process_dll, entry )
     {
         if (dll->base == base) return dll;
@@ -514,7 +505,7 @@ static struct process_dll *process_load_
             return NULL;
         }
         if (file) dll->file = (struct file *)grab_object( file );
-        list_add_head( &process->dlls, &dll->entry );
+        list_add_tail( &process->dlls, &dll->entry );
     }
     return dll;
 }
@@ -524,7 +515,7 @@ static void process_unload_dll( struct p
 {
     struct process_dll *dll = find_process_dll( process, base );
 
-    if (dll && dll != &process->exe)
+    if (dll && (&dll->entry != list_head( &process->dlls )))  /* main exe can't be unloaded */
     {
         if (dll->file) release_object( dll->file );
         if (dll->filename) free( dll->filename );
@@ -597,8 +588,6 @@ static void process_killed( struct proce
     destroy_process_classes( process );
     remove_process_locks( process );
     set_process_startup_state( process, STARTUP_ABORTED );
-    if (process->exe.file) release_object( process->exe.file );
-    process->exe.file = NULL;
     wake_up( &process->obj, 0 );
     if (!--running_processes) close_master_socket();
 }
@@ -850,18 +839,12 @@ struct module_snapshot *module_snap( str
 {
     struct module_snapshot *snapshot, *ptr;
     struct process_dll *dll;
-    int total = 1;
+    int total = 0;
 
     LIST_FOR_EACH_ENTRY( dll, &process->dlls, struct process_dll, entry ) total++;
     if (!(snapshot = mem_alloc( sizeof(*snapshot) * total ))) return NULL;
 
-    /* first entry is main exe */
-    snapshot->base     = process->exe.base;
-    snapshot->size     = process->exe.size;
-    snapshot->namelen  = process->exe.namelen;
-    snapshot->filename = memdup( process->exe.filename, process->exe.namelen );
-    ptr = snapshot + 1;
-
+    ptr = snapshot;
     LIST_FOR_EACH_ENTRY( dll, &process->dlls, struct process_dll, entry )
     {
         ptr->base     = dll->base;
@@ -992,22 +975,20 @@ DECL_HANDLER(init_process_done)
     }
 
     /* check if main exe has been registered as a dll already */
-    if ((dll = find_process_dll( process, req->module )))
-    {
-        list_remove( &dll->entry );
-        memcpy( &process->exe, dll, sizeof(*dll) );
-        list_init( &process->exe.entry );
-        free( dll );
-    }
-    else
+    if (!(dll = find_process_dll( process, req->module )))
     {
-        process->exe.base = req->module;
-        process->exe.size = req->module_size;
-        process->exe.name = req->name;
-        if ((process->exe.namelen = get_req_data_size()))
-            process->exe.filename = memdup( get_req_data(), process->exe.namelen );
+        if (!(dll = process_load_dll( process, NULL, req->module,
+                                      get_req_data(), get_req_data_size() ))) return;
+        dll->size       = req->module_size;
+        dll->dbg_offset = 0;
+        dll->dbg_size   = 0;
+        dll->name       = req->name;
     }
 
+    /* main exe is the first in the dll list */
+    list_remove( &dll->entry );
+    list_add_head( &process->dlls, &dll->entry );
+
     generate_startup_debug_events( process, req->entry );
     set_process_startup_state( process, STARTUP_DONE );
 
diff --git a/server/process.h b/server/process.h
index 02c3602..57dc7fb 100644
--- a/server/process.h
+++ b/server/process.h
@@ -75,7 +75,6 @@ struct process
     obj_handle_t         winstation;      /* main handle to process window station */
     obj_handle_t         desktop;         /* handle to desktop to use for new threads */
     struct token        *token;           /* security token associated with this process */
-    struct process_dll   exe;             /* main exe file */
     struct list          dlls;            /* list of loaded dlls */
     void                *peb;             /* PEB address in client address space */
     void                *ldt_copy;        /* pointer to LDT copy in client addr space */
@@ -134,4 +133,10 @@ inline static int is_process_init_done( 
     return process->startup_state == STARTUP_DONE;
 }
 
+inline static struct process_dll *get_process_exe_module( struct process *process )
+{
+    struct list *ptr = list_head( &process->dlls );
+    return ptr ? LIST_ENTRY( ptr, struct process_dll, entry ) : NULL;
+}
+
 #endif  /* __WINE_SERVER_PROCESS_H */
diff --git a/server/snapshot.c b/server/snapshot.c
index ccbbe72..55dcc79 100644
--- a/server/snapshot.c
+++ b/server/snapshot.c
@@ -117,6 +117,7 @@ static struct snapshot *create_snapshot(
 static int snapshot_next_process( struct snapshot *snapshot, struct next_process_reply *reply )
 {
     struct process_snapshot *ptr;
+    struct process_dll *exe_module;
 
     if (!snapshot->process_count)
     {
@@ -137,10 +138,10 @@ static int snapshot_next_process( struct
     reply->threads  = ptr->threads;
     reply->priority = ptr->priority;
     reply->handles  = ptr->handles;
-    if (ptr->process->exe.filename)
+    if ((exe_module = get_process_exe_module( ptr->process )) && exe_module->filename)
     {
-        size_t len = min( ptr->process->exe.namelen, get_reply_max_size() );
-        set_reply_data( ptr->process->exe.filename, len );
+        size_t len = min( exe_module->namelen, get_reply_max_size() );
+        set_reply_data( exe_module->filename, len );
     }
     return 1;
 }




More information about the wine-cvs mailing list