45 #include "CASharedLibrary.h"
48 #if CASharedLibrary_Use_DYLD
49 #include <mach-o/dyld.h>
59 void* CASharedLibrary::LoadLibraryAndGetRoutineAddress(
const char* inRoutineName,
const char* ,
const char* inLibraryPath)
63 #if CASharedLibrary_Use_DYLD
64 const struct mach_header* theImage = NSAddImage(inLibraryPath, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
67 NSSymbol theSymbol = NSLookupSymbolInImage(theImage, inRoutineName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND);
70 theRoutine = NSAddressOfSymbol(theSymbol);
74 void* theImage = dlopen(inLibraryPath, RTLD_LAZY);
79 theRoutine = dlsym(theImage, &(inRoutineName[1]));
87 void* CASharedLibrary::GetRoutineAddressIfLibraryLoaded(
const char* inRoutineName,
const char* ,
const char* inLibraryPath)
91 #if CASharedLibrary_Use_DYLD
92 const struct mach_header* theImage = NSAddImage(inLibraryPath, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED);
95 NSSymbol theSymbol = NSLookupSymbolInImage(theImage, inRoutineName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND);
98 theRoutine = NSAddressOfSymbol(theSymbol);
102 void* theImage = dlopen(inLibraryPath, RTLD_LAZY | RTLD_NOLOAD);
107 theRoutine = dlsym(theImage, &(inRoutineName[1]));