From 55213f4095a5b7a3cb1f679ca0c69473269abfb8 Mon Sep 17 00:00:00 2001 From: asimon-1 <40246417+asimon-1@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:05:08 -0500 Subject: [PATCH] Add additional bytes and use symbols to prevent false-positives --- src/common/offsets.rs | 49 +++++++++++-------------------------------- src/training/mod.rs | 28 ++++++++++++------------- 2 files changed, 26 insertions(+), 51 deletions(-) diff --git a/src/common/offsets.rs b/src/common/offsets.rs index 21bf0dd72..f3b8bb7e0 100644 --- a/src/common/offsets.rs +++ b/src/common/offsets.rs @@ -252,6 +252,10 @@ static NEEDLE_CLOUD_ADD_LIMIT: &[u8] = &[ 0xf6, 0x57, 0x09, 0xa9, 0xf4, 0x4f, 0x0a, 0xa9, 0xfd, 0x7b, 0x0b, 0xa9, + 0xfd, 0xc3, 0x02, 0x91, + 0x13, 0x28, 0x40, 0xf9, + 0x68, 0x02, 0x40, 0xf9, + 0x08, 0x85, 0x40, 0xf9, ]; impl_offset!(CLOUD_ADD_LIMIT); @@ -308,31 +312,6 @@ static NEEDLE_FOLLOW_REQ: &[u8] = &[ ]; impl_offset!(FOLLOW_REQ); -// OFFSET_EFFECT_REQ = 0x44de50 -static NEEDLE_EFFECT_REQ: &[u8] = &[ - 0xff, 0x43, 0x03, 0xd1, - 0xe9, 0x23, 0x07, 0x6d, - 0xf9, 0x43, 0x00, 0xf9, - 0xf8, 0x5f, 0x09, 0xa9, - 0xf6, 0x57, 0x0a, 0xa9, - 0xf4, 0x4f, 0x0b, 0xa9, - 0xfd, 0x7b, 0x0c, 0xa9, - 0xfd, 0x03, 0x03, 0x91, -]; -impl_offset!(EFFECT_REQ); - -// OFFSET_JOINT_EFFECT_REQ = 0x44e1e0 -static NEEDLE_JOINT_EFFECT_REQ: &[u8] = &[ - 0xff, 0xc3, 0x05, 0xd1, - 0xec, 0x73, 0x00, 0xfd, - 0xeb, 0x2b, 0x0f, 0x6d, - 0xe9, 0x23, 0x10, 0x6d, - 0xfc, 0x6f, 0x11, 0xa9, - 0xfa, 0x67, 0x12, 0xa9, - 0xf8, 0x5f, 0x13, 0xa9, - 0xf6, 0x57, 0x14, 0xa9, -]; -impl_offset!(JOINT_EFFECT_REQ); // OFFSET_CAN_FUTTOBI_BACK = 0x260f950 static NEEDLE_CAN_FUTTOBI_BACK: &[u8] = &[ @@ -344,6 +323,10 @@ static NEEDLE_CAN_FUTTOBI_BACK: &[u8] = &[ 0x28, 0x11, 0x40, 0xb8, 0x0a, 0x05, 0x00, 0x71, 0xeb, 0x03, 0x00, 0x54, + 0x0d, 0x00, 0x40, 0xf9, + 0x28, 0x51, 0x80, 0xb8, + 0x8e, 0x7b, 0x94, 0xd2, + 0x8e, 0x0d, 0xb7, 0xf2, ]; impl_offset!(CAN_FUTTOBI_BACK); @@ -360,18 +343,6 @@ static NEEDLE_REUSED_UI: &[u8] = &[ ]; impl_offset!(REUSED_UI); -// OFFSET_ARTICLE_GET_INT = 0x3d5920 -static NEEDLE_ARTICLE_GET_INT: &[u8] = &[ - 0xf5, 0x0f, 0x1d, 0xf8, - 0xf4, 0x4f, 0x01, 0xa9, - 0xfd, 0x7b, 0x02, 0xa9, - 0xfd, 0x83, 0x00, 0x91, - 0x08, 0x00, 0x40, 0xf9, - 0x08, 0xe5, 0x40, 0xf9, - 0xf3, 0x03, 0x02, 0x2a, - 0xf4, 0x03, 0x01, 0x2a, -]; -impl_offset!(ARTICLE_GET_INT); // OFFSET_OPCF = 0x6b7fdc static NEEDLE_OPCF: &[u8] = &[ @@ -431,6 +402,10 @@ static NEEDLE_KIRBY_OPFF: &[u8] = &[ 0xf4, 0x4f, 0x07, 0xa9, 0xfd, 0x7b, 0x08, 0xa9, 0xfd, 0x03, 0x02, 0x91, + 0x3a, 0x10, 0x40, 0xf9, + 0x54, 0x2b, 0x40, 0xf9, + 0x88, 0x02, 0x40, 0xf9, + 0x08, 0x59, 0x40, 0xf9, ]; impl_offset!(KIRBY_OPFF); diff --git a/src/training/mod.rs b/src/training/mod.rs index 4afed4146..7e534d474 100644 --- a/src/training/mod.rs +++ b/src/training/mod.rs @@ -11,7 +11,7 @@ use crate::logging::*; use crate::training::character_specific::{items, kirby, pikmin, ptrainer}; use skyline::hooks::{getRegionAddress, InlineCtx, Region}; use skyline::nn::ro::LookupSymbol; -use smash::app::{self, enSEType, lua_bind::*, utility}; +use smash::app::{self, BattleObjectModuleAccessor, enSEType, lua_bind::*, utility}; use smash::lib::lua_const::*; use smash::params::*; use smash::phx::{Hash40, Vector3f}; @@ -590,9 +590,9 @@ pub unsafe fn handle_effect_follow( ) } -#[skyline::hook(offset = *OFFSET_EFFECT_REQ)] // hooked to prevent death gfx from playing when loading save states +#[skyline::hook(replace = EffectModule::req)] // hooked to prevent death gfx from playing when loading save states pub unsafe fn handle_fighter_effect( - effect_module: *mut FighterEffectModule, // pointer to effect module + module_accessor: &mut BattleObjectModuleAccessor, eff_hash: Hash40, pos: *const Vector3f, rot: *const Vector3f, @@ -604,7 +604,7 @@ pub unsafe fn handle_fighter_effect( ) -> u64 { if !is_training_mode() { return original!()( - effect_module, + module_accessor, eff_hash, pos, rot, @@ -615,9 +615,9 @@ pub unsafe fn handle_fighter_effect( arg9, ); } - size = ptrainer::handle_pokemon_effect(&mut *(*effect_module).owner, eff_hash, size); + size = ptrainer::handle_pokemon_effect(module_accessor, eff_hash, size); original!()( - effect_module, + module_accessor, eff_hash, pos, rot, @@ -629,9 +629,9 @@ pub unsafe fn handle_fighter_effect( ) } -#[skyline::hook(offset = *OFFSET_JOINT_EFFECT_REQ)] // hooked to prevent death gfx from playing when loading save states +#[skyline::hook(replace = EffectModule::req_on_joint)] // hooked to prevent death gfx from playing when loading save states pub unsafe fn handle_fighter_joint_effect( - effect_module: *mut FighterEffectModule, // pointer to effect module + module_accessor: &mut BattleObjectModuleAccessor, eff_hash: Hash40, joint_hash: Hash40, pos: *const Vector3f, @@ -646,7 +646,7 @@ pub unsafe fn handle_fighter_joint_effect( ) -> u64 { if !is_training_mode() { return original!()( - effect_module, + module_accessor, eff_hash, joint_hash, pos, @@ -660,9 +660,9 @@ pub unsafe fn handle_fighter_joint_effect( arg9, ); } - size = ptrainer::handle_pokemon_effect(&mut *(*effect_module).owner, eff_hash, size); + size = ptrainer::handle_pokemon_effect(module_accessor, eff_hash, size); original!()( - effect_module, + module_accessor, eff_hash, joint_hash, pos, @@ -767,13 +767,13 @@ pub unsafe fn handle_reused_ui( original!()(fighter_data, param_2) } -#[skyline::hook(offset = *OFFSET_ARTICLE_GET_INT)] +#[skyline::hook(replace = ArticleModule::get_int)] pub unsafe fn handle_article_get_int( - article_module: *mut app::BattleObjectModuleAccessor, // *mut ArticleModule + module_accessor: *mut app::BattleObjectModuleAccessor, generate_article: i32, address: i32, ) -> i32 { - original!()(article_module, generate_article, address) + original!()(module_accessor, generate_article, address) } // Instruction run on the completion of the CPU Control function