-
-
Notifications
You must be signed in to change notification settings - Fork 430
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
Added function to calculate and encode relative operands #368
Conversation
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 |
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 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? 😄
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well, thanks a lot for tackling this!
Related to 268 and #345.
This PR introduces
ZydisEncoderEncodeInstructionAbsolute
function 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.