diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index e585876f..18fdba01 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -27,7 +27,7 @@ namespace win_emu.emu().hook_memory_write( win_emu.process().peb.value() + offsetof(PEB64, ProcessParameters), 0x8, - [&, cache_logging](const uint64_t address, size_t, const uint64_t value) { + [&win_emu, cache_logging, params_hook](const uint64_t address, size_t, const uint64_t value) mutable { const auto target_address = win_emu.process().peb.value() + offsetof(PEB64, ProcessParameters); if (address == target_address) diff --git a/src/windows-emulator/debugging/x64_gdb_stub_handler.hpp b/src/windows-emulator/debugging/x64_gdb_stub_handler.hpp index 66961d54..58e1a47b 100644 --- a/src/windows-emulator/debugging/x64_gdb_stub_handler.hpp +++ b/src/windows-emulator/debugging/x64_gdb_stub_handler.hpp @@ -2,6 +2,7 @@ #include #include "gdb_stub.hpp" #include "scoped_hook.hpp" +#include inline std::vector gdb_registers{ x64_register::rax, x64_register::rbx, x64_register::rcx, x64_register::rdx, x64_register::rsi, x64_register::rdi, @@ -153,12 +154,15 @@ class x64_gdb_stub_handler : public gdb_stub_handler { try { - this->hooks_[{addr, size, type}] = scoped_hook( - *this->emu_, this->emu_->hook_memory_access( - addr, size, map_breakpoint_type(type), - [this](uint64_t, size_t, uint64_t, memory_operation) { this->on_interrupt(); })); + return this->hooks_.access([&](hook_map& hooks) { + hooks[{addr, size, type}] = scoped_hook( + *this->emu_, this->emu_->hook_memory_access(addr, size, map_breakpoint_type(type), + [this](uint64_t, size_t, uint64_t, memory_operation) { + this->on_interrupt(); // + })); - return true; + return true; + }); } catch (...) { @@ -170,15 +174,17 @@ class x64_gdb_stub_handler : public gdb_stub_handler { try { - const auto entry = this->hooks_.find({addr, size, type}); - if (entry == this->hooks_.end()) - { - return false; - } + return this->hooks_.access([&](hook_map& hooks) { + const auto entry = hooks.find({addr, size, type}); + if (entry == hooks.end()) + { + return false; + } - this->hooks_.erase(entry); + hooks.erase(entry); - return true; + return true; + }); } catch (...) { @@ -193,5 +199,7 @@ class x64_gdb_stub_handler : public gdb_stub_handler private: x64_emulator* emu_{}; - std::unordered_map hooks_{}; + + using hook_map = std::unordered_map; + utils::concurrency::container hooks_{}; };