Skip to content

Commit

Permalink
去掉多余的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
WindySha committed May 26, 2021
1 parent 3f92896 commit 61ec8ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha14"
classpath 'com.android.tools.build:gradle:7.0.0-alpha15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 28 22:42:40 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
35 changes: 3 additions & 32 deletions lib/bypass_dlfcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@

#ifdef __LP64__
static const char *const kSystemLibDir = "/system/lib64/";
static const char *const kOdmLibDir = "/odm/lib64/";
static const char *const kVendorLibDir = "/vendor/lib64/";
static const char *const kApexLibDir = "/apex/com.android.runtime/lib64/";
static const char *const kApexArtNsLibDir = "/apex/com.android.art/lib64/";
#else
static const char *const kSystemLibDir = "/system/lib/";
static const char *const kOdmLibDir = "/odm/lib/";
static const char *const kVendorLibDir = "/vendor/lib/";
static const char *const kApexLibDir = "/apex/com.android.runtime/lib/";
static const char *const kApexArtNsLibDir = "/apex/com.android.art/lib/";
#endif
Expand Down Expand Up @@ -99,38 +95,13 @@ static void *get_trampoline_address() {
return trampoline_address_from_system_lib;
}

static inline void *bp_dlopen_with_fullpath(const char *filename, int flag) {
void *JNIEXPORT bp_dlopen(const char *filename, int flag) {
if (get_android_api_level() < ANDROID_N) {
return dlopen(filename, flag);
}
return dlopen(filename, flag);
}
return dlfcn_trampoline(filename, (void *) flag, get_trampoline_address(), dlopen);
}

void *JNIEXPORT bp_dlopen(const char *filename, int flag) {
void *handle = NULL;
if (strlen(filename) > 0 && filename[0] == '/') {
handle = bp_dlopen_with_fullpath(filename, flag);
}
if (handle)
return handle;

const char *file_path_prefix[] =
{kApexArtNsLibDir, kApexLibDir, kSystemLibDir, kVendorLibDir, kOdmLibDir};
int size = 5;
char full_name[512] = {0};

for (int i = 0; i < size; i++) {
const char *prefix = file_path_prefix[i];
memset(full_name, 0, sizeof(full_name));
sprintf(full_name, "%s%s", prefix, filename);

handle = bp_dlopen_with_fullpath(full_name, flag);
if (handle)
return handle;
}
return NULL;
}

int JNIEXPORT bp_dlclose(void *handle) {
if (get_android_api_level() < ANDROID_N) {
return dlclose(handle);
Expand Down

0 comments on commit 61ec8ac

Please sign in to comment.