-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
decoded instruction size is bigger than essential #554
Comments
It's better to copy off only the information you need into your own structure which gives you full control over what and how you store it. Also iced does not provide additional information such as regs write or read out of the box and has some extra API for this which is how its instruction structure is relatively small. |
Hello, thanks for the amazing project! [1] I believe it is reasonable to follow that structure in future versions of Zydis. It seems to be a better approach to have an external database or API structured this way - adhering to separation of responsibilities. [2] "It's better to copy off only the information you need into your own structure which gives you full control over what and how you store it" makes sense. [3] Improving this would be universally beneficial to all users, so I'd like to keep this thread open! Thanks! :D |
Hi @laie, You are right that we could remove all meta-data from the In the past, we already made some steps in this direction with the removal of In terms of low hanging fruits, there is really only the
You can chain these methods to decode only the instruction and all visible operands: Lines 278 to 280 in bffbb61
Lines 308 to 310 in bffbb61
Simply set |
Thanks! Didn't know I could decode visible operands only. Thank you for making this great library again! |
tried this thing for reference: [1] only using encoder-essential information
I could reduce the struct size to 200 bytes, which is quite significant improvement from 1128 bytes, but I think some architectural work is needed to make < 100 size struct. |
adding #pragma pack(push, 1) #pragma pack(pop) reduces it further down to 127 bytes which is pretty good |
Yes, there is definitely some room for improvement. The discussion about packed structs, bitfields etc. as well came up a few time already over the past years. We haven't yet made a decision here. The difficulty is with bindings for languages that do not support custom alignment. |
maybe one idea: ZydisDecoderDecodedInstructionToPackedVersion ps) maybe just use Packed version of the struct as main, and then provide non-packed version for compatibility and other lanauges |
[1] The fully decoded instruction byte count is reported 1128 bytes on my build environment
[2] This big decoded instruction size makes infeasible to fully decompile some real world EXE files into memory.,
For example, Unreal Engine 4 sample game has more than 10,000,000 instructions.
If we fully decode those with Zydis and store it in memory, we end up spending 11280000000 bytes, which is more than 11 GB.
[3] The decoded instruction structure can have some weight loses. It might be a low hanging fruit.
[4] Workaround
I was forced to discard decoded instructions, and then only keep Block Entry addresses
and whenever I need decoded instruction info, I re-decoded the block fully.
However this caused significant dev cost and performance losses.
[5] For reference:
Iced claims that they have 40 bytes of decoded instruction size https://github.com/icedland/iced/tree/master/src/rust/iced-x86
The text was updated successfully, but these errors were encountered: