Welcome to MSDN Blogs Sign in | Join | Help

Debugging Toolbox

Windbg scripts, debugging and troubleshooting tools to help you isolate software problems.
Read Me

The purpose of this blog is to provide you with information that will help you during debugging sessions. The debugging toolbox I provide is a collection of Windbg scripts I created to help me on a daily basis. The collection expands whenever I develop a script to replace manual debugging.

 

The Windbg programming language looks like Perl.

To use the scripts you need to download Windbg and setup the public symbols. Actually not all scripts demand symbols, but it’s good to have them for your debugging session.

 

Most of the scripts should be executed using the following command from Windbg:

 

$$><path\scriptname.txt

 

The default directory I use is MyScripts, located inside the Windbg folder. If you want to use another location or another script file name, just change the source code to reflect the new location and/or file name.

 

In my machine the scripts are located at:

C:\Debuggers\MyScripts

 

You can think about the scripts like commands or extensions. My goal is not to teach you how to create Windbg scripts; however, if you want to learn how, check the Windbg documentation.

Although you have the source code, the commands and logic aren’t fully described. The reasons for this are the following:

 

-          Sometimes I’m going to use pointers or offsets that are strictly related to our products, so I won’t discuss these. Besides, they can change anytime and break the script.

-          Sometimes I’m going to use commands that aren’t clearly documented.

-          Sometimes I’m going to work around the script limitations using some of my techniques. Although unlikely, I may change the Windbg scripts from time to time to make them use the new commands/instructions, thus avoiding work around.

-          I also prefer not to explain the source code details for security reasons.

 

Common problems you may have:

 

-          Syntax error: Usually happens when you have a line break in the wrong place.

-          Syntax error when executing a script twice that uses custom alias: it’s a problem related to an alias. It will be fixed in the future, anyway, just call the script one more time and it'll run fine.

-          Some rare scripts must be called using $$< not $$><. Check the header file comments; otherwise, you won’t have the correct results from the script.

-          When you read something like “should work on 64 bits,” it means I didn’t test it on 64 bit machines, but it should work based just on my guess.

-          Some scripts are strictly version dependents so any product or OS update can break their functioning.

-          I couldn’t test them on different Windows versions; therefore, you could have problems in some OS versions. Most of the time I create and use them on Windows XP SP 2 and Windows Vista.

-          For scripts that requires symbols use: .reload /f  just once before running the script.

 

Before running a script you should read the header information in the source code.

Also remove any extra spaces between lines after copying the source code.

If you have problems or find a bug let me know.

If you have an idea you think might be cool for scripting let me know, too. J I’m interested! I just cannot promise I’ll implement all suggestions.

 

I hope you enjoy my little toys as much as I enjoy creating them! J

Posted: Sunday, March 18, 2007 9:14 PM by Roberto Farah
Filed under: ,

Comments

Mike Hoover said:

Really a quality work! This is awsome, I have heard about it but actually never read about it, this is the first blog I see related to the topic.

# March 18, 2007 11:42 PM

Roberto Farah said:

Thanks Mike!

# March 19, 2007 3:57 PM

nickx said:

your work is appreciated.

# October 16, 2007 10:31 AM

Debugging Toolbox said:

Have you ever had this situation: You need to get ASP information from an IIS process? If yes, you can

# December 24, 2007 7:41 PM

Debugging Toolbox said:

First, this script is not really about cheating. It does that with Minesweeper, but there are several

# December 24, 2007 7:42 PM

Debugging Toolbox said:

This is one of my “just for fun” scripts. It’s very simple and has some limitations, but it’s fun! What

# December 24, 2007 7:44 PM

Debugging Toolbox said:

This is a very simple script, yet powerful script. You can use it to see the APIs an application is using

# December 24, 2007 7:44 PM

Debugging Toolbox said:

Have you ever had a situation where you find yourself debugging a dump from ASP.NET when suddenly you

# December 24, 2007 7:44 PM

Debugging Toolbox said:

In the past I worked on a support case where I needed to find out if some MessageBox from a C++ application

# December 24, 2007 7:45 PM

Debugging Toolbox said:

After creating this script, I have used it in almost every case that requires decompilation, and I guess

# December 24, 2007 7:47 PM

Debugging Toolbox said:

Sometimes you cannot avoid reading the disassembled code to look for a specific assembly instruction.

# December 24, 2007 7:47 PM

sandeep said:

Thanks!! it is a great help.

# June 6, 2008 9:45 AM

Toyota said:

Hi,

Thank you for the nice info!

By the way, you said;

"It will be fixed in the future, anyway,..."

Does this mean that the current script engine has some problems?

# July 9, 2008 9:49 PM

Roberto Farah said:

Hi Toyota,

The scripts are ok, no problems found and when someone finds a bug I try to fix it as soon as possible, however, WinDbg had (and has) some issues when running scripts, for example, when you run a script that has alias and call it again you get an error. If you want to verify it by yourself, use, for example, dig_stack.txt, then call it again. Most of the problems I'm aware of were already fixed.

Lately I'm creating scripts using PowerShell that offer much more resources, stability and power. In a few weeks I'll post the newest PowerDbg library and a new script. Keep one eye in my blog. :)

Thanks

# July 9, 2008 10:27 PM

Toyota said:

To Mr.Farah,

> Lately I'm creating scripts using PowerShell that

> offer much more resources, stability and power. In a

> few weeks I'll post the newest PowerDbg library and a

> new script. Keep one eye in my blog. :)

This is great!

I cannot wait any longer!!!

Thank you for your answer. I will try dig_stack.txt.

# July 9, 2008 11:15 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker