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

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);

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);

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);

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);

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);

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);

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);

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);

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.