Mike wrote:
... I'm not sure how this works. You create a new "raw" kernel thread using clone, then run NT code using it. But that isn't valid and may not work - only threads created by Wine may use Win32.
The right thing to do would be to promote the linux thread to be a win32 thread, but as a temporary stopgap, Thomas had the linux thread just do CreateThread and exit, hoping that the newly create Windows thread was healthy. Maybe we should look more carefully about what it takes to build a normal, healthy win32 thread from a posix thread.
You are using ptrace instead of signals. That seems over complex - signals are designed to interrupt a thread ...
Well, kind of. Signals are only delivered when syscalls return, so they won't work well if the thread you pick to molest happens to not make any syscalls for a long time. (Plus, signals aren't completely reliable... see http://www.opengroup.org/austin/mailarchives/ag/msg07173.html for a 2004 proposal for making signals reliable.)
You don't preserve the register state.
Really? What's ptrace(PTRACE_GETREGS, pid, NULL, regs) then, chopped liver? :-)
[Why not queue a windows APC?]
Well, if Alexandre thinks that's the way to go, that'd be fine. I thought those only fired when the thread in question performed an alertable wait condition (so says http://msdn.microsoft.com/library/en-us/dllproc/base/queueuserapc.asp ) so it didn't seem like an obvious way to go. - Dan