Closed williballenthin closed 5 years ago
Of course, I can cast the mnemonic
field as an i32
; however, it seems like I shouldn't have to do this manually.
Yes, this is an artifact of the currently released version on crates.io
using bindgen and using a released zydis version. Zydis v2.0.3 (the latest release) used to typedef ZydisU16 ZydisMnemonic;
and then have a seperate enum ZydisMnemonics
with all the values (see here for more context). Thus bindgen also generates two different types for that.
On the current master branch, we've moved away from bindgen for various reasons, and also are tracking the zydis development branch, instead of a tagged release, so the problem you're having doesn't exist there anymore. I'm holding off a release on crates.io
until a new zydis version gets officially released. I think in the meantime your only option is to either life with the casts, or use these bindings from git directly (theres an example in the readme). There have been some breaking changes however, all enums are now properly scoped. ZYDIS_MNEMONIC_JMP
would turn into Mnemonic::JMP
, etc. As far as I remember all the other breaking changes should only involve the formatter, and especially only formatter hooks.
thanks for the explanation, @th0rex!
I think for the time being I'll cast things explicitly, but definitely intend to upgrade once the new release is out.
as a short updated, i've updated my project to use zydis-rs master, and things are much nicer here. it was easy to switch over, and the types are better. nice work!
I'd like to inspect the mnemonic of decoded instructions in order to find specific instructions. This is not as easy as I'd like because of a type mismatch between the mnemonic constants and the mnemonic field.
A
ZydisDecodedInstruction_
has a fieldmnemonic
with typeZydisMnemonic
:ZydisMnemonic
is an alias foru16
:The mnemonic constants exported have type
ZydisMnemonics
:And, unfortunately,
ZydisMnemonics
is an alias forc_uint
:This prevents me from directly comparing the mnemonic field of a decoded instruction to a constant exported by Zydis:
Would you consider changing the type of
ZydisMnemonic
orZydisMnemonics
so that they are the same?