3

I do a bit of raster graphics and video programming. What would be super handy would be some IDE, plugin, debugger or tool that is able to view a chunk of memory as a bitmap image.

Most debuggers let you introspect composite types, arrays, strings and so on. When it comes to bitmaps though, they can only show you the raw memory, and since I'm not a hacker from the Matrix, it's very hard to diagnose problems here.

It would be great if there were some tool that, given a memory location, pixel format (e.g. ARGB8888, YUV420) and image dimensions, show a picture of what that memory represents. What I currently have to do is write code to dump the memory out to file and view it in an external viewer, which is very clunky.

Requirements:

  • Any of Windows (XP or greater), OS X or Linux
  • Must work with program memory or integrated in IDE; must not be file-only viewer
  • If IDE, support latest C/C++ standards (C99 and greater, C++11 and greater), must not require custom language, platform or types
  • Choose from a number of pixel formats
  • Any price is ok
1

I'm answering this, because you did not get other answers for more than a year now. I'd say your request is quite specific.

Pictures in dumps

If you have a Windows crash dump (.dmp) file, you can open it in WinDbg, which is the free Microsoft debugger for user mode and kernel mode dumps.

There are 4 undocumented commands that can find images in memory. Those commands are part of the ext extension which is loaded by default:

!findgifs
!findjpegs
!findjpgs
!findpngs

The output will give you the start and end address of an image in memory. You can use that to write the image to disk using the .writemem command.

Example output of a running Notepad++ application:

0:000> |
.  0    id: 472c    attach  name: C:\Program Files (x86)\Notepad++\notepad++.exe
0:000> !findpngs
Found:  0062387c    00636f76
Found:  06ed3cfa    07940c87
...
0:000> .writemem c:\tmp\writemem.png 0062387c 00636f76
Writing 136fb bytes............

The result was this PNG file:

PNG file extracted from Notepad++

You can automate this with PyKD to write all PNGs from memory to disk. You'll need the dbgCommand() function to do !findpngs first, then process the string (split the lines and extract start and end address) and then use dbgCommand() again to do the .writemem. Unfortunately I don't have it installed at the moment, so I can't provide a complete script.

Why I consider this as an answer:

Any of Windows (XP or greater)

WinDbg is available for Windows XP through 10. Maybe you need different versions of WinDbg, but they should still be available.

Must work with program memory or integrated in IDE; must not be file-only viewer

This solution works from memory (crash dump file) with the workaround over disk. This may not be 100% what you want, but perhaps it's still easier to do (if scripted) than from any other IDE.

Choose from a number of pixel formats

Actually I'm not sure how it detects that. IMHO there's no way to explicitly define a pixel format.

Any price is ok

WinDbg and PyKD are both available gratis.

Dump2Picture

Reading your question the first time I thought you'd be looking for something like this. I'll leave this as a reference for other readers, if that's what they want.

The tool Dump2Picture can convert a Windows crash dump (.dmp) into a picture. The author of these books has used it as a design element at the top of the book cover.

However, you'll hardly find real images (such as JPGs) in there. The reasons are:

  • the pixels will not be aligned correctly, i.e. the width and height of the generated picture don't match the image in memory
  • the color depth will likely not match
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.