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原创, 转载注明出处喵~


电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.