psapi 1/3: preparation
Eric Pouech
eric.pouech at wanadoo.fr
Sat Jan 4 15:33:07 CST 2003
in order for the upcoming patch (on psapi) to be easily written, this
patch does two things:
- it removes dependencies for the snapshot server requests on the
toolhelp API
- it implements a get_dll_info request
A+
--
Eric Pouech
-------------- next part --------------
Name: thlp
ChangeLog:
- no longer depend on toolhelp definitions for generating snapshots in server
- added get_dll_info request to wineserver
License: LGPL
GenDate: 2003/01/04 21:25:09 UTC
ModifiedFiles: server/protocol.def dlls/kernel/toolhelp.c server/process.c server/snapshot.c
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/protocol.def,v
retrieving revision 1.53
diff -u -u -r1.53 protocol.def
--- server/protocol.def 25 Nov 2002 02:47:32 -0000 1.53
+++ server/protocol.def 3 Jan 2003 19:43:05 -0000
@@ -359,6 +359,17 @@
#define SET_THREAD_INFO_AFFINITY 0x02
+/* Retrieve information about a module */
+ at REQ(get_dll_info)
+ obj_handle_t handle; /* process handle */
+ void* base_address; /* base address of module */
+ at REPLY
+ size_t size; /* module size */
+ void* entry_point;
+ VARARG(filename,string); /* file name of module */
+ at END
+
+
/* Suspend a thread */
@REQ(suspend_thread)
obj_handle_t handle; /* thread handle */
@@ -1100,10 +1126,14 @@
@END
+#define SNAP_HEAPLIST 0x00000001
+#define SNAP_PROCESS 0x00000002
+#define SNAP_THREAD 0x00000004
+#define SNAP_MODULE 0x00000008
/* Create a snapshot */
@REQ(create_snapshot)
int inherit; /* inherit flag */
- int flags; /* snapshot flags (TH32CS_*) */
+ int flags; /* snapshot flags (SNAP_*) */
process_id_t pid; /* process id */
@REPLY
obj_handle_t handle; /* handle to the snapshot */
Index: server/process.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/process.c,v
retrieving revision 1.91
diff -u -u -r1.91 process.c
--- server/process.c 19 Oct 2002 01:00:59 -0000 1.91
+++ server/process.c 3 Jan 2003 20:23:16 -0000
@@ -1058,6 +1058,35 @@
process_unload_dll( current->process, req->base );
}
+/* retrieve information about a module in a process */
+DECL_HANDLER(get_dll_info)
+{
+ struct process *process;
+
+ if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
+ {
+ struct process_dll *dll;
+
+ for (dll = &process->exe; dll; dll = dll->next)
+ {
+ if (dll->base == req->base_address)
+ {
+ reply->size = dll->size;
+ reply->entry_point = 0; /* FIXME */
+ if (dll->filename)
+ {
+ size_t len = min( dll->namelen, get_reply_max_size() );
+ set_reply_data( dll->filename, len );
+ }
+ break;
+ }
+ }
+ if (!dll)
+ set_error(STATUS_DLL_NOT_FOUND);
+ release_object( process );
+ }
+}
+
/* wait for a process to start waiting on input */
/* FIXME: only returns event for now, wait is done in the client */
DECL_HANDLER(wait_input_idle)
Index: server/snapshot.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/snapshot.c,v
retrieving revision 1.16
diff -u -u -r1.16 snapshot.c
--- server/snapshot.c 3 Oct 2002 19:54:58 -0000 1.16
+++ server/snapshot.c 3 Jan 2003 20:24:25 -0000
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include "windef.h"
-#include "tlhelp32.h"
#include "handle.h"
#include "process.h"
@@ -79,7 +78,7 @@
struct snapshot *snapshot;
/* need a process for modules and heaps */
- if (flags & (TH32CS_SNAPMODULE|TH32CS_SNAPHEAPLIST))
+ if (flags & (SNAP_MODULE|SNAP_HEAPLIST))
{
if (!pid) process = (struct process *)grab_object( current->process );
else if (!(process = get_process_from_id( pid ))) return NULL;
@@ -95,17 +94,17 @@
snapshot->process_pos = 0;
snapshot->process_count = 0;
- if (flags & TH32CS_SNAPPROCESS)
+ if (flags & SNAP_PROCESS)
snapshot->processes = process_snap( &snapshot->process_count );
snapshot->thread_pos = 0;
snapshot->thread_count = 0;
- if (flags & TH32CS_SNAPTHREAD)
+ if (flags & SNAP_THREAD)
snapshot->threads = thread_snap( &snapshot->thread_count );
snapshot->module_pos = 0;
snapshot->module_count = 0;
- if (flags & TH32CS_SNAPMODULE)
+ if (flags & SNAP_MODULE)
snapshot->modules = module_snap( process, &snapshot->module_count );
return snapshot;
Index: dlls/kernel/toolhelp.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/toolhelp.c,v
retrieving revision 1.19
diff -u -u -r1.19 toolhelp.c
--- dlls/kernel/toolhelp.c 3 Oct 2002 19:54:57 -0000 1.19
+++ dlls/kernel/toolhelp.c 3 Jan 2003 20:25:13 -0000
@@ -221,7 +221,11 @@
/* Now do the snapshot */
SERVER_START_REQ( create_snapshot )
{
- req->flags = flags & ~TH32CS_INHERIT;
+ req->flags = 0;
+ if (flags & TH32CS_SNAPMODULE) req->flags |= SNAP_MODULE;
+ if (flags & TH32CS_SNAPPROCESS) req->flags |= SNAP_PROCESS;
+ if (flags & TH32CS_SNAPTHREAD) req->flags |= SNAP_THREAD;
+
req->inherit = (flags & TH32CS_INHERIT) != 0;
req->pid = process;
wine_server_call_err( req );
More information about the wine-patches
mailing list