Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic patching support in pnaches #11801

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Implement dynamic patching support in pnaches #11801

wants to merge 1 commit into from

Conversation

F0bes
Copy link
Member

@F0bes F0bes commented Sep 11, 2024

Experimental !!

Description of Changes

Implement a new dpatch command

The length of the dpatch line is dynamic and user controlled

dpatch=<# of patterns>,<# of replacements>,...

After these first two sections you put the patterns and replacements. The format of those are identical:
<offset>,<value>

An example is as follows:

dpatch=3,1,0,8FA20000,4,02002025,8,24420010,8,00000000

This line has 3 patterns and 1 replacement

It looks for the following set of instructions

0 | 8FA20000
4 | 02002025
8 | 24420010

and will replace offset #8 with 00000000

The values are a fixed 32 bits because this only works on code memory. Dynamic patches only work on the EE recompiler and only activate during recompilation stage. This means the dpatch will only work on code that has not been compiled to x86 yet. If you enable the dpatch too late, nothing will happen. I suppose the entire rec cache can be invalidated when dpatches are enabled or disabled. I think it's easier just telling people to reset the VM after enabling (or disabling) any dpatches.

Rationale behind Changes

Sometimes you need to patch dynamic code that moves around.

Suggested Testing Steps

Try to write a dynamic patch and see if it works.
Maybe make sure it doesn't cause issues with gamedb dynamic patches?
Interleave them with normal patches?

pcsx2/Patch.cpp Outdated Show resolved Hide resolved
@SuperSamus
Copy link
Contributor

Tested Ratchet: Deadlocked (PCSX2/pcsx2_patches#383), works fine 👍.
It was also interleaved with a normal patch (the Widescreen patch).

make sure it doesn't cause issues with gamedb dynamic patches?

Didn't test it.
Should this system still be here? There's only one game that uses it (R&C 2 PAL), couldn't it be replaced by the patches: default: content: |- syntax used to apply regular patches on other games?

@F0bes
Copy link
Member Author

F0bes commented Sep 11, 2024

Should this system still be here? There's only one game that uses it (R&C 2 PAL), couldn't it be replaced by the patches: default: content: |- syntax used to apply regular patches on other games?

I guess this can replace the dynamic patches in the gamedb. I'll be honest, I don't really know if I like this system. There is no lookahead in the pnach parser. I was forced to write a layout that is placed in all one line and it's kind of unreadable lol

@F0bes
Copy link
Member Author

F0bes commented Sep 16, 2024

I suppose the entire rec cache can be invalidated when dpatches are enabled or disabled.

My fundamental understanding how the dynamic patches are applied was incorrect. Like normal patches, once the patch is enabled it will be stuck and baked into savestates,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants