pub struct ExecutableMemory { /* private fields */ }Expand description
executable memory region for trampolines
automatically freed when dropped
Implementations§
Source§impl ExecutableMemory
impl ExecutableMemory
Sourcepub fn allocate_near(target: usize, size: usize) -> Result<Self>
pub fn allocate_near(target: usize, size: usize) -> Result<Self>
allocate executable memory near a target address
tries to allocate within ±2GB of target for relative jumps. falls back to any available address if near allocation fails.
Sourcepub fn allocate(size: usize) -> Result<Self>
pub fn allocate(size: usize) -> Result<Self>
allocate executable memory at any available address
Sourcepub fn write(&mut self, code: &[u8]) -> Result<usize>
pub fn write(&mut self, code: &[u8]) -> Result<usize>
write code to the memory region
returns the address where the code was written
Sourcepub fn is_near(&self, target: usize) -> bool
pub fn is_near(&self, target: usize) -> bool
check if this memory is within rel32 range of target
Sourcepub fn flush_icache(&self) -> Result<()>
pub fn flush_icache(&self) -> Result<()>
flush instruction cache for this region
Trait Implementations§
Source§impl Drop for ExecutableMemory
impl Drop for ExecutableMemory
impl Send for ExecutableMemory
impl Sync for ExecutableMemory
Auto Trait Implementations§
impl Freeze for ExecutableMemory
impl RefUnwindSafe for ExecutableMemory
impl Unpin for ExecutableMemory
impl UnwindSafe for ExecutableMemory
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