diff --git a/src/environment.cpp b/src/environment.cpp index f9c646e..338aaf3 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -117,44 +117,30 @@ void Environment::register_default_hooks(hook_t entry, hook_t exit) { m_default_hooks.exit = exit; } -bool Environment::entry_hook(reg_t syscall) const { - if (!m_hooks.contains(syscall)) - return false; +void Environment::entry_hook(reg_t syscall) const { + if (!m_hooks.contains(syscall)) { + if (m_default_hooks.entry) + m_default_hooks.entry(); + + return; + } const HookPair& hooks = m_hooks.at(syscall); - if (!hooks.entry) - return false; - - hooks.entry(); - return true; + if (hooks.entry) + hooks.entry(); } -bool Environment::exit_hook(reg_t syscall) const { - if (!m_hooks.contains(syscall)) - return false; +void Environment::exit_hook(reg_t syscall) const { + if (!m_hooks.contains(syscall)) { + if (m_default_hooks.exit) + m_default_hooks.exit(); + + return; + } const HookPair& hooks = m_hooks.at(syscall); - if (!hooks.exit) - return false; - - hooks.exit(); - return true; -} - -bool Environment::default_entry_hook() const { - if (!m_default_hooks.entry) - return false; - - m_default_hooks.entry(); - return true; -} - -bool Environment::default_exit_hook() const { - if (!m_default_hooks.exit) - return false; - - m_default_hooks.exit(); - return true; + if (hooks.exit) + hooks.exit(); } TraceContextCollection& Environment::contexts() { diff --git a/src/environment.hpp b/src/environment.hpp index 0f91f73..f524a09 100644 --- a/src/environment.hpp +++ b/src/environment.hpp @@ -61,10 +61,8 @@ public: void register_hooks(reg_t syscall, hook_t entry, hook_t exit); void register_default_hooks(hook_t entry, hook_t exit); - bool entry_hook(reg_t syscall) const; - bool exit_hook(reg_t syscall) const; - bool default_entry_hook() const; - bool default_exit_hook() const; + void entry_hook(reg_t syscall) const; + void exit_hook(reg_t syscall) const; TraceContextCollection& contexts(); const TraceContextCollection& contexts() const; diff --git a/src/execution.cpp b/src/execution.cpp index 4a6a5f8..947f45e 100644 --- a/src/execution.cpp +++ b/src/execution.cpp @@ -166,9 +166,9 @@ bool rewire_run(int argc, const char* const* argv) { reg_t syscall = ctx->regs.orig_rax; if (ctx->mode == TraceContext::EXECUTION_MODE::USER) - ENV.entry_hook(syscall) || ENV.default_entry_hook(); // Short-circuit guaranteed by C++ standard ;) + ENV.entry_hook(syscall); else if (ctx->mode == TraceContext::EXECUTION_MODE::KERNEL) - ENV.exit_hook(syscall) || ENV.default_exit_hook(); + ENV.exit_hook(syscall); if (ctx->regs_dirty) { if (ptrace(PTRACE_SETREGS, pid, NULL, &ctx->regs) != 0)