Skip to content

Commit

Permalink
Forgot formatting, like an idiot
Browse files Browse the repository at this point in the history
  • Loading branch information
Jujstme committed Oct 12, 2023
1 parent eadf75f commit 7556ffa
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/file_format/pe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::{fmt, mem};

use bytemuck::{Pod, Zeroable};

use crate::{string::ArrayCString, Address, FromEndian, Process, Error};
use crate::{string::ArrayCString, Address, Error, FromEndian, Process};

// Reference:
// https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
Expand Down Expand Up @@ -285,7 +285,10 @@ pub struct Symbol {

impl Symbol {
/// Tries to retrieve the name of the current symbol
pub fn get_name<const CAP: usize>(&self, process: &Process) -> Result<ArrayCString<CAP>, Error> {
pub fn get_name<const CAP: usize>(
&self,
process: &Process,
) -> Result<ArrayCString<CAP>, Error> {
process.read(self.name_addr)
}
}
Expand All @@ -308,8 +311,8 @@ pub fn symbols(
};

let export_directory = match dos_header {
Ok(x) => process
.read::<u32>(address + x.e_lfanew + if is_64_bit { 0x88 } else { 0x78 })
Ok(header) => process
.read::<u32>(address + header.e_lfanew + if is_64_bit { 0x88 } else { 0x78 })
.ok(),
_ => None,
};
Expand All @@ -327,20 +330,19 @@ pub fn symbols(
.unwrap_or_default();

(0..symbols_def.number_of_functions).filter_map(move |i| {
let name_addr = address
+ process
.read::<u32>(
address + symbols_def.function_name_array_index + i.wrapping_mul(4),
)
.ok()?;

let address: Address = address
+ process
.read::<u32>(
address + symbols_def.function_address_array_index + i.wrapping_mul(4),
)
.ok()?;

Some(Symbol { address, name_addr })
Some(Symbol {
address: address
+ process
.read::<u32>(
address + symbols_def.function_address_array_index + i.wrapping_mul(4),
)
.ok()?,
name_addr: address
+ process
.read::<u32>(
address + symbols_def.function_name_array_index + i.wrapping_mul(4),
)
.ok()?,
})
})
}

0 comments on commit 7556ffa

Please sign in to comment.