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: CStringName of the symbol.
func_address: *const fn()Pointer to the address of the symbol.
protection: c_intMemory protection. A bitwise-OR of PROT_READ, PROT_WRITE
and PROT_EXEC.
Currently, on MSWindows this value is always 0.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more