Struct TextPoke

Source
pub struct TextPoke {
    pub record_id: Option<RecordId>,
    pub addr: u64,
    pub old_bytes: Vec<u8>,
    pub new_bytes: Vec<u8>,
}
Expand description

Records changes to kernel text i.e. self-modified code.

§Examples

Running this example may require root privileges.

use std::fs::File;
use std::os::fd::AsRawFd;

use perf_event_open::config::{Cpu, Opts, Proc, WakeUpOn};
use perf_event_open::count::Counter;
use perf_event_open::event::sw::Software;

let event = Software::Dummy;
let target = (Proc::CURRENT, Cpu::ALL);

let mut opts = Opts::default();
opts.wake_up.on = WakeUpOn::Bytes(1);
opts.extra_record.ksymbol = true;
opts.extra_record.text_poke = true;

let counter = Counter::new(event, target, opts).unwrap();
let sampler = counter.sampler(5).unwrap();
counter.enable().unwrap();

// Insert a kernel module that registers a kprobe.
let file = File::open("register_kprobe_module.ko").unwrap();
unsafe {
    libc::syscall(libc::SYS_finit_module, file.as_raw_fd(), c"".as_ptr(), 0);
    libc::syscall(libc::SYS_delete_module, c"register_kprobe_module".as_ptr(), 0);
}

for it in sampler.iter() {
    println!("{:-?}", it);
}

Since linux-5.9: https://github.com/torvalds/linux/commit/e17d43b93e544f5016c0251d2074c15568d5d963

Fields§

§record_id: Option<RecordId>

Record IDs.

§addr: u64

Address.

§old_bytes: Vec<u8>

Old bytes.

§new_bytes: Vec<u8>

New bytes.

Trait Implementations§

Source§

impl Clone for TextPoke

Source§

fn clone(&self) -> TextPoke

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextPoke

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.