aboutsummaryrefslogtreecommitdiff
path: root/custom_mutators/rust
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2022-01-30 20:59:24 +0100
committerGitHub <noreply@github.com>2022-01-30 20:59:24 +0100
commit2d9325aed9bde0630162a5efaac33a2a8f5bb252 (patch)
treebbb0cf0f8620b71d315dcc449018affd3ea5b33a /custom_mutators/rust
parent143c9d175e9357ba548413ee7dcee6a8de23f733 (diff)
parent53eb5ba2fbfa75e1c008239bf5d54238bfadb148 (diff)
downloadafl++-2d9325aed9bde0630162a5efaac33a2a8f5bb252.tar.gz
Merge pull request #1319 from AFLplusplus/dev
push to stable
Diffstat (limited to 'custom_mutators/rust')
-rw-r--r--custom_mutators/rust/custom_mutator/src/lib.rs48
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(