pub struct Module { /* private fields */ }Expand description
A validated, currently-loaded ELF object.
Implementations§
Source§impl Module
impl Module
Sourcepub unsafe fn from_handle(handle: *mut c_void) -> Result<Self>
pub unsafe fn from_handle(handle: *mut c_void) -> Result<Self>
Acquire a module from a dlopen handle. On glibc, dlinfo
(RTLD_DI_LINKMAP) yields the object’s load bias, which selects its
dl_iterate_phdr entry.
§Safety
handle must be a live handle returned by dlopen/dlmopen for a
currently-loaded object.
Sourcepub unsafe fn from_address(address: *const c_void) -> Result<Self>
pub unsafe fn from_address(address: *const c_void) -> Result<Self>
Acquire the module containing address — e.g. the address of an exported
§Safety
address must point into a loadable segment of a currently-mapped object.
Sourcepub fn from_name(name: &str) -> Result<Self>
pub fn from_name(name: &str) -> Result<Self>
Acquire an already-loaded module by SONAME / path (dlopen with
RTLD_NOLOAD, so a not-yet-loaded object is reported rather than loaded).
Sourcepub fn enumerate() -> Result<Vec<Self>>
pub fn enumerate() -> Result<Vec<Self>>
Enumerate every object loaded in the process (Scope::AllModules). Objects
that fail validation (no PT_DYNAMIC, unsupported machine) are skipped.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Size of the mapped image span (hi - lo over its loadable segments).
Sourcepub fn imports(&self) -> Result<Vec<ImportSlot>>
pub fn imports(&self) -> Result<Vec<ImportSlot>>
Enumerate the module’s import slots (JUMP_SLOT + GLOB_DAT).
Every returned slot’s address was validated to lie inside a loadable
segment and to be pointer-aligned, so it is safe to pass to
crate::install.