Enhancing toolhelp snaphost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this patch enhances the process snapshots
now the parentID and process pathname are now filled in

A+
Name: thlp_pcs
ChangeLog: added the parent process ID and the path in the process snapshot
GenDate: 2002/02/23 21:34:08 UTC
ModifiedFiles: dlls/kernel/toolhelp.c server/protocol.def server/process.h server/process.c server/snapshot.c
AddedFiles: 
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/toolhelp.c,v
retrieving revision 1.14
diff -u -u -r1.14 toolhelp.c
--- dlls/kernel/toolhelp.c	30 Nov 2001 18:46:43 -0000	1.14
+++ dlls/kernel/toolhelp.c	16 Feb 2002 22:05:17 -0000
@@ -287,6 +287,7 @@
     {
         req->handle = handle;
         req->reset = first;
+        wine_server_set_reply( req, lppe->szExeFile, sizeof(lppe->szExeFile));
         if ((ret = !wine_server_call_err( req )))
         {
             lppe->cntUsage            = reply->count;
@@ -294,10 +295,10 @@
             lppe->th32DefaultHeapID   = 0;  /* FIXME */
             lppe->th32ModuleID        = 0;  /* FIXME */
             lppe->cntThreads          = reply->threads;
-            lppe->th32ParentProcessID = 0;  /* FIXME */
+            lppe->th32ParentProcessID = (DWORD)reply->ppid;
             lppe->pcPriClassBase      = reply->priority;
             lppe->dwFlags             = -1; /* FIXME */
-            lppe->szExeFile[0]        = 0;  /* FIXME */
+            lppe->szExeFile[wine_server_reply_size(reply)] = 0;
         }
     }
     SERVER_END_REQ;
Index: server/protocol.def
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/protocol.def,v
retrieving revision 1.24
diff -u -u -r1.24 protocol.def
--- server/protocol.def	9 Jan 2002 21:16:24 -0000	1.24
+++ server/protocol.def	21 Feb 2002 20:54:46 -0000
19       count;         /* process usage count */
     void*        pid;           /* process id */
+    void*        ppid;          /* process parent id */
     int          threads;       /* number of threads */
     int          priority;      /* process priority */
+    VARARG(name,string);        /* process (path)name */
 @END
 
 
Index: server/process.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/process.h,v
retrieving revision 1.24
diff -u -u -r1.24 process.h
--- server/process.h	4 Dec 2001 20:17:44 -0000	1.24
+++ server/process.h	21 Feb 2002 20:46:16 -0000
15_snapshot
 {
     struct process *process;  /* process ptr */
+    struct process *parent;   /* parent process */
     int             count;    /* process refcount */
     int             threads;  /* number of threads */
     int             priority; /* priority class */
+    char            name[MAX_PATH];/* process name */
 };
 
 struct module_snapshot
Index: server/process.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/process.c,v
retrieving revision 1.76
diff -u -u -r1.76 process.c
--- server/process.c	20 Dec 2001 00:07:09 -0000	1.76
+++ server/process.c	23 Feb 2002 21:24:53 -0000
@@ -693,12 +707,24 @@
     ptr = snapshot;
     for (process = first_process; process; process = process->next)
     {
+        int     adr;
+
         if (!process->running_threads) continue;
         ptr->process  = process;
         ptr->threads  = process->running_threads;
         ptr->count    = process->obj.refcount;
         ptr->priority = process->priority;
+        ptr->parent   = process->parent;
+        if (!process->exe.name ||
+            read_process_memory( process, process->exe.name, 1, &adr) != 1 ||
+            adr == 0 ||
+            read_process_memory( process, (void*)adr, 
+                                 sizeof(ptr->name) / sizeof(int), 
+                                 (int*)ptr->name) == 0)
+            ptr->name[0] = 0;
+
         grab_object( process );
+        if (process->parent) grab_object( process->parent );
         ptr++;
     }
     *count = running_processes;
Index: server/snapshot.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/snapshot.c,v
retrieving revision 1.12
diff -u -u -r1.12 snapshot.c
--- server/snapshot.c	20 Dec 2001 00:07:09 -0000	1.12
+++ server/snapshot.c	16 Feb 2002 22:08:05 -0000
@@ -112,8 +112,10 @@
     ptr = &snapshot->processes[snapshot->process_pos++];
     reply->count    = ptr->count;
     reply->pid      = get_process_id( ptr->process );
+    reply->ppid     = get_process_id( ptr->parent );
     reply->threads  = ptr->threads;
     reply->priority = ptr->priority;
+    set_reply_data( ptr->name, strlen(ptr->name) );
     return 1;
 }
 
@@ -178,7 +180,11 @@
     if (snapshot->process_count)
     {
         for (i = 0; i < snapshot->process_count; i++)
+        {
             release_object( snapshot->processes[i].process );
+            if (snapshot->processes[i].parent)
+                release_object( snapshot->processes[i].parent );
+        }
         free( snapshot->processes );
     }
     if (snapshot->thread_count)

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux