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

Function demangle_ms

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

Source from the content-addressed store, hash-verified

129}
130
131pub fn demangle_ms<S: BnStrCompatible>(
132 arch: &CoreArchitecture,
133 mangled_name: S,
134 simplify: bool,
135) -> Option<(QualifiedName, Option<Ref<Type>>)> {
136 let mangled_name_bwn = mangled_name.into_bytes_with_nul();
137 let mangled_name_ptr = mangled_name_bwn.as_ref();
138
139 let mut out_type: *mut BNType = std::ptr::null_mut();
140 let mut out_name: *mut *mut std::os::raw::c_char = std::ptr::null_mut();
141 let mut out_size: usize = 0;
142 let res = unsafe {
143 BNDemangleMS(
144 arch.handle,
145 mangled_name_ptr.as_ptr() as *const c_char,
146 &mut out_type,
147 &mut out_name,
148 &mut out_size,
149 simplify,
150 )
151 };
152
153 match res {
154 true => {
155 assert!(!out_name.is_null());
156 let names: Vec<_> = unsafe { ArrayGuard::<BnString>::new(out_name, out_size, ()) }
157 .iter()
158 .map(str::to_string)
159 .collect();
160 unsafe { BNFreeDemangledName(&mut out_name, out_size) };
161
162 let out_type = match out_type.is_null() {
163 true => None,
164 false => Some(unsafe { Type::ref_from_raw(out_type) }),
165 };
166
167 Some((names.into(), out_type))
168 }
169 false => None,
170 }
171}
172
173#[derive(PartialEq, Eq, Hash)]
174pub struct Demangler {

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