Expose load commands
This commit is contained in:
parent
6dba4064f2
commit
f76597cb7c
10
src/lib.rs
10
src/lib.rs
|
@ -9,6 +9,7 @@ use pyo3::{exceptions::PyTypeError, prelude::*};
|
|||
mod exports;
|
||||
mod header;
|
||||
mod imports;
|
||||
mod load_commands;
|
||||
mod sections;
|
||||
mod segments;
|
||||
mod symbols;
|
||||
|
@ -16,6 +17,7 @@ mod symbols;
|
|||
use exports::Export;
|
||||
use header::Header;
|
||||
use imports::Import;
|
||||
use load_commands::LoadCommand;
|
||||
use sections::{Section, Sections};
|
||||
use segments::Segment;
|
||||
use symbols::Symbols;
|
||||
|
@ -149,6 +151,14 @@ impl Object {
|
|||
.map_err(|_| PyErr::new::<PyTypeError, _>("failed"))?;
|
||||
Ok(imports.into_iter().map(|exp| exp.into()).collect())
|
||||
}
|
||||
|
||||
fn load_commands(&self) -> Vec<LoadCommand> {
|
||||
self.macho()
|
||||
.load_commands
|
||||
.iter()
|
||||
.map(|cmd| cmd.into())
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Object {
|
||||
|
|
26
src/load_commands.rs
Normal file
26
src/load_commands.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use pyo3::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[pyclass]
|
||||
pub struct LoadCommand {
|
||||
#[pyo3(get)]
|
||||
offset: usize,
|
||||
#[pyo3(get)]
|
||||
command: String,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl LoadCommand {
|
||||
fn __repr__(&self) -> String {
|
||||
format!("{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&goblin::mach::load_command::LoadCommand> for LoadCommand {
|
||||
fn from(lcmd: &goblin::mach::load_command::LoadCommand) -> Self {
|
||||
LoadCommand {
|
||||
offset: lcmd.offset,
|
||||
command: format!("{:?}", lcmd.command),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue