Edit Anything

Professional text and hex editing
with Binary Templates technology.







010 Editor - Text/Hex Editor Homepage

Arrays and Duplicates

When writing a template, regular arrays can be declaring using the same syntax as scripts (see Arrays and Strings). However, 010 Editor has a syntax that allows arrays to be built in a special way. When declaring template variables, multiple copies of the same variable can be declared. For example:

    int x;
    int y;
    int x;

010 Editor allows you to treat the multiple declarations of the variable as an array (this is called a Duplicate Array). In this example, x[0] could be used to reference the first occurrence of x and x[1] could be used to reference the second occurrence of x. Duplicate arrays can even be defined with for or while loops. For example:

    local int i;
    for( i = 0; i < 5; i++ )
        int x;

For another example, see the 'ZIPTemplate.bt' file that uses duplicate arrays to parse ZIP files. Duplicate arrays are also useful because of how 010 Editor deals with arrays of structs.


Optimizing Structs

010 Editor contains an optimization that allows it to generate arrays of structures with millions and millions of elements. The optimization calculates the size of the first element of the array and assumes all elements of the array are the same size. This optimization will cause incorrect results if the elements can be variable size (010 Editor will display a warning in the Output text area if it detects this may be happening). To turn the optimization off, use the syntax '<optimize=false>' after the array declaration. For example:

    typedef struct {
        int   id;
        int   length;
        uchar data[ length ];
    } RECORD;

    RECORD record[5] <optimize=false>;

If 010 Editor displays a warning in the Output text area, but you would still like to use the optimization, use the syntax '<optimize=true>' to turn off display of the warning. The '<optimize=false>' syntax can also be used with struct typedefs to indicate that optimization should not be used on any arrays using that structure. Unoptimized arrays can also be rewritten as duplicate arrays (see above) since the elements of duplicate arrays can have different sizes.


This is the manual for 010 Editor, a professional hex editor and process editor. Use 010 Editor to edit the individual bytes of any binary file, hard drive, or process on your machine. 010 Editor contains a whole host of powerful analysis and editing tools, plus Binary Templates technology that allows any binary format to be understood.