title: Explorer.exe is deadlocked on startup when injecting a DLL
body: <p>I use the registry "run" key to automatically execute my program each time a user logs on to Windows (using <em>HKCU\Software\Microsoft\Windows\CurrentVersion\Run</em> registry path).<br>
  My application starts by injecting a DLL into explorer.exe process, using <a href="http://code.google.com/p/injector/" rel="nofollow">Command Line DLL-Injector</a>.  </p>
  
  <p>The effect should be: Each time after user logs in (after restarting Windows) - My application is executed, and my DLL is injected to explorer.exe</p>
  
  <p>In some cases it works, but in few cases (a matter of timing, rarely reproduces), both the injector and the explorer.exe processes are deadlocked and aren't responding.<br>
  I'm not sure, but I believe it happens because the injector is trying to inject a DLL to the process (and suspend it while doing so), while the process is already loading a different DLL (so it's locked). That way both of the processes are locked ==> deadlock.</p>
  
  <p>I know that the deadlock is achieved before the DLL was actually injected to the process.</p>
  
  <p>Does anyone have any idea how to avoid it? Maybe querying the state of explorer.exe before injecting into it? Maybe wait for the explorer to be stabilized? If so - how can I do that?</p>
  
  <p>Thanks</p>