Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
Warning: Division by zero in /home/cuttterp/public_html/mambots/content/geshibot/geshi.class.php on line 2285
| Mach-o and CFM Wizardry |
|
|
|
| Written by Dave Thorup | ||||||
| Thursday, 20 April 2006 | ||||||
|
CFM is dead. It died a long time ago, replaced by the Mach-o binary format. Even though it is dead, it still likes to poke its head out every now and then just to anoy the crap out of you. Anyway, in order to call code in a CFM library from a Mach-o application you need to implement some magical pointer glue so that the different environments know how to take to each other. But hasn't this been documented in the past? Well, sure for some cases. In particular, Apple has some sample code, CFM_MachO_CFM, that shows you how to pass a CFM callback function to a Mach-o library from within a CFM application. That is, the code path is CFM -> Mach-o -> CFM. What I'll be detailing is how to do the opposite of that - Mach-o -> CFM -> Mach-o.
Lucky for us, the CFBundle APIs will take care of most of the heavy lifting. The basic steps in the process are as follows:
Bundlize your LibraryIn order to use the CFBundle APIs you need to put your CFM shared library into a Bundle structure. The easiest way to do this is to use a nice little application called MakeBundle which you can find here. With this application all you need to do is drag and drop your library onto MakeBundle and it will be bundlized. The bundle that is created ends with a .cfm extension and I'd suggest you change this to .bundle. This isn't required, but it makes things easier in Xcode because it knows what to do with .bundles but not .cfms. Add your new bundlized library to Xcode and now we're ready for some coding. CFBundle is our FriendWhile you can certainly implement your own pointer glue and other wizardry to load the CFM function pointers, it's much easier to use the CFBundle APIs. All you need to do is 1) load your bundle using CFBundleLoadExecutable, 2) then load the function pointers you need using CFBundleGetFunctionPointerForName. Here's some code that shows how to do that:
Note that this code isn't very good. It uses a global variable to store the function pointer among other things. We still need some GlueFor most situations this is all you need to do. But, if you need to pass a Mach-o callback function to the CFM library then you need to perform a little magic. What you need to do is create a fake TVector structure (thank George Warner for this).
Now, all you need to do is call NewCFMFuncPointerFromMachOFuncPointer with your Mach-o function pointer as an argument and you'll get back a function pointer that you can pass to the CFM library. Be sure to delete the CFM pointer when you're done with it. Well, that's it for now. I might update this in the future so that there is a working example. But CFM is so long dead that I doubt this will be very helpful anybody in the future. References:CFM_MachO_CFM Related Items:Nothing related Add as favourites (67) | Quote this article on your site | Views: 2148
Write Comment
Powered by AkoComment Tweaked Special Edition v.1.4.3 |
||||||
| Last Updated ( Wednesday, 30 August 2006 ) | ||||||
| < Prev |
|---|







