Re: Loading mach-o shared libraries
Re: Loading mach-o shared libraries
- Subject: Re: Loading mach-o shared libraries
- From: Mark Thomas <email@hidden>
- Date: Thu, 10 Jun 2004 16:07:54 +0100
- Organization: Coderus Ltd
I was wondering if anybody here, might know what the answer might be
Thanks
Mark.
------------------------------------------------------------------------
Thanks, these to to track down the proc in the shared library a treat, but
if I try to call it, I get an exception (EXC_BAD_ACCESS) :-(,
I've enclosed of basically, what I'm doing which I have done similar things
in CFM and windows and worked ok, so wondering why here its not happening.
(I'm also doing this from Coca if that matters).
Any ideas
Thanks
Mark.
typedef void (*callbackProc)(void *pParam1, void *pParam2, void *pParam3 );
typedef struct
{
callbackProc mQuitProc;
callbackProc mInstallModule;
} callbackInterface;
typedef void (*dllCallbackProc)(callbackInterface *pProc);
const struct mach_header *dllFile = NSAddImage( [dllPath cString],
NSADDIMAGE_OPTION_NONE );
dllCallbackProc *theProc = (dllCallbackProc*) NSLookupSymbolInImage (
dllFile, "_setupCallbacks", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY );
if ( theProc )
{
(*theProc) (&theCallback);
}
In Shared library
~~~~~~~~~~~~~~~~~
callbackInterface *gCallbacks;
extern "C"
{
void setupCallback(callbackInterface *pCallbacks)
{
gCallbacks=pCallbacks;
gCallbacks->mQuitProc(NULL,NULL,NULL);
}
}
>
This document is probably what you are looking for. Look up NSAddImage
>
and NSLookupSymbolInImage.
>
>
Randy
>
>
On Jun 1, 2004, at 9:59 AM, Mark Thomas wrote:
>
>
> Hi,
>
> Can anybody point me in the right direct for loading a macho shared
>
> library, as I want to load it, and find a symbol and then call it.
>
> I've seen
>
> the CFPlugin interface but that a bit of an overkill for me. The
>
> annoying
>
> thing I've done this on Solaris but cannot the api dyload or something,
>
>
>
> Ahh memory going :-(, must have drunken too much beer :-(.
>
>
>
> Thanks
>
> Mark.
>
> _______________________________________________
>
> 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.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.