I want to inject some functions to Backboardd, because of some reasons, I can not use plist to restrict it, so I want to use "if" to determine whether it's inside Backboardd.I know in 'Logos' I can use like that:

%ctor{
    if (%c(SpringBoard)) {
    }
}

But without Logos, can I do it like below?It doesn't work.

MSInitialize {
    if (objc_getClass("Backboardd")) {
        CFMessagePortRef local = CFMessagePortCreateLocal(NULL, CFSTR(MACH_PORT_NAME), messageCallBack, NULL, NULL);
        CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(NULL, local, 0);
        CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
    }
}
有帮助吗?

解决方案

In general, you need to find some obj-c class that is unique to what you are hooking. Ideally, it should be class defined inside that binary, not imported from a framework. For example, in SpringBoard there is SpringBoard class that can only be found inside SpringBoard's binary. If objc_getClass("SpringBoard") returns non NULL value then you're inside the SpringBoard.

Now, backboardd. What I'm doing in cases like that is copying binary on my PC and obtaining the list of all classes inside that binary using class-dump or IDA. In case of backboardd, good candidate would be BKApplication. So

if (objc_getClass("BKApplication")) {
    ...
}

would do the job. There is no Backboardd class in backboardd.

And just for the future, use more popular tags for the questions like that. You have a better chance of getting an answer if you use jailbreak or iphone-privateapi tags.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top