-
-
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
undocumented/unintended ZYDIS_FORMATTER_FUNC_POST_OPERAND behavior #497
Comments
Yes, we should clarify that in the documentation. The proper way of omitting an operand here is to return ZYDIS_STATUS_SKIP_TOKEN. A failure status code immediately stops the complete formatting and causes that code to be propagated to the exported ZydisFormatter* APIs. |
What I find particularly disconcerting is that returning ZYAN_STATUS_SUCCESS causes the source operand to be dropped resulting in an invalid instruction being printed (missing the source operand.) When a function returns ZYAN_STATUS_SUCCESS, I expect a complete, valid, instruction not a mutilated one. Basically, ZYAN_STATUS_SUCCESS is behaving sort of as ZYDIS_STATUS_SKIP_TOKEN. I say "sort of" because I didn't test returning ZYDIS_STATUS_SKIP_TOKEN and comparing the results but, after tracing the execution, I believe it might be the same. |
Right. There is a ! missing for the post-operand condition check. |
The following question is strictly curiousity... I don't want it to be interpreted as being "unreasonable" or "pushy". I see this bug as a fairly simple bug with a fairly simple fix, though I could be wrong about that but, presuming it is a simple fix, what's the reasonable time frame to expect a bug of this kind to be fixed ? |
If you create a PR, we can fix it as soon as you are ready 🙂 Should be fixed by adding the missing "not" in front of the ZYAN_SUCCESS() call after the post-operand callback in ZydisFormatterIntel.c and ZydisFormatterATT.c Not sure if I have time to work on it myself over the weekend.. |
I'm not well versed in Zydis (but learning) nor github, If I were, I would gladly make the necessary changes and test them but, at this time, I am too afraid I'll mess something up due to general "lack of knowledge" (read: ignorance.) |
Hello,
Hooking the function for
ZYDIS_FORMATTER_FUNC_POST_OPERAND
does not seem to behave as documented. if the function returnsZYAN_STATUS_SUCCESS
then the source operand is dropped from the instruction (not output/printed). if the function returnsZYAN_STATUS_FAILED
then the source operand is printed.The above behavior does not seem consistent with the behavior documented for
ZydisFormatterFunc
.The above behavior can be obtained by making the following modifications to the "Formatter01" example.
(1.)
(2.)
(3.) add the following hook function
(4.) declare the variable to pass to the set hook function
ZydisFormatterFunc default_post_op;
The text was updated successfully, but these errors were encountered: