Debugging a User-Mode Process Using Visual Studio

In Microsoft Visual Studio, you can use the Windows User Mode Debugger to attach to a running process or to spawn and attach to a new process. The process can run on the same computer that is running the debugger, or it can run on a separate computer.

The procedures shown in this topic require that you have the Windows Driver Kit integrated into Visual Studio. To get the integrated environment, first install Visual Studio, and then install the Windows Driver Kit (WDK). For more information, see Windows Driver Development.

Attaching to a running process on the same computer

  1. In Visual Studio, from the Tools menu, choose Attach to Process.
  2. In the Attach to Process dialog box, set Transport to Windows User Mode Debugger, and set Qualifier to Localhost.
  3. In the Available Processes list, select the process that you want to attach to.
  4. Click Attach.

Noninvasive debugging

If you want to debug a running process and interfere only minimally in its execution, you should debug the process noninvasively.

Spawning a new process on the same computer

  1. In Visual Studio, from the Tools menu, choose Launch Under Debugger.
  2. In the Launch Under Debugger dialog box, enter the path to the executable file. You can also enter arguments and a working directory.
  3. Click Launch.

Processes that the debugger creates (also known as spawned processes) behave a little differently than processes that the debugger does not create.

Instead of using the standard heap API, processes that the debugger creates use a special debug heap. You can force a spawned process to use the standard heap instead of the debug heap by using the _NO_DEBUG_HEAP environment variable.

Also, because the target application is a child process of the debugger, it inherits the debugger's permissions. This permission might enable the target application to perform certain actions that it could not perform otherwise. For example, the target application might be able to affect protected processes.

Attaching to a running process on a separate computer

Sometimes the debugger and the code being debugged run on separate computers. The computer that runs the debugger is called the host computer, and the computer that runs the code being debugged is called the target computer. You can configure a target computer from Visual Studio on the host computer. Configuring the target computer is also called provisioning the target computer. For more information, see Configuring a Computer for Testing and Debugging.

After you have provisioned a target computer, you can use Visual Studio on the host computer to attach to a process running on the target computer.

  1. On the host computer, in Visual Studio, from the Tools menu, choose Attach to Process.
  2. In the Attach to Process dialog box, set Transport to Windows User Mode Debugger, and set Qualifier to the name of the target computer.
  3. In the Available Processes list, select the process that you want to attach to.
  4. Click Attach.

Note  

If you are using separate host and target computers, do not install Visual Studio and the WDK on the target computer. Debugging is not supported if Visual Studio and the WDK are installed on the target computer.

 

 

Send comments about this topic to Microsoft

Build date: 1/27/2014

Show:
© 2014 Microsoft. All rights reserved.