From 6111f2fad32d7b1094065caad087f49c376505a1 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 24 Dec 2024 09:23:38 +0100 Subject: [PATCH] Fix silencing --- src/windows-emulator/windows_emulator.cpp | 21 ++++++++++++--------- src/windows-emulator/windows_emulator.hpp | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index bdb64243..a2883bad 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -720,10 +720,10 @@ windows_emulator::windows_emulator(const emulator_settings& settings, std::unique_ptr emu) : windows_emulator(std::move(emu)) { - this->silent_until_main = settings.silent_until_main && !settings.disable_logging; + this->silent_until_main_ = settings.silent_until_main && !settings.disable_logging; this->stdout_callback_ = std::move(settings.stdout_callback); this->use_relative_time_ = settings.use_relative_time; - this->logger.disable_output(settings.disable_logging || this->silent_until_main); + this->logger.disable_output(settings.disable_logging || this->silent_until_main_); this->setup_process(settings); } @@ -884,6 +884,15 @@ void windows_emulator::setup_hooks() if (binary) { + const auto is_entry_point = address == binary->entry_point; + + if (this->silent_until_main_ && is_entry_point && binary == this->process_ + .executable) + { + this->silent_until_main_ = false; + this->logger.disable_output(false); + } + const auto export_entry = binary->address_names.find(address); if (export_entry != binary->address_names.end()) { @@ -892,14 +901,8 @@ void windows_emulator::setup_hooks() binary->name.c_str(), export_entry->second.c_str(), address); } - else if (address == binary->entry_point) + else if (is_entry_point) { - if (this->silent_until_main && binary == this->process_.executable) - { - this->silent_until_main = false; - this->logger.disable_output(true); - } - logger.print(is_interesting_call ? color::yellow : color::gray, "Executing entry point: %s (0x%llX)\n", binary->name.c_str(), diff --git a/src/windows-emulator/windows_emulator.hpp b/src/windows-emulator/windows_emulator.hpp index a62c47d5..ce82e0b0 100644 --- a/src/windows-emulator/windows_emulator.hpp +++ b/src/windows-emulator/windows_emulator.hpp @@ -103,7 +103,6 @@ public: bool buffer_stdout{false}; bool fuzzing{false}; bool switch_thread{false}; - bool silent_until_main{false}; void yield_thread(); void perform_thread_switch(); @@ -115,6 +114,7 @@ public: private: bool use_relative_time_{false}; + bool silent_until_main_{false}; std::unique_ptr emu_{}; std::vector syscall_hooks_{}; std::function stdout_callback_{};