Skip to content
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

Rust conditional compilation #1932

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 14 additions & 60 deletions bindings/rust/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,15 @@ pub type uc_hook = *mut c_void;
pub type uc_context = *mut c_void;

extern "C" {
pub fn uc_version(
major: *mut u32,
minor: *mut u32,
) -> u32;
pub fn uc_version(major: *mut u32, minor: *mut u32) -> u32;
pub fn uc_arch_supported(arch: Arch) -> bool;
pub fn uc_open(
arch: Arch,
mode: Mode,
engine: *mut uc_handle,
) -> uc_error;
pub fn uc_open(arch: Arch, mode: Mode, engine: *mut uc_handle) -> uc_error;
pub fn uc_close(engine: uc_handle) -> uc_error;
pub fn uc_context_free(mem: uc_context) -> uc_error;
pub fn uc_errno(engine: uc_handle) -> uc_error;
pub fn uc_strerror(error_code: uc_error) -> *const c_char;
pub fn uc_reg_write(
engine: uc_handle,
regid: c_int,
value: *const c_void,
) -> uc_error;
pub fn uc_reg_read(
engine: uc_handle,
regid: c_int,
value: *mut c_void,
) -> uc_error;
pub fn uc_reg_write(engine: uc_handle, regid: c_int, value: *const c_void) -> uc_error;
pub fn uc_reg_read(engine: uc_handle, regid: c_int, value: *mut c_void) -> uc_error;
pub fn uc_mem_write(
engine: uc_handle,
address: u64,
Expand All @@ -51,12 +36,7 @@ extern "C" {
bytes: *mut u8,
size: libc::size_t,
) -> uc_error;
pub fn uc_mem_map(
engine: uc_handle,
address: u64,
size: libc::size_t,
perms: u32,
) -> uc_error;
pub fn uc_mem_map(engine: uc_handle, address: u64, size: libc::size_t, perms: u32) -> uc_error;
pub fn uc_mem_map_ptr(
engine: uc_handle,
address: u64,
Expand All @@ -73,11 +53,7 @@ extern "C" {
write_cb: *mut c_void,
user_data_write: *mut c_void,
) -> uc_error;
pub fn uc_mem_unmap(
engine: uc_handle,
address: u64,
size: libc::size_t,
) -> uc_error;
pub fn uc_mem_unmap(engine: uc_handle, address: u64, size: libc::size_t) -> uc_error;
pub fn uc_mem_protect(
engine: uc_handle,
address: u64,
Expand Down Expand Up @@ -107,32 +83,12 @@ extern "C" {
end: u64,
...
) -> uc_error;
pub fn uc_hook_del(
engine: uc_handle,
hook: uc_hook,
) -> uc_error;
pub fn uc_query(
engine: uc_handle,
query_type: Query,
result: *mut libc::size_t,
) -> uc_error;
pub fn uc_context_alloc(
engine: uc_handle,
context: *mut uc_context,
) -> uc_error;
pub fn uc_context_save(
engine: uc_handle,
context: uc_context,
) -> uc_error;
pub fn uc_context_restore(
engine: uc_handle,
context: uc_context,
) -> uc_error;
pub fn uc_ctl(
engine: uc_handle,
control: u32,
...
) -> uc_error;
pub fn uc_hook_del(engine: uc_handle, hook: uc_hook) -> uc_error;
pub fn uc_query(engine: uc_handle, query_type: Query, result: *mut libc::size_t) -> uc_error;
pub fn uc_context_alloc(engine: uc_handle, context: *mut uc_context) -> uc_error;
pub fn uc_context_save(engine: uc_handle, context: uc_context) -> uc_error;
pub fn uc_context_restore(engine: uc_handle, context: uc_context) -> uc_error;
pub fn uc_ctl(engine: uc_handle, control: u32, ...) -> uc_error;
}

pub struct UcHook<'a, D: 'a, F: 'a> {
Expand Down Expand Up @@ -293,10 +249,8 @@ pub unsafe extern "C" fn insn_out_hook_proxy<D, F>(
(user_data.callback)(&mut user_data_uc, port, size, value);
}

pub unsafe extern "C" fn insn_sys_hook_proxy<D, F>(
uc: uc_handle,
user_data: *mut UcHook<D, F>,
) where
pub unsafe extern "C" fn insn_sys_hook_proxy<D, F>(uc: uc_handle, user_data: *mut UcHook<D, F>)
where
F: FnMut(&mut crate::Unicorn<D>),
{
let user_data = &mut *user_data;
Expand Down
Loading
Loading