/bnsql:disassemblyfrom bnsql
Query Binary Ninja disassembly: functions, segments, instructions, blocks. Use for code-level analysis and instruction inspection.
Ships in bnsql. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Query Binary Ninja's disassembly: functions, segments, basic blocks, and per-instruction rows.
| Table | Description | Required filter |
|---|---|---|
funcs | All detected functions | none |
segments | Memory segments (writable: INSERT/DELETE/UPDATE start_addr move, end_addr resize, perm; see "Segment writes") | none |
blocks | Basic blocks inside functions | func_addr = X for perf |
cfg_edges | Intra-function control-flow edges (from_addr, to_addr, edge_type) | func_addr = X for perf |
dominators / post_dominators | Immediate dominator/post-dominator trees | func_addr = X |
loops | Natural loops (header_addr, latch_addr, nesting depth) | func_addr = X |
switch_tables | HLIL switch bounds and slot counts; physical/default table addresses are unavailable | func_addr = X for perf |
function_frames | Stack-frame sizes and stack-base register | none |
data_items | Defined data variables, target-endian scalar preview, section, initialization | none |
instructions | One row per instruction | func_addr = X for perf |
instruction_operands | One row per rendered instruction operand | func_addr = X for perf |
entries | Entry points / exports | none |
SELECT hex(addr) AS addr, name, size
FROM funcs
ORDER BY size DESC
LIMIT 10;
SELECT name, hex(start_addr) AS start, hex(end_addr) AS end,
perm, class
FROM segments
ORDER BY start_addr;
-- Add an unbacked region (e.g. SRAM), then move it.
-- A segment's identity is (start_addr, end_addr, perm) only. Binary Ninja
-- segments have no stored name/class: `name` reads back as seg_<addr> and
-- `class` is derived from perm (CODE if executable, else DATA), so INSERT
-- takes just start_addr/end_addr/perm.
INSERT INTO segments(start_addr, end_addr, perm)
VALUES (0x20000000, 0x20005000, 6);
UPDATE segments SET start_addr = 0x20010000 WHERE start_addr = 0x20000000;
A row is one Binary Ninja segment, and a write acts on what the row is:
| Row is | DELETE | UPDATE perm | UPDATE start_addr / end_addr |
|---|---|---|---|
| a user segment (INSERT, or added by a script) | removes it | sets R/W/X | moves / resizes it |
a memory region added to the view (e.g. add_memory_region) | removes the region | sets the region's R/W/X | refused, naming the region |
| a segment the loader defined (a PE/ELF section, a raw image's mapping, a section's unbacked tail) | refused | sets R/W/X (the row's own loader region) | refused |
... is defined by the loader (memory region 'origin<PE>@0x1000') ...,
... comes from memory region 'NAME'; start_addr/end_addr of a memory region cannot be changed through segments ...) and changes nothing.perm or DELETE is
refused when the region backs other rows too (memory region 'NAME' [...) backs more than the segment at 0x...). A section and its unbacked tail (BSS)
are separate rows with separate loader regions; perm on one leaves the other.... overlaps the segment at 0x...); delete or shrink that one first.perm sets only R/W/X; the code/data flags stay.UPDATE segments SET start_addr = start_addr + 0x100000 WHERE ...).funcs until the database is
reopened; data variables, names and comments at its addresses stay after that
too. Delete them through their own tables if they should go.Failure and recovery: a loader-defined row can only have its perm changed;
to move or remove that memory, add a user segment or region instead. On an
overlap, DELETE or shrink the other segment first, then retry.
In a kernel image (0xFFFFF800..., 0xFFFFFFFF8...) every address is at or
above 0x8000000000000000, which SQL holds as a negative INTEGER. So
ORDER BY addr lists the high half first (most negative first), then the low
half, and funcs, blocks, instructions, names, comments, data_items
and segments all return and order rows that way.
0xFFFFF80000100000) or the negative
decimal, never as a decimal >= 2^63 (18446735277617577984 is a REAL
to SQLite and matches nothing; segments INSERT refuses it by name).addr > 0xFFFFF80000100000 is "signed-greater": it also includes every
low-half address. Bound the high half with AND addr < 0 (or
BETWEEN <high hex> AND -1); -1 is 0xFFFFFFFFFFFFFFFF, above every address.end_addr is -1
(0xFFFFFFFFFFFFFFFF); an end_addr of 0 or below start_addr (unsigned)
is refused.-- The function after 0xFFFFF80000100000, staying in the high half
SELECT hex(addr) AS next_func, name FROM funcs
WHERE addr > 0xFFFFF80000100000 AND addr < 0
ORDER BY addr LIMIT 1;
-- The highest function in the database (the top of the high half, if any)
SELECT hex(addr) AS top_func, name FROM funcs
WHERE addr < 0 ORDER BY addr DESC LIMIT 1;
-- Map a kernel-style region, up to the top of the address space
INSERT INTO segments(start_addr, end_addr, perm)
VALUES (0xFFFFFFFFFFFFE000, -1, 6);
SELECT hex(start_addr) AS bb_start, hex(end_addr) AS bb_end
FROM blocks
WHERE func_addr = 0x401000
ORDER BY start_addr;
-- Single-address view
SELECT disasm(0x401000);
-- Per-instruction rows inside a function (constrained!)
SELECT hex(addr) AS addr, mnemonic, operand0, operand1, operand2, disasm
FROM instructions
WHERE func_addr = 0x401000
ORDER BY addr;
-- Structured operands for the same listing
SELECT hex(addr), operand_index, text, type_name, value, size
FROM instruction_operands
WHERE func_addr = 0x401000
ORDER BY addr, operand_index;
SELECT node_addr, idom_addr, depth
FROM dominators
WHERE func_addr = 0x401000
ORDER BY depth, node_addr;
SELECT header_addr, latch_addr, depth, block_count
FROM loops
WHERE func_addr = 0x401000;
SELECT instr_addr, min_case, max_case, case_count
FROM switch_tables
WHERE func_addr = 0x401000;
Column name: the full disassembly text of an
instructionsrow is thedisasmcolumn —SELECT text FROM instructionsfails with "no such column: text".
instructions, instruction_operands, blocks, CFG/tree/loop tables, and
switch_tables are high-cost when scanned unconstrained — they walk every
function in the database. Always pass func_addr = X.
xrefs for call-graph and reference analysis (use the callers/callees
views, not func_start())decompiler for HLIL pseudocodedata for byte_search binary pattern search (table-valued)For exhaustive table column shapes and SQL function signatures, see
prompts/bnsql_agent.md in the bnsql repo. Use
PRAGMA table_xinfo(<table>) to confirm any column you're uncertain about.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
11 skills in this plugin
/analysisBNSQL analysis workflows: triage, security audit, crypto/network detection, multi-table queries./annotationsEdit Binary Ninja databases: comments, renames, types, patches. Mutations require SELECT save() to persist (explicit-save model, v0.0.9+)./connectConnect to Binary Ninja databases and bootstrap sessions. Use when starting analysis, routing to other skills, or setting up CLI/HTTP/MCP connections./dataQuery Binary Ninja strings, bytes, and binary patterns. Use the byte_search table for fast byte-pattern search.npx claudepluginhub 0xeb/bnsql-skills --plugin bnsql