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

Method resolve_missing_ntrs

plugins/pdb-ng/src/parser.rs:358–454  ·  view source on GitHub ↗
(
        &mut self,
        symbols: &Vec<ParsedSymbol>,
        progress: Box<dyn Fn(usize, usize) -> Result<()> + '_>,
    )

Source from the content-addressed store, hash-verified

356 }
357
358 fn resolve_missing_ntrs(
359 &mut self,
360 symbols: &Vec<ParsedSymbol>,
361 progress: Box<dyn Fn(usize, usize) -> Result<()> + '_>,
362 ) -> Result<()> {
363 let mut unknown_names = HashMap::new();
364 let mut known_names = self
365 .bv
366 .types()
367 .iter()
368 .map(|qnat| qnat.name)
369 .collect::<HashSet<_>>();
370
371 for ty in &self.named_types {
372 known_names.insert(ty.0.clone());
373 }
374
375 let count = symbols.len();
376 for (i, sym) in symbols.iter().enumerate() {
377 match sym {
378 ParsedSymbol::Data(ParsedDataSymbol {
379 type_: Some(type_), ..
380 }) => {
381 self.collect_names(type_.contents.as_ref(), &mut unknown_names);
382 }
383 ParsedSymbol::Procedure(ParsedProcedure {
384 type_: Some(type_),
385 locals,
386 ..
387 }) => {
388 self.collect_names(type_.contents.as_ref(), &mut unknown_names);
389 for l in locals {
390 if let Some(ltype) = &l.type_ {
391 self.collect_names(ltype.contents.as_ref(), &mut unknown_names);
392 }
393 }
394 }
395 _ => {}
396 }
397 progress(i, count)?;
398 }
399
400 for (name, class) in unknown_names.into_iter() {
401 if known_names.contains(&name) {
402 self.log(|| format!("Found referenced name and ignoring: {}", &name));
403 continue;
404 }
405 self.log(|| format!("Adding referenced but unknown type {} (likely due to demangled name and stripped type)", &name));
406 match class {
407 NamedTypeReferenceClass::UnknownNamedTypeClass
408 | NamedTypeReferenceClass::TypedefNamedTypeClass => {
409 self.debug_info.add_type(&name, Type::void().as_ref(), &[]);
410 // TODO : Components
411 }
412 NamedTypeReferenceClass::ClassNamedTypeClass
413 | NamedTypeReferenceClass::StructNamedTypeClass
414 | NamedTypeReferenceClass::UnionNamedTypeClass => {
415 let mut structure = StructureBuilder::new();

Callers 1

try_parse_infoMethod · 0.80

Calls 15

mapMethod · 0.80
collect_namesMethod · 0.80
iterMethod · 0.45
typesMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45
as_refMethod · 0.45
into_iterMethod · 0.45
containsMethod · 0.45
logMethod · 0.45
add_typeMethod · 0.45

Tested by

no test coverage detected