Size of injected code decreased

This commit is contained in:
Nekotekina 2015-02-24 19:38:10 +03:00
parent a8688bff85
commit 991fd015de
4 changed files with 18 additions and 16 deletions

View file

@ -88,7 +88,7 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
auto old_last_syscall = CPU.m_last_syscall;
CPU.m_last_syscall = func->id;
if (!(index & EIF_DONT_SAVE_RTOC))
if (index & EIF_SAVE_RTOC)
{
// save RTOC if necessary
vm::write64(vm::cast(CPU.GPR[1] + 0x28), CPU.GPR[2]);
@ -109,6 +109,12 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
CPU.GPR[3] = 0;
}
if (index & EIF_PERFORM_BLR)
{
// return if necessary
CPU.SetBranch(vm::cast(CPU.LR & ~3), true);
}
CPU.m_last_syscall = old_last_syscall;
}
else
@ -219,9 +225,7 @@ void hook_ppu_funcs(u32* base, u32 size)
{
LOG_NOTICE(LOADER, "Function '%s' hooked (addr=0x%x)", g_ppu_func_subs[j].name, vm::get_addr(base + i * 4));
g_ppu_func_subs[j].found++;
base[i + 0] = re32(0x04000000 | g_ppu_func_subs[j].index | EIF_DONT_SAVE_RTOC); // hack
base[i + 1] = se32(0x4e800020); // blr
i += 1; // skip modified code
base[i] = re32(0x04000000 | g_ppu_func_subs[j].index | EIF_PERFORM_BLR); // hack
}
}
}