[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    thread suspend/resume/WriteProcessMemory
From:       Andreas Mohr <amohr () student ! ei ! uni-stuttgart ! de>
Date:       2000-03-31 17:24:34
[Download RAW message or body]

Hello all,

a program I tested (VideoSelect.exe) does this:
Call KERNEL32.746: WriteProcessMemory(7fffffff,78004858,4106b948,00000005,4106b944) \
                ret=0a93b7b3 fs=0247
0819ac10: write_process_memory( handle=2147483647, addr=0x78004858, len=2, \
                first_mask=ffffffff, last_mask=000000ff, \
                data={e9,d3,71,93,92,00,61,00} )
0819ac10: *attached*
0819ac10: *signal* signal=19
suspend: 1
suspended
pid: 62ce, addr: 0x78004858, data: -1821256727
file_set_error: No such process
continue
0819ac10: write_process_memory() = 1869f
0805fcb8: *timeout*
0805fcb8: select() = 0 { signaled=258 }
0805fcb8: event_op( handle=1414155747, op=1 )
0805fcb8: event_op() = 0
0805fcb8: select( count=1, flags=4, timeout=5, handles={1414155711} )
fixme:ntdll:RtlNtStatusToDosError no mapping for 0001869f
Ret  KERNEL32.746: WriteProcessMemory() retval=00000000 ret=0a93b7b3 fs=0247
Call KERNEL32.372: GetProcAddress(78000000,0a949330 "??2@YAPAXI@Z") ret=0a939846 \
fs=0247 Ret  KERNEL32.372: GetProcAddress() retval=78013642 ret=0a939846 fs=0247
Call KERNEL32.306: GetCurrentProcess() ret=0a93b7ac fs=0247
Ret  KERNEL32.306: GetCurrentProcess() retval=7fffffff ret=0a93b7ac fs=0247
Call KERNEL32.746: WriteProcessMemory(7fffffff,78013642,4106b948,00000005,4106b944) \
                ret=0a93b7b3 fs=0247
0819ac10: write_process_memory( handle=2147483647, addr=0x78013640, len=2, \
first_mask=ffff0000, last_mask=00ffffff, data={e9,d3,e9,69,85,92,92,00} ) already \
                attached
0819ac10: *signal* signal=19
suspend2: 1
suspended
pid: 62ce, addr: 0x78013640, data: 1776927492
pid: 62ce, addr: 0x78013644, data: 26382981
continue
0819ac10: write_process_memory() = 0
Ret  KERNEL32.746: WriteProcessMemory() retval=00000001 ret=0a93b7b3 fs=0247

Why the hell does there appear this file_set_error error message the first
time and not the second time, too ?

I tried to debug the whole server code in ptrace.c, process.c and thread.c
and couldn't find any problem.
(we wait4() the SIGSTOP to arrive, ...)
Oh, BTW: the "no such process" comes from process.c/write_process_memory():
    if (suspend_for_ptrace( thread ))
    {
        fprintf(stderr, "suspended\n");
        /* first word is special */
        if (len > 1)
        {
            if (write_thread_int( thread, addr++, *src++, first_mask ) == -1) goto \
done;

The write_thread_int() tries to do a ptrace() which fails with errno
#define ESRCH            3      /* No such process */.

Does anybody have a clue as to why the first time fails ?
It's working a zillion times later with the *same* pid; only the first
WriteProcessMemory fails.
I guess it's related to some inconsistency of the attach phase.
At least the suspending and resuming seems to work properly (all subsequent
WriteProcessMemory():s are successful).
Hmm, maybe something like wait4_thread() is broken ?

Alexandre ? ;)

Andreas Mohr


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic