Intercepting Program Startup on Windows and Trying to Not Mess Things Up

Have you ever heard of Image File Execution Options (IFEO)? It is a registry key under HKEY_LOCAL_MACHINE that controls things like Global Flags and Mitigation Policies on a per-process basis. One of its features that drew my attention is a mechanism designed to help developers debug multi-process applications. Imagine a scenario where some program creates a child process that crashes immediately. In case you cannot launch this child manually (that can happen for various reasons), you might have a hard time troubleshooting this problem. With IFEO, however, you can instruct the system to launch your favorite debugger right when it's about to start this troublesome process. Then you can single-step through the code and figure what goes wrong. Sounds incredibly useful, right?
I don't know about you, but I immediately saw this feature as a mechanism for executing arbitrary code when someone creates a new process. Even more importantly, it happens synchronously, i.e., the target won't start unless we allow it. Internally, the system swaps the path to the image file with the debugger's location, passing the former as a parameter. Therefore, it becomes the debugger's responsibility to start the application and then attach itself to it.
So, are there any limitations on what we can do if we register ourselves as a debugger? Let's push this opportunity to the limits and see what we can achieve.
В ядре Windows есть модуль, отвечающий за поддержку группировки файловых операций в некоторую сущность, называемую транзакцией. Действия над этой сущностью изолированы и атомарны: её можно применить, сделав перманентной, или откатить. Очень удобно при установке программ, согласитесь? Мы всегда переходим от одного согласованного состояния к другому, и если что-то идёт не так, все изменения откатываются.
Я люблю Хабр и Гиктаймс за то, насколько вменяемые и образованные люди здесь собрались. Но будучи даже мастером рационального мышления можно попасться на высказывании какой-нибудь глупости просто потому, что вы не задумались об альтернативах вовремя. Как говорится, сколько ещё морских свинок должно пострадать из-за того, что они не морские и не свинки? Я предлагаю вашему внимаю подборку и обсуждение некоторых достаточно распространённых заблуждений, чтобы впредь мы c вами были чуть меньше неправы. Давайте посмотрим, насколько вы знакомы с обратившими на себя внимание вопросами, и знаете ли правильные ответы на них.