Eric Pouech <[EMAIL PROTECTED]> writes:

> WriteProcessMemory(GetCurrentProcess()) is very close to a memcpy... (ok, without 
>the exception handling part...)
> the server, while processing a WriteProcessMemory(pid, ...) on process pid, that :
> - either the caller is a debugger debugging pid, or pid is not currently debugged 
>and the caller
> will (temporaly) act as a debugger
> - in both cases pid and caller shall be two distinct process

Doing a WriteProcessMemory on itself should work just fine; it can be
used for instance to write to read-only pages. The problem is that the
code path is a bit different when the process is not being debugged,
and I didn't test this case... Andreas could you try the following
patch?

Index: server/ptrace.c
===================================================================
RCS file: /home/wine/wine/server/ptrace.c,v
retrieving revision 1.7
diff -u -r1.7 ptrace.c
--- server/ptrace.c     2000/03/17 15:16:58     1.7
+++ server/ptrace.c     2000/04/03 13:17:10
@@ -166,12 +166,12 @@
         suspend_thread( thread, 0 );
         return 1;
     }
-    if (attach_thread( thread ))
-    {
-        /* the attach will have suspended it */
-        thread->suspend++;
-        return 1;
-    }
+    /* can't stop a thread while initialisation is in progress */
+    if (!thread->unix_pid || thread->process->init_event) goto error;
+    thread->suspend++;
+    if (attach_thread( thread )) return 1;
+    thread->suspend--;
+ error:
     set_error( STATUS_ACCESS_DENIED );
     return 0;
 }

-- 
Alexandre Julliard
[EMAIL PROTECTED]

Reply via email to