HexEdit includes a C/C++ parser to assist you when making templates. It is primarily designed for parsing of structs from C header files (though it is flexible enough to handle just about any C or C++ you throw at it).
I have had two "bug" reports that the parsing of C structs is producing no output. The problem is that to get the correct results you have to understand how the C language (which the HexEdit parser closely follows) works, and carefully examine the code you are using. I will give a few examples.
First it is important to remember that generally C header files are used to declare types (including structs) but it is is considered very bad style to declare variables of those type in header files. A header file will often contain a type declaration like this:
CODE
struct a_
{
int b;
};
When you paste this code into the HexEdit Parser dialog the parser will remember a type for "a_", but will not create any template STRUCT elements. (Though you can save this type as a "STRUCT" in the "_custom_types.xml" for later use if you use the "Save Custom Types" checkbox.)
To actually obtain a variable of the type of the struct you need to define one like this:
CODE
struct a_ aa;
A simpler way is to just add a variable name at the end of the structure definition:
CODE
struct a_
{
int b;
} aa;
Here is something that confuses many people. The following looks like it is declaring a variable called "A" but in fact the preceding typedef turns this into a type named "A" (synonymous with "struct a_"). Hence nothing is added to the template here either.
CODE
typedef struct a_
{
int b;
} A;
To use it you must declare a variable of type "A":
CODE
A aa;
Here are two more examples to make it perfectly clear:
CODE
struct
{
int b;
};
Nothing is produced here at all as there is no variable name and the structure is anonymous. (There is not even a type remembered as the structure has no name.)
CODE
struct
{
int b;
} aa;
Here a STRUCT (called "a") is created in the template (containing an integer DATA element called "b"). The structure is anonymous so no type is remembered.
--------------
Andrew Phillips
Moderator of Forums and creator of Hex Edit