mirror of
https://github.com/notwa/mm
synced 2024-06-26 03:57:13 -07:00
optimize basic hook for size
This commit is contained in:
parent
c3c9d632e0
commit
8f599e1e9f
|
@ -30,24 +30,28 @@ local injection_points = {
|
||||||
ow_before = 0x0C03151F,
|
ow_before = 0x0C03151F,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
injection_points['O JP10'] = injection_points['O US10']
|
||||||
|
|
||||||
local header = [[
|
local header = [[
|
||||||
[overwritten]: 0x%08X
|
[overwritten]: 0x%08X
|
||||||
// TODO: optimize for size
|
// note: this will fail when the overwritten function takes args on stack
|
||||||
// TODO: fix case where overwritten function takes 5+ args
|
sw ra, -4(sp)
|
||||||
push ra
|
sw a0, 0(sp)
|
||||||
push a0, a1, a2, a3
|
sw a1, 4(sp)
|
||||||
|
sw a2, 8(sp)
|
||||||
|
sw a3, 12(sp)
|
||||||
bal start
|
bal start
|
||||||
nop
|
subi sp, sp, 20
|
||||||
pop a0, a1, a2, a3
|
lw ra, 16(sp)
|
||||||
jal @overwritten
|
lw a0, 20(sp)
|
||||||
nop
|
lw a1, 24(sp)
|
||||||
jpop ra
|
lw a2, 28(sp)
|
||||||
|
lw a3, 32(sp)
|
||||||
|
j @overwritten
|
||||||
|
addi sp, sp, 20
|
||||||
start:
|
start:
|
||||||
]]
|
]]
|
||||||
|
|
||||||
injection_points['O JP10'] = injection_points['O US10']
|
|
||||||
|
|
||||||
function inject(fn)
|
function inject(fn)
|
||||||
local asm_dir = bizstring and 'inject/' or './mm/Lua/inject/'
|
local asm_dir = bizstring and 'inject/' or './mm/Lua/inject/'
|
||||||
local asm_path = asm_dir..fn
|
local asm_path = asm_dir..fn
|
||||||
|
|
Loading…
Reference in New Issue
Block a user