The change of Android7.0 to Dlopen

Source: Internet
Author: User

Two memory segments

In the same process space dlopen a. So file, theoretically in memory is the same piece of area, but the actual debugging found in Android7.0 (read "/proc/self/maps"), read the same. So memory actually appeared two segments!

This was not seen in the low version of Android (such as 4.x).

Some of the following blog analysis, and Android7.0 on the dlopen of the rewrite, may be different namespaces under the reading results are not the same, may be a security promotion.

Android 7.0 Behavioral Changes

NDK app link to platform library

Different Android 7.0 Dlopen

7.0 references to already loaded. So/hook

As a result of the above analysis, the Dlopen. So files in their own code are loaded in different memory segments, so they cannot be directly hook, to get the memory address of the. So that the target program loads.

You can use BASE_ADDR + offset to get the address of the target method, base_addr by looking for "/proc/self/maps" to get

This method comes from Android inject to get the address    void* get_module_base (int pid, const char* module_name) {    FILE *fp;    Long addr = 0;    char *pch;    Char filename[32];    Char line[1024];    if (PID < 0) {/        * Self process *        /snprintf (filename, sizeof (filename), "/proc/self/maps", PID);    }    else {        snprintf (filename, sizeof (filename), "/proc/%d/maps", PID);    }    fp = fopen (filename, "R");    if (fp = NULL) {        while (fgets (line, sizeof (line), FP)) {            if (strstr (line, module_name)) {                pch = Strtok (lin E, "-");                Addr = Strtoul (PCH, NULL, +);                if (addr = = 0x8000)                    addr = 0;                break;            }        }        Fclose (FP);    }    return (void *) addr;

Reference blog:

How to hook Dlopen and dlsym underlying functions

The change of Android7.0 to Dlopen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.