Sauric’s answer to RipDev


By
Posted on Wednesday December 17th, 2008 / 11:15

Ο Sauric απαντάει στην πρόκληση της RipDev:

(This is the author of MobileSubstrate.) Ok, I would normally totally ignore something like this, but now you are getting into the world of personal misinformation. :(

For the record, my day job actually is (at least often) doing these kind of hacks. I have spent the last few years doing embedded ARM development, working for a client that wants code they wrote 20 years ago to work on their new device, often without source code or documentation. This requires drastic reverse engineering efforts and various hooks into the code.

Now/, however, my day job is iPhone/Android development, and has been for months. After I released Cycorder I started spending less and less time doing consulting, and now I simply don’t do it at all.

Finally, my PhD work is in “Post-Compile-Time Code Modification and Optimization”. As an undergraduate I even published a paper on hooking method calls in pre-existing Java applications (which is actually more difficult than doing the same for C/Objective-C, as you can’t just back-patch the already loaded code).

I therefore find your assertions that my expertise is lacking in this area surprising ;P.

You also happen to be making a couple incorrect claims about my work, which I will now address. As an example: the way I do C hooking /definitely/ allows multiple hooks to coexist. I highly recommend reading the code again: each time someone hooks the function, they will lift out a trampoline which contains code to call the previous hook.

This is difficult to see as it is a side effect of the hooking process as opposed to an explicit feature, so I understand why you missed it. To be honest, even I have to rethink through why it works if I haven’t looked at it in a couple months.

In the case of MobileSafety’s signal hooks, you have a point, but it is a dubious one: remember that inserted libraries are loaded before the original application. This means that the application is going to be forced to hook them after I do: I can’t stop those hooks, and can only hope that they call through to me afterwards. The only time there should be another handler I’d have to call through to is if another library made such a hook.

I will, therefore, fix this issue, but it should be made very clear that this is not even remotely the big deal you are making it out to be, and that your specific complaint about “insert a full-fledged GUI application” is simply false. Even then, the entire concept of the argument is weird: the mobile safe mode mechanism /only/ hooks SpringBoard.

Past that, you make a few correct, but unimportant claims: the fact that MobileSubstrate attempts to use Objective-C’isms when possible ever so slightly slows it down. However, when you are already hooking Objective-C messages this cost isn’t noticeable. I would love to see some high-level numbers where you show the costs.

Specifically, for example, I can’t imagine the startup penalty of MobileSubstrate is even measurable. An application already takes about two seconds to load. I know that all of the measurements I’ve done simply haven’t mattered.

As for the 50-400 instructions per hook, that is only going to cause issues when you are hooking something at the lowest possible depths of a program (where only a foolish developer used Objective-C to begin with). Think about it: what is the hook even doing? It’s probably/hopefully going to be sending a number of further messages, which will swamp the couple hundred nanoseconds you are concerned about.

That said, I agree: it would be nice to provide that option, and I thank you for the suggestion. The next version of MobileSubstrate will also support an IMP pass-through method of calling the next hook (although given that, as you say, it is slightly more bothersome to the developer, I doubt many people will prefer it).

This is one of the wonderful aspects of open source: you were able to read MobileSubstrate, and give me a useful suggestion. A patch would have been even cooler, but this is still awesome.

On that note, I didn’t even know that Mobile Enhancer was something that third parties could use. (To be very frank: I wasn’t even certain that Mobile Enhancer did anything similar to MobileSubstrate until today.) Is there any documentation for it, or any examples? If you Google search for it you just get confused users trying to guess what it is for. One gets the feeling that you preferred that technology to be for RiPDev’s internal usage on their projects, not something to be used by everyone.

Really, AFAIK, MobileSubstrate is in use by as many people as it is only because I wrote WinterBoard, which I designed because A) SummerBoard was dead, B) I don’t remember FaceLift fully working on 2.x at the time, and C) even if it did, it was commercial anyway and I felt the most bang-for-the-buck could be had giving that part away. While doing this, everyone really wanted WinterBoard to be open source, especially given that SummerBoard simply got abandoned and FaceLift was stagnating.

Originally, therefore, I simply wrote it. At that same time, a number of other people /also/ wanted to hook things, and were coming to me for the techniques (which, as you know, were more complex on 2.x due to the new Objective-C ABI). I just kept pointing them to WinterBoard’s source code. As far as I still know, this is because no one knew how to use Mobile Enhancer to do this, assuming that they even were able to.

After a couple weeks of this, I finally decided to abstract that part of the code out of WinterBoard into a library, in order to A) make this easier and B) allow the hooks to be centralized (which makes installing them much simpler: too many developers were messing up their installation programs and SWOD’ing people’s devices). So that’s the story of why it was written.

If Mobile Enhancer had been “out there” and documented (which something that is closed source kind of has to be to be usable ;P), maybe no one would have come to me, and maybe no one would be using Mobile Substrate. You never know.

Συζήτηση στο forum: PseudoSubstrate vs MobileSubstrate

About Vasilis Ananiadis

Ο ζωντανός θρύλος της Ελληνικής blogόσφαιρας, ο αβυσσαλέος master του SEO, o πρίγκηπας των Social Media, ο τυφώνας των Web Startups, ο οργασμός της ιντερνετικής επιτυχίας. Τώρα και στο twitter: @vananiadis

Tags: ,




Comments are closed.