[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DAT45EN9J24RAYSMWQNDZH":3,"skill-same:01M7DAT45EN9J24RAYSMWQNDZH":77},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7DAT45EN9J24RAYSMWQNDZH","ghidra-rpc",null,"alicewe1\u002Falice_skill","alicewe1","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F102134151?v=4","01M7D9STCM8HAESM958JP0989K","Alice_we","01M7D9STDR22MTD9FTTWPAZNV8",64,"GPL-3.0","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: ghidra-rpc\ndescription: >\n  Reverse engineering assistant powered by Ghidra. Use for binary analysis,\n  decompilation, vulnerability research, auditing compiled code, renaming symbols,\n  annotating disassembly, cross-references, or any RE task - even without explicit\n  mention of Ghidra.\nx-alice-class: reverse\n---# Ghidra RPC\n\nA CLI daemon that exposes Ghidra reverse engineering capabilities over a Unix domain socket.\nYou interact with it by running `ghidra-rpc` commands via the bash tool - every command\noutputs JSON to stdout.\n\n## Running Commands\n\n**All `ghidra-rpc` commands must be run with `uv run` from the ghidra-rpc skill directory\n(the directory containing this SKILL.md file):**\n```bash\ncd \u003Cskill-dir> && uv run ghidra-rpc \u003Ccommand> ...\n```\n\n## Prerequisites Check\n\nBefore using any commands, verify the setup:\n\n1. **Is the daemon running?** Run `uv run ghidra-rpc status --project \u003Cpath>`. If not running,\n   the user needs to start it in a separate terminal: `uv run ghidra-rpc start --project \u002Fpath\u002Fto\u002Fproject.gpr`\n   (blocking, human-only). The `--headless` flag skips the GUI. For non-blocking \u002F automated\n   startup use `start --detach --headless` or `restart --headless`. Both commands accept\n   `--timeout SECS` (default: 60 s headless, 180 s GUI) and log daemon output to\n   `\u002Ftmp\u002Fghidra-rpc-\u003Chash>.log`.\n2. **GUI mode: verify the correct project is active.** The daemon passes the `--project` path\n   directly to GhidraRun so Ghidra opens the requested project immediately. After\n   `start --detach` (GUI mode), confirm the right project is loaded before issuing any\n   analysis commands:\n   ```bash\n   uv run ghidra-rpc list-project-programs --project \u002Fpath\u002Fto\u002Fproject.gpr\n   ```\n   Cross-check the returned binary names against what you expect. If the names don't match\n   (or a `warning` field appears in the response), stop and ask the user to open the correct\n   project in Ghidra's Project window before proceeding.\n3. **GUI mode: open the binary in CodeBrowser.** In GUI mode the daemon discovers programs\n   via the running CodeBrowser tool. If the binary is in the project but not currently open\n   in CodeBrowser, `list-binaries` will return empty and all commands will fail with\n   \"Binary not found\". Use `list-project-programs` to see what's stored in the project,\n   then double-click the program in Ghidra's Project window to open it.\n4. **Is `GHIDRA_INSTALL_DIR` set?** The daemon will fail loudly if this is missing.\n\nOnce the daemon is running, all commands below work automatically. If the daemon dies,\ncommands will attempt auto-restart from the saved session.\n\n## Command Reference\n\nEvery command accepts `--project \u003Cpath>` (or reads `GHIDRA_RPC_PROJECT` env var).\nAll output is JSON. Exit code 0 = success, 1 = error.\n\n### Project Management\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `ghidra-rpc start --project \u003Cgpr> [--headless] [--detach] [--ghidra-install-dir DIR]` | Start daemon (blocking by default; `--detach` backgrounds it) | `ghidra-rpc start -p \u002Ftmp\u002Fre.gpr --headless --detach` |\n| `ghidra-rpc stop --project \u003Cgpr>` | Stop the daemon | `ghidra-rpc stop -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc status --project \u003Cgpr>` | Check if daemon is running | `ghidra-rpc status -p \u002Ftmp\u002Fre.gpr` |\n\n`status` output: `{running, socket, mode, mode_source, project, binaries}`. `binaries` is the loaded-binary list when the daemon is running, `null` when stopped (one-shot health check without a second `list-binaries` call). `mode_source` is\n`\"running\"` when the daemon is live, `\"session\"` when the mode is from the saved\nsession only (daemon stopped), and `null` if no session exists.\n| `ghidra-rpc restart --project \u003Cgpr> [--headless] [--timeout SECS] [--ghidra-install-dir DIR]` | Restart daemon in background (`--headless` to override mode) | `ghidra-rpc restart -p \u002Ftmp\u002Fre.gpr --headless` |\n| `ghidra-rpc list-binaries --project \u003Cgpr>` | List binaries loaded in daemon | `ghidra-rpc list-binaries -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc list-project-programs --project \u003Cgpr>` | List all programs stored in the project repo (reads project folder, not CodeBrowser live state; returns `warning` if the active Ghidra project doesn't match) | `ghidra-rpc list-project-programs -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc save [binary] --project \u003Cgpr>` | Save program(s) to disk (auto-save also runs after every write) | `ghidra-rpc save -p \u002Ftmp\u002Fre.gpr` |\n\n### Loading & Analysis\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `ghidra-rpc load \u003Cpath> -p \u003Cgpr> [--no-analyze] [--analysis-timeout SECS]` | Import & analyze a binary | `ghidra-rpc load \u002Fusr\u002Fbin\u002Ftarget -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc metadata \u003Cbinary> -p \u003Cgpr>` | Binary metadata (arch, bits, format) | `ghidra-rpc metadata target -p \u002Ftmp\u002Fre.gpr` |\n\n`load` flags:\n- `--no-analyze` - skip auto-analysis entirely (fast; useful when you only need the\n  listing or plan to run analysis later via Ghidra GUI).\n- `--analysis-timeout SECS` - abort auto-analysis after the given wall-clock budget\n  (best-effort); the binary is saved with whatever analysis completed in time.\n\n### Listing\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc functions \u003Cbinary> [--offset N] [--limit N] [--address-min ADDR] [--address-max ADDR] [--with-body]` | List functions (paginated); `--address-min\u002Fmax` for server-side range filter; `--with-body` adds body range fields | `{functions: [{name, address, signature[, body_min, body_max, body_size]}], count, total, offset}` |\n| `ghidra-rpc imports \u003Cbinary>` | List imports | `{imports: [{name, address, library}], count}` |\n| `ghidra-rpc exports \u003Cbinary>` | List exports | `{exports: [{name, address}], count}` |\n| `ghidra-rpc relocations \u003Cbinary> [--address ADDR] [--limit N]` | List relocation table entries | `{relocations: [{address, type, symbol, bytes, status}], count, total}` |\n| `ghidra-rpc list-calling-conventions \u003Cbinary>` | List valid calling convention names for the architecture | `{conventions: [str], default, count}` |\n\n### Decompilation\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc decompile \u003Cbinary> \u003Cfunc> [--timeout SECS]` | Decompile to pseudo-C (default **120 s**) | `{name, address, signature, c_code}` |\n| `ghidra-rpc basic-blocks \u003Cbinary> \u003Cfunc> [--limit N]` | Get basic blocks (CFG) of a function | `{name, address, blocks:[{start,end,size,instructions,successors,predecessors}], num_blocks, edges}` |\n| `ghidra-rpc pcode \u003Cbinary> \u003Cfunc> [--high] [--timeout SECS] [--limit N]` | Get P-code (Ghidra IR); raw or high SSA form (--high) | `{name, address, mode, ops:[{address,seq,opcode,output,inputs}], count, truncated}` |\n| `ghidra-rpc search-decompiled \u003Cbinary> \u003Cregex> [--class NAME] [--case-sensitive] [--limit N] [--max-scan N] [--timeout SECS] [--socket-timeout SECS]` | Regex-search decompiled C across many functions in one call (skips one-RPC-per-function `decompile`+grep loops) | `{matches:[{function,address,matching_lines:[{line,text}]}], count, functions_searched, functions_total, truncated}` |\n\n`\u003Cfunc>` can be a function name or hex address (e.g., `main` or `0x401000`). If the name\nis ambiguous, the error message lists matches so you can use the address instead.\n\n`search-decompiled` is especially useful on multidex Android projects, where `xrefs-to`\non a method only sees callers within the same DEX program (see the Android APK\u002FDEX\nsection) — use it in place of a symbols+decompile+grep loop, e.g. `search-decompiled\napp.apk targetF1 --class\ncom::example::Foo`. `--max-scan` (default 5000) bounds how many functions get decompiled\nwhen `--class` isn't given, so a search on a 50k+-function binary can't run away; raise\n`--socket-timeout` (default 1800s) alongside it if you do widen the scan.\n\n### Search\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc find-bytes \u003Cbinary> \u003Cpattern> [--limit N] [--address ADDR]` | Search for byte pattern with wildcards (e.g. `\"55 8b ?? 83 ec\"`) | `{pattern, matches: [{address, context_hex}], count, truncated}` |\n| `ghidra-rpc strings \u003Cbinary> \u003Cquery> [--limit N]` | Search strings (substring) | `{strings: [{address, value, type}], count}` |\n| `ghidra-rpc symbols \u003Cbinary> \u003Cquery> [--limit N] [--offset N]` | Search symbols | `{symbols: [{name, address, type}], count, total}` |\n\n`symbols` normalizes literal spaces and underscores as equivalent before matching, so a\nquery pasted straight from `strings` output (real spaces) still finds the corresponding\nlabel even though Ghidra auto-generates labels from string content by turning each space\ninto `_` (and leaving every other character, including non-ASCII\u002FCJK text, untouched).\n\n### Cross-References\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc xrefs-to \u003Cbinary> \u003Ctarget> [--limit N] [--all-binaries]` | Who references this? | `{xrefs: [{from_address, from_function, type}], count}` |\n| `ghidra-rpc xrefs-from \u003Cbinary> \u003Ctarget> [--limit N] [--no-stack]` | What does this reference? (`--no-stack` hides `Stack[-0x...]` entries) | `{xrefs: [{to_address, to_function, type}], count}` |\n\nGhidra's reference manager is per-binary: a call whose caller and target live in two\n*different* loaded binaries is invisible to a single-binary `xrefs-to` lookup (most\ncommonly hit on multidex Android projects, where a method in one `classesN.dex` is\ncalled from another, but this isn't DEX-specific — it applies to any project with more\nthan one binary loaded in the daemon). Pass `--all-binaries` to also search every other\ncurrently loaded binary for a symbol with the same fully-qualified name and merge in\nreal callers found there; each merged entry carries a `binary` field so you can tell\nwhich binary it came from.\n\n### Navigation (GUI mode only)\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc goto \u003Cbinary> \u003Ctarget> [function\\|address]` | Navigate GUI | `{address, success}` |\n\n### Memory & Disassembly\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc memory-map \u003Cbinary>` | List all memory segments (name, address range, size, rwx flags, type) | `{segments: [{name, start, end, size, read, write, execute, initialized, type, source_name}], count}` |\n| `ghidra-rpc write-bytes \u003Cbinary> \u003Caddress> \u003Chex>` | Write raw bytes to an address; does NOT auto-redisassemble | `{address, length, hex, verified}` |\n| `ghidra-rpc read-bytes \u003Cbinary> \u003Caddress> \u003Clength>` | Read raw bytes; LENGTH accepts decimal or `0x` hex | `{address, length, hex, hexdump}` |\n| `ghidra-rpc read-pointers \u003Cbinary> \u003Caddress> \u003Ccount> [--pointer-size N]` | Read COUNT pointers and resolve each to its symbol (vtables, import\u002Fjump tables, RTTI arrays) | `{address, count, pointer_size, endian, pointers:[{index, offset, slot_address, value, target_address, target_name, target_kind}]}` |\n| `ghidra-rpc list-vtable \u003Cbinary> \u003Caddress> [--count N] [--pointer-size N]` | Dump a C++ vtable's slots as resolved methods; ADDRESS may be a symbol name. Without `--count`, stops at the next vftable symbol \u002F first non-function pointer (see `stopped_reason`) | `{vtable_address, symbol, count, pointer_size, stopped_reason, slots:[{index, offset, slot_address, target_address, target_name, target_kind}]}` |\n| `ghidra-rpc disassemble \u003Cbinary> \u003Caddress> [--count N]` | Disassemble N instructions (default 20); `warning` field if start address had no instruction | `{address, count, instructions:[{address,bytes,mnemonic,operands,length,comment}], listing[, warning]}` |\n| `ghidra-rpc assemble \u003Cbinary> \u003Caddress> \u003Cinstr> [\u003Cinstr> ...]` | Assemble instruction text at address (Ghidra SLEIGH assembler) | `{address, bytes_written, hex, instructions:[{address,bytes,mnemonic,operands,length}]}` |\n\n### Modifications\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc create-function \u003Cbinary> \u003Caddress> [--name NAME]` | Create a function at an address (auto-detects body from flow) | `{name, address, size, body}` |\n| `ghidra-rpc delete-function \u003Cbinary> \u003Ctarget>` | Remove a function definition (bytes unchanged; address reverts to undefined) | `{address, name, deleted}` |\n| `ghidra-rpc rename-function \u003Cbinary> \u003Ctarget> \u003Cnew_name> [--namespace NS]` | Rename function; `--namespace` moves it into a namespace | `{address, old_name, new_name, verified[, old_namespace, new_namespace]}` |\n| `ghidra-rpc rename-symbol \u003Cbinary> \u003Caddress> \u003Cnew_name> [--create]` | Rename symbol; `--create` makes a new label if none exists | `{address, old_name, new_name, created, verified}` |\n| `ghidra-rpc create-label \u003Cbinary> \u003Caddress> \u003Cname>` | Create-or-rename a label at any address (upsert) | `{address, name, old_name, action, created, verified}` |\n| `ghidra-rpc set-comment \u003Cbinary> \u003Caddress> --comment \u003Ctext> [--type TYPE]` | Set comment (comment text is `--comment`, matching `set-bookmark`) | `{address, comment_type, comment, verified}` |\n| `ghidra-rpc batch-rename \u003Cbinary> --json \\|--json-file FILE [--mode function\\|label]` | Rename 40+ functions\u002Flabels in one transaction; per-item error reporting | `{results:[{ok, index, address, old_name, new_name}], count, ok_count, error_count}` |\n| `ghidra-rpc batch-set-comment \u003Cbinary> --json \\|--json-file FILE` | Set comments at many addresses in one transaction | `{results:[{ok, index, address, comment_type, comment}], count, ok_count, error_count}` |\n| `ghidra-rpc set-signature \u003Cbinary> \u003Ctarget> \u003Csignature>` | Set function signature | `{address, old_signature, new_signature, verified}` |\n| `ghidra-rpc set-data-type \u003Cbinary> \u003Caddress> \u003Ctype>` | Define data type in listing | `{address, data_type, length, value}` |\n| `ghidra-rpc retype-variable \u003Cbinary> \u003Cfunc> \u003Cvariable> \u003Ctype> [--timeout SECS]` | Retype decompiler variable | `{function, variable, old_type, new_type, verified}` |\n| `ghidra-rpc rename-variable \u003Cbinary> \u003Cfunc> \u003Cvariable> \u003Cnew_name> [--timeout SECS]` | Rename decompiler variable | `{function, variable, new_name, verified}` |\n| `ghidra-rpc batch-edit-variable \u003Cbinary> \u003Cfunc> --json \\|--json-file FILE [--timeout SECS]` | Rename and\u002For retype many locals in ONE decompiler snapshot — avoids the auto-name renumbering that breaks chained single edits. Each op: `{variable\\|storage, new_name?, data_type?}` (identify by name or storage string; at least one of new_name\u002Fdata_type) | `{function, results:[{ok, index, variable, storage, old_name, new_name, old_type, new_type, verified}], count, ok_count, error_count, verified_count}` |\n| `ghidra-rpc set-calling-convention \u003Cbinary> \u003Ctarget> \u003Cconvention>` | Change a function's calling convention | `{address, name, old_convention, new_convention, verified}` |\n| `ghidra-rpc set-thunk \u003Cbinary> \u003Cthunk> \u003Ctarget>` | Mark a function as a thunk (forwarding wrapper) | `{thunk_address, thunk_name, target_address, target_name, verified}` |\n| `ghidra-rpc set-flow-override \u003Cbinary> \u003Caddress> \u003Coverride>` | Override instruction flow type (NONE\u002FBRANCH\u002FCALL\u002FCALL_RETURN\u002FRETURN) | `{address, override, old_override, verified}` |\n| `ghidra-rpc get-processor-context \u003Cbinary> \u003Caddress> [--register REG]` | Inspect ISA context register values (e.g. TMode on ARM) | `{address, registers:{name:value}}` |\n| `ghidra-rpc set-processor-context \u003Cbinary> \u003Caddress> \u003Cregister> \u003Cvalue> [--end ADDR]` | Set ISA context register over a range — fixes ARM Thumb mis-classification | `{address, end, register, value, verified}` |\n| `ghidra-rpc create-namespace \u003Cbinary> \u003Cname> [--parent NS]` | Create or look up a namespace | `{name, path, id, created}` |\n| `ghidra-rpc list-namespaces \u003Cbinary> [--limit N]` | List all namespaces with symbol counts | `{namespaces:[{name,path,id,type,symbol_count}], count}` |\n\nComment types: `plate`, `pre`, `post`, `eol` (default), `repeatable`.\n\nSignature input is sanitised automatically: trailing semicolons are stripped,\nwhitespace is trimmed, and inline calling conventions (`__thiscall`, `__fastcall`,\n`__stdcall`, `__cdecl`, `__vectorcall`, `__pascal`) are extracted from the string\nand applied via the proper Ghidra API. So you can paste a C prototype directly\n(e.g. `void __thiscall Foo::Bar(int x);` works without manual cleanup).\n\nType expressions for `set-data-type`, `retype-variable`, and struct field types:\n- Built-ins: `byte`, `char`, `int`, `uint`, `short`, `long`, `float`, `double`, `void`, `string`, `unicode`\n- Pointer: `char *`, `void *`, `int **`\n- Array: `char[11]`, `int[4]`\n- Any type in the program's data type manager by name or path: `MyStruct`, `\u002FPOSIX\u002Fsize_t`\n\n**Order of operations — set signatures\u002Ftypes before naming locals.** Each of\n`set-signature`, `set-data-type`, `retype-variable`, and `rename-variable` re-runs the\ndecompiler, which re-numbers the remaining auto-named locals (`uVar1`, `dVar2`, …). So\nchaining single-variable edits is fragile: after renaming `dVar1`, the old `dVar2` may\nnow be `dVar1`. Do all signature\u002F`this`-typing first, then name locals — or, better, use\n`batch-edit-variable` to apply every rename **and** retype against a single decompiler\nsnapshot in one call (it also lets you address a variable by its stable `storage` string\ninstead of the volatile auto name).\n\n### Bookmarks\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc set-bookmark \u003Cbinary> \u003Caddress> [--type TYPE] [--category CAT] [--comment TEXT]` | Create\u002Fupdate a bookmark at an address | `{address, type, category, comment, action}` |\n| `ghidra-rpc list-bookmarks \u003Cbinary> [--type TYPE] [--category CAT] [--address ADDR] [--limit N]` | List bookmarks (all, by type, category, or at address) | `{bookmarks: [{address, type, category, comment}], count, total}` |\n| `ghidra-rpc remove-bookmark \u003Cbinary> \u003Caddress> [--type TYPE] [--category CAT]` | Remove a bookmark at an address | `{address, type, removed}` |\n\nBookmark types: `Note` (default), `Warning`, `Error`, `Info`, `Analysis`.\n\n`--category` is a case-insensitive substring filter. On heavily auto-analyzed binaries\n(large native programs, and especially DEX\u002FDalvik — 50k+ functions is normal), Ghidra\ngenerates many `Analysis`-type bookmarks (commonly category `Address Table`) that can\nbury a handful of your own; filter them out with `--category` (or `--type` to isolate\nyour own type, e.g. `Note`) instead of paging through the unfiltered list.\n\nBookmarks are visible in the Ghidra GUI's Bookmarks window. Use them to\npersistently mark interesting locations, track analysis progress, or flag\nfindings for human review.\n\n### Function Tags\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc tag-function \u003Cbinary> \u003Ctarget> --tag TAG` | Add a tag to a function for classification | `{address, name, tag, all_tags}` |\n| `ghidra-rpc untag-function \u003Cbinary> \u003Ctarget> --tag TAG` | Remove a tag from a function | `{address, name, tag, removed, all_tags}` |\n| `ghidra-rpc list-tags \u003Cbinary>` | List all defined tags with use counts | `{tags:[{name,count}], count}` |\n| `ghidra-rpc functions-by-tag \u003Cbinary> --tag TAG [--limit N]` | List functions with a specific tag | `{tag, functions:[{name,address,signature}], count, total}` |\n\nTags are string labels (e.g. `crypto`, `vuln-sink`, `analyzed`, `needs-review`)\nvisible in Ghidra's Function Tags window. Use them to classify functions\nand track analysis progress.\n\n### Data-Type Authoring\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc create-struct \u003Cbinary> \u003Cname> TYPE FIELD [TYPE FIELD ...] [--if-not-exists\\|--or-replace]` | Create a named struct; `--if-not-exists` is idempotent, `--or-replace` rebuilds it | `{name, path, size, fields:[...], already_existed}` |\n| `ghidra-rpc create-struct \u003Cbinary> \u003Cname> --field OFFSET TYPE NAME [--field ...]` | Create a struct laying fields at explicit byte offsets (OFFSET is decimal or 0x hex); gaps between fields are auto-padded with undefined bytes (no manual pad fields). Overlaps are rejected. | `{name, path, size, fields:[...], already_existed}` |\n| `ghidra-rpc create-union \u003Cbinary> \u003Cname> TYPE FIELD [TYPE FIELD ...] [--if-not-exists\\|--or-replace]` | Create a named union; all fields share offset 0 | `{name, path, size, fields:[...], already_existed}` |\n| `ghidra-rpc modify-struct \u003Cbinary> \u003Cstruct_name> --field-offset N\\|--field-name NAME [--new-type TYPE] [--new-name NAME]` | Retype, rename, or re-comment a struct field | `{name, path, size, fields:[...], modified_field:{...}}` |\n| `ghidra-rpc clear-data-range \u003Cbinary> \u003Cstart> \u003Cend>` | Reset inclusive byte range to undefined | `{start, end, cleared}` |\n| `ghidra-rpc apply-data-type-range \u003Cbinary> \u003Cstart> \u003Cend> \u003Ctype> [--clear]` | Stamp a type repeatedly across an inclusive range; `--clear` clears the region atomically before stamping | `{start, end, data_type, type_size, applied_count, cleared}` |\n| `ghidra-rpc list-labels \u003Cbinary> \u003Caddress> [--end ADDR] [--limit N]` | List symbols at an address or in a range, including data type at each location | `{labels:[{address,name,type,source,is_primary,data_type,data_length}], count, total}` |\n| `ghidra-rpc create-enum \u003Cbinary> \u003Cname> NAME VAL [NAME VAL ...] [--size 1|2|4|8] [--if-not-exists|--or-replace]` | Create a named enum in the DTM | `{name, path, size, values:[{name,value}], already_existed}` |\n| `ghidra-rpc modify-enum \u003Cbinary> \u003Cname> [--add NAME:VAL ...] [--remove NAME ...]` | Add\u002Fremove individual entries from an existing enum | `{name, path, size, values:[{name,value}]}` |\n| `ghidra-rpc set-equate \u003Cbinary> \u003Caddr> \u003Cequate_name> \u003Cvalue> [--operand-index N] [--enum-path PATH]` | Attach a named scalar constant to an instruction operand; auto-links to enum if found | `{address, operand_index, equate_name, value, enum_linked, verified}` |\n| `ghidra-rpc list-equates \u003Cbinary> [address] [--limit N]` | List all equates in the program or only those applied at an address | `{equates:[{name,value[,operand_index,address]}], count, total}` |\n| `ghidra-rpc list-data-types \u003Cbinary> [--category CAT] [--query SUBSTR] [--limit N]` | List types in the DTM; category: struct, enum, union, typedef, pointer, array, all | `{data_types:[{name,path,category,size}], count, total}` |\n\n### Version Tracking & Diff\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc version-track \u003Cold> \u003Cnew> [--changed-only] [--limit N] [--min-similarity F]` | Match functions between two versions; find what changed. Results deduplicated per source function. | `{matched:[{source_name,destination_name,similarity,confidence,correlator}], unmatched_source, unmatched_destination, summary:{source_functions_total, changed_functions, identical_functions, ...}}` |\n| `ghidra-rpc function-diff \u003Cbin1> \u003Cfunc1> \u003Cbin2> \u003Cfunc2> [--mode decompile\\|disassembly]` | Unified diff of a function between two versions; normalises auto-generated names (`FUN_*`, `DAT_*`, `local_*`, `param_*`) to suppress relocation noise | `{is_identical, diff, raw_code1, raw_code2, func1_address, func2_address}` |\n| `ghidra-rpc match-function \u003Cbin1> \u003Cfunc> \u003Cbin2> [--threshold F]` | Find best match for a function in another binary using BSim + correlators | `{source:{name,address}, candidates:[{name,address,similarity,confidence,correlator}], count}` |\n| `ghidra-rpc decompile-all \u003Cbinary> [--limit N] [--offset N] [--timeout SECS] [--socket-timeout SECS]` | Bulk decompile all functions; for export and external diff tools | `{functions:[{name,address,signature,c_code}], count, total, offset, errors}` |\n\n`decompile-all`'s default `--socket-timeout` (1800s) assumes a bulk sweep can take much\nlonger than any single function's `--timeout`; raise it further for binaries with tens of\nthousands of functions (e.g. large DEX\u002FAPK programs).\n\nFor the full patch-diff workflow see `docs\u002Fflows\u002Fpatch-analysis.md`.\n\n## Error Handling\n\nError responses look like:\n```json\n{\"id\": \"...\", \"ok\": false, \"error\": \"FunctionNotFound\", \"message\": \"Function 'foo' not found.\"}\n```\n\nCommon errors:\n- **DaemonNotRunning**: Daemon isn't started. Tell the user to run `ghidra-rpc start`.\n- **ValueError**: Bad argument (ambiguous name, invalid address). The message usually tells\n  you what to do - e.g., use a more specific name or an address.\n- **RuntimeError**: Ghidra-level error. For GUI-only commands in headless mode, the error\n  says so explicitly.\n\n**All CLI output is JSON, including usage errors.** A malformed invocation (unknown\noption, invalid `--type` choice, unknown subcommand, missing required argument) is also\nreported as `{\"ok\": false, \"error\": \"...\", \"message\": \"...\"}` on stdout, with a nonzero\nexit code — never a plain-text Click usage string. Scripted callers can always\n`json.loads()` stdout unconditionally, without special-casing argument errors.\n\n## Write Operations & Persistence\n\nWrite operations (rename, create-label, create-function, delete-function, set-comment, batch-rename, batch-set-comment, set-signature, set-data-type, retype-variable, rename-variable, batch-edit-variable, set-calling-convention, set-thunk, set-flow-override, set-processor-context, create-struct, create-union, modify-struct, create-enum, modify-enum, set-equate, set-bookmark, clear-data-range, apply-data-type-range, write-bytes, assemble, tag-function, untag-function, create-namespace)\nuse Ghidra transactions internally. **Every write is automatically saved to the project\ndatabase on disk** after the transaction commits, so changes survive daemon restarts and\nare visible when the project is reopened in the Ghidra GUI.\n\nEvery write response includes a `verified` boolean that confirms whether the change was\nread back successfully after committing.\n\nYou can also save explicitly at any time:\n```bash\nghidra-rpc save              # saves all loaded programs\nghidra-rpc save \u003Cbinary>     # saves one program\n```\n\nOn clean shutdown (`stop` or Ctrl+C), all programs are saved automatically.\n\n## Patch \u002F Diff Analysis Quick Start\n\n```bash\n# 1. Load both versions\nghidra-rpc load \u002Fpath\u002Fto\u002Fbinary_v1 -p project.gpr\nghidra-rpc load \u002Fpath\u002Fto\u002Fbinary_v2 -p project.gpr\n\n# 2. Find changed functions (summary counts all changes; matched list is filtered)\nghidra-rpc version-track binary_v1 binary_v2 --changed-only\n\n# 3. Diff a specific changed function\nghidra-rpc function-diff binary_v1 \u003Cfunc> binary_v2 \u003Cfunc>\n```\n\nFull workflow — correlator details, unmatched analysis, bulk decompile:\nread `docs\u002Fflows\u002Fpatch-analysis.md`.\n\n## Android APK \u002F DEX Analysis\n\nGhidra has **built-in** APK and DEX support (Dalvik processor + FileFormats\nloaders) — no extension install needed. `load` a `.dex` or `.apk` directly and\nthe usual commands (`decompile`, `functions`, `strings`, `xrefs-*`, …) work on\nthe Dalvik program, which decompiles to Java-like pseudocode. Note the\n**multi-dex caveat**: `load app.apk` imports only the primary `classes.dex`.\n\nFor the full workflow — multi-dex extraction, class-qualified `::` symbols and\nambiguous methods, the DEX string-vs-`xrefs-to` gotcha, minified apps, and\nmanifest\u002F`.so` extraction — read `docs\u002Fflows\u002Fandroid-apk.md`.\n\n## Typical Workflow\n\n1. User starts daemon: `cd \u003Cskill-dir> && uv run ghidra-rpc start --project \u002Fpath\u002Fto\u002Fproject.gpr --headless`\n   For automation \u002F non-blocking start: `uv run ghidra-rpc start --project \u002Fpath\u002Fto\u002Fproject.gpr --headless --detach`\n2. Load binary: `uv run ghidra-rpc load \u002Fpath\u002Fto\u002Fbinary -p \u002Fpath\u002Fto\u002Fproject.gpr`\n   Response includes `short_name` (usable alias in all subsequent commands).\n   (add `--no-analyze` to skip analysis, `--analysis-timeout SECS` to cap it)\n3. Get overview: `metadata`, `functions`, `imports`, `exports`\n4. Investigate: `decompile` interesting functions, `xrefs-to` to trace callers\n5. Annotate: `rename-function`, `set-comment` to document findings\n6. Search: `strings` for hardcoded values, `symbols` for specific patterns\n\n## FAQ \u002F Common Gotchas\n\n**`create-label` properly replaces DEFAULT (auto-analysis) symbols**:\n`create-label` creates a USER_DEFINED label and sets it as the primary symbol at the\naddress. If a DEFAULT symbol (e.g. `DAT_00418138`) already exists, it is demoted to\nsecondary. The decompiler will then use the new name. `rename-symbol` renames in\nplace but requires an existing symbol; `create-label` is preferred for annotating\naddresses regardless of existing symbols.\n\n**Annotating an address with no existing symbol** (`rename-symbol` fails with \"No symbol found\"):\n`rename-symbol` requires a symbol to already exist at the address. Auto-analysis only\nplaces `DAT_` symbols where it detects data; inside arrays or dense struct regions\nmany addresses have no symbol. Use `create-label` instead - it creates a new USER_DEFINED\nlabel if none exists, or renames the existing one:\n```bash\nghidra-rpc create-label \u003Cbinary> 0x0040e4ac topPtrErrorMsg\n```\nYou can also add `--create` to `rename-symbol` for the same upsert behaviour.\n\n**Defining and applying a struct across a memory region**:\nFull workflow to stamp a struct across a repeated data table:\n```bash\n# 1. Create the struct type in the DTM (--if-not-exists makes the call idempotent)\nghidra-rpc create-struct binary ErrorEntry int errorNumber \"char *\" ptrErrorMsg --if-not-exists\n\n# 2. Stamp the struct across the range with --clear to atomically clear + apply\n#    (23 × 8-byte ErrorEntry structs, both endpoints inclusive)\nghidra-rpc apply-data-type-range binary 0x0040e4a8 0x0040e55f ErrorEntry --clear\n```\nAfter this, each address `0x0040e4a8`, `0x0040e4b0`, ... has type `ErrorEntry`.\nWithout `--clear`, `apply-data-type-range` skips positions where existing data\nconflicts and reports them in the `errors` list. Use `clear-data-range` first if\nyou need finer control over which region is cleared.\n\n**Discovering what labels exist at an address or range**:\n```bash\n# Single address\nghidra-rpc list-labels binary 0x0040e4a8\n\n# Range\nghidra-rpc list-labels binary 0x0040e4a8 --end 0x0040e55f --limit 50\n```\n\n**Using the binary name after `load`**:\n`load` returns both a full key (`binary`) with a hash suffix and a `short_name`\n(the original filename). Use `short_name` in all subsequent commands - it works\nbecause commands match binary names by substring:\n```bash\n# Load response: {\"binary\": \"\u002FWinHelloCPP.exe-85cbcc\", \"short_name\": \"WinHelloCPP.exe\", ...}\nghidra-rpc decompile WinHelloCPP.exe main        # short_name works\nghidra-rpc decompile WinHelloCPP main            # even without extension, if unambiguous\n```\nIf two binaries share the same stem, use the full key to disambiguate.\n\n**Trailing semicolons in signatures**: Ghidra's parser rejects C prototypes that end\nwith `;`. ghidra-rpc strips trailing semicolons automatically, so you can paste verbatim.\n\n**`list-binaries` is empty but I loaded a binary**: In GUI mode, the binary must be\nopen in CodeBrowser. Use `list-project-programs` to see what's stored in the project\nrepo, then open it in CodeBrowser's Project window.\n\n**Daemon log file**: When started in the background (`start --detach` or `restart`),\nlogs are written to `\u002Ftmp\u002Fghidra-rpc-\u003Chash>.log` (same directory and stem as the Unix\nsocket). If the daemon fails to start or become responsive, check that file first:\n```bash\ntail -50 \u002Ftmp\u002Fghidra-rpc-*.log\n```\nThe timeout error message always prints the exact log path.\n\n**`GHIDRA_INSTALL_DIR` not found after backgrounding**: Environment variables may be\nlost when daemonising (nohup, cron, systemd units, etc.). Fix options, in order of preference:\n1. Pass `--ghidra-install-dir \u002Fpath\u002Fto\u002Fghidra` to `start` or `restart` - the value is\n   persisted in the session file and forwarded to every subsequent restart automatically.\n2. Export `GHIDRA_INSTALL_DIR` in your shell profile (`~\u002F.bashrc`, `~\u002F.zshrc`) so it\n   survives login sessions.\n3. Use `start --detach --headless` from the same terminal where the env var is set.\n\n**Session file location**: By default the session file (`.ghidra-rpc-\u003Chash>.json`) is\nwritten alongside the `.gpr` project file, keeping all state self-contained. To use a\ncustom directory (e.g. a shared location or a RAM-disk), set `GHIDRA_RPC_STATE_DIR`:\n```bash\nexport GHIDRA_RPC_STATE_DIR=\u002Ftmp\u002Fghidra-sessions\n```\n\n**Changes not visible in the Ghidra GUI**: Make sure you open the project copy\n(e.g. `basic_code-501243` in the Project window), not the raw binary via File → Open.\nAlso ensure you are not running two separate Ghidra instances on the same project\n(causes lock conflicts). Changes made by ghidra-rpc are auto-saved to disk and will\nbe visible the next time the program is opened in the GUI.\n\n**`restart` without a prior session**: Pass `--headless` so `restart` can create\na fresh headless session instead of requiring a prior `start`.\n\n**Decompiler timeout on certain functions**: Some functions trigger expensive\ndecompiler analysis paths and time out even with simple assembly. Use\n`decompile --timeout 300` (or higher) for stubborn functions. The default timeout\nis **120 s** (increased from 60 s to handle large firmware functions). The\n`retype-variable` and `rename-variable` commands also accept `--timeout` since it\ntriggers an internal decompilation pass.\n\n**`decompile` returns bad-instruction warnings — use `pcode --high` as fallback**:\nWhen `decompile` produces output like *\"Bad instruction data\"* or fails to decode\na function body (common on ARM Thumb code in regions that auto-analysis\nmis-classified as data), try `pcode --high` instead:\n```bash\nghidra-rpc pcode binary 0x03288102 --high\n```\nThe P-code engine re-decodes bytes from the *function object's* context rather\nthan from the listing-level disassembler, so it often succeeds where `decompile`\nfails. High P-code also reveals all CALL \u002F CALLIND \u002F BRANCHIND targets and data\nflow, making it useful for tracing arguments even without valid decompilation.\nFix the root cause with `set-processor-context` (see below).\n\n**`disassemble` starts from the wrong address** (B2 warning):\nIf `disassemble` is called at an address with no instruction (e.g. an address\nthat is mid-instruction or undefined), the response now includes a `warning`\nfield explaining that disassembly started from the next available instruction.\nCheck for `warning` in the JSON response when the listing looks wrong.\n\n**ARM Thumb mis-classification — `set-processor-context` is the fix** (F1\u002FF5):\nWhen ARM auto-analysis classifies Thumb code as data, the listing disassembler\ndecodes it as 32-bit ARM (TMode=0) and produces garbage. The full recovery\nworkflow:\n```bash\n# 1. Diagnose: check TMode at the affected address\nghidra-rpc get-processor-context binary 0x03288100 --register TMode\n# Expected: {\"TMode\": 0}  ← this is the problem\n\n# 2. Clear the bad data\u002Fcode classification\nghidra-rpc clear-data-range binary 0x03288100 0x032883ff\n\n# 3. Set Thumb mode for the range\nghidra-rpc set-processor-context binary 0x03288100 TMode 1 --end 0x032883ff\n\n# 4. Verify disassembly now shows Thumb-2 instructions\nghidra-rpc disassemble binary 0x03288100 --count 20\n\n# 5. Re-create the function\nghidra-rpc create-function binary 0x03288100\n```\nIf `create-function` fails because a bad stub still exists at the address,\nuse `delete-function` first to remove it.\n\n**Bad stubs blocking re-creation — use `delete-function`** (F2):\nIf `create-function 0x03288103` (wrong parity) left a stub, and now\n`create-function 0x03288102` (correct address) fails with *\"already exists at\noverlapping address\"*, delete the bad stub first:\n```bash\nghidra-rpc delete-function binary 0x03288103\nghidra-rpc create-function  binary 0x03288102\n```\n\n**Batch rename \u002F comment 40+ functions without round-trip overhead** (F7):\nUse `batch-rename` and `batch-set-comment` to apply many annotations in a single\nserver round-trip and Ghidra transaction:\n```bash\n# Rename functions from a JSON file\nghidra-rpc batch-rename binary --json-file renames.json\n\n# Or inline\nghidra-rpc batch-rename binary --json \\\n  '[{\"target\":\"sub_401234\",\"new_name\":\"init_uart\"},{\"target\":\"0x400200\",\"new_name\":\"isr_handler\"}]'\n\n# Label-mode (symbol\u002Flabel rename by address)\nghidra-rpc batch-rename binary --mode label --json \\\n  '[{\"address\":\"0x0333afcc\",\"new_name\":\"g_debugStr\"}]'\n\n# Batch comments\nghidra-rpc batch-set-comment binary --json \\\n  '[{\"address\":\"0x03288102\",\"comment\":\"Thumb ISR entry\",\"comment_type\":\"plate\"}]'\n```\nAll items that succeed are committed in one transaction; failed items are\nreported per-item in `results[].ok=false` and do not roll back the successes.\n\n**Concurrent write operations are serialised**: The daemon serialises all command\nhandler invocations internally to prevent Ghidra transaction conflicts. You do\nnot need to serialize write commands externally — parallel writes are queued\nautomatically. This is slightly slower than concurrent execution but eliminates\nsilent partial failures.\n\n## Reporting Bugs and Missing Features\n\nWhile using ghidra-rpc you may encounter bugs, errors, or missing capabilities.\n**Please report them** - real-world usage drives continuous improvement.\n\nAt the end of any analysis session where you hit a problem, save a brief report:\n\n```bash\ncat > \u002Ftmp\u002Fghidra-rpc-issues-$(date +%Y%m%d-%H%M%S).md \u003C\u003C 'EOF'\n## ghidra-rpc Issue Report\n\n**Date:** $(date)\n**Binary:** \u003Cname of binary analysed>\n\n### Bugs encountered\n\u003C!-- Describe: command used, error message \u002F unexpected output, expected behaviour -->\n\n### Missing features\n\u003C!-- Describe what you needed but couldn't do with the current command set -->\n\n### Suggestions\n\u003C!-- Any UX improvements or new commands that would have helped -->\nEOF\n```\n\nThen inform the user:\n> \"I saved a ghidra-rpc issue report to `\u002Ftmp\u002Fghidra-rpc-issues-\u003Ctimestamp>.md`.\n>  If you'd like to submit it, run: `cat \u002Ftmp\u002Fghidra-rpc-issues-*.md`\"\n\nThe report is written to `\u002Ftmp` so it stays local to the machine and is lost on reboot -\nit is never sent anywhere automatically.\n\n## Further Documentation\n\nFor detailed guidance on specific workflows:\n- **Installation & setup**: read `docs\u002Finstall.md`\n- **Quick start tutorial**: read `docs\u002Fquickstart.md`\n- **Troubleshooting**: read `docs\u002Ftroubleshooting.md`\n- **Binary audit workflow**: read `docs\u002Fflows\u002Fbinary-audit.md`\n- **Vulnerability research**: read `docs\u002Fflows\u002Fvulnerability-research.md`\n- **Patch\u002Fdiff analysis**: read `docs\u002Fflows\u002Fpatch-analysis.md`\n- **Android APK \u002F DEX analysis**: read `docs\u002Fflows\u002Fandroid-apk.md`\n","A CLI daemon that exposes Ghidra reverse engineering capabilities over a Unix domain socket.\nYou interact with it by running `ghidra-rpc` commands via the bash tool - every command\noutputs JSON to stdout.\n\n## Running Commands\n\n**All `ghidra-rpc` commands must be run with `uv run` from the ghidra-rpc skill directory\n(the directory containing this SKILL.md file):**\n```bash\ncd \u003Cskill-dir> && uv run ghidra-rpc \u003Ccommand> ...\n```\n\n## Prerequisites Check\n\nBefore using any commands, verify the setup:\n\n1. **Is the daemon running?** Run `uv run ghidra-rpc status --project \u003Cpath>`. If not running,\n   the user needs to start it in a separate terminal: `uv run ghidra-rpc start --project \u002Fpath\u002Fto\u002Fproject.gpr`\n   (blocking, human-only). The `--headless` flag skips the GUI. For non-blocking \u002F automated\n   startup use `start --detach --headless` or `restart --headless`. Both commands accept\n   `--timeout SECS` (default: 60 s headless, 180 s GUI) and log daemon output to\n   `\u002Ftmp\u002Fghidra-rpc-\u003Chash>.log`.\n2. **GUI mode: verify the correct project is active.** The daemon passes the `--project` path\n   directly to GhidraRun so Ghidra opens the requested project immediately. After\n   `start --detach` (GUI mode), confirm the right project is loaded before issuing any\n   analysis commands:\n   ```bash\n   uv run ghidra-rpc list-project-programs --project \u002Fpath\u002Fto\u002Fproject.gpr\n   ```\n   Cross-check the returned binary names against what you expect. If the names don't match\n   (or a `warning` field appears in the response), stop and ask the user to open the correct\n   project in Ghidra's Project window before proceeding.\n3. **GUI mode: open the binary in CodeBrowser.** In GUI mode the daemon discovers programs\n   via the running CodeBrowser tool. If the binary is in the project but not currently open\n   in CodeBrowser, `list-binaries` will return empty and all commands will fail with\n   \"Binary not found\". Use `list-project-programs` to see what's stored in the project,\n   then double-click the program in Ghidra's Project window to open it.\n4. **Is `GHIDRA_INSTALL_DIR` set?** The daemon will fail loudly if this is missing.\n\nOnce the daemon is running, all commands below work automatically. If the daemon dies,\ncommands will attempt auto-restart from the saved session.\n\n## Command Reference\n\nEvery command accepts `--project \u003Cpath>` (or reads `GHIDRA_RPC_PROJECT` env var).\nAll output is JSON. Exit code 0 = success, 1 = error.\n\n### Project Management\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `ghidra-rpc start --project \u003Cgpr> [--headless] [--detach] [--ghidra-install-dir DIR]` | Start daemon (blocking by default; `--detach` backgrounds it) | `ghidra-rpc start -p \u002Ftmp\u002Fre.gpr --headless --detach` |\n| `ghidra-rpc stop --project \u003Cgpr>` | Stop the daemon | `ghidra-rpc stop -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc status --project \u003Cgpr>` | Check if daemon is running | `ghidra-rpc status -p \u002Ftmp\u002Fre.gpr` |\n\n`status` output: `{running, socket, mode, mode_source, project, binaries}`. `binaries` is the loaded-binary list when the daemon is running, `null` when stopped (one-shot health check without a second `list-binaries` call). `mode_source` is\n`\"running\"` when the daemon is live, `\"session\"` when the mode is from the saved\nsession only (daemon stopped), and `null` if no session exists.\n| `ghidra-rpc restart --project \u003Cgpr> [--headless] [--timeout SECS] [--ghidra-install-dir DIR]` | Restart daemon in background (`--headless` to override mode) | `ghidra-rpc restart -p \u002Ftmp\u002Fre.gpr --headless` |\n| `ghidra-rpc list-binaries --project \u003Cgpr>` | List binaries loaded in daemon | `ghidra-rpc list-binaries -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc list-project-programs --project \u003Cgpr>` | List all programs stored in the project repo (reads project folder, not CodeBrowser live state; returns `warning` if the active Ghidra project doesn't match) | `ghidra-rpc list-project-programs -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc save [binary] --project \u003Cgpr>` | Save program(s) to disk (auto-save also runs after every write) | `ghidra-rpc save -p \u002Ftmp\u002Fre.gpr` |\n\n### Loading & Analysis\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `ghidra-rpc load \u003Cpath> -p \u003Cgpr> [--no-analyze] [--analysis-timeout SECS]` | Import & analyze a binary | `ghidra-rpc load \u002Fusr\u002Fbin\u002Ftarget -p \u002Ftmp\u002Fre.gpr` |\n| `ghidra-rpc metadata \u003Cbinary> -p \u003Cgpr>` | Binary metadata (arch, bits, format) | `ghidra-rpc metadata target -p \u002Ftmp\u002Fre.gpr` |\n\n`load` flags:\n- `--no-analyze` - skip auto-analysis entirely (fast; useful when you only need the\n  listing or plan to run analysis later via Ghidra GUI).\n- `--analysis-timeout SECS` - abort auto-analysis after the given wall-clock budget\n  (best-effort); the binary is saved with whatever analysis completed in time.\n\n### Listing\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc functions \u003Cbinary> [--offset N] [--limit N] [--address-min ADDR] [--address-max ADDR] [--with-body]` | List functions (paginated); `--address-min\u002Fmax` for server-side range filter; `--with-body` adds body range fields | `{functions: [{name, address, signature[, body_min, body_max, body_size]}], count, total, offset}` |\n| `ghidra-rpc imports \u003Cbinary>` | List imports | `{imports: [{name, address, library}], count}` |\n| `ghidra-rpc exports \u003Cbinary>` | List exports | `{exports: [{name, address}], count}` |\n| `ghidra-rpc relocations \u003Cbinary> [--address ADDR] [--limit N]` | List relocation table entries | `{relocations: [{address, type, symbol, bytes, status}], count, total}` |\n| `ghidra-rpc list-calling-conventions \u003Cbinary>` | List valid calling convention names for the architecture | `{conventions: [str], default, count}` |\n\n### Decompilation\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc decompile \u003Cbinary> \u003Cfunc> [--timeout SECS]` | Decompile to pseudo-C (default **120 s**) | `{name, address, signature, c_code}` |\n| `ghidra-rpc basic-blocks \u003Cbinary> \u003Cfunc> [--limit N]` | Get basic blocks (CFG) of a function | `{name, address, blocks:[{start,end,size,instructions,successors,predecessors}], num_blocks, edges}` |\n| `ghidra-rpc pcode \u003Cbinary> \u003Cfunc> [--high] [--timeout SECS] [--limit N]` | Get P-code (Ghidra IR); raw or high SSA form (--high) | `{name, address, mode, ops:[{address,seq,opcode,output,inputs}], count, truncated}` |\n| `ghidra-rpc search-decompiled \u003Cbinary> \u003Cregex> [--class NAME] [--case-sensitive] [--limit N] [--max-scan N] [--timeout SECS] [--socket-timeout SECS]` | Regex-search decompiled C across many functions in one call (skips one-RPC-per-function `decompile`+grep loops) | `{matches:[{function,address,matching_lines:[{line,text}]}], count, functions_searched, functions_total, truncated}` |\n\n`\u003Cfunc>` can be a function name or hex address (e.g., `main` or `0x401000`). If the name\nis ambiguous, the error message lists matches so you can use the address instead.\n\n`search-decompiled` is especially useful on multidex Android projects, where `xrefs-to`\non a method only sees callers within the same DEX program (see the Android APK\u002FDEX\nsection) — use it in place of a symbols+decompile+grep loop, e.g. `search-decompiled\napp.apk targetF1 --class\ncom::example::Foo`. `--max-scan` (default 5000) bounds how many functions get decompiled\nwhen `--class` isn't given, so a search on a 50k+-function binary can't run away; raise\n`--socket-timeout` (default 1800s) alongside it if you do widen the scan.\n\n### Search\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc find-bytes \u003Cbinary> \u003Cpattern> [--limit N] [--address ADDR]` | Search for byte pattern with wildcards (e.g. `\"55 8b ?? 83 ec\"`) | `{pattern, matches: [{address, context_hex}], count, truncated}` |\n| `ghidra-rpc strings \u003Cbinary> \u003Cquery> [--limit N]` | Search strings (substring) | `{strings: [{address, value, type}], count}` |\n| `ghidra-rpc symbols \u003Cbinary> \u003Cquery> [--limit N] [--offset N]` | Search symbols | `{symbols: [{name, address, type}], count, total}` |\n\n`symbols` normalizes literal spaces and underscores as equivalent before matching, so a\nquery pasted straight from `strings` output (real spaces) still finds the corresponding\nlabel even though Ghidra auto-generates labels from string content by turning each space\ninto `_` (and leaving every other character, including non-ASCII\u002FCJK text, untouched).\n\n### Cross-References\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc xrefs-to \u003Cbinary> \u003Ctarget> [--limit N] [--all-binaries]` | Who references this? | `{xrefs: [{from_address, from_function, type}], count}` |\n| `ghidra-rpc xrefs-from \u003Cbinary> \u003Ctarget> [--limit N] [--no-stack]` | What does this reference? (`--no-stack` hides `Stack[-0x...]` entries) | `{xrefs: [{to_address, to_function, type}], count}` |\n\nGhidra's reference manager is per-binary: a call whose caller and target live in two\n*different* loaded binaries is invisible to a single-binary `xrefs-to` lookup (most\ncommonly hit on multidex Android projects, where a method in one `classesN.dex` is\ncalled from another, but this isn't DEX-specific — it applies to any project with more\nthan one binary loaded in the daemon). Pass `--all-binaries` to also search every other\ncurrently loaded binary for a symbol with the same fully-qualified name and merge in\nreal callers found there; each merged entry carries a `binary` field so you can tell\nwhich binary it came from.\n\n### Navigation (GUI mode only)\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc goto \u003Cbinary> \u003Ctarget> [function\\|address]` | Navigate GUI | `{address, success}` |\n\n### Memory & Disassembly\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc memory-map \u003Cbinary>` | List all memory segments (name, address range, size, rwx flags, type) | `{segments: [{name, start, end, size, read, write, execute, initialized, type, source_name}], count}` |\n| `ghidra-rpc write-bytes \u003Cbinary> \u003Caddress> \u003Chex>` | Write raw bytes to an address; does NOT auto-redisassemble | `{address, length, hex, verified}` |\n| `ghidra-rpc read-bytes \u003Cbinary> \u003Caddress> \u003Clength>` | Read raw bytes; LENGTH accepts decimal or `0x` hex | `{address, length, hex, hexdump}` |\n| `ghidra-rpc read-pointers \u003Cbinary> \u003Caddress> \u003Ccount> [--pointer-size N]` | Read COUNT pointers and resolve each to its symbol (vtables, import\u002Fjump tables, RTTI arrays) | `{address, count, pointer_size, endian, pointers:[{index, offset, slot_address, value, target_address, target_name, target_kind}]}` |\n| `ghidra-rpc list-vtable \u003Cbinary> \u003Caddress> [--count N] [--pointer-size N]` | Dump a C++ vtable's slots as resolved methods; ADDRESS may be a symbol name. Without `--count`, stops at the next vftable symbol \u002F first non-function pointer (see `stopped_reason`) | `{vtable_address, symbol, count, pointer_size, stopped_reason, slots:[{index, offset, slot_address, target_address, target_name, target_kind}]}` |\n| `ghidra-rpc disassemble \u003Cbinary> \u003Caddress> [--count N]` | Disassemble N instructions (default 20); `warning` field if start address had no instruction | `{address, count, instructions:[{address,bytes,mnemonic,operands,length,comment}], listing[, warning]}` |\n| `ghidra-rpc assemble \u003Cbinary> \u003Caddress> \u003Cinstr> [\u003Cinstr> ...]` | Assemble instruction text at address (Ghidra SLEIGH assembler) | `{address, bytes_written, hex, instructions:[{address,bytes,mnemonic,operands,length}]}` |\n\n### Modifications\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc create-function \u003Cbinary> \u003Caddress> [--name NAME]` | Create a function at an address (auto-detects body from flow) | `{name, address, size, body}` |\n| `ghidra-rpc delete-function \u003Cbinary> \u003Ctarget>` | Remove a function definition (bytes unchanged; address reverts to undefined) | `{address, name, deleted}` |\n| `ghidra-rpc rename-function \u003Cbinary> \u003Ctarget> \u003Cnew_name> [--namespace NS]` | Rename function; `--namespace` moves it into a namespace | `{address, old_name, new_name, verified[, old_namespace, new_namespace]}` |\n| `ghidra-rpc rename-symbol \u003Cbinary> \u003Caddress> \u003Cnew_name> [--create]` | Rename symbol; `--create` makes a new label if none exists | `{address, old_name, new_name, created, verified}` |\n| `ghidra-rpc create-label \u003Cbinary> \u003Caddress> \u003Cname>` | Create-or-rename a label at any address (upsert) | `{address, name, old_name, action, created, verified}` |\n| `ghidra-rpc set-comment \u003Cbinary> \u003Caddress> --comment \u003Ctext> [--type TYPE]` | Set comment (comment text is `--comment`, matching `set-bookmark`) | `{address, comment_type, comment, verified}` |\n| `ghidra-rpc batch-rename \u003Cbinary> --json \\|--json-file FILE [--mode function\\|label]` | Rename 40+ functions\u002Flabels in one transaction; per-item error reporting | `{results:[{ok, index, address, old_name, new_name}], count, ok_count, error_count}` |\n| `ghidra-rpc batch-set-comment \u003Cbinary> --json \\|--json-file FILE` | Set comments at many addresses in one transaction | `{results:[{ok, index, address, comment_type, comment}], count, ok_count, error_count}` |\n| `ghidra-rpc set-signature \u003Cbinary> \u003Ctarget> \u003Csignature>` | Set function signature | `{address, old_signature, new_signature, verified}` |\n| `ghidra-rpc set-data-type \u003Cbinary> \u003Caddress> \u003Ctype>` | Define data type in listing | `{address, data_type, length, value}` |\n| `ghidra-rpc retype-variable \u003Cbinary> \u003Cfunc> \u003Cvariable> \u003Ctype> [--timeout SECS]` | Retype decompiler variable | `{function, variable, old_type, new_type, verified}` |\n| `ghidra-rpc rename-variable \u003Cbinary> \u003Cfunc> \u003Cvariable> \u003Cnew_name> [--timeout SECS]` | Rename decompiler variable | `{function, variable, new_name, verified}` |\n| `ghidra-rpc batch-edit-variable \u003Cbinary> \u003Cfunc> --json \\|--json-file FILE [--timeout SECS]` | Rename and\u002For retype many locals in ONE decompiler snapshot — avoids the auto-name renumbering that breaks chained single edits. Each op: `{variable\\|storage, new_name?, data_type?}` (identify by name or storage string; at least one of new_name\u002Fdata_type) | `{function, results:[{ok, index, variable, storage, old_name, new_name, old_type, new_type, verified}], count, ok_count, error_count, verified_count}` |\n| `ghidra-rpc set-calling-convention \u003Cbinary> \u003Ctarget> \u003Cconvention>` | Change a function's calling convention | `{address, name, old_convention, new_convention, verified}` |\n| `ghidra-rpc set-thunk \u003Cbinary> \u003Cthunk> \u003Ctarget>` | Mark a function as a thunk (forwarding wrapper) | `{thunk_address, thunk_name, target_address, target_name, verified}` |\n| `ghidra-rpc set-flow-override \u003Cbinary> \u003Caddress> \u003Coverride>` | Override instruction flow type (NONE\u002FBRANCH\u002FCALL\u002FCALL_RETURN\u002FRETURN) | `{address, override, old_override, verified}` |\n| `ghidra-rpc get-processor-context \u003Cbinary> \u003Caddress> [--register REG]` | Inspect ISA context register values (e.g. TMode on ARM) | `{address, registers:{name:value}}` |\n| `ghidra-rpc set-processor-context \u003Cbinary> \u003Caddress> \u003Cregister> \u003Cvalue> [--end ADDR]` | Set ISA context register over a range — fixes ARM Thumb mis-classification | `{address, end, register, value, verified}` |\n| `ghidra-rpc create-namespace \u003Cbinary> \u003Cname> [--parent NS]` | Create or look up a namespace | `{name, path, id, created}` |\n| `ghidra-rpc list-namespaces \u003Cbinary> [--limit N]` | List all namespaces with symbol counts | `{namespaces:[{name,path,id,type,symbol_count}], count}` |\n\nComment types: `plate`, `pre`, `post`, `eol` (default), `repeatable`.\n\nSignature input is sanitised automatically: trailing semicolons are stripped,\nwhitespace is trimmed, and inline calling conventions (`__thiscall`, `__fastcall`,\n`__stdcall`, `__cdecl`, `__vectorcall`, `__pascal`) are extracted from the string\nand applied via the proper Ghidra API. So you can paste a C prototype directly\n(e.g. `void __thiscall Foo::Bar(int x);` works without manual cleanup).\n\nType expressions for `set-data-type`, `retype-variable`, and struct field types:\n- Built-ins: `byte`, `char`, `int`, `uint`, `short`, `long`, `float`, `double`, `void`, `string`, `unicode`\n- Pointer: `char *`, `void *`, `int **`\n- Array: `char[11]`, `int[4]`\n- Any type in the program's data type manager by name or path: `MyStruct`, `\u002FPOSIX\u002Fsize_t`\n\n**Order of operations — set signatures\u002Ftypes before naming locals.** Each of\n`set-signature`, `set-data-type`, `retype-variable`, and `rename-variable` re-runs the\ndecompiler, which re-numbers the remaining auto-named locals (`uVar1`, `dVar2`, …). So\nchaining single-variable edits is fragile: after renaming `dVar1`, the old `dVar2` may\nnow be `dVar1`. Do all signature\u002F`this`-typing first, then name locals — or, better, use\n`batch-edit-variable` to apply every rename **and** retype against a single decompiler\nsnapshot in one call (it also lets you address a variable by its stable `storage` string\ninstead of the volatile auto name).\n\n### Bookmarks\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc set-bookmark \u003Cbinary> \u003Caddress> [--type TYPE] [--category CAT] [--comment TEXT]` | Create\u002Fupdate a bookmark at an address | `{address, type, category, comment, action}` |\n| `ghidra-rpc list-bookmarks \u003Cbinary> [--type TYPE] [--category CAT] [--address ADDR] [--limit N]` | List bookmarks (all, by type, category, or at address) | `{bookmarks: [{address, type, category, comment}], count, total}` |\n| `ghidra-rpc remove-bookmark \u003Cbinary> \u003Caddress> [--type TYPE] [--category CAT]` | Remove a bookmark at an address | `{address, type, removed}` |\n\nBookmark types: `Note` (default), `Warning`, `Error`, `Info`, `Analysis`.\n\n`--category` is a case-insensitive substring filter. On heavily auto-analyzed binaries\n(large native programs, and especially DEX\u002FDalvik — 50k+ functions is normal), Ghidra\ngenerates many `Analysis`-type bookmarks (commonly category `Address Table`) that can\nbury a handful of your own; filter them out with `--category` (or `--type` to isolate\nyour own type, e.g. `Note`) instead of paging through the unfiltered list.\n\nBookmarks are visible in the Ghidra GUI's Bookmarks window. Use them to\npersistently mark interesting locations, track analysis progress, or flag\nfindings for human review.\n\n### Function Tags\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc tag-function \u003Cbinary> \u003Ctarget> --tag TAG` | Add a tag to a function for classification | `{address, name, tag, all_tags}` |\n| `ghidra-rpc untag-function \u003Cbinary> \u003Ctarget> --tag TAG` | Remove a tag from a function | `{address, name, tag, removed, all_tags}` |\n| `ghidra-rpc list-tags \u003Cbinary>` | List all defined tags with use counts | `{tags:[{name,count}], count}` |\n| `ghidra-rpc functions-by-tag \u003Cbinary> --tag TAG [--limit N]` | List functions with a specific tag | `{tag, functions:[{name,address,signature}], count, total}` |\n\nTags are string labels (e.g. `crypto`, `vuln-sink`, `analyzed`, `needs-review`)\nvisible in Ghidra's Function Tags window. Use them to classify functions\nand track analysis progress.\n\n### Data-Type Authoring\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc create-struct \u003Cbinary> \u003Cname> TYPE FIELD [TYPE FIELD ...] [--if-not-exists\\|--or-replace]` | Create a named struct; `--if-not-exists` is idempotent, `--or-replace` rebuilds it | `{name, path, size, fields:[...], already_existed}` |\n| `ghidra-rpc create-struct \u003Cbinary> \u003Cname> --field OFFSET TYPE NAME [--field ...]` | Create a struct laying fields at explicit byte offsets (OFFSET is decimal or 0x hex); gaps between fields are auto-padded with undefined bytes (no manual pad fields). Overlaps are rejected. | `{name, path, size, fields:[...], already_existed}` |\n| `ghidra-rpc create-union \u003Cbinary> \u003Cname> TYPE FIELD [TYPE FIELD ...] [--if-not-exists\\|--or-replace]` | Create a named union; all fields share offset 0 | `{name, path, size, fields:[...], already_existed}` |\n| `ghidra-rpc modify-struct \u003Cbinary> \u003Cstruct_name> --field-offset N\\|--field-name NAME [--new-type TYPE] [--new-name NAME]` | Retype, rename, or re-comment a struct field | `{name, path, size, fields:[...], modified_field:{...}}` |\n| `ghidra-rpc clear-data-range \u003Cbinary> \u003Cstart> \u003Cend>` | Reset inclusive byte range to undefined | `{start, end, cleared}` |\n| `ghidra-rpc apply-data-type-range \u003Cbinary> \u003Cstart> \u003Cend> \u003Ctype> [--clear]` | Stamp a type repeatedly across an inclusive range; `--clear` clears the region atomically before stamping | `{start, end, data_type, type_size, applied_count, cleared}` |\n| `ghidra-rpc list-labels \u003Cbinary> \u003Caddress> [--end ADDR] [--limit N]` | List symbols at an address or in a range, including data type at each location | `{labels:[{address,name,type,source,is_primary,data_type,data_length}], count, total}` |\n| `ghidra-rpc create-enum \u003Cbinary> \u003Cname> NAME VAL [NAME VAL ...] [--size 1|2|4|8] [--if-not-exists|--or-replace]` | Create a named enum in the DTM | `{name, path, size, values:[{name,value}], already_existed}` |\n| `ghidra-rpc modify-enum \u003Cbinary> \u003Cname> [--add NAME:VAL ...] [--remove NAME ...]` | Add\u002Fremove individual entries from an existing enum | `{name, path, size, values:[{name,value}]}` |\n| `ghidra-rpc set-equate \u003Cbinary> \u003Caddr> \u003Cequate_name> \u003Cvalue> [--operand-index N] [--enum-path PATH]` | Attach a named scalar constant to an instruction operand; auto-links to enum if found | `{address, operand_index, equate_name, value, enum_linked, verified}` |\n| `ghidra-rpc list-equates \u003Cbinary> [address] [--limit N]` | List all equates in the program or only those applied at an address | `{equates:[{name,value[,operand_index,address]}], count, total}` |\n| `ghidra-rpc list-data-types \u003Cbinary> [--category CAT] [--query SUBSTR] [--limit N]` | List types in the DTM; category: struct, enum, union, typedef, pointer, array, all | `{data_types:[{name,path,category,size}], count, total}` |\n\n### Version Tracking & Diff\n\n| Command | Description | Output shape |\n|---------|-------------|--------------|\n| `ghidra-rpc version-track \u003Cold> \u003Cnew> [--changed-only] [--limit N] [--min-similarity F]` | Match functions between two versions; find what changed. Results deduplicated per source function. | `{matched:[{source_name,destination_name,similarity,confidence,correlator}], unmatched_source, unmatched_destination, summary:{source_functions_total, changed_functions, identical_functions, ...}}` |\n| `ghidra-rpc function-diff \u003Cbin1> \u003Cfunc1> \u003Cbin2> \u003Cfunc2> [--mode decompile\\|disassembly]` | Unified diff of a function between two versions; normalises auto-generated names (`FUN_*`, `DAT_*`, `local_*`, `param_*`) to suppress relocation noise | `{is_identical, diff, raw_code1, raw_code2, func1_address, func2_address}` |\n| `ghidra-rpc match-function \u003Cbin1> \u003Cfunc> \u003Cbin2> [--threshold F]` | Find best match for a function in another binary using BSim + correlators | `{source:{name,address}, candidates:[{name,address,similarity,confidence,correlator}], count}` |\n| `ghidra-rpc decompile-all \u003Cbinary> [--limit N] [--offset N] [--timeout SECS] [--socket-timeout SECS]` | Bulk decompile all functions; for export and external diff tools | `{functions:[{name,address,signature,c_code}], count, total, offset, errors}` |\n\n`decompile-all`'s default `--socket-timeout` (1800s) assumes a bulk sweep can take much\nlonger than any single function's `--timeout`; raise it further for binaries with tens of\nthousands of functions (e.g. large DEX\u002FAPK programs).\n\nFor the full patch-diff workflow see `docs\u002Fflows\u002Fpatch-analysis.md`.\n\n## Error Handling\n\nError responses look like:\n```json\n{\"id\": \"...\", \"ok\": false, \"error\": \"FunctionNotFound\", \"message\": \"Function 'foo' not found.\"}\n```\n\nCommon errors:\n- **DaemonNotRunning**: Daemon isn't started. Tell the user to run `ghidra-rpc start`.\n- **ValueError**: Bad argument (ambiguous name, invalid address). The message usually tells\n  you what to do - e.g., use a more specific name or an address.\n- **RuntimeError**: Ghidra-level error. For GUI-only commands in headless mode, the error\n  says so explicitly.\n\n**All CLI output is JSON, including usage errors.** A malformed invocation (unknown\noption, invalid `--type` choice, unknown subcommand, missing required argument) is also\nreported as `{\"ok\": false, \"error\": \"...\", \"message\": \"...\"}` on stdout, with a nonzero\nexit code — never a plain-text Click usage string. Scripted callers can always\n`json.loads()` stdout unconditionally, without special-casing argument errors.\n\n## Write Operations & Persistence\n\nWrite operations (rename, create-label, create-function, delete-function, set-comment, batch-rename, batch-set-comment, set-signature, set-data-type, retype-variable, rename-variable, batch-edit-variable, set-calling-convention, set-thunk, set-flow-override, set-processor-context, create-struct, create-union, modify-struct, create-enum, modify-enum, set-equate, set-bookmark, clear-data-range, apply-data-type-range, write-bytes, assemble, tag-function, untag-function, create-namespace)\nuse Ghidra transactions internally. **Every write is automatically saved to the project\ndatabase on disk** after the transaction commits, so changes survive daemon restarts and\nare visible when the project is reopened in the Ghidra GUI.\n\nEvery write response includes a `verified` boolean that confirms whether the change was\nread back successfully after committing.\n\nYou can also save explicitly at any time:\n```bash\nghidra-rpc save              # saves all loaded programs\nghidra-rpc save \u003Cbinary>     # saves one program\n```\n\nOn clean shutdown (`stop` or Ctrl+C), all programs are saved automatically.\n\n## Patch \u002F Diff Analysis Quick Start\n\n```bash\n# 1. Load both versions\nghidra-rpc load \u002Fpath\u002Fto\u002Fbinary_v1 -p project.gpr\nghidra-rpc load \u002Fpath\u002Fto\u002Fbinary_v2 -p project.gpr\n\n# 2. Find changed functions (summary counts all changes; matched list is filtered)\nghidra-rpc version-track binary_v1 binary_v2 --changed-only\n\n# 3. Diff a specific changed function\nghidra-rpc function-diff binary_v1 \u003Cfunc> binary_v2 \u003Cfunc>\n```\n\nFull workflow — correlator details, unmatched analysis, bulk decompile:\nread `docs\u002Fflows\u002Fpatch-analysis.md`.\n\n## Android APK \u002F DEX Analysis\n\nGhidra has **built-in** APK and DEX support (Dalvik processor + FileFormats\nloaders) — no extension install needed. `load` a `.dex` or `.apk` directly and\nthe usual commands (`decompile`, `functions`, `strings`, `xrefs-*`, …) work on\nthe Dalvik program, which decompiles to Java-like pseudocode. Note the\n**multi-dex caveat**: `load app.apk` imports only the primary `classes.dex`.\n\nFor the full workflow — multi-dex extraction, class-qualified `::` symbols and\nambiguous methods, the DEX string-vs-`xrefs-to` gotcha, minified apps, and\nmanifest\u002F`.so` extraction — read `docs\u002Fflows\u002Fandroid-apk.md`.\n\n## Typical Workflow\n\n1. User starts daemon: `cd \u003Cskill-dir> && uv run ghidra-rpc start --project \u002Fpath\u002Fto\u002Fproject.gpr --headless`\n   For automation \u002F non-blocking start: `uv run ghidra-rpc start --project \u002Fpath\u002Fto\u002Fproject.gpr --headless --detach`\n2. Load binary: `uv run ghidra-rpc load \u002Fpath\u002Fto\u002Fbinary -p \u002Fpath\u002Fto\u002Fproject.gpr`\n   Response includes `short_name` (usable alias in all subsequent commands).\n   (add `--no-analyze` to skip analysis, `--analysis-timeout SECS` to cap it)\n3. Get overview: `metadata`, `functions`, `imports`, `exports`\n4. Investigate: `decompile` interesting functions, `xrefs-to` to trace callers\n5. Annotate: `rename-function`, `set-comment` to document findings\n6. Search: `strings` for hardcoded values, `symbols` for specific patterns\n\n## FAQ \u002F Common Gotchas\n\n**`create-label` properly replaces DEFAULT (auto-analysis) symbols**:\n`create-label` creates a USER_DEFINED label and sets it as the primary symbol at the\naddress. If a DEFAULT symbol (e.g. `DAT_00418138`) already exists, it is demoted to\nsecondary. The decompiler will then use the new name. `rename-symbol` renames in\nplace but requires an existing symbol; `create-label` is preferred for annotating\naddresses regardless of existing symbols.\n\n**Annotating an address with no existing symbol** (`rename-symbol` fails with \"No symbol found\"):\n`rename-symbol` requires a symbol to already exist at the address. Auto-analysis only\nplaces `DAT_` symbols where it detects data; inside arrays or dense struct regions\nmany addresses have no symbol. Use `create-label` instead - it creates a new USER_DEFINED\nlabel if none exists, or renames the existing one:\n```bash\nghidra-rpc create-label \u003Cbinary> 0x0040e4ac topPtrErrorMsg\n```\nYou can also add `--create` to `rename-symbol` for the same upsert behaviour.\n\n**Defining and applying a struct across a memory region**:\nFull workflow to stamp a struct across a repeated data table:\n```bash\n# 1. Create the struct type in the DTM (--if-not-exists makes the call idempotent)\nghidra-rpc create-struct binary ErrorEntry int errorNumber \"char *\" ptrErrorMsg --if-not-exists\n\n# 2. Stamp the struct across the range with --clear to atomically clear + apply\n#    (23 × 8-byte ErrorEntry structs, both endpoints inclusive)\nghidra-rpc apply-data-type-range binary 0x0040e4a8 0x0040e55f ErrorEntry --clear\n```\nAfter this, each address `0x0040e4a8`, `0x0040e4b0`, ... has type `ErrorEntry`.\nWithout `--clear`, `apply-data-type-range` skips positions where existing data\nconflicts and reports them in the `errors` list. Use `clear-data-range` first if\nyou need finer control over which region is cleared.\n\n**Discovering what labels exist at an address or range**:\n```bash\n# Single address\nghidra-rpc list-labels binary 0x0040e4a8\n\n# Range\nghidra-rpc list-labels binary 0x0040e4a8 --end 0x0040e55f --limit 50\n```\n\n**Using the binary name after `load`**:\n`load` returns both a full key (`binary`) with a hash suffix and a `short_name`\n(the original filename). Use `short_name` in all subsequent commands - it works\nbecause commands match binary names by substring:\n```bash\n# Load response: {\"binary\": \"\u002FWinHelloCPP.exe-85cbcc\", \"short_name\": \"WinHelloCPP.exe\", ...}\nghidra-rpc decompile WinHelloCPP.exe main        # short_name works\nghidra-rpc decompile WinHelloCPP main            # even without extension, if unambiguous\n```\nIf two binaries share the same stem, use the full key to disambiguate.\n\n**Trailing semicolons in signatures**: Ghidra's parser rejects C prototypes that end\nwith `;`. ghidra-rpc strips trailing semicolons automatically, so you can paste verbatim.\n\n**`list-binaries` is empty but I loaded a binary**: In GUI mode, the binary must be\nopen in CodeBrowser. Use `list-project-programs` to see what's stored in the project\nrepo, then open it in CodeBrowser's Project window.\n\n**Daemon log file**: When started in the background (`start --detach` or `restart`),\nlogs are written to `\u002Ftmp\u002Fghidra-rpc-\u003Chash>.log` (same directory and stem as the Unix\nsocket). If the daemon fails to start or become responsive, check that file first:\n```bash\ntail -50 \u002Ftmp\u002Fghidra-rpc-*.log\n```\nThe timeout error message always prints the exact log path.\n\n**`GHIDRA_INSTALL_DIR` not found after backgrounding**: Environment variables may be\nlost when daemonising (nohup, cron, systemd units, etc.). Fix options, in order of preference:\n1. Pass `--ghidra-install-dir \u002Fpath\u002Fto\u002Fghidra` to `start` or `restart` - the value is\n   persisted in the session file and forwarded to every subsequent restart automatically.\n2. Export `GHIDRA_INSTALL_DIR` in your shell profile (`~\u002F.bashrc`, `~\u002F.zshrc`) so it\n   survives login sessions.\n3. Use `start --detach --headless` from the same terminal where the env var is set.\n\n**Session file location**: By default the session file (`.ghidra-rpc-\u003Chash>.json`) is\nwritten alongside the `.gpr` project file, keeping all state self-contained. To use a\ncustom directory (e.g. a shared location or a RAM-disk), set `GHIDRA_RPC_STATE_DIR`:\n```bash\nexport GHIDRA_RPC_STATE_DIR=\u002Ftmp\u002Fghidra-sessions\n```\n\n**Changes not visible in the Ghidra GUI**: Make sure you open the project copy\n(e.g. `basic_code-501243` in the Project window), not the raw binary via File → Open.\nAlso ensure you are not running two separate Ghidra instances on the same project\n(causes lock conflicts). Changes made by ghidra-rpc are auto-saved to disk and will\nbe visible the next time the program is opened in the GUI.\n\n**`restart` without a prior session**: Pass `--headless` so `restart` can create\na fresh headless session instead of requiring a prior `start`.\n\n**Decompiler timeout on certain functions**: Some functions trigger expensive\ndecompiler analysis paths and time out even with simple assembly. Use\n`decompile --timeout 300` (or higher) for stubborn functions. The default timeout\nis **120 s** (increased from 60 s to handle large firmware functions). The\n`retype-variable` and `rename-variable` commands also accept `--timeout` since it\ntriggers an internal decompilation pass.\n\n**`decompile` returns bad-instruction warnings — use `pcode --high` as fallback**:\nWhen `decompile` produces output like *\"Bad instruction data\"* or fails to decode\na function body (common on ARM Thumb code in regions that auto-analysis\nmis-classified as data), try `pcode --high` instead:\n```bash\nghidra-rpc pcode binary 0x03288102 --high\n```\nThe P-code engine re-decodes bytes from the *function object's* context rather\nthan from the listing-level disassembler, so it often succeeds where `decompile`\nfails. High P-code also reveals all CALL \u002F CALLIND \u002F BRANCHIND targets and data\nflow, making it useful for tracing arguments even without valid decompilation.\nFix the root cause with `set-processor-context` (see below).\n\n**`disassemble` starts from the wrong address** (B2 warning):\nIf `disassemble` is called at an address with no instruction (e.g. an address\nthat is mid-instruction or undefined), the response now includes a `warning`\nfield explaining that disassembly started from the next available instruction.\nCheck for `warning` in the JSON response when the listing looks wrong.\n\n**ARM Thumb mis-classification — `set-processor-context` is the fix** (F1\u002FF5):\nWhen ARM auto-analysis classifies Thumb code as data, the listing disassembler\ndecodes it as 32-bit ARM (TMode=0) and produces garbage. The full recovery\nworkflow:\n```bash\n# 1. Diagnose: check TMode at the affected address\nghidra-rpc get-processor-context binary 0x03288100 --register TMode\n# Expected: {\"TMode\": 0}  ← this is the problem\n\n# 2. Clear the bad data\u002Fcode classification\nghidra-rpc clear-data-range binary 0x03288100 0x032883ff\n\n# 3. Set Thumb mode for the range\nghidra-rpc set-processor-context binary 0x03288100 TMode 1 --end 0x032883ff\n\n# 4. Verify disassembly now shows Thumb-2 instructions\nghidra-rpc disassemble binary 0x03288100 --count 20\n\n# 5. Re-create the function\nghidra-rpc create-function binary 0x03288100\n```\nIf `create-function` fails because a bad stub still exists at the address,\nuse `delete-function` first to remove it.\n\n**Bad stubs blocking re-creation — use `delete-function`** (F2):\nIf `create-function 0x03288103` (wrong parity) left a stub, and now\n`create-function 0x03288102` (correct address) fails with *\"already exists at\noverlapping address\"*, delete the bad stub first:\n```bash\nghidra-rpc delete-function binary 0x03288103\nghidra-rpc create-function  binary 0x03288102\n```\n\n**Batch rename \u002F comment 40+ functions without round-trip overhead** (F7):\nUse `batch-rename` and `batch-set-comment` to apply many annotations in a single\nserver round-trip and Ghidra transaction:\n```bash\n# Rename functions from a JSON file\nghidra-rpc batch-rename binary --json-file renames.json\n\n# Or inline\nghidra-rpc batch-rename binary --json \\\n  '[{\"target\":\"sub_401234\",\"new_name\":\"init_uart\"},{\"target\":\"0x400200\",\"new_name\":\"isr_handler\"}]'\n\n# Label-mode (symbol\u002Flabel rename by address)\nghidra-rpc batch-rename binary --mode label --json \\\n  '[{\"address\":\"0x0333afcc\",\"new_name\":\"g_debugStr\"}]'\n\n# Batch comments\nghidra-rpc batch-set-comment binary --json \\\n  '[{\"address\":\"0x03288102\",\"comment\":\"Thumb ISR entry\",\"comment_type\":\"plate\"}]'\n```\nAll items that succeed are committed in one transaction; failed items are\nreported per-item in `results[].ok=false` and do not roll back the successes.\n\n**Concurrent write operations are serialised**: The daemon serialises all command\nhandler invocations internally to prevent Ghidra transaction conflicts. You do\nnot need to serialize write commands externally — parallel writes are queued\nautomatically. This is slightly slower than concurrent execution but eliminates\nsilent partial failures.\n\n## Reporting Bugs and Missing Features\n\nWhile using ghidra-rpc you may encounter bugs, errors, or missing capabilities.\n**Please report them** - real-world usage drives continuous improvement.\n\nAt the end of any analysis session where you hit a problem, save a brief report:\n\n```bash\ncat > \u002Ftmp\u002Fghidra-rpc-issues-$(date +%Y%m%d-%H%M%S).md \u003C\u003C 'EOF'\n## ghidra-rpc Issue Report\n\n**Date:** $(date)\n**Binary:** \u003Cname of binary analysed>\n\n### Bugs encountered\n\u003C!-- Describe: command used, error message \u002F unexpected output, expected behaviour -->\n\n### Missing features\n\u003C!-- Describe what you needed but couldn't do with the current command set -->\n\n### Suggestions\n\u003C!-- Any UX improvements or new commands that would have helped -->\nEOF\n```\n\nThen inform the user:\n> \"I saved a ghidra-rpc issue report to `\u002Ftmp\u002Fghidra-rpc-issues-\u003Ctimestamp>.md`.\n>  If you'd like to submit it, run: `cat \u002Ftmp\u002Fghidra-rpc-issues-*.md`\"\n\nThe report is written to `\u002Ftmp` so it stays local to the machine and is lost on reboot -\nit is never sent anywhere automatically.\n\n## Further Documentation\n\nFor detailed guidance on specific workflows:\n- **Installation & setup**: read `docs\u002Finstall.md`\n- **Quick start tutorial**: read `docs\u002Fquickstart.md`\n- **Troubleshooting**: read `docs\u002Ftroubleshooting.md`\n- **Binary audit workflow**: read `docs\u002Fflows\u002Fbinary-audit.md`\n- **Vulnerability research**: read `docs\u002Fflows\u002Fvulnerability-research.md`\n- **Patch\u002Fdiff analysis**: read `docs\u002Fflows\u002Fpatch-analysis.md`\n- **Android APK \u002F DEX analysis**: read `docs\u002Fflows\u002Fandroid-apk.md`\n",{},"main","19a54ac988e9929160334271f5c1924ddd9b227e","_modules\u002Fghidra-rpc",19,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill","https:\u002F\u002Fgithub.com\u002Falicewe1","写一些自己用得上的工具，能自动化就绝不手动 · 自动化 \u002F 工程效率 \u002F Agent 技能生态 · 保持好奇，持续构建","2026-09-30 00:41:20",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add alicewe1\u002Falice_skill --skill ghidra-rpc",{"tool":37,"command":38},"bunx","bunx skills add alicewe1\u002Falice_skill --skill ghidra-rpc",{"tool":40,"command":41},"pnpm","pnpm dlx skills add alicewe1\u002Falice_skill --skill ghidra-rpc","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002FSKILL.md",true,[45,51,57,61,65,69,73],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},".gitignore","OTHER","其他",452,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002F.gitignore",{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"AGENTS.md","REFERENCE","参考文档",17276,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002FAGENTS.md",{"path":58,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":59,"sourceHtmlUrl":60},"CHANGELOG.md",7818,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002FCHANGELOG.md",{"path":62,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":63,"sourceHtmlUrl":64},"CLAUDE.md",9,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002FCLAUDE.md",{"path":66,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":67,"sourceHtmlUrl":68},"package.json",294,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002Fpackage.json",{"path":70,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":71,"sourceHtmlUrl":72},"pyproject.toml",718,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002Fpyproject.toml",{"path":74,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":75,"sourceHtmlUrl":76},"README.md",5034,"https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002F_modules\u002Fghidra-rpc\u002FREADME.md",[78,85,92,99,106,113],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M7DBMD9P6R27SWQCW5HYVWG0","alice","Alice 六类技能总路由。用户输入 Alice 或要求查看 Alice 技能菜单时，严格输出固定菜单；输入攻\u002F防模式、六类入口或直接描述任务时，按类别→领域→模块渐进路由。","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002Faliceskill\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M7DBM8X5M7YXPYBVFMWF8HRC","alice-reverse","逆向分析渐进路由（二进制 \u002F 移动端 \u002F 协议 \u002F 取证 \u002F 保护机制 \u002F 运行时观测）。触发词：二进制\u002F移动端\u002F反编译\u002FFrida\u002FIDA\u002FGhidra\u002FPE\u002FELF\u002FAPK\u002F协议\u002F取证；先选领域索引，再按任务匹配度与评分选模块，禁止一次读取全部领域。","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002Falice-reverse\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":18},"01M7DBM630E2YKQP29194TT7HC","alice-pentest","web安全渐进路由（Web \u002F API \u002F 资产发现 \u002F 漏洞验证 \u002F 云与网络安全）。触发词：Web\u002FAPI\u002F资产发现\u002F端口\u002F漏洞验证\u002F云与网络安全；先选领域索引，再按任务匹配度与评分选模块，禁止一次读取全部领域。","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002Falice-pentest\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":18},"01M7DBM20M2VDYV5D3MYDGBTQX","alice-game","游戏攻防渐进路由（游戏客户端 \u002F 内存 \u002F 图形 \u002F 反作弊 \u002F 安全研究）。触发词：游戏客户端\u002F内存\u002F图形\u002F偏移\u002F反作弊\u002F模拟器\u002F覆盖层；先选领域索引，再按任务匹配度与评分选模块，禁止一次读取全部领域。","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002Falice-game\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":18},"01M7DBKXVEKB8931MZG23VACFN","alice-crack","卡密授权渐进路由（卡密 \u002F 激活 \u002F 授权验证 \u002F 许可证管理 \u002F 本地授权分析）。触发词：卡密\u002F激活\u002F授权验证\u002Flicense\u002F机器码\u002F试用状态；先选领域索引，再按任务匹配度与评分选模块，禁止一次读取全部领域。","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002Falice-crack\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":18},"01M7DBKTMT90MGV2WP8K73TMQD","alice-assist","技能指令渐进路由（技能路由 \u002F 评分 \u002F 吸收 \u002F 迁移 \u002F 自动化 \u002F 文档与平台集成）。触发词：技能创建\u002F吸收\u002F评分\u002F迁移\u002F自动化\u002F文档\u002F平台指令；先选领域索引，再按任务匹配度与评分选模块，禁止一次读取全部领域。","https:\u002F\u002Fgithub.com\u002Falicewe1\u002Falice_skill\u002Fblob\u002Fmain\u002Falice-assist\u002FSKILL.md",[],[]]