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

Function import_til_section

plugins/idb_import/src/lib.rs:155–219  ·  view source on GitHub ↗
(
    debug_info: &mut DebugInfo,
    debug_file: &BinaryView,
    til: &TILSection,
    progress: impl Fn(usize, usize) -> Result<(), ()>,
)

Source from the content-addressed store, hash-verified

153}
154
155pub fn import_til_section(
156 debug_info: &mut DebugInfo,
157 debug_file: &BinaryView,
158 til: &TILSection,
159 progress: impl Fn(usize, usize) -> Result<(), ()>,
160) -> Result<()> {
161 let types = types::translate_til_types(debug_file.default_arch().unwrap(), til, progress)?;
162
163 // print any errors
164 for ty in &types {
165 match &ty.ty {
166 TranslateTypeResult::NotYet => {
167 panic!(
168 "type could not be processed `{}`: {:#?}",
169 ty.name.as_utf8_lossy(),
170 &ty.og_ty
171 );
172 }
173 TranslateTypeResult::Error(error) => {
174 error!(
175 "Unable to parse type `{}`: {error}",
176 ty.name.as_utf8_lossy(),
177 );
178 }
179 TranslateTypeResult::PartiallyTranslated(_, error) => {
180 if let Some(error) = error {
181 error!(
182 "Unable to parse type `{}` correctly: {error}",
183 ty.name.as_utf8_lossy(),
184 );
185 } else {
186 warn!(
187 "Type `{}` maybe not be fully translated",
188 ty.name.as_utf8_lossy(),
189 );
190 }
191 }
192 TranslateTypeResult::Translated(_) => {}
193 };
194 }
195
196 // add all type to binary ninja
197 for ty in &types {
198 if let TranslateTypeResult::Translated(bn_ty)
199 | TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
200 {
201 if !debug_info.add_type(ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
202 error!("Unable to add type `{}`", ty.name.as_utf8_lossy())
203 }
204 }
205 }
206
207 // add a second time to fix the references LOL
208 for ty in &types {
209 if let TranslateTypeResult::Translated(bn_ty)
210 | TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
211 {
212 if !debug_info.add_type(ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {

Callers 2

parse_idb_infoFunction · 0.85
parse_til_infoFunction · 0.85

Calls 3

translate_til_typesFunction · 0.85
default_archMethod · 0.80
add_typeMethod · 0.45

Tested by

no test coverage detected