Coaxing DWORD values out of a Binary file...

Bengt Richter bokr at oz.net
Sun Nov 24 18:15:52 EST 2002


On Sun, 24 Nov 2002 22:46:30 GMT, "adeptus" <adeptus at earthlink.net> wrote:

>(in an attempt to write a utility to ginsu the data from Buzz .bm? files)
>I'm loosing my mind trying to read DWORD values out of a binary file.
>
>I've tried unpacking them via the struct module, (by passing them in as 4
>byte strings) but the numbers I get don't seem to make any sense for the
>file format...
>
>Am I making a naive assumption about how VC++ would write a DWORD to a
>binary file???
>
>I'm also assuming that:
>    (i386 centric)
>    8-Bits = 1 Char = 1 Byte
>    1 Word = 2 Bytes
>    1 DWORD = 4 Bytes
>
>What I'm asking is, what is proper officially pythonic way of accessing
>DWORD values stored in a binary file by a VC++ program???
>
It depends. You don't specify whether the data was written out of an array
of DWORDS or whether you are trying to find individual DWORDS in buried
in some kind of record structs or what.

Since the program is going to be trivial, why don't you post a test snippet
to show what you are doing. And maybe a little hex dump from the front of the
file, so we know what it actually is. Maybe you just forgot to open the file
in binary, but without a code snippet with a copy of interactive session results
it's (kind of annoying, since we're not mindreaders ;-) guesswork.

Regards,
Bengt Richter



More information about the Python-list mailing list