Skip to content
vlangPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

decomp

An experimental static decompiler for x86-64 (AMD64) and ARM64 (AArch64), written in V and started as a port of fast-decomp. It loads an executable, discovers functions, lifts instructions to a checked intermediate representation, and prints C-like pseudocode. The implementation uses V ownership mode for its application code, with owning aggregates, explicit borrows, and independent clones where needed.

The upstream reference is commit b64727aded1f6bcd60d866de425a349978522f7b. The port implements SSA, whole-program analysis and a checked statement AST. The mapping to all 18 upstream crates and remaining differences are listed in PORTING.md. Upstream performance numbers and corpus results do not describe this implementation.

Build

Requirements: a recent V compiler with aggregate ownership support, a C compiler, Make, pkg-config, and the PCRE2 8-bit development library (libpcre2-dev on Debian/Ubuntu, pcre2 on Homebrew). Tests additionally use Python 3, a C++ compiler, and strip. CI covers Linux x86-64 and ARM64 hosts. Both hosts can decompile either target architecture. The pinned compiler revision is bcc7f9b287e07a8f2dbaaeed4b01c659445840a4.

On ARM64 Linux, tests additionally need the gcc-x86-64-linux-gnu, g++-x86-64-linux-gnu, binutils-x86-64-linux-gnu, and libc6-dev-amd64-cross packages for the original x86 corpus and x86 library-header checks. The emitted C and its independent reference still compile and execute natively on the host. CI installs these cross tools on its ARM64 runner.

git clone https://github.com/vlang/decomp
cd decomp
make V=/path/to/v/v
./bin/decomp --help

If V is on PATH, make is sufficient. The build uses v -ownership -prod -cc cc -o bin/decomp cmd/decomp. The application rejects a build that omits ownership mode. V's default garbage collector stays enabled; the ownership checker also handles owned cleanup in application code. See OWNERSHIP.md for the distinction and the concrete borrowing boundaries.

The x86-64 instruction decoder is the vendored MIT-licensed Zydis 4.1.1 C library. The ARM64 decoder is native V and has no additional dependency. V also implements the loaders, discovery, IR, lifting, analyses, metadata, project handling, services, and emitter. Zydis supplies x86 instruction lengths, operands, register effects, and assembly text; its adapter retains no V pointers. Both decoders build locally. An installed decoder library or a Rust toolchain is not required. Dependency provenance includes exact Zydis revisions and regeneration instructions.

Try it

The demo needs to be an x86-64 binary. On Apple Silicon, add -arch x86_64 to the cc command below.

mkdir -p build
cc -O2 -g tests/fixtures/project_fixture.c -o build/demo

./bin/decomp info build/demo
./bin/decomp memory-map build/demo
./bin/decomp functions build/demo --name list
./bin/decomp disasm build/demo --function list_sum
./bin/decomp cfg build/demo --function list_sum > build/list_sum.dot
./bin/decomp ir build/demo --function list_sum --stage lifted
./bin/decomp decompile build/demo --function list_sum
./bin/decomp decompile build/demo --function list_weight --verify --json
./bin/decomp export build/demo --out build/demo-decomp --jobs 4

The checked-in ARM64 fixture can be used on either host without a cross compiler:

./bin/decomp info tests/fixtures/arm64_fixture.elf
./bin/decomp disasm tests/fixtures/arm64_fixture.elf --function arm_sum
./bin/decomp decompile tests/fixtures/arm64_fixture.elf --function arm_nine --verify
./bin/decomp selfcheck tests/fixtures/arm64_fixture.elf --jobs 4

--address 0x... selects a function by its image virtual address. Addresses are not file offsets and are not adjusted for a running process's ASLR slide. Names can be original symbols, demangled names, generated C identifiers, or project names. Ambiguous names require an address.

memory-map shows mapped ranges with exclusive end addresses, permissions, file offsets and zero-filled tails. Use bytes --address VA --length N to inspect the image at a virtual address. Both commands accept --json. The resident service and MCP expose the same data as memory_map and bytes.

diff compares two loaded images and reports changed bytes, added and removed memory, changes to permissions and file backing, and differences in sections, symbols, imports, exports, libraries, and entry points.

./bin/decomp diff build/before build/after --json
./bin/decomp diff build/before build/after --relative --address 0x1000 --length 256
./bin/decomp diff build/before build/after --projects --json
./bin/decomp diff build/before build/after --references --relative --json
./bin/decomp diff build/before build/after --references --stack-references --json
./bin/decomp diff build/before build/after --register-references --relative --json
./bin/decomp diff build/before build/after --instructions --relative --json
./bin/decomp diff build/before build/after --data --projects --json

The default coordinate is the virtual address. With --relative, offsets start at each image's first mapped address. Rebased images can still differ in the bytes that encode absolute addresses. A window selected by --address and --length reports only mapped memory in that range. Each changed range shows its full length and the first 16 bytes from each image. --max-ranges limits the number of displayed byte ranges while preserving exact totals.

With --projects, diff also compares effective names, comments, signatures, and type assertions from the two verified projects. Use --source-project DIR or --project DIR to select project directories. Changes include the original subjects and values on each side. Addressed subjects follow the same absolute or relative coordinates as the memory diff. A full diff includes field annotations and changes to the contents of types.h. A range includes annotations whose addresses fall within it. Comparing projects is read-only. The project diff also lists added, removed, and edited bookmarks using the same address coordinates and range.

With --references, native discovery compares instruction-level data accesses, calls, branches, and bounded jump-table slots, plus loader pointer and import references. The report lists added and removed references. Each row includes the source and destination in the selected coordinates and the original virtual addresses. A range filters by source address.

--stack-references compares explicit stack loads and stores, including accesses to the incoming argument area. Each row identifies the instruction, owning function, operand index, access width, and signed offset from the stack pointer at function entry. The comparison uses proven, fixed stack offsets.

--register-references compares explicit integer and scalar vector register reads with proven origins in ABI argument registers. It follows unchanged bit slices through register copies and reports the operand, input register, bit offset, and zero-based ABI register slot. An address range filters instruction addresses.

With --instructions, diff compares recovered instructions by their starting addresses, sizes, and encodings. Each changed row shows the complete instruction on both sides, including its raw bytes and disassembly. A range includes instructions whose bytes intersect it. Use --references in the same command to include reference changes from the same discovery pass.

With --data, diff compares definitions at matching starts. It includes sized object symbols and loader pointer and import slots. --projects adds effective global type assertions, including changes to the underlying type layout when the assertion text stays the same. A range includes definitions whose extents intersect it. The byte diff reports changes to stored values.

cfg exports a recovered function graph as Graphviz DOT or JSON. Edges retain branch direction and switch slot indices, including repeated table targets. The graph marks edges that leave the function and blocks with unresolved control flow. Use dot -Tsvg build/list_sum.dot -o build/list_sum.svg to render the optional DOT output.

Compare two builds of the same architecture and calling convention with ./bin/decomp compare build/before build/after --json. The report pairs unique symbols first, then functions with identical recovered bytes and block layout, then unique library-style signatures that mask address-dependent operands. It reports moved functions, changed bytes, additions, removals and ambiguous candidates. An identical byte or masked signature is matching evidence. The command reads both images without loading project annotations.

An export directory contains functions/*.c, fd_prelude.h, types.h, and index.tsv, strings.tsv, globals.tsv, xrefs.tsv, vcalls.tsv, classes.tsv, and methods.tsv. --single-file --out build/all.c writes one combined file and both headers beside it. Output is deterministic across worker counts. Export workers borrow one immutable session and own their function-local IR and text; the writer emits results in address order in bounded batches.

Desktop workbench

The optional desktop workbench shows a searchable function browser next to the disassembly and C-like pseudocode. Type a name or virtual address to filter the list. Press Enter to open the first match. The workbench runs on Apple Silicon and analyzes x86-64 and ARM64 binaries.

Install ui2 as a V module before building the workbench. ui2 installation instructions

make ui
./bin/decomp-ui build/demo

You can also start with an empty window, then choose Open Binary… or drop an executable onto the window. The app defaults to main when discovered. Keep decomp-ui and decomp in the same directory. The Code tab gets disassembly and pseudocode from the CLI over a read-only stdio session.

Instruction info

Place the caret on a disassembly instruction and click Info… or press Command/Ctrl + I. The inspector shows the instruction bytes, operands, register and memory effects, control flow, and encoding fields. Previous and Next move in listing order. Open the instruction in Code or Memory, or follow its mapped direct target or the first mapped memory operand.

Comments

Open Comments… in Annotations to browse saved function, instruction, and data comments. Filter by comment text or address, or by subject. Select a row to read the full comment, open its exact location in Code or Memory, or edit it in Annotations. Back returns to the list and restores its filter.

Function tags

Open Tags… in Disassembly or Function Tags in Annotations. Create a tag with a name and optional comment, then use Assign Tag on the current function. Tags can be reused across functions. Select a tag to see its members and select a function to open its entry in Code. Rename a tag or edit its comment with Save Changes. Remove Tag detaches it from the current function. Delete Tag removes the tag and all its assignments.

Decomp saves tags in the verified project's function-tags.jsonl. The CLI uses the same tags.

./bin/decomp function-tag build/demo create --name Reviewed --comment 'Checked against source'
./bin/decomp function-tag build/demo assign --name Reviewed --address 0xADDRESS
./bin/decomp function-tag build/demo list --name Reviewed --json

Control flow

Select a function and open Control Flow to see its basic blocks and recovered edges. Select a block to read all of its instructions and follow incoming or outgoing edges, including switch cases. Open Code selects the block’s first instruction in Disassembly. Use the zoom controls to inspect larger graphs and Entry to return to the function entry. Enable Calls to include resolved call targets. The CLI offers the same edge selection with cfg --calls.

Call tree

Open Call Tree to see incoming and outgoing calls for the function selected in the function list. Expand rows to follow callers or callees through other functions. Each call instruction has its own row. Recursive paths end at the repeated function, and imports and unresolved indirect targets remain visible. Select a row and choose Open Site to inspect its instruction or Open Function to inspect the related function. Back returns to the tree.

Cross-references

Open References and enter an image address. Incoming finds references to that address, At Address shows references from an instruction or loader slot there, and In Function shows references originating in the containing function. Find References in the Disassembly header starts an incoming search at the selected function or the instruction reached through a reference.

Select a result to open its source or a recovered code target in Disassembly. For a data target, Open Memory shows the bytes at that address. Use Find Uses to look up the target address.

Mapped memory

Open Memory to browse mapped ranges, permissions, and file-backed and zero-fill sizes. Select a range or enter a virtual address to view its bytes in hexadecimal and ASCII. Previous and Next move between pages of mapped bytes. Select a byte to see its virtual address and file offset or zero-fill status. Find References looks up incoming references to the selected byte.

Open Sections… in Mapped Ranges to browse named ELF, PE, and Mach-O sections. Filter by name, segment, kind, or start address and switch between mapped and unmapped sections. The details show header flags, file offsets, mapped permissions, backing, and RELRO slices. Jump to the first or last mapped byte, look up references to the first byte, or open Checksums with the section bounds filled in.

Choose Defined Data in Memory to browse sized symbols, loader slots, and saved global types. Filter by name, address, or type, and select an entry to see its byte preview and the fields or elements of its saved type. Open the exact bytes, incoming references, data annotation, or a resolved pointer target from the detail pane.

Use Relocations… in the Mapped Ranges pane to inspect load-time ELF RELA and RELR records, PE base relocations, and Mach-O dyld fixups. Filter by address, type, symbol, or binding status. The details show the original file bytes when the width and backing are known, the addend when available, and any resolved target. Open the relocation address in Memory, look up incoming references, or follow a mapped target.

Open Checksums… in Mapped Ranges to calculate the arithmetic checksums, CRCs, Adler-32, and MD and SHA digests supported by Ghidra's generator. Use the current mapped range, enter start and exclusive end addresses, or choose Whole Image. The report counts file-backed bytes in address order, including ranges separated by holes. Choose Byte Order to compare the numeric checksum bytes directly with Ghidra.

Open Memory → Debug Memory… and choose Launch to start the opened executable under LLDB. This uses lldb-dap on PATH or the macOS developer tools. When the process stops, enter a runtime address or a + offset from the displayed runtime image base, enter a byte count from 1 to 256, and choose Read. Use Continue and Pause to inspect another stop. Reread highlights bytes that changed at the same address, and End Debugging closes the launched process. Image Memory returns to the executable's mapped bytes.

Open Search Memory to find raw bytes. In Hex, spaces separate groups. Big endian reads the bytes in each group as entered, and Little endian reverses the bytes within each group. For example, 1234 56 matches 34 12 56 in little endian. An odd-length group has a leading zero. Use ? or . to match any nibble, or put either wildcard in its own group to match any byte. Binary accepts up to eight bits per byte, with ? or . for any single bit. Short groups have leading zeroes. Text supports ASCII, UTF-8, UTF-16LE, and UTF-16BE. Enable Ignore case to match either case of ASCII letters. Enable Escape sequences to interpret escapes such as \n, \t, \0, \\, \xNN, and \uNNNN. Text searches are case sensitive and literal by default. Decimal searches for signed or unsigned integers at 8, 16, 32, or 64 bits. Float and Double search for exact IEEE 754 encodings at 32 and 64 bits. For these numeric formats, select the byte order and separate consecutive values with spaces. Regex uses PCRE2 syntax on file-backed bytes. Use \xNN for a particular byte. A dot matches any byte by default, including line breaks. Matches are non-overlapping and contain at least one byte. The results show the full match length and preview the first 256 bytes. The preview validates the expression as you type. PCRE2 pattern syntax The Bytes and Mask preview updates as you edit the pattern or change format options. Each mask bit set to 1 must match the corresponding bit in the byte sequence. Scroll the preview horizontally to inspect long patterns. Use Alignment (bytes) to limit matches to addresses divisible by that number. Optional start and exclusive end addresses narrow the search. Use Match limit to cap the matches returned by each bulk search. Leave it blank for unlimited results. When a search reaches the limit, Decomp stops scanning and reports the limit in the status line. Its table, filters, and exports use the collected matches. A combination uses the applied limit for each input search. Decomp remembers the setting across launches. Directional finds keep working beyond the limit. Loaded blocks searches virtual addresses. Enable Unmapped file bytes to include gaps in the executable's file backing, such as unallocated sections. File hits use file:0x… offsets and open in Memory's file view. With both regions enabled, virtual addresses come first. Use file:0x… for a file bound or find origin, or leave both bounds blank to search both regions. With only file bytes enabled, plain numbers also denote offsets. Memory can switch between mapped and unmapped ranges. To search selected bytes, choose the first byte in Memory, turn on Select range, and choose the other endpoint. A manually selected range includes both endpoints and stays inside its mapping. Auto-restrict to selection is on by default. Opening Search Memory from Memory with a new selection enables Selection only. Turn off Selection only to restore your manual bounds and region options. Decomp remembers the automatic setting across launches. Search selection enables Selection only directly. Fill pattern from selection fills an empty pattern with one to nine contiguous selected bytes in Hex format when you open Search Memory from Memory. It is on by default and remembers your preference across launches. Toggle Instructions, Defined data, and Undefined data to filter matches by their starting byte. Defined data uses the same object symbols, pointer and import slots, and saved types as Defined Data. Fixed-width searches include mapped zero-fill. Each match stays within one mapped range. The results show exact labels and the instruction or data unit containing each match's first byte. For text and numeric formats, Match value decodes the bytes found using the selected encoding, width, signedness, and byte order. Text values show control characters and backslashes as escapes. Use Filter results to find rows by address, bytes, decoded value, label, or code unit. It searches across all result pages and includes directional and combined hits. Filter Options offers Contains, Starts with, Exact, and Regex, plus case sensitivity and inversion. Regex uses PCRE2 on the text of individual result cells. For text modes, All terms and Any term accept comma-separated terms. Quote a term that contains a comma. Use Column Filters to add rules for individual columns. Apply Rules combines them with the text filter across all result pages. AND binds before OR, and a column regex must match the entire cell. Clear Rules clears the column rules. Open Presets… in the column rule editor to save a named draft. Saved presets are available across binaries and launches. Load Preset fills the editor so you can review the rules before choosing Apply Rules. Removing a preset leaves any rules currently applied to the table in place. Click a column header to sort results across all pages. Click it again for descending order and a third time to restore search order. Match value sorts the displayed text. Clear Filter keeps the current sort and column rules. Clearing all filters and the sort returns to the original page. Open Columns… beside the filter to show, hide, or reorder the result columns. Decomp saves the layout across launches. Reset Columns restores the five default columns and their order. Hiding the sorted column restores search order. Use Select All to check matches across every result page within the applied limit and active filters. Decomp opens the complete list so you can review the selection. The header checkbox checks or clears the current list. Choose Copy rows for tab-separated text or Export CSV… for a file with column headers. Copy uses the checked rows or the focused match. With no rows checked, CSV export includes every result within the active filters. Both actions use the visible columns in table order. An ellipsis marks byte previews that end before the match does. Select a result to open its first byte in Memory. Back returns to the result list. Turn off Open results on single click in the search options to select a result without leaving the list. Double-click a row or use Open Match to inspect it. Decomp remembers the setting across launches. Press Down from the pattern or result filter to enter the results. Up, Down, Home, End, Page Up, and Page Down move through the displayed results. Return opens the focused match in either click mode. Space toggles the focused row’s checkbox. With the results focused, Command/Ctrl+A selects all matches and Command/Ctrl+C copies rows. Check rows and choose Select in Memory to highlight their full byte ranges. Overlapping and adjacent matches merge. Search selection searches those ranges and skips the gaps between them. Use the row checkboxes and Remove selected to trim the current result set. Removals stay in effect while paging. Search rebuilds the results, and Find Next or Find Previous can add a hit back. Refresh rereads match addresses in the executable on disk, including matches on later result pages. Changed byte and value cells are red, and their rows show the previous bytes on hover. Open Scan… and choose Unchanged, Changed, Increased, or Decreased to keep only those matches. Each action compares against the previous successful read or, for a new match, its original bytes. Numeric matches use their original width, byte order, and signedness. Other formats compare unsigned bytes in address order. Memory and Code show the analysis snapshot. Use Compare to… in the scan controls to apply the selected scan mode to a second executable. Decomp maps virtual addresses by their offset from each image base and uses the same file offset for matches outside loaded mappings. The comparison shows both addresses and byte values, with a count of ranges unavailable in the target. Select a row to open the source location or open the target location in a second workbench window. Export CSV… saves the comparison. Back to Search returns to the original results. Highlight matches marks returned hits in Memory’s hex and ASCII columns and in the instruction bytes shown in Code’s disassembly. It includes earlier result pages, directional hits, and combined results. The highlights follow row removals and remain distinct from byte selections. Toggle them in Memory or in the Search Memory options. Hide Search collapses the pattern, format, preview, and range fields. Hide Options independently closes the format settings, alignment, and filters. Both free space for results while keeping the active query, checked rows, paging, and directional find controls. Recent recalls up to eight searches from the current binary session. Select an entry to restore its pattern, format options, range, and alignment, then select Search to run it again.

Find Next and Find Previous locate the nearest match strictly after or before Find from. Opening Search Memory starts from the current workbench location. Found addresses accumulate above the bulk results, with the latest hit highlighted at the top. Revisiting a match or paging through bulk results keeps one row per address. Select any hit to inspect it in Memory. A fresh search replaces the accumulated hits. Searches stop at the range boundaries.

To combine searches, run the first query, edit the query, then open Combine… next to Search. Choose Union, Intersection, Symmetric Diff, Current Only, or New Only. These actions use every page and compare matches by their starting address. The current set includes directional hits and reflects any rows you removed. Union and intersection retain the longer match at a shared address. Cancel Combine keeps the current results, and Search replaces them with the new query.

From Code or Memory, press S to open Search Memory and focus the pattern field. Use Return in that field to run the search. Press F3 or Shift+F3 to repeat the last completed memory search forward or backward from the current location. In Code, an instruction hit selects it in the listing. Other hits open in Memory. Use Back to return to the starting location.

Program text

Open Search Text or press Command/Ctrl + Shift + F to find literal text in decoded instructions, mapped labels, and saved function, instruction, and data comments. Choose a field filter, enable Match case, or limit the search to the function selected in Code. Select a result to open its listing row, mapped byte, or annotation. Back returns to the results.

Scalar search

Open Search Text → Scalars… to find decoded instruction immediates, nonzero register-relative displacements, and integers and enums in initialized project-defined data. Defined data includes nested structure fields and array elements. Enter an exact value or an inclusive range in decimal or hexadecimal. Choose Signed for negative values, filter by bit width, or enable Current function to search that function's instructions. Select a result to open its exact address in Code or Memory. Instruction hits also offer Info to inspect the operands. Back returns to the results.

Recovered strings

Open Strings to browse recovered UTF-8 and UTF-16LE values. Search by text, filter by encoding, or enable Referenced only. Select a result to see its full text and properties. Open Memory selects its first byte and Find References lists recovered incoming references to its address.

Symbols

Open Symbols to search names, libraries, and addresses. Filter by functions, data symbols, imports, or exports. Select a result to inspect its binding, library, version, or forwarded destination. Follow recovered function entries to Disassembly or mapped data to Memory. Imports expose their stub and loader slot separately.

Program Diff and bookmarks

Open the first executable and select Program Diff. Choose the second file with Choose File… or drop it onto the tab, then click Compare. Enable Relative addresses to align rebased binaries. Analysis details includes instructions, data definitions, and references, including stack and register references. Project overlays compares annotations, bookmarks, and type headers when both binaries have adjacent .fdproj directories.

Choose Compare Functions… in Program Diff to review discovered matches, changed bytes, moved entries, and unpaired functions. Select a row to compare pseudocode or disassembly in aligned columns. Disassembly offsets are relative to each function entry. Generated pseudocode headers omit the entry address shown above each column. Previous Change and Next Change navigate the highlighted lines, with Shift+F7 and F7 as shortcuts. Select lines and press Command/Ctrl+C to copy them. Use Manual Pair to compare functions by exact name or image address, including two functions in the same executable. This view uses the unannotated output of both executables and requires matching architectures and calling conventions.

Open Transfer with the source executable loaded. Choose or drop the destination executable, then create its project if needed. Preview Transfer lists the annotations and type declarations with their source and destination values, match evidence, and any conflicts or skips. Select an item to inspect its full values. Apply Transfer writes the reviewed eligible batch into the destination project. If the plan changes, preview it again before applying.

Open Bookmarks to list and edit bookmarks for the current executable. Click Create Project if the binary has no project. Enter an address, type, category, and comment, then click Add Bookmark. Select a row to edit its comment or remove the bookmark. New starts a bookmark at the selected function's address when available.

Translate pseudocode

Install and sign in to the codex or claude CLI, then choose an Account and Model in the toolbar. Codex defaults to Terra and Claude defaults to Sonnet. The workbench remembers your model choice for each provider. Select a function and click Translate in the Decompiler pane. The selected CLI sends that function's pseudocode to its provider and returns a readable C rewrite. Use Original and Translation to switch views. Codex CLI reference · Claude Code CLI reference

The picker lists each CLI's default login and discovers additional accounts from ~/.fusecode/codex-accounts/ and ~/.fusecode/claude-accounts/. It uses the same per-account login directories and api-key files as FuseCode. Add accounts in FuseCode or sign in to named directories from a terminal. Use a different directory for each account.

mkdir -p -m 700 "$HOME/.fusecode/codex-accounts/work" "$HOME/.fusecode/claude-accounts/work"
CODEX_HOME="$HOME/.fusecode/codex-accounts/work" codex login
CLAUDE_CONFIG_DIR="$HOME/.fusecode/claude-accounts/work" claude auth login

Open the account picker again to see newly added accounts.

Translations use the enabled proxy from FuseCode's settings for both Codex and Claude. Decomp reads the settings each time it starts a translation. HTTP, HTTPS, SOCKS5, and SOCKS5H URLs are supported. SOCKS5 connections use a local HTTP CONNECT bridge that resolves provider hostnames through the SOCKS proxy. Loopback addresses bypass the proxy, along with entries in NO_PROXY or no_proxy.

To override the FuseCode setting when launching the workbench, set DECOMP_TRANSLATION_PROXY:

DECOMP_TRANSLATION_PROXY=socks5h://127.0.0.1:1080 ./bin/decomp-ui build/demo

Set DECOMP_TRANSLATION_PROXY= to skip the saved FuseCode setting and inherit the shell's proxy variables. Decomp also inherits them when FuseCode's proxy is disabled or unconfigured.

What is implemented

Area Current implementation
Images Checked AMD64 and ARM64 ELF64/PE64/Mach-O/fat, immutable/RELRO reads, relocations, actual import-stub targets, symbols/imports/exports; target-specific unwind ranges and exception metadata
Debug data Native DWARF 2–5 and PDB/MSF/CodeView readers, validated identities, ranges, names, types and signatures
Discovery Staged recovery, boundaries and stack depth, direct/tail/import calls, thunks, guarded jump-table proofs and bounded fallbacks
Instructions AMD64 integer/flags, REP strings and SSE/AVX; ARM64 integer/NZCV, addressing/writeback, scalar FP and NEON; conversions, shuffles and explicit intrinsic effects
SSA and optimization Global SSA, phi simplification, unthreading, known bits, width narrowing, arithmetic/magic-division rewrites, immutable folding, CSE/DCE and checked control recovery
Analysis Frame lattice, escape/liveness, slot promotion, canaries, balance, stack/register parameters, variadics and returns; SCC summaries, caller demand, type unification and class flow
Output Region forest, loops/switches/short circuits, phi destruction, local coalescing, independent statement AST, typed fields/locals/globals, enums/constants, virtual calls and explicit fallback
Names and classes Native Itanium/MSVC/Rust legacy/v0 grammars, overload identifiers, runtime-string naming, RTTI, inheritance, vtables and constructor/destructor evidence
Library data Platform prototypes, record layouts, constants/flag sets, contextual argument formatting, allocator/noreturn/FP evidence and runtime helper contracts
Library recognition Native .libsig format, code/data/call-context matching, archive/PDB-backed build/merge/truth tools and bundled MSVC databases
Projects Binary/fingerprint binding, function/global/line/parameter/frame/field assertions, C declarations and ABI layouts, validation, retraction and provenance-preserving compaction
Automation Structured decompilation JSON, resident prepared facts with project edits/change generations, and MCP read tools over stdio

Both architectures use the same discovery, SSA, analysis, decompilation, project, export, JSON, resident-service and MCP workflows. ARM64 uses AAPCS64 on ELF, the Apple ARM64 ABI on Mach-O, and the Windows ARM64 ABI on PE. This includes separate integer/FP argument banks, link-register returns, an incoming stack argument at sp+0, callee saves, and target-specific project type layouts.

The precise instruction families and operand limitations are in SUPPORTED_INSTRUCTIONS.md. ARM64 exception support recovers PE packed/unpacked function ranges and handler entries; complete ARM unwind opcode execution and ARM-specific C++ exception-language data remain outside the implemented subset. Platform library table coverage is described in libdata/README.md.

Reading the output

The text describes recovered machine operations. It is pseudocode, not the original source or a promise that a translation unit recompiles. Integer values retain their machine widths. Floating operations use bit patterns and helpers, so a scalar floating result can appear as uint64_t rather than a guessed C return type. For ELF binaries with DWARF, supported scalar result and register parameter types can appear in the emitted signature. The JSON signature reports dwarf when Decomp uses those types. Function signatures, incomplete argument lists, and uncertain metadata remain marked as likely or asserted.

__unknown(...) is an instruction whose semantics are not implemented. Its known register and memory effects remain visible. __indirect_jump(...) is an unresolved transfer. __clobbered_register(...) represents a call result or volatile register value that cannot be determined. These markers are part of the result and should not be read as no-ops.

The analysis assumes static code, the selected platform ABI, ordinary memory, and the default floating-point environment. It does not model concurrent interference, arbitrary self-modification, unmasked FP exceptions, or a custom calling convention. The default GC is part of the supported runtime setup.

Projects and types

A project defaults to BINARY.fdproj. --project DIR selects another project; --no-project ignores it. A project is bound to the executable's complete SHA-256, size and upstream quick hash. Older native metadata without a quick hash still checks SHA-256. --force permits applying presentation assertions to another binary and marks the binding unverified. Function assertions also carry code size and a relocation-insensitive fingerprint. Invalid subjects are withheld; fingerprint mismatches warn while retaining address-bound assertions.

./bin/decomp project init build/demo
./bin/decomp annotate build/demo types --decl \
  'struct node { int32_t key; int32_t flags; struct node *next; };'
./bin/decomp functions build/demo --name list_sum

Use the address printed by functions in the next command:

./bin/decomp annotate build/demo func 0xADDRESS \
  --name sum_keys \
  --sig 'int32_t sum_keys(struct node *list)' \
  --comment 'Sum the keys of the linked list'
./bin/decomp decompile build/demo --function sum_keys
./bin/decomp project check build/demo
./bin/decomp project compact build/demo

In decomp-ui, select a function and open Annotations to edit its name, C signature, and multiline comment. Copy from Code fills the signature editor with the current decompiler declaration. Create a project from the panel if needed. Empty fields clear saved overrides. In the CLI, --clear-name, --clear-sig, and --clear-comment remove individual overrides. For example, --name sum_keys --clear-comment applies both changes together.

In Annotations → Parameters, select a recovered parameter to edit its name and C type independently. Empty fields restore the recovered values. The Function tab controls parameters when a full C signature is saved.

Annotations → Stack Frame shows recovered stack slots, their offsets relative to the entry stack pointer or an aligned base, and their sizes. Local slots with addresses retained in Code support name overrides. Saving a name shows its alias in pseudocode. Clear the field to remove the alias.

Choose Annotate Data… on a mapped data symbol in Symbols, or at a data address in Memory, to edit its name, C type, and comment. Project names are searchable in Symbols. The editor links back to the exact address in Memory and to its incoming references.

Use the toolbar arrows or Command/Ctrl + [ and Command/Ctrl + ] to move back and forward through the current binary's workbench history. History restores linked addresses, view selections, and browser queries.

Go To… (Cmd/Ctrl+G) accepts a hex address with 0x, a decimal address, a symbol name or pattern, an address expression, or file(offset). For example, main+10 adds 16 bytes to main, and +20 adds 32 bytes to the current location. Expressions support +, -, *, /, <<, >>, and parentheses. Numbers in expressions are hexadecimal. Use double quotes around symbol names that contain spaces or expression operators.

Symbol patterns are case-sensitive by default. Enable Ignore case to match symbols regardless of case. Use * for any number of characters and ? for one character within a name. Use ** as a full namespace component to cross namespace levels, as in alpha::**::run*. A leading :: anchors the path at the global namespace. For example, core::run also matches alpha::core::run, while ::core::run starts at the global core namespace. A plain unqualified name prefers an exact match. Use **::run to find the same name across all namespaces.

Enable Dynamic labels to include generated names for unnamed recovered function entries (FUN_), branch targets (LAB_), and data reference targets (DAT_). The suffix is the hexadecimal virtual address, padded to at least eight digits. For example, LAB_* finds generated branch labels.

File offsets are decimal unless prefixed with 0x, as in file(0x1000). Decoded instruction starts open in Code, and other mapped addresses open at the requested byte in Memory. When a symbol or file offset maps to several addresses, select a destination from the list.

Recent recalls up to eight successful Go To queries for the open binary. Selecting one restores its text and search options. Press Go to run it again from the current location.

Choose Next/Previous… in Go To, or press Command/Ctrl + Shift + G, to jump to a nearby instruction, function, defined data item, undefined byte, label, or bookmark. The dialog starts at the current Code or Memory address and accepts an edited start address. Instruction, Data, and Undefined skip the contiguous run containing that address. Back returns to where you started.

Open Types to edit the project's types.h declarations. Save Types checks the header and the signatures and types that depend on it, then refreshes Code. If another edit changed the header, the editor keeps your draft and offers Discard & Reload to load the saved version. The CLI can read the header with decomp project types FILE or replace it with decomp project types FILE --replace-from HEADER.

To comment on an instruction, place the caret on its row in Disassembly and click Annotate…, or select the Annotations tab. The comment appears under that instruction in the listing and at its address in the pseudocode header. Show in Code returns to the annotated row.

Use bookmarks to mark addresses for review in a verified project.

./bin/decomp bookmark build/demo set --address 0xADDRESS --category review --comment 'Check bounds'
./bin/decomp bookmark build/demo list --category review --json
./bin/decomp bookmark build/demo remove --address 0xADDRESS --category review

Address, type, and category identify a bookmark. Setting the same bookmark updates its comment. The default type is Note and the default category is empty. Projects store bookmarks in bookmarks.jsonl when first edited.

The type parser supports structures, unions, enumerations, typedefs, pointers, function-pointer declarators, arrays, qualifiers, flexible array members, explicit offsets/sizes, packing/alignment, and checked constant expressions. Layouts distinguish LP64 and Windows LLP64. Constant expressions are bounded to signed 64-bit arithmetic and reject overflow.

An asserted signature supplies parameter display names when its ABI placement is understood; it never truncates a machine value to a narrower asserted type. Parameter, frame-local and field assertions guide display names and typed expressions. Line comments and global assertions retain their addresses. Machine-derived read/write contracts remain separate from presentation assertions. Unsupported annotation keys are rejected; invalid subjects, declarations and signatures are checked before a write. For example:

./bin/decomp annotate build/demo param 0xADDRESS a1 --name list
./bin/decomp annotate build/demo frame 0xADDRESS local_20 --name temporary
./bin/decomp annotate build/demo field node 0 --name key --type int32_t

--delete retracts the supplied properties. With no supplied property it retracts all properties of that subject. Records retain per-property by and note provenance through compaction. Projects use a versioned native format; an upstream Rust project's metadata file is not assumed compatible.

Correct the underlying analysis

Use Analysis Overrides from the workbench's Annotations page, or the analysis CLI, to change function entries and bounds, code/data classification, return behavior, indirect targets, bounded jump tables, and function/call-site calling conventions and scalar storage. These assumptions live in a separate analysis.jsonl log and require a verified binary, including with --force.

./bin/decomp analysis build/demo --json
./bin/decomp analysis build/demo --from corrections.json --dry-run --json
./bin/decomp analysis build/demo --from corrections.json --expect-analysis REVISION

The complete proposed log is validated and reanalyzed before an atomic save. Records retain author, note, and line provenance; append a matching kind and address with "delete":true to retract one. Decompilation and verification report these as analyst assumptions. See Analysis overrides for the record schema, examples, storage limits, and resident protocol.

Transfer annotations between builds

Initialize a project for the new image, then preview the transfer from the old image. Both project hashes must match their respective binaries.

./bin/decomp project init build/new
./bin/decomp transfer build/old build/new --json
./bin/decomp transfer build/old build/new --apply

--source-project DIR and --project DIR select the old and new project directories. The comparison uses discoveries from both images before project renaming. It can carry function names and comments across a unique symbol match even when the bytes changed. Signatures, parameter and frame annotations, and instruction comments require identical recovered code. A typed property also requires compatible layouts for the types it references. The preview lists conflicts, unchanged values, and skipped properties with their reasons.

Global names and comments follow unique shared object symbols, including globals with a changed address or initializer. Global types also require equal, known object sizes and enough mapped storage for the asserted type.

Missing declarations from types.h transfer together in source order. The planner recognizes duplicates even when whitespace or comments differ. The preview reports conflicts in the declaration group. Field annotations match by structure name and byte offset. The field name and type transfer as a pair, with separate provenance for its comment. Overlapping fields and incompatible layouts appear as conflicts.

--apply keeps existing destination values and transfers the eligible batch with the original author and note. Function-relative records get a fresh destination fingerprint. Repeating a transfer reports already copied values as unchanged. The planned and written counts include each annotation record and one additional item when the header changes.

JSON previews include a revision. Use --apply --expect-plan REVISION to apply only when the plan under the destination lock matches that preview.

Library recognition and debug input

Bundled signatures load by default. --libsig FILE adds a database, --libsig-only selects only supplied databases, and --no-libsig disables recognition. --pdb FILE selects a PDB, --no-debug disables debug input, and --no-strnames disables runtime-string naming.

./bin/decomp libsig info libid/data/msvc/msvc-vc-14.38.libsig
./bin/decomp libsig match build/demo --list
./bin/decomp libsig build build/demo --all-symbols --library demo -o build/demo.libsig
./bin/decomp libsig merge -o build/combined.libsig build/demo.libsig
./bin/decomp libsig --help

Construction also supports archive membership and PDB module provenance. libsig match --truth FILE.pdb compares recognition against PDB truth. Recognized types require agreement with actual parameter shapes; they do not replace machine contracts.

ARM64 signature databases use gnu-arm64 and msvc-arm64 families, separate from the AMD64 databases. Bundled MSVC signatures describe AMD64 code; ARM64 databases can be built from ARM64 binaries with the same commands.

Resident service

serve retains the image and prepared facts, accepts one JSON request per line on stdin, and writes one JSON response per line on stdout:

printf '%s\n' \
  '{"id":1,"op":"functions","name":"list"}' \
  '{"id":2,"op":"decompile","function":"list_sum"}' \
  '{"id":3,"op":"callers","function":"list_sum"}' \
  | ./bin/decomp serve build/demo

Read operations include info, memory_map, bytes, search_memory, functions, disasm, cfg, ir, decompile, imports, strings, globals, vcalls, xrefs, callers, callees, classes, class, and vtables. functions supports cursor/limit; text operations support offset/max_bytes with UTF-8-safe slicing. Decompilation JSON also describes signatures/parameters, callers/callees, strings/globals/classes, assertions, diagnostics and verification. callers and callees are directional queries.

sections_page lists nonempty named sections in section table order. It accepts cursor, limit, a case-insensitive grep, and a category of mapped, unmapped, or empty. Pass the row's index to section_details for the mapped slices and exact first and last mapped addresses. Section and slice ends are exclusive.

checksums accepts optional address and exclusive end bounds, a scope of sum (default), carry, or xor, and an optional numeric complement of ones or twos. It returns the file-backed byte count, hashed span count, and the values in hexadecimal, decimal where applicable, and Ghidra byte order.

search_memory accepts a pattern, an optional encoding of hex (default), binary, ascii, utf8, utf16le, utf16be, decimal, float, double, or regex, and optional address and end bounds. Text encodings accept boolean ignore_case (ASCII letters) and escape_sequences options. Decimal accepts a width in bits (default 32) and an unsigned flag. Hex and numeric formats accept byte_order of little or big. Hex defaults to big, and numeric formats default to little. The optional code_types array selects instruction, defined, or undefined match starts. Omit it or pass an empty array to include all types. The optional selection_ranges array contains objects with numeric start and exclusive end addresses. A match must fit within the selected bytes and the optional address bounds. Overlapping and adjacent ranges merge. Use "file": true to qualify an individual selection range as file offsets. The optional regions array selects loaded (the default) and file. With both, loaded addresses sort before file:0x… offsets. The memory_map service returns file ranges alongside virtual mappings, and bytes accepts file:0x… addresses in those ranges. Set include_context to return the label and containing code unit for each match when available. The context object includes kind, unit, and the optional label and unit_address fields. With this option, text, numeric, and regular-expression matches also include a value string. A regex result reports its full length and includes up to 256 bytes in its hex and value previews. Use a positive integer alignment to constrain match addresses. It returns matching addresses and bytes in ascending address order. Pass the response's next address as resume with the same search parameters to continue. limit is the maximum number of matches per response, from 1 to 500. Set stop_at_limit to true to stop as soon as that many matches are found. If the scan reaches the limit, the response sets limit_reached to true and returns an empty next.

preview_memory_pattern accepts the same pattern and format options as search_memory and returns bytes and mask as hex strings without scanning the address space. For regex it validates the expression and leaves both strings empty.

find_memory uses the same pattern, address bounds, selection ranges, alignment, code types, and context option. Pass an origin address and a scope of forward or backward. The response contains at most one match and an empty continuation.

search_text accepts a literal grep query, optional category of labels, instructions, or comments, a match_case boolean, and an optional exact function entry address to limit the search. Results use cursor and limit and include the matching field, address, owning function when known, and a preview around the match.

search_scalars accepts a decimal or hexadecimal minimum string and optional maximum string for an inclusive range. Use signed for two's-complement comparison, width for an exact width in bits (0 for any), or function_address for an exact function entry. Set category to instructions or data to search one source. The default searches both sources, with instruction hits first. Results use cursor and limit (1 to 500) and include hexadecimal, signed decimal, and unsigned decimal values as strings. Instruction hits include a zero-based operand index. Data hits include the exact field or element address, the root data_address, and an operand index of -1. A function scope searches only instructions.

comments_page lists saved function, instruction, and data comments in address order. It accepts cursor, limit, a case-insensitive grep filter on text or address, and an optional category of function-comment, instruction-comment, or data-comment. Rows contain text previews. Read the full comment using function_annotations, line_annotations, or global_annotations with the row's address.

The references operation takes address and a scope of to, from, or function. It returns individual recovered reference sites, including their source instruction and owning function when available. Results support cursor and limit.

instruction_info accepts an exact decoded instruction address and an optional function_address to identify its listing when code is shared. It returns bytes, operand metadata, effects, flow, and listing neighbors.

go_to accepts an address, symbol name or pattern, expression, or file(offset) in name. Set ignore_case to true for case-insensitive lookup or dynamic_labels to true to include generated labels. Supply the current location in address for relative expressions such as +20. File offset results report the total number of mapped addresses backed by the byte and return up to 40 destinations.

navigate_unit accepts a starting address, a scope of next or previous, and a category of instruction, function, data, undefined, label, or bookmark. It returns the same location shape as go_to. Data and instruction navigation skip the current contiguous run. Undefined navigation searches mapped bytes outside recovered instructions and known data definitions, and also skips the current run.

call_tree takes an exact function entry address and a scope of incoming or outgoing. It returns call links in instruction address order, including tail calls, with cursor and limit pagination.

strings_page accepts cursor, limit, case-insensitive grep, an optional encoding of utf8 or utf16, and the referenced_only boolean. A row's truncated flag indicates that its value is a preview. Use string_details with the row's address and encoding to get its full value.

symbols_page accepts cursor, limit, case-insensitive name, and an optional category of functions, data, imports, or exports. Rows retain same-address aliases and distinguish mapped locations from forwarded exports.

data_page accepts cursor, limit, a case-insensitive grep, and an optional category of typed, objects, or slots. Pass an exact row address to data_details for its backing, byte preview, typed components, and resolved pointer or resolver destination.

relocations_page accepts cursor, limit, a case-insensitive grep, and an optional category of resolved (including resolvers), binding, or other. Each record includes its source, type, status, and known width. When available, it returns the addend, original file byte preview, symbol, and mapped target.

serve BINARY --read-only exposes the inspection operations and prepares whole-program facts on the first request that needs them.

Project operations are project_init, project_check, project_status, annotate, analysis_overrides, analysis_override, reload, and changes_since. For example:

{"id":4,"op":"annotate","record":{"func":"0x1234","name":"read_packet"},"dry_run":true}

annotate accepts exactly one record, records, or types; dry_run validates without writing. Updates build validated replacement state, refresh retained facts, compare emitted-text hashes and advance the generation token. changes_since reports functions whose output changed since a token and removed function addresses in removed; unchanged reloads advance the token without false changes. Failed validation leaves files and token unchanged. Refresh currently reanalyzes the whole program; upstream dependency-driven incremental performance is not reproduced.

./bin/decomp mcp BINARY exposes the read tools using JSON-RPC over stdio and the MCP 2024-11-05 protocol. It reports tools through tools/list and accepts tools/call. Diagnostic text goes to stderr.

Verification

make check
make test
./bin/decomp selfcheck build/demo --jobs 4 --seeds 4

SSA, dominance, CFGs, regions and statement assignment are structurally checked. --verify and selfcheck compare lifted versus optimized IR and optimized IR versus an independently executed statement AST. Ordered traces include calls, intrinsics, unknown effects, stores, returns and traps; seeded models compare external effects. Separate concrete samples report unavailable memory, missing external models, undefined values, unsupported semantics and exhausted budgets as skipped. Arithmetic status flags are not ABI results; DF remains observable.

JSON results use structurally_valid and a separate verification object with runs, matched, skipped, and skip_reasons, together with distinct effect-trace, AST and frame statistics. Limited traces and skipped samples are not complete matches. These are bounded differential checks, not proofs of arbitrary output.

The test suite includes loader corruption checks, real compiled/stripped ELF and C++ RTTI fixtures, ownership move rejection, C type/layout checks, CFG and jump-table regressions, upstream scalar rewrite cases, generated CFGs through each stage, independently executed ASTs, emitted-C compilation/execution, deterministic parallel output, all project subjects, library-signature commands and MCP/session integration. The original-source CLI suite builds four variants of the small corpus, checks source-function discovery, and compares compiled emitted C against independently compiled original C over boundary and random inputs. See PARITY.md for the reference revisions, regression cases, commands and limits. ARM64 tests also cover independently assembled instruction encodings and an LLVM-generated ELF fixture, including integer/FP parameters, nine integer arguments, a loop, calls, globals, and NEON operations. tests/generate_arm64_fixture.py optionally regenerates this fixture using an installed LLVM shared library; LLVM is not needed to run the tests. Native architecture suites compare before/after optimization against the CPU and report host-feature skips; exact coverage is documented in the instruction table. Every V test compiles with -ownership; the runner also rejects allocator diagnostics even on exit status 0.

The completed x86 parity validation report and machine-readable record identify the original tested revision before ARM64 integration, 83 passing native V suites, all four then-existing CLI suites under normal and production builds, and results for four small and eight medium corpus inputs. The report preserves Lua's shared unsupported x87 effects, skipped execution samples and the original Rust tests blocked by ptrace. The complete upstream 29-entry corpus has not been run, and no full output or performance parity is claimed. The Ghidra benchmark records results for a separate freestanding nine-function corpus.

For a constrained development environment, DECOMP_TEST_LOW_DISK=1 removes passing test binaries. DECOMP_TEST_CC selects the C compiler for V test builds without changing the native C/C++ fixture compiler; for example, DECOMP_TEST_CC=tcc DECOMP_TEST_CFLAGS='' make test. CI uses the default C compiler.

License and attribution

MIT, preserving the upstream copyright notice. See LICENSE, UPSTREAM.md, the Zydis/Zycore licenses under thirdparty/zydis, and the library-data notice.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages