types

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
This skill is the authoritative reference for IDA's type system as exposed through idasql. For annotation workflows that use types, see
annotations
. For decompiler-specific type interactions (ctree, lvars, union selection, numform), see
decompiler
.

本技能是通过idasql暴露的IDA类型系统的权威参考。对于使用类型的标注工作流,请查看
annotations
技能。针对反编译器特有的类型交互(ctree、lvars、union选择、numform),请查看
decompiler
技能。

Trigger Intents

触发场景

Use this skill when user asks to:
  • create/edit structs, unions, enums, typedefs
  • inspect function prototype argument types
  • resolve hidden pointer/typedef behavior
  • apply or refine recovered data models
Route to:
  • decompiler
    for expression-level type context
  • annotations
    for applying and documenting type decisions
  • re-source
    for recursive structure-recovery workflows

当用户提出以下需求时使用本技能:
  • 创建/编辑struct、union、enum、typedef
  • 检查函数原型的参数类型
  • 解析隐藏的指针/typedef行为
  • 应用或优化已恢复的数据模型
相关技能路由:
  • 如需表达式级别的类型上下文,请使用
    decompiler
    技能
  • 如需应用并记录类型决策,请使用
    annotations
    技能
  • 如需递归结构恢复工作流,请使用
    re-source
    技能

Do This First (Warm-Start Sequence)

初始操作(快速启动流程)

sql
-- 1) Inventory local types
SELECT ordinal, name, kind, size
FROM types
ORDER BY ordinal
LIMIT 30;

-- 2) Large/high-signal structs
SELECT name, size
FROM types
WHERE is_struct = 1
ORDER BY size DESC
LIMIT 20;

-- 3) Prototype introspection sample
SELECT type_name, arg_index, arg_name, arg_type
FROM types_func_args
WHERE arg_index >= 0
LIMIT 40;
Interpretation guidance:
  • Start with inventory and prioritize large/high-fanout types.
  • Use
    types_func_args
    resolved fields for typedef-aware reasoning.

sql
-- 1) 盘点本地类型
SELECT ordinal, name, kind, size
FROM types
ORDER BY ordinal
LIMIT 30;

-- 2) 大型/高关联度结构体
SELECT name, size
FROM types
WHERE is_struct = 1
ORDER BY size DESC
LIMIT 20;

-- 3) 函数原型检查示例
SELECT type_name, arg_index, arg_name, arg_type
FROM types_func_args
WHERE arg_index >= 0
LIMIT 40;
解读指南:
  • 从类型盘点开始,优先处理大型/高引用类型。
  • 使用
    types_func_args
    的解析字段进行支持typedef的推理。

Failure and Recovery

故障排查与恢复

  • Type insert/update failed:
    • Validate declaration syntax and target ordinal/name existence.
  • Conflicting/incomplete type picture:
    • Correlate with
      decompiler
      (
      ctree_lvars
      , call args) before committing changes.
  • Unexpected disassembly rendering:
    • Re-check operand format settings and applied declarations.

  • 类型插入/更新失败:
    • 验证声明语法和目标序号/名称是否存在。
  • 类型冲突/信息不完整:
    • 在提交更改前,结合
      decompiler
      技能(
      ctree_lvars
      、调用参数)进行关联分析。
  • 反汇编显示异常:
    • 重新检查操作数格式设置和已应用的声明。

Handoff Patterns

技能交接模式

  1. types
    ->
    decompiler
    to validate semantic effect in pseudocode.
  2. types
    ->
    annotations
    for naming/comments on newly typed fields.
  3. types
    ->
    re-source
    for multi-function struct refinement.

  1. types
    ->
    decompiler
    :验证伪代码中的语义效果。
  2. types
    ->
    annotations
    :为新添加的类型字段命名/添加注释。
  3. types
    ->
    re-source
    :多函数结构体优化。

Type Tables

类型表

local_types

local_types

Local type declarations as stored in the database. Use this for quick inventory/filtering of local types; use
types*
tables for deeper editing workflows.
ColumnTypeDescription
ordinal
INTType ordinal (local type ID)
name
TEXTType name
type
TEXTDeclared type text
is_struct
INT1=struct
is_enum
INT1=enum
is_typedef
INT1=typedef
sql
-- Quick local type inventory
SELECT ordinal, name, type FROM local_types ORDER BY ordinal LIMIT 50;
For canonical schema and owner mapping, see
../connect/references/schema-catalog.md
(
local_types
).
存储在数据库中的本地类型声明。 用于快速盘点/筛选本地类型;如需深度编辑工作流,请使用
types*
系列表。
列名类型描述
ordinal
INT类型序号(本地类型ID)
name
TEXT类型名称
type
TEXT声明的类型文本
is_struct
INT1=结构体
is_enum
INT1=枚举
is_typedef
INT1=类型定义
sql
-- 快速盘点本地类型
SELECT ordinal, name, type FROM local_types ORDER BY ordinal LIMIT 50;
如需完整模式和所有者映射,请查看
../connect/references/schema-catalog.md
中的
local_types
部分。

types

types

All local type definitions. Supports INSERT (create struct/union/enum), UPDATE, and DELETE.
ColumnTypeDescription
ordinal
INTType ordinal (unique identifier)
name
TEXTType name
size
INTSize in bytes
kind
TEXTstruct/union/enum/typedef/func
is_struct
INT1=struct
is_union
INT1=union
is_enum
INT1=enum
sql
-- List all structs
SELECT ordinal, name, size FROM types WHERE is_struct = 1 ORDER BY size DESC;

-- List all enums
SELECT ordinal, name FROM types WHERE is_enum = 1;

-- Find types by name pattern
SELECT * FROM types WHERE name LIKE '%CONTEXT%';
所有本地类型定义。支持INSERT(创建struct/union/enum)、UPDATE和DELETE操作。
列名类型描述
ordinal
INT类型序号(唯一标识符)
name
TEXT类型名称
size
INT字节大小
kind
TEXTstruct/union/enum/typedef/func
is_struct
INT1=结构体
is_union
INT1=联合体
is_enum
INT1=枚举
sql
-- 列出所有结构体
SELECT ordinal, name, size FROM types WHERE is_struct = 1 ORDER BY size DESC;

-- 列出所有枚举
SELECT ordinal, name FROM types WHERE is_enum = 1;

-- 按名称模式查找类型
SELECT * FROM types WHERE name LIKE '%CONTEXT%';

Creating Types

创建类型

sql
-- Create a struct
INSERT INTO types (name, kind) VALUES ('MY_HEADER', 'struct');

-- Create a union
INSERT INTO types (name, kind) VALUES ('PARAM_UNION', 'union');

-- Create an enum
INSERT INTO types (name, kind) VALUES ('CMD_TYPE', 'enum');

-- Verify creation (get the assigned ordinal)
SELECT ordinal, name, kind FROM types WHERE name = 'MY_HEADER';
sql
-- 创建结构体
INSERT INTO types (name, kind) VALUES ('MY_HEADER', 'struct');

-- 创建联合体
INSERT INTO types (name, kind) VALUES ('PARAM_UNION', 'union');

-- 创建枚举
INSERT INTO types (name, kind) VALUES ('CMD_TYPE', 'enum');

-- 验证创建结果(获取分配的序号)
SELECT ordinal, name, kind FROM types WHERE name = 'MY_HEADER';

Deleting Types

删除类型

sql
-- Delete a type by name
DELETE FROM types WHERE name = 'MY_HEADER';

-- Delete by ordinal
DELETE FROM types WHERE ordinal = 42;

sql
-- 按名称删除类型
DELETE FROM types WHERE name = 'MY_HEADER';

-- 按序号删除类型
DELETE FROM types WHERE ordinal = 42;

types_members

types_members

Structure and union members. Supports INSERT, UPDATE, and DELETE.
ColumnTypeDescription
type_ordinal
INTParent type ordinal
type_name
TEXTParent type name
member_name
TEXTMember name
offset
INTByte offset
size
INTMember size
member_type
TEXTType string (e.g.,
int
,
void *
,
char[256]
)
mt_is_ptr
INT1=pointer
mt_is_array
INT1=array
mt_is_struct
INT1=embedded struct
sql
-- View members of a struct
SELECT member_name, member_type, offset, size
FROM types_members WHERE type_name = 'MY_HEADER'
ORDER BY offset;

-- Add members (member_type supports: int, void *, char[64], etc.)
INSERT INTO types_members (type_ordinal, member_name, member_type)
VALUES (42, 'magic', 'unsigned int');
INSERT INTO types_members (type_ordinal, member_name, member_type)
VALUES (42, 'data_ptr', 'void *');

-- Rename/retype a member
UPDATE types_members SET member_name = 'signature'
WHERE type_ordinal = 42 AND member_name = 'magic';
UPDATE types_members SET member_type = 'DWORD'
WHERE type_ordinal = 42 AND member_name = 'signature';

-- Delete a member
DELETE FROM types_members
WHERE type_ordinal = 42 AND member_name = 'reserved';

结构体和联合体成员。支持INSERT、UPDATE和DELETE操作。
列名类型描述
type_ordinal
INT父类型序号
type_name
TEXT父类型名称
member_name
TEXT成员名称
offset
INT字节偏移量
size
INT成员大小
member_type
TEXT类型字符串(例如:
int
,
void *
,
char[256]
mt_is_ptr
INT1=指针类型
mt_is_array
INT1=数组类型
mt_is_struct
INT1=嵌入式结构体
sql
-- 查看结构体成员
SELECT member_name, member_type, offset, size
FROM types_members WHERE type_name = 'MY_HEADER'
ORDER BY offset;

-- 添加成员(member_type支持:int, void *, char[64]等)
INSERT INTO types_members (type_ordinal, member_name, member_type)
VALUES (42, 'magic', 'unsigned int');
INSERT INTO types_members (type_ordinal, member_name, member_type)
VALUES (42, 'data_ptr', 'void *');

-- 重命名/修改成员类型
UPDATE types_members SET member_name = 'signature'
WHERE type_ordinal = 42 AND member_name = 'magic';
UPDATE types_members SET member_type = 'DWORD'
WHERE type_ordinal = 42 AND member_name = 'signature';

-- 删除成员
DELETE FROM types_members
WHERE type_ordinal = 42 AND member_name = 'reserved';

types_enum_values

types_enum_values

Enum constant values. Supports INSERT, UPDATE, and DELETE.
ColumnTypeDescription
type_ordinal
INTEnum type ordinal
type_name
TEXTEnum name
value_name
TEXTConstant name
value
INTConstant value
sql
-- View enum values
SELECT value_name, value FROM types_enum_values
WHERE type_name = 'CMD_TYPE'
ORDER BY value;

-- Add enum values (optional comment column supported)
INSERT INTO types_enum_values (type_ordinal, value_name, value)
VALUES (50, 'CMD_INIT', 0);
INSERT INTO types_enum_values (type_ordinal, value_name, value)
VALUES (50, 'CMD_READ', 1);

-- Rename / delete enum values
UPDATE types_enum_values SET value_name = 'CMD_OPEN'
WHERE type_ordinal = 50 AND value_name = 'CMD_INIT';
DELETE FROM types_enum_values
WHERE type_ordinal = 50 AND value_name = 'CMD_READ';

枚举常量值。支持INSERT、UPDATE和DELETE操作。
列名类型描述
type_ordinal
INT枚举类型序号
type_name
TEXT枚举名称
value_name
TEXT常量名称
value
INT常量值
sql
-- 查看枚举值
SELECT value_name, value FROM types_enum_values
WHERE type_name = 'CMD_TYPE'
ORDER BY value;

-- 添加枚举值(支持可选注释列)
INSERT INTO types_enum_values (type_ordinal, value_name, value)
VALUES (50, 'CMD_INIT', 0);
INSERT INTO types_enum_values (type_ordinal, value_name, value)
VALUES (50, 'CMD_READ', 1);

-- 重命名/删除枚举值
UPDATE types_enum_values SET value_name = 'CMD_OPEN'
WHERE type_ordinal = 50 AND value_name = 'CMD_INIT';
DELETE FROM types_enum_values
WHERE type_ordinal = 50 AND value_name = 'CMD_READ';

types_func_args

types_func_args

Function prototype arguments with deep type classification.
ColumnTypeDescription
type_ordinal
INTFunction type ordinal
type_name
TEXTFunction type name
arg_index
INTArgument index (-1 = return type, 0+ = args)
arg_name
TEXTArgument name
arg_type
TEXTArgument type string
calling_conv
TEXTCalling convention (on return row only)
带有深度类型分类的函数原型参数。
列名类型描述
type_ordinal
INT函数类型序号
type_name
TEXT函数类型名称
arg_index
INT参数索引(-1 = 返回类型,0+ = 参数)
arg_name
TEXT参数名称
arg_type
TEXT参数类型字符串
calling_conv
TEXT调用约定(仅返回行包含)

Surface-Level Type Classification

表层类型分类

Literal type as written — what you see in the declaration:
ColumnDescription
is_ptr
1 if pointer type
is_int
1 if exactly
int
is_integral
1 if int-like (int, long, short, char, bool)
is_float
1 if float/double
is_void
1 if void
is_struct
1 if struct/union
is_array
1 if array
ptr_depth
Pointer depth (int** = 2)
base_type
Type with pointers stripped
声明中显示的字面类型——即你在声明中看到的内容:
列名描述
is_ptr
1表示指针类型
is_int
1表示恰好是
int
类型
is_integral
1表示类int类型(int、long、short、char、bool)
is_float
1表示float/double类型
is_void
1表示void类型
is_struct
1表示struct/union类型
is_array
1表示数组类型
ptr_depth
指针深度(int** = 2)
base_type
去除指针后的基础类型

Resolved Type Classification

解析后类型分类

After typedef resolution — what the type actually is:
ColumnDescription
is_ptr_resolved
1 if resolved type is pointer
is_int_resolved
1 if resolved type is exactly int
is_integral_resolved
1 if resolved type is int-like
is_float_resolved
1 if resolved type is float/double
is_void_resolved
1 if resolved type is void
ptr_depth_resolved
Pointer depth after resolution
base_type_resolved
Resolved type with pointers stripped
This dual classification is critical for typedef-aware queries. For example,
HANDLE
appears as non-pointer at surface level but resolves to
void *
.
sql
-- Typedefs that hide pointers (HANDLE, HMODULE, etc.)
SELECT DISTINCT type_name, arg_type, base_type_resolved
FROM types_func_args
WHERE is_ptr = 0 AND is_ptr_resolved = 1;

-- Functions with struct parameters
SELECT type_name, arg_name, arg_type FROM types_func_args
WHERE arg_index >= 0 AND is_struct = 1;
For more
types_func_args
query patterns (string parameters, pointer counts, return type filters), see references/type-patterns.md.

解析typedef后的实际类型:
列名描述
is_ptr_resolved
1表示解析后的类型是指针
is_int_resolved
1表示解析后的类型恰好是int
is_integral_resolved
1表示解析后的类型是类int类型
is_float_resolved
1表示解析后的类型是float/double
is_void_resolved
1表示解析后的类型是void
ptr_depth_resolved
解析后的指针深度
base_type_resolved
解析后去除指针的基础类型
这种双重分类对于支持typedef的查询至关重要。例如,
HANDLE
在表层显示为非指针类型,但解析后是
void *
sql
-- 隐藏指针的typedef(HANDLE、HMODULE等)
SELECT DISTINCT type_name, arg_type, base_type_resolved
FROM types_func_args
WHERE is_ptr = 0 AND is_ptr_resolved = 1;

-- 带有结构体参数的函数
SELECT type_name, arg_name, arg_type FROM types_func_args
WHERE arg_index >= 0 AND is_struct = 1;
如需更多
types_func_args
查询模式(字符串参数、指针计数、返回类型筛选),请查看references/type-patterns.md

Type Views

类型视图

Convenience views for filtering types:
ViewDescription
types_v_structs
SELECT * FROM types WHERE is_struct = 1
types_v_unions
SELECT * FROM types WHERE is_union = 1
types_v_enums
SELECT * FROM types WHERE is_enum = 1
types_v_typedefs
SELECT * FROM types WHERE is_typedef = 1
types_v_funcs
SELECT * FROM types WHERE is_func = 1
types_v_inheritance
Struct/class inheritance relationships (baseclasses from
types_members
)
用于筛选类型的便捷视图:
视图描述
types_v_structs
SELECT * FROM types WHERE is_struct = 1
types_v_unions
SELECT * FROM types WHERE is_union = 1
types_v_enums
SELECT * FROM types WHERE is_enum = 1
types_v_typedefs
SELECT * FROM types WHERE is_typedef = 1
types_v_funcs
SELECT * FROM types WHERE is_func = 1
types_v_inheritance
结构体/类继承关系(来自
types_members
的基类信息)

types_v_inheritance
view

types_v_inheritance
视图

Shows struct/class inheritance relationships extracted from baseclass members.
ColumnTypeDescription
derived_ordinal
INTOrdinal of the derived type
derived_name
TEXTName of the derived type
base_type_name
TEXTName of the base type
base_ordinal
INTOrdinal of the base type
base_offset
INTByte offset of the base within the derived type
sql
-- Find base classes of a type
SELECT * FROM types_v_inheritance WHERE derived_name = 'MyClass';

-- Recursive ancestors
WITH RECURSIVE ancestors(name, depth) AS (
    SELECT base_type_name, 1 FROM types_v_inheritance WHERE derived_name = 'MyClass'
    UNION ALL
    SELECT i.base_type_name, a.depth + 1
    FROM types_v_inheritance i JOIN ancestors a ON i.derived_name = a.name
    WHERE a.depth < 10
)
SELECT * FROM ancestors;

展示从基类成员中提取的结构体/类继承关系。
列名类型描述
derived_ordinal
INT派生类型的序号
derived_name
TEXT派生类型的名称
base_type_name
TEXT基类类型的名称
base_ordinal
INT基类类型的序号
base_offset
INT基类在派生类型中的字节偏移量
sql
-- 查找某类型的基类
SELECT * FROM types_v_inheritance WHERE derived_name = 'MyClass';

-- 递归查找祖先类
WITH RECURSIVE ancestors(name, depth) AS (
    SELECT base_type_name, 1 FROM types_v_inheritance WHERE derived_name = 'MyClass'
    UNION ALL
    SELECT i.base_type_name, a.depth + 1
    FROM types_v_inheritance i JOIN ancestors a ON i.derived_name = a.name
    WHERE a.depth < 10
)
SELECT * FROM ancestors;

Importing C Declarations (parse_decls)

导入C语言声明(parse_decls)

parse_decls(text)
imports C declarations into the local type library. This is the most powerful way to seed types.
sql
-- Import a simple struct
SELECT parse_decls('
struct MY_HEADER {
    unsigned int magic;
    unsigned int version;
    unsigned int size;
    void *data;
};
');

-- Import with pragmas for packing (enums, typedefs, nested unions)
SELECT parse_decls('
#pragma pack(push, 1)
typedef enum operations_e { op_empty=0, op_open=11, op_read=22 } operations_e;
typedef struct command_t { operations_e cmd_id; unsigned __int64 ret; } command_t;
#pragma pack(pop)
');

-- Verify imported types
SELECT name, kind, size FROM types WHERE name IN ('command_t', 'operations_e');
For a full multi-struct
parse_decls
example with nested unions, see references/type-patterns.md.

parse_decls(text)
用于将C语言声明导入本地类型库。这是批量初始化类型最有效的方式。
sql
-- 导入简单结构体
SELECT parse_decls('
struct MY_HEADER {
    unsigned int magic;
    unsigned int version;
    unsigned int size;
    void *data;
};
');

-- 导入带打包指令的声明(枚举、typedef、嵌套联合体)
SELECT parse_decls('
#pragma pack(push, 1)
typedef enum operations_e { op_empty=0, op_open=11, op_read=22 } operations_e;
typedef struct command_t { operations_e cmd_id; unsigned __int64 ret; } command_t;
#pragma pack(pop)
');

-- 验证导入的类型
SELECT name, kind, size FROM types WHERE name IN ('command_t', 'operations_e');
如需包含嵌套联合体的完整多结构体
parse_decls
示例,请查看references/type-patterns.md

Applying Types to Functions and Variables

将类型应用于函数和变量

Function Prototypes

函数原型

sql
-- Apply type to function via prototype column
UPDATE funcs SET prototype = 'void __fastcall exec_command(command_t *cmd);'
WHERE address = 0x140001BD0;

-- Apply via set_type function
SELECT set_type(0x140001BD0, 'void __fastcall exec_command(command_t *cmd);');

-- Read current type at address
SELECT type_at(0x140001BD0);

-- Clear type (reset to auto-detected)
SELECT set_type(0x140001BD0, '');

-- Re-decompile to see effect
SELECT decompile(0x140001BD0, 1);
sql
-- 通过prototype列为函数应用类型
UPDATE funcs SET prototype = 'void __fastcall exec_command(command_t *cmd);'
WHERE address = 0x140001BD0;

-- 通过set_type函数应用类型
SELECT set_type(0x140001BD0, 'void __fastcall exec_command(command_t *cmd);');

-- 读取地址处的当前类型
SELECT type_at(0x140001BD0);

-- 清除类型(重置为自动检测)
SELECT set_type(0x140001BD0, '');

-- 重新反编译查看效果
SELECT decompile(0x140001BD0, 1);

Local Variables

局部变量

sql
-- Change local variable type
UPDATE ctree_lvars SET type = 'MY_HEADER *'
WHERE func_addr = 0x401000 AND idx = 0;

-- Change and verify
SELECT decompile(0x401000, 1);
SELECT idx, name, type FROM ctree_lvars
WHERE func_addr = 0x401000 AND idx = 0;
sql
-- 修改局部变量类型
UPDATE ctree_lvars SET type = 'MY_HEADER *'
WHERE func_addr = 0x401000 AND idx = 0;

-- 修改后验证
SELECT decompile(0x401000, 1);
SELECT idx, name, type FROM ctree_lvars
WHERE func_addr = 0x401000 AND idx = 0;

Call Sites

调用站点

Use call-site typing for indirect calls when function prototypes and local-variable types still leave a specific call under-typed.
sql
-- Discover indirect call sites first
SELECT call_ea, target_op, target_var_name, arg_count
FROM ctree_v_indirect_calls
WHERE func_addr = 0x140001BD0
ORDER BY call_ea;

-- Apply a prototype to one call site
SELECT apply_callee_type(
  0x140001C3E,
  'int __fastcall emit_message(const char *name, const char *target, int flag, const char *tag);'
);

-- Verify the persisted call-site typing
SELECT callee_type_at(0x140001C3E);
SELECT call_arg_addrs(0x140001C3E);
SELECT decompile(0x140001BD0, 1);
当函数原型和局部变量类型仍无法明确特定调用的类型时,可使用调用站点类型设置。
sql
-- 先发现间接调用站点
SELECT call_ea, target_op, target_var_name, arg_count
FROM ctree_v_indirect_calls
WHERE func_addr = 0x140001BD0
ORDER BY call_ea;

-- 为单个调用站点应用原型
SELECT apply_callee_type(
  0x140001C3E,
  'int __fastcall emit_message(const char *name, const char *target, int flag, const char *tag);'
);

-- 验证持久化的调用站点类型
SELECT callee_type_at(0x140001C3E);
SELECT call_arg_addrs(0x140001C3E);
SELECT decompile(0x140001BD0, 1);

Typing Surfaces Matrix

类型应用场景矩阵

SurfaceScopeSemantic vs render-onlyTypical use
UPDATE funcs SET prototype = ...
/
set_type()
Function/global addressSemanticGive a function or global the right declared type
UPDATE ctree_lvars SET type = ...
One decompiled local/argSemanticClean up local pointer/struct inference
apply_callee_type(call_ea, decl)
One call siteSemanticFix an indirect call when the callee prototype must be explicit
instructions.operand*_format_spec
One disassembly operandRender-onlyShow enums/struct offsets in listing output
set_union_selection*
One decompiler expressionRender-onlyChoose a union arm for nicer pseudocode
set_numform*
One decompiler expression operandRender-onlyChange numeric rendering without changing base type
应用场景作用范围语义型 vs 仅渲染型典型用途
UPDATE funcs SET prototype = ...
/
set_type()
函数/全局地址语义型为函数或全局变量设置正确的声明类型
UPDATE ctree_lvars SET type = ...
单个反编译局部变量/参数语义型优化局部指针/结构体的推断结果
apply_callee_type(call_ea, decl)
单个调用站点语义型当被调用者原型必须明确时,修复间接调用
instructions.operand*_format_spec
单个反汇编操作数仅渲染型在列表输出中显示枚举/结构体偏移量
set_union_selection*
单个反编译器表达式仅渲染型选择联合体分支以优化伪代码显示
set_numform*
单个反编译器表达式操作数仅渲染型在不改变基础类型的情况下修改数值显示方式

Names

命名

sql
-- Set a name at address
INSERT INTO names(address, name) VALUES (0x402000, 'g_config');

sql
-- 为地址设置名称
INSERT INTO names(address, name) VALUES (0x402000, 'g_config');

Struct Offset Representation in Disassembly

反汇编中的结构体偏移表示

The
instructions
table
operand*_format_spec
column applies struct offset display to disassembly operands:
sql
-- Apply struct-offset: makes `[rax+10h]` display as `[rax+MY_STRUCT.field_name]`
UPDATE instructions SET operand0_format_spec = 'stroff:MY_STRUCT,delta=0'
WHERE address = 0x401030;

-- Apply enum: `enum:CMD_TYPE`; clear back to plain: `clear`
UPDATE instructions SET operand1_format_spec = 'enum:CMD_TYPE'
WHERE address = 0x401020;

instructions
表的
operand*_format_spec
字段用于在反汇编操作数中显示结构体偏移:
sql
-- 应用结构体偏移:将`[rax+10h]`显示为`[rax+MY_STRUCT.field_name]`
UPDATE instructions SET operand0_format_spec = 'stroff:MY_STRUCT,delta=0'
WHERE address = 0x401030;

-- 应用枚举:`enum:CMD_TYPE`;恢复为默认显示:`clear`
UPDATE instructions SET operand1_format_spec = 'enum:CMD_TYPE'
WHERE address = 0x401020;

Enum/Union Rendering in Decompiled Code

反编译代码中的枚举/联合体渲染

For numform helpers (
set_numform*
) and union selection helpers (
set_union_selection*
), see
decompiler
skill.
apply_callee_type
belongs on the semantic side of the fence: it affects call analysis, unlike render-only enum/union formatting helpers.

如需numform辅助工具(
set_numform*
)和联合体选择辅助工具(
set_union_selection*
),请查看
decompiler
技能。
apply_callee_type
属于语义型操作:它会影响调用分析,不同于仅渲染型的枚举/联合体格式化工具。

Performance Rules

性能规则

TableArchitectureKey ConstraintNotes
types
Cached
ordinal
(optional)
Full cache rebuilt on demand; usually fast (<1000 types)
types_members
Cached
type_ordinal
O(1) lookup with constraint; without it iterates all types
types_enum_values
Cached
type_ordinal
O(1) lookup with constraint
types_func_args
Cached
type_ordinal
O(1) lookup with constraint
Key rules:
  • type_ordinal
    constraint pushdown gives O(1) access to a single type's members, enum values, or func args.
  • Without constraint, these tables iterate all local types. This is usually fast (most binaries have <1000 local types), but prefer filtered queries when you know the target.
  • Type views (
    types_v_structs
    , etc.) are pre-filtered — use them for categorical queries.
  • parse_decls()
    is the fastest way to seed multiple types at once (single call vs multiple INSERTs).

架构关键约束说明
types
缓存
ordinal
(可选)
按需重建完整缓存;通常速度较快(类型数<1000)
types_members
缓存
type_ordinal
带约束时为O(1)查找;无约束时遍历所有类型
types_enum_values
缓存
type_ordinal
带约束时为O(1)查找
types_func_args
缓存
type_ordinal
带约束时为O(1)查找
核心规则:
  • 传递
    type_ordinal
    约束可实现O(1)访问单个类型的成员、枚举值或函数参数。
  • 无约束时,这些表会遍历所有本地类型。通常速度较快(大多数二进制文件的本地类型数<1000),但当明确目标时优先使用过滤查询。
  • 类型视图(
    types_v_structs
    等)已预过滤——分类查询时优先使用。
  • parse_decls()
    是批量初始化多个类型的最快方式(单次调用 vs 多次INSERT)。

Related Skills

相关技能

  • annotations
    — Workflow expert: how to combine type application with renaming and commenting
  • decompiler
    — Deep ctree mechanics, union selection, numform, mutation loop
  • re-source
    — Structure recovery methodology from offset casts

  • annotations
    — 工作流专家:如何结合类型应用与重命名、注释操作
  • decompiler
    — 深入ctree机制、联合体选择、numform、循环修改
  • re-source
    — 基于偏移转换的结构恢复方法

Additional Resources

额外资源

  • For complete type workflow examples and advanced CTE patterns: references/type-patterns.md
  • 完整的类型工作流示例和高级CTE模式:references/type-patterns.md