Skip to content
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

Hooking every hookable targets with independent wrapper fucntion. #95

Open
sindney opened this issue May 14, 2024 · 0 comments
Open

Hooking every hookable targets with independent wrapper fucntion. #95

sindney opened this issue May 14, 2024 · 0 comments

Comments

@sindney
Copy link

sindney commented May 14, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant