From 6da3f27da6cd30f9061b501c3edb4b08766f76bc Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 3 Jan 2025 16:43:07 +0100 Subject: [PATCH] Fix .text logging --- src/analyzer/main.cpp | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index d6cdfb3e..d6d7e191 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -3,7 +3,7 @@ #include #include -//#define CONCISE_EMULATOR_OUTPUT +#define CONCISE_EMULATOR_OUTPUT #include "object_watching.hpp" @@ -124,39 +124,41 @@ namespace auto read_handler = [&, section](const uint64_t address, size_t, uint64_t) { const auto rip = win_emu.emu().read_instruction_pointer(); - if (rip >= section.region.start && rip < section.region.start + section. - region.length) + if (win_emu.process().module_manager.find_by_address(rip) != win_emu.process().executable) { + return; + } + #ifdef CONCISE_EMULATOR_OUTPUT - static uint64_t count{0}; - ++count; - if (count > 100 && count % 10000 != 0) return; + static uint64_t count{0}; + ++count; + if (count > 100 && count % 10000 != 0) return; #endif - win_emu.logger.print( - color::green, - "Reading from executable section %s: 0x%llX at 0x%llX\n", - section.name.c_str(), address, rip); - } + win_emu.logger.print( + color::green, + "Reading from executable section %s at 0x%llX via 0x%llX\n", + section.name.c_str(), address, rip); }; const auto write_handler = [&, section](const uint64_t address, size_t, uint64_t) { const auto rip = win_emu.emu().read_instruction_pointer(); - if (rip >= section.region.start && rip < section.region.start + section. - region.length) + if (win_emu.process().module_manager.find_by_address(rip) != win_emu.process().executable) { + return; + } + #ifdef CONCISE_EMULATOR_OUTPUT - static uint64_t count{0}; - ++count; - if (count > 100 && count % 10000 != 0) return; + static uint64_t count{0}; + ++count; + if (count > 100 && count % 10000 != 0) return; #endif - win_emu.logger.print( - color::cyan, - "Writing to executable section %s: 0x%llX at 0x%llX\n", - section.name.c_str(), address, rip); - } + win_emu.logger.print( + color::blue, + "Writing to executable section %s at 0x%llX via 0x%llX\n", + section.name.c_str(), address, rip); }; win_emu.emu().hook_memory_read(section.region.start, section.region.length, std::move(read_handler));