More fuzzing progress

This commit is contained in:
momo5502
2024-09-24 18:35:34 +02:00
parent 7547fee251
commit a259072b27
14 changed files with 321 additions and 94 deletions

View File

@@ -36,6 +36,7 @@ struct basic_block
using edge_generation_hook_callback = std::function<void(const basic_block& current_block,
const basic_block& previous_block)>;
using basic_block_hook_callback = std::function<void(const basic_block& block)>;
using instruction_hook_callback = std::function<instruction_hook_continuation()>;
@@ -73,6 +74,7 @@ public:
virtual emulator_hook* hook_interrupt(interrupt_hook_callback callback) = 0;
virtual emulator_hook* hook_edge_generation(edge_generation_hook_callback callback) = 0;
virtual emulator_hook* hook_basic_block(basic_block_hook_callback callback) = 0;
virtual void delete_hook(emulator_hook* hook) = 0;

View File

@@ -5,6 +5,7 @@
#include <string_view>
#include <stdexcept>
#include <cstring>
#include <optional>
namespace utils
{
@@ -12,7 +13,7 @@ namespace utils
class buffer_deserializer;
template <typename T>
concept Serializable = requires(T a, const T ac, buffer_serializer & serializer, buffer_deserializer & deserializer)
concept Serializable = requires(T a, const T ac, buffer_serializer& serializer, buffer_deserializer& deserializer)
{
{ ac.serialize(serializer) } -> std::same_as<void>;
{ a.deserialize(deserializer) } -> std::same_as<void>;
@@ -100,7 +101,7 @@ namespace utils
this->offset_ += sizeof(old_size);
#endif
return result;
}
@@ -148,6 +149,19 @@ namespace utils
return object;
}
template <typename T>
void read_optional(std::optional<T>& val)
{
if (this->read<bool>())
{
val = this->read<T>();
}
else
{
val = {};
}
}
template <typename T>
void read_vector(std::vector<T>& result)
{
@@ -294,6 +308,17 @@ namespace utils
}
}
template <typename T>
void write_optional(const std::optional<T>& val)
{
this->write(val.has_value());
if (val.has_value())
{
this->write(*val);
}
}
template <typename T>
void write_span(const std::span<T> vec)
{