• 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
Re: Calling a CFM library from Mach-o and passing a Callback...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a CFM library from Mach-o and passing a Callback...


  • Subject: Re: Calling a CFM library from Mach-o and passing a Callback...
  • From: George Warner <email@hidden>
  • Date: Thu, 20 Apr 2006 12:41:53 -0700
  • Thread-topic: Calling a CFM library from Mach-o and passing a Callback...

on 4/20/06 9:34 AM, Dave Thorup at <email@hidden> wrote:

> Alright, I'm in the unfortunate position of having to use a third-party CFM
> library with our Mach-o application.  I have it working for the most part
> using CFBundle to load the library and CFBundleGetFunctionPointerForName to
> load the function pointers that I need.  The last thing that I need to do is
> be able to pass a function pointer from my Mach-o application so that it can
> be used by the CFM library.
>
> I can't seem to find any way to do this, at least I haven't been able to find
> it yet.  The best I could do was locate the CFM_MachO_CFM sample code.  But
> this does the opposite of what I need to do (CFM -> Mach-o -> CFM), I need to
> do Mach-o -> CFM -> Mach-o.  Can anybody point me in the right direction?

All you need to do is create fake TVectors for the macho routines that you
need to pass as callback for CFM API's.

typedef struct TVector_struct {
    void *codePtr;
    void *tocPtr;
} TVector_rec,*TVector_ptr;

Set the codePtr to the macho routine; the tocPtr doesn't matter (for macho).
then pass the address of this vector as the callback. Note: Don't use a
stack based TVector that may "go away" when your routine returns if the
callback may get called after that point (such as a asynchronous callback).
For callbacks that only get called (back) while it's parent routine is
executing (before it returns) it's ok.

--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)


 _______________________________________________
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 a CFM library from Mach-o and passing a Callback...
      • From: Dave Thorup <email@hidden>
References: 
 >Calling a CFM library from Mach-o and passing a Callback... (From: Dave Thorup <email@hidden>)

  • Prev by Date: Re: Calling a CFM library from Mach-o and passing a Callback...
  • Next by Date: Why no execinfo.h?
  • Previous by thread: Re: Calling a CFM library from Mach-o and passing a Callback...
  • Next by thread: Re: Calling a CFM library from Mach-o and passing a Callback...
  • Index(es):
    • Date
    • Thread