void *get_base_of_lib_from_soinfo(char *soname) { if (soname == NULL) return NULL; void *imagehandle = dlopen(soname, RTLD_LOCAL | RTLD_LAZY); if (imagehandle == NULL) { return NULL; } char *basename; char *searchname; int i; void *libdl_ptr = dlopen("libdl.so", 3); basename = strrchr(soname, '/'); searchname = basename ? basename + 1 : soname; for (i = (int) libdl_ptr; i != NULL; i = *(int *) (i + 164)) { if (!strcmp(searchname, (char *) i)) { unsigned int *lbase = (unsigned int *) i + 140; void *baseaddr = (void *) *lbase; return baseaddr; } } return NULL; }
参考链接:https://koz.io/android-substrate-c-hooking/
发表评论