instruction_pointer_operations

Crates.ioinstruction_pointer_operations
lib.rsinstruction_pointer_operations
version0.1.0
created_at2025-08-30 01:27:26.123815+00
updated_at2025-08-30 01:27:26.123815+00
descriptionA simple crate that allows users to manipulate the value of the instruction pointer without needing to write inline assembly.
homepage
repository
max_upload_size
id1817154
size3,508
(WebAppEnjoyer)

documentation

README

I don't really know what to write for this readme.

So here is the entirity of this library's source code:

#![no_std]
use core::arch::asm;
/// Gets the instruction pointer to the exact next instruction.
#[inline(always)]
pub fn get_ip() -> usize {
    let ip: usize;
    unsafe {
        asm!(
            "lea {0}, [rip]", 
            out(reg) ip
        );
    }
    ip
}
/// Sets the current value of the instruction pointer to addr.
#[inline(always)]
pub unsafe fn set_ip(addr: usize) -> ! {
    unsafe{
        asm!(
        "jmp {0}",
        in(reg) addr,
        options(noreturn)
        );
    }
}
Commit count: 0

cargo fmt