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

Pointer Field

Pointer field is functionally equivalent to a plain field but additionally describes the type this field points to. When Hex Editor Neo binds a pointer field, it automatically binds a pointed type at a calculated offset.

Syntax:

type-id var-id as pointed-type-id * [(expression)];

Expression, if present, is evaluated at run-time and the result is added to a field value. type-id must be an integer type. pointed-type-id must be a user-defined type.

Example of pointer field:

struct B
{
    // …
};

struct A
{
    short ptr1 as B *;
    unsigned int ptr2 as B *(10);     // B will be bound at offset (ptr2 + 10)
};

The resulting offset must be an absolute offset in a file. In cases where fields contain only relative offsets, this keyword may be used in an expression to “convert” a relative offset to an absolute offset:

struct B;

struct A
{
    short ptr1 as B *(this);  // B will be bound at offset (this + ptr1)
};

When pointers are processed and pointed structures are bound at resulting offsets, the current structure scope is used as a parent scope for a bound structure. This allows referencing its fields from the pointed structure:

struct B;

struct A
{
    int a;
    int ptr as B *;
};

struct B
{
    int array[a];     // will reference a in A, if B is automatically bound via a pointer
};

Late-evaluation is performed for pointers, which allows pointed types to reference fields from the parent scope even if they are defined below the pointer field.