From 1a79912a10a6cded54d1f1de5f746bbffec3ffee Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 21 Jul 2010 10:50:12 +0200 Subject: [PATCH] server: Try to use /proc/pid/mem to read process memory since it should be faster. --- server/ptrace.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/ptrace.c b/server/ptrace.c index 111804809d5..111368bf0d8 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -19,9 +19,11 @@ */ #include "config.h" +#include "wine/port.h" #include #include +#include #include #include #include @@ -377,6 +379,24 @@ int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t if (suspend_for_ptrace( thread )) { + if (len > 3) /* /proc/pid/mem should be faster for large sizes */ + { + char procmem[24]; + int fd; + + sprintf( procmem, "/proc/%u/mem", process->unix_pid ); + if ((fd = open( procmem, O_RDONLY )) != -1) + { + ssize_t ret = pread( fd, dest, size, ptr ); + close( fd ); + if (ret == size) + { + len = 0; + goto done; + } + } + } + if (len > 1) { if (read_thread_long( thread, addr++, &data ) == -1) goto done;