patch for kernel32:toolhelp

eric pouech eric.pouech at wanadoo.fr
Sun Sep 30 11:30:53 CDT 2001


with this patch, the process snapshots from toolhelp has the field 
for parent process filled.

however, I'm not sure Alexandre will like it (let's see)
(drawbacks are:
- loose coupling between process and it's parent
- nothing is done when parent dies to update children fields...
)

-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: ws_ppid
ChangeLog: toolhelp process' snapshot now generates parent id
GenDate: 2001/09/30 16:26:15 UTC
ModifiedFiles: server/protocol.def server/process.c server/process.h server/snapshot.c dlls/kernel/toolhelp.c
AddedFiles: 
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/protocol.def,v
retrieving revision 1.7
diff -u -u -r1.7 protocol.def
--- server/protocol.def	2001/09/24 01:19:59	1.7
+++ server/protocol.def	2001/09/30 14:20:48
@@ -831,6 +929,7 @@
 @REPLY
     int          count;         /* process usage count */
     void*        pid;           /* process id */
+    void*        parent_pid;    /* parent's process id */
     int          threads;       /* number of threads */
     int          priority;      /* process priority */
 @END
Index: server/process.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/process.c,v
retrieving revision 1.70
diff -u -u -r1.70 process.c
--- server/process.c	2001/07/14 00:50:30	1.70
+++ server/process.c	2001/09/30 14:49:24
@@ -173,6 +184,8 @@
     process->exe.file        = NULL;
     process->exe.dbg_offset  = 0;
     process->exe.dbg_size    = 0;
+    process->parent_pid      = 0;
+
     gettimeofday( &process->start_time, NULL );
     if ((process->next = first_process) != NULL) process->next->prev = process;
     first_process = process;
@@ -222,6 +235,7 @@
             fatal_protocol_error( current, "init_process: called twice?\n" );
             return;
         }
+	process->parent_pid = get_process_id( parent );
     }
 
     /* set the process flags */
     process->create_flags = info ? info->create_flags : CREATE_NEW_CONSOLE;
Index: server/process.h
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/process.h,v
retrieving revision 1.22
diff -u -u -r1.22 process.h
--- server/process.h	2001/07/19 00:35:37	1.22
+++ server/process.h	2001/09/30 14:36:43
@@ -50,12 +49,12 @@
     struct process_dll   exe;             /* main exe file */
     void                *ldt_copy;        /* pointer to LDT copy in client addr space */
     void                *ldt_flags;       /* pointer to LDT flags in client addr space */
+    void                *parent_pid;      /* parent process' pid */
 };
 
 struct process_snapshot
 {
     struct process *process;  /* process ptr */
-    struct process *parent;   /* process parent */
     int             count;    /* process refcount */
     int             threads;  /* number of threads */
     int             priority; /* priority class */
Index: server/snapshot.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/snapshot.c,v
retrieving revision 1.10
diff -u -u -r1.10 snapshot.c
--- server/snapshot.c	2001/01/05 04:08:08	1.10
+++ server/snapshot.c	2001/09/30 14:49:09
@@ -110,10 +110,12 @@
         return 0;
     }
     ptr = &snapshot->processes[snapshot->process_pos++];
-    req->count    = ptr->count;
-    req->pid      = get_process_id( ptr->process );
-    req->threads  = ptr->threads;
-    req->priority = ptr->priority;
+    req->count      = ptr->count;
+    req->pid        = get_process_id( ptr->process );
+    req->parent_pid = ptr->process->parent_pid;
+    req->threads    = ptr->threads;
+    req->priority   = ptr->priority;
+ 
     return 1;
 }
 
Index: dlls/kernel/toolhelp.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/dlls/kernel/toolhelp.c,v
retrieving revision 1.12
diff -u -u -r1.12 toolhelp.c
--- dlls/kernel/toolhelp.c	2001/07/25 00:43:30	1.12
+++ dlls/kernel/toolhelp.c	2001/09/30 14:29:41
@@ -294,7 +294,7 @@
             lppe->th32DefaultHeapID   = 0;  /* FIXME */
             lppe->th32ModuleID        = 0;  /* FIXME */
             lppe->cntThreads          = req->threads;
-            lppe->th32ParentProcessID = 0;  /* FIXME */
+            lppe->th32ParentProcessID = req->parent_pid;
             lppe->pcPriClassBase      = req->priority;
             lppe->dwFlags             = -1; /* FIXME */
             lppe->szExeFile[0]        = 0;  /* FIXME */


More information about the wine-patches mailing list