summaryrefslogtreecommitdiff
path: root/plugins/idb_import/src/lib.rs
diff options
context:
space:
mode:
authorrbran <git@rubens.io>2025-01-27 13:43:35 -0300
committerMason Reed <mason@vector35.com>2025-01-27 12:22:47 -0500
commit37f4ee46a40eee23cd039ae8329c9157a86aff65 (patch)
treecda7901a60f948613b6b8e76f2ae9edc12559c5b /plugins/idb_import/src/lib.rs
parent123bb13826f68cbfa3158e2ebf30ca59a143afb1 (diff)
Update idb_import to 0.1.8
Diffstat (limited to 'plugins/idb_import/src/lib.rs')
-rw-r--r--plugins/idb_import/src/lib.rs34
1 files changed, 13 insertions, 21 deletions
diff --git a/plugins/idb_import/src/lib.rs b/plugins/idb_import/src/lib.rs
index ddd22ea5..70bbf07c 100644
--- a/plugins/idb_import/src/lib.rs
+++ b/plugins/idb_import/src/lib.rs
@@ -10,7 +10,7 @@ use binaryninja::debuginfo::{
use idb_rs::id0::{ID0Section, IDBParam1, IDBParam2};
use idb_rs::til::section::TILSection;
-use idb_rs::til::Type as TILType;
+use idb_rs::til::TypeVariant as TILTypeVariant;
use log::{error, trace, warn, LevelFilter};
@@ -92,9 +92,7 @@ impl std::io::Seek for BinaryViewReader<'_> {
fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result<u64> {
let new_offset = match pos {
std::io::SeekFrom::Start(offset) => Some(offset),
- std::io::SeekFrom::End(end) => u64::try_from(self.bv.len())
- .unwrap()
- .checked_add_signed(end),
+ std::io::SeekFrom::End(end) => self.bv.len().checked_add_signed(end),
std::io::SeekFrom::Current(next) => self.offset.checked_add_signed(next),
};
let new_offset =
@@ -148,9 +146,9 @@ fn parse_til_info(
bv: debug_file,
offset: 0,
};
- let file = std::io::BufReader::new(file);
+ let mut file = std::io::BufReader::new(file);
trace!("Parsing the TIL section");
- let til = TILSection::parse(file)?;
+ let til = TILSection::read(&mut file, idb_rs::IDBSectionCompression::None)?;
import_til_section(debug_info, debug_file, &til, progress)
}
@@ -168,26 +166,26 @@ pub fn import_til_section(
TranslateTypeResult::NotYet => {
panic!(
"type could not be processed `{}`: {:#?}",
- &String::from_utf8_lossy(&ty.name),
+ ty.name.as_utf8_lossy(),
&ty.og_ty
);
}
TranslateTypeResult::Error(error) => {
error!(
"Unable to parse type `{}`: {error}",
- &String::from_utf8_lossy(&ty.name)
+ ty.name.as_utf8_lossy(),
);
}
TranslateTypeResult::PartiallyTranslated(_, error) => {
if let Some(error) = error {
error!(
"Unable to parse type `{}` correctly: {error}",
- &String::from_utf8_lossy(&ty.name)
+ ty.name.as_utf8_lossy(),
);
} else {
warn!(
"Type `{}` maybe not be fully translated",
- &String::from_utf8_lossy(&ty.name)
+ ty.name.as_utf8_lossy(),
);
}
}
@@ -200,11 +198,8 @@ pub fn import_til_section(
if let TranslateTypeResult::Translated(bn_ty)
| TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
{
- if !debug_info.add_type(String::from_utf8_lossy(&ty.name), bn_ty, &[/* TODO */]) {
- error!(
- "Unable to add type `{}`",
- &String::from_utf8_lossy(&ty.name)
- )
+ if !debug_info.add_type(ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
+ error!("Unable to add type `{}`", ty.name.as_utf8_lossy())
}
}
}
@@ -214,11 +209,8 @@ pub fn import_til_section(
if let TranslateTypeResult::Translated(bn_ty)
| TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
{
- if !debug_info.add_type(String::from_utf8_lossy(&ty.name), bn_ty, &[/* TODO */]) {
- error!(
- "Unable to fix type `{}`",
- &String::from_utf8_lossy(&ty.name)
- )
+ if !debug_info.add_type(ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
+ error!("Unable to fix type `{}`", ty.name.as_utf8_lossy())
}
}
}
@@ -273,7 +265,7 @@ fn parse_id0_section_info(
});
match (label, &ty, bnty) {
- (_, Some(TILType::Function(_)), bnty) => {
+ (_, Some(ty), bnty) if matches!(&ty.type_variant, TILTypeVariant::Function(_)) => {
if bnty.is_none() {
error!("Unable to convert the function type at {addr:#x}",)
}