Hi carbon-ga,
No, it is not practical to decode a file like this without detailed
knowledge of the software that wrote the file.
Even if you knew the types of the data elements involved, that would
not necessarily be sufficient, because the representation of the data
in the file is largely under the control of the application software.
The application can have MFC write some information about the class in
the file, as you described in your question, but that information is
not sufficient to decode all the data.
MFC provides some functions for serializing primitive data types and
MFC objects, but this doesn't help for two reasons. First, the
representation of the data in the file is not self-defining. A
sequence of four bytes could represent four BYTE members or two WORD
members or one LONG or DWORD member and there is no way to tell from
the information in the file alone which of these interpretations is
appropriate.
The second reason the standard functions don't help is that an
application does not have to use those functions anyway. When one is
writing the software to serialize an object, the main requirement is
that it be able to read what it has written and reconstruct an object.
MFC does not impose any requirements on how the data is represented
in the file. If a programmer writes the software to put out a
floating-point number in character representation, for example, that
will be perfectly fine with MFC.
So the problem of decoding a file written with MFC serialization is
much the same as the problem of decoding any file of unknown format.
If you have some information about what may or should be in a file and
you study the data, you may be able to crack the code, but it is not
practical to do it automatically.
Additional Links:
Microsoft Developer Network pages on serialization
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Serialization_Topics.asp
Search Strategy:
I consulted two books:
MFC Programming by Alan R. Feuer. Addison-Wesley (1997)
Inside Visual C++ by David J. Kruglinski. Microsoft Press (4th ed.,
1997)
I also referred to the help files of Microsoft Visual C++ 6.0, and I
wrote a test program and looked at its output. I relied primarily on
these off-line information sources, not Internet sources.
I hope this information is helpful. If anything in this answer is too
obscure, please ask for a clarification.
--efn-ga |