Board index » cppbuilder » structure templates

structure templates

2003-11-05 01:20:02 AM
Say someone were to come to me and ask me to write a program that would read his binary file full of data. But he didnít have the structure template. Now, Iíve always thought of a structure template as the fileís basic building blocks . . . the fileís DNA, if you will. (Certainly as important as DNA), or the fileís ďblueprint? That people canít read a binary file (like they can ASCII) without a computer program to translate it for
them, and a computer program canít read a binary file without a
structure template to instruct it to how to read the gibberish
and store the various variables and data types. [Or am I wrong
in this assumption?] So my question is this, is there some way I
could reconstruct this guy's fileís structure template so that I
could then read/write to it.

Re:structure templates

You should use a HexViewer (BC comes with an example, i think it was at
First you have to recognize if the file has some kind of header or not. Then
detect header size.
After that you must recognize if records are fixed length or variable ones.
If records are variable lenght, problably the content is string. Two types
of strings are the most common: zero terminated (C style)
or lenght defined (Pascal style).
If record are fixed lenght you must detect what info its stored, tipically
'int' or 'long' variables can easily be detected, usually
they are Intel aligned (excpet that the file come from a Mac, where they are
Motorola-aligned ).
Hope this helps
PS: If the file is encripted or compressed this could be a very difficult