Added function to calculate and encode relative operands#368
Merged
athre0z merged 4 commits intozyantific:masterfrom Jul 25, 2022
Merged
Added function to calculate and encode relative operands#368athre0z merged 4 commits intozyantific:masterfrom
athre0z merged 4 commits intozyantific:masterfrom
Conversation
Contributor
Author
|
Pushed some tests, CI fails because I cannot commit workflow change: - name: Running regression tests (encoder)
run: |
cd tests
- python3 regression_encoder.py ../build/ZydisFuzzReEncoding ../build/ZydisFuzzEncoder
+ python3 regression_encoder.py ../build/ZydisFuzzReEncoding ../build/ZydisFuzzEncoder ../build/ZydisTestEncoderAbsolute |
Member
|
Thanks a lot @mappzor 👍 I just pushed the workflow changes. There seems to be a minor string format issue, but other than that it looks very good 🙂 |
flobernd
approved these changes
Jul 22, 2022
Member
flobernd
left a comment
There was a problem hiding this comment.
LGTM! Thanks again, that will make a lot of users happy!
Is there a python script to generate the new .inc file or was it rather "generated" by hand? 😄
Contributor
Author
|
There's a new mode added to the script, will push it in a moment. It's not the prettiest thing but it does the job. |
athre0z
approved these changes
Jul 25, 2022
Member
athre0z
left a comment
There was a problem hiding this comment.
LGTM as well, thanks a lot for tackling this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to 268 and #345.
This PR introduces
ZydisEncoderEncodeInstructionAbsolutefunction which accepts absolute addresses instead of:First group of instructions is handled by patching displacement after encoding. Second group uses fast size prediction algorithm to find the right variant and calculate relative operand prior to encoding. This has less overhead than trying to brute-force encode different variants. Solutions exploits simplicity of branching instructions as they have less "moving parts" such as prefixes, ModR/M, SIB, etc. This allows for fast table lookups with some minor adjustments.
Let me know if you have any feedback. If we want to proceed with this solution I will clean up my test code and add it to this PR. Final test suite would be a small C tool triggered from usual python test scripts.