Last active
December 25, 2020 12:44
-
-
Save RamseyK/ac5b67f8e8dd386a27aba97a9b5a0d6b to your computer and use it in GitHub Desktop.
Example code for retrieving loaded libraries using functions in dyld.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mach-o/dyld.h> | |
char *target_image_name = "libdyld"; | |
const struct mach_header* target_mach_header = NULL; | |
const char *image_name = NULL; | |
int num_images = _dyld_image_count(); | |
printf("%i images loaded\n", num_images); | |
for (int i = 0; i < num_images; i++) { | |
image_name = _dyld_get_image_name(i); | |
printf("%s (slide %lx)\n", image_name, _dyld_get_image_vmaddr_slide(i)); | |
if (strstr(image_name, target_image_name)) { | |
printf("Found lib: %s\n", image_name); | |
target_mach_header = _dyld_get_image_header(i); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment