diff --git a/src/analyzer/analysis.cpp b/src/analyzer/analysis.cpp index 0e2b8f33..eb9ecc06 100644 --- a/src/analyzer/analysis.cpp +++ b/src/analyzer/analysis.cpp @@ -63,6 +63,17 @@ namespace debugger::handle_events(ec); #endif } + + void handle_module_load(const analysis_context& c, const mapped_module& mod) + { + c.win_emu->log.log("Mapped %s at 0x%" PRIx64 "\n", mod.path.generic_string().c_str(), mod.image_base); + } + + void handle_module_unload(const analysis_context& c, const mapped_module& mod) + { + c.win_emu->log.log("Unmapping %s (0x%" PRIx64 ")\n", mod.path.generic_string().c_str(), mod.image_base); + } + void handle_instruction(analysis_context& c, const uint64_t address) { auto& win_emu = *c.win_emu; @@ -200,6 +211,8 @@ void register_analysis_callbacks(analysis_context& c) cb.on_stdout = make_callback(c, handle_stdout); cb.on_syscall = make_callback(c, handle_syscall); cb.on_ioctrl = make_callback(c, handle_ioctrl); + cb.on_module_load = make_callback(c, handle_module_load); + cb.on_module_unload = make_callback(c, handle_module_unload); cb.on_instruction = make_callback(c, handle_instruction); cb.on_thread_switch = make_callback(c, handle_thread_switch); cb.on_generic_access = make_callback(c, handle_generic_access); diff --git a/src/windows-emulator/module/module_manager.cpp b/src/windows-emulator/module/module_manager.cpp index bd5428ed..00eb45ab 100644 --- a/src/windows-emulator/module/module_manager.cpp +++ b/src/windows-emulator/module/module_manager.cpp @@ -122,8 +122,6 @@ mapped_module* module_manager::map_local_module(const std::filesystem::path& fil auto mod = map_module_from_file(*this->memory_, std::move(local_file)); mod.is_static = is_static; - logger.log("Mapped %s at 0x%" PRIx64 "\n", mod.path.generic_string().c_str(), mod.image_base); - const auto image_base = mod.image_base; const auto entry = this->modules_.try_emplace(image_base, std::move(mod)); this->callbacks_->on_module_load(entry.first->second); @@ -163,7 +161,7 @@ void module_manager::deserialize(utils::buffer_deserializer& buffer) this->win32u = win32u_base ? this->find_by_address(win32u_base) : nullptr; } -bool module_manager::unmap(const uint64_t address, const logger& logger) +bool module_manager::unmap(const uint64_t address) { const auto mod = this->modules_.find(address); if (mod == this->modules_.end()) @@ -176,8 +174,6 @@ bool module_manager::unmap(const uint64_t address, const logger& logger) return true; } - logger.log("Unmapping %s (0x%" PRIx64 ")\n", mod->second.path.generic_string().c_str(), mod->second.image_base); - this->callbacks_->on_module_unload(mod->second); unmap_module(*this->memory_, mod->second); this->modules_.erase(mod); diff --git a/src/windows-emulator/module/module_manager.hpp b/src/windows-emulator/module/module_manager.hpp index 7a789d9d..4123f733 100644 --- a/src/windows-emulator/module/module_manager.hpp +++ b/src/windows-emulator/module/module_manager.hpp @@ -51,7 +51,7 @@ class module_manager void serialize(utils::buffer_serializer& buffer) const; void deserialize(utils::buffer_deserializer& buffer); - bool unmap(uint64_t address, const logger& logger); + bool unmap(uint64_t address); const module_map& modules() const { return modules_; diff --git a/src/windows-emulator/syscalls/section.cpp b/src/windows-emulator/syscalls/section.cpp index 47ba9633..753db3c6 100644 --- a/src/windows-emulator/syscalls/section.cpp +++ b/src/windows-emulator/syscalls/section.cpp @@ -287,7 +287,7 @@ namespace syscalls const auto* mod = c.win_emu.mod_manager.find_by_address(base_address); if (mod != nullptr) { - if (c.win_emu.mod_manager.unmap(base_address, c.win_emu.log)) + if (c.win_emu.mod_manager.unmap(base_address)) { return STATUS_SUCCESS; }