I am writing a tool in C++ to help debug and test deployed Windows 10 Store Apps. One of the problems I've run into is that I need a way to launch a Store App in a suspended state so I can attach a debugger before the app initializes. The usual way I know of to do something like this would be to set a hook on process creation in the parent process and forcibly flag the created process to start in a suspended state; however, for Store Apps, the parent process that creates the actual app process is svchost.exe which runs at a system level and can't be hooked without a kernel-mode driver of some sort.
I am using the IApplicationActivationManager
interface to launch applications, and am using the IPackageDebugSettings
interface to control/debug them after launch. Is there a way I can suspend a Windows 10 Store App when it launches so that it isn't allowed to first initialize?
In Visual Studio go to the properties of your project. Then go into the Debug tab and select 'Do not launch, but debug my code when it starts'.
Is this what you're looking for?
Looking back, I nearly answered my own question within the question itself. To launch a Windows 10 Store app in a suspended state, use the
IPackageDebugSettings::EnableDebugging
method to set an executable as a debugger. The app being debugged will launch suspended automatically; it's then the debugger's responsibility to resume the app.What I ended up doing in my project is something akin to this:
I wrote a basic wrapper for
IPackageDebugSettings
as well as a few utility functions for dealing with Windows 10 Store apps to make the overall process easier.