Skip to content

Commit

Permalink
Fix c10+ inkling crashes (#547)
Browse files Browse the repository at this point in the history
* Fix c10+ inkling crashes

* Update inkling c10+ patch to use BranchBuilder & added offsets

* Remove the `except` from the inkling c10+ patch

---------

Co-authored-by: Raytwo <[email protected]>
  • Loading branch information
Coolsonickirby and Raytwo authored Sep 22, 2023
1 parent 39d02a2 commit fafe449
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/fixes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::offsets;
use skyline::{from_offset, hook, hooks::InlineCtx, install_hooks, patching::Patch};
use skyline::{from_offset, hook, hooks::InlineCtx, install_hooks, patching::{Patch, BranchBuilder}};

// Patches to get Inkling c08+ working
fn install_inkling_patches() {
Expand All @@ -10,10 +10,18 @@ fn install_inkling_patches() {
}

// Inkling Patches here nop some branches so it can work with more than c08+
Patch::in_text(offsets::inkling_patch()).nop().expect("Failed to patch inkling 1 cmp");
Patch::in_text(offsets::inkling_patch())
.nop()
.expect("Failed to patch inkling 1 cmp");

Patch::in_text(offsets::inkling_patch() + 4)
.nop()
.expect("Failed to patch inkling 1 b.cs");

BranchBuilder::branch()
.branch_offset(offsets::inkling_c10plus())
.branch_to_offset(offsets::inkling_c10plus() + 0x38)
.replace();

install_hooks!(clear_ink_patch);
}
Expand Down
13 changes: 13 additions & 0 deletions src/offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ static CHANGE_COLOR_R_CODE: (&[u8], isize) = (
0x18,
);

static INKLING_C10PLUS_CODE: (&[u8], isize) = (
&[
0xe9, 0x03, 0x00, 0xb9, 0x00, 0x01, 0x3f, 0xd6, 0xa8, 0x02, 0x40, 0xf9, 0x08, 0x51, 0x40, 0xf9, 0xe1, 0x03, 0x00, 0x2a, 0xc2, 0xfa, 0x01,
0x11, 0xe0, 0x03, 0x15, 0xaa, 0x00, 0x01, 0x3f, 0xd6, 0xa8, 0x02, 0x40, 0xf9, 0x08, 0x51, 0x40, 0xf9, 0xc2, 0xfe, 0x01, 0x11, 0xe0, 0x03,
0x15, 0xaa, 0xe1, 0x03, 0x1f, 0x2a, 0x00, 0x01, 0x3f, 0xd6, 0xa8, 0x02, 0x40, 0xf9, 0x08, 0x51, 0x40, 0xf9, 0xc2, 0x02, 0x02, 0x11, 0xe0,
0x03, 0x15, 0xaa, 0xe1, 0x03, 0x1f, 0x2a, 0x00, 0x01, 0x3f, 0xd6
],
0x54,
);

#[allow(clippy::inconsistent_digit_grouping)]
fn offset_from_adrp(adrp_offset: usize) -> usize {
unsafe {
Expand Down Expand Up @@ -397,6 +407,7 @@ generate_members! {
is_online: usize,
change_color_r: usize,
change_color_l: usize,
inkling_c10plus: usize,
}
}

Expand Down Expand Up @@ -433,6 +444,7 @@ impl Offsets {
let chara_select_scene_destructor = get_offset_neon(text, CHARA_SELECT_SCENE_DESTRUCTOR_SEARCH_CODE);
let change_color_r = get_offset_neon(text, CHANGE_COLOR_R_CODE);
let change_color_l = change_color_r + 0x298;
let inkling_c10plus = get_offset_neon(text, INKLING_C10PLUS_CODE);
let filesystem_info = {
let adrp = get_offset_neon(text, FILESYSTEM_INFO_ADRP_SEARCH_CODE);
let adrp_offset = offset_from_adrp(adrp);
Expand Down Expand Up @@ -493,6 +505,7 @@ impl Offsets {
is_online,
change_color_r,
change_color_l,
inkling_c10plus
})
}
}
Expand Down

0 comments on commit fafe449

Please sign in to comment.