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. |
構造体ビューは、.yupat で定義した構造を現在のカーソル位置に適用し、バイナリデータをフィールド単位で確認するための機能です。
.yupat のサンプルファイルは、配布パッケージ内の patterns フォルダに含まれています。
開く... ボタンから .yupat ファイルを選択します。.yupat は、C言語の struct 宣言に、YuHex 用のディレクティブを少し加えた定義ファイルです。
UTF-8 を推奨します。// ... と /* ... */ が使えます。@entry で指定します。@entry を省略できます。| ディレクティブ | 説明 |
|---|---|
@entry 型名 |
構造体ビューの起点になる構造体型を指定します。 |
@member_align 0 |
メンバー間の自動パディングを入れません。ファイルフォーマット定義ではよく使います。 |
@member_align 4, @member_align 8 |
自然アラインメントに従ってメンバーを配置し、必要ならパディングを入れます。 |
@pointer_size 4, @pointer_size 8 |
ポインタ型を何 byte として扱うかを指定します。 |
@sizeof_short, @sizeof_int, @sizeof_long など |
C の基本型サイズをファイル単位で上書きします。 |
| ディレクティブ | 説明 |
|---|---|
@entry <type-name> |
起点となる構造体型名を指定します。構造体定義が複数ある場合は必須です。 |
@sizeof_short <number> |
short 系を何 byte として扱うかを指定します。省略時は 2 です。 |
@sizeof_int <number> |
int 系を何 byte として扱うかを指定します。省略時は 4 です。 |
@sizeof_long <number> |
long 系を何 byte として扱うかを指定します。省略時は 8 です。 |
@sizeof_long_long <number> |
long long 系を何 byte として扱うかを指定します。省略時は 8 です。 |
@sizeof_float <number> |
float を何 byte として扱うかを指定します。省略時は 4 です。 |
@sizeof_double <number> |
double を何 byte として扱うかを指定します。省略時は 8 です。 |
@pointer_size <number> |
すべてのポインタ型を何 byte として扱うかを指定します。省略時は 8 です。 |
@member_align <number> |
メンバー配置時のアラインメント上限を指定します。省略時は 8、0 の場合はメンバー間パディングを入れません。 |
struct name { ... };typedef struct tag { ... } TYPE;typedef 既存型 別名;typedef struct tag TYPE; のような前方宣言type name;type name[count];type name[];type* name;union、enum、ビットフィールド、多次元配列には対応していません。#include、#define、条件コンパイルなどのプリプロセッサ構文には対応していません。[] は、構造体の最後のメンバーにのみ置けます。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;
このサンプルには、typedef、前方宣言、通常メンバー、固定長配列、構造体メンバー、ポインタ、可変長配列が含まれています。
配布パッケージの patterns フォルダには、tftp_rrq.yupat や zip_local_file.yupat などのサンプルが含まれています。まずはそれらを編集して使い始めるのがおすすめです。
| 項目 | 説明 |
|---|---|
| オフセット | 16進ダンプ領域 のカーソル位置を基準にした実ファイル上の位置を表示します。 |
| 値 | フィールドの内容を表示します。数値、16進列、ASCII文字列など、表示形式を切り替えられます。 |
| サイズ | フィールドのサイズを byte 単位で表示します。可変長配列は 1+ のように表示されます。 |
| フィールド | 構造体名、メンバー名、または <padding> を表示します。 |
... を表示します。値 列の見出し右側にあるボタンから、表示形式を切り替えられます。
| 設定項目 | 内容 |
|---|---|
| バイト配列表示 | 16進列 と ASCII文字列 を切り替えます。 |
| 数値の並び | Little Endian と Big Endian を切り替えます。 |
| 数値の表示 | Hex と Dec を切り替えます。 |
ASCII文字列表示では、次のルールで表示します。
\0 が見つかった場合は、そこまでを文字列として表示します。... を付けます。| ボタン | 説明 |
|---|---|
開く... |
.yupat 定義ファイルを選択します。 |
再読込(F5) |
現在開いている .yupat 定義ファイルを再読込します。 |
クリア |
現在の構造体定義を外し、構造体ビューを空にします。 |
情報 |
定義ファイルの情報ペインを開閉します。 |