mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 08:36:41 +01:00
list imports per exe-rs example
This commit is contained in:
parent
14a6dca63f
commit
fe2fedadad
1 changed files with 14 additions and 1 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -1,5 +1,7 @@
|
|||
use clap::Parser;
|
||||
use std::path::Path;
|
||||
use exe::pe::{PE, VecPE};
|
||||
use exe::types::{ImportDirectory, ImportData, CCharString};
|
||||
|
||||
type Usually<T> = Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
|
|
@ -23,7 +25,18 @@ impl VestalCli {
|
|||
}
|
||||
}
|
||||
fn inspect (&self, path: impl AsRef<Path>) -> Usually<()> {
|
||||
todo!("inspect");
|
||||
let image = VecPE::from_disk_file(path)?;
|
||||
let import_directory = ImportDirectory::parse(&image)?;
|
||||
for descriptor in import_directory.descriptors {
|
||||
let name = descriptor.get_name(&image)?.as_str()?;
|
||||
println!("\n{name}:");
|
||||
for import in descriptor.get_imports(&image).unwrap() {
|
||||
match import {
|
||||
ImportData::Ordinal(x) => println!("{name} #{}", x),
|
||||
ImportData::ImportByName(s) => println!("{name} {}", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue