Struct View applies a structure defined in a .yupat file to the current cursor position and lets you inspect binary data field by field.
.yupat files are included in the patterns folder inside the distribution package.
Open... in Struct View and select a .yupat file.A .yupat file is a C-style structure definition file with a small set of YuHex-specific directives.
UTF-8 is recommended.// ... and /* ... */ comments are supported.@entry to specify the root structure.@entry can be omitted.| Directive | Description |
|---|---|
@entry type_name |
Specifies the root structure type for Struct View. |
@member_align 0 |
Disables automatic padding between members. This is often useful for file format definitions. |
@member_align 4, @member_align 8 |
Places members using natural alignment and inserts padding when needed. |
@pointer_size 4, @pointer_size 8 |
Defines the size of pointer types in bytes. |
@sizeof_short, @sizeof_int, @sizeof_long, etc. |
Overrides the sizes of C basic types for this file. |
| Directive | Description |
|---|---|
@entry <type-name> |
Specifies the root structure type. Required when the file defines multiple structures. |
@sizeof_short <number> |
Sets the size of short types. Default: 2. |
@sizeof_int <number> |
Sets the size of int types. Default: 4. |
@sizeof_long <number> |
Sets the size of long types. Default: 8. |
@sizeof_long_long <number> |
Sets the size of long long types. Default: 8. |
@sizeof_float <number> |
Sets the size of float. Default: 4. |
@sizeof_double <number> |
Sets the size of double. Default: 8. |
@pointer_size <number> |
Sets the size of all pointer types. Default: 8. |
@member_align <number> |
Sets the maximum alignment used when placing members. Default: 8. A value of 0 disables member padding. |
struct name { ... };typedef struct tag { ... } TYPE;typedef existing_type alias;typedef struct tag TYPE; style forward declarationstype name;type name[count];type name[];type* name;union, enum, bit fields, and multi-dimensional arrays are not supported.#include, #define, and conditional compilation are not supported.[] can only appear as the last member of a structure.file = { ws | comment | directive | declaration } ;
directive = "@entry" ident
| "@sizeof_short" number
| "@sizeof_int" number
| "@sizeof_long" number
| "@sizeof_long_long" number
| "@sizeof_float" number
| "@sizeof_double" number
| "@pointer_size" number
| "@member_align" number ;
declaration = typedef_decl
| struct_decl
| forward_decl ;
typedef_decl = "typedef" type_spec declarator_list ";" ;
struct_decl = [ "typedef" ] "struct" [ ident ] "{"
member_decl* "}" [ ident ] ";" ;
forward_decl = "typedef" "struct" ident ident ";" ;
member_decl = type_spec declarator ";" ;
type_spec = builtin_type
| ident
| "struct" ident ;
declarator_list = declarator { "," declarator } ;
declarator = [ "*" ] ident [ array_suffix ] ;
array_suffix = "[" number "]"
| "[" "]" ;
@member_align 0
@pointer_size 8
@entry sample_record
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef struct nested_header nested_header_t;
struct nested_header {
WORD flags;
BYTE reserved[2];
};
typedef struct sample_record {
WORD magic;
BYTE version;
BYTE name_length;
BYTE name[8];
nested_header_t header;
void* next;
char payload[];
} sample_record;
This sample includes all currently supported directives, along with typedef, a forward declaration, normal members, a fixed-size array, a nested structure member, a pointer, and a flexible array member.
The patterns folder in the distribution package includes samples such as tftp_rrq.yupat and zip_local_file.yupat. Editing those files is a good way to get started.
| Item | Description |
|---|---|
| Offset | Shows the actual file offset relative to the current cursor position in the hex dump area. |
| Value | Shows the field value. You can switch between numeric, hex-byte, and ASCII string display modes. |
| Size | Shows the field size in bytes. Flexible arrays are shown as 1+, for example. |
| Field | Shows the structure name, member name, or <padding>. |
... is shown at the end.Use the button on the right side of the Value header to change how values are shown.
| Setting | Description |
|---|---|
| Byte Array Display | Switches between Hex Bytes and ASCII String. |
| Numeric Endian | Switches between Little Endian and Big Endian. |
| Numeric Base | Switches between Hex and Dec. |
ASCII string display follows these rules.
\0 is found, the string is shown up to that point.... is appended.| Button | Description |
|---|---|
Open... |
Selects a .yupat definition file. |
Reload (F5) |
Reloads the currently opened .yupat file. |
Clear |
Clears the current structure definition and empties the view. |
Info |
Shows or hides the definition file information pane. |