From c603112fcaba898b4dce74ee56d2e60a65d77857 Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Mon, 23 Nov 2026 08:40:59 +0300 Subject: [PATCH] The plugin check accepts exlaunch's exl_inline_hook_with_fp_impl, the inline-hook entry that saves d0..d15 next to x0..x29. Magic of the Kingdom's hook stub calls it and was refused for it (#1388) Co-Authored-By: Claude Opus 5.5 --- tests/exefs_plugins_test.py | 6 ++++++ tools/exefs_plugins.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/exefs_plugins_test.py b/tests/exefs_plugins_test.py index 4f5a39ce..00c060c7 100644 --- a/tests/exefs_plugins_test.py +++ b/tests/exefs_plugins_test.py @@ -182,6 +182,12 @@ class Check(unittest.TestCase): self.assertEqual(hooks[0]['callback'], f'plugin0+{CB_OFF:#x}') self.assertEqual(hooks[0]['trampoline'], f'plugin0+{TRAMP_OFF:#x}') + def test_good_with_fp_impl(self): # Magic of the Kingdom: the impl that saves d0..d15 as well + self.assertIn('exl_inline_hook_with_fp_impl', xp.HOOK_IMPLS) + hooks, reasons = xp.check_record(record(), {PLUGIN + IMPL_OFF: 'exl_inline_hook_with_fp_impl'}) + self.assertEqual(reasons, []) + self.assertEqual(hooks[0]['impl'], 'exl_inline_hook_with_fp_impl') + def test_good_plain_original(self): self.assertEqual(self.reasons(record(original=0xAA0003F3)), []) # mov x19, x0, copied as it is diff --git a/tools/exefs_plugins.py b/tools/exefs_plugins.py index ec584a30..7fd98069 100644 --- a/tools/exefs_plugins.py +++ b/tools/exefs_plugins.py @@ -37,7 +37,7 @@ The check (check_record) accepts a record only when every rule holds; each broke - the init called only the svcs ALLOWED_SVCS, GetInfo with ALLOWED_INFO, and the imports ALLOWED_IMPORTS; - every write into a game module is a word of main's .text whose original is no br, blr or ret, and it is one of: - an inline hook (MSFix, Full Inventory Expansion): `b ` into a plugin's .text, the stub in exlaunch's - shape (stur x30, [sp, #-0x10]; bl exl_inline_hook_impl or the float one; ldur x30, [sp, #-0x10]; + shape (stur x30, [sp, #-0x10]; bl one of exlaunch's hook impls, HOOK_IMPLS; ldur x30, [sp, #-0x10]; b ; .quad ), the trampoline the site's original relocated (the same word, the same PC-relative target, or exlaunch's long form of it, relocation_end) and its jump back to the site + 4 (returns_to); @@ -86,7 +86,10 @@ ALLOWED_IMPORTS = SAFE_LIBC | {SNPRINTF, '_ZN2nn2oe17GetDisplayVersionEPNS0_14Di # talks to a service or changes memory mappings. REACH_IMPORTS = SAFE_LIBC | {SNPRINTF} SVC_OUTPUT_DEBUG_STRING = 0x27 -HOOK_IMPLS = ('exl_inline_hook_impl', 'exl_inline_float_hook_impl') +# exlaunch's inline-hook entry points. Each saves the registers its context holds, calls the callback with that context +# and restores them; none saves NZCV (recomp/flags.py). exl_inline_hook_with_fp_impl (Magic of the Kingdom) saves +# d0..d15 next to x0..x29. +HOOK_IMPLS = ('exl_inline_hook_impl', 'exl_inline_float_hook_impl', 'exl_inline_hook_with_fp_impl') STUR_X30 = 0xF81F03FE # stur x30, [sp, #-0x10] LDUR_X30 = 0xF85F03FE # ldur x30, [sp, #-0x10] STUB_WORDS = 6 # 4 instructions and the callback's .quad