美文网首页
android 7.0获取soinfo

android 7.0获取soinfo

作者: 处于蒙比阶段的小白 | 来源:发表于2018-11-21 21:13 被阅读0次

    烂笔头

    7.0开始不再允许获取soinfo对象,贴一下大概流程以及依据:
    6.0:
    dlopen -> dlopen_ext:返回soinfo* result = do_dlopen(filename, flags, extinfo);
    ->do_dlopen:soinfo* si = find_library(name, flags, extinfo);return si;

    7.0:
    dlopen -> dlopen_ext:返回void* result = do_dlopen(filename, flags, extinfo, caller_addr);
    ->do_dlopen:
    soinfo* si = find_library(ns, translated_name, flags, extinfo, caller);
    return si->to_handle();

    to_handle() -> 判断版本号,调用get_handle()
    get_handle() -> 返回handle_
    handle_ -> 定义在struct soinfo结构体中,类型为 uintptr_t.


    参考地址

    获取方法

        LibraryReader *libraryReader = new LibraryReader("/system/bin/linker");
        void *soinfo_handles_map = reinterpret_cast<void *>(libraryReader->get_symbol_address(
                "__dl__ZL20g_soinfo_handles_map"));
        std::unordered_map<uintptr_t, void *> *g_soinfo_handles_map = (std::unordered_map<uintptr_t, void *> *) soinfo_handles_map;
        void *handle = dlopen("/system/lib/libc++.so", 0);
        auto it = g_soinfo_handles_map->find((uintptr_t) handle);
    
        void *soinfo = it->second;
        LogHex::DumpHexByPrintf(soinfo, 256);
    

    内存打印

    image.png

    相关文章

      网友评论

          本文标题:android 7.0获取soinfo

          本文链接:https://www.haomeiwen.com/subject/twshqqtx.html