Skip to main content

Patch

Struct Patch 

Source
pub struct Patch { /* private fields */ }
Expand description

A memory patch that can be enabled or disabled at runtime. When enabled, the patch will overwrite the target bytes with the patch bytes. When disabled, the original bytes will be restored.

The patch will be automatically disabled and cleaned up when dropped.

Implementations§

Source§

impl Patch

Source

pub fn new(addr: u32, bytes: &[u8], enable: bool) -> Self

Creates a new patch at the given address with the given patch bytes. The patch is enabled if enable is true, otherwise it is created in a disabled state.

Source

pub fn addr(&self) -> u32

Gets the address that this patch targets.

Source

pub fn len(&self) -> u32

Gets the length of this patch in bytes.

Source

pub fn enabled(&self) -> bool

Returns true if this patch is currently enabled.

Source

pub fn enable(&mut self)

Enables this patch, applying the patch bytes to the target address.

Source

pub fn disable(&mut self)

Disables this patch, restoring the original bytes at the target address.

Source

pub fn patch_bytes(&self) -> &[u8]

Returns a byte slice of the patch bytes that will be written when this patch is enabled.

Source

pub fn original_bytes(&self) -> &[u8]

Returns a byte slice of the original bytes that are overwritten when this patch is enabled.

Trait Implementations§

Source§

impl Drop for Patch

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl Freeze for Patch

§

impl RefUnwindSafe for Patch

§

impl !Send for Patch

§

impl !Sync for Patch

§

impl Unpin for Patch

§

impl UnsafeUnpin for Patch

§

impl UnwindSafe for Patch

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> 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, 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.