Get iOS classes by Objective-C runtime feature

Hooking something in iOS is really interesting while checking header files to find them is boring. So there are some codes to print a  list of classes by using Objective-C runtime feature.

In fact, these codes work in OS X, too. I find them in Xcode documents. And I made a little modification on them.


int numClasses;
Class * classes = NULL;
if ((numClasses = objc_getClassList(NULL, 0)) > 0 ){
classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
        for (int i = 0; i < numClasses; i++) {

Within the result of these codes, I created a Xcode template. It's useful when you want to hook a class but without libsubstrate.dylib. You can find this template here.

声明: 本文为0xBBC原创, 转载注明出处喵~

Leave a Reply

Your email address will not be published. Required fields are marked *