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
impl Patch
Sourcepub fn new(addr: u32, bytes: &[u8], enable: bool) -> Self
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.
Sourcepub fn disable(&mut self)
pub fn disable(&mut self)
Disables this patch, restoring the original bytes at the target address.
Sourcepub fn patch_bytes(&self) -> &[u8]
pub fn patch_bytes(&self) -> &[u8]
Returns a byte slice of the patch bytes that will be written when this patch is enabled.
Sourcepub fn original_bytes(&self) -> &[u8]
pub fn original_bytes(&self) -> &[u8]
Returns a byte slice of the original bytes that are overwritten when this patch is enabled.
Trait Implementations§
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> 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