Skip to content

Commit cff94a4

Browse files
authored
Merge pull request #1932 from lockbox/rust-conditional-compilation
Rust conditional compilation
2 parents b4f2ac9 + c850db1 commit cff94a4

File tree

3 files changed

+364
-328
lines changed

3 files changed

+364
-328
lines changed

bindings/rust/src/ffi.rs

+14-60
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,15 @@ pub type uc_hook = *mut c_void;
1515
pub type uc_context = *mut c_void;
1616

1717
extern "C" {
18-
pub fn uc_version(
19-
major: *mut u32,
20-
minor: *mut u32,
21-
) -> u32;
18+
pub fn uc_version(major: *mut u32, minor: *mut u32) -> u32;
2219
pub fn uc_arch_supported(arch: Arch) -> bool;
23-
pub fn uc_open(
24-
arch: Arch,
25-
mode: Mode,
26-
engine: *mut uc_handle,
27-
) -> uc_error;
20+
pub fn uc_open(arch: Arch, mode: Mode, engine: *mut uc_handle) -> uc_error;
2821
pub fn uc_close(engine: uc_handle) -> uc_error;
2922
pub fn uc_context_free(mem: uc_context) -> uc_error;
3023
pub fn uc_errno(engine: uc_handle) -> uc_error;
3124
pub fn uc_strerror(error_code: uc_error) -> *const c_char;
32-
pub fn uc_reg_write(
33-
engine: uc_handle,
34-
regid: c_int,
35-
value: *const c_void,
36-
) -> uc_error;
37-
pub fn uc_reg_read(
38-
engine: uc_handle,
39-
regid: c_int,
40-
value: *mut c_void,
41-
) -> uc_error;
25+
pub fn uc_reg_write(engine: uc_handle, regid: c_int, value: *const c_void) -> uc_error;
26+
pub fn uc_reg_read(engine: uc_handle, regid: c_int, value: *mut c_void) -> uc_error;
4227
pub fn uc_mem_write(
4328
engine: uc_handle,
4429
address: u64,
@@ -51,12 +36,7 @@ extern "C" {
5136
bytes: *mut u8,
5237
size: libc::size_t,
5338
) -> uc_error;
54-
pub fn uc_mem_map(
55-
engine: uc_handle,
56-
address: u64,
57-
size: libc::size_t,
58-
perms: u32,
59-
) -> uc_error;
39+
pub fn uc_mem_map(engine: uc_handle, address: u64, size: libc::size_t, perms: u32) -> uc_error;
6040
pub fn uc_mem_map_ptr(
6141
engine: uc_handle,
6242
address: u64,
@@ -73,11 +53,7 @@ extern "C" {
7353
write_cb: *mut c_void,
7454
user_data_write: *mut c_void,
7555
) -> uc_error;
76-
pub fn uc_mem_unmap(
77-
engine: uc_handle,
78-
address: u64,
79-
size: libc::size_t,
80-
) -> uc_error;
56+
pub fn uc_mem_unmap(engine: uc_handle, address: u64, size: libc::size_t) -> uc_error;
8157
pub fn uc_mem_protect(
8258
engine: uc_handle,
8359
address: u64,
@@ -107,32 +83,12 @@ extern "C" {
10783
end: u64,
10884
...
10985
) -> uc_error;
110-
pub fn uc_hook_del(
111-
engine: uc_handle,
112-
hook: uc_hook,
113-
) -> uc_error;
114-
pub fn uc_query(
115-
engine: uc_handle,
116-
query_type: Query,
117-
result: *mut libc::size_t,
118-
) -> uc_error;
119-
pub fn uc_context_alloc(
120-
engine: uc_handle,
121-
context: *mut uc_context,
122-
) -> uc_error;
123-
pub fn uc_context_save(
124-
engine: uc_handle,
125-
context: uc_context,
126-
) -> uc_error;
127-
pub fn uc_context_restore(
128-
engine: uc_handle,
129-
context: uc_context,
130-
) -> uc_error;
131-
pub fn uc_ctl(
132-
engine: uc_handle,
133-
control: u32,
134-
...
135-
) -> uc_error;
86+
pub fn uc_hook_del(engine: uc_handle, hook: uc_hook) -> uc_error;
87+
pub fn uc_query(engine: uc_handle, query_type: Query, result: *mut libc::size_t) -> uc_error;
88+
pub fn uc_context_alloc(engine: uc_handle, context: *mut uc_context) -> uc_error;
89+
pub fn uc_context_save(engine: uc_handle, context: uc_context) -> uc_error;
90+
pub fn uc_context_restore(engine: uc_handle, context: uc_context) -> uc_error;
91+
pub fn uc_ctl(engine: uc_handle, control: u32, ...) -> uc_error;
13692
}
13793

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

296-
pub unsafe extern "C" fn insn_sys_hook_proxy<D, F>(
297-
uc: uc_handle,
298-
user_data: *mut UcHook<D, F>,
299-
) where
252+
pub unsafe extern "C" fn insn_sys_hook_proxy<D, F>(uc: uc_handle, user_data: *mut UcHook<D, F>)
253+
where
300254
F: FnMut(&mut crate::Unicorn<D>),
301255
{
302256
let user_data = &mut *user_data;

0 commit comments

Comments
 (0)