简体   繁体   English

注入DLL时启动时Explorer.exe死锁

[英]Explorer.exe is deadlocked on startup when injecting a DLL

I use the registry "run" key to automatically execute my program each time a user logs on to Windows (using HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run registry path). 每当用户登录Windows时,我使用注册表“运行”键自动执行程序(使用HKCU \\ Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Run注册表路径)。
My application starts by injecting a DLL into explorer.exe process, using Command Line DLL-Injector . 我的应用程序首先使用命令行DLL-Injector将DLL注入explorer.exe进程。

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 效果应为:每次用户登录后(重新启动Windows后)-执行我的应用程序,并将我的DLL注入explorer.exe。

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. 在某些情况下,它可以工作,但在少数情况下(时间问题,很少重现),注入器和explorer.exe进程均处于死锁状态,并且没有响应。
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). 我不确定,但是我相信会发生,因为注入器试图将DLL注入进程(并在执行过程中将其挂起),而进程已经在加载其他DLL(因此被锁定)。 That way both of the processes are locked ==> deadlock. 这样,两个进程都被锁定==>死锁。

I know that the deadlock is achieved before the DLL was actually injected to the process. 我知道在将DLL实际注入到进程之前就已经实现了死锁。

Does anyone have any idea how to avoid it? 有谁知道如何避免它? Maybe querying the state of explorer.exe before injecting into it? 也许在注入之前查询explorer.exe的状态? Maybe wait for the explorer to be stabilized? 也许等待探险者稳定下来? If so - how can I do that? 如果是这样-我该怎么做?

Thanks 谢谢

您总是可以通过重新注入可执行文件的.reloc节来避免使用DLL并避免挂起目标进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM