Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This improvement implements storing hooks in the pluginex base class, so that almost all plugins no longer need to store hook objects (inherited from BaseHook) in their own containers.
Hooks were typically stored in plugin members in two ways:
std::unique_ptr<libhook::SyscallHook> some_func_hook;
)std::map<uint64_t, std::unique_ptr<libhook::ReturnHook>> ret_hooks
with the key calculated by themake_hook_id()
), which also breaks some plugins (Hooks on nested functions are broken #1712)Hooks are now by default saved in the
pluginex::hooks
map with a unique key (hook address), so there are additional methods to remove or register (i.e. take ownership of an existing hook previously created with thesave = false
flag) hook.So, the key changes:
pluginex
methods for creating hooks (egcreateReturnHook()
) now return raw pointers (instead of 'std::unique_ptr') and have abool save
flag (true
by default).std::unique_ptr
s in varoius plugins.*_ret_cb()
) using the backward reference inparams
(this->remove_hook(params->hook_);
).plugin->remove_hook()
) or just read the information via dereference.bool = false
flag, then it is responsible for storing/deleting the hook (usually in this case the raw pointer is instantly wrapped instd::unique_ptr
).Also made a small refactoring related to containers in different classes (
std::map
->std::unordered_map
,std::vector
->std::unordered_set
, etc.).