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

Function demangle_gnu3

rust/src/demangle.rs:90–129  ·  view source on GitHub ↗
(
    arch: &CoreArchitecture,
    mangled_name: S,
    simplify: bool,
)

Source from the content-addressed store, hash-verified

88}
89
90pub fn demangle_gnu3<S: BnStrCompatible>(
91 arch: &CoreArchitecture,
92 mangled_name: S,
93 simplify: bool,
94) -> Option<(QualifiedName, Option<Ref<Type>>)> {
95 let mangled_name_bwn = mangled_name.into_bytes_with_nul();
96 let mangled_name_ptr = mangled_name_bwn.as_ref();
97 let mut out_type: *mut BNType = std::ptr::null_mut();
98 let mut out_name: *mut *mut std::os::raw::c_char = std::ptr::null_mut();
99 let mut out_size: usize = 0;
100 let res = unsafe {
101 BNDemangleGNU3(
102 arch.handle,
103 mangled_name_ptr.as_ptr() as *const c_char,
104 &mut out_type,
105 &mut out_name,
106 &mut out_size,
107 simplify,
108 )
109 };
110
111 match res {
112 true => {
113 assert!(!out_name.is_null());
114 let names: Vec<_> = unsafe { ArrayGuard::<BnString>::new(out_name, out_size, ()) }
115 .iter()
116 .map(str::to_string)
117 .collect();
118 unsafe { BNFreeDemangledName(&mut out_name, out_size) };
119
120 let out_type = match out_type.is_null() {
121 true => None,
122 false => Some(unsafe { Type::ref_from_raw(out_type) }),
123 };
124
125 Some((names.into(), out_type))
126 }
127 false => None,
128 }
129}
130
131pub fn demangle_ms<S: BnStrCompatible>(
132 arch: &CoreArchitecture,

Callers 1

test_demangler_simpleFunction · 0.50

Calls 4

into_bytes_with_nulMethod · 0.80
mapMethod · 0.80
as_refMethod · 0.45
iterMethod · 0.45

Tested by 1

test_demangler_simpleFunction · 0.40