Symbol

Struct Symbol 

Source
pub struct Symbol {
    pub name: CString,
    pub func_address: *const fn(),
    pub protection: c_int,
}
Expand description

A symbol found in the PLT section.

Use ObjectFile::symbols to get them.

§Using function addresses

The function address in Symbol can be used to invoke functions.

You have to cast the address to the correct function type.

use plthook::ObjectFile;

let pid = std::process::id();

let object = ObjectFile::open_main_program().unwrap();
let getpid_fn = object
    .symbols()
    .find(|sym| sym.name.to_str() == Ok("getpid"))
    .unwrap()
    .func_address as *const fn() -> libc::pid_t;

assert_eq!(pid, unsafe { (*getpid_fn)() as u32 });

Fields§

§name: CString

Name of the symbol.

§func_address: *const fn()

Pointer to the address of the symbol.

§protection: c_int

Memory protection. A bitwise-OR of PROT_READ, PROT_WRITE and PROT_EXEC.

Currently, on MSWindows this value is always 0.

Trait Implementations§

Source§

impl Debug for Symbol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Symbol

§

impl RefUnwindSafe for Symbol

§

impl !Send for Symbol

§

impl !Sync for Symbol

§

impl Unpin for Symbol

§

impl UnwindSafe for Symbol

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.