在逆向分析某代码时,get到一处有点差异的地方。

Android 7.0 dlopen的不同

开始觉得很奇怪,判断了dlopen返回值最后一位,若为1则知道版本7.0以后,查看源码分析后才知,7.0之后dlopen代码做了一些改动,而该判断是否为7.0前后版本依据为如下源码:
Android 7.0 dlopen的不同

为什么要这样做呢,主要是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.

handle为随机生成的一个hash值,指向soinfo存在了 g_soinfo_handles_map字典中。
Android 7.0 dlopen的不同

PS:好像8.0又可以获取soinfo了….

转载请注明出处。

相关文章:

  • 2021-06-13
  • 2021-05-24
  • 2021-09-17
  • 2022-01-07
  • 2021-04-30
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-09-26
  • 2022-02-08
  • 2021-11-22
  • 2022-02-16
相关资源
相似解决方案