You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dynamic linking functions(dlopen, dlsym) in recent Android versions are restricted with caller address checked. This project can be used as a workaround by forging caller address.
The basic idea is to simply set dlopen/dlsym as JNI functions, which are actually called by trampoline code in libart.so and can be used to trick the linker.
In this way, neither /proc/self/maps file nor ELF parsing is needed, and hopefully symbol hash table could be utilized during resolution for faster symbol lookup.
Setup
The library is built with the new feature of Android Gradle Plugin for native code dependency, which would add prefab modules into the .aar file.
To use the library, first make sure that Android Gradle Plugin version 4.0+ is used. Then add the library as a dependency:
implementation 'io.github.rk700:dlfunc:0.1.1'
Put the following lines into the android block of the module's build.gradle file to enable prefab:
buildFeatures {
prefab true
}
In CMakeLists.txt file, add the following lines to expose the dlfunc library to native code:
find_package(dlfunc REQUIRED CONFIG)
target_link_libraries( # Specifies the target library.
app
# Links the dlfunc library to the target library.
dlfunc::dlfunc
)
Android NDK sample for prefab also provides an example for importing a prefab library.
Usage
First, include the header file dlfunc.h in the native code:
#include"dlfunc.h"
Then run the function dlfunc_init for initialization.