////////////////////////////////////////////////////// void listimages(void) { uint32_t i; uint32_t ic = _dyld_image_count(); printf("总数:%d\n", ic); for (i = 0; i < ic; i++) { printf("%d: %p\t%s\t(slide: %p)\n", i, _dyld_get_image_header(i), _dyld_get_image_name(i), _dyld_get_image_vmaddr_slide(i)); } } void add_callback(const struct mach_header *mh, intptr_t vmaddr_slide) { Dl_info info; dladdr(mh, &info); printf("Callback invoked for image: %p %s (slide: %p)\n", mh, info.dli_fname, vmaddr_slide); } void listImagesTest() { // 方法1 listimages(); // 方法2 _dyld_register_func_for_add_image(add_callback); } //////////////////////////////////////////////////////
发表评论