Hex Editor - Binary File Editing Software for Windows
Download Hex Editor Neo Hide this button

Array Field

Array field describes an array of some data type. Array is a sequence of several values of the same type.

Syntax:

[[noindex]] type-id var-id[expression];

Expression may be constant expression or dynamic expression. If it evaluates to 0, the field is removed from the output.

Hex Editor Neo automatically distinguishes between a simple array and an ordinary array. An array of elements of integer and floating-point built-in types is considered a simple array. Simple arrays do not impose a limit on a number of items and are extremely cheap to bind and consume no memory at all. Ordinary arrays (that is, arrays of user-defined types, or string types) have a hard-coded limit on array item count (about 2 million items) and require a corresponding amount of free RAM. A noindex attribute may precede the array field declaration if you do not use an Array Indexing Operator in any of the expressions to refer to elements of this array.

This will save the memory and structure binding time.

Example of array fields:

struct B
{
    // …
};

struct A
{
    int a[5];      // static array, considered as simple array
    B b[a[0]];     // dynamic array (a number of elements is taken from the first element of a). Not a simple array
};

Simple and Ordinary Arrays

Any array of elements of integer or floating-point built-in types is called a simple array. Array of elements of other types is called an ordinary array.

The following table briefly describes the difference between two array types:

PropertySimple ArrayOrdinary Array
User-defined element type supportedNoYes
Consumes more memory as array's size increasesNoYes
Consumes more time as array's size increasesNoYes
Has upper array size limitNoYes
Supports [noindex] attributeNo, ignored if usedYes, consumes less memory and time if used on an array

“Infinite” Arrays

You are allowed to declare an array of “infinite” size when declaring an array. The following syntax is used:

type-id var-id[*];          

type-id must be a user-defined type that must contain at least one $break_array directive that will specify the last element of the “infinite” array.

This is very useful if array size is not known at the array declaration point. For example, the following code snippet is capable of parsing a C-style null-terminated string:

struct StringCharacter
{
    char c;
    if (c == 0)
      $break_array(true);
};

struct NullTerminatedString
{
    StringCharacter chars[*];
};

// Display the class usage
struct FileStructure
{
    NullTerminatedString FileName;
    NullTerminatedString Location;
    // …
};    

Visualization

When Hex Editor Neo visualizes an array, it optionally visualizes its first several values in-line. Other values are displayed when you expand the array item. Character arrays (arrays of elements of char and wchar_t types) are visualized as ANSI or UNICODE strings respectively.