From 9eb0d555bd424dd641c59d5219df6cbd2f97c1eb Mon Sep 17 00:00:00 2001 From: SuddyN Date: Mon, 30 Jun 2025 19:09:23 -0400 Subject: [PATCH 1/6] 13.0.4 offsets --- .github/workflows/rust.yml | 2 +- src/common/offsets.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d92dc238d..d2cb52094 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -114,7 +114,7 @@ jobs: --create-dirs \ --output-dir ${{env.SMASH_PLUGIN_DIR}} \ --remote-name-all \ - https://github.com/ultimate-research/params-hook-plugin/releases/download/v13.0.3/libparam_hook.nro \ + https://github.com/ultimate-research/params-hook-plugin/releases/download/v13.0.4/libparam_hook.nro \ https://github.com/ultimate-research/nro-hook-plugin/releases/download/v0.4.0/libnro_hook.nro zip -r training_modpack_beta.zip atmosphere - name: Delete Release diff --git a/src/common/offsets.rs b/src/common/offsets.rs index b61bc036a..fbeb1dd89 100644 --- a/src/common/offsets.rs +++ b/src/common/offsets.rs @@ -63,7 +63,7 @@ static NEEDLE_GET_BATTLE_OBJECT_FROM_ID: &[u8] = &[ ]; impl_offset!(GET_BATTLE_OBJECT_FROM_ID); -// OFFSET_COPY_SETUP = 0xba0e60 +// OFFSET_COPY_SETUP = 0xba0e80 static NEEDLE_COPY_SETUP: &[u8] = &[ 0xe8, 0x0f, 0x19, 0xfc, 0xfc, 0x6f, 0x01, 0xa9, @@ -76,7 +76,7 @@ static NEEDLE_COPY_SETUP: &[u8] = &[ ]; impl_offset!(COPY_SETUP); -// OFFSET_IS_VISIBLE_BACKSHIELD = 0x1655400 +// OFFSET_IS_VISIBLE_BACKSHIELD = 0x1655410 static NEEDLE_IS_VISIBLE_BACKSHIELD: &[u8] = &[ 0xfd, 0x7b, 0xbf, 0xa9, 0xfd, 0x03, 0x00, 0x91, @@ -170,7 +170,7 @@ impl_offset!(CLOUD_ADD_LIMIT); // OFFSET_STALE_MENU = 0x13e88c0 static NEEDLE_STALE_MENU: &[u8] = &[ 0xdf, 0x82, 0x2d, 0x39, - 0xb3, 0x43, 0x8e, 0x94, + 0xab, 0x44, 0x8e, 0x94, 0x00, 0x1d, 0xa8, 0x4e, 0xc0, 0xa2, 0x06, 0x91, ]; @@ -179,7 +179,7 @@ impl_offset!(STALE_MENU); // IMPORTANT! See above comment for STALE_MENU // OFFSET_STALE = 0x13e88c4 static NEEDLE_STALE: &[u8] = &[ - 0xb3, 0x43, 0x8e, 0x94, + 0xab, 0x44, 0x8e, 0x94, 0x00, 0x1d, 0xa8, 0x4e, 0xc0, 0xa2, 0x06, 0x91, 0xdf, 0x22, 0x2f, 0x39, @@ -295,7 +295,7 @@ static NEEDLE_KIRBY_OPFF: &[u8] = &[ ]; impl_offset!(KIRBY_OPFF); -// OFFSET_ACTIVATE_AUTONOMY = 0x34b6990 +// OFFSET_ACTIVATE_AUTONOMY = 0x34B6720 static NEEDLE_ACTIVATE_AUTONOMY: &[u8] = &[ 0xf6, 0x57, 0xbd, 0xa9, 0xf4, 0x4f, 0x01, 0xa9, @@ -308,7 +308,7 @@ static NEEDLE_ACTIVATE_AUTONOMY: &[u8] = &[ ]; impl_offset!(ACTIVATE_AUTONOMY); -// OFFSET_POKEMON_DECIDE = 0x34ce904 +// OFFSET_POKEMON_DECIDE = 0x34CE694 static NEEDLE_POKEMON_DECIDE: &[u8] = &[ 0x28, 0x69, 0x2b, 0x38, 0x48, 0x26, 0x8b, 0x52, @@ -317,7 +317,7 @@ static NEEDLE_POKEMON_DECIDE: &[u8] = &[ ]; impl_offset!(POKEMON_DECIDE); -// OFFSET_LAYOUT_ARC_MALLOC = 0x3773d74 +// OFFSET_LAYOUT_ARC_MALLOC = 0x3774154 static NEEDLE_LAYOUT_ARC_MALLOC: &[u8] = &[ 0xe3, 0xe6, 0x06, 0x94, 0xa0, 0x05, 0x00, 0xb4, @@ -330,7 +330,7 @@ impl_offset!(LAYOUT_ARC_MALLOC); static NEEDLE_TRAINING_RESET_CHECK: &[u8] = &[ 0x1f, 0x09, 0x00, 0x71, 0x41, 0x1c, 0x00, 0x54, - 0x08, 0xfa, 0x01, 0xb0, + 0x08, 0xfa, 0x01, 0x90, 0x08, 0x7d, 0x42, 0xf9, 0x08, 0x01, 0x40, 0xf9, 0x09, 0xa1, 0x40, 0xb9, From 3235b9e189314d4ff420375ee2b3eeb351bf1a91 Mon Sep 17 00:00:00 2001 From: SuddyN Date: Tue, 1 Jul 2025 21:32:19 -0400 Subject: [PATCH 2/6] use memchr::memmem --- Cargo.toml | 1 + src/common/offsets.rs | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 932cdb4fe..0e54bec11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ num-traits = "0.2" wsl = "0.1.0" strum = "0.21.0" strum_macros = "0.21.0" +memchr = "2.7.4" minreq = { version = "2", features = ["https-native", "json-using-serde"] } sarc = { version = "1.2.0", features = [], default-features = false } serde = { version = "1", features = ["derive"] } diff --git a/src/common/offsets.rs b/src/common/offsets.rs index fbeb1dd89..cc80f672c 100644 --- a/src/common/offsets.rs +++ b/src/common/offsets.rs @@ -5,23 +5,28 @@ use training_mod_sync::LazyLock; // Stolen from HDR who stole it from Arcropolis // https://github.com/HDR-Development/HewDraw-Remix/blob/dev/dynamic/src/util.rs -pub fn byte_search(needle: &[T]) -> Option { - let text = unsafe { - let start = skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *const T; - let end = skyline::hooks::getRegionAddress(skyline::hooks::Region::Rodata) as *const T; +pub fn byte_search(needle: &[u8]) -> (Option, Option) { + let haystack = unsafe { + let start = skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as *const u8; + let end = skyline::hooks::getRegionAddress(skyline::hooks::Region::Rodata) as *const u8; let length = end.offset_from(start) as usize; std::slice::from_raw_parts(start, length) }; - - text.windows(needle.len()) - .position(|window| window == needle) + use memchr::memmem; + let first = memmem::find(haystack, needle); + let last = memmem::rfind(haystack, needle); + return (first, last); } // Wrapper around byte_search() with some additional logging fn find_offset(name: &str, needle: &[u8]) -> Option { info!("Searching for {}", name); let offset_opt = byte_search(needle); - match offset_opt { + if offset_opt.0 != offset_opt.1 { + error!("Found multiple offsets for {}. Extend the bytecode to be more specific", name); + return None; + } + match offset_opt.0 { Some(offset) => { info!("Found offset for {} at {:#x}", name, offset); Some(offset) @@ -73,10 +78,11 @@ static NEEDLE_COPY_SETUP: &[u8] = &[ 0xf4, 0x4f, 0x05, 0xa9, 0xfd, 0x7b, 0x06, 0xa9, 0xfd, 0x83, 0x01, 0x91, + 0xff, 0x43, 0x17, 0xd1, ]; impl_offset!(COPY_SETUP); -// OFFSET_IS_VISIBLE_BACKSHIELD = 0x1655410 +// OFFSET_IS_VISIBLE_BACKSHIELD = 0x1655610 static NEEDLE_IS_VISIBLE_BACKSHIELD: &[u8] = &[ 0xfd, 0x7b, 0xbf, 0xa9, 0xfd, 0x03, 0x00, 0x91, From 39fac2cca915087175904c73be76b88a7c7d305f Mon Sep 17 00:00:00 2001 From: asimon-1 <40246417+asimon-1@users.noreply.github.com> Date: Wed, 2 Jul 2025 07:29:47 -0400 Subject: [PATCH 3/6] Update skyline_smash to use our fork --- training_mod_consts/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/training_mod_consts/Cargo.toml b/training_mod_consts/Cargo.toml index 87dee493f..b345e54a0 100644 --- a/training_mod_consts/Cargo.toml +++ b/training_mod_consts/Cargo.toml @@ -13,7 +13,7 @@ serde = { version = "1.0", features = ["derive"] } serde_repr = "0.1.8" serde_json = "1" skyline = { git = "https://github.com/ultimate-research/skyline-rs.git" } -skyline_smash = { git = "https://github.com/ultimate-research/skyline-smash.git", optional = true } +skyline_smash = { git = "https://github.com/austintraver/skyline-smash.git", optional = true } toml = "0.5.9" anyhow = "1.0.72" rand = { git = "https://github.com/skyline-rs/rand" } From d584f562f77b8694a14ddd18452d1392a3e92a63 Mon Sep 17 00:00:00 2001 From: asimon-1 <40246417+asimon-1@users.noreply.github.com> Date: Wed, 2 Jul 2025 07:39:46 -0400 Subject: [PATCH 4/6] Add more bytes to NEEDLE_COPY_SETUP to avoid multiple matches --- src/common/offsets.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/offsets.rs b/src/common/offsets.rs index cc80f672c..a1d9e5284 100644 --- a/src/common/offsets.rs +++ b/src/common/offsets.rs @@ -79,6 +79,10 @@ static NEEDLE_COPY_SETUP: &[u8] = &[ 0xfd, 0x7b, 0x06, 0xa9, 0xfd, 0x83, 0x01, 0x91, 0xff, 0x43, 0x17, 0xd1, + 0x18, 0xa4, 0x40, 0xf9, + 0xfa, 0x03, 0x03, 0x2a, + 0x5f, 0x18, 0x00, 0x71, + 0xc1, 0x02, 0x00, 0x54, ]; impl_offset!(COPY_SETUP); From 0e758d37c8945f5ab552e18a83d309accb2d3a8f Mon Sep 17 00:00:00 2001 From: asimon-1 <40246417+asimon-1@users.noreply.github.com> Date: Wed, 2 Jul 2025 08:35:27 -0400 Subject: [PATCH 5/6] Fix camera manager address --- src/training/tech.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/training/tech.rs b/src/training/tech.rs index 4499cd591..d2e18f34a 100644 --- a/src/training/tech.rs +++ b/src/training/tech.rs @@ -464,7 +464,7 @@ unsafe fn set_fixed_camera_values() { pub unsafe fn get_camera_manager() -> &'static mut CameraManager { // CameraManager pointer is located here - let on_cam_mgr_ptr = (getRegionAddress(Region::Text) as u64) + 0x52b6f00; + let on_cam_mgr_ptr = (getRegionAddress(Region::Text) as u64) + 0x52b5f00; let pointer_arith = on_cam_mgr_ptr as *const *mut *mut CameraManager; &mut ***pointer_arith } From b4e9ed596ccbb8d99224e7c4c8c0c06e1cf1bc0d Mon Sep 17 00:00:00 2001 From: jugeeya Date: Wed, 2 Jul 2025 10:25:23 -0700 Subject: [PATCH 6/6] Update rust.yml --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d2cb52094..ec5d826af 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -56,7 +56,7 @@ jobs: cache-all-crates: true - name: Install Skyline run: | - cargo install --git https://github.com/jam1garner/cargo-skyline --branch master --force + cargo install --git https://github.com/jugeeya/cargo-skyline --branch patch-3 --force cargo-skyline skyline update-std - name: Build release NRO id: build_release