Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pass callback from mach-o to CFM



Dear Mr. Poirier

Thank you for your reply.

> // create a CFM function pointer to a Mach-O function
> translatedFunctionPtr = NewCFMFromMachO((void*)YourOriginalMachoCallback);
Upper code locate at Mach-O SHLB

> // when you and the CFM app are all done with it
> DisposeCFMFromMachO(translatedFunctionPtr);
My call and upper code locate at CFM App,
Work fine.
Thanks a lot!

Also I could not understand acttually your code below.
> void * NewCFMFromMachO(void * inMachoFunctionPtr)
> {
> void * result = NewPtr(8);
> ((void**)result)[0] = inMachoFunctionPtr;
> ((void**)result)[1] = result;
> return result;
> }
I guess your code simply slide [1] (second member of array) of marh-o
pointer.

Would you lindly explain outline of this method?
Do it require the understanding MACH-O Runtime architecture?
(I would like to know why the code work fine.)

Please kindly advice.
Best regards.

On 03.8.28 9:15 PM, "Marc Poirier" <email@hidden> wrote:

>> I'm serching the way how to pass my callback function from Mach-o shlib
>> to CFM App.
>>
>> If anyone know how to pass mycallback function from Mach-O to CFM App,
>> please advice me your informations.
>
> void * NewCFMFromMachO(void * inMachoFunctionPtr)
> {
> void * result = NewPtr(8);
> ((void**)result)[0] = inMachoFunctionPtr;
> ((void**)result)[1] = result;
> return result;
> }
>
> void DisposeCFMFromMachO(void * inPtr)
> {
> if (inPtr != NULL)
> DisposePtr((Ptr)inPtr);
> }
>
> // create a CFM function pointer to a Mach-O function
> translatedFunctionPtr = NewCFMFromMachO((void*)YourOriginalMachoCallback);
>
> // when you and the CFM app are all done with it
> DisposeCFMFromMachO(translatedFunctionPtr);
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.