pub struct Patch(_);
Expand description
A constructor to acquire a PatchBuilder
, which you can use to patch the game’s memory.
Example:
// Replace the instruction at `main` + 0x14a8504 with a branch
// to `main` + 0x14a853C
let text_builder: PatchBuilder = Patch::in_text(0x69),
Implementations
sourceimpl Patch
impl Patch
sourcepub fn at_offset(offset: usize) -> Self
pub fn at_offset(offset: usize) -> Self
Provide the base offset to work with for methods. This offset will be treated as absolute.
If you would like to work relative to a region, prefer using the other methods like Patch::in_text.
Some methods, such as branch_to, will assume a Region for you.
Example:
// In this context, branch_to will overwrite the instruction at offset 0x69
// Since branch_to assumes that you are working using Region::Text, your offset will be turned into .text+offset.
Patch::at_offset(0x69).branch_to(0x420);
sourcepub fn branch_to(self, dest_offset: usize)
pub fn branch_to(self, dest_offset: usize)
Insert a b
ARM instruction to jump to the destination offset.
It is assumed that the offset you provided is relative to the Text region of the running executable
Shortcut method for:
BranchBuilder::branch().branch_offset().branch_to_offset().replace()
Example:
// Overwriting the instruction at offset 0x69 with a branch in the .text section that redirects the Program Counter to address 0x420
Patch::at_offset(0x69).branch_to(0x420);
sourcepub fn branch_link_to(self, dest_offset: usize)
pub fn branch_link_to(self, dest_offset: usize)
Insert a bl
ARM instruction to jump to the destination offset.
It is assumed that the offset you provided is relative to the Text region of the running executable
Shortcut method for:
BranchBuilder::branch_link().branch_offset().branch_to_offset().replace
Example:
// Overwriting the instruction at offset 0x69 with a branch link in the .text section that redirects the Program Counter to address 0x420
Patch::at_offset(0x69).branch_link_to(0x420);
sourcepub fn in_section(self, region: Region) -> PatchBuilder
pub fn in_section(self, region: Region) -> PatchBuilder
Use the base offset provided to at_offset to get an address for a section of the executable.
It is preferable that you use the shortcut methods for conciseness.
Example:
// In this context, branch_to will overwrite the instruction at offset 0x69
let builder: PatchBuilder = Patch::at_offset(0x69).in_section(Region::Text);
sourcepub fn in_text(offset: usize) -> PatchBuilder
pub fn in_text(offset: usize) -> PatchBuilder
Provide a PatchBuilder targeting the .text section
Shortcut method for:
PatchBuilder::at_offset(offset).in_section(Region::Text)
Example:
let builder: PatchBuilder = Patch::in_text(offset);
sourcepub fn in_data(offset: usize) -> PatchBuilder
pub fn in_data(offset: usize) -> PatchBuilder
Provide a PatchBuilder targeting the .data section
Shortcut method for:
PatchBuilder::at_offset(offset).in_section(Region::Data)
Example:
let builder: PatchBuilder = Patch::in_data(offset);
sourcepub fn in_rodata(offset: usize) -> PatchBuilder
pub fn in_rodata(offset: usize) -> PatchBuilder
Provide a PatchBuilder targeting the .rodata section
Shortcut method for:
PatchBuilder::at_offset(offset).in_section(Region::Rodata)
Example:
let builder: PatchBuilder = Patch::in_rodata(offset);
sourcepub fn in_bss(offset: usize) -> PatchBuilder
pub fn in_bss(offset: usize) -> PatchBuilder
Provide a PatchBuilder targeting the .bss section
Shortcut method for:
PatchBuilder::at_offset(offset).in_section(Region::Bss)
Example:
let builder: PatchBuilder = Patch::in_bss(offset);
sourcepub fn in_heap(offset: usize) -> PatchBuilder
pub fn in_heap(offset: usize) -> PatchBuilder
Provide a PatchBuilder targeting the heap
Shortcut method for:
PatchBuilder::at_offset(offset).in_section(Region::Heap)
Example:
let builder: PatchBuilder = Patch::in_heap(offset);
Auto Trait Implementations
impl RefUnwindSafe for Patch
impl Send for Patch
impl Sync for Patch
impl Unpin for Patch
impl UnwindSafe for Patch
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more