BitHack is a very old utility that I originally wrote in DOS and have updated
to windows. It does one thing, and that is extraction of bitmaps from binary
files. I'm not talking about RLE or compressed bitmaps, but raw pixmap or DIB,
i.e. actual pixels saved to file, usually scanline by scanline with maybe some
pad bytes between.
BitHack allows you to extract that data and display it, refining the parameters in
real time until you have the right image. It takes some skill to recognise an image
and bring it into "focus" but it's lots of fun anyway.
I had the mis-fortune of receiving a screenshot sent from an Outlook user, which
was attached as a "winmail.dat" file. My email client
Scribe
now supports decoding winmail.dat files to the individual files. In this case the
attachment decoded to a single file "Unknown Attachment" which didn't help me much
because I don't know what type of file it is. So after looking at it in a
hex editor I had a hunch it was an bitmap because of the
regularity of the data, lots of similar but different 32bit values. So I fired up
BitHack and made a little graphical example of how I extracted the image.
|
This is what I saw when I first openned the file... doesn't look like much does it?
|
|
So I changed the width using the -> arrow. If you add Shift
it changes faster.
|
|
But the bit depth of the image is 32 bits/pixel, and the default is 24, so I
change the depth to 32 using the menu and this is what I got.
|
|
Now I widen the image even furthur watching for the noise to disappear, here
at this point I can see diagonal lines appearing in the mush of pixels. So the
image gets wider and wider the diagonal lines start to become more vertical.
|
|
Here you can see I'm approaching the right width, the lines are now getting close
to vertical.
|
|
Finally, we have the right width and the image starts to appear. It's the wrong
colours and it's offset a funny amount but you can begin to make out the
picture. These colours are typical of a sub-pixel offset shifting the colour
channels around.
|
|
I use the ↓ to change the offset into the picture one byte at a time,
this moves the byte data into a different colour channel, now it's all yellow.
|
|
Ah ha... now we have removed the sub-pixel offset and all the data is in the
right colour channels. Time to remove the x offset using Ctrl+
↓. The adition of Ctrl moves the offset into
the file by a whole pixel at a time.
|
|
The X offset is now correct. But there is a bunch of garbage at the top of the file.
I can remove that by moving the offset down by a scanline at a time, the
key for this is Shift+↓.
|
|
Ok now everything is fine... except it's upside down. Windows DIB's are stored
upside down, but no worries, BitHack has an option to flip the image.
|
|
All done.
|