iximeow / yaxpeax-x86

x86 decoders for the yaxpeax project
BSD Zero Clause License
129 stars 23 forks source link

FFI examples directory is missing #33

Open gsuberland opened 6 months ago

gsuberland commented 6 months ago

The readme says "see the examples directory for FFI usage of this library", but there isn't an examples directory in this repo.

(also hi)

iximeow commented 6 months ago

.... huh. where did that go. i'll... fix that.

(hi)

iximeow commented 2 months ago

well, part of the problem here is that the FFI bindings for yaxpeax-x86 are kinda useless and awful, which i think i realized when i tried writing an example before, but never got to fixing up.

yaxpeax_x86_64_fmt needs to return the number of characters it wrote to the string, especially because it never makes sure that the string is actually null terminated. it needs to make sure the string is null terminated.

yaxpeax_x86_64_decode takes a *mut long_mode::Instruction but there's no way to initialize one in a way that is stable across library versions.

half of this file is #[cfg(feature = "fmt")], but i'm not really sure feature flags on this .so make sense for some C program that may not know what features were enabled - there probably should be stub implementations if !fmt even if there are ifdefs around the declarations in a header

speaking of which, there are no header files. i think i'd assumed years ago that you can Just Bindgen It but that's not... ideal either.

i'm about 90% sure i'd called these functions by hand from a python repl just to see that yes it does work, but this is really not good enough to point anyone at 😅