Commit a9597adf authored by swift_gan's avatar swift_gan

fix fake dlopen on Android Q

parent e287e044
...@@ -92,8 +92,13 @@ void *fake_dlopen_with_path(const char *libpath, int flags) { ...@@ -92,8 +92,13 @@ void *fake_dlopen_with_path(const char *libpath, int flags) {
maps = fopen("/proc/self/maps", "r"); maps = fopen("/proc/self/maps", "r");
if (!maps) fatal("failed to open maps"); if (!maps) fatal("failed to open maps");
while (!found && fgets(buff, sizeof(buff), maps)) while (fgets(buff, sizeof(buff), maps)) {
if (strstr(buff, "r-xp") && strstr(buff, libpath)) found = 1; if ((strstr(buff, "r-xp") || strstr(buff, "r--p")) && strstr(buff, libpath)) {
found = 1;
__android_log_print(ANDROID_LOG_DEBUG, "dlopen", "%s\n", buff);
break;
}
}
fclose(maps); fclose(maps);
......
...@@ -124,8 +124,18 @@ void *ElfImg::getModuleBase(const char *name) { ...@@ -124,8 +124,18 @@ void *ElfImg::getModuleBase(const char *name) {
off_t load_addr; off_t load_addr;
int found = 0; int found = 0;
maps = fopen("/proc/self/maps", "r"); maps = fopen("/proc/self/maps", "r");
while (!found && fgets(buff, sizeof(buff), maps)) while (fgets(buff, sizeof(buff), maps)) {
if (strstr(buff, "r-xp") && strstr(buff, name)) found = 1; if ((strstr(buff, "r-xp") || strstr(buff, "r--p")) && strstr(buff, name)) {
found = 1;
__android_log_print(ANDROID_LOG_DEBUG, "dlopen", "%s\n", buff);
break;
}
}
if (!found) {
LOGE("failed to read load address for %s", name);
return nullptr;
}
if (sscanf(buff, "%lx", &load_addr) != 1) if (sscanf(buff, "%lx", &load_addr) != 1)
LOGE("failed to read load address for %s", name); LOGE("failed to read load address for %s", name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment