mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-28 15:31:02 +00:00
Log more interesting things if outside any mapped module
This commit is contained in:
@@ -468,23 +468,25 @@ void register_analysis_callbacks(analysis_context& c)
|
||||
watch_import_table(c);
|
||||
}
|
||||
|
||||
mapped_module* get_module_if_interesting(module_manager& manager, const string_set& modules, const uint64_t address)
|
||||
std::optional<mapped_module*> get_module_if_interesting(module_manager& manager, const string_set& modules,
|
||||
const uint64_t address)
|
||||
{
|
||||
if (manager.executable->is_within(address))
|
||||
{
|
||||
return manager.executable;
|
||||
}
|
||||
|
||||
if (modules.empty())
|
||||
auto* mod = manager.find_by_address(address);
|
||||
if (!mod)
|
||||
{
|
||||
// Not being part of any module is interesting
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* mod = manager.find_by_address(address);
|
||||
if (mod && modules.contains(mod->name))
|
||||
if (modules.contains(mod->name))
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -43,4 +43,5 @@ struct analysis_context
|
||||
};
|
||||
|
||||
void register_analysis_callbacks(analysis_context& c);
|
||||
mapped_module* get_module_if_interesting(module_manager& manager, const string_set& modules, uint64_t address);
|
||||
std::optional<mapped_module*> get_module_if_interesting(module_manager& manager, const string_set& modules,
|
||||
uint64_t address);
|
||||
|
||||
@@ -430,13 +430,13 @@ namespace
|
||||
|
||||
win_emu->emu().hook_instruction(x86_hookable_instructions::cpuid, [&] {
|
||||
const auto rip = win_emu->emu().read_instruction_pointer();
|
||||
auto* mod = get_module_if_interesting(win_emu->mod_manager, options.modules, rip);
|
||||
const auto mod = get_module_if_interesting(win_emu->mod_manager, options.modules, rip);
|
||||
|
||||
if (mod)
|
||||
if (mod.has_value())
|
||||
{
|
||||
const auto leaf = win_emu->emu().reg<uint32_t>(x86_register::eax);
|
||||
win_emu->log.print(color::blue, "Executing CPUID instruction with leaf 0x%X at 0x%" PRIx64 " (%s)\n",
|
||||
leaf, rip, mod->name.c_str());
|
||||
leaf, rip, (*mod) ? (*mod)->name.c_str() : "<N/A>");
|
||||
}
|
||||
|
||||
return instruction_hook_continuation::run_instruction;
|
||||
|
||||
Reference in New Issue
Block a user