Skip to content

Commit

Permalink
PE: Use OFTs for resolving imports without FTs
Browse files Browse the repository at this point in the history
  • Loading branch information
kkent030315 committed Oct 29, 2024
1 parent d096260 commit cfbb2c1
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/pe/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,29 @@ impl<'a> SyntheticImportDirectoryEntry<'a> {
}
};

let import_address_table_offset = &mut utils::find_offset(
import_directory_entry.import_address_table_rva as usize,
sections,
file_alignment,
opts,
)
.ok_or_else(|| {
error::Error::Malformed(format!(
"Cannot map import_address_table_rva {:#x} into offset for {}",
import_directory_entry.import_address_table_rva, name
))
})?;
let rva = match import_directory_entry.import_address_table_rva.is_zero() {
true => import_directory_entry.import_lookup_table_rva,
false => import_directory_entry.import_address_table_rva,
};

let import_address_table_offset =
&mut utils::find_offset(rva as usize, sections, file_alignment, opts).ok_or_else(
|| {
error::Error::Malformed(
if import_directory_entry.import_address_table_rva.is_zero() {
format!(
"Cannot map import_lookup_table_rva {:#x} into offset for {}",
rva, name
)
} else {
format!(
"Cannot map import_address_table_rva {:#x} into offset for {}",
rva, name
)
},
)
},
)?;
let mut import_address_table = Vec::new();
loop {
let import_address = bytes
Expand Down

0 comments on commit cfbb2c1

Please sign in to comment.