Debugging application startup when you don't directly launch the app
Out of the blue yesterday an internal MS architect called me in my office (which rarely happens.) They needed to debug a second instance of Windows Media Player which crashed when launched within Internet Explorer. The good old "Attach to process" debugger trip wouldn't work, since Media Player faulted before they could attach to it.
Reaching way back into my bag of tricks, I recalled the "Image File Execution Options" trick. By setting a registry key, you can cause Windows to launch a different executable than the original program. In this case, you tell Windows to start the debugger of your choice, with the name of the original executable passed as an argument to the debugger.
This trick is mainly used for debugging services, but comes in handy in other cases as well. After a day of fighting the version control system and test scripts, it sure felt good to have done at least one useful thing.
Comments
Anonymous
August 12, 2004
This is a great tip, thanks Matt!
I wonder which process handle gets passed back to the app that called CreateProcess? The debugger or the target app? Hopefully the target app. The MSDN article doesn't say.Anonymous
August 16, 2004
My favorite use for this is sysinternals.com replacing task manager with process explorer.Anonymous
August 23, 2004
The comment has been removedAnonymous
January 03, 2008
PingBack from http://actors.247blogging.info/?p=1271Anonymous
March 20, 2008
PingBack from http://dinnermoviesblog.info/under-the-hood-matt-pietrek-debugging-application-startup-when-you/Anonymous
March 08, 2009
PingBack from http://thetweaker.wordpress.com/2009/03/09/debugging-a-process-launch/