<div dir="ltr"><span style="font-size:12.8px">Hi all,</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">I have an application that is creating a process suspended and then</span><br style="font-size:12.8px"><span style="font-size:12.8px">using detours modifies the imports of the new process prior to</span><br style="font-size:12.8px"><span style="font-size:12.8px">resuming it (the application is called Tracker.exe and is part</span><br style="font-size:12.8px"><span style="font-size:12.8px">of MS toolchain, it can be retrieved in MS EWDK package)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">The application does not work as it should on Wine, as the DLL its</span><br style="font-size:12.8px"><span style="font-size:12.8px">trying to inject to the new process is not getting loaded, I tracked</span><br style="font-size:12.8px"><span style="font-size:12.8px">down the problem here are the technical details:</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">When a new process is created, after all the other set-ups its running</span><br style="font-size:12.8px"><span style="font-size:12.8px">the function:</span><br style="font-size:12.8px"><span style="font-size:12.8px">dlls/ntdll/server.c!server_</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">init_process_done</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">This function sets up the handlers for the different signals</span><br style="font-size:12.8px"><span style="font-size:12.8px">(signal_init_process) and makes a wine_server_call init_process_done.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">In the wine server function server/process.c!init_process_</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">done a check</span><br style="font-size:12.8px"><span style="font-size:12.8px">is made to see if the</span><br style="font-size:12.8px"><span style="font-size:12.8px">thread of the process needs to be suspended (stop_thread_if_suspended)</span><br style="font-size:12.8px"><span style="font-size:12.8px">and indeed when</span><br style="font-size:12.8px"><span style="font-size:12.8px">a process is created with the CREATE_SUSPENDED flag, thread->suspend</span><br style="font-size:12.8px"><span style="font-size:12.8px">== 1,  process->suspend == 0, and the process state is done at this</span><br style="font-size:12.8px"><span style="font-size:12.8px">point).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">This makes the wine_server call to stop_thread which will send a</span><br style="font-size:12.8px"><span style="font-size:12.8px">SIGUSR1 signal to the new process.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">The new process however still have the signals in a block state, thus</span><br style="font-size:12.8px"><span style="font-size:12.8px">not processing the signal and putting it into a pending state.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">The next thing that happens is LdrInitializeThunk continues and fixing</span><br style="font-size:12.8px"><span style="font-size:12.8px">up the EXE module imports, this is not the same behavior as Windows in</span><br style="font-size:12.8px"><span style="font-size:12.8px">which the Ldr only starts running after the thread has</span><br style="font-size:12.8px"><span style="font-size:12.8px">resumed.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Only later signals are being unblocked and then the thread enters a</span><br style="font-size:12.8px"><span style="font-size:12.8px">suspended state, the function</span><br style="font-size:12.8px"><span style="font-size:12.8px">which unblocks the signals today is attach_process_dlls</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">The interesting thing is that in the past Wine behavior was correct</span><br style="font-size:12.8px"><span style="font-size:12.8px">and the change that basically broke it is commit:</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">commit 0f5fc117a2320bb7e21b9ae4d07d71</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">7bed413171</span><br style="font-size:12.8px"><span style="font-size:12.8px">Author: Alexandre Julliard <</span><a href="mailto:julliard@winehq.org" style="font-size:12.8px">julliard@winehq.org</a><span style="font-size:12.8px">></span><br style="font-size:12.8px"><span style="font-size:12.8px">Date:   Mon Nov 19 14:27:07 2007 +0100</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">    ntdll: Unblock signals in process init only after the dlls have</span><br style="font-size:12.8px"><span style="font-size:12.8px">been imported.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Unfortunately though there I could not find any reason why the change</span><br style="font-size:12.8px"><span style="font-size:12.8px">was made or if there is any bug that it fixed back then (2007) .</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">I was thinking that perhaps in order to resolve the problem and be</span><br style="font-size:12.8px"><span style="font-size:12.8px">closer in the behavior to Windows would be to unblock the signals just</span><br style="font-size:12.8px"><span style="font-size:12.8px">before server_init_process_done returns.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Please let me know if you have any other questions, will be happy to</span><br style="font-size:12.8px"><span style="font-size:12.8px">resolve this now that we have all the information laid out.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Thanks,</span><br style="font-size:12.8px"><span style="font-size:12.8px">-- Jon.</span><br></div>