mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
Reimplement/fix PRX patches
This commit is contained in:
parent
48296c2ba6
commit
e26ae9899c
4 changed files with 56 additions and 60 deletions
|
|
@ -315,18 +315,18 @@ static void ppu_initialize_modules(ppu_linkage_info* link)
|
|||
ppu_loader.trace("** &0x%08X: %s (size=0x%x, align=0x%x)", variable.first, variable.second.name, variable.second.size, variable.second.align);
|
||||
|
||||
// Allocate HLE variable
|
||||
if (variable.second.size >= 4096 || variable.second.align >= 4096)
|
||||
if (variable.second.size >= 0x10000 || variable.second.align >= 0x10000)
|
||||
{
|
||||
variable.second.addr = vm::alloc(variable.second.size, vm::main, std::max<u32>(variable.second.align, 0x10000));
|
||||
}
|
||||
else
|
||||
{
|
||||
const u32 next = utils::align(alloc_addr, variable.second.align);
|
||||
const u32 end = next + variable.second.size;
|
||||
const u32 end = next + variable.second.size - 1;
|
||||
|
||||
if (!next || (end >> 12 != alloc_addr >> 12))
|
||||
if (!next || (end >> 16 != alloc_addr >> 16))
|
||||
{
|
||||
alloc_addr = vm::alloc(4096, vm::main);
|
||||
alloc_addr = vm::alloc(0x10000, vm::main);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -773,12 +773,12 @@ static void ppu_check_patch_spu_images(const ppu_segment& seg)
|
|||
for (const auto& prog : obj.progs)
|
||||
{
|
||||
// Apply the patch
|
||||
applied += g_fxo->get<patch_engine>()->apply_with_ls_check(hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
|
||||
applied += g_fxo->get<patch_engine>()->apply(hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
|
||||
|
||||
if (!Emu.GetTitleID().empty())
|
||||
{
|
||||
// Alternative patch
|
||||
applied += g_fxo->get<patch_engine>()->apply_with_ls_check(Emu.GetTitleID() + '-' + hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
|
||||
applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash, (elf_header + prog.p_offset), prog.p_filesz, prog.p_vaddr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1084,21 +1084,33 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
|
|||
sha1_finish(&sha, prx->sha1);
|
||||
|
||||
// Format patch name
|
||||
std::string hash("PRX-0000000000000000000000000000000000000000");
|
||||
for (u32 i = 0; i < 20; i++)
|
||||
{
|
||||
constexpr auto pal = "0123456789abcdef";
|
||||
hash[4 + i * 2] = pal[prx->sha1[i] >> 4];
|
||||
hash[5 + i * 2] = pal[prx->sha1[i] & 15];
|
||||
}
|
||||
std::string hash = fmt::format("PRX-%s", fmt::base57(prx->sha1));
|
||||
|
||||
// Apply the patch
|
||||
auto applied = g_fxo->get<patch_engine>()->apply(hash, vm::g_base_addr);
|
||||
std::basic_string<u32> applied;
|
||||
|
||||
if (!Emu.GetTitleID().empty())
|
||||
for (usz i = 0; i < prx->segs.size(); i++)
|
||||
{
|
||||
// Alternative patch
|
||||
applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash, vm::g_base_addr);
|
||||
const auto& seg = prx->segs[i];
|
||||
|
||||
if (!seg.size) continue;
|
||||
|
||||
const std::string hash_seg = fmt::format("%s-%u", hash, i);
|
||||
|
||||
// Apply the patch
|
||||
auto _applied = g_fxo->get<patch_engine>()->apply(hash_seg, vm::get_super_ptr(seg.addr), seg.size);
|
||||
|
||||
if (!Emu.GetTitleID().empty())
|
||||
{
|
||||
// Alternative patch
|
||||
_applied += g_fxo->get<patch_engine>()->apply(Emu.GetTitleID() + '-' + hash_seg, vm::get_super_ptr(seg.addr), seg.size);
|
||||
}
|
||||
|
||||
// Rebase patch offsets
|
||||
std::for_each(_applied.begin(), _applied.end(), [&](u32& res) { if (res != umax) res += seg.addr; });
|
||||
|
||||
applied += _applied;
|
||||
|
||||
ppu_loader.success("PRX library hash: %s (<- %u)", hash_seg, _applied.size());
|
||||
}
|
||||
|
||||
// Embedded SPU elf patching
|
||||
|
|
@ -1109,8 +1121,6 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
|
|||
|
||||
prx->analyse(toc, 0, end, applied);
|
||||
|
||||
ppu_loader.success("PRX library hash: %s (<- %u)", hash, applied.size());
|
||||
|
||||
try_spawn_ppu_if_exclusive_program(*prx);
|
||||
|
||||
return prx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue