Skip to content

Commit

Permalink
fix win build (AFLplusplus#2321)
Browse files Browse the repository at this point in the history
Co-authored-by: Your Name <[email protected]>
  • Loading branch information
tokatoka and Your Name authored Jun 17, 2024
1 parent 7792d87 commit a4070de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion utils/desyscall/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::env;

fn main() {
if cfg!(not(target_os = "linux")) {
println!("Not supported!");
println!("cargo:warning=Not supported!");
return;
}

Expand Down
12 changes: 12 additions & 0 deletions utils/desyscall/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
#[cfg(target_os = "linux")]
use std::{mem::MaybeUninit, sync::Once};

#[cfg(target_os = "linux")]
use libc::{c_int, c_void};
#[cfg(target_os = "linux")]
use meminterval::IntervalTree;

#[cfg(target_os = "linux")]
pub mod file;
#[cfg(target_os = "linux")]
pub mod mmap;

#[cfg(target_os = "linux")]
pub type Pointer = *mut c_void;

#[cfg(target_os = "linux")]
#[derive(Debug, Clone)]
pub struct Mapping {
prot: c_int,
flags: c_int,
mapped: bool,
}

#[cfg(target_os = "linux")]
pub struct Context {
enabled: bool,
mappings: IntervalTree<Pointer, Mapping>,
exit_hook: Option<Box<dyn FnMut(i32)>>,
}

#[cfg(target_os = "linux")]
impl Default for Context {
fn default() -> Self {
Self::new()
}
}

#[cfg(target_os = "linux")]
impl Context {
#[must_use]
pub fn new() -> Self {
Expand Down Expand Up @@ -76,6 +86,7 @@ impl Context {
}
}

#[cfg(target_os = "linux")]
extern "C" {
fn __libafl_raw_exit_group(status: c_int);
}
Expand All @@ -84,6 +95,7 @@ extern "C" {
/// # Safety
/// Call to function using syscalls
#[no_mangle]
#[cfg(target_os = "linux")]
pub unsafe extern "C" fn _exit(status: c_int) {
let ctx = Context::get();

Expand Down

0 comments on commit a4070de

Please sign in to comment.