Skip to content

Commit

Permalink
Use RVA for PE symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
benfred committed Nov 1, 2024
1 parent 68d418b commit ae1e218
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/binary_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,8 @@ pub fn parse_binary(filename: &Path, addr: u64, size: u64) -> Result<BinaryInfo,
Object::PE(pe) => {
for export in pe.exports {
if let Some(name) = export.name {
if let Some(export_offset) = export.offset {
if let Some(addr) = offset.checked_add(export_offset as u64) {
symbols.insert(name.to_string(), addr);
}
if let Some(addr) = offset.checked_add(export.rva as u64) {
symbols.insert(name.to_string(), addr);
}
}
}
Expand Down
18 changes: 16 additions & 2 deletions src/python_process_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ impl PythonProcessInfo {
let map = maps.iter().find(|m| {
if let Some(pathname) = m.filename() {
if let Some(pathname) = pathname.to_str() {
return is_python_bin(pathname) && m.is_exec();
#[cfg(not(windows))]
{
return is_python_bin(pathname) && m.is_exec();
}
#[cfg(windows)]
{
return is_python_bin(pathname);
}
}
}
false
Expand Down Expand Up @@ -139,7 +146,14 @@ impl PythonProcessInfo {
let libmap = maps.iter().find(|m| {
if let Some(pathname) = m.filename() {
if let Some(pathname) = pathname.to_str() {
return is_python_lib(pathname) && m.is_exec();
#[cfg(not(windows))]
{
return is_python_lib(pathname) && m.is_exec();
}
#[cfg(windows)]
{
return is_python_lib(pathname);
}
}
}
false
Expand Down

0 comments on commit ae1e218

Please sign in to comment.