As an academic and mental exercise, how would one download a precompiled binary file and execute methods in it on an iOS device?
I understand this violates Apple's License Agreement, section 3.2.2, but I am asking for personal projects and to learn more about the iOS runtime.
Goal
- Download http://someexample.com/MyCoolBinary.a
- Save downloaded binary to device disk.
- Call a known method that exists in the binary.
What I've tried
I haven't attempted anything concrete, but I would imagine that it would be possible to do something along the lines of...
void *myDownloadedLibrary = dlopen("/path/to/newly/downloaded/framework/MyCoolBinary.framework")
dlsym(myDownloadedLibrary)
Any examples or pointers on what kind of libraries this would work with would be appreciated.
Thanks.
Try something like
void *uikit = dlopen("path_to_dylib", RTLD_LAZY);
id (*FunctionName)(id) = dlsym(uikit, "FunctionName");
FunctionName(arg1);
dlclose(uikit);
For more information you can read about dynamic loading here: http://en.wikipedia.org/wiki/Dynamic_loading
来源:https://stackoverflow.com/questions/23187911/download-and-execute-ios-code-dynamically-at-runtime