diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2022-01-27 09:00:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 09:00:57 +0100 |
commit | b2465a05ebc9a363290ea243b471b5ecb90dd6e1 (patch) | |
tree | 2001b9dbbf3bfb08bc0f81a10b02a4d7c22f02a9 /custom_mutators/rust/custom_mutator | |
parent | f75535807a19cb7b3696fc0a701b97e994184502 (diff) | |
parent | aa5f59b50196360e4d68178064120100c8ece4dd (diff) | |
download | afl++-b2465a05ebc9a363290ea243b471b5ecb90dd6e1.tar.gz |
Merge pull request #1311 from AFLplusplus/libafl_mutator
LibAFL basic (just havoc + tokens) custom mutator
Diffstat (limited to 'custom_mutators/rust/custom_mutator')
-rw-r--r-- | custom_mutators/rust/custom_mutator/src/lib.rs | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/custom_mutators/rust/custom_mutator/src/lib.rs b/custom_mutators/rust/custom_mutator/src/lib.rs index 013d3769..f872241e 100644 --- a/custom_mutators/rust/custom_mutator/src/lib.rs +++ b/custom_mutators/rust/custom_mutator/src/lib.rs @@ -358,6 +358,36 @@ pub mod wrappers { } } +/// An exported macro to defined afl_custom_init meant for insternal usage +#[cfg(feature = "afl_internals")] +#[macro_export] +macro_rules! _define_afl_custom_init { + ($mutator_type:ty) => { + #[no_mangle] + pub extern "C" fn afl_custom_init( + afl: ::std::option::Option<&'static $crate::afl_state>, + seed: ::std::os::raw::c_uint, + ) -> *const ::std::os::raw::c_void { + $crate::wrappers::afl_custom_init_::<$mutator_type>(afl, seed as u32) + } + }; +} + +/// An exported macro to defined afl_custom_init meant for insternal usage +#[cfg(not(feature = "afl_internals"))] +#[macro_export] +macro_rules! _define_afl_custom_init { + ($mutator_type:ty) => { + #[no_mangle] + pub extern "C" fn afl_custom_init( + _afl: *const ::std::os::raw::c_void, + seed: ::std::os::raw::c_uint, + ) -> *const ::std::os::raw::c_void { + $crate::wrappers::afl_custom_init_::<$mutator_type>(seed as u32) + } + }; +} + /// exports the given Mutator as a custom mutator as the C interface that AFL++ expects. /// It is not possible to call this macro multiple times, because it would define the custom mutator symbols multiple times. /// # Example @@ -381,23 +411,7 @@ pub mod wrappers { #[macro_export] macro_rules! export_mutator { ($mutator_type:ty) => { - #[cfg(feature = "afl_internals")] - #[no_mangle] - pub extern "C" fn afl_custom_init( - afl: ::std::option::Option<&'static $crate::afl_state>, - seed: ::std::os::raw::c_uint, - ) -> *const ::std::os::raw::c_void { - $crate::wrappers::afl_custom_init_::<$mutator_type>(afl, seed as u32) - } - - #[cfg(not(feature = "afl_internals"))] - #[no_mangle] - pub extern "C" fn afl_custom_init( - _afl: *const ::std::os::raw::c_void, - seed: ::std::os::raw::c_uint, - ) -> *const ::std::os::raw::c_void { - $crate::wrappers::afl_custom_init_::<$mutator_type>(seed as u32) - } + $crate::_define_afl_custom_init!($mutator_type); #[no_mangle] pub unsafe extern "C" fn afl_custom_fuzz_count( |