Python API
The binbun package: pip install binbun, then import binbun. Generated from its type stubs and docstrings; the guide is Python.
binbun
binbun as a Python library: open a binary, read its functions, listing, cross-references and C (with each line's machine instructions), verify what the C says; name, comment, type and correct it in transactions (each one undo step).
>>> import binbun
>>> with binbun.open("/usr/bin/true", project=False) as db:
... f = db.functions.get_by_name("main")
... print(db.decompile(f).text)
... with db.transaction("Name the entry"):
... db.functions.set_name(f, "entry_point")
import binbun loads the extension only: no thread starts, no plugin loads, until a database is opened.
binbun.connect() talks to a running binbun GUI instead (or to a script's db.serve()) over the user's own socket: its writes land in the GUI's history, one undo step per run.
The decoders need no database: binbun.x86 and binbun.aarch64, with the vocabulary they share here (Status, Branch, Token...), and one decoder for both, binbun.disassemble(data, arch=binbun.Arch.X86) (Decoder, Instruction), whose instructions give the native ones as .x86 and .aarch64.
Module functions
paths(*, sizes: bool = ...) -> dict[str, Folder]-
binbun's folders in order (
config,data,state,cache,runtime), each{"path": str | None, "size": int | None}: its path (Nonewithout a place) and the bytes of its files, not counting another of the folders inside it (Nonewithout a place or withsizes=False, which does not walk them). The GIL is released while they are walked. open(path: str | PathLike[str], *, project: str | PathLike[str] | Literal[False] | None = ..., debug: str | PathLike[str] | Literal['search', 'none'] | None = ..., symbols: Literal['never', 'ask', 'always'] = ..., view: View | Literal['exact', 'reading'] | None = ..., types: Literal['fixed', 'plain'] = ..., declarations: Literal['scoped', 'top'] = ..., names: Literal['numbered', 'registers'] = ..., warm: bool = ..., wait: Stage | int | None = ..., timeout: float | None = ..., slice: str | None = ..., signatures: bool | Literal['exact'] | None = ...) -> Database-
Opens the binary at
path(seeDatabase). Returns once the analysis reachedwait(by defaultStage.ANALYSED;None: at once). Of a universal Mach-O file, the sliceslice(x86_64,arm64e;None: this machine's instruction set's, else the first), as the CLI's--arch.signatures: library functions named by the signature packs binbun reads (True: by identity atStage.SIGNATURES, then by behaviour in the background;"exact": by identity alone;False: none).types: how the C spells integer types ("fixed":int32_t;"plain":int,long, as C programmers write them for the binary's platform).declarations: where the C declares locals ("scoped": in the blocks using them;"top": all at the top of each function).names: how the C names variables with no name of their own ("numbered":a1,v7;"registers": by where the machine code kept them,arg1,rax,var_58). The layout (braces, indentation) isDatabase.set_style's. connect(target: str | os.PathLike[str] | None = None, *, slice: str | None = None, sha256: str | None = None, socket: str | os.PathLike[str] | None = None, mode: Literal['remote', 'local'] | None = None, label: str | None = None, author: str | None = None, agent: str | None = None, protocol: tuple[int, int] = (1, 1)) -> RemoteDatabase | Database-
Connects to a running binbun GUI (or a script's
db.serve()): the database attarget(a path, or a file name:"libc.so.6";slice: its slice, of a universal Mach-O file, asDatabase.slicenames it) or with SHA-256sha256, else the one whose window had the focus last;socketnames a server directly.AmbiguousErrorif those named match several,PermissionErrorif the server is another user's,VersionErrorwithout a common protocol version.mode="remote"(the default): aRemoteDatabase.mode="local": the binary opened in this process (nothing saved; the slice the server opened, with the debug file its analysis read) following the GUI's changes, its writes made in the GUI.labelnames the run group (the script's name unless given);authormakes its writes (script:<name>unless given).agent: the connection is that agent's ("Codex"): a participant of the session with an identity of its own (held by the GUI's binbun), shown among the window's participants while connected, its writes applied and attributed to it (history, Why…), its cursor where its code works. Inbinbun mcp's interpreter,agentandmodedefault to the agent's and"local", and the database connected becomesdb. disassemble(data: bytes | bytearray | memoryview, *, arch: Arch | Literal['x86', 'aarch64'], address: int = ..., mode: binbun.x86.Mode | int | None = None) -> Decoder-
A linear sweep of
data(bytes,bytearray,memoryview...), which is ataddress, forarch(abinbun.Arch; x86 inmode, abinbun.x86.Mode, 64-bit by default; no mode for AArch64): abinbun.Decoder.
Module constants and types
__version__: str
API_VERSION: tuple[int, int]- The Python surface's own version: (major, minor);
binbun.iraside. PROTOCOL_VERSION: int- The session protocol's major version (
binbun.connect). Address = int
FunctionLike = int | Function
AddressLike = Union[int, Function, StringItem, TextHit, EntryInfo, ImportInfo, ListingLine, Instruction, Invalid, Segment, Section, Block, Named, Comment, CComment, Use, CorrectedItem]- What an
eaparameter takes: anint, or a binbun object at one address (aFunction: its entry;Segment,Section,Block: their start; the decoders' instructions too). Objects at several addresses (Xref,CLine,CToken,Verification) are aTypeErrornaming the attribute to give. _ListingRole = Literal['space', 'prefix', 'opcode_bytes', 'mnemonic', 'jump_mnemonic', 'call_mnemonic', 'return_mnemonic', 'padding_mnemonic', 'register', 'number', 'punctuation', 'keyword', 'operand_keyword', 'directive', 'code_name', 'data_name', 'import_name', 'local_name', 'string', 'comment', 'auto_comment', 'code_xref', 'data_xref']
_Event = StageReached | Progress | Changed | Failed | Unresolved | HistoryChanged | Reanalysed | ThreadChanged | Mentioned
Revision
How far a database's state has come: analyses swapped in (corrections, debug information fetched) and edits made. Every document carries the revision it was printed at.
analysis: int- Analyses before this one.
edits: int- Edits made.
Database
One binary opened (binbun.open(path)): analysed on threads of its own, its edits in its project (binbun's own, keyed by the file's SHA-256; a directory given; or none, project=False). Usable from several Python threads; heavy calls release the GIL. A context manager: with binbun.open(path) as db: closes it at the end.
Database.open(path: str | PathLike[str], *, project: str | PathLike[str] | Literal[False] | None = ..., debug: str | PathLike[str] | Literal['search', 'none'] | None = ..., symbols: Literal['never', 'ask', 'always'] = ..., view: View | Literal['exact', 'reading'] | None = ..., types: Literal['fixed', 'plain'] = ..., declarations: Literal['scoped', 'top'] = ..., names: Literal['numbered', 'registers'] = ..., warm: bool = ..., wait: Stage | int | None = ..., timeout: float | None = ..., slice: str | None = ..., signatures: bool | Literal['exact'] | None = ...) -> Databasebinbun.open, also reachable asDatabase.open.set_style(*, braces: Literal['kr', 'llvm', 'linux', 'allman'] | None = ..., types: Literal['fixed', 'plain'] | None = ..., declarations: Literal['scoped', 'top'] | None = ..., names: Literal['numbered', 'registers'] | None = ...) -> None- Changes how the C is printed from now on:
braces, the layout asbinbun decompile --stylenames it ("kr", the default: Kernighan and Ritchie, four spaces, braces only where needed;"llvm": attached braces, two spaces;"linux": tabs;"allman": every brace on a line of its own, always braces);types, how it spells integer types ("fixed":int32_t;"plain":int,long, as C programmers write them for the binary's platform);declarations, where it declares locals ("scoped": in the blocks using them;"top": all at the top of each function);names, how it names variables with no name of their own ("numbered":a1,v7;"registers": by where the machine code kept them,arg1,rax,var_58);Nonekeeps each. Documents already made keep their text; the next ones are printed again. close(*, save: bool | None = ...) -> None- Closes the database: its threads stop; every handle of it raises afterwards; a transaction open is rolled back.
save: write the edits to the project (None: as opened, each change saved as made). __enter__() -> Database
__exit__(*_exc: object) -> None
path: str- The binary's path.
name: str- The binary's file name.
sha256: str | None- The SHA-256 of the file, in hexadecimal (once the image is parsed).
slice: str | None- The slice open of a universal Mach-O file (
x86_64,arm64e), orNonefor any other file (once the image is parsed). format: FormatFormat.ELF,Format.PEorFormat.MACHO.machine: Machine- The instruction set: a
Machine. architecture: str- The instruction set's name:
x86,x86_64,aarch64,armorother. bitness: int- 32 or 64.
base_address: int- The image's base address.
start_ip: int | None- The entry point, if the image has one.
minimum_ea: int- The lowest mapped address.
maximum_ea: int- The address after the highest mapped byte.
debug_file: str | None- The file the debug information was read from, if any.
project_dir: str | None- The project's directory (
Nonewithproject=False). connected: bool- Whether this database follows a GUI's (
binbun.connect(mode="local")). stage: Stage- How far the analysis is: a
Stage. revision: Revision- The revision now.
wait(stage: Stage | int | None = ..., *, timeout: float | None = ...) -> Stage- Waits until the analysis reaches
stage(defaultStage.CALLERS; without warming,Stage.WARMEDisStage.CALLERS); the stage reached. Ctrl-C stops waiting. cancel() -> None- Stops the analysis and every question being answered.
functions: Functions- The functions.
xrefs: Xrefs- The cross-references.
names: Names- The names.
comments: Comments- The user's comments.
bookmarks: Bookmarks- The user's bookmarks.
bytes: Bytes- The bytes.
segments: Segments- The segments.
sections: Sections- The sections.
strings: Strings- The string literals.
entries: Entries- The entry points and exports.
imports: Imports- The imports.
listing: Listing- The listing.
events: Events- The session's events.
types: Types- The user's types.
corrections: Corrections- The user's corrections of recovery.
signatures: Signatures- The library signatures: the packs, the matches, rejecting one.
identity: str- The identity key (hexadecimal) this database's changes are signed by; connected, the server's (whose session makes them).
threads: Threads- The threads (
binbun._talk.Threads). suggestions: Suggestions- The suggestions (
binbun._talk.Suggestions). session: Session- The session: who is in it (
binbun._talk.Session). suggestion(label: str | None = ..., *, rationale: str | None = ..., evidence: Iterable[_Citable] | None = ..., thread: Thread | str | None = ..., supersedes: Suggestion | str | None = ...) -> SuggestionDraft- A suggestion (
binbun.SuggestionDraft):with db.suggestion("Name parse_args", rationale=..., evidence=[...]) as s:records the writes made in it on this thread instead of making them, and makes them a suggestion labelledlabelwhen it ends (s.suggestion; nothing if an exception leaves it): a person accepts it or not.evidence: query results it rests on, as they were got;thread: the thread it answers;supersedes: a suggestion of this identity's it is the next version of (its label, rationale, evidence and thread kept unless given). cursor: int | None(writable)- Connected (
binbun.connect(mode="local")): the GUI's cursor,Noneif it has none; set, the GUI goes there.CapabilityErrorin process (no GUI) or if the server has no window. selection: tuple[int, int] | None- Connected: the GUI's selection,
(start, end), if one is made; ascursor. transaction(label: str, *, author: str | None = ..., wait: bool = ...) -> Transaction- A transaction:
with db.transaction("Name crypto helpers"):makes the writes in it on this thread one undo step, made byauthor(user,script:<name>,plugin:<id>,agent; by defaultscript:and the script's file name), rolled back if an exception leaves it. An inner one joins the outer. Corrections in it are analysed anew once, at commit; withwait, leaving it returns once the new analysis is in place. undo(*, wait: bool = ...) -> HistoryEntry | None- Undoes this install's last change not undone (a key changed by someone since is left alone:
HistoryEntry.skipped); the change written,Noneif nothing is left to undo. Withwait, an undone correction's new analysis is waited for. redo(*, wait: bool = ...) -> HistoryEntry | None- Makes the last change undone again; as
undo. history: list[HistoryEntry]- The changes, newest first: every author's.
commit() -> HistoryEntry | None- Connected (
binbun.connect(mode="local")): commits the run group (the writes made outside a transaction so far, one undo step in the GUI); the change it made. In process:None(each write is a step of its own). serve(*, ui: bool = ...) -> Server- Serves this database over the user's socket, as the GUI serves its own (
binbun.connect()finds it), until theServeris closed; withui, a window's cursor and selection too (set on theServer), which clients read as the GUI's. decompile(function: FunctionLike, *, view: View | Literal['exact', 'reading'] | None = ..., timeout: float | None = ...) -> CDocument- The C of
function(aFunctionor an entry) inview(default: as opened): aCDocument. Decompiled once, kept. decompile_all(*, view: View | Literal['exact', 'reading'] | None = ..., workers: int | None = ...) -> DecompileAll- Every function's C in
view, made onworkersthreads (default: asbinbun decompiledoes):(Function, CDocument | DecompileError)pairs in address order.
Functions
The functions of a database, in address order: iterable, sized, indexed by entry (db.functions[0x401000]), with get_* lookups and the writes that name, type, create and remove functions.
__len__() -> int
__iter__() -> FunctionIter
__contains__(entry: FunctionLike, /) -> bool
__getitem__(entry: FunctionLike, /) -> Function- The function starting exactly at
entry(aFunctionor anint);NoFunctionError(aKeyError) if none does. get_all() -> FunctionIter- Every function, in address order.
get_at(ea: AddressLike) -> Function | None- The function holding
ea: the one starting there, else of those whose blocks hold it the one with the greatest entry below it;Noneif none does (or no segment holdsea). get_containing(ea: AddressLike) -> list[Function]- Every function whose blocks hold
ea(blocks can be shared), by entry (none if no segment holdsea). get_between(start: AddressLike, end: AddressLike) -> list[Function]- The functions whose entries are in
start..end, in address order. get_next(ea: AddressLike) -> Function | None- The first function whose entry is after
ea. get_by_name(name: str) -> Function | None- The function named
name: the user's name, a symbol, orsub_XXXX. entries() -> list[int]- Every function's entry, sorted (no handle per function).
set_name(function: FunctionLike, name: str | None) -> None- Names
function(aFunctionor an entry)name(Noneor empty: its own name again). set_prototype(function: FunctionLike, c: str | None) -> None- Gives
functionthe prototype Cc(None: as analysis finds it): it and its callers are decompiled again with it.CDeclarationError(with.span) if the C is refused. set_frame_name(function: FunctionLike, offset: int, name: str | None) -> None- Names the frame slot of
functionatoffset(from the stack pointer on entry)namein the listing. create(ea: AddressLike, *, end: AddressLike | None = ...) -> None- A function starting at
ea(the GUI'sP), ending atendif given: a correction (the binary is analysed anew). set_end(function: FunctionLike, end: AddressLike | None) -> Nonefunctionending atend(None: where recovery ends it; Edit Function): a correction.remove(function: FunctionLike) -> None- No function at
function's entry (Delete Function; its code stays code): a correction.
FunctionIter
An iteration over the functions, in address order. The analysis it started on must stay: StaleError if another is swapped in.
__iter__() -> FunctionIter
__next__() -> Function
__len__() -> int
Function
A function, by its entry: found again on each use (a function gone after a re-analysis raises FunctionGoneError). Equal handles name the same entry of the same database.
entry: int- The entry.
name: str- Its name: the user's, else
Self::default_name. default_name: str- Its name without the user's: the image's, else
sub_XXXX. symbol: str | None- The image's name for it (a symbol, an import thunk's import), if it has one.
user_name: str | None- The user's name, if given.
name_source: Literal['user', 'script', 'plugin', 'agent', 'signature', 'symbol', 'debug'] | None- Where its name comes from:
"user"(or"script","plugin","agent": an edit by one),"signature"(a library signature),"symbol","debug";Nonefor binbun's own (sub_…). signature_match: SignatureMatch | None- What a library signature says of it, if one matched (a match the user rejected says so).
prototype: str | None- The user's prototype, as C, if given.
returns: bool- Whether it returns.
parts: list[int]- Its parts placed apart (cold parts), by start.
landing_pads: list[int]- Its exception landing pads.
funclets: list[int]- Its funclets.
part_of: Function | None- The function it is a part of, if it is one.
blocks: list[Block]- Its blocks, by start.
ranges: list[tuple[int, int]]- Its blocks' address ranges, merged:
(start, end)pairs. source_unit: str | None- The compilation unit the debug information puts it in, if any.
callees() -> list[Function]- The functions it calls, by entry.
callers() -> list[Function]- The functions calling it, by entry.
xrefs_to() -> XrefsTo- The references to its entry: a
binbun.XrefsTo. xrefs_from() -> list[Xref]- The references it makes.
decompile(*, view: View | Literal['exact', 'reading'] | None = ..., timeout: float | None = ...) -> CDocument- Its C in
view(default: as opened): aCDocument. verify(*, view: View | Literal['exact', 'reading'] | None = ..., profile: str | None = ..., timeout: float | None = ...) -> Verification- Whether its C does what its machine code does (
binbun verify, the interactive check's fuel): aVerification. On a processor'sprofile(a shipped profile's name or a file) if given. why(*, view: View | Literal['exact', 'reading'] | None = ..., timeout: float | None = ...) -> Explanation- Why each variable has its type and name (
binbun why). origins(of: CVariable | CToken, *, view: View | Literal['exact', 'reading'] | None = ..., timeout: float | None = ...) -> Origins- Where a value comes from and goes (
binbun origin): of aCVariable, or aCToken's node. run(state: str | None = ..., *, view: View | Literal['exact', 'reading'] | None = ..., profile: str | None = ..., timeout: float | None = ...) -> Run- Its C and its machine code run from an example state (
binbun run): the state as TOML (None: a scratch state); on a processor'sprofile(a shipped profile's name or a file) if given. stages(*, view: View | Literal['exact', 'reading'] | None = ..., timeout: float | None = ...) -> Stages- It through every stage of decompilation, as text (
binbun stages): abinbun.ir.Stages. Unstable.
Block
A basic block, by its start: found again on each use.
start: int- Its first instruction's address.
end: int- The address after its last instruction.
count: int- How many instructions it has.
exit: str- How it ends:
next,jump,branch,call,return,stop,invalidorlimit. successors: list[Successor]- Where control goes next:
binbun.Successor(kind, address)s, kind one ofnext,jump,taken,not_taken,call_return,table,unwind. table: list[int] | None- The resolved targets of its computed jump, if it ends in one.
functions: list[Function]- The functions it is part of, by entry.
Xref
A cross-reference: made at from_ea (an instruction, or a pointer in data) to to_ea; a value of the revision it was read at. Equal when made at the same place, to the same address, the same way, in the same database. A call, as evidence (evidence=[...]): the call at from_ea (its caller's C line); no other kind is cited alone (cite db.xrefs.to_ea(x.to_ea): what refers there).
from_ea: int- Where it is made.
to_ea: int- What it refers to.
kind: XrefKind- How it refers: an
XrefKind. function: Function | None- The function making it (
None: a pointer in data). pointer_origin: Literal['relocation', 'scan'] | None- A pointer's origin:
relocationorscan(elseNone). relocation: str | None- A relocated pointer's relocation:
relative,absolute,glob_dat,jump_slot,baseorrebase(Mach-O). is_code: bool- Whether it is a call or a jump.
is_call: bool- Whether it is a call.
is_jump: bool- Whether it is a jump.
is_read: bool- Whether it reads.
is_write: bool- Whether it writes.
Xrefs
The cross-references of a database (binbun xrefs): to an address, made at one, within a range. Built once (the first call waits for them).
to_ea(ea: AddressLike, *, kinds: set[XrefKind] | None = ...) -> XrefsTo- The references to
ea, ofkinds(a set ofXrefKind;None: all): abinbun.XrefsTo(a list that remembersea, cited as what refers to it). from_ea(ea: AddressLike, *, kinds: set[XrefKind] | None = ...) -> list[Xref]- The references made at
ea, ofkinds. to_range(start: AddressLike, end: AddressLike) -> list[Xref]- The references to any address in
start..end. calls_to_ea(ea: AddressLike) -> list[int]- Where the calls to
eaare made. table(*, ea: AddressLike | None = ...) -> XrefTable- Every reference (or those to
ea) in columns, no object per reference: anXrefTable. unlifted: list[Function]- The functions that do not lift: only their calls and jumps are recovered.
XrefTable
Cross-references in columns: from_ea, to_ea, kind (XrefKind values) and function (entries, None for pointers in data), one row each.
from_ea: list[int]- Where each is made.
to_ea: list[int]- What each refers to.
kind: list[str]- How each refers.
function: list[int | None]- The entry of the function making each.
__len__() -> int
Names
The names of a database (db.names).
get_at(ea: AddressLike) -> str | None- The name of
ea: the user's, else the image's (a symbol, an import thunk's or pointer slot's). get_display_at(ea: AddressLike) -> str | None- The name of
eaas the listing shows it (with its dummy names:sub_,loc_,off_, a string'sa…). Builds the listing the first time. get_ea(name: str) -> int | None- The address named
name(the user's names first), if one is. get_all() -> list[Named]- Every name, by address (
binbun.Named(address, name)s): the image's, the user's over them. Names.demangle(name: str) -> str | None- An Itanium C++ mangling (
_Z…) as C++ text, if it reads as one. set_name(ea: AddressLike, name: str | None) -> None- Names
eaname(Noneor empty: its own name again): the function starting there, else the global.
Comments
The user's comments (one kind; \n separates lines).
get_at(ea: AddressLike) -> str | None- The comment at
ea, if there is one. set_at(ea: AddressLike, text: str | None) -> None- Comments
eawithtext(\nbetween lines;Noneor empty: no comment). It shows in the listing and in the C. get_all() -> list[Comment]- Every comment, by address:
binbun.Comment(address, text)s.
Bookmarks
The user's bookmarks (the GUI's Alt+M).
get_at(ea: AddressLike) -> str | None- The bookmark at
ea, if there is one. set_at(ea: AddressLike, name: str | None) -> None- Bookmarks
eaasname(Noneor empty: no bookmark). get_all() -> list[Named]- Every bookmark, by address:
binbun.Named(address, name)s.
Bytes
The bytes of the image (read-only), and the searches through it, its listing and its C.
get_bytes_at(ea: AddressLike, size: int) -> bytes | Nonesizebytes atea(zero where a segment has no file bytes);Noneif they are not all in one segment.get_byte_at(ea: AddressLike) -> int | None- The byte at
ea;Noneif unmapped. get_word_at(ea: AddressLike) -> int | None- The 16-bit word at
ea(little-endian);Noneif its bytes are not all in one segment. get_dword_at(ea: AddressLike) -> int | None- The 32-bit word at
ea; asget_word_at. get_qword_at(ea: AddressLike) -> int | None- The 64-bit word at
ea; asget_word_at. get_cstring_at(ea: AddressLike, max_length: int = ...) -> str | None- The NUL-terminated string at
ea(at mostmax_lengthbytes, UTF-8, invalid bytes replaced);Noneif unmapped. is_mapped(ea: AddressLike) -> bool- Whether
eais mapped. is_code_at(ea: AddressLike) -> bool- Whether
eais code. file_bytes() -> bytes- The whole file.
find_bytes(pattern: str | bytes, start: AddressLike | None = ..., end: AddressLike | None = ...) -> list[int]- Where
patternis in the segments, sorted: hexadecimal text with??(or?nibbles) for any ("48 8b ?? 0?"), orbytes; only instart..endif given. Searched on threads of their own. find_immediate(value: int, start: AddressLike | None = ..., end: AddressLike | None = ...) -> list[int]- The instructions with an operand that is
value(at its width or another:-1is0FFFFFFFFh), as the listing shows them; only instart..endif given. find_text(text: str, *, where: Literal['listing', 'c'] = ..., regex: bool = ..., case: bool = ..., view: View | Literal['exact', 'reading'] | None = ...) -> list[TextHit]- The lines with
text(a regular expression ifregex; its case ignored unlesscase): of the listing as shown (where="listing") or of every function's C inview(where="c", decompiling every function not yet).
TextHit
A line found by a text search: where, and its text with the matches.
address: int- Its address (a C line's first instruction, else its function's entry).
function: Function | None- The function holding it, if one does.
source: Literal['listing', 'c', 'declaration']listingorc.text: str- The line (a listing line without its address prefix), its indentation trimmed.
ranges: list[tuple[int, int]]- The matches:
(start, end)byte ranges oftext.
Segment
A segment: mapped bytes with permissions.
start: int- Its first address.
end: int- The address after it.
readable: bool- Readable.
writable: bool- Writable.
executable: bool- Executable.
file_offset: int | None- Where its bytes are in the file (
Noneif it has none there). name: str | None- The section at its start, if any.
Segments
The segments, in address order.
get_all() -> list[Segment]- Every segment.
get_at(ea: AddressLike) -> Segment | None- The segment holding
ea, if one does. __len__() -> int
__iter__() -> Iterator[Segment]
Section
A section of the file.
name: str- Its name.
start: int- Its first address.
end: int- The address after it.
is_code: bool- Whether it holds code.
Sections
The sections, as the file lists them.
get_all() -> list[Section]- Every section.
get_by_name(name: str) -> Section | None- The section named
name, if there is one. __len__() -> int
__iter__() -> Iterator[Section]
StringItem
A string literal of the image's data (binbun strings). As evidence (evidence=[...]): the string at its address; a thread's anchor (db.threads.create(item, ...)): the data item there.
address: int- Its first byte.
length: int- Its length in characters.
size: int- Its size in bytes, without the NUL.
encoding: Literal['utf8', 'utf16']utf8orutf16.text: str- Its text.
references: int- How many references there are to its first byte.
referenced: bool- Whether anything refers to it.
read_only: bool- Whether the program cannot change it.
section: str | None- The section holding it, if any.
Strings
The string literals: those referred to, and those of at least min_length characters found by scanning.
get_all(*, min_length: int = ...) -> list[StringItem]- Every literal, in address order.
get_at(ea: AddressLike) -> StringItem | None- The literal starting at
ea, if one does. __len__() -> int
__iter__() -> Iterator[StringItem]
EntryInfo
An entry point or an export.
address: int- Its address.
name: str | None- Its name, if it has one.
kind: Literal['entry', 'export']entry(the image's entry point) orexport.
Entries
The image's entry point and exported functions.
get_all() -> list[EntryInfo]- The entry point first, then the exported functions by address.
__len__() -> int
__iter__() -> Iterator[EntryInfo]
ImportInfo
An import: its pointer slot, name and library.
address: int- The address of its pointer slot.
name: str- Its name.
module: str | None- The library it comes from, if the image says.
Imports
The image's imports.
get_all() -> list[ImportInfo]- Every import, as the image lists them.
__len__() -> int
__iter__() -> Iterator[ImportInfo]
Listing
The listing of a database (built the first time it is read, on the calling thread with the GIL released): every mapped byte as lines.
__len__() -> int
line_of(ea: AddressLike) -> int- The line of the item holding
ea(else the nearest after it). lines(line: int, count: int) -> list[ListingLine]countlines from line numberline, as shown.text(start: AddressLike, end: AddressLike) -> str- The text of the lines of the items from
startup toend, one per line, as shown. set_number_form(ea: AddressLike, value: int, form: NumberForm | Literal['hex', 'decimal', 'char'] | None = ...) -> None- Writes the number
valuethe instruction ateauses inform(aNumberForm;None: as the listing and the printer choose), in the listing and the C (the GUI'sH,R). set_enum_form(ea: AddressLike, value: int, name: str) -> None- Writes the number
valuethe instruction ateauses by the constants of the enumerationnamenames (a typedef's, orenum tag; the type library's or oneTypes.definemade), in the listing and the C (the GUI'sM): the constant equal to it, or the flags it holds. RaisesCDeclarationErrorifnamenames no enumeration.
ListingLine
A line of the listing as shown.
number: int- Its number.
address: int- The address of its item.
kind: str- What it is:
instruction,data,label,comment,blank,banner,proc,end,xref, … (the listing's kinds). text: str- Its text.
tokens: list[tuple[str, _ListingRole, int | None]]- Its tokens:
(text, role, target), the role its colour (mnemonic,register,number, …; a mnemonic's by its instruction's class:jump_mnemonic,call_mnemonic,return_mnemonic,padding_mnemonic;operand_keywordforshort,qword ptr,offsetand segments), the target the address a reference goes to.
CDocument
One function's C as printed, a value of the revision it was printed at: its text, lines and tokens, each with the machine instructions it came from.
revision: Revision- The revision it was printed at.
function: Function- The function.
view: View- The view: a
View. text: str- The C file, as
binbun decompileprints the function (with the user's names and comments). lines: list[CLine]- The lines, each with the instructions it came from.
tokens: list[CToken]- The tokens, in order, each with its node and instructions.
comments: list[CComment]- The user's comments printed:
binbun.CComment(line, address, text)s, one per line of a comment. counts: dict[str, int]- What the C contains:
{"casts": …, "gotos": …, "escapes": …}. variables: list[CVariable]- The variables printed, in order of first use.
lines_of(ea: AddressLike) -> list[CLine]- The lines made from the instruction at
ea. token_at(line: int, column: int) -> CToken | None- The token at byte
columnof lineline, if one is there. variable(name: str) -> CVariable- The variable printed as
name;NoVariableErrorif none is.
CLine
A line of a function's C: as evidence (evidence=[...], alone or in a list of one document's lines), these lines of its function's C in its view; a thread's anchor (db.threads.create(line, ...)), the line by its first instruction. Equal lines are of the same database, function, view and number, and read the same.
function: Function- Its function.
number: int- Its number, from 0.
text: str- Its text.
addresses: list[int]- The instructions its expressions and statements came from, sorted.
view: View- The view of the document it was read from: a
View.
CToken
A token of a function's C: its bytes in the text, its kind, the L2 node it stands for, the instructions it came from.
index: int- Its index among the tokens.
start: int- Its first byte in the text.
end: int- The byte after it.
kind: Literal['control_keyword', 'keyword', 'type', 'builtin_type', 'function', 'local', 'parameter', 'global', 'field', 'macro', 'number', 'string', 'operator', 'punctuation', 'comment', 'label']control_keyword,keyword,type,builtin_type,function,local,parameter,global,field,macro,number,string,operator,punctuation,commentorlabel.category: Literal['keyword', 'identifier', 'type', 'literal', 'operator', 'punctuation', 'comment', 'label']- Its kind's coarse class:
keyword,identifier,type,literal,operator,punctuation,commentorlabel. automatic: bool- Whether it is a name binbun made up (
v17,sub_401000). cast: bool- Whether it is part of a cast (its parentheses or type).
node: str | None- The L2 node it stands for (
expr 12,stmt 3,var 1,type 7), if any. Unstable. text: str- Its text.
addresses: list[int]- The instructions it stands for: its node's, else its line's.
CVariable
A variable of a function's C: its printed name, its default name, kind and type, and its identity (what it was made from), which survives re-analysis as edits do: renamed and typed by it. Equal variables have the same identity and print the same.
name: str- Its name as printed.
default_name: str | None- Its name without the user's.
kind: strparameter,local,global,frameorenvironment.type: str | None
origins: list[str]- What it was made from (its identity, with
ordinal). ordinal: int- Its place among the function's variables made from the same.
function: Function- Its function.
view: View- The view of the document it was read from.
rename(name: str | None) -> None- Names it
name(None: the printer's name again), in both views: the name goes to what it was made from. set_type(c: str | None) -> None- Types it as C
c(as wide as it is;None: as analysis types it).CDeclarationError(with.span) if the C is refused.
DecompileAll
Every function's C, made on threads of their own (the GIL released while waiting), yielded in address order as (Function, CDocument | DecompileError). Dropping it stops the threads.
__iter__() -> DecompileAll
__next__() -> tuple[Function, CDocument | DecompileError]
__len__() -> int
Verification
Whether a function's C does what its machine code does: the differential check's verdict (binbun verify). As evidence (evidence=[...]): the verdict of its function in its view.
function: Function- The function.
view: View- The view checked.
verdict: Literal['agreed', 'differs', 'not_checkable']agreed,differsornot_checkable.states: int- States run (agreed).
agreed: int- States where both runs ended the same way (agreed).
skips: dict[str, int]- States not compared, by why (agreed).
difference: Literal['structure', 'run'] | None- How it differs:
structureorrun(differs). message: str | None- What differs, or why it cannot be checked.
counterexample: tuple[int, int] | None- The counterexample's seed and index among the states (a run that differs).
addresses: list[int]- The instructions where the runs part (a run that differs).
fuel: int- The fuel the runs had (blocks L1 may enter per run).
lowering_s: float- Seconds spent lowering.
checking_s: float- Seconds spent checking.
profile: str | None- The processor it ran on: a profile's label (
intel-raptor-cove r1), orNonefor the architecture.
Explanation
Why each variable of a function has its type and name (binbun why).
function: Function- The function.
items: list[ExplanationItem]- One item per variable (and the return value).
ExplanationItem
Why one variable has its type and name. As evidence (evidence=[...]): why its variable has them, in the view asked (the return value's item names no variable: not cited).
function: Function- Its function.
view: View- The view asked: a
View. var: int | None- The L2 variable, if it is one (not the return value).
name: str- Its name.
name_source: str- Where the name comes from:
user,debug,symbol,convention,declared,argument,counter,result,printer. type: str
source: str- Where the type comes from:
user,debug,prototype,platform,declaration,promoted,callee,scheme,callers,program,solver,default. clues: list[str]- The solver's clues for it, as their reasons.
conflicts: list[str]- The clues that lost a conflict.
Origins
Where a value comes from and where it goes (binbun origin).
function: Function- The function.
chains: list[OriginStep]- Each value's chain back to where it comes from.
uses: list[Use]- Where the values go:
binbun.Use(address, how)s.
OriginStep
A step of a value's origin: the value, what made it, the instructions, the steps it was made from.
value: str- The L1 value (
v12). Unstable. kind: str- What made it:
constant,undefined,parameter,load,call,operation,join,otherorcut. detail: str- What made it, in words (the constant, the register, the address loaded, the callee, the operation).
addresses: list[int]- The instructions it was made at.
inputs: list[OriginStep]- The steps it was made from.
Run
A function's C and its machine code run from an example state (binbun run).
agree: bool | None- Where both returned, whether the machine's result is the C's; where both stopped at a call needing a stub, whether the same callee; else
None. stop: Literal['returned', 'needs_stub', 'fault', 'trap', 'undetermined', 'escape', 'unreachable', 'out_of_steps', 'cancelled', 'malformed']- How the C's run stopped:
returned,needs_stub,fault,trap,undetermined,escape,unreachable,out_of_steps,cancelledormalformed. detail: str- How it stopped, in words (the value returned, the access that faulted, the callee needing a stub).
statements: int- The statements the C's run executed.
calls: int- The calls it made.
machine: bool- Whether the machine code ran too.
profile: str | None- The processor it ran on: a profile's label (
intel-raptor-cove r1), orNonefor the architecture.
Stages
A function through every stage of decompilation (binbun stages), as text. Unstable: the stages and their text change with the engine.
function: Function- The function.
stages: list[StageText]- The stages, in order.
__len__() -> int
get(name: str) -> StageText | None- The stage named
name(machine, a pass's name,c), if there is one. names() -> list[str]- The names of the stages, in order.
StageText
One stage of a function's decompilation, as text. Unstable.
name: str- Its name.
label: str- What the viewer calls it.
level: Literal['machine', 'l1', 'l2', 'c']machine,l1,l2orc.text: str- Its text.
lines: list[list[int]]- The instructions each line came from.
Events
The events of a database (EventQueues).
subscribe(*kinds: type[Any]) -> EventQueue- A queue of every event from now on (of
kinds, event classes, if given); the first is the stage reached.
EventQueue
Events as they come, pulled with get or by iterating (which ends when the database closes or the queue is closed).
get(timeout: float | None = ...) -> _Event | None- The next event, waiting up to
timeoutseconds (None: until one comes);Noneif none came, or the queue is closed. close() -> None- Stops the queue: no more events.
__iter__() -> EventQueue
__next__() -> _Event
StageReached
The analysis reached a stage.
stage: Stage- The stage: a
Stage.
Progress
The warming went on: warmed of total functions' interfaces found.
warmed: int- Functions warmed.
total: int- Functions to warm.
Changed
An edit or a stage changed documents or listing lines.
revision: Revision | None- The revision after it (
Nonefrom a server, which does not say). functions: list[Function | RemoteFunction]- The functions whose C reads differently now.
listing_ranges: list[tuple[int, int]]- The address ranges whose listing lines read differently:
(start, end)pairs.
Failed
Opening failed, or an edit could not be saved.
message: str- Why.
Unresolved
Edits found not to resolve (their function or address gone).
edits: list[str]- Each edit and why, as text.
HistoryChanged
Changes entered the history (made, undone, made again): newest first.
entries: list[HistoryEntry]- The changes.
Reanalysed
The binary analysed anew (corrections, debug information fetched) took the place of the analysis before: handles find their functions again by entry.
revision: Revision- The revision of the new analysis.
kept: int | None- How many functions of the analysis before the new one has too (
Nonefrom a server, which does not say).
ThreadChanged
Conversation came, made here or taken from elsewhere: threads opened, posted to, resolved; posts edited or deleted; suggestions made or decided (db.threads.get(id), db.suggestions.get(id)).
threads: list[str]- The threads with something new, by id.
suggestions: list[str]- The suggestions made or decided, by id.
Mentioned
A new post mentions this database's identity: the person, or one of its scripts or agents (mention.agent: "script:helper", whom a script compares with its own author).
thread: str- The post's thread, by id.
post: str- The post, by id.
author: Author- Who posted it: a
binbun.Author. mention: Mention- Whom it mentions: a
binbun.Mention(this identity'skey, and its script or agent,agent;None: the person). body: str- What the post says.
Transaction
A transaction (with db.transaction(label):): one undo step of the writes made in it on this thread, rolled back if an exception leaves it; an inner one joins the outer. Corrections made in it are analysed anew once, at commit; with wait, leaving it returns once the new analysis is swapped in.
label: str- What it does.
author: str- Who makes it:
script:<name>unless given. entry: HistoryEntry | None- The change it made, once committed (
Nonebefore, for an inner transaction, or if it wrote nothing). __enter__() -> Transaction
__exit__(exc_type: object, _exc: object = ..., _traceback: object = ...) -> bool
HistoryEntry
A change in the history: what it did, who made it, when.
id: str- The change's id (its author's chain and its number there); empty for a private bookmark's edit undone or made again alone (the GUI's, local: no change).
label: str- What it did (
Rename crypto helpers,Undo: Comment). time: float- When, in seconds since the Unix epoch.
edits: int- How many edits it made.
mine: bool- Whether this install made it.
skipped: list[str]- What an undo or redo left alone (changed by someone since).
author: Author- Who made it: a
binbun.Author(via:user,script:<name>,plugin:<id>,agent, orundo,redo,accept...). suggested_by: Author | None- Who made the suggestion it accepted, if it accepted one (a
binbun.Author;authoris then the person who accepted it, viaaccept).
StructMember
A member of a StructLayout.
name: str- Its name (empty: an anonymous struct or union).
bit_offset: int- Its offset in bits.
size: int- Its size in bytes.
bit_width: int | None- A bit-field's width in bits.
Connection
A connection to a server (a running GUI, a script's db.serve()), found by its discovery file: the one database open, or the one at target (a path; slice: its slice, of a universal Mach-O file) or with SHA-256 sha256, or the server at socket. Made by binbun.connect(), which wraps it.
Connection(target: str | None = ..., *, slice: str | None = ..., sha256: str | None = ..., socket: str | PathLike[str] | None = ..., label: str | None = ..., author: str | None = ..., agent: str | None = ..., agent_version: str | None = ..., protocol: tuple[int, int] = ...)
server: str- The server:
binbun-gui/and the app's version. protocol: int- The protocol version chosen.
engine: str- The server's engine version.
capabilities: list[str]- What the server can do.
identity: str | None- The server's identity key (hexadecimal): the key its changes are signed by, which a mention of its scripts names.
database: dict[str, Any]- The database attached:
{"id", "path", "name", "sha256", "debug" (the debug file its analysis read), "stage", "revision"}. label: str- The run group's label.
cell(label: str) -> None- Makes the run group a console cell's from now on: labelled
label, opened by the first write or transaction, the transactions begun in it joining it (an inner one rolled back rolls the cell's writes back too, as nested transactions do), committed byfinish(). The run group open, if any, keeps its label. author: str- Who makes the writes outside a transaction.
agent: str | None- The agent's identity key (hexadecimal) if this connection is an agent's (
agent=): the key its writes are signed by, which a mention of it names. presence(address: int | None) -> None- Says where the agent's code works (its cursor in the GUI, as a collaborator's); nothing for a connection of no agent, or a server without it.
requests: int- How many requests were sent (a call refused for a capability the server lacks sends none).
closed: bool- Whether the connection is lost or closed.
call(method: str, params: Any = ..., *, timeout: float | None = ...) -> Any- Request
methodwithparams(JSON-able), its result as Python values.CapabilityErrorbefore sending when the server lacks what it needs;TimeoutErrorif no answer comes withintimeoutseconds (the server goes on). function_entries() -> list[int]- Every function's entry, in order, in one request (
functions.entries, packed). write(write: dict[str, Any]) -> dict[str, Any]- Makes
write(a dict in the protocol's form,{"write": "comment", "address": "0x…", "text": …}): in the transaction open, else in the run group. What it did ({"key": …, "corrected": …}). begin(label: str, author: str | None = ...) -> None- Opens a transaction (the run group committed first).
commit() -> tuple[HistoryEntry | None, bool]- Commits the transaction open: the change made, whether the binary is analysed anew.
rollback() -> None- Rolls the transaction open back.
finish() -> HistoryEntry | None- Commits the run group, if open: the change it made.
undo() -> HistoryEntry | None- Undoes this install's last change in the server.
redo() -> HistoryEntry | None- Makes the last change undone again.
history() -> list[HistoryEntry]- The server's history, newest first.
settle() -> None- Waits until no new analysis is under way.
notification(timeout: float = ...) -> tuple[str, Any] | None- The next notification,
(method, params), if one comes withintimeoutseconds (aftercall("events.subscribe")). close(*, commit: bool = ...) -> None- Ends the connection; with
commit(the default), the run group committed first. A transaction left open is rolled back by the server.
Server
db.serve(): a server over a database opened in process, as the GUI runs one (its socket in $XDG_RUNTIME_DIR/binbun/, on Windows a named pipe told in %LOCALAPPDATA%\binbun\run\; found by binbun.connect()), until closed; with ui=True, standing in for a GUI's window too: a cursor and a selection its clients read with ui.cursor and ui.selection (a client's jump moves the cursor).
socket: str- Its socket.
cursor: int | None(writable)- The cursor its clients read (
ui.cursor;db.jump()moves it);serve(ui=True)only. selection: tuple[int, int] | None(writable)- The selection its clients read (
ui.selection):(start, end);serve(ui=True)only. agents: list[dict[str, Any]]- The agents connected, as its window would show them: each one's
name,key(hexadecimal),versionandaddress(where its code works, if it said);serve(ui=True)only. close() -> None- Stops serving: the socket and discovery file removed; connections end.
__enter__() -> Server
__exit__(*_exc: object) -> None
StructLayout
A struct's layout as C defines it (db.types.layout).
key: str- Its key (
struct pair). size: int- Its size in bytes.
members: list[StructMember]- Its members, in order.
Types
The user's types (db.types): definitions, globals' and synthesised structs' types, members; C checked without writing.
define(c: str) -> str- Defines the struct, union, enumeration or typedef C
cdefines (the last, if several) as the user's; the key it defines (struct pair).CDeclarationError(with.span) if the C is refused. undefine(key: str) -> None- Drops the user's definition of
key. set_global_type(ea: AddressLike, c: str | None) -> None- Types the global at
eaas Cc(None: as analysis types it). set_struct(struct: str | tuple[FunctionLike, int], c: str | None) -> None- Gives a synthesised struct (its key,
struct struct_main_1, or(function entry, number)) the user's definitionc(None: the table's again). rename_member(key: str, member: str, name: str) -> None- Names member
memberof structkey(struct pair)name(a C identifier). retype_member(key: str, member: str, c: str) -> None- Types member
memberof structkeyas Cc, as wide as it is. resize_member(key: str, member: str, c: str) -> None- Types member
memberof structkeyas Cc, of any width the layout holds (the GUI'sD). check(target: CVariable | AddressLike, c: str) -> None- Whether C
ccan typetarget(aFunction's prototype, aCVariable, a global's address), without writing:CDeclarationErrorif not. layout(c: str) -> StructLayout- The layout of the struct C
cdefines, without defining it. definition(key: str) -> str | None- The definition of
keyas C: the user's, else the type library's, if either defines it. names() -> list[str]- The names a type may be written with, sorted.
get_global_type(ea: AddressLike) -> str | None- The user's type of the global at
ea, as C. definitions() -> list[Definition]- The user's definitions, by key:
binbun.Definition(key, c)s (names()lists the type library's too).
Corrections
The user's corrections of recovery (db.corrections, the GUI's C, U, D, A, *): each is a write; the binary is analysed anew with them (once per transaction) and swapped in.
make_code(ea: AddressLike) -> None- Code from
ea(the GUI'sC). make_data(ea: AddressLike, unit: Unit | Literal['byte', 'word', 'dword', 'qword', 'string', 'utf16'], count: int = ...) -> Nonecountunits ofunit(aUnit) atea(the GUI'sD,*).make_string(ea: AddressLike) -> None- The string the bytes at
eastart, C or UTF-16 by what they are (the GUI'sA). undefine(ea: AddressLike, size: int) -> Nonesizebytes fromeatyped as nothing (the GUI'sU).clear(ea: AddressLike) -> None- Drops the user's item starting at
ea. items() -> list[CorrectedItem]- The user's items:
binbun.CorrectedItem(address, kind, size)s, kindcode,undefinedor a unit's name (dword,string); size in bytes. functions() -> list[CorrectedFunction]- The functions the user made or ended:
binbun.CorrectedFunction(start, end)s (endNone: where recovery ends it). Those deleted:deleted(). deleted() -> list[int]- The entries of the functions the user deleted.
SignatureMatch
What a library signature says of a function: the pack, the library function and how it matched.
pack: str- The pack and its revision (
musl-1.2.5@1). library: str- The library (
musl). version: str- Its version.
name: str- The library function's name.
object: str- The object it comes from.
how: Literal['exact', 'behaviour']- How it matched:
exactorbehaviour. states: int | None- For a match by behaviour, the states that agreed.
ruled_out: int | None- For a match by behaviour, the candidates ruled out.
prototype: str | None- The library's prototype, as C, if the pack has one.
returns: bool- Whether it returns:
Falsewhere the type library declares it noreturn. rejected: bool- Whether the user rejected the match.
Signatures
The library signatures of a database (db.signatures).
packs: list[str]- The packs binbun reads (
library-version@revision): the user's own, those installed with binbun, andBINBUN_SIGNATURES's. matches() -> list[FunctionMatch]- Every match, by entry (those the user rejected too):
binbun.FunctionMatch(function, match)s. reject(function: FunctionLike) -> None- Rejects the match of
function(aFunctionor its entry): its name and prototype as before, and no later run applies it again; undone, it is back.
Branch
What an instruction does to the flow of control, as it would at its address (binbun_branch): kind, whether it is conditional, whether execution falls_through to the next instruction, and where it goes (target_kind, target).
kind: BranchKind- How it transfers control: a
binbun.BranchKind. conditional: bool- Whether the jump or trap happens only when a condition holds.
falls_through: bool- Whether execution can continue with the next instruction.
target_kind: TargetKind- Where it goes: a
binbun.TargetKind. target: int | None- The target address (
ADDRESS), the address of the pointer to it (POINTER) or the far offset (FAR);Nonefor the others. pointer_size: int- The pointer's size in bytes, for a
POINTERtarget; else 0. selector: int- The segment selector, for a
FARtarget; else 0.
Token
One token of an instruction's text (binbun_token): its kind, the operand it is part of (None for the mnemonic, prefixes, separators and the whitespace between them), where it is in the text, the number it stands for, and its text.
kind: TokenKind- What it is: a
binbun.TokenKind. operand: int | None- Which operand (an index into the instruction's
operands) it is part of;Nonefor none. offset: int- Where the token starts in the instruction's text.
length: int- Its length.
value: int- What it stands for: an immediate's, an integer's, an address's or a displacement's value (two's complement when negative), a float's bits, an x86 register's number; 0 for the others.
text: str- Its text.
Invalid
Bytes a decoder stepped over because they are no instruction: where they are, why (status), and how many (1 on x86, where a sweep resynchronises byte by byte; 4 on AArch64, fewer at the end of the buffer).
address: int- The address of the first byte.
status: Status- Why the bytes are no instruction: a
binbun.Status. length: int- How many bytes the decoder stepped over.
bytes: bytes- The bytes.
__len__() -> int
Sweep
A linear sweep in columns, one entry per instruction or invalid step, without an object per instruction: addresses, lengths, statuses (0, Status.OK, for an instruction), branch_kinds and target_kinds (BranchKind, TargetKind numbers), targets (as Branch.target). Each read of a column makes a new list.
addresses: list[int]- Each instruction's address.
lengths: list[int]- Each one's length in bytes.
statuses: list[int]- Each one's status: 0 for an instruction, else why it is none.
branch_kinds: list[int]- Each one's
BranchKindnumber (0 for an invalid step). target_kinds: list[int]- Each one's
TargetKindnumber. targets: list[int | None]- Each one's target, as
Branch.target. __len__() -> int
Instruction
One instruction of either architecture at its address: the facts both share (arch, address, length, bytes, mnemonic, branch, registers_read, registers_written, text()), and the native instruction (x86 or aarch64, the other None) for the rest. A value: equal when the same bytes are decoded at the same address for the same architecture (and x86 mode).
arch: Arch- The architecture: a
binbun.Arch(the x86 mode isx86.mode). address: int- Its address.
length: int- Its length in bytes: 1 to 15 on x86, 4 on AArch64.
__len__() -> int
bytes: builtins.bytes- Its bytes (AArch64's word little-endian).
mnemonic: str- The mnemonic its text writes, lower case: on x86 the word after any prefix words (
movsbofrep movsb, wherex86.mnemonicis XED'sREP_MOVSB), on AArch64 after alias selection (mov,b.eq; Arm's isaarch64.encoding_mnemonic). branch: Branch- What it does to the flow of control at its address.
registers_read: tuple[str, ...]- The registers it may read, by name, each once: the decoders' operands (memory operands' address registers included) and implicit registers, the condition flags left out (
x86.flags,aarch64.flags). Names are the architecture's (alandrax,w0andx0are different registers). registers_written: tuple[str, ...]- The registers it may write, as
registers_read. x86: binbun.x86.Instruction | None- The x86 instruction (
binbun.x86.Instruction), orNonefor AArch64. aarch64: binbun.aarch64.Instruction | None- The AArch64 instruction (
binbun.aarch64.Instruction), orNonefor x86. text(options: TextOptions | int = 0) -> str- Its text, as the native decoder writes it (
x86.text,aarch64.text): Intel syntax as XED writes it, or LLVM's (a tab after the mnemonic); branch targets as addresses, or on AArch64 as offsets withTextOptions.RELATIVE_LABELS. x86 text has no options: anything butTextOptions.DEFAULTis aValueError.
Decoder
A linear sweep over a buffer of code, which is at address, for arch (x86 in mode, 64-bit by default): an iterator of binbun.Instructions and, where bytes are no instruction, binbun.Invalid steps as the native decoders take them (one byte on x86, four on AArch64, fewer at the end of the buffer). offset is where the next instruction is in the buffer; set it to continue elsewhere.
Decoder(data: bytes | bytearray | memoryview, *, arch: Arch | Literal['x86', 'aarch64'], address: int = ..., mode: binbun.x86.Mode | int | None = None)
arch: Arch- The architecture: a
binbun.Arch. offset: int(writable)- Where the next instruction is in the buffer.
address: int- The address of the next instruction.
__iter__() -> Iterator[Instruction | Invalid]
__next__() -> Instruction | Invalid
XrefsTo
class XrefsTo(list['Xref'])
The references to an address (db.xrefs.to_ea(ea), f.xrefs_to()): a list of binbun.Xref that keeps the address, to_ea, even when empty. As evidence (evidence=[...]): what refers to to_ea, every kind (a kinds filter is not recorded).
XrefsTo(to_ea: int, xrefs: Iterable[Xref] = ())
to_ea: int
Named
class Named(NamedTuple)
A name at an address (db.names.get_all(), db.bookmarks.get_all()).
address: int
name: str- The name.
Comment
class Comment(NamedTuple)
A comment at an address (db.comments.get_all()).
address: int
text: str
CComment
class CComment(NamedTuple)
A user's comment as the C prints it (CDocument.comments): its line's number, the address it is at, one line of its text.
line: int
address: int
text: str
Use
class Use(NamedTuple)
Where a value goes (Origins.uses): the instruction, and how it is used there, in words.
address: int
how: str
Successor
class Successor(NamedTuple)
Where control goes from a block (Block.successors): how (next, jump, taken, not_taken, call_return, table, unwind) and the address.
kind: str
address: int
CorrectedItem
class CorrectedItem(NamedTuple)
An item the user made (db.corrections.items()): where, its kind (code, undefined or a unit's name: dword, string) and its size in bytes.
address: int
kind: str
size: int
CorrectedFunction
class CorrectedFunction(NamedTuple)
A function the user made or ended (db.corrections.functions()): its entry and the address after it (None: where recovery ends it).
start: int
end: int | None
FunctionMatch
class FunctionMatch(NamedTuple)
A function a library signature matched (db.signatures.matches()) and what the signature says.
function: Function
match: SignatureMatch
Definition
class Definition(NamedTuple)
A type the user defined (db.types.definitions()): the key it defines (struct pair) and its C.
key: str
c: str
Enumerations
The enums of binbun's Python API (the extension builds its values from these).
Stage
class Stage(enum.IntEnum)
How far the analysis of an opened binary is (binbun_session::Stage).
OPENING = 0
IMAGE = 1
ANALYSED = 2
REFERENCED = 3
SIGNATURES = 4
CALLERS = 5
WARMED = 6View
class View(enum.Enum)
Which C: the exact C, or the reading view (checks assumed away).
EXACT = 'exact'
READING = 'reading'Format
class Format(enum.Enum)
The file's format.
ELF = 'elf'
PE = 'pe'
MACHO = 'macho'Machine
class Machine(enum.Enum)
The instruction set the file says its code is for.
X86 = 'x86'
X86_64 = 'x86_64'
AARCH64 = 'aarch64'
ARM = 'arm'
OTHER = 'other'Arch
class Arch(enum.Enum)
The architecture binbun.Decoder decodes for (x86 in a binbun.x86.Mode).
X86 = 'x86'
AARCH64 = 'aarch64'XrefKind
class XrefKind(enum.Enum)
How a cross-reference refers (binbun::references::Kind).
CALL = 'call'
JUMP = 'jump'
READ = 'read'
WRITE = 'write'
ADDRESS = 'address'
POINTER = 'pointer'NumberForm
class NumberForm(enum.Enum)
How a number is written in the listing and the C (the H and R keys; binbun_session::NumberForm).
HEX = 'hex'
DECIMAL = 'decimal'
CHAR = 'char'Unit
class Unit(enum.Enum)
The units of a data item made by a correction (binbun::corrections::Unit).
BYTE = 'byte'
WORD = 'word'
DWORD = 'dword'
QWORD = 'qword'
STRING = 'string'
UTF16 = 'utf16'Status
class Status(enum.IntEnum)
What a decode came to (binbun_status); from INVALID to 63, why the bytes are no instruction.
OK = 0
END = 1
TRUNCATED = 2
NULL_POINTER = 3
BAD_ARGUMENT = 4
FAILED = 5
INVALID = 16
X86_TOO_LONG = 17
X86_INVALID_MODE = 18
X86_BAD_REGISTER = 19
X86_BAD_LOCK_PREFIX = 20
X86_BAD_LEGACY_PREFIX = 21
X86_BAD_REX_PREFIX = 22
X86_BAD_MAP = 23
X86_BAD_EVEX_V_PRIME = 24
X86_BAD_EVEX_ZEROING = 25
X86_BAD_EVEX_LENGTH = 26
X86_GATHER_REGISTERS = 27
X86_BAD_REGISTER_MATCH = 28
AARCH64_UNALLOCATED = 32
AARCH64_UNDEFINED = 33
AARCH64_UNPREDICTABLE = 34
is_invalid: bool- Whether the bytes are no instruction (
BINBUN_STATUS_IS_INVALID).
Access
class Access(enum.IntFlag)
How an instruction may access an operand (BINBUN_ACCESS_*).
READ = 1
WRITE = 2BranchKind
class BranchKind(enum.IntEnum)
How an instruction transfers control (binbun_branch_kind).
NONE = 0
JUMP = 1
CALL = 2
RETURN = 3
TRAP = 4
SYSTEM_CALL = 5
EXCEPTION_RETURN = 6
HALT = 7TargetKind
class TargetKind(enum.IntEnum)
Where a jump or call goes, as far as the instruction tells (binbun_target_kind).
NONE = 0
ADDRESS = 1
POINTER = 2
INDIRECT = 3
FAR = 4TextOptions
class TextOptions(enum.IntFlag)
How to write an instruction's text (BINBUN_TEXT_*).
DEFAULT = 0
RELATIVE_LABELS = 1TokenKind
class TokenKind(enum.IntEnum)
What a token of an instruction's text is (binbun_token_kind).
MNEMONIC = 0
PREFIX = 1
REGISTER = 2
IMMEDIATE = 3
INTEGER = 4
FLOAT = 5
ADDRESS = 6
DISPLACEMENT = 7
SYMBOL = 8
PUNCTUATION = 9
SEPARATOR = 10
WHITESPACE = 11Exceptions
The exceptions binbun raises.
Each derives from BinbunError and, where one fits, from the built-in it refines, so except LookupError catches an InvalidAddressError.
BinbunError
class BinbunError(Exception)
The root of binbun's exceptions.
OpenError
class OpenError(BinbunError, OSError)
The file cannot be read, or is no image binbun reads.
ProjectError
class ProjectError(BinbunError)
The project cannot be read or written.
NotAnalysedError
class NotAnalysedError(BinbunError, RuntimeError)
A read needs a stage the analysis did not reach (it stopped).
InvalidAddressError
class InvalidAddressError(BinbunError, LookupError)
An address in no segment.
NoFunctionError
class NoFunctionError(BinbunError, KeyError)
No function starts at the address (db.functions[ea]: a KeyError, as indexing raises).
NoVariableError
class NoVariableError(BinbunError, LookupError)
The document has no such variable.
StaleError
class StaleError(BinbunError)
The analysis changed under an iterator or a handle.
FunctionGoneError
class FunctionGoneError(StaleError)
A function handle's entry is no longer a function.
DecompileError
class DecompileError(BinbunError)
The function does not decompile (as binbun decompile says).
TimeoutError
class TimeoutError(BinbunError, builtins.TimeoutError)
A timeout= elapsed; the work goes on and its result is kept.
CancelledError
class CancelledError(BinbunError)
Ctrl-C or db.cancel() stopped it.
CDeclarationError
class CDeclarationError(BinbunError, ValueError)
C refused (a prototype, a type, a definition): message says why, span is the (start, end) bytes of c at fault.
CDeclarationError(message: str, span: tuple[int, int] = (0, 0), c: str = '')
message: str
span: tuple[int, int]
c: str
CorrectionError
class CorrectionError(BinbunError, ValueError)
A correction of recovery cannot apply there (the reason).
TransactionError
class TransactionError(BinbunError)
A transaction misused: none open, rolled back by an inner one, or another thread's open while this one writes.
ConversationError
class ConversationError(BinbunError)
A thread, post or suggestion cannot be written: none such, another's (only its author edits a post; only its author or an owner deletes it), or a suggestion no longer pending.
ReadOnlyError
class ReadOnlyError(BinbunError)
Writes are refused here.
CapabilityError
class CapabilityError(BinbunError)
The server connected to lacks what the call needs (raised before anything is sent).
AmbiguousError
class AmbiguousError(BinbunError, LookupError)
A lookup that names none or several: no database, or several open and none named; a name several members of the session have. The message lists them.
ProtocolError
class ProtocolError(BinbunError)
A malformed or unexpected message on the connection.
VersionError
class VersionError(BinbunError)
The client and the server speak no protocol version in common.
ConnectionError
class ConnectionError(BinbunError, builtins.ConnectionError)
The connection to the server failed or was lost.
PermissionError
class PermissionError(BinbunError, builtins.PermissionError)
The server's directory or socket is another user's.
DecodeError
class DecodeError(BinbunError, ValueError)
Bytes that are no instruction (binbun.x86, binbun.aarch64): status says why, address where.
DecodeError(message: str, status: Status, address: int)
status: Status
address: int
Connecting to the app
binbun.connect(): a script talking to a running binbun GUI (or to a script's db.serve()) over the user's own Unix socket (on Windows a named pipe).
Two modes:
mode="remote"(the default): aRemoteDatabase, whose reads and writes all cross the socket. It reads what is cheap to send: the functions (entries, names, address ranges), names, comments, bookmarks, a function's C as text, the GUI's cursor and selection. Where it cannot do whatbinbun.Databasedoes, the name is absent.mode="local": the same binary opened in this process (abinbun.Database, nothing saved), following the GUI's change log (each change the GUI makes is taken here as it is made), its writes still made in the GUI, so that they land in the GUI's history. Every read ofbinbun.Databaseworks, at in-process speed.
Writes made outside a transaction form the run group: one undo step in the GUI, labelled label (the script's name unless given), committed by db.commit(), db.close(), leaving with binbun.connect() as db:, or the interpreter's exit. A db.transaction() begun meanwhile commits the run group first and is an undo step of its own. A script killed mid-group leaves nothing: the GUI rolls its group back.
RemoteEventQueue
The server's notifications as they come (db.events.subscribe()), as the events a database in process gives: Changed.functions are RemoteFunction\ s, and what a server does not send (Changed.revision, Reanalysed.kept) is None.
RemoteEventQueue(db: RemoteDatabase, kinds: tuple[type, ...])
get(timeout: float | None = None) -> _Event | None- The next event, waiting up to
timeoutseconds (None: until one comes);Noneif none came, or the queue is closed. close() -> None- Stops the queue: no more events.
__iter__() -> Iterator[_Event]
RemoteEvents
db.events: the server's notifications.
RemoteEvents(db: RemoteDatabase)
subscribe(*kinds: type) -> RemoteEventQueue- A queue of the events of
kinds(event classes:binbun.StageReached,Changed,HistoryChanged,Reanalysed,ThreadChanged,Mentioned; all of them if none) from now on; one queue per connection. A server sends noProgress,FailedorUnresolved:CapabilityError.
RemoteDocument
A function's C as the server prints it.
function: RemoteFunction
view: View
text: str
lines: list[RemoteCLine]- Its lines, from 0.
RemoteCLine
A line of a function's C as the server prints it: its function, the view, its number (from 0) and text. As evidence (evidence=[...], alone or in a list of one document's lines): these lines of its function's C in its view.
function: RemoteFunction
view: View
number: int
text: str
RemoteFunction
A function of the server's database, by entry; read on each use.
RemoteFunction(db: RemoteDatabase, entry: int)
name: str- Its name: the user's, else the image's, else
sub_XXXX. user_name: str | None- The user's name, if given.
name_source: str | None- Where its name comes from:
"user"(or"script","plugin","agent": an edit by one),"signature"(a library signature),"symbol","debug";Nonefor binbun's own (sub_…), asFunction.name_source. ranges: list[tuple[int, int]]- Its blocks' address ranges, merged:
(start, end)pairs. decompile(*, view: View | str | None = None, timeout: float | None = None) -> RemoteDocument- Its C as text.
RemoteFunctions
db.functions over the socket.
RemoteFunctions(db: RemoteDatabase)
__iter__() -> Iterator[RemoteFunction]
__len__() -> int
entries() -> list[int]- Every function's entry, in order.
__contains__(function: object) -> bool
__getitem__(function: object) -> RemoteFunction
get_at(ea: object) -> RemoteFunction | None- The function holding
ea: the one starting there, else of those whose blocks hold it the one with the greatest entry below it;Noneif none does. get_containing(ea: object) -> list[RemoteFunction]- Every function whose blocks hold
ea(blocks can be shared), by entry. get_by_name(name: str) -> RemoteFunction | None- The function named
name, if one is. set_name(function: object, name: str | None) -> None- Names
function(aRemoteFunctionor its entry;None: its own name again). set_prototype(function: object, c: str | None) -> None- Gives
functionthe prototype Cc(None: inferred).
RemoteNames
db.names over the socket.
RemoteNames(db: RemoteDatabase)
get_at(ea: object) -> str | None- The name of
ea: the user's, else the image's. set_name(ea: object, name: str | None) -> None- Names
ea: the function starting there, else the global.
RemoteComments
db.comments over the socket.
RemoteComments(db: RemoteDatabase)
get_all() -> list[Comment]- Every comment, by address.
get_at(ea: object) -> str | None- The comment at
ea, if there is one. set_at(ea: object, text: str | None) -> None- Comments
eawithtext(Noneor empty: none).
RemoteBookmarks
db.bookmarks over the socket.
RemoteBookmarks(db: RemoteDatabase)
get_all() -> list[Named]- Every bookmark, by address.
get_at(ea: object) -> str | None- The bookmark at
ea, if there is one. set_at(ea: object, name: str | None) -> None- Bookmarks
eaasname(Noneor empty: none).
RemoteTypes
db.types' writes over the socket.
RemoteTypes(db: RemoteDatabase)
define(c: str) -> str- Defines the struct, union, enumeration or typedef C
c: its key (struct pair). Not inside a suggestion: the server says the key only once it writes the definition (CapabilityError). undefine(key: str) -> None- Drops the user's definition of
key. set_global_type(ea: object, c: str | None) -> None- Types the global at
ea.
RemoteTransaction
with db.transaction(label): over the socket: one undo step in the server, rolled back if an exception leaves it.
RemoteTransaction(db: RemoteDatabase, label: str, author: str | None, wait: bool)
__enter__() -> RemoteTransaction
__exit__(exc_type: object, _exc: object = None, _traceback: object = None) -> Literal[False]
RemoteDatabase
A database open in a binbun GUI (or a script's db.serve()), read and written over the socket (binbun.connect()).
RemoteDatabase(connection: Connection)
mode: Literal['remote']
identity: str | None- The server's identity key (hexadecimal): whom a mention of its scripts names.
suggestion(label: str | None = None, *, rationale: str | None = None, evidence: Iterable[_Citable] | None = None, thread: Thread | str | None = None, supersedes: Suggestion | str | None = None) -> SuggestionDraft- A suggestion:
with db.suggestion(label, rationale=..., evidence=[...]) as s:records the writes made in it on this thread instead of making them and makes them a suggestion when it ends (s.suggestion), asbinbun.Database.suggestion. The server checks the writes then (CDeclarationError...). decompile(function: object, *, view: View | str | None = None, timeout: float | None = None) -> RemoteDocument- The C of
function(aRemoteFunctionor its entry) as the server prints it;TimeoutErroraftertimeoutseconds (the server goes on). transaction(label: str, *, author: str | None = None, wait: bool = True) -> RemoteTransaction- A transaction: one undo step labelled
label. commit() -> HistoryEntry | None- Commits the run group (the writes made outside a transaction so far): one undo step; the change it made.
undo(*, wait: bool = True) -> HistoryEntry | None- Undoes this install's last change in the server; with
wait, an undone correction's new analysis is waited for. redo(*, wait: bool = True) -> HistoryEntry | None- Makes the last change undone again; as
undo. history: list[HistoryEntry]- The server's history, newest first.
cursor: int | None(writable)- The GUI's cursor,
Noneif it has none; set, the GUI goes there (CapabilityErrorif the server has no window). selection: tuple[int, int] | None- The GUI's selection:
(start, end), if one is made. close() -> None- Commits the run group and ends the connection.
__enter__() -> RemoteDatabase
__exit__(*_exc: object) -> None
Threads and suggestions
Threads, suggestions and who is in the session: db.threads, db.suggestions, db.suggestion() and db.session.members of a database open in process (binbun.open), connected (binbun.connect(), either mode: they are the server's) or remote.
- A thread is discussion about something in the binary (
db.threads.create(about, text): abinbun.Function, abinbun.CLineby the first instruction it was made from, abinbun.CVariable, aSuggestion, abinbun.StringItem, an address: the instruction or data item there; a type byAnchor.type(key)): it follows them across re-analysis, never printed into the C. Read back, what it is about is itsAnchor. - A post is edited by its author only and deleted by its author or the project's owner (shown "removed by the owner");
mentionsname whom it is for (Member\ s ofdb.session.members), told to them asbinbun.Mentioned. - A suggestion proposes writes with what they rest on:
with db.suggestion("Name parse_args", rationale=..., evidence=[...]):records the ordinary write calls made in its block (db.functions.set_name,CVariable.rename...) instead of making them. Nothing is written until a person accepts it, in whole or in part (one undo step of theirs, the suggestion's author named in the history); its author may supersede it with a new version (db.suggestion(supersedes=s)); its evidence can be asked again (stale items marked). - Evidence (
evidence=, of a suggestion or a post) is the query results it rests on, as they were got: C lines (abinbun.CLine, or a list of one document's; abinbun.RemoteCLinelikewise),db.xrefs.to_ea(ea)(abinbun.XrefsTo: what refers toea), a call'sbinbun.Xref(the call at its site),f.verify()(its verdict), an item off.why().items(why its variable has its type and name),db.strings.get_at(ea)(the string there), astr(its author's own words), or anEvidenceread back. Each is recorded as what it points at and quoted by the database when the post or suggestion is made; read back, it is anEvidence. - A member is someone in the session (
Member): a person or an agent (an agent connected withbinbun.connect(agent=...)or throughbinbun mcphas an identity of its own). Talk to people in threads, mentioning them (mentions=[member]); there is no chat from Python.
Ids are strings ("<chain>:<seq>:<n>"), keys hexadecimal, times seconds since the Unix epoch.
Author
Who did something: an identity key (hexadecimal) and as whom (via: user, script:<name>, agent...).
key: str
via: str
Mention
Whom a post mentions, read back: an identity (key; the server's, or this database's, if None), and one of its scripts or agents (agent: "script:helper"; None: the identity itself).
agent: str | None
key: str | None
Anchor
What a thread is about, as the protocol states it (data): thread.anchor. Anchor.type(key) makes one for a type, which no object stands for.
data: dict[str, Any]
kind: strfunction,instruction,data,line,variable,typeorsuggestion.address: int | None- Its address, if it has one (a line's first instruction).
Anchor.type(key: str) -> Anchor- A type, by the key its definition defines (
struct pair).
Evidence
An item of evidence of a post or suggestion, read back: what it points at (data: what asks it again) and what it said when quoted (quote; None if it could not be answered then). Given as evidence again, it is quoted anew.
data: dict[str, Any]
quote: str | None
kind: strwhy,lines,verification,xrefs_to,string,callortext.
Post
A post as it is now: body is empty once deleted, deleted_by who deleted it (removed_by_owner: an owner, not its author).
id: str
thread: str
reply_to: str | None
author: Author
time: float
body: str
edited: float | None
deleted_by: Author | None
removed_by_owner: bool
mentions: tuple[Mention, ...]
evidence: tuple[Evidence, ...]
deleted: bool- Whether it is deleted.
edit(text: str) -> Post- Edits it to say
text(its author only): it as it is now. delete() -> Post- Deletes it (its author, or an owner): it as it is now.
Thread
A thread as it was read: what it is about (anchor), its posts and the suggestions answering it.
id: str
anchor: Anchor
quote: str
opened_by: Author
time: float
resolved: bool
posts: tuple[Post, ...]
suggestions: tuple[str, ...]
reply(text: str, *, reply_to: Post | str | None = None, mentions: Iterable[Member] = (), evidence: Iterable[_Citable] = ()) -> Post- Posts
textin it (mentions:Member\ s;evidence: query results, see the module). resolve(resolved: bool = True) -> Thread- Resolves it (or opens it again): it as it is now.
refresh() -> Thread- It as it is now.
Threads
db.threads: every thread (iterating), those at an address or in a function, and the writes.
Threads(call: Caller)
__iter__() -> Iterator[Thread]
__len__() -> int
at(ea: object) -> list[Thread]- The threads anchored at
ea(a function's entry, an instruction, a data item, a C line's first instruction). in_function(function: object) -> list[Thread]- The threads in
function(aFunctionor its entry): about it, a line or variable of it, an instruction it holds. get(id: str) -> Thread | None- Thread
id, if made. create(about: object, text: str = '', *, quote: str = '', mentions: Iterable[Member] = (), evidence: Iterable[_Citable] = ()) -> Thread- Opens a thread about
about(aFunction, aCLine, aCVariable, aSuggestion, aStringItem, an address: the instruction or data item there;Anchor.type(key)), quoting its text now (quote), its first posttextif not empty (mentions:Member\ s;evidence: query results): one change. post(thread: Thread | str, text: str, *, reply_to: Post | str | None = None, mentions: Iterable[Member] = (), evidence: Iterable[_Citable] = ()) -> Post- Posts
textinthread. edit(post: Post | str, text: str) -> Post- Edits
postto saytext(its author only). delete(post: Post | str) -> Post- Deletes
post(its author, or an owner). resolve(thread: Thread | str, resolved: bool = True) -> Thread- Resolves
thread(or opens it again).
Proposal
An edit a suggestion proposes, against its key now: kind (function_name, comment...), its address, the value proposed, the value shown now, whether the key moved since.
kind: str
address: int | None
key: str
value: str | None
now: str | None
moved: bool
Rechecked
An item of evidence asked again: the item as quoted, what it says now (or the error asking it), whether it is stale.
item: Evidence
now: str | None
error: str | None
stale: bool
Suggestion
A suggestion as it was read: state is pending, accepted, dismissed or superseded.
id: str
author: Author
time: float
label: str
edits: tuple[Proposal, ...]
rationale: str
evidence: tuple[Evidence, ...]
thread: str | None
supersedes: str | None
state: Literal['pending', 'accepted', 'dismissed', 'superseded']
accepted: tuple[int, ...]
reason: str | None
superseded_by: str | None
decided_by: Author | None
accept(edits: Iterable[int] | None = None) -> HistoryEntry | None- Accepts it: the edits numbered
edits(all ifNone), one undo step of this identity's naming who suggested it. The change made (Noneif it changed nothing). dismiss(reason: str = '') -> Suggestion- Dismisses it, saying why: it as it is now.
recheck() -> list[Rechecked]- Its evidence asked again against the analysis now, stale items marked.
refresh() -> Suggestion- It as it is now.
Suggestions
db.suggestions: every suggestion (iterating), by state, by id. Suggestions are made with db.suggestion(...).
Suggestions(call: Caller)
__iter__() -> Iterator[Suggestion]
__len__() -> int
pending() -> list[Suggestion]- Those waiting for review.
accepted() -> list[Suggestion]- Those accepted.
get(id: str) -> Suggestion | None- Suggestion
id, if made.
SuggestionDraft
with db.suggestion(label, rationale=..., evidence=[...], thread=...) as s:: the writes made in the block on this thread (db.functions.set_name(f, ...), CVariable.rename...) are recorded instead of made (each checked as it is made, after those before it), and become a suggestion when the block ends: s.suggestion (None until then). An exception leaving the block makes none. A transaction, an undo or another suggestion inside the block is a TransactionError; threads and posts are written as usual.
supersedes: a suggestion of this identity's (or its id) the new one is the next version of; its label, rationale, evidence and thread are kept unless given.
SuggestionDraft(db: _Recorder, call: Caller, label: str | None = None, *, rationale: str | None = None, evidence: Iterable[_Citable] | None = None, thread: Thread | str | None = None, supersedes: Suggestion | str | None = None)
__enter__() -> SuggestionDraft
__exit__(exc_type: object, _exc: object = None, _traceback: object = None) -> Literal[False]
Member
Someone in the session: a person or an agent (kind), their name, their role in the shared project (owner, editor, viewer, agent; None unless it is shared), whether they are online, whether it is you (the binbun's own user), and key, their identity (hexadecimal). A post mentions them by it (mentions=[member]).
key: str
name: str
kind: Literal['person', 'agent']
role: str | None
online: bool
you: bool
Members
class Members(Sequence[Member])
db.session.members: who is in the session, a sequence (this binbun's user first), also looked up by name or by key (members["alice"]): KeyError if none is, AmbiguousError (naming their keys) if a name is several members'.
Members(members: Iterable[Member])
__getitem__(index: int) -> Member
__getitem__(index: slice) -> tuple[Member, ...]
__getitem__(index: str) -> Member
__len__() -> int
__iter__() -> Iterator[Member]
Session
db.session: the session the database is in.
Session(call: Caller)
members: Members- Who is in the session, people and agents, this binbun's user first: in a shared project its members, else the user and the agents that worked here;
members["alice"]by name or key.
binbun.x86
binbun's x86 decoder (16, 32 and 64-bit, XED-exact), without a database.
>>> from binbun import x86
>>> insn = x86.decode(b"\x48\x89\xc7", address=0x1000)
>>> insn.text(), insn.length, insn.mnemonic
('mov rdi, rax', 3, 'mov')
>>> [str(i) for i in x86.Decoder(b"\x55\xc3", address=0x401000)]
['push rbp', 'ret']
The vocabulary is the C API's (binbun/disasm.h): every enum below has the names and numbers of its BINBUN_X86_* constants, and binbun.Status, binbun.Branch and binbun.Token are shared with binbun.aarch64.
Module functions
decode(data: bytes | bytearray | memoryview, address: int = ..., mode: Mode | int = ...) -> Instruction- Decodes the instruction at the start of
data(bytes,bytearray,memoryview...), which is ataddress, inmode.DecodeErrorif the bytes are no instruction (itsstatussays why:Status.TRUNCATEDif they end before it does). decode_length(data: bytes | bytearray | memoryview, mode: Mode | int = ...) -> int- The length of the instruction at the start of
datainmode: XED's length decoder alone, which decodes prefixes and opcode maps but does not check which instructions exist, so it accepts some bytesdecoderejects.DecodeErrorif it finds no length. sweep(data: bytes | bytearray | memoryview, address: int = ..., mode: Mode | int = ...) -> Sweep- A linear sweep of
data, which is ataddress, inmode, in columns (binbun.Sweep): whatDecoderyields, without an object per instruction, decoded with the GIL released.
Module constants and types
MAX_LENGTH: int- The longest instruction, in bytes (15).
Action
class Action(enum.IntEnum)
How an instruction accesses an operand (binbun_x86_action).
READ = 1
WRITE = 2
READ_WRITE = 3
CONDITIONAL_READ = 4
CONDITIONAL_WRITE = 5
CONDITIONAL_READ_WRITE = 6
READ_CONDITIONAL_WRITE = 7Condition
class Condition(enum.IntEnum)
The condition an instruction tests (binbun_x86_condition).
NONE = 0
O = 1
NO = 2
B = 3
NB = 4
Z = 5
NZ = 6
BE = 7
NBE = 8
S = 9
NS = 10
P = 11
NP = 12
L = 13
NL = 14
LE = 15
NLE = 16
FALSE = 17
TRUE = 18
COUNT_ZERO = 19
LOOP = 20
LOOP_ZERO = 21
LOOP_NOT_ZERO = 22
TRANSACTION_ABORT = 23Decoder
A linear sweep over a buffer of code, which is at address, in mode: an iterator of Instructions and, where bytes are no instruction, binbun.Invalid steps of one byte, so that a sweep over data resynchronises (as binbun_x86_decoder_next). offset is where the next instruction is in the buffer; set it to continue elsewhere.
Decoder(data: bytes | bytearray | memoryview, address: int = ..., mode: Mode | int = ...)
offset: int(writable)- Where the next instruction is in the buffer.
address: int- The address of the next instruction.
__iter__() -> Iterator[Instruction | Invalid]
__next__() -> Instruction | Invalid
Encoding
class Encoding(enum.IntEnum)
How an instruction is encoded (binbun_x86_encoding).
LEGACY = 1
VEX = 2
EVEX = 3
XOP = 4Flag
class Flag(enum.IntFlag)
The flags (BINBUN_X86_FLAG_*): RFLAGS bit positions, and the x87 condition codes C0-C3 in bits 28-31.
CF = 1
PF = 4
AF = 16
ZF = 64
SF = 128
TF = 256
IF = 512
DF = 1024
OF = 2048
IOPL = 12288
NT = 16384
RF = 65536
VM = 131072
AC = 262144
VIF = 524288
VIP = 1048576
ID = 2097152
FC0 = 268435456
FC1 = 536870912
FC2 = 1073741824
FC3 = 2147483648Flags
What an instruction does to the flags (binbun_x86_flag_effect), as Flag bits: read, written (modified, set, cleared or left undefined) and undefined; whether it may_write them and whether it must_write them (a shift by 0 does not).
read: Flag- The flags read.
written: Flag- The flags written.
undefined: Flag- The flags left undefined.
may_write: bool- Whether the instruction may write flags.
must_write: bool- Whether it always writes them.
Instruction
One x86 instruction at its address: what it is (mnemonic, form, category, extension, isa_set, encoding), its operands, what it does to the flags and to the flow of control (branch), and its text (Intel syntax as XED writes it) plain or as tokens. A value: equal when the same bytes are decoded at the same address in the same mode.
address: int- Its address.
length: int- Its length in bytes, 1 to 15.
__len__() -> int
bytes: bytes- Its bytes.
mode: Mode- The mode it was decoded in: a
Mode. mnemonic: str- The mnemonic, XED's iclass in lower case (
add,call_near,rep_movsb), as every mnemonic binbun gives is. form: str- The form, XED's iform: the mnemonic with its operand types (
ADD_GPRv_GPRv_01). category: str- The category (
BINARY,COND_BR,CALL). extension: str- The ISA extension (
BASE,AVX2). isa_set: str- The feature set it needs (
I86,AVX2). encoding: Encoding- How it is encoded: an
Encoding. condition: Condition- The condition it tests (
Jcc,SETcc,CMOVcc,LOOP): aCondition,Condition.NONEfor none. operand_width: int- The effective operand width in bits: 8, 16, 32 or 64.
address_width: int- The effective address width in bits, 16, 32 or 64, or 0 for none.
stack_address_width: int- The stack address width in bits: 16, 32 or 64.
branch: Branch- What it does to the flow of control at its address: relative targets as addresses, a jump or call through
[rip+disp]as aPOINTERtarget. computed_address: int | None- The address a RIP-relative
leacomputes, elseNone. flags: Flags- What it does to the flags (XED's flag records).
operands: tuple[Operand, ...]- Its operands in XED's order: those the text shows, then implied ones (the stack pointer, the flags).
text(options: TextOptions | int = 0) -> str- Its text, as XED writes Intel syntax (
lock add dword ptr [rax+rbx*4-0x10], 0x5; branch targets as addresses). x86 text has no options: anything butTextOptions.DEFAULTis aValueError. tokens(options: TextOptions | int = 0) -> list[Token]- Its text as tokens, each a span of
text().
Mode
class Mode(enum.IntEnum)
The processor mode (binbun_x86_mode).
REAL16 = 1
REAL32 = 2
BITS16 = 3
BITS32 = 4
BITS64 = 5Operand
One operand (binbun_x86_operand): what its value is (kind), which decoder field holds it (field), whether the text shows it (visibility), how the instruction accesses it (action, access), its width in bits, and the value: register; a memory operand's segment, base, index, scale, displacement and memory_size; an immediate's value and signed_immediate; a relative branch's displacement. Fields a kind has not are 0 or None.
kind: OperandKind- What its value is: an
OperandKind. field: OperandField- Which decoder field holds it: an
OperandField(XED's operand names,REG0,MEM0,IMM0,RELBR). visibility: Visibility- Whether the text shows it: a
Visibility. action: Action- How the instruction accesses it: an
Action. access: Access- Whether it may be read, may be written: a
binbun.Access. bits: int- Its width in bits.
register: str | None- A register operand's register (
rax,st(0)), elseNone. segment: str | None- A memory operand's segment register as XED reports it (outside 64-bit mode the segment used, in 64-bit mode only an
fsorgsoverride), elseNone. base: str | None- A memory operand's base register, else
None. index: str | None- A memory operand's index register, else
None. scale: int- A memory operand's index multiplier (1, 2, 4 or 8), 0 without a SIB byte.
displacement: int- A memory operand's displacement, or a relative branch's displacement from the next instruction.
memory_size: int- How many bytes a memory operand accesses; 0 for an address computation (
lea). value: int- An immediate's value (its bytes zero-extended), or an absolute branch address or far pointer offset.
signed_immediate: bool- Whether the instruction sign-extends an immediate.
OperandField
class OperandField(enum.IntEnum)
Which decoder field holds an operand (binbun_x86_operand_field, XED's operand names).
REG0 = 1
REG1 = 2
REG2 = 3
REG3 = 4
REG4 = 5
REG5 = 6
REG6 = 7
REG7 = 8
REG8 = 9
REG9 = 10
BASE0 = 11
BASE1 = 12
MEM0 = 13
MEM1 = 14
AGEN = 15
IMM0 = 16
IMM1 = 17
RELBR = 18
ABSBR = 19
PTR = 20OperandKind
class OperandKind(enum.IntEnum)
What an operand's value is (binbun_x86_operand_kind).
REGISTER = 1
MEMORY = 2
IMMEDIATE = 3
SECOND_IMMEDIATE = 4
RELATIVE = 5
FIELD = 6Visibility
class Visibility(enum.IntEnum)
Whether the text shows an operand (binbun_x86_visibility).
EXPLICIT = 1
IMPLICIT = 2
SUPPRESSED = 3binbun.aarch64
binbun's AArch64 decoder (A64: every encoding of the 2026-09 release of Arm's A-profile specification, LLVM-exact text), without a database.
>>> import binbun
>>> from binbun import aarch64
>>> aarch64.decode_word(0x8B020020).text()
'add\tx0, x1, x2'
>>> b = aarch64.decode_word(0x14000010, address=0x1000)
>>> b.text(), b.text(binbun.TextOptions.RELATIVE_LABELS), hex(b.branch.target)
('b\t0x1040', 'b\t#0x40', '0x1040')
The vocabulary is the C API's (binbun/disasm.h): every enum below has the names and numbers of its BINBUN_AARCH64_* constants, and binbun.Status, binbun.Branch and binbun.Token are shared with binbun.x86.
Module functions
decode(data: bytes | bytearray | memoryview, address: int = ...) -> Instruction- Decodes the instruction at the start of
data(little-endian;bytes,bytearray,memoryview...), which is ataddress.DecodeErrorif it is none (Status.TRUNCATEDfor fewer than 4 bytes). decode_word(word: int, address: int = ...) -> Instruction- Decodes the instruction word
word, which is ataddress.DecodeErrorif it is none (itsstatussays why). sweep(data: bytes | bytearray | memoryview, address: int = ...) -> Sweep- A linear sweep of
data, which is ataddress, in columns (binbun.Sweep): whatDecoderyields, without an object per instruction, decoded with the GIL released.
Module constants and types
LENGTH: int- Every instruction's length in bytes (4).
_Value = Register | RegisterList | Immediate | Float | Shift | Extend | Memory | Label | Cond | SystemRegister | Named | Za | ZaList | int | IndexedRegister
CompareKind
class CompareKind(enum.IntEnum)
What a compare-and-branch compares with (binbun_aarch64_compare_kind).
REGISTER = 1
IMMEDIATE = 2Cond
class Cond(enum.IntEnum)
A condition field (binbun_aarch64_cond): EQ 0 to NV 15.
EQ = 0
NE = 1
HS = 2
LO = 3
MI = 4
PL = 5
VS = 6
VC = 7
HI = 8
LS = 9
GE = 10
LT = 11
GT = 12
LE = 13
AL = 14
NV = 15Condition
The condition an instruction tests (binbun_aarch64_condition), as kind says: the flags satisfy cond (b.cond, csel), register is zero or not (sense: cbz true), bit bit of register is set or clear (sense: tbnz true), or register compared with right_register or right_immediate satisfies cond.
kind: ConditionKind- What is tested: a
ConditionKind. cond: Cond | None- The condition, for
FLAGSandCOMPARE(as the encoding is:cset w0, eqtestsne); elseNone. sense: boolZERO: whether the test passes when the register is zero;BIT: when the bit is set.bit: intBIT: the bit's number.register: Register | None- The register tested, or the left one compared;
NoneforFLAGS. right_kind: CompareKind | NoneCOMPARE: what the register is compared with, aCompareKind; elseNone.right_register: Register | NoneCOMPAREwith a register: the register; elseNone.right_immediate: int | NoneCOMPAREwith an immediate: the immediate; elseNone.
ConditionKind
class ConditionKind(enum.IntEnum)
What a condition tests (binbun_aarch64_condition_kind).
FLAGS = 1
ZERO = 2
BIT = 3
COMPARE = 4Decoder
A linear sweep over a buffer of code, which is at address: an iterator of Instructions and, for words that are none, binbun.Invalid steps of 4 bytes (fewer at the end of the buffer: Status.TRUNCATED), as binbun_aarch64_decoder_next. offset is where the next instruction is in the buffer; set it to continue elsewhere.
Decoder(data: bytes | bytearray | memoryview, address: int = ...)
offset: int(writable)- Where the next instruction is in the buffer.
address: int- The address of the next instruction.
__iter__() -> Iterator[Instruction | Invalid]
__next__() -> Instruction | Invalid
Element
class Element(enum.IntEnum)
An element size (binbun_aarch64_element).
NONE = 0
B = 1
H = 2
S = 3
D = 4
Q = 5Extend
An extend of the register before it (binbun_aarch64_extend): kind and the shift amount (None where the text writes none).
kind: ExtendKind- The kind: an
ExtendKind. amount: int | None- The shift amount, else
None.
ExtendKind
class ExtendKind(enum.IntEnum)
An extend (binbun_aarch64_extend_kind).
UXTB = 1
UXTH = 2
UXTW = 3
UXTX = 4
SXTB = 5
SXTH = 6
SXTW = 7
SXTX = 8Flag
class Flag(enum.IntFlag)
The condition flags, as they sit in NZCV (BINBUN_AARCH64_FLAG_*).
V = 1
C = 2
Z = 4
N = 8Flags
The condition flags an instruction reads and writes, as Flag bits.
read: Flag- The flags read (those the condition tests, the carry of
adc...). written: Flag- The flags written.
Float
A floating-point immediate: its value, and whether it is a constant the encoding selects (exact, written shortest) rather than encodes.
value: float- The value.
exact: bool- Whether it is a constant the encoding selects.
Immediate
An immediate (binbun_aarch64_immediate): its value (two's complement when signed), and how the text writes it (radix). int() is the value, negative where signed.
value: int- The value's bits (two's complement when
signed). signed: bool- Whether it is signed.
radix: Radix- How the text writes it: a
Radix. __int__() -> int
IndexedRegister
A register selected by a general register plus an offset (p2.b[w12, 15]): register, index and offset.
register: Register- The register selected from.
index: Register- The index register.
offset: int- The offset added to the index.
Instruction
One A64 instruction at its address: its word, the encoding it is an instance of (Arm's name), its mnemonic after alias selection, its operands (each with its access), what it does to the flags, the memory access it makes, the registers it uses without naming them, what it does to the flow of control (branch), and its text (as LLVM writes it) plain or as tokens. A value: equal when the same word is decoded at the same address.
address: int- Its address.
word: int- The instruction word.
length: int- Its length in bytes: 4.
__len__() -> int
bytes: bytes- Its bytes, little-endian.
encoding: str- The encoding the word is an instance of, as Arm's specification names it (
ADD_64_addsub_shift). encoding_mnemonic: str- The mnemonic of the encoding's own syntax (
ORRformov x0, x1). features: list[str]- The architecture features the encoding needs (
FEAT_SVE...). mnemonic: str- The mnemonic as the text writes it, after alias selection (
movfororr x0, xzr, x1,b.eq). branch: Branch- What it does to the flow of control at its address:
b,b.cond,cbz,tbzandblgive their target;br,blrand their pointer-authenticating forms areINDIRECT. computed_address: int | None- The address an
adrcomputes, elseNone(adrpcomputes a page, not a pointer). condition: Condition | None- The condition it tests (
b.cond,csel,cbz,tbnz), elseNone. flags: Flags- The condition flags it reads and writes.
memory: MemoryAccess | None- The memory access it makes through an operand, else
None. implicit_reads: list[Register]- The registers it reads without naming them (x30 of
ret, x16 and x17 ofpacia1716, FFR). implicit_writes: list[Register]- The registers it writes without naming them (x30 of
bl, FFR). operands: tuple[Operand, ...]- Its operands, as the text writes them (after alias selection), each with how the instruction accesses it.
text(options: TextOptions | int = 0) -> str- Its text, as LLVM writes it: the mnemonic, a tab, the operands (
ldr\tx0, [x1, #0x8]); labels as the addresses they name, or as offsets withTextOptions.RELATIVE_LABELS. tokens(options: TextOptions | int = 0) -> list[Token]- Its text as tokens, each a span of
text(options).
Label
A PC-relative address (binbun_aarch64_label): offset from the instruction or its 4 KiB page (base), the target it names, and how relative text writes it (radix).
offset: int- The offset from the base.
base: LabelBase- What it is relative to: a
LabelBase. radix: Radix- How
TextOptions.RELATIVE_LABELSwrites it: aRadix. target: int- The address it names.
LabelBase
class LabelBase(enum.IntEnum)
What a PC-relative address is relative to (binbun_aarch64_label_base).
INSTRUCTION = 1
PAGE = 2ListStyle
class ListStyle(enum.IntEnum)
How a register list is written (binbun_aarch64_list_style).
COMMAS = 1
RANGE = 2Memory
A memory operand (binbun_aarch64_memory): the base register, what is added to it (offset_kind: an immediate offset, an index register shifted or extended as modifier says, or offset vector lengths), and the writeback.
base: Register- The base register.
offset_kind: OffsetKind- What is added to the base: an
OffsetKind. offset: int- The immediate offset, or the number of vector lengths; 0 for none.
offset_signed: bool- Whether an immediate offset is signed.
offset_radix: Radix | None- How the text writes an immediate offset: a
Radix, elseNone. index: Register | None- The index register of a register offset, else
None. modifier: Modifier- How the index is modified: a
Modifier. modifier_kind: ShiftKind | ExtendKind | None- The modifier's kind: a
ShiftKindor anExtendKind, elseNone. modifier_amount: int | None- The modifier's amount, where the text writes one, else
None. writeback: Writeback- Whether and when the base is written back: a
Writeback.
MemoryAccess
The memory access an instruction makes through an operand: its kind and size in bytes (0 where it depends on the vector length, the implementation or a register).
kind: MemoryKind- What kind of access: a
MemoryKind. size: int- The bytes accessed in total; 0 where that is not fixed.
MemoryKind
class MemoryKind(enum.IntEnum)
What kind of memory access (binbun_aarch64_memory_kind).
LOAD = 1
STORE = 2
ATOMIC = 3
LOAD_EXCLUSIVE = 4
STORE_EXCLUSIVE = 5
PREFETCH = 6
COPY = 7
LOAD_TAG = 8
STORE_TAG = 9Modifier
class Modifier(enum.IntEnum)
How a memory operand's index register is modified (binbun_aarch64_modifier).
NONE = 0
SHIFT = 1
EXTEND = 2Named
A named operand: a prefetch operation, barrier option, BTI target, PSTATE field, SVE pattern, system operation or keyword (kind), and its name (lower case, pldl1keep, ish).
kind: NameKind- What it names: a
NameKind. name: str- The name.
NameKind
class NameKind(enum.IntEnum)
What a named operand names (binbun_aarch64_name_kind).
PREFETCH = 1
BARRIER = 2
BRANCH_TARGET = 3
PSTATE_FIELD = 4
PATTERN = 5
SYSTEM_OPERATION = 6
KEYWORD = 7OffsetKind
class OffsetKind(enum.IntEnum)
What a memory operand adds to its base (binbun_aarch64_offset_kind).
NONE = 0
IMMEDIATE = 1
REGISTER = 2
VECTOR_LENGTH = 3Operand
One operand, as the text writes it: what it is (kind), how the instruction accesses it (access: a memory operand's access is the memory access; values are read), and its value: a Register (REGISTER, WRITEBACK), RegisterList, Immediate, Float, Shift, Extend, Memory, Label, Cond, SystemRegister, Named, Za, ZaList, an int (TABLE_SLICE) or an IndexedRegister.
kind: OperandKind- What it is: an
OperandKind. access: Access- Whether it is read, written: a
binbun.Access. value: _Value- What it holds, as its
kindsays.
OperandKind
class OperandKind(enum.IntEnum)
What an operand is (binbun_aarch64_operand_kind), and so what its value is.
REGISTER = 1
LIST = 2
IMMEDIATE = 3
FLOAT = 4
SHIFT = 5
EXTEND = 6
MEMORY = 7
WRITEBACK = 8
LABEL = 9
CONDITION = 10
SYSTEM_REGISTER = 11
NAMED = 12
ZA = 13
ZA_LIST = 14
TABLE_SLICE = 15
INDEXED_REGISTER = 16Predication
class Predication(enum.IntEnum)
A predicate qualifier (binbun_aarch64_predication).
NONE = 0
ZEROING = 1
MERGING = 2Radix
class Radix(enum.IntEnum)
How a number is written (binbun_aarch64_radix).
HEX = 1
DECIMAL = 2
PADDED_HEX = 3Register
A register, with what is written on it (binbun_aarch64_register): its register_class and number, an arrangement (lanes elements of element, or the element alone with 0 lanes), an element index, a predication. str() writes it as the text does (x0, sp, v1.16b, z2.s[1], p0/z).
register_class: RegisterClass- Its class: a
RegisterClass. number: int- Its number; for general registers 31 is the zero register or the stack pointer, as the class says.
lanes: int- The arrangement's element count (
16ofv0.16b); 0 for none. element: Element- The arrangement's element size: an
Element,NONEfor none. index: int | None- The element index (
1ofv0.s[1]), elseNone. predication: Predication- The predicate qualifier: a
Predication.
RegisterClass
class RegisterClass(enum.IntEnum)
The letter and width a register is written with (binbun_aarch64_register_class).
W = 1
X = 2
WSP = 3
XSP = 4
B = 5
H = 6
S = 7
D = 8
Q = 9
V = 10
Z = 11
P = 12
PN = 13
ZT = 14
C = 15
FFR = 16RegisterList
A register list (binbun_aarch64_register_list): count registers from first, numbers stride apart, written in style; registers lists them.
first: Register- The first register, with the arrangement and index all share.
count: int- How many registers.
stride: int- The distance between their numbers.
style: ListStyle- How the list is written: a
ListStyle. registers: list[Register]- Every register of the list.
Shift
A shift of the operand before it (binbun_aarch64_shift): kind and amount.
kind: ShiftKind- The kind: a
ShiftKind. amount: int- The amount.
ShiftKind
class ShiftKind(enum.IntEnum)
A shift (binbun_aarch64_shift_kind).
LSL = 1
LSR = 2
ASR = 3
ROR = 4
MSL = 5
MUL = 6SliceDirection
class SliceDirection(enum.IntEnum)
A ZA tile slice's direction (binbun_aarch64_slice_direction).
NONE = 0
HORIZONTAL = 1
VERTICAL = 2SystemRegister
A system register: its name for this access as LLVM writes it (TPIDR_EL0; None where it has none) and its 16-bit encoding (op0:op1:CRn:CRm:op2).
name: str | None- Its name, else
None. encoding: intop0:op1:CRn:CRm:op2,op0in bits 15:14.
Writeback
class Writeback(enum.IntEnum)
Whether and when a memory operand's base is written back (binbun_aarch64_writeback).
NONE = 0
PRE = 1
POST = 2Za
The SME array or a tile, whole or sliced (binbun_aarch64_za): tile (None: the whole array), element, slice direction, and a slice's index register w<slice_index>, slice_offset, slice_last and vector group (2, 4, or 0).
tile: int | None- The tile, else
Nonefor the whole array. element: Element- The element size: an
Element. direction: SliceDirection- The slice direction: a
SliceDirection. slice_index: int | None- The number of a slice's index register (
12ofw12), elseNonewithout a slice. slice_offset: int- A slice's offset.
slice_last: int | None- The last offset of a slice range, else
None. group: int- A slice's vector group, 2 or 4, or 0.
ZaList
A list of ZA tiles (binbun_aarch64_za_list): one slice (za) or the 64-bit tiles in tiles (bit i for za<i>.d), as kind says.
kind: ZaListKind- Which it is: a
ZaListKind. tiles: int- The 64-bit tiles, bit i for
za<i>.d. za: Za | None- The slice, else
None.
ZaListKind
class ZaListKind(enum.IntEnum)
What a ZA list holds (binbun_aarch64_za_list_kind).
SLICE = 1
TILES = 2binbun.ir
Unstable: binbun's intermediate representations, as text.
A function through every stage of its decompilation (f.stages()): the machine code, L1 after each pass, L2 after each pass, the C. Excluded from binbun.API_VERSION: the stages, their names and their text change with the engine (IR_VERSION).
Also here, as in binbun: StageText, Stages.
Module constants and types
IR_VERSION: str- The engine version the text forms are of.