None of _start, _end and __INIT_ARRAY__ present in library
guy-adshir opened this issue · 6 comments
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!
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 ...
}
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.
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.
Thanks. I did not use the fourth parameter.
Are my assumptions above correct?
Thank you so much for your help
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.
I'll try debugging it further, thanks :)