windows crate

This commit is contained in:
Andrea Fioraldi 2021-02-16 10:47:15 +01:00
parent 6b936826a8
commit 97ad4e92f9
5 changed files with 27 additions and 8 deletions

View File

@ -86,7 +86,7 @@ fn fuzz(input: Option<Vec<PathBuf>>, broker_port: u16) -> Result<(), Error> {
println!("We're a client, let's fuzz :)");
let mut mutator = HavocBytesMutator::new_default();
let mut mutator = HavocBytesMutator::default();
mutator.set_max_size(4096);
let stage = StdMutationalStage::new(mutator);
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));

View File

@ -84,7 +84,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
__lafl_max_edges_size as usize
});
// If not retsrating, create a State from scratch
// If not restarting, create a State from scratch
let mut state = state.unwrap_or(State::new(
InMemoryCorpus::new(),
tuple_list!(MaxMapFeedback::new_with_observer(
@ -97,7 +97,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
println!("We're a client, let's fuzz :)");
// Create a PNG dictionary of not existing
// Create a PNG dictionary if not existing
if state.metadata().get::<TokensMetadata>().is_none() {
state.add_metadata(TokensMetadata::new(vec![
vec![137, 80, 78, 71, 13, 10, 26, 10], // PNG header
@ -109,7 +109,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
}
// Setup a basic mutator with a mutational stage
let mutator = HavocBytesMutator::new_default();
let mutator = HavocBytesMutator::default();
let stage = StdMutationalStage::new(mutator);
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));

View File

@ -3,6 +3,7 @@ name = "libafl"
version = "0.1.0"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -42,7 +43,6 @@ required-features = ["std"]
[dependencies]
tuple_list = "0.1.2"
hashbrown = { version = "0.9", features = ["serde", "ahash-compile-time-rng"] } # A faster hashmap, nostd compatible
libc = "0.2" # For (*nix) libc
num = "*"
xxhash-rust = { version = "0.8.0", features = ["xxh3"] } # xxh3 hashing for rust
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
@ -51,3 +51,12 @@ postcard = { version = "0.5.1", features = ["alloc"] } # no_std compatible serde
static_assertions = "1.1.0"
serde_json = { version = "1.0", default-features = false, features = ["alloc"] } # an easy way to debug print SerdeAnyMap
#TODO: for llmp brotli = { version = "3.3.0", default-features = false } # brotli compression
[target.'cfg(unix)'.dependencies]
libc = "0.2" # For (*nix) libc
[target.'cfg(windows)'.dependencies]
windows = "0.3.1"
[target.'cfg(windows)'.build-dependencies]
windows = "0.3.1"

10
libafl/build.rs Normal file
View File

@ -0,0 +1,10 @@
fn main() {
#[cfg(target_os = "windows")]
windows::build!(
// API needed for the shared memory
windows::win32::system_services::{CreateFileMappingA, MapViewOfFile, UnmapViewOfFile},
windows::win32::windows_programming::CloseHandle
);
}

View File

@ -1,5 +1,5 @@
use alloc::vec::Vec;
use core::{fmt, marker::PhantomData};
use core::{fmt, default::Default, marker::PhantomData};
use fmt::Debug;
use crate::{
@ -266,7 +266,7 @@ where
}
}
impl<C, I, R, S> HavocBytesMutator<StdScheduledMutator<C, I, R, S>, C, I, R, S>
impl<C, I, R, S> Default for HavocBytesMutator<StdScheduledMutator<C, I, R, S>, C, I, R, S>
where
C: Corpus<I, R>,
I: Input + HasBytesVec,
@ -274,7 +274,7 @@ where
S: HasCorpus<C, I, R> + HasMetadata,
{
/// Create a new HavocBytesMutator instance wrapping StdScheduledMutator
pub fn new_default() -> Self {
fn default() -> Self {
let mut scheduled = StdScheduledMutator::<C, I, R, S>::new();
scheduled.add_mutation(mutation_bitflip);
scheduled.add_mutation(mutation_byteflip);