• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Calling back from CFM into Mach-O [was: Mach-O app calling CFM plug-in?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling back from CFM into Mach-O [was: Mach-O app calling CFM plug-in?]


  • Subject: Calling back from CFM into Mach-O [was: Mach-O app calling CFM plug-in?]
  • From: Philippe Casgrain <email@hidden>
  • Date: Tue, 29 Aug 2006 09:37:08 -0400

Wyatt Webb a écrit :
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.
Thanks, Wyatt and Rosyna. You are both correct, and in the flurry of things that I tried to get this to work I forgot that if I call CFM2MachO() like above, I can call a CFM function from Mach-O.

But how can I setup callbacks? I don't have any control over the plug-ins (think Photoshop plug-ins), so they expect their callbacks to be in CFM format (for lack of a better term).

Philippe
_______________________________________________
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


  • Follow-Ups:
    • Re: Calling back from CFM into Mach-O [was: Mach-O app calling CFM plug-in?]
      • From: Philippe Casgrain <email@hidden>
References: 
 >Mach-O app calling CFM plug-in? (From: Philippe Casgrain <email@hidden>)
 >Re: Mach-O app calling CFM plug-in? (From: Rosyna <email@hidden>)
 >Re: Mach-O app calling CFM plug-in? (From: Philippe Casgrain <email@hidden>)
 >Re: Mach-O app calling CFM plug-in? (From: Wyatt Webb <email@hidden>)

  • Prev by Date: Re: Cmath and math.h Changes in Xcode 2.4
  • Next by Date: Re: Mach-O app calling CFM plug-in?
  • Previous by thread: Re: Mach-O app calling CFM plug-in?
  • Next by thread: Re: Calling back from CFM into Mach-O [was: Mach-O app calling CFM plug-in?]
  • Index(es):
    • Date
    • Thread