Deadlock in RhInjectLibrary?

Mar 25, 2010 at 11:45 AM

I have a service that using WMI to monitor any newly created process, and inject dll into them. Normally this scheme works fine, except for the processes spawned by Visual Studio 2008. Every time I use Visual Studio 2008 to debug an application (as simple as directly "return 0;") while leaving the service running, the application does not show up, and the service is frozen at RhInjectLibrary. It seems the remote thread falls into an infinite loop or something and RhInjectLibrary waits the remote thread to return. At the time, VS2008 cannot stop the debug session.

If the service spawns a thread to do the injection, waits several second, and if timeout, kill the thread, service will not freeze, however the application still freezes. My question is, is there a chance RhInjectLibrary would freeze the target process and never return? If yes, how do I avoid this?

Thanks in advance.