mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-07 03:58:09 +00:00
Size of injected code decreased
This commit is contained in:
parent
a8688bff85
commit
991fd015de
@ -88,7 +88,7 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
|
|||||||
auto old_last_syscall = CPU.m_last_syscall;
|
auto old_last_syscall = CPU.m_last_syscall;
|
||||||
CPU.m_last_syscall = func->id;
|
CPU.m_last_syscall = func->id;
|
||||||
|
|
||||||
if (!(index & EIF_DONT_SAVE_RTOC))
|
if (index & EIF_SAVE_RTOC)
|
||||||
{
|
{
|
||||||
// save RTOC if necessary
|
// save RTOC if necessary
|
||||||
vm::write64(vm::cast(CPU.GPR[1] + 0x28), CPU.GPR[2]);
|
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;
|
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;
|
CPU.m_last_syscall = old_last_syscall;
|
||||||
}
|
}
|
||||||
else
|
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));
|
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++;
|
g_ppu_func_subs[j].found++;
|
||||||
base[i + 0] = re32(0x04000000 | g_ppu_func_subs[j].index | EIF_DONT_SAVE_RTOC); // hack
|
base[i] = re32(0x04000000 | g_ppu_func_subs[j].index | EIF_PERFORM_BLR); // hack
|
||||||
base[i + 1] = se32(0x4e800020); // blr
|
|
||||||
i += 1; // skip modified code
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@ enum : u32
|
|||||||
// flags passed with index
|
// flags passed with index
|
||||||
enum : u32
|
enum : u32
|
||||||
{
|
{
|
||||||
EIF_DONT_SAVE_RTOC = (1 << 25), // don't save RTOC before calling
|
EIF_SAVE_RTOC = (1 << 25), // save RTOC in [SP+0x28] before calling HLE/LLE function
|
||||||
|
EIF_PERFORM_BLR = (1 << 24), // do BLR after calling HLE/LLE function
|
||||||
|
|
||||||
EIF_FLAGS = 0x2000000, // all flags
|
EIF_FLAGS = 0x3000000, // all flags
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ModuleFunc
|
struct ModuleFunc
|
||||||
|
@ -249,7 +249,7 @@ namespace loader
|
|||||||
index = add_psv_func(psv_func(nid, 0, nullptr, "UNKNOWN", nullptr));
|
index = add_psv_func(psv_func(nid, 0, nullptr, "UNKNOWN", nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
vm::psv::write32(addr + 0, 0xe0700090 | (index & 0xfff0) << 4 | (index & 0xf)); // HACK instruction (ARM)
|
vm::psv::write32(addr, 0xe0700090 | (index & 0xfff0) << 4 | (index & 0xf)); // HACK instruction (ARM)
|
||||||
|
|
||||||
code_end = std::min<u32>(addr, code_end);
|
code_end = std::min<u32>(addr, code_end);
|
||||||
}
|
}
|
||||||
|
@ -417,14 +417,13 @@ namespace loader
|
|||||||
{
|
{
|
||||||
u32 i_addr = 0;
|
u32 i_addr = 0;
|
||||||
|
|
||||||
if (!vm::check_addr(addr, 8) || !vm::check_addr(i_addr = vm::read32(addr), 8))
|
if (!vm::check_addr(addr, 8) || !vm::check_addr(i_addr = vm::read32(addr), 4))
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOADER, "Failed to inject code for function '%s' (opd=0x%x, 0x%x)", SysCalls::GetHLEFuncName(nid), addr, i_addr);
|
LOG_ERROR(LOADER, "Failed to inject code for exported function '%s' (opd=0x%x, 0x%x)", SysCalls::GetHLEFuncName(nid), addr, i_addr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vm::write32(i_addr + 0, HACK(index | EIF_DONT_SAVE_RTOC));
|
vm::write32(i_addr, HACK(index | EIF_PERFORM_BLR));
|
||||||
vm::write32(i_addr + 4, BLR());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,14 +449,13 @@ namespace loader
|
|||||||
LOG_NOTICE(LOADER, "Imported function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr);
|
LOG_NOTICE(LOADER, "Imported function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vm::check_addr(addr, 8))
|
if (!vm::check_addr(addr, 4))
|
||||||
{
|
{
|
||||||
LOG_ERROR(LOADER, "Failed to inject code for function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr);
|
LOG_ERROR(LOADER, "Failed to inject code for function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vm::write32(addr + 0, HACK(index));
|
vm::write32(addr, HACK(index | EIF_SAVE_RTOC | EIF_PERFORM_BLR));
|
||||||
vm::write32(addr + 4, BLR());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -671,8 +669,7 @@ namespace loader
|
|||||||
LOG_NOTICE(LOADER, "Imported %sfunction '%s' in '%s' module (0x%x)", func->lle_func ? "LLE " : "", SysCalls::GetHLEFuncName(nid), module_name, addr);
|
LOG_NOTICE(LOADER, "Imported %sfunction '%s' in '%s' module (0x%x)", func->lle_func ? "LLE " : "", SysCalls::GetHLEFuncName(nid), module_name, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vm::write32(addr + 0, HACK(index));
|
vm::write32(addr, HACK(index | EIF_SAVE_RTOC | EIF_PERFORM_BLR));
|
||||||
vm::write32(addr + 4, BLR());
|
|
||||||
|
|
||||||
//if (!func || !func->lle_func)
|
//if (!func || !func->lle_func)
|
||||||
//{
|
//{
|
||||||
|
Loading…
Reference in New Issue
Block a user