Hi fellow rustaceans,
As my first real Rust project I have written bindings for the unicorn emulator (http://www.unicorn-engine.org/). You can find the project on https://github.com/ekse/unicorn-rs. It’s still a work in progress but it covers most of the features. There are build instructions in the README.md, I have tested only on Ubuntu Linux so far. I would be really glad if you have feedback on the code. The C API is fairly easy to understand by looking at https://github.com/unicorn-engine/unicorn/blob/master/include/unicorn/unicorn.h.
I would especially like your help on the following design limitation. I had to define
reg_write() as an i32 instead of a
Register type as I couldn’t find a way in Rust to have a generic type that would support the different types of registers (
RegisterMIPS). This is inconvenient as the registers have to be explicitly converted with as i32 when calling these functions. I tried using a
Register trait and impl it for the register types, but the compiler complains that Register is not
Sized. Does anyone know of a better way to do this?
I also had to do some transmute tomfoolery to support different callback signatures when calling
uc_hook_add(), as well as in
mem_regions() to deal with the pointer to an array of uc_mem_region. If some of this stuff is making you cringe please tell me so that I can improve it.
One of the things on my todo list is to check the value of hook_type in
add_mem_hook() to make sure it is valid in that context.
Thanks in advance,