-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search system DLLs for hooking via VADs (not via PEB) #1698
Conversation
Can one of the admins verify this patch? |
@drakvuf-jenkins Test this please |
@drakvuf-jenkins Test this please |
hook_dll(drakvuf, info, &ctx->mmvad.value(), &ctx->is_hooked); | ||
} | ||
|
||
bool get_module_mmvad(drakvuf_t drakvuf, addr_t eprocess, addr_t base_address, mmvad_info_t* mmvad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More clean would be use std::optional:
std::optional<mmvad_info_t> get_module_mmvad(drakvuf_t drakvuf, addr_t eprocess, addr_t base_address);
if (!mmvad->file_name_ptr) | ||
return false; | ||
|
||
if (drakvuf_mmvad_type(drakvuf, mmvad) != 2) // VAD_TYPE_DLL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the VAD_TYPE_DLL constant will eliminate the need to add comments
|
||
auto* vctx = (visitor_context_t*)callback_data; | ||
|
||
if (name.find(vctx->name) != std::string::npos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comparison is not perfect:
name = "msi.dllhack.dll"
vctx->name = "msi.dll"
and
name = "not_a_ntdll.dll"
vctx->name = "ntdll.dll"
would be true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open an issue for this to be tracked as the PR has been merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new code is logically identical to the old one:
if (name.find("ntdll.dll") != std::string::npos)
so the note is about the refactoring and not this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, an unreliable algorithm for searching for system DLLs through PEB has been implemented, for at least three reasons:
The patch implements traverse via VADs.
Also fixed a bug where, after a failed hook attempt, the process is still added to the cache (this is now controlled by the
is_hooked
flag).