[][src]Struct skyline::patching::BranchBuilder

pub struct BranchBuilder { /* fields omitted */ }

A builder type to help when replacing branches in games

Example:

// Replace the instruction at `main` + 0x14a8504 with a branch
// to `main` + 0x14a853C
BranchBuilder::branch()
    .branch_offset(0x14a8504)
    .branch_to_offset(0x14a853C)
    .replace()

// Replace the instruction at `main` + 0x14a8504 with a branch
// to `replacement_function`
BranchBuilder::branch()
    .branch_offset(0x14a8504)
    .branch_to_ptr(replacement_function as *const ())
    .replace()

Methods

impl BranchBuilder[src]

pub fn branch() -> Self[src]

Create new branch builder for a b ARM instruction

Create new branch builder for a bl ARM instruction

pub fn branch_offset(self, offset: usize) -> Self[src]

Set the offset within the executable of the instruction to replace

pub fn branch_to_offset(self, offset: usize) -> Self[src]

Offset within the executable for the branch to jump to

pub fn branch_to_ptr<T>(self, ptr: *const T) -> Self[src]

Set a pointer for the branch to be jumped to. Must be within +/- 128 MiB of the given offset

pub fn replace(self)[src]

Replaces an instruction at the provided offset with a branch to the given pointer.

Panics

Panics if an offset/ptr hasn't been provided or if the pointer is out of range of the branch

Auto Trait Implementations

impl RefUnwindSafe for BranchBuilder

impl !Send for BranchBuilder

impl !Sync for BranchBuilder

impl Unpin for BranchBuilder

impl UnwindSafe for BranchBuilder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.