Ask a Question related to Mac Programming, Design and Development.
-
Hans Stoessel #1
Using GetSharedLibrary in a Mach-O application
Hi
Can I use GetSharedLibrary in a Mach-O application?
Or is there a workaround to load a CFM shared library in a Mach-O
application?
I use this shared library only because I can't link a CFM library in a
Mach-O application which I use.
Thanks for the help
Regards
Hans
Hans Stoessel Guest
-
CF and Mach-ii ??
What makes a Big Difference when coding with Plain CF when compared to working with MACH-II applying OO design, it's been more structural you could... -
Mach II Framework Questions
I am considering rewriting my website using the machii framework. First a specific question as of right now my site loads a topbar and a menubar... -
mach-ii opinions and experiences??
Just been evaluating mach-ii. It seems pretty easy and pretty powerful in that you get the whole MVC thing happening, I am pretty happy to start... -
Mach II & URLSessionFormat()
I am working through the MachII sample sites, trying to incorporate #URLSessionFormat()# to pass JSESSIONID to maintain session without cookies. I... -
Shared library / Mach-O: Application crashs if I call a function
Hi, me again Meanwhile, I can load the shared library in my Mach-O Application and I found my function (BeepTwice) in it. But if I try to call... -
Eric VERGNAUD #2
Re: Using GetSharedLibrary in a Mach-O application
dans l'article bkevqj$139a5$1@ID-142477.news.uni-berlin.de, Hans Stoessel à
[email]hstoessel.list@pm-medici.ch[/email] a écrit le 19/09/03 15:20*:
I think you need to use GetDiskFragment and FindSymbol.> Hi
>
> Can I use GetSharedLibrary in a Mach-O application?
> Or is there a workaround to load a CFM shared library in a Mach-O
> application?
>
> I use this shared library only because I can't link a CFM library in a
> Mach-O application which I use.
>
> Thanks for the help
>
> Regards
> Hans
>
>
Eric
Eric VERGNAUD Guest
-
Hans Stoessel #3
Re: Using GetSharedLibrary in a Mach-O application
Hi
Thanks for your help. Now I can load the fragment and I found my function in
it. But if I try to call this function, the system crashs with the message:
"unknown PowerPC" exception. I have a test application (Mach-O bundle) and a
shared CFM library which I want load in the test application.
Here is the code I use:
//--------------------------------------------------------------------------
--
// Test application: Test.cpp
//--------------------------------------------------------------------------
--
static pascal int (*beepTwice) (void);
static pascal OSErr loadLibrary()
{
OSErr myerr;
CFragConnectionID connID = kInvalidID;
FSSpec fsSpec;
CFragSymbolClass symClass;
myerr = FSMakeFSSpec(0, 0, "\pShlb4DOpen", &fsSpec);
myerr = GetDiskFragment(&fsSpec,
0,
kCFragGoesToEOF,
NULL,
kLoadCFrag,
&connID,
NULL,
NULL);
myerr = FindSymbol (connID, "\pBeepTwice",
(Ptr*) &beepTwice, &symClass);
beepTwice();
return myerr;
}
//--------------------------------------------------------------------------
--
// Shared Library: BeepTwice.c
//--------------------------------------------------------------------------
--
#include <Sound.h>
#pragma export on
int BeepTwice ( void );
#pragma export off
int BeepTwice (void)
{
SysBeep(2);
SysBeep(2);
return 0;
}
Is it maybe a C/C++ problem?
Or a problem with the keyword pascal?
Thanks and Regards
Hans
"Eric VERGNAUD" <eric.vergnaud@wanadoo.fr> schrieb im Newsbeitrag
news:BB91573C.126BC%eric.vergnaud@wanadoo.fr...à> dans l'article bkevqj$139a5$1@ID-142477.news.uni-berlin.de, Hans Stoessel> [email]hstoessel.list@pm-medici.ch[/email] a écrit le 19/09/03 15:20 :
>>> > Hi
> >
> > Can I use GetSharedLibrary in a Mach-O application?
> > Or is there a workaround to load a CFM shared library in a Mach-O
> > application?
> >
> > I use this shared library only because I can't link a CFM library in a
> > Mach-O application which I use.
> >
> > Thanks for the help
> >
> > Regards
> > Hans
> >
> >
> I think you need to use GetDiskFragment and FindSymbol.
>
> Eric
>
Hans Stoessel Guest
-
Martin #4
Re: Using GetSharedLibrary in a Mach-O application
> Thanks for your help. Now I can load the fragment and I found my function in
The following should work (I haven't tried to compile it though):> it. But if I try to call this function, the system crashs with the message:
> "unknown PowerPC" exception. I have a test application (Mach-O bundle) and a
> shared CFM library which I want load in the test application.
>
> Here is the code I use:
>
> //--------------------------------------------------------------------------
> --
> // Test application: Test.cpp
> //--------------------------------------------------------------------------
> --
> static pascal int (*beepTwice) (void);
>
> static pascal OSErr loadLibrary()
> {
> OSErr myerr;
> CFragConnectionID connID = kInvalidID;
> FSSpec fsSpec;
> CFragSymbolClass symClass;
>
> myerr = FSMakeFSSpec(0, 0, "\pShlb4DOpen", &fsSpec);
> myerr = GetDiskFragment(&fsSpec,
> 0,
> kCFragGoesToEOF,
> NULL,
> kLoadCFrag,
> &connID,
> NULL,
> NULL);
>
> myerr = FindSymbol (connID, "\pBeepTwice",
> (Ptr*) &beepTwice, &symClass);
>
> beepTwice();
>
> return myerr;
> }
UInt32 my_template[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004,
0x7C0903A6, 0x4E800420};
void *CFM2MachO( void *cfmfp )
{
UInt32 *mfp = (UInt32*) NewPtr( sizeof(my_template) );
mfp[0] = my_template[0] | ((UInt32)cfmfp >> 16);
mfp[1] = my_template[1] | ((UInt32)cfmfp & 0xFFFF);
mfp[2] = my_template[2];
mfp[3] = my_template[3];
mfp[4] = my_template[4];
mfp[5] = my_template[5];
MakeDataExecutable( mfp, sizeof(my_template) );
return( mfp );
}
typedef pascal int (*BeepPointer) (void);
static BeepPointer beepTwice;
static pascal OSErr loadLibrary()
{
OSErr myerr;
CFragConnectionID connID = kInvalidID;
FSSpec fsSpec;
CFragSymbolClass symClass;
Ptr CFMBeepTwice;
myerr = FSMakeFSSpec(0, 0, "\pShlb4DOpen", &fsSpec);
myerr = GetDiskFragment(&fsSpec,
0,
kCFragGoesToEOF,
NULL,
kLoadCFrag,
&connID,
NULL,
NULL);
myerr = FindSymbol (connID, "\pBeepTwice",
(Ptr*) &CFMBeepTwice, &symClass);
beepTwice = (BeepPointer)CFM2MachO(CFMBeepTwice);
beepTwice();
DisposePtr((Ptr)beepTwice);
return myerr;
}
Martin Guest



Reply With Quote

