plthook icon indicating copy to clipboard operation
plthook copied to clipboard

None of _start, _end and __INIT_ARRAY__ present in library

Open guy-adshir opened this issue 5 years ago • 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!

guy-adshir avatar Jan 20 '21 14:01 guy-adshir

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 ...
}

kubo avatar Jan 24 '21 13:01 kubo

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.

guy-adshir avatar Jan 24 '21 19:01 guy-adshir

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.

kubo avatar Jan 25 '21 05:01 kubo

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

Thank you so much for your help

guy-adshir avatar Jan 25 '21 08:01 guy-adshir

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.

kubo avatar Jan 25 '21 08:01 kubo

I'll try debugging it further, thanks :)

guy-adshir avatar Jan 25 '21 08:01 guy-adshir