R_CORE(3)
R_CORE(3) โ the Radare2 Core Library API, bestie edition ๐
okay so picture this: it's the Library Functions Manual, it's r_core, and it's literally the whole beating heart of radare2. grab a snack, we're doing this. ๐
โจ NAME โจ
r_core โ the Radare2 Core Library API. that's it, that's the name, she's iconic, she contains multitudes ๐
โจ SYNOPSIS โจ
#include <r_core.h>
that's the whole vibe. one include and you're in. ๐ฆ
โจ DESCRIPTION โจ
so the r_core library hands you the central functionality of radare2 and exposes it to programs and bindings. it's giving glue, it's giving main character. it pulls together all the subsystems: binary parsing, disassembly, analysis, emulation (ESIL), debugging, and interactive UI control โ all of it, in one place, no cap.
you use RCore to drive radare2 workflows: open a binary, run analyses, query information, and programmatically mess with the project state. obsessed.
Important points for embedding and scripting โ read these, they're the tea โ:
RCoreis the single structure holding the state (io,bin,anal,debug,flags, etc.). treat it as the main entrypoint for the API. it's the mothership, fr fr.- Commands are the primary high-level control mechanism. use
r_core_cmd/r_core_cmd_strto invoke existing r2 semantics from code. why reinvent when the command already ate? ๐ - Many APIs return heap-allocated strings (for example
r_core_cmd_str) โ the caller is responsible for freeing them. yes bestie, you are the caller. no leaking. ๐ซถ - Analysis functions (
r_core_anal_fcn,r_core_anal_op) populate internal structures that power higher-level operations (pdf,af, crossrefs). Run analysis before relying on function graphs. no analysis, no graph, that's just how it is ๐ญ - Seeking (
r_core_seek) changes the current offset for subsequent commands. prefer absolute seeks for deterministic behavior in scripts โ your future self will thank you.
โจ INITIALIZATION โจ
RCore * r_core_new(void)โ allocate and initialize a freshRCoreinstance with all its subsystems (io,bin,anal,dbg,flags, etc.). the returned pointer is owned by the caller and must be freed withr_core_free. it's yours now, you take care of it ๐void r_core_free(RCore *core)โ free anRCoreinstance and everything attached to it. after this call the core pointer must not be used. it's gone, she's retired, do not text her back ๐bool r_core_init(RCore *core)โ do extra initialization on an existingRCoreobject. most users just callr_core_new (), which already does internal initialization for you, but this one's here for when you're embedding or recreating a core structure. lowkey niche, highkey useful.
โจ COMMAND EXECUTION โจ
int r_core_cmd(RCore *core, const char *cmd, bool log)โ execute a textual radare2 command. this is the primary way to drive functionality from host programs: opening files (o), running analysis (aaa), printing (pd,px), and manipulating flags.logcontrols whether the executed command gets recorded in the core's history/log. yes she journals ๐char * r_core_cmd_str(RCore *core, const char *cmd)โ execute a command and return its output as a newly allocated string. the caller is responsible for freeing the returned pointer (e.g. withfree ()). language bindings and scripts are obsessed with this one because they need to capture command output. don't forget the free, bestie, I'm begging ๐int r_core_cmdf(RCore *core, const char *fmt, ...)โ format and execute a command (convenience wrapper). perfect for building commands with addresses or sizes without doing manual string handling. let the format string cook ๐ง๐ณint r_core_cmd0(RCore *core, const char *cmd)โ execute a command without recording it in the log or history. use it for internal operations or when performance matters. stealth mode, no receipts ๐คซ
โจ SEEKING โจ
bool r_core_seek(RCore *core, ut64 addr, bool rb)โ set the core's current offset toaddr. seeking affects subsequent commands that use the current address (for examplepdorpx).rbsays whether the core should try to read bytes at the destination to validate the seek. sorbis like, the vibe check on the destination โจbool r_core_seek_delta(RCore *core, st64 addr)โ move the current offset by a signed delta relative to where you are now. great for short relative moves in scripts. little scoots, we love a little scoot ๐ฆvoid r_core_seek_previous(RCore *core, const char *type)โ seek to the previous item of a giventype(like a previous function or basic block). this is how you implement backwards navigation in tools that iterate over analysis results. rewind time, kind of ๐
โจ ANALYSIS โจ
RAnalOp * r_core_anal_op(RCore *core, ut64 addr, int mask)โ analyze a single instruction ataddrand return anRAnalOp *describing it. the returnedRAnalOp *is owned by the caller and must be freed withr_anal_op_free (). this API is ideal when you want structured, per-instruction info without running whole-function analysis. just one lil instruction, as a treat ๐bool r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth)โ do function-level analysis starting at addressat. this populates internal function graphs, basic blocks and cross-references, and it's typically followed by printing functions (pdf) or running decompiler stages. the full glow-up pipeline ๐void r_core_anal_esil(RCore *core, const char *str, const char *addr)โ evaluate an ESIL expression or code snippet. ESIL is radare2's emulation language, and this function helps you run small fragments or boot the ESIL VM for scripted emulation. baby emulation steps ๐งint r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr, ut64 *prev_addr, bool stepOver)โ step the ESIL VM until an address or condition is met. use it to implement single-stepping or conditional traces programmatically. one step at a time, she's careful ๐
โจ DISASSEMBLY โจ
int r_core_print_disasm(RCore *core, ut64 addr, ut8 *buf, int len, int count, enum r_pdu_condition_t pdu_condition_type, const void *pdu_condition, bool count_bytes, bool json, PJ *pj, RAnalFunction *pdf)โ format and print disassembly for a buffer or address range. the high-level commands (pd,pdf) are implemented using this API, so call it when you need controlled, fast formatting โ and optionally JSON output viaPJ. she's the engine under the hood ๐ฅchar * r_core_disassemble_instr(RCore *core, ut64 addr, int l)โ return a heap-allocated string with the disassembly of a single instruction ataddr. caller must free it. yes, again. free it. ๐คchar * r_core_disassemble_bytes(RCore *core, ut64 addr, int b)โ disassemblebbytes starting ataddrand return the output as a newly allocated string. bytes go in, string comes out, you can't explain that ๐
โจ BINARY OPERATIONS โจ
bool r_core_bin_load(RCore *core, const char *file, ut64 baseaddr)โ load a binary into the core for analysis.fileaccepts normal file paths and special providers used in tests (for examplemalloc://SIZEto create an in-memory file). after loading, analysis and printing commands operate on the loaded binary. she's loaded, literally ๐bool r_core_bin_info(RCore *core, int action, PJ *pj, int mode, int va, RCoreBinFilter *filter, const char *chksum)โ retrieve structured information about the currently loaded binary (sections, symbols, checksums). use thePJparameter for JSON-formatted output. structured info, cute presentation โจbool r_core_bin_set_cur(RCore *core, RBinFile *binfile)โ set theRBinFileused as current. perfect when the caller is juggling multiple binaries, or just wants to switch the activeRBinFilewithout reloading from disk. channel surfing, but for binaries ๐บ
โจ VISUAL MODE โจ
void r_core_visual(RCore *core, const char *input)โ enter the interactive visual mode driven byRCore. frontends can call this to open the TUI and optionally feed initial key events or commands viainput. it's giving immersive ๐int r_core_visual_refs(RCore *core, bool xref, bool fcnInsteadOfAddr)โ show cross-references inside the visual UI. the parameters control whether to show XREFs and whether to present functions instead of raw addresses. choose your fighter ๐bool r_core_visual_hud(RCore *core)โ display or toggle the heads-up display (HUD) that shows contextual information in visual mode. heads up bestie, info incoming ๐
โจ PROJECT MANAGEMENT โจ
bool r_core_project_open(RCore *core, const char *file)โ open and restore a previously saved.r2project. projects replay seeks, flags and other persistent state so you can pick up where you left off without re-running expensive analyses. your progress is safe, breathe ๐ฎโ๐จbool r_core_project_save(RCore *core, const char *file)โ save the current session tofile. after a successful save you can restore it later withr_core_project_open. save your work, bestie, please ๐int r_core_project_list(RCore *core, int mode)โ list available projects. super handy for UIs that expose multiple saved sessions. a whole lineup of vibes ๐ธ
โจ UNDO SYSTEM โจ
void r_core_undo_push(RCore *core, RCoreUndo *cu)โ push an undo record representing a reversible change. frontends and scripts can use this to build undo/redo flows for user actions. ctrl+z but make it API ๐void r_core_undo_pop(RCore *core)โ revert the last undo entry recorded in the core. restores previous state (flags, bytes, metadata) as captured in the undo record. we're going back, back to before ๐void r_core_undo_print(RCore *core, int mode, RCoreUndoCondition *cond)โ print or query the undo history, for display or automated rollback. receipts: available ๐งพ
โจ SEARCH โจ
int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback cb)โ run a custom search betweenfromandto, invoking the callback for each hit. this low-level API gives you full control over match handling and early termination. you're the boss here ๐int r_core_search_preludes(RCore *core, bool log)โ scan for common function preludes and heuristics to bootstrap function discovery in stripped binaries. often used before callingr_core_anal_fcnor printing results. a lil warm-up before the main event โจ
โจ EXAMPLES โจ
the examples below illustrate common real-world patterns found in the tree: capturing command output, using in-memory files in tests/fuzzers, and combining seeking with single-instruction analysis. real code, real patterns, no made-up nonsense ๐
Example 1 โ open, analyze and capture disassembly:
/* Example 1: open, analyze and capture disassembly */
RCore *core = r_core_new();
r_core_cmd(core, "o /bin/ls", false); /* open file */
r_core_cmd(core, "aaa", false); /* run full analysis */
char *out = r_core_cmd_str(core, "pd 10"); /* capture output */
printf("%s0, out);
free(out); /* must free returned string */
r_core_free(core);
Example 2 โ in-memory file used by fuzz tests (test/fuzz/fuzz_ia.c):
/* Example 2: in-memory file used by fuzz tests (test/fuzz/fuzz_ia.c) */
RCore *r = r_core_new();
/* create an anonymous in-memory file of Size bytes */
r_core_cmdf (r, "o malloc://%zu", (size_t)4096);
/* write data into r->io using r_io_write_at (test code) */
r_core_cmd0 (r, "oba 0"); /* avoid history */
r_core_cmd0 (r, "ia"); /* run instruction analysis */
r_core_free (r);
Example 3 โ seek + single-instruction analysis:
/* Example 3: seek + single-instruction analysis */
RCore *c2 = r_core_new();
/* load binary first via r_core_cmd or r_core_bin_load */
r_core_seek(c2, 0x1000, true);
RAnalOp *op = r_core_anal_op(c2, 0x1000, R_ANAL_OP_MASK_BASIC);
if (op) {
printf("Mnemonic: %s0, op->mnemonic);
r_anal_op_free(op);
}
r_core_free(c2);
psst โ yes, the printf lines above are written exactly the way they appear in the original page. copying code character-for-character is the whole point, so no "fixing" the quotes here ๐
โจ SEE ALSO โจ
the whole friend group, go say hi ๐ซถ
โจ AUTHORS โจ
The radare2 project team. icons only, no notes ๐
and that's the page!! ๐ this one's from Debian, dated September 20, 2025, and it lives at section R_CORE(3) โ so if you ever need to find her again, that's where she'll be, slaying in the manual like always. bye bestie, go free your strings ๐ โจ
๐ฆ where this page comes from
- alpine 3.24: radare2-doc 6.1.6-r0 ยท GPL-3.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later
- arch rolling: radare2 6.2.2-1 ยท GPL-3.0-only AND LGPL-3.0-only
- nixos 26.05: radare2 6.1.8
- nixpkgs unstable: radare2 6.2.4
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 ยท GPL-3.0-only AND LGPL-3.0-only
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 ยท GPL-3.0-only AND LGPL-3.0-only
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 ยท GPL-3.0-only AND LGPL-3.0-only
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 ยท GPL-3.0-only AND LGPL-3.0-only
- ubuntu resolute: radare2 6.0.7+ds-1 ยท LGPL-3.0-only
- ubuntu stonking: radare2 6.1.8+ds-1 ยท LGPL-3.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms