Links

Data Inspector

Quickly decode bytes as various different encodings
The Data Inspector aids identifying of encoded values in binary data without needing to write a full Pattern definition for it. It simply takes one or more bytes (depending on the type it decodes the bytes as) from the current cursor position in the data and decodes it as it.
Not all rows necessarily display a useful value. The Inspector tries to identify invalid decodings and display Invalid in that row but that's not always possible. Just because the data inspector says these bytes mean a specific thing, doesn't mean that that's the actual meaning of those bytes.
To copy the decoded value of a row, simply click on it once.

Editing

Some rows can also be modified for the data inspector to write the encoded byte value of your input back to where it read the previous value. This is not possible for all rows.
To do this, simply double click the row you want to edit and a input text field will appear where the new value can be entered.

Settings

At the bottom of the Inspector there are multiple sliders to customize how values are being displayed in the Value column.
  • Endian: This setting specifies the endianess of read data. Switching it from Little to Big will invert the order of bytes before trying to decode it
  • Format: This setting changes the numeric base the values are displayed in such as Decimal, Hexadecimal or Octal. This only makes sense for numeric values so it only applies to these.
  • Invert: This setting bitwise inverts the value of every read byte before decoding it. As such the byte 0xFA (0b1111'1010) will become 0x05 (0b0000'0101).

Adding new Rows

Adding new rows to the inspector can either be done through a custom Plugin, when needing custom display widgets or extra speed, or it can be done through the Pattern Language by adding a new .hexpat file to the %IMHEX_PATH%/scripts/inspectors folder.
Simple custom inspector
1
#include <std/io.pat>
2
​
3
// Type definition for the custom type we want to decode
4
struct MyCustomInspector {
5
u32 value;
6
} [[format_read("custom_inspector_formatter")]];
7
​
8
// Formatter function which formats the displayed value
9
fn custom_inspector_formatter(MyCustomInspector customInspector) {
10
return std::format("Hello World: {:02X}", customInspector.value);
11
};
12
​
13
// Placements. Each individual placement becomes a new line in the inspector
14
// All values need to be placed at the current cursor position ($) to respect
15
// the cursor position set in the editor
16
// The [[name]] attribute changes the value in the Name column, otherwise
17
// 'customInspector' would be used.
18
MyCustomInspector customInspector @ $ [[name("Custom Inspector Name")]];
The next time the cursor position is changed now, the new row will show up and decode the selected bytes.
Custom Data Inspector Row
Last modified 5d ago