Loading...
Loading...
Compare original and translation side by side
analysisxrefsdisassemblyannotationsanalysisxrefsdisassemblyannotations-- 1) Current breakpoint inventory
SELECT printf('0x%X', address) AS addr, type_name, enabled
FROM breakpoints
ORDER BY address;
-- 2) Current patch inventory
SELECT printf('0x%X', ea) AS ea, original_value, patched_value
FROM patched_bytes
ORDER BY ea
LIMIT 50;
-- 3) Validate target bytes before patch
SELECT ea, value, original_value, is_patched
FROM bytes
WHERE ea = 0x401000;-- 1) 当前断点清单
SELECT printf('0x%X', address) AS addr, type_name, enabled
FROM breakpoints
ORDER BY address;
-- 2) 当前补丁清单
SELECT printf('0x%X', ea) AS ea, original_value, patched_value
FROM patched_bytes
ORDER BY ea
LIMIT 50;
-- 3) 补丁前验证目标字节
SELECT ea, value, original_value, is_patched
FROM bytes
WHERE ea = 0x401000;bytespatched_bytesrevert_byte(...)bytespatched_bytesrevert_byte(...)debuggerdisassemblydebuggerxrefsdebuggerannotationsdebuggerdisassemblydebuggerxrefsdebuggerannotations| Column | Type | RW | Description |
|---|---|---|---|
| INT | R | Breakpoint address |
| INT | RW | 1=enabled, 0=disabled |
| INT | RW | Breakpoint type (0=software, 1=hw_write, 2=hw_read, 3=hw_rdwr, 4=hw_exec) |
| TEXT | R | Type name (software, hardware_write, etc.) |
| INT | RW | Breakpoint size (for hardware breakpoints) |
| INT | RW | Breakpoint flags |
| INT | RW | Pass count before trigger |
| TEXT | RW | Condition expression |
| INT | R | Location type code |
| TEXT | R | Location type (absolute, relative, symbolic, source) |
| TEXT | R | Module path (relative breakpoints) |
| TEXT | R | Symbol name (symbolic breakpoints) |
| INT | R | Offset (relative/symbolic) |
| TEXT | R | Source file (source breakpoints) |
| INT | R | Source line number |
| INT | R | 1=hardware breakpoint |
| INT | R | 1=currently active |
| TEXT | RW | Breakpoint group name |
| INT | R | Breakpoint ID |
-- List all breakpoints
SELECT printf('0x%08X', address) as addr, type_name, enabled, condition
FROM breakpoints;
-- Add software breakpoint
INSERT INTO breakpoints (address) VALUES (0x401000);
-- Add hardware write watchpoint
INSERT INTO breakpoints (address, type, size) VALUES (0x402000, 1, 4);
-- Add conditional breakpoint
INSERT INTO breakpoints (address, condition) VALUES (0x401000, 'eax == 0');
-- Disable a breakpoint
UPDATE breakpoints SET enabled = 0 WHERE address = 0x401000;
-- Delete a breakpoint
DELETE FROM breakpoints WHERE address = 0x401000;
-- Find which functions have breakpoints
SELECT b.address, f.name, b.type_name, b.enabled
FROM breakpoints b
JOIN funcs f ON b.address >= f.address AND b.address < f.end_ea;| 列名 | 类型 | 读写权限 | 描述 |
|---|---|---|---|
| INT | R | 断点地址 |
| INT | RW | 1=启用,0=禁用 |
| INT | RW | 断点类型(0=软件断点,1=硬件写断点,2=硬件读断点,3=硬件读写断点,4=硬件执行断点) |
| TEXT | R | 类型名称(software、hardware_write等) |
| INT | RW | 断点大小(针对硬件断点) |
| INT | RW | 断点标志位 |
| INT | RW | 触发前的通过次数 |
| TEXT | RW | 条件表达式 |
| INT | R | 位置类型代码 |
| TEXT | R | 位置类型(absolute、relative、symbolic、source) |
| TEXT | R | 模块路径(相对断点) |
| TEXT | R | 符号名称(符号断点) |
| INT | R | 偏移量(相对/符号断点) |
| TEXT | R | 源文件(源断点) |
| INT | R | 源文件行号 |
| INT | R | 1=硬件断点 |
| INT | R | 1=当前处于活跃状态 |
| TEXT | RW | 断点组名称 |
| INT | R | 断点ID |
-- 列出所有断点
SELECT printf('0x%08X', address) as addr, type_name, enabled, condition
FROM breakpoints;
-- 添加软件断点
INSERT INTO breakpoints (address) VALUES (0x401000);
-- 添加硬件写监视断点
INSERT INTO breakpoints (address, type, size) VALUES (0x402000, 1, 4);
-- 添加条件断点
INSERT INTO breakpoints (address, condition) VALUES (0x401000, 'eax == 0');
-- 禁用断点
UPDATE breakpoints SET enabled = 0 WHERE address = 0x401000;
-- 删除断点
DELETE FROM breakpoints WHERE address = 0x401000;
-- 查找哪些函数设置了断点
SELECT b.address, f.name, b.type_name, b.enabled
FROM breakpoints b
JOIN funcs f ON b.address >= f.address AND b.address < f.end_ea;heads| Column | Type | RW | Description |
|---|---|---|---|
| INT | R | Byte address |
| INT | RW | Current byte value (UPDATE patches byte) |
| INT | R | Original byte value before patch |
| INT | R | 1 if byte differs from original |
| INT | R | Physical/input file offset (NULL when unavailable) |
-- Read one address
SELECT ea, value, original_value, is_patched
FROM bytes WHERE ea = 0x401000;
-- Read a byte range, including item-tail bytes
SELECT ea, value
FROM bytes
WHERE ea >= 0x401000 AND ea < 0x401010
ORDER BY ea;
-- Get item metadata separately
SELECT address, size, type, flags, disasm
FROM heads
WHERE address = 0x401000;
-- Patch via table update
UPDATE bytes SET value = 0x90 WHERE ea = 0x401000;
-- Inspect patch inventory
SELECT * FROM patched_bytes LIMIT 20;
-- Persist once done
SELECT save_database();heads| 列名 | 类型 | 读写权限 | 描述 |
|---|---|---|---|
| INT | R | 字节地址 |
| INT | RW | 当前字节值(UPDATE操作会修改字节) |
| INT | R | 补丁前的原始字节值 |
| INT | R | 1表示字节与原始值不同 |
| INT | R | 物理/输入文件偏移量(不可用时为NULL) |
-- 读取单个地址
SELECT ea, value, original_value, is_patched
FROM bytes WHERE ea = 0x401000;
-- 读取字节范围,包括项尾部字节
SELECT ea, value
FROM bytes
WHERE ea >= 0x401000 AND ea < 0x401010
ORDER BY ea;
-- 单独获取项元数据
SELECT address, size, type, flags, disasm
FROM heads
WHERE address = 0x401000;
-- 通过表更新打补丁
UPDATE bytes SET value = 0x90 WHERE ea = 0x401000;
-- 查看补丁清单
SELECT * FROM patched_bytes LIMIT 20;
-- 完成后持久化
SELECT save_database();| Column | Type | Description |
|---|---|---|
| INT | Patched address |
| INT | Original byte value |
| INT | Current patched value |
| INT | File offset when available |
SELECT printf('0x%X', ea) AS ea,
printf('0x%02X', original_value) AS old,
printf('0x%02X', patched_value) AS new
FROM patched_bytes
ORDER BY ea;| 列名 | 类型 | 描述 |
|---|---|---|
| INT | 补丁地址 |
| INT | 原始字节值 |
| INT | 当前补丁值 |
| INT | 可用时的文件偏移量 |
SELECT printf('0x%X', ea) AS ea,
printf('0x%02X', original_value) AS old,
printf('0x%02X', patched_value) AS new
FROM patched_bytes
ORDER BY ea;| Function | Description |
|---|---|
| Read |
| Read |
| Load patch bytes from a host file into memory/file image |
| Patch one byte at |
| Patch 2 bytes at |
| Patch 4 bytes at |
| Patch 8 bytes at |
| Revert one patched byte to original |
| Read original (pre-patch) byte |
-- Read bytes
SELECT bytes(0x401000, 16);
-- Patch one byte (example: NOP)
SELECT patch_byte(0x401000, 0x90) AS ok;
-- Verify current vs original
SELECT bytes(0x401000, 1) AS current, get_original_byte(0x401000) AS original;
-- Revert patch
SELECT revert_byte(0x401000) AS reverted;
-- Persist patches explicitly
SELECT save_database();load_file_bytes(...)patch_*| 函数 | 描述 |
|---|---|
| 读取 |
| 读取 |
| 将主机文件中的补丁字节加载到内存/文件镜像中 |
| 在 |
| 在 |
| 在 |
| 在 |
| 将已补丁字节回滚到原始值 |
| 读取原始(补丁前)字节 |
-- 读取字节
SELECT bytes(0x401000, 16);
-- 打一个字节补丁(示例:NOP指令)
SELECT patch_byte(0x401000, 0x90) AS ok;
-- 验证当前值与原始值
SELECT bytes(0x401000, 1) AS current, get_original_byte(0x401000) AS original;
-- 回滚补丁
SELECT revert_byte(0x401000) AS reverted;
-- 显式持久化补丁
SELECT save_database();load_file_bytes(...)patch_*-- Breakpoint on every call to VirtualAlloc (or similar)
INSERT INTO breakpoints (address)
SELECT ea FROM disasm_calls WHERE callee_name LIKE '%VirtualAlloc%';
-- Verify
SELECT printf('0x%08X', address) AS addr, type_name, enabled
FROM breakpoints;-- 为所有VirtualAlloc(或类似函数)的调用设置断点
INSERT INTO breakpoints (address)
SELECT ea FROM disasm_calls WHERE callee_name LIKE '%VirtualAlloc%';
-- 验证
SELECT printf('0x%08X', address) AS addr, type_name, enabled
FROM breakpoints;-- Hardware write watchpoint on a 4-byte field (e.g., config.flags at base+0x10)
-- First, find where the struct base is stored (requires manual analysis)
INSERT INTO breakpoints (address, type, size) VALUES (0x402010, 1, 4);
-- type=1 is hardware_write, size=4 for DWORD field-- 为4字节字段设置硬件写监视断点(例如,config.flags在基地址+0x10处)
-- 首先,找到结构体基地址的存储位置(需要手动分析)
INSERT INTO breakpoints (address, type, size) VALUES (0x402010, 1, 4);
-- type=1表示hardware_write,size=4对应DWORD字段-- Break when first argument (rcx on x64 fastcall) equals a specific enum value
INSERT INTO breakpoints (address, condition)
VALUES (0x401000, 'rcx == 3');
-- Break on error return
INSERT INTO breakpoints (address, condition)
VALUES (0x401050, 'rax == 0xFFFFFFFF');-- 当第一个参数(x64 fastcall中的rcx)等于特定枚举值时触发断点
INSERT INTO breakpoints (address, condition)
VALUES (0x401000, 'rcx == 3');
-- 在函数返回错误时触发断点
INSERT INTO breakpoints (address, condition)
VALUES (0x401050, 'rax == 0xFFFFFFFF');IsDebuggerPresent-- Find calls to IsDebuggerPresent
SELECT dc.ea, (SELECT name FROM funcs WHERE dc.func_addr >= address AND dc.func_addr < end_ea LIMIT 1) AS func_name,
disasm_at(dc.ea, 2) AS context
FROM disasm_calls dc
WHERE dc.callee_name LIKE '%IsDebuggerPresent%';
-- Patch the conditional jump after the check (example: jnz → nop nop)
-- First inspect the instruction after the call
SELECT disasm_at(0x401030, 3);
-- Then patch (adjust addresses based on actual binary)
SELECT patch_byte(0x401035, 0x90);
SELECT patch_byte(0x401036, 0x90);IsDebuggerPresent-- 查找IsDebuggerPresent的调用
SELECT dc.ea, (SELECT name FROM funcs WHERE dc.func_addr >= address AND dc.func_addr < end_ea LIMIT 1) AS func_name,
disasm_at(dc.ea, 2) AS context
FROM disasm_calls dc
WHERE dc.callee_name LIKE '%IsDebuggerPresent%';
-- 补丁检查后的条件跳转(示例:jnz → nop nop)
-- 首先检查调用后的指令
SELECT disasm_at(0x401030, 3);
-- 然后打补丁(根据实际二进制调整地址)
SELECT patch_byte(0x401035, 0x90);
SELECT patch_byte(0x401036, 0x90);-- Full patch report: what was changed and where
SELECT printf('0x%X', ea) AS address,
(SELECT name FROM funcs WHERE ea >= address AND ea < end_ea LIMIT 1) AS func_name,
printf('0x%02X', original_value) AS original,
printf('0x%02X', patched_value) AS patched,
disasm_at(ea) AS context
FROM patched_bytes
ORDER BY ea;-- 完整补丁报告:修改内容及位置
SELECT printf('0x%X', ea) AS address,
(SELECT name FROM funcs WHERE ea >= address AND ea < end_ea LIMIT 1) AS func_name,
printf('0x%02X', original_value) AS original,
printf('0x%02X', patched_value) AS patched,
disasm_at(ea) AS context
FROM patched_bytes
ORDER BY ea;| Table | Size | Constraint | Notes |
|---|---|---|---|
| Small (<100 typical) | none needed | Always fast |
| All mapped bytes | | Critical — constrain to one address or a tight range |
| Small (patch count) | none needed | Scans all patches, usually tiny |
breakpointsbytesWHERE ea = Xeapatched_bytes| 表名 | 大小 | 约束 | 说明 |
|---|---|---|---|
| 小(通常<100条) | 无需约束 | 始终快速 |
| 所有映射字节 | | 关键 — 限制为单个地址或窄范围 |
| 小(补丁数量级) | 无需约束 | 扫描所有补丁,通常速度很快 |
breakpointsbytesWHERE ea = Xeapatched_bytes