Skip to content

Hooking every hookable targets with independent wrapper fucntion. #95

Description

@sindney

Hi, i'm trying to use rebind_symbols_image to add hook for our game.
I'm adding mmap/munmap hooks to count overall memory usage, in order to gather the memory usage for every library\executable in the game process. For performance reasons, using a single global hook with frequent call to dladdr is unpractical:

Dl_info Dlinfo;
// Returns caller's return address.
void *Addr = __builtin_return_address(0);
// Determine which library the caller belongs.
if (dladdr(Addr, &Dlinfo))

So i need to provide independent hook(we uses marco tricks to pre-define wrappers) functions for every library/executables. I'm using _dyld_register_func_for_add_image to get noticed when new library is added, and then call fishhook's rebind_symbols_image in the callback to register it hooks.

When running, the actual memory usage data is small and the result seems didn't hook all libraries. The rebind_symbols_image return ok, i'm not sure using rebind_symbols_image in _dyld_register_func_for_add_image callback is a valide usage. I tried to delay the call with timer and it didn't work either. Any suggestions?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions