From db18572a704a20a7749997ff1ab4b47df25bd2e7 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Sun, 24 Nov 2024 22:05:38 +0000 Subject: [PATCH] CHudPause_patches: allocate options strings on stack --- UnleashedRecomp/patches/ui/CHudPause_patches.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/UnleashedRecomp/patches/ui/CHudPause_patches.cpp b/UnleashedRecomp/patches/ui/CHudPause_patches.cpp index 92db1a2b..0f4d4b55 100644 --- a/UnleashedRecomp/patches/ui/CHudPause_patches.cpp +++ b/UnleashedRecomp/patches/ui/CHudPause_patches.cpp @@ -5,18 +5,10 @@ void CHudPauseAddOptionsItemMidAsmHook(PPCRegister& pThis) { - auto pStrMemory = __HH_ALLOC(8); + guest_stack_var menu("TopMenu"); + guest_stack_var name("option"); - auto menu = Hedgehog::Base::CSharedString("TopMenu"); - auto name = Hedgehog::Base::CSharedString("option"); - - // TODO: replace with wrapper to put these into guest memory. - memcpy(pStrMemory, &menu, 4); - memcpy((void*)((size_t)pStrMemory + 4), &name, 4); - - GuestToHostFunction(0x824AE690, pThis.u32, pStrMemory, (void*)((size_t)pStrMemory + 4)); - - __HH_FREE(pStrMemory); + GuestToHostFunction(0x824AE690, pThis.u32, menu.get(), name.get()); } bool InjectOptionsBehaviour(uint32_t pThis, uint32_t count)