From 8f599e1e9ffa9354ff45c41df706fc11380e3552 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 10 Jan 2016 11:58:16 -0800 Subject: [PATCH] optimize basic hook for size --- Lua/inject.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Lua/inject.lua b/Lua/inject.lua index 9eb458e..9038a22 100644 --- a/Lua/inject.lua +++ b/Lua/inject.lua @@ -30,24 +30,28 @@ local injection_points = { ow_before = 0x0C03151F, }, } +injection_points['O JP10'] = injection_points['O US10'] local header = [[ [overwritten]: 0x%08X - // TODO: optimize for size - // TODO: fix case where overwritten function takes 5+ args - push ra - push a0, a1, a2, a3 + // note: this will fail when the overwritten function takes args on stack + sw ra, -4(sp) + sw a0, 0(sp) + sw a1, 4(sp) + sw a2, 8(sp) + sw a3, 12(sp) bal start - nop - pop a0, a1, a2, a3 - jal @overwritten - nop - jpop ra + subi sp, sp, 20 + lw ra, 16(sp) + lw a0, 20(sp) + lw a1, 24(sp) + lw a2, 28(sp) + lw a3, 32(sp) + j @overwritten + addi sp, sp, 20 start: ]] -injection_points['O JP10'] = injection_points['O US10'] - function inject(fn) local asm_dir = bizstring and 'inject/' or './mm/Lua/inject/' local asm_path = asm_dir..fn