Re: Mach-O app calling CFM plug-in?
Re: Mach-O app calling CFM plug-in?
- Subject: Re: Mach-O app calling CFM plug-in?
- From: Wyatt Webb <email@hidden>
- Date: Mon, 28 Aug 2006 15:23:26 -0700
On Aug 28, 2006, at 1:54 PM, Philippe Casgrain wrote:
On 06-08-28, at 16:31, Rosyna wrote:
I'm not sure, but this may be relevant.
http://developer.apple.com/samplecode/CFM_MachO_CFM/index.html
Thank you, I know (and used) this sample code. This is when you're
a CFM application, calling into a Mach-O loadable bundle, and maybe
calling back from the bundle into your CFM application. We use this
for WebKit integration.
We're trying to call CFM from Mach-O, not the other way around :-].
I guess we're looking for MachO_CFM_MachO...
Actually, it was this very code sample that led me to writing the
code that does what you want. Here's a snippet of what I ended up with:
const UInt32 kCFMGlue[6] = {0x3D800000, 0x618C0000, 0x800C0000,
0x804C0004, 0x7C0903A6, 0x4E800420};
Ptr CFM2MachO( Ptr pFunction )
{
// use the glue code with the function pointer to make a new
// function pointer that Mach-O can use
UInt32 *lNewFunction = reinterpret_cast< UInt32* >( NewPtr( sizeof
(kCFMGlue) ) );
lNewFunction[0] = kCFMGlue[0] | (reinterpret_cast< UInt32 >
( pFunction ) >> 16);
lNewFunction[1] = kCFMGlue[1] | (reinterpret_cast< UInt32 >
( pFunction ) & 0xFFFF);
lNewFunction[2] = kCFMGlue[2];
lNewFunction[3] = kCFMGlue[3];
lNewFunction[4] = kCFMGlue[4];
lNewFunction[5] = kCFMGlue[5];
MakeDataExecutable( lNewFunction, sizeof(kCFMGlue) );
return( reinterpret_cast< Ptr >( lNewFunction ) );
}
In my code I call GetDiskFragment to find my CFM library. I then use
FindSymbol to get the function pointer I want. Then I pass that to
CFM2MachO. That gives me a Mach-O pointer I can now use.
Hope this is what you're looking for,
Wyatt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden