maat::event::EventManager class

The event manager holds all hooks that have been set in the engine. It allows to add/remove/enable/disable hooks. It also serves as an interface to check whether hooks should be triggered or not given the current executed instruction.

❱   Public types

using hook_t = std::shared_ptr<EventHook>
Shared pointer to a hook object. We use shared pointers to prevent users to delete pending hooks in their callbacks, which would result in having pending hooks that have been destroyed in memory. By using shared_ptr we ensure that even if a hook is destroyed by the user it will be accessible by callbacks until automatic hook processing is complete.

❱   Constructors, destructors, conversion operators

EventManager()
Default constructor.

❱   Public functions

auto get_by_name(const std::string& name) -> hook_t
Return the hook with name name, or nullptr if the hook doesn't exist.

auto get_by_id(int id) -> hook_t
Return the hook with ID id, or nullptr if the hook doesn't exist.

auto get_all() -> const std::list<hook_t>&
Get all hooks.

void add(event::Event event, event::When when, std::string name = "", AddrFilter filter = AddrFilter(), std::string group = "")
Hook an event without callbacks.

void add(event::Event event, event::When when, EventCallback callback, std::string name = "", AddrFilter filter = AddrFilter(), std::string group = "")
Add an event hook with a single callback.

void add(event::Event event, event::When when, const std::vector<EventCallback>& callbacks, std::string name = "", AddrFilter filter = AddrFilter(), std::string group = "")
Add an event hook with multiple callbacks.

void disable(std::string name)
Disable a hook by name.

void disable_group(std::string group)
Disable all hooks in 'group'.

void disable(int id)
Disable a hook by ID.

void disable_all()
Disable all hooks.

void enable(std::string name)
Enable a hook by name.

void enable_group(std::string group)
Enable all hooks in 'group'.

void enable(int id)
Enable hook by ID.

❱   Protected variables

std::list<hook_t> all_hooks
A list of all hooks.

❱   Friends

auto operator<<(std::ostream& os, const EventManager& manager) -> std::ostream&
Pretty print hooks.

❱   Function documentation

void maat::event::EventManager::add(event::Event event, event::When when, std::string name = "", AddrFilter filter = AddrFilter(), std::string group = "")

Hook an event without callbacks.

Parameters
event Event to monitor
when When to trigger the hook
name hook unique name (optional)
filter Address filter (optional)
group hook group (optional)

void maat::event::EventManager::add(event::Event event, event::When when, EventCallback callback, std::string name = "", AddrFilter filter = AddrFilter(), std::string group = "")

Add an event hook with a single callback.

Parameters
event Event to monitor
when When to trigger the hook
callback Callback to execute when the hook is triggered
name hook unique name (optional)
filter Address filter (optional)
group hook group (optional)

void maat::event::EventManager::add(event::Event event, event::When when, const std::vector<EventCallback>& callbacks, std::string name = "", AddrFilter filter = AddrFilter(), std::string group = "")

Add an event hook with multiple callbacks.

Parameters
event Event to monitor
when Indicates whether to trigger the hook before of after the event
callbacks List of callbacks to execute when the hook is triggered
name hook unique name (optional)
filter Address filter (optional)
group hook group (optional)