-
-
Notifications
You must be signed in to change notification settings - Fork 432
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
Add size and offset to immediate and memory operand structs #489
Add size and offset to immediate and memory operand structs #489
Conversation
This information is already available in the public interface via |
Thanks for your contribution! I agree with @athre0z. Besides the already mentioned reason, ZydisDecodedOperand is meant to primarily hold the semantic/logical information about operands where as the "raw" struct shall be used to access details about the physical encoding. |
Hey, thanks for the response. What about something like this? struct ZydisDecodedOperandMemDisp_
{
/**
* The displacement value
*/
ZyanI64 value;
/**
* The size of the displacement value
*/
ZyanU8 size;
} disp; If the size is 0, then it means no displacement value and we get rid of the |
I would be ok with merging this. What do you think @athre0z? We have a bunch of interface breaking changes anyways. |
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.
This change should be mentioned in assets/porting-guide-v4-v5.md
.
When we are on it, we should as well change the comment slightly to make it clear that this field contains the physical displacement size. |
Hmm yeah, that seems like a decent idea. If we move the size into the operand, we should also move the offset field. I don't know how you'd reliably use the size without also having the offset. We should further apply the same change for immediate operands for consistency. Looking at struct ZydisDecodedOperandMemDisp_ {
ZyanBool has_displacement; /* 0 1 */
/* XXX 7 bytes hole, try to pack */
ZyanI64 value; /* 8 8 */
/* size: 16, cachelines: 1, members: 2 */
/* sum members: 9, holes: 1, sum holes: 7 */
/* last cacheline: 16 bytes */
}; my previous claim that adding a new field would increase struct size was in fact inaccurate: there are 7 padding bytes waiting to be put to use. In that sense moving the offset over as well is actually free. We could also keep |
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.
Thanks for updating the PR 🙂 I left some more comments.
LGTM from my side! Thanks 🙂 |
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.
Yes, I think this is a good change. For me personally those two fields are the only thing in the entire raw
portion that I ever use. Going forward we could consider moving raw
into the decoder context instead, or make outputting it optional: I suspect that barely anything aside from ZydisInfo
uses the other stuff. Either way, just thinking out loud here: that's a problem for another day. Thanks for the effort @NaC-L, LGTM!
LGTM! |
ZydisDecodedOperandMemDisp_
ZydisDecodedOperandMemDisp_
ZydisDecodedOperandMemDisp_
Access to size of displacement value from operand