I am trying to write some kind of discompiler.I want to parse files according to structures which I have defined.

ie
mystruct starts
byte
string
string
mystruct ends

I know how to define this struct

mystruct struct
field db ?
string1 db 50 dup(?)
string2 db 50 dup(?)
mystruct ends

Also string1 and string2 doesnt have lenght of 50 bytes.if it is 10 bytes lets say.After 0, string2 starts.
How can parse someting according the structures I defined.I mean what is the most efficent and fast way.Hope you understand me.Sorry for my bad english.Thanks.
Posted on 2001-11-10 13:59:13 by LaptoniC
If you know that a file cannot contain more than 1024 structs, use static arrays, like this :

MIN_SIZE = 1024
field DWORD MIN_SIZE DUP (?)
pString1 DWORD MIN_SIZE DUP (?)
pString2 DWORD MIN_SIZE DUP (?)

pString1 and pString2 are string pointers. When you parse the file, allocate the number of characters you need for each string.

If you don't know the number of struct you need, use the HeapCreate, HeapAlloc and HeapRealloc to allocate the arrays and resize them dynamically.
Posted on 2001-11-11 01:29:41 by Dr. Manhattan