Skip to content

Commit

Permalink
Add additional bytes and use symbols to prevent false-positives
Browse files Browse the repository at this point in the history
  • Loading branch information
asimon-1 committed Jan 10, 2024
1 parent fe32466 commit 55213f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 51 deletions.
49 changes: 12 additions & 37 deletions src/common/offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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] = &[
Expand All @@ -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);

Expand All @@ -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] = &[
Expand Down Expand Up @@ -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);

Expand Down
28 changes: 14 additions & 14 deletions src/training/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 55213f4

Please sign in to comment.