Implement dynamic patching support in pnaches #11801
Merged
+136
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Implement a new
dpatch
commandThe length of the dpatch line is dynamic and user controlled
dpatch=<version/type>,<# of patterns>,<# of replacements>,...
As of this PR the only valid version/type is 0. This is to prevent the need to break backwards compatibility in the future
After these first three sections you put the patterns and replacements. The format of those are identical:
<offset>,<value>
An example is as follows:
dpatch=0,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
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?