-
-
Save zhuowei/4bc4baeb12f64b2e03608cd2b2d7b4d7 to your computer and use it in GitHub Desktop.
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
// dsc_extractor from https://github.com/apple-opensource/dyld/blob/1128192c016372ae94793d88530bc5978c1fce93/dyld3/shared-cache/dsc_extractor.cpp#L817 | |
// test program | |
#include <stdio.h> | |
#include <stddef.h> | |
#include <dlfcn.h> | |
typedef int (*extractor_proc)(const char* shared_cache_file_path, const char* extraction_root_path, | |
void (^progress)(unsigned current, unsigned total)); | |
int main(int argc, const char* argv[]) | |
{ | |
if ( argc != 3 ) { | |
fprintf(stderr, "usage: dsc_extractor <path-to-cache-file> <path-to-device-dir>\n"); | |
return 1; | |
} | |
//void* handle = dlopen("/Volumes/my/src/dyld/build/Debug/dsc_extractor.bundle", RTLD_LAZY); | |
// zhuowei: the path | |
// void* handle = dlopen("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/dsc_extractor.bundle", RTLD_LAZY); | |
void* handle = dlopen("/usr/lib/dsc_extractor.bundle", RTLD_LAZY); | |
if ( handle == NULL ) { | |
fprintf(stderr, "dsc_extractor.bundle could not be loaded\n"); | |
return 1; | |
} | |
extractor_proc proc = (extractor_proc)dlsym(handle, "dyld_shared_cache_extract_dylibs_progress"); | |
if ( proc == NULL ) { | |
fprintf(stderr, "dsc_extractor.bundle did not have dyld_shared_cache_extract_dylibs_progress symbol\n"); | |
return 1; | |
} | |
int result = (*proc)(argv[1], argv[2], ^(unsigned c, unsigned total) { printf("%d/%d\n", c, total); } ); | |
fprintf(stderr, "dyld_shared_cache_extract_dylibs_progress() => %d\n", result); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment