Debug Windows Service through Remote Desktop

Debugging Windows NT Service is headache. Doing so through remote desktop is even more difficult. But the remote debugging makes the story easier.

Let’s review the background.

Debugging a service is challenging because the service process starts before you log-in to the operating system. It’s not possible to debug a service process by starting CDB:


# Doesn't work!
cdb "C:\Program Files\MyService.exe"

Instead, you have to edit the Image File Execution Option registry key.

The debugger starts when the service process is initiated. But there is another problem. The debugger starts in session-0 as this is where the service process is running. In Windows Vista and later, the session-0 is not “interactive”. It means the debugger window is not visible to the console user.

A good news is that you can make a service to interact with a special desktop by setting an option.

The knowledge base below explains the story up to here. It’s worth reading but there is a bad news which is not covered by the article.
http://support.microsoft.com/kb/824344

A problem is that the interactive service doesn’t work when you are debugging through remote desktop. In other words, the special desktop is not available to he remote desktop users.

You can solve this problem by using remote debugging. First, use the image file execution option to start a debugger with -server option.

Then access the target from the remote desktop console:

It enables you to debug Windows NT services without using session-0 interactive desktop.

Advertisements

About Moto

Engineer who likes coding
This entry was posted in Advanced Debugging, Tips. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s