zyantific / zydis

Fast and lightweight x86/x86-64 disassembler and code generation library
https://zydis.re
MIT License
3.47k stars 436 forks source link

Convert ZydisDecoder field decoder_mode to a bitmap. #435

Closed jpidancet closed 1 year ago

jpidancet commented 1 year ago

Make decoder_mode a bitmap instead of an array of booleans for space efficiency.

jpidancet commented 1 year ago

Hi,

Thank you for having a look. It looks like the || vs | mix-up was causing all the build and fuzzing errors. It is fixed now.

flobernd commented 1 year ago

@jpidancet Thanks for fixing! I will merge if @athre0z agrees as well.

@athre0z @th0rex fyi, this is a breaking change for the JS, Rust, etc. bindings 🙂

For v5 I would like to change the public API for this entirely (ZydisDecoderEnableMode(mode) -> ZydisDecoderSetModes(bitmask) and converting the ZYDIS_DECODER_MODE_X constants to bits), but for now it's probably better to keep the current API.

athre0z commented 1 year ago

For v5 I would like to change the public API for this entirely (ZydisDecoderEnableMode(mode) -> ZydisDecoderSetModes(bitmask) and converting the ZYDIS_DECODER_MODE_X constants to bits), but for now it's probably better to keep the current API.

We can do this in a non-breaking manner by just adding such a function without removing the old one. I think this would be preferable here since maintaining the old function is very little effort. We can mark the old function as deprecated and remove it in a few years, or just keep it around forever. Changing the constants is not API breaking, only ABI breaking, so can be done in a minor version.