use std::os::raw::{c_char, c_int, c_void};
#[repr(C)]
pub struct RCore {
_private: [u8; 0],
}
#[repr(C)]
pub struct RConfig {
_private: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct R2RustBinIdentity {
pub bin_file: usize,
pub bin_object: usize,
pub bin_file_id: u32,
}
#[repr(C)]
pub struct R2RustSymbol {
pub name: *const c_char,
pub paddr: u64,
pub vaddr: u64,
pub size: u32,
pub ordinal: u32,
pub kind: c_int,
}
#[repr(C)]
pub struct R2RustAddrLine {
pub addr: u64,
pub file: *const c_char,
pub path: *const c_char,
pub line: u32,
pub column: u32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct R2RustMapIdentity {
pub map_id: u32,
pub fd: i32,
pub perm: i32,
pub begin: u64,
pub size: u64,
pub delta: u64,
}
pub type R2RustAddrLineCallback = unsafe extern "C" fn(*mut c_void, *const R2RustAddrLine) -> bool;
pub const R2_RUST_SYMBOL_NOTYPE: c_int = 0;
pub const R2_RUST_SYMBOL_OBJECT: c_int = 1;
pub const R2_RUST_SYMBOL_FUNCTION: c_int = 2;
#[repr(C)]
pub struct RCorePluginSession {
pub core: *mut RCore,
pub plugin: *mut c_void,
pub data: *mut c_void,
}
#[repr(C)]
pub struct RPluginMeta {
pub name: *mut c_char,
pub desc: *mut c_char,
pub author: *mut c_char,
pub version: *mut c_char,
pub license: *mut c_char,
pub contact: *mut c_char,
pub copyright: *mut c_char,
pub status: c_int,
}
#[repr(C)]
pub struct RCorePlugin {
pub meta: RPluginMeta,
pub init: Option<unsafe extern "C" fn(*mut RCorePluginSession) -> bool>,
pub fini: Option<unsafe extern "C" fn(*mut RCorePluginSession) -> bool>,
pub call: Option<unsafe extern "C" fn(*mut RCorePluginSession, *const c_char) -> bool>,
}
#[repr(C)]
pub struct RLibStruct {
pub type_: c_int,
pub data: *mut c_void,
pub version: *const c_char,
pub free: Option<unsafe extern "C" fn(*mut c_void)>,
pub pkgname: *const c_char,
pub abiversion: u32,
}
unsafe impl Sync for RLibStruct {}
unsafe impl Sync for RCorePlugin {}
unsafe impl Sync for RPluginMeta {}
#[link(name = "r_core")]
unsafe extern "C" {
pub fn r_core_cmd0(core: *mut RCore, cmd: *const c_char) -> c_int;
pub fn r_core_cmd_str(core: *mut RCore, cmd: *const c_char) -> *mut c_char;
pub fn r_core_cmd_lines(core: *mut RCore, lines: *const c_char) -> bool;
pub fn r_config_get(config: *mut RConfig, name: *const c_char) -> *const c_char;
pub fn r_config_set(
config: *mut RConfig,
name: *const c_char,
value: *const c_char,
) -> *mut c_void;
pub fn r_config_get_b(config: *mut RConfig, name: *const c_char) -> bool;
pub fn r_config_set_b(config: *mut RConfig, name: *const c_char, value: bool) -> *mut c_void;
pub fn r_config_desc(
config: *mut RConfig,
name: *const c_char,
desc: *const c_char,
) -> *mut c_void;
pub fn r_config_lock(config: *mut RConfig, lock: bool);
pub fn r_config_node_get(config: *mut RConfig, name: *const c_char) -> *mut c_void;
pub fn r2_rust_core_config(core: *mut RCore) -> *mut RConfig;
pub fn r2_rust_current_bin_identity(core: *mut RCore, identity: *mut R2RustBinIdentity)
-> bool;
pub fn r2_rust_bin_identity_matches(
core: *mut RCore,
identity: *const R2RustBinIdentity,
) -> bool;
pub fn r2_rust_symbol_count(core: *mut RCore, identity: *const R2RustBinIdentity) -> usize;
pub fn r2_rust_symbol_exists(
core: *mut RCore,
identity: *const R2RustBinIdentity,
symbol: *const R2RustSymbol,
) -> bool;
pub fn r2_rust_symbol_add(
core: *mut RCore,
identity: *const R2RustBinIdentity,
symbol: *const R2RustSymbol,
) -> bool;
pub fn r2_rust_symbols_truncate(
core: *mut RCore,
identity: *const R2RustBinIdentity,
length: usize,
) -> bool;
pub fn r2_rust_addrline_foreach(
core: *mut RCore,
identity: *const R2RustBinIdentity,
callback: R2RustAddrLineCallback,
user: *mut c_void,
) -> bool;
pub fn r2_rust_addrline_reset(core: *mut RCore, identity: *const R2RustBinIdentity) -> bool;
pub fn r2_rust_addrline_add(
core: *mut RCore,
identity: *const R2RustBinIdentity,
line: *const R2RustAddrLine,
) -> bool;
pub fn r2_rust_map_for_paddr(
core: *mut RCore,
paddr: u64,
vaddr: *mut u64,
identity: *mut R2RustMapIdentity,
) -> bool;
pub fn r2_rust_map_for_vaddr(
core: *mut RCore,
vaddr: u64,
paddr: *mut u64,
identity: *mut R2RustMapIdentity,
) -> bool;
pub fn r2_rust_map_identity_matches(
core: *mut RCore,
identity: *const R2RustMapIdentity,
) -> bool;
pub fn r2_rust_function_exists(core: *mut RCore, addr: u64) -> bool;
pub fn r2_rust_function_analyze(core: *mut RCore, addr: u64, name: *const c_char) -> bool;
pub fn r2_rust_function_matches(core: *mut RCore, addr: u64, name: *const c_char) -> bool;
pub fn r2_rust_function_delete(core: *mut RCore, addr: u64, name: *const c_char) -> bool;
pub fn r2_rust_xref_exists(core: *mut RCore, from: u64, to: u64, type_: c_int) -> bool;
pub fn r2_rust_xref_add(core: *mut RCore, from: u64, to: u64, type_: c_int) -> bool;
pub fn r2_rust_xref_delete(core: *mut RCore, from: u64, to: u64, type_: c_int) -> bool;
}
unsafe extern "C" {
pub fn free(ptr: *mut c_void);
}