Learn  /  Appendix (files 80-84)  /  lesson 82

JavaScript API Quick Reference

Level: Appendix What This Is: Every Rerius JavaScript API method in one place.

Loading#

const rerius = require('rerius')

// Auto-close after callback
rerius.withBinary(path, bin => { ... })

// Manual lifecycle
const bin = rerius.load(path)
// ... use bin ...
bin.close()

// Async callback
await rerius.withBinaryAsync(path, async bin => { ... })

Binary Properties (no call needed)#

bin.arch        // 'x86_64' | 'AArch64 (ARM64)' | 'RISC-V RV64' | ...
bin.format      // 'ELF64' | 'ELF32' | 'PE64' | 'PE32' | 'Mach-O 64' | ...
bin.os          // 'Linux' | 'Windows' | 'macOS' | 'Android' | ...
bin.entry       // BigInt: entry point virtual address
bin.sha256      // string: hex SHA-256 of the binary
bin.buildId     // string: GNU build ID or empty string
bin.isPie       // boolean
bin.isStripped  // boolean
bin.hasDebug    // boolean
bin.file        // string: absolute file path

Sections#

bin.sections()              // Section[]
bin.sectionByName('.text')  // Section | null
bin.sectionAt(addr)         // Section | null (addr = BigInt)

Section object:

{
    name: string,       // '.text', '.data', etc.
    type: string,       // 'code' | 'data' | 'rodata' | 'bss' | 'plt' | 'got' | 'other'
    vaddr: bigint,
    size: bigint,
    offset: bigint,
    flags: number,
    insnCount: number,
}

Symbols#

bin.symbols()              // Symbol[]
bin.symAt(addr)            // Symbol | null

Symbol object:

{
    name: string,       // raw (possibly mangled) name
    demangled: string,  // demangled name or empty string
    address: bigint,
    size: bigint,
    type: string,       // 'func' | 'object' | 'other'
}

Functions#

bin.functions()            // DaxFunction[]
bin.funcAt(addr)           // DaxFunction | null
bin.hottestFunctions(n)    // { function: DaxFunction, callCount: number }[]

DaxFunction object:

{
    name: string,
    start: bigint,
    end: bigint,
    size: bigint,
    insnCount: number,
    blockCount: number,
    hasLoops: boolean,
    hasCalls: boolean,
}

Cross References#

bin.xrefs()             // Xref[]
bin.xrefsTo(addr)       // Xref[] (incoming)
bin.xrefsFrom(addr)     // Xref[] (outgoing)

Xref object:

{
    from: bigint,
    to: bigint,
    isCall: boolean,    // false = branch
}

Disassembly#

bin.disasmJson(section, { limit: number, offset: number })  // Instruction[]

Instruction object:

{
    address: bigint,
    mnemonic: string,
    operands: string,
    length: number,
    group: string,     // 'call' | 'branch' | 'ret' | 'stack' | 'arithmetic' | ...
    bytes: Uint8Array,
    symbol: string | null,
}

Full Analysis#

bin.analyze()  // AnalyzeResult

AnalyzeResult:

{
    info: { arch, format, os, entry, sha256, isPie, isStripped, hasDebug, codeSize, imageSize },
    sections: Section[],
    symbols: Symbol[],
    functions: DaxFunction[],
    xrefs: Xref[],
    blocks: Block[],
    loadTimeMs: number,
    analysisTimeMs: number,
}

Raw Access#

bin.readBytes(addr, length)  // Uint8Array | null

Advanced (ARM64 and RISC-V)#

bin.entropy()            // string report
bin.rda(section)         // string report
bin.ivf()                // string report: IVF + SMC + VM detector
bin.symexec(funcIdx)     // string report
bin.decompile(funcIdx)   // pseudo-C with type inference and resolved calls
bin.ssa(funcIdx)         // NR (Rerius Representation): inter-function IR
bin.strings()            // { address: bigint, value: string }[]
bin.unicodeStrings()     // { address: bigint, value: string, encoding: string }[]
bin.emulate(funcIdx, initRegs)  // string report (also captures real-time SMC)

BigInt Tips#

// Literal BigInt
const addr = 0x401234n

// Convert number to BigInt
const addr = BigInt(0x401234)

// Convert BigInt to hex string
addr.toString(16)        // '401234'
'0x' + addr.toString(16) // '0x401234'

// JSON serialization
JSON.stringify(obj, (_, v) => typeof v === 'bigint' ? '0x' + v.toString(16) : v)
Edit this page on GitHub Source: learn/82_js_api_quick_reference.md
On this page
JavaScript API Quick Reference Loading Binary Properties (no call needed) Sections Symbols Functions Cross References Disassembly Full Analysis Raw Access Advanced (ARM64 and RISC-V) BigInt Tips
ESC
↑↓ navigate openesc close