1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-05 05:39:02 -08:00
mm/Lua/inject/print.asm
2015-12-26 19:32:31 -08:00

38 lines
787 B
NASM

// translates calls to 800021F8
// to copy strings to memory instead
// for Lua to later pick up on
// reset buffer position in our per-frame hook
la t0, buffer
sw t0, buffer_pos
// and set the string to null
sb r0, 0(t0)
jr
nop
// keep track of where we are in the buffer
buffer_pos:
.word 0
// we'll just let this overflow
.align 8
buffer:
.word 0
// overwrite (not hook) the debug printing function
.org 0x800021B0
// a0: unknown
// a1: char *msg
// a2: size_t len
lw t0, buffer_pos
copy_loop:
lb t1, 0(a1)
sb t1, 0(t0)
addi t0, t0, 1
addi a1, a1, 1
subi a2, a2, 1
bne a2, r0, copy_loop
sb r0, 0(t0) // null terminate
sw t0, buffer_pos
jr
nop