Using 010 Editor–Template
1
What is 010 Editor
A professional text editor and hex editor designed to quickly
and easily edit the contents of any file on your computer.
View and edit any binary file on your hard drive and text files
including Unicode files, C/C++ source code, etc.
Unique Binary Templates technology allows you to understand
any binary file format.
Analyze and edit text and binary data with powerful tools including
Find, Replace, Find in Files, Replace in Files, etc.
Find and fix problems with hard drives, floppy drives, etc.
2
Binary Template
010 Editor's unique Binary Templates technology allows
you to understand the bytes of a binary file by presenting
you with the file parsed into an easy-to-use structure.
A Binary Template allows a binary file to be understood by
parsing the file into a hierarchical structure.
Templates have a similar syntax to C/C++ structs but they
are run as a program. Every time a variable is declared in
the Template, the variable is mapped to a set of bytes in
the current file.
3
Binary Template: An Example
struct FILE {
struct HEADER {
char type[4];
version;
int
int
numRecords;
} header;
struct RECORD {
employeeId;
int
char name[40];
float salary;
} record[header.numRecords];
} file;
The variable type is mapped to the bytes 0 to 3 in the file.
version is mapped to the bytes 4 to 7.
numRecords is mapped to the bytes 8 to 11.
4
Binary Template (cont.)
Any time a variable is accessed, its value is read from the
file.
Any time the variable is assigned, its value is written to the
file.
These structures are different from regular C since they
can contain control statements such as if, for, or while.
Templates are executed in a similar fashion to an
interpreter, where each line is executing starting from the
top of the file.
5
Writing Templates
6
Template Basics
Templates allow binary files to be understood and edited in a
much easier fashion than typical hex editors.
Each Template is stored as a text file with the extension ".bt"
and can be edited directly in 010 Editor.
Templates are executed as an interpreter would run, starting
from the first line in the file and progressing downwards.
When a Template is executed the file is parsed into a
number of variables, which are displayed in the Template
Results panel.
Templates can be configured to automatically load and
execute each time a file is opened.
7
Numbers
Numbers may be entered in a number of different formats:
Decimal - 456
Hexadecimal - 0xff, 25h, 0EFh
Octal - 013 (with a zero before any numbers)
Binary - 0b011
The 'u' character can be used after a number to indicate an
unsigned value (e.g. '12u'),
'L' can be used to indicate an 8-byte int64 value (e.g. '-1L').
Floating-point numbers may contain 'e' for an exponent
(e.g. 1e10).
A floating-point number is automatically assumed to be an
8-byte double unless an 'f' character is located after the
name (e.g. 2.0f), in which case the number is assumed to
be a 4-byte float.
8