You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thus, according to the key, only one hook per thread in a process can be stored at a time.
The scenario when this concept breaks the functionality is when in a plugin (with such a map) we hook 2 functions, one of which calls the other (let it be kernel32!LoadLibraryExW() -> ntdll!LdrLoadDll()).
The following happens:
The hook on kernel32!LoadLibraryExW() is triggered, the plugin creates a ret hook, placing it in the ret_hooks map.
The hook on ntdll!LdrLoadDll() is triggered, the plugin creates a ret hook, placing it in the ret_hooks map with the same key, so the previous ret hook is destroyed (since all traps in classes based on BaseHook destroyed in dtor), replacing it with a new ret hook.
The ret hook from ntdll!LdrLoadDll is triggered, the return value is captured and the entire event is printed.
The is no ret hook from kernel32!LoadLibraryExW (it was removed on step 2), so we lose the entire event.
In apimon, the bug appeared in e2e6c3a, but this is just one of the typical bugs caused by copy-paste.
The text was updated successfully, but these errors were encountered:
DRAKVUF has the same code concept, which, when copied from plugin to plugin, causes the same bug.
Some plugins, like apimon, use the map as a container to store hooks:
drakvuf/src/plugins/apimon/apimon.h
Line 145 in ec7af12
So the plugin also uses a function to generate a key for this map:
drakvuf/src/plugins/apimon/apimon.cpp
Lines 126 to 131 in ec7af12
Thus, according to the key, only one hook per thread in a process can be stored at a time.
The scenario when this concept breaks the functionality is when in a plugin (with such a map) we hook 2 functions, one of which calls the other (let it be
kernel32!LoadLibraryExW()
->ntdll!LdrLoadDll()
).The following happens:
kernel32!LoadLibraryExW()
is triggered, the plugin creates a ret hook, placing it in theret_hooks
map.ntdll!LdrLoadDll()
is triggered, the plugin creates a ret hook, placing it in theret_hooks
map with the same key, so the previous ret hook is destroyed (since all traps in classes based onBaseHook
destroyed in dtor), replacing it with a new ret hook.ntdll!LdrLoadDll
is triggered, the return value is captured and the entire event is printed.kernel32!LoadLibraryExW
(it was removed on step 2), so we lose the entire event.In apimon, the bug appeared in e2e6c3a, but this is just one of the typical bugs caused by copy-paste.
The text was updated successfully, but these errors were encountered: