Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/file_format/pe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ struct OptionalCOFFHeader {
struct ExportedSymbolsTableDef {
_unk: [u8; 0x14],
number_of_functions: u32,
_unk_1: u32,
number_of_names: u32,
function_address_array_index: u32,
function_name_array_index: u32,
name_ordinals_array_index: u32,
}

/// The machine type (architecture) of a module in a process. An image file can
Expand Down Expand Up @@ -340,12 +341,20 @@ pub fn symbols(
}
.unwrap_or_default();

(0..symbols_def.number_of_functions).filter_map(move |i| {
(0..symbols_def.number_of_names).filter_map(move |i| {
let ordinal = process
.read::<u16>(address + symbols_def.name_ordinals_array_index + i.wrapping_mul(2))
.ok()
.map(|val| val as u32)
.filter(|&val| val < symbols_def.number_of_functions)?;

Some(Symbol {
address: address
+ process
.read::<u32>(
address + symbols_def.function_address_array_index + i.wrapping_mul(4),
address
+ symbols_def.function_address_array_index
+ ordinal.wrapping_mul(4),
)
.ok()?,
name_addr: address
Expand Down
Loading