mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-22 05:03:56 +00:00
Prepare fuzzing engine
This commit is contained in:
38
src/fuzzing-engine/input_generator.hpp
Normal file
38
src/fuzzing-engine/input_generator.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
|
||||
#include "random_generator.hpp"
|
||||
|
||||
namespace fuzzer
|
||||
{
|
||||
using input_score = uint64_t;
|
||||
using input_handler = input_score(std::span<const uint8_t>);
|
||||
|
||||
struct input_entry
|
||||
{
|
||||
std::vector<uint8_t> data{};
|
||||
input_score score{};
|
||||
};
|
||||
|
||||
class input_generator
|
||||
{
|
||||
public:
|
||||
input_generator();
|
||||
|
||||
void access_input(const std::function<input_handler>& handler);
|
||||
|
||||
private:
|
||||
std::mutex mutex_{};
|
||||
random_generator rng{};
|
||||
|
||||
std::vector<input_entry> top_scorer_{};
|
||||
input_score lowest_score{0};
|
||||
|
||||
std::vector<uint8_t> generate_next_input();
|
||||
|
||||
void store_input_entry(input_entry entry);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user