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

None of _start, _end and __INIT_ARRAY__ present in library #30

Open
guy-adshir opened this issue Jan 20, 2021 · 6 comments
Open

None of _start, _end and __INIT_ARRAY__ present in library #30

guy-adshir opened this issue Jan 20, 2021 · 6 comments

Comments

@guy-adshir
Copy link

Hi
I'm trying to hook GLES calls on Android 10 for a Unity apk, but calling library (libunity.so) exports none of the 3 required symbols.
The rest of the libraries in the apk all export _end.
Any ideas? Thanks!

@kubo
Copy link
Owner

kubo commented Jan 24, 2021

Does the library libunity.so export some symbols? If so, could you use plthook_open_by_address()?

#include <dlfcn.h>
#include <plthook.h>

plthook_t *plthook;

// The following code is same with what plthook_open does on Android except symbol names.
void *handle = dlopen("libunity.so", RTLD_LAZY | RTLD_NOLOAD);
if (handle == NULL) {
    ... error ...
}
void *addr = dlsym(handle, "any_symbol_name_exported_by_libunity_so");
if (addr != NULL) {
    ... error ...
}
int rv = plthook_open_by_address(&plthook, addr);
if (rv != 0) {
    ... error ...
}

@guy-adshir
Copy link
Author

Thank you.
'plthook_open_by_address' succeeds, but then 'plthook_replace' fails, with the error:
"no such function: glBindBuffer"

So just to be sure I'm on the right page here: I should be calling dlopen/dlsym/plthook_replace on the library where the CALL I want to hook is located, not the library that holds the implememntation of the function (in my case, glBindBuffer).
Also, do I need to wait until the PLT entry for glBindBuffer for libunity.so is resolved?

Thanks again.

@kubo
Copy link
Owner

kubo commented Jan 25, 2021

Also, do I need to wait until the PLT entry for glBindBuffer for libunity.so is resolved?

It depends on whether you use the fourth argument of plthook_replace.
I recommend that you don't. See Usage.

@guy-adshir
Copy link
Author

Thanks. I did not use the fourth parameter.
Are my assumptions above correct?

Thank you so much for your help

@kubo
Copy link
Owner

kubo commented Jan 25, 2021

Are my assumptions above correct?

No. If your code don't use the parameter, it doesn't depend on whether the PLT entry is resolved or not.

@guy-adshir
Copy link
Author

I'll try debugging it further, thanks :)

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

2 participants