MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / demangle_generic

Function demangle_generic

rust/src/demangle.rs:29–59  ·  view source on GitHub ↗
(
    arch: &CoreArchitecture,
    mangled_name: S,
    view: Option<&BinaryView>,
    simplify: bool,
)

Source from the content-addressed store, hash-verified

27pub type Result<R> = std::result::Result<R, ()>;
28
29pub fn demangle_generic<S: BnStrCompatible>(
30 arch: &CoreArchitecture,
31 mangled_name: S,
32 view: Option<&BinaryView>,
33 simplify: bool,
34) -> Option<(QualifiedName, Option<Ref<Type>>)> {
35 let mangled_name_bwn = mangled_name.into_bytes_with_nul();
36 let mangled_name_ptr = mangled_name_bwn.as_ref();
37 let mut out_type: *mut BNType = std::ptr::null_mut();
38 let mut out_name = BNQualifiedName::default();
39 let res = unsafe {
40 BNDemangleGeneric(
41 arch.handle,
42 mangled_name_ptr.as_ptr() as *const c_char,
43 &mut out_type,
44 &mut out_name,
45 view.map(|v| v.handle).unwrap_or(std::ptr::null_mut()),
46 simplify,
47 )
48 };
49
50 if res {
51 let out_type = match out_type.is_null() {
52 true => None,
53 false => Some(unsafe { Type::ref_from_raw(out_type) }),
54 };
55 Some((QualifiedName::from_owned_raw(out_name), out_type))
56 } else {
57 None
58 }
59}
60
61pub fn demangle_llvm<S: BnStrCompatible>(mangled_name: S, simplify: bool) -> Option<QualifiedName> {
62 let mangled_name_bwn = mangled_name.into_bytes_with_nul();

Callers 1

test_custom_demanglerFunction · 0.50

Calls 3

into_bytes_with_nulMethod · 0.80
mapMethod · 0.80
as_refMethod · 0.45

Tested by 1

test_custom_demanglerFunction · 0.40