Bitmap Memory Debugger
Version 1.10
June 25, 2003
Last Update Feb 18, 2006
Copyright 2003-2006 Octopus Motor Games
Lars Norpchen
bmd@NOSPAM_theycamefromhollywood.com

 
Download V1.10
Here.
 
Introduction
Display Mode Notes
File Menu
Tools Menu
Examples
Usage License
Known Bugs and Issues
Wish List
Change History


Introduction
Bitmap Memory Debugger is a tool used to help windows developers debug code by showing memory in a 2d graphical manner. It operates in tandem with a standard debugger, but shows memory in a variety of visual styles and bit sizes. Designed to help debug graphics applications, it can also be used to display any memory in a 2d array for quick visual review on large regions of memory. The idea for BMD was based loosely on Snoop by Raj Mohan from Window's Developer Journal July 1998 combined with my going blind studying the MSVC memory window while working on They Came From Hollywood.
 
 



The area on the left are the programmer's controls for describing the data to be examined. The picture on the right is the data leeched from the debugged application

The window / process pull down lists all open application windows. Pick the application you wish to debug. If your application doesn't show up, for example, it was launched after BMD opened, hit the rescan button. The application is picked by window name and the process ID is reacquired on each refresh, so stopping and restarting the debugged application does not cause BMD to lose which application is being debugged (as long as it's window title remains consistent). However, it can't distinguish between multiple instances of the same application, so it's recommended only one instance be debugger / run.

Image type field picks how BMD should convert the data to a bitmap as well as setting the data field size. There are three palettes available for byte data based on what's most appropriate for the developer. See the notes below on what the options mean. The pad byte is inserted between each data field, to allow for reading a given field in an array of structures.

Image data area sets where the data to be read can be found within the debugged application's memory space. The address shown is the base address used for both the image data and the dimensions (if dims are in address+offset mode). Usually you want to copy and paste the base address from your debugger-it will take hex or decimal input (it figures it out depending on a leading 0x ) The offset is the location of the image data as offset from the base address (for accessing image data within a structure or class) Address+offset mode is used when the memory's location is direct, statically declared, or embedded within the structure directly. *(address+offset) is used when the memory's location is referenced via a pointer in a structure. The net address being viewed is shown in hex.

The Dims area describes the image size. Direct Entry mode lets the developer specify the image size directly and statically. Address+offset mode is used to pull the dimensions from a structure within the debugged application dynamically, with their bit size specified. In Address+offset mode, you set the offset from the base address (as specified in the image data region), and the read-from-memory dimensions are shown in the width, height and (optionally) pitch fields. See the examples below for more detail. The program has a built in limit of 4000 for width or height for sanity checking.

Pitch is used when the row length is greater than the image width (as some video memory buffers require). Pitch cannot be smaller than width..

Refresh controls when the display is refreshed. Paused suspends updates allowing the developer to enter the data into the fields without having BMD try to update it's image with half valid data. This is the default state on startup. "Refresh now" will refresh the display and all dynamic data on demand. Auto refresh will cause BMD to automatically update itself at a given interval (in milliseconds). It's not recommended to set the interval very low on slow machines when viewing large amounts of data as this can really bog down the machine. Auto update while the debugged application is running is very useful for watching the data change in real time.

Vert flip will display the image upside down (a vertical mirror flip, not a 180' rotation). This is useful for some image formats which store data bottom to top.

The Zoom buttons allow the image to be scaled (the scale factor is displayed in the window's title bar). It will not allow a zoomed image to be greater than 1500 pixels tall or wide. If a data read is larger than 1500 pixels, it will automatically be scaled down until it fits. (zoom levels smaller than 1:1 will skip pixels, not interpolate)

Display Modes Notes:
The total number of data fields read is pitch * height, whereas the size of each data field is set by the image type plus pad bytes. So the total bytes read is (pitch * height * (data byte size + pad bytes)). The memory request may fail if the read size exceeds the real size of the available data

The aInv button will invert the alpha channel, which is useful if your alpha channel represents opacity instead of transparency.


File Menu

Load and Save Config will load / save a configuration so you don't have to remember or recalculate offsets, dims, etc. for structures and classes used frequently. Config files are stored as .ini files for convenient editing, should you feel the need.

Export to TGA will save the current image, at its current zoom level, as a 24 bit TGA file.

The 9 most recently saved and loaded configurations are listed under the file commands for quick access.

And then there's Exit...


Tools Menu

Offset Finder
This is a tool to hunt for offset values automatically, since it can be hard to calculate offsets manually when padding, vtables, inheritance, etc. come into play. Set up the base address of your structure in the main window. Then open the offset finder (make sure it shows the proper structure base address in the window). Using the debugger, find the value of the structure field you want. Enter the value to hunt for, it's byte size, and a reasonable upper limit to the search range. Hit start to start the search at the base address. The resulting offset will be displayed if it's found, or it will say not found. Hit find again to find the next instance of the hunt value (find again will gray out if it hits the end of the search range). Copy the found offset to the desired offset field in the main window.


Examples:
For clarity, these examples assume the compiler is not padding the structures for data alignment. Your compiler probably is padding things, so set your offsets accordingly. You might have to use your debugger's memory window to examine a structure's real offsets, skipping over this pointers and vtables. Once you set up a struct or class correctly, save it using the file menu so you don't have to do it again (unless you change the order, offsets or packing)

Example 1: A simple static memory array:

byte data[10000];

would be setup as:

Example 2: A structure with a pointer to the image data:

class foo
{
long width;
long height;
byte * data;
};

would be setup as:
every refresh, the dimensions and data pointer would be re-read and recalculated, so the structure can change dynamically in size and data location.

Example 3: A array of structures / classes with other data around the desired data:

class foo
{
byte image_data;
byte other_data;
word more_data;
};

foo array_of_foo [10000];

would be setup as:


if you wanted to look at other_data, set the address_offset to 1
if you wanted to look at more_data, set the image type to a 16 bit format, pad bytes to 2, and address offset to 2

Example 4: An array of structures / classes with an array inside and extra data:

class foo
{
long useless_data;
byte image_data[100];
word more_data;
};

foo array_of_foo [100];

would be setup as:


Example 5: Looking at 32 bit RGBA images:

To look at the RGB pixel data, set the image type to 24 bit and pad byte to 1
To look at the alpha channel, set the address offset to 3, image type to 8 bit grayscale and pad bytes to 3.
Again, compiler structure padding may change these values


 
Usage License
Blah blah blah. Bitmap Memory Debugger is copyright 2003-2006 by Octopus Motor, all rights reserved. No warranty or fitness for any particular purpose is implied or given. Octopus Motor is not liable for any damage caused by use or misuse of this software. Software is provided "as is" and used at your own risk. This software and documentation may not be distributed except as a complete and unmodifed package and without charge. It may not be distributed bundled with other products. Please contact Octopus Motor via email for permissions beyond these terms. Octopus Motor reserves the right to change or revoke this license agreement at any time. Use of software constitutes acceptance and agreement to these terms.

Bitmap Memory Debugger is free to use for educational, non-commercial or non profit purposes. Use in a professional or commercial project requires payment of USD $20 per copy / seat via Paypal to
bmd@NOSPAM_theycamefromhollywood.com (remove NOSPAM_ ) If you don't want to use paypal, please email me for other payment options.

I'm sorry I can't give away the source code, there are some sections which I cannot release.


Known Bugs / Issues:
The edit fields don't update the display until they lose focus. I did this because they were responding to every change as one typed-for example, entering 123 for the width caused to try to display first a width of 1, then 12, then finally 123. So just hit another control (ie: refresh now) if you are updating an edit field and want to see the change refresh. THIS SHOULD BE FIXED IN 1.10

Window / process name is not saved as part of the config...not sure if that's good or bad, actually...

Sometimes part of the error response gets cut off above the bitmap.

Offset finder doesn't always get the base address the first time through

If you have questions, comments, feedback, bug reports or requests, please let me know at
bmd@NOSPAM_theycamefromhollywood.com (remove NOSPAM_ )

 
Wish List

Change History
v1.0
first release

v1.01
fixed float denormal detection
changed float min / max to use sci notation

v1.02
fixed large size x 1 pixel bug
Added auto offset finder tool.
Stores settings in registry
Stores window position between sessions
Timestamp of last memory read now shown above image
Proper version number & build date displayed in about box.

v1.03
added Top Z Lock button


v1.04
Added BGR, RGBA and BGRA modes per request
Alpha support, and invert alpha button
Custom icon
Tooltips


v1.05
Changed refresh rate to ms instead of seconds. Don’t crank it up too high!


v1.10
Changed edit fields to combo boxes with history on request
Changed settings to use local preferences file