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

IParser Interface

This interface is implemented by the intrinsic parser object, provided to scripts running as part of the Structure Viewer structure binding under the name parser. The name may be omitted and the methods below may be called directly.

Declaration

interface IParser {

    // Methods
    ${abort}(message: string): void;
    ${alert}(message: string): void;
    ${bind}(typeName: string, varName: string, offset: number): void;
    ${eval}(Expression: string): boolean | number | string;
    ${print}(varName: string, varValue: string): void;
    ${add_coloring_scheme}(name: string, frontColor: object, backColor: object, outlineColor: object, roundEdges: boolean): void;
}
// This interface is not available in managed environment
// This interface is not available in native environment

IParser Methods

abort

abort(message: string): void;
// This method is not available in managed environment
// This method is not available in native environment
message
A message to be displayed in the Structure Viewer Tool Window.

Abort current binding. Behaves like the $assert directive.

alert

alert(message: string): void;
// This method is not available in managed environment
// This method is not available in native environment
message
String to display

Display informational message in a popup message box. Should be used only for debugging purposes.

Expression evaluation

function f()
{
    var a = eval("pe_header.e_lfanew.sections[0].Name");
    alert("First PE file section name is \"" + a + "\"");
    return 0;
}

bind

bind(typeName: string, varName: string, offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
typeName
The name of the user-defined type. The type must be fully defined.
varName
The name of the variable. Must be unique.
offset
Structure starting address (absolute value).

Bind a given structure to a given address. Hex Editor Neo performs delayed binding, that is, a new structure is bound only after the current one is successfully finished binding.

Binding a structure

function f()
{
    bind("struct A","a",0);
}

eval

eval(Expression: string): boolean | number | string;
// This method is not available in managed environment
// This method is not available in native environment
Expression
The expression to evaluate.

Expression evaluation result.

Calculate expression value. You may reference global constants, enumerations, field values of already bound types and so on.

Expression evaluation

function f()
{
    var a = eval("pe_header.e_lfanew.sections[0].Name");
    alert("First PE file section name is \"" + a + "\"");
    return 0;
}

print

print(varName: string, varValue: string): void;
// This method is not available in managed environment
// This method is not available in native environment
varName
Name of the variable. Must be unique in the current scope.
varValue
Variable's value, as string.

Add a virtual field to the output.

Adding virtual fields

function f()
{
    print("var1",10);
    print("var2","Hello, World");
}

add_coloring_scheme

add_coloring_scheme(name: string, frontColor: object, backColor: object, outlineColor: object, roundEdges: boolean): void;
// This method is not available in managed environment
// This method is not available in native environment
name
Scheme's name. Must not match any of existing coloring schemes.
frontColor
An object that specifies the font color. See Remarks for details.
backColor
An object that specifies the background color. See Remarks for details.
outlineColor
An object that specifies the outline color. See Remarks for details.
roundEdges
true to round outline edges, false otherwise.

Create new binding-local coloring scheme. FrontColor, BackColor and OutlineColor must be JavaScript objects with r, g, b and a properties. If any of the property is omitted, its value is defaulted to 0, except for a, which value is defaulted to 255. All values must be within [0..255] range.

Creating new color scheme

function f()
{
// Create a coloring scheme Red on Blue, no outline (0 alpha = full transparent), no round edges
    parser.add_coloring_scheme("my scheme",{ r:255, g:0, b:0, a:255 }, 
        { r:0, g:0, b:255, a:255 }, { a:0 }, false);
}