如何在iOS中获取使用标识符指定的应用程序的所有类?

时间:2015-06-28 05:07:43

标签: objective-c jailbreak objective-c-runtime tweak

我希望在运行时获取指定应用程序的所有类(可能是任何其他应用程序,而不仅仅是应用程序本身),我可以使用它的标识符获取该应用程序的NSBundle,但是如何使用NSBundle获取类,或者我可以直接使用应用程序的标识符获取类?我们假设它可能是一个越狱的环境。我试过objc_copyClassNamesForImage但是失败了,有人有想法吗?

NSBundle * bundle = [NSBundle bundleWithIdentifier:appIdentifier];
NSString * bundlePath = [bundle bundlePath];
NSLog(@"%@", bundlePath);

unsigned int count;
const char **classes;

classes = objc_copyClassNamesForImage([bundlePath UTF8String], &count);

for (int i = 0; i< sizeof(classes)/sizeof(classes[0]); i++){
    NSLog(@"class name: %s", classes[i]);
}

0 个答案:

没有答案