Only call default hook if neither entry nor exit hook is given for syscall
This commit is contained in:
parent
58bf9c77da
commit
72caec00d6
@ -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;
|
||||
|
||||
const HookPair& hooks = m_hooks.at(syscall);
|
||||
if (!hooks.entry)
|
||||
return false;
|
||||
|
||||
hooks.entry();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Environment::exit_hook(reg_t syscall) const {
|
||||
if (!m_hooks.contains(syscall))
|
||||
return false;
|
||||
|
||||
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;
|
||||
|
||||
void Environment::entry_hook(reg_t syscall) const {
|
||||
if (!m_hooks.contains(syscall)) {
|
||||
if (m_default_hooks.entry)
|
||||
m_default_hooks.entry();
|
||||
return true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool Environment::default_exit_hook() const {
|
||||
if (!m_default_hooks.exit)
|
||||
return false;
|
||||
const HookPair& hooks = m_hooks.at(syscall);
|
||||
if (hooks.entry)
|
||||
hooks.entry();
|
||||
}
|
||||
|
||||
void Environment::exit_hook(reg_t syscall) const {
|
||||
if (!m_hooks.contains(syscall)) {
|
||||
if (m_default_hooks.exit)
|
||||
m_default_hooks.exit();
|
||||
return true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const HookPair& hooks = m_hooks.at(syscall);
|
||||
if (hooks.exit)
|
||||
hooks.exit();
|
||||
}
|
||||
|
||||
TraceContextCollection& Environment::contexts() {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user