From 30363cc760f848b71de450d1b0a64f26e742ddac Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 25 May 2025 17:56:50 +0200 Subject: [PATCH] Reimplement snapshot support --- src/fuzzer/main.cpp | 2 +- src/windows-emulator/windows_emulator.cpp | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/fuzzer/main.cpp b/src/fuzzer/main.cpp index 9623f7e9..5d088e56 100644 --- a/src/fuzzer/main.cpp +++ b/src/fuzzer/main.cpp @@ -75,7 +75,7 @@ namespace emu.restore_snapshot(); } - fuzzer::execution_result execute(std::span data, + fuzzer::execution_result execute(const std::span data, const std::function& coverage_handler) override { // printf("Input size: %zd\n", data.size()); diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 8b4b3181..fc2458a8 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -696,11 +696,9 @@ void windows_emulator::deserialize(utils::buffer_deserializer& buffer) this->dispatcher.deserialize(buffer); } -// NOLINTNEXTLINE(readability-convert-member-functions-to-static) void windows_emulator::save_snapshot() { - throw std::runtime_error("Not supported"); - /*utils::buffer_serializer serializer{}; + utils::buffer_serializer serializer{}; this->emu().serialize_state(serializer, true); this->memory.serialize_memory_state(serializer, true); this->mod_manager.serialize(serializer); @@ -709,14 +707,12 @@ void windows_emulator::save_snapshot() this->process_snapshot_ = serializer.move_buffer(); // TODO: Make process copyable - // this->process_snapshot_ = this->process;*/ + // this->process_snapshot_ = this->process; } -// NOLINTNEXTLINE(readability-convert-member-functions-to-static) void windows_emulator::restore_snapshot() { - throw std::runtime_error("Not supported"); - /*if (this->process_snapshot_.empty()) + if (this->process_snapshot_.empty()) { assert(false); return; @@ -727,5 +723,5 @@ void windows_emulator::restore_snapshot() this->memory.deserialize_memory_state(deserializer, true); this->mod_manager.deserialize(deserializer); this->process.deserialize(deserializer); - // this->process = *this->process_snapshot_;*/ + // this->process = *this->process_snapshot_; }