mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
PPU: Add new patch function for SONIC 06
This commit is contained in:
parent
681a6ef73c
commit
f572e29a13
10 changed files with 94 additions and 25 deletions
|
@ -718,7 +718,7 @@ static usz apply_modification(std::basic_string<u32>& applied, const patch_engin
|
|||
// Always executable
|
||||
u64 flags = vm::alloc_executable | vm::alloc_unwritable;
|
||||
|
||||
switch (p.offset % patch_engine::mem_protection::mask)
|
||||
switch (p.offset & patch_engine::mem_protection::mask)
|
||||
{
|
||||
case patch_engine::mem_protection::rw:
|
||||
case patch_engine::mem_protection::wx:
|
||||
|
@ -754,15 +754,26 @@ static usz apply_modification(std::basic_string<u32>& applied, const patch_engin
|
|||
// Register code
|
||||
ppu_register_range(addr, alloc_size);
|
||||
|
||||
// Write branch to code
|
||||
ppu_form_branch_to_code(out_branch, addr);
|
||||
resval = out_branch & -4;
|
||||
|
||||
// Write branch to return to code
|
||||
if (!ppu_form_branch_to_code(addr + static_cast<u32>(p.value.long_value) * 4, resval + 4))
|
||||
{
|
||||
patch_log.error("Failed to write return jump at 0x%x", addr + static_cast<u32>(p.value.long_value) * 4);
|
||||
ensure(alloc_map->dealloc(addr));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write branch to code
|
||||
if (!ppu_form_branch_to_code(out_branch, addr))
|
||||
{
|
||||
patch_log.error("Failed to jump to code cave at 0x%x", out_branch);
|
||||
ensure(alloc_map->dealloc(addr));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write address of the allocated memory to the code entry
|
||||
*vm::get_super_ptr<u32>(resval) = addr;
|
||||
|
||||
// Write branch to return to code
|
||||
ppu_form_branch_to_code(addr + static_cast<u32>(p.value.long_value) * 4, resval + 4);
|
||||
relocate_instructions_at = addr;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue