Beispiel #1
0
int uv__set_process_title(const char* title) {
#if TARGET_OS_IPHONE
  return -1;
#else
  typedef CFTypeRef (*LSGetCurrentApplicationASNType)(void);
  typedef OSStatus (*LSSetApplicationInformationItemType)(int,
                                                          CFTypeRef,
                                                          CFStringRef,
                                                          CFStringRef,
                                                          CFDictionaryRef*);
  CFBundleRef launch_services_bundle;
  LSGetCurrentApplicationASNType ls_get_current_application_asn;
  LSSetApplicationInformationItemType ls_set_application_information_item;
  CFStringRef* display_name_key;
  ProcessSerialNumber psn;
  CFTypeRef asn;
  CFStringRef display_name;
  OSStatus err;

  launch_services_bundle =
      CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices"));

  if (launch_services_bundle == NULL)
    return -1;

  ls_get_current_application_asn = (LSGetCurrentApplicationASNType)
      CFBundleGetFunctionPointerForName(launch_services_bundle,
                                        CFSTR("_LSGetCurrentApplicationASN"));

  if (ls_get_current_application_asn == NULL)
    return -1;

  ls_set_application_information_item = (LSSetApplicationInformationItemType)
      CFBundleGetFunctionPointerForName(launch_services_bundle,
                                        CFSTR("_LSSetApplicationInformationItem"));

  if (ls_set_application_information_item == NULL)
    return -1;

  display_name_key = CFBundleGetDataPointerForName(launch_services_bundle,
                                                   CFSTR("_kLSDisplayNameKey"));

  if (display_name_key == NULL || *display_name_key == NULL)
    return -1;

  /* Force the process manager to initialize. */
  GetCurrentProcess(&psn);

  display_name = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8);
  asn = ls_get_current_application_asn();
  err = ls_set_application_information_item(-2,  /* Magic value. */
                                            asn,
                                            *display_name_key,
                                            display_name,
                                            NULL);

  return (err == noErr) ? 0 : -1;
#endif  /* !TARGET_OS_IPHONE */
}
bool PluginPackage::load()
{
    if (m_isLoaded) {
        m_loadCount++;
        return true;
    }

    WTF::RetainPtr<CFStringRef> path(AdoptCF, m_path.createCFString());
    WTF::RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.get(),
                                                                        kCFURLPOSIXPathStyle, false));
    m_module = CFBundleCreate(NULL, url.get());
    if (!m_module || !CFBundleLoadExecutable(m_module)) {
        LOG(Plugins, "%s not loaded", m_path.utf8().data());
        return false;
    }

    m_isLoaded = true;

    NP_GetEntryPointsFuncPtr NP_GetEntryPoints = 0;
    NP_InitializeFuncPtr NP_Initialize;
    NPError npErr;

    NP_Initialize = (NP_InitializeFuncPtr)CFBundleGetFunctionPointerForName(m_module, CFSTR("NP_Initialize"));
    NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)CFBundleGetFunctionPointerForName(m_module, CFSTR("NP_GetEntryPoints"));
    m_NPP_Shutdown = (NPP_ShutdownProcPtr)CFBundleGetFunctionPointerForName(m_module, CFSTR("NP_Shutdown"));

    if (!NP_Initialize || !NP_GetEntryPoints || !m_NPP_Shutdown)
        goto abort;

    memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs));
    m_pluginFuncs.size = sizeof(m_pluginFuncs);

    initializeBrowserFuncs();

    npErr = NP_Initialize(&m_browserFuncs);
    LOG_NPERROR(npErr);
    if (npErr != NPERR_NO_ERROR)
        goto abort;

    npErr = NP_GetEntryPoints(&m_pluginFuncs);
    LOG_NPERROR(npErr);
    if (npErr != NPERR_NO_ERROR)
        goto abort;

    m_loadCount++;
    return true;

abort:
    unloadWithoutShutdown();
    return false;
}
Beispiel #3
0
	PluginEntryProc getMainEntry ()
	{
		PluginEntryProc mainProc = 0;
	#if _WIN32
		mainProc = (PluginEntryProc)GetProcAddress ((HMODULE)module, "VSTPluginMain");
		if (!mainProc)
			mainProc = (PluginEntryProc)GetProcAddress ((HMODULE)module, "main");
	#elif TARGET_API_MAC_CARBON
		mainProc = (PluginEntryProc)CFBundleGetFunctionPointerForName ((CFBundleRef)module, CFSTR("VSTPluginMain"));
		if (!mainProc)
			mainProc = (PluginEntryProc)CFBundleGetFunctionPointerForName ((CFBundleRef)module, CFSTR("main_macho"));
	#endif
		return mainProc;
	}
Beispiel #4
0
/*
 * LoadGlxBundle
 *  The Quartz mode X server needs to dynamically load the appropriate
 *  bundle before initializing GLX.
 */
static void LoadGlxBundle(void)
{
    CFBundleRef mainBundle;
    CFStringRef bundleName;
    CFURLRef    bundleURL;
    CFBundleRef glxBundle;

    // Get the main bundle for the application
    mainBundle = CFBundleGetMainBundle();

    // Choose the bundle to load
    ErrorF("Loading GLX bundle ");
    if (quartzUseAGL) {
        bundleName = CFSTR("glxAGL.bundle");
        ErrorF("glxAGL.bundle (using Apple's OpenGL)\n");
    } else {
        bundleName = CFSTR("glxMesa.bundle");
        ErrorF("glxMesa.bundle (using Mesa)\n");
    }

    // Look for the appropriate GLX bundle in the main bundle by name
    bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
                                        NULL, NULL);
    if (!bundleURL) {
        FatalError("Could not find GLX bundle.");
    }

    // Make a bundle instance using the URLRef
    glxBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);

    if (!CFBundleLoadExecutable(glxBundle)) {
        FatalError("Could not load GLX bundle.");
    }

    // Find the GLX init functions
    GlxExtensionInit = (void *) CFBundleGetFunctionPointerForName(
                                glxBundle, CFSTR("GlxExtensionInit"));

    GlxWrapInitVisuals = (void *) CFBundleGetFunctionPointerForName(
                                glxBundle, CFSTR("GlxWrapInitVisuals"));

    if (!GlxExtensionInit || !GlxWrapInitVisuals) {
        FatalError("Could not initialize GLX bundle.");
    }

    // Release the CF objects
    CFRelease(mainBundle);
    CFRelease(bundleURL);
}
static void GetMissingQTFunctionPointers()
{
	OSErr 				err;
	CFBundleRef 		sysBundle;
    
	err = LoadFrameworkBundle(CFSTR("QuickTime.framework"), &sysBundle);
	if (err == noErr)
	{
		mNewQTNextPtr = (NewQTNextTaskPtr) CFBundleGetFunctionPointerForName( sysBundle, CFSTR("NewQTNextTaskNeededSoonerCallbackUPP") );
		mQTInstallNextPtr = (QTInstallNextTaskPtr) CFBundleGetFunctionPointerForName( sysBundle, CFSTR("QTInstallNextTaskNeededSoonerCallback") );
		mQTGetTimeUntilNextTaskPtr = (QTGetTimeUntilNextTaskPtr) CFBundleGetFunctionPointerForName( sysBundle, CFSTR("QTGetTimeUntilNextTask") );
		mDisposeQTNextTaskPtr = (DisposeQTNextTaskPtr)CFBundleGetFunctionPointerForName( sysBundle, CFSTR("DisposeQTNextTaskNeededSoonerCallbackUPP") );
		mQTUninstallNextTaskPtr = (QTUninstallNextTaskPtr)CFBundleGetFunctionPointerForName( sysBundle, CFSTR("QTUninstallNextTaskNeededSoonerCallback") );;
	}
}
static WTF::RetainPtr<CFDictionaryRef> readPListFile(CFStringRef fileName, bool createFile, CFBundleRef bundle)
{
    if (createFile) {
        BP_CreatePluginMIMETypesPreferencesFuncPtr funcPtr =
            (BP_CreatePluginMIMETypesPreferencesFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("BP_CreatePluginMIMETypesPreferences"));
        if (funcPtr)
            funcPtr();
    }

    WTF::RetainPtr<CFDictionaryRef> map;
    WTF::RetainPtr<CFURLRef> url =
        CFURLCreateWithFileSystemPath(kCFAllocatorDefault, fileName, kCFURLPOSIXPathStyle, false);

    CFDataRef resource = 0;
    SInt32 code;
    if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, url.get(), &resource, 0, 0, &code))
        return map;

    WTF::RetainPtr<CFPropertyListRef> propertyList =
            CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, 0);

    CFRelease(resource);

    if (!propertyList)
        return map;

    if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID())
        return map;

    map = static_cast<CFDictionaryRef>(static_cast<CFPropertyListRef>(propertyList.get()));
    return map;
}
Beispiel #7
0
 void *mac_getBundleSym(CFBundleRef bundle, const char *name) 
 {
     CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII);
     void *sym = CFBundleGetFunctionPointerForName(bundle, nameRef);
     CFRelease(nameRef);
     return sym;
 }
__private_extern__ void _CFBundlePlugInLoaded(CFBundleRef bundle) {
    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
    CFStringRef tempStr;
    CFPlugInDynamicRegisterFunction func = NULL;

    if (!__CFBundleGetPlugInData(bundle)->_isPlugIn || __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration || !infoDict || !CFBundleIsExecutableLoaded(bundle)) return;

    tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
    if (tempStr && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
        CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
        tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegisterFunctionKey);
        if (!tempStr || CFGetTypeID(tempStr) != CFStringGetTypeID() || CFStringGetLength(tempStr) <= 0) tempStr = CFSTR("CFPlugInDynamicRegister");
        __CFBundleGetPlugInData(bundle)->_loadOnDemand = false;
        __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;

        /* Find the symbol and call it. */
        func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
        if (func) {
            func(bundle);
            // MF:!!! Unload function is never called.  Need to deal with this!
        }

        __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
        if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && __CFBundleGetPlugInData(bundle)->_instanceCount == 0) CFBundleUnloadExecutable(bundle);   // Unload now if we can/should.
    } else {
        CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
    }
}
void HeadlessView::loadExtensions() {
    if (extensionsLoaded) {
        return;
    }

#ifdef MBGL_USE_CGL
    gl::InitializeExtensions([](const char * name) {
        static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
        if (!framework) {
            throw std::runtime_error("Failed to load OpenGL framework.");
        }

        CFStringRef str = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII);
        void* symbol = CFBundleGetFunctionPointerForName(framework, str);
        CFRelease(str);

        return reinterpret_cast<gl::glProc>(symbol);
    });
#endif

#ifdef MBGL_USE_GLX
    gl::InitializeExtensions([](const char * name) {
        return glXGetProcAddress(reinterpret_cast<const GLubyte *>(name));
    });
#endif

    extensionsLoaded = true;
}
//-----------------------------------------------------------------------------
void *DynamicLibrary::getProcAddress( const char *function )
{
	OSErr err = noErr;
	void *fnAddress = NULL;
#if defined(TORQUE_OS_MAC_CARB)
	if (platState.osX)
	{
		CFStringRef str = CFStringCreateWithCString(NULL, function, kCFStringEncodingMacRoman);
		fnAddress = CFBundleGetFunctionPointerForName( (CFBundleRef)hInst, str );
		if (fnAddress == NULL)
			err = cfragNoSymbolErr;
		CFRelease(str);
	}
	else
#endif
	{
		err = FindSymbol((CFragConnectionID)hInst, str2p(function), (char**)&fnAddress, NULL);
	}

	if (!fnAddress) {
		if (mErrorReport)
			Con::errorf("DynamicLibrary: function '%s' not found!", function);
		mError = true;		
	}
	return fnAddress;
}
Beispiel #11
0
void*   OSCodeFragment::GetSymbol(const char* inSymbolName)
{
    if (fFragmentP == NULL)
        return NULL;
        
#if defined(HPUX) || defined(HPUX10)
    void *symaddr = NULL;
    int status;

    errno = 0;
    status = shl_findsym((shl_t *)&fFragmentP, symname, TYPE_PROCEDURE, &symaddr);
    if (status == -1 && errno == 0) /* try TYPE_DATA instead */
        status = shl_findsym((shl_t *)&fFragmentP, inSymbolName, TYPE_DATA, &symaddr);
    return (status == -1 ? NULL : symaddr);
#elif defined(DLSYM_NEEDS_UNDERSCORE)
    char *symbol = (char*)malloc(sizeof(char)*(strlen(inSymbolName)+2));
    void *retval;
    qtss_sprintf(symbol, "_%s", inSymbolName);
    retval = dlsym(fFragmentP, symbol);
    free(symbol);
    return retval;
#elif defined(__Win32__)
    return ::GetProcAddress(fFragmentP, inSymbolName);
#elif defined(__MacOSX__)
    CFStringRef theString = CFStringCreateWithCString( kCFAllocatorDefault, inSymbolName, kCFStringEncodingASCII);
    void* theSymbol = (void*)CFBundleGetFunctionPointerForName( fFragmentP, theString );
    CFRelease(theString);
    return theSymbol;
#else
    return dlsym(fFragmentP, inSymbolName);
#endif  
}
Beispiel #12
0
void* get_gl_proc_address_by_api(const char* name)
{
	void* ret = NULL;

#ifdef GLLOADER_GLES
	ret = (void*)(eglGetProcAddress(name));
#endif
#ifdef GLLOADER_WGL
	ret = (void*)(::wglGetProcAddress(name));
#endif
#ifdef GLLOADER_AGL
	CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
		CFSTR("/System/Library/Frameworks/OpenGL.framework"), kCFURLPOSIXPathStyle, true);

	CFStringRef functionName = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII);

	CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
	assert(bundle != NULL);

	ret = CFBundleGetFunctionPointerForName(bundle, functionName);

	CFRelease(bundleURL);
	CFRelease(functionName);
	CFRelease(bundle);
#endif
#ifdef GLLOADER_GLX
	ret = (void*)(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(name)));
#endif

	return ret;
}
void CFBundleGetFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]) {
    SInt32 i, c;
    
    if (!ftbl) return;
    
    c = CFArrayGetCount(functionNames);
    for (i = 0; i < c; i++) ftbl[i] = CFBundleGetFunctionPointerForName(bundle, (CFStringRef)CFArrayGetValueAtIndex(functionNames, i));
}
void InitBMDStreamingAPI(void)
{
	CFURLRef bundleURL;

	bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kBMDStreamingAPI_BundlePath), kCFURLPOSIXPathStyle, true);
	if (bundleURL != NULL)
	{
		gBMDStreamingAPIBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
		if (gBMDStreamingAPIBundleRef != NULL)
		{
			gCreateDiscoveryFunc = (CreateDiscoveryFunc)CFBundleGetFunctionPointerForName(gBMDStreamingAPIBundleRef, CFSTR("CreateBMDStreamingDiscoveryInstance_0002"));
			gCreateNALParserFunc = (CreateNALParserFunc)CFBundleGetFunctionPointerForName(gBMDStreamingAPIBundleRef, CFSTR("CreateBMDStreamingH264NALParser_0001"));
		}

		CFRelease(bundleURL);
	}
}
static CFBundleRef LoadRadioEffectComponent()
{
	bool bLoaded = false;
	CFBundleRef Bundle = NULL;

	CFBundleRef MainBundleRef = CFBundleGetMainBundle();
	if( MainBundleRef )
	{
		CFURLRef ComponentURLRef = CFBundleCopyResourceURL( MainBundleRef, CFSTR("RadioEffectUnit"), CFSTR("component"), 0 );
		if( ComponentURLRef )
		{
			Bundle = CFBundleCreate(kCFAllocatorDefault, ComponentURLRef);
			if(Bundle)
			{
				CFArrayRef Components = (CFArrayRef)CFBundleGetValueForInfoDictionaryKey(Bundle, CFSTR("AudioComponents"));
				if ( Components && CFArrayGetCount(Components) )
				{
					CFDictionaryRef ComponentInfo = (CFDictionaryRef)CFArrayGetValueAtIndex(Components, 0);
					CFNumberRef ComponentVersion = (CFNumberRef)CFDictionaryGetValue(ComponentInfo, CFSTR("version"));
					CFStringRef ComponentFactoryFunction = (CFStringRef)CFDictionaryGetValue(ComponentInfo, CFSTR("factoryFunction"));
					if( ComponentVersion && ComponentFactoryFunction )
					{
						int32 Version = 0;
						CFNumberGetValue(ComponentVersion, kCFNumberSInt32Type, &Version);
						
						AudioComponentFactoryFunction Factory = (AudioComponentFactoryFunction)CFBundleGetFunctionPointerForName(Bundle, ComponentFactoryFunction);
						if(Factory)
						{
							//	fill out the AudioComponentDescription
							AudioComponentDescription theDescription;
							theDescription.componentType = kAudioUnitType_Effect;
							theDescription.componentSubType = 'Rdio';
							theDescription.componentManufacturer = 'Epic';
							theDescription.componentFlagsMask = 0;
							
							AudioComponent RadioComponent = AudioComponentFindNext(nullptr, &theDescription);
							if ( !RadioComponent )
							{
								RadioComponent = AudioComponentRegister(&theDescription, CFSTR("Epic Games: RadioEffectUnit"), Version, Factory);
								check(RadioComponent);
							}
							bLoaded = (RadioComponent != NULL);
						}
					}
				}
				if(!bLoaded)
				{
					CFRelease(Bundle);
					Bundle = NULL;
				}
			}

			CFRelease( ComponentURLRef );
		}
	}

	return Bundle;
}
void	InitDeckLinkAPI_v7_6 (void)
{
	CFURLRef		bundleURL;

	bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kDeckLinkAPI_BundlePath), kCFURLPOSIXPathStyle, true);
	if (bundleURL != NULL)
	{
		gBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
		if (gBundleRef != NULL)
		{
			gCreateIteratorFunc = (CreateIteratorFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateDeckLinkIteratorInstance"));
			gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHelperFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateOpenGLScreenPreviewHelper"));
			gCreateCocoaPreviewFunc = (CreateCocoaScreenPreviewFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateCocoaScreenPreview"));
			gCreateVideoConversionFunc = (CreateVideoConversionInstanceFunc_v7_6)CFBundleGetFunctionPointerForName(gBundleRef, CFSTR("CreateVideoConversionInstance"));
		}
		CFRelease(bundleURL);
	}
}
Beispiel #17
0
static void_t* GetProcessAddress (CFBundleRef bundle, const char* lpszprocname) {
  if (NULL == bundle)
    return NULL;

  CFStringRef cfprocname = CFStringCreateWithCString (NULL, lpszprocname, CFStringGetSystemEncoding());
  void_t* processAddress = CFBundleGetFunctionPointerForName (bundle, cfprocname);
  CFRelease (cfprocname);

  return processAddress;
}
Beispiel #18
0
int printOnOSXFormat(char * string,char *format) {
	CFBundleRef bundle;
	int(*fprintf_ptr)(FILE *stream, const char *format, ...) = NULL;
	int(*fcnFlush_ptr)(FILE *stream) = NULL;
	void* fcn_ptr = NULL;
	void* fcnFlushx_ptr = NULL;
	OSErr	err;
	FILE* stderr_ptr = NULL;
	void* __sf_ptr = NULL;
	
	err = LoadFrameworkBundle( CFSTR("System.framework"), &bundle );

	fcn_ptr = CFBundleGetFunctionPointerForName(bundle, CFSTR("fprintf"));
	fcnFlushx_ptr = CFBundleGetFunctionPointerForName(bundle, CFSTR("fflush"));
	__sf_ptr = CFBundleGetDataPointerForName(bundle, CFSTR("__sF"));
	
	if(fcn_ptr) {
	   /* cast it */
	   fprintf_ptr = ( int(*)(FILE *stream, const char *format, ...) ) fcn_ptr;
	} else {
	   /* it failed, handle that somehow */
	   return;
	}

	if(fcnFlushx_ptr) {
	   /* cast it */
	   fcnFlush_ptr = ( int(*)(FILE *stream) ) fcnFlushx_ptr;
	} else {
	   /* it failed, handle that somehow */
	   return;
	}

	if(__sf_ptr) {
	   stderr_ptr = (FILE*) ( ((char*)__sf_ptr) + 176);
	   /* 176 = 88*2, where 88=sizeof(FILE) under BSD */
	} else {
	   /* it failed */
	   return;
	}

	fprintf_ptr(stderr_ptr, format,string);
	fcnFlush_ptr(stderr_ptr);
}
Beispiel #19
0
static void *_get_proc(const char *proc)
{
    void *res;

    CFStringRef procname = CFStringCreateWithCString(kCFAllocatorDefault, proc,
                                                     kCFStringEncodingASCII);
    res = CFBundleGetFunctionPointerForName(bundle, procname);
    CFRelease(procname);
    return res;
}
Beispiel #20
0
/*ARGSUSED*/
static long
krb5int_get_plugin_sym (struct plugin_file_handle *h, 
                        const char *csymname, int isfunc, void **ptr,
			struct errinfo *ep)
{
    long err = 0;
    void *sym = NULL;
    
#if USE_DLOPEN
    if (!err && !sym && (h->dlhandle != NULL)) {
        /* XXX Do we need to add a leading "_" to the symbol name on any
        modern platforms?  */
        sym = dlsym (h->dlhandle, csymname);
        if (sym == NULL) {
            const char *e = dlerror (); /* XXX copy and save away */
            Tprintf ("dlsym(%s): %s\n", csymname, e);
            err = ENOENT; /* XXX */
	    krb5int_set_error(ep, err, "%s", e);
        }
    }
#endif
    
#if USE_CFBUNDLE
    if (!err && !sym && (h->bundle != NULL)) {
        CFStringRef cfsymname = NULL;
        
        if (!err) {
            cfsymname = CFStringCreateWithCString (kCFAllocatorDefault, csymname, 
                                                   kCFStringEncodingASCII);
            if (cfsymname == NULL) { err = ENOMEM; }
        }
        
        if (!err) {
            if (isfunc) {
                sym = CFBundleGetFunctionPointerForName (h->bundle, cfsymname);
            } else {
                sym = CFBundleGetDataPointerForName (h->bundle, cfsymname);
            }
            if (sym == NULL) { err = ENOENT; }  /* XXX */       
        }
        
        if (cfsymname != NULL) { CFRelease (cfsymname); }
    }
#endif
    
    if (!err && (sym == NULL)) {
        err = ENOENT;  /* unimplemented */
    }
    
    if (!err) {
        *ptr = sym;
    }
    
    return err;
}
void* GetProcessAddress(CFBundleRef bundleRef, const char* lpProcName)
{
	void *processAddress = NULL;
	if(NULL != bundleRef)
	{
		CFStringRef cfProcName = CFStringCreateWithCString(kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
		processAddress = CFBundleGetFunctionPointerForName(bundleRef, cfProcName);
		CFRelease(cfProcName);
	}
	return processAddress;
}
Beispiel #22
0
void *Bundle::lookupSymbol(const char *name)
{
    CFRef<CFStringRef> cfName(CFStringCreateWithCString(NULL, name,
                                                        kCFStringEncodingMacRoman));
    if (!cfName)
		UnixError::throwMe(EBADEXEC);	// sort of
    void *function = CFBundleGetFunctionPointerForName(cfBundle(), cfName);
    if (function == NULL)
		UnixError::throwMe(EBADEXEC);	// sort of
    return function;
}
gl::glProc HeadlessBackend::initializeExtension(const char* name) {
    static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
    if (!framework) {
        throw std::runtime_error("Failed to load OpenGL framework.");
    }

    CFStringRef str = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII);
    void* symbol = CFBundleGetFunctionPointerForName(framework, str);
    CFRelease(str);

    return reinterpret_cast<gl::glProc>(symbol);
}
/*
 * QuartzLoadDisplayBundle
 *  Try to load the appropriate bundle containing the back end display code.
 */
Bool QuartzLoadDisplayBundle(
    const char *dpyBundleName)
{
    CFBundleRef mainBundle;
    CFStringRef bundleName;
    CFURLRef    bundleURL;
    CFBundleRef dpyBundle;
    QuartzModeBundleInitPtr bundleInit;

    // Get the main bundle for the application
    mainBundle = CFBundleGetMainBundle();

    // Make CFString from bundle name
    bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
                                                 dpyBundleName,
                                                 kCFStringEncodingASCII,
                                                 kCFAllocatorNull);

    // Look for the appropriate bundle in the main bundle
    bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
                                        NULL, NULL);
    if (!bundleURL) {
        ErrorF("Could not find display mode bundle %s.\n", dpyBundleName);
        return FALSE;
    }

    // Make a bundle instance using the URLRef
    dpyBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);

    if (!CFBundleLoadExecutable(dpyBundle)) {
        ErrorF("Could not load display mode bundle %s.\n", dpyBundleName);
        return FALSE;
    }

    // Lookup the bundle initialization function
    bundleInit = (void *)
            CFBundleGetFunctionPointerForName(dpyBundle,
                                              CFSTR("QuartzModeBundleInit"));
    if (!bundleInit) {
        ErrorF("Could not initialize display mode bundle %s.\n",
               dpyBundleName);
        return FALSE;
    }
    if (!bundleInit())
        return FALSE;

    // Release the CF objects
    CFRelease(bundleName);
    CFRelease(bundleURL);

    return TRUE;
}
Beispiel #25
0
    AEffect *loadVst2xPlugin(LibraryHandle libraryHandle)
    {
        // Somewhat cheap hack to avoid a tricky compiler warning. Casting from void* to a proper function
        // pointer will cause GCC to warn that "ISO C++ forbids casting between pointer-to-function and
        // pointer-to-object". Here, we represent both types in a union and use the correct one in the given
        // context, thus avoiding the need to cast anything.
        // See also: http://stackoverflow.com/a/2742234/14302
        union {
            Vst2xPluginEntryFunc entryPointFuncPtr;
            void *entryPointVoidPtr;
        } entryPoint;

        entryPoint.entryPointVoidPtr = CFBundleGetFunctionPointerForName(libraryHandle, CFSTR("VSTPluginMain"));
        Vst2xPluginEntryFunc mainEntryPoint = entryPoint.entryPointFuncPtr;

        // VST plugins previous to the 2.4 SDK used main_macho for the entry point name
        if (mainEntryPoint == NULL) {
            entryPoint.entryPointVoidPtr = CFBundleGetFunctionPointerForName(libraryHandle, CFSTR("main_macho"));
            mainEntryPoint = entryPoint.entryPointFuncPtr;
        }

        if (mainEntryPoint == NULL) {
            logError("Couldn't get a pointer to plugin's main()");
            CFBundleUnloadExecutable(libraryHandle);
            CFRelease(libraryHandle);
            return NULL;
        }

        AEffect *plugin = mainEntryPoint(pluginVst2xHostCallback);

        if (plugin == NULL) {
            logError("Plugin's main() returns null");
            CFBundleUnloadExecutable(libraryHandle);
            CFRelease(libraryHandle);
            return NULL;
        }

        return plugin;
    }
Beispiel #26
0
void * _glfwPlatformGetProcAddress( const char *procname )
{
    CFStringRef symbolName = CFStringCreateWithCString( kCFAllocatorDefault,
                                                        procname,
                                                        kCFStringEncodingASCII );

    void *symbol = CFBundleGetFunctionPointerForName( _glfwLibs.OpenGLFramework,
                                                      symbolName );

    CFRelease( symbolName );

    return symbol;
}
Beispiel #27
0
void * aglGetProcAddress (char * pszProc)
{
	static bool first_time = true;
	if (first_time)
	{
		first_time = false;
		if (aglInitEntryPoints() != noErr)
			return NULL;			
	}
    return CFBundleGetFunctionPointerForName (gBundleRefOpenGL,
                CFStringCreateWithCStringNoCopy (NULL,
                     pszProc, CFStringGetSystemEncoding (), NULL));
}
Beispiel #28
0
    void set_message(wchar_t const* filename) {

#ifdef __APPLE__
      CFBundleRef mainBundle = CFBundleGetMainBundle();
      CFURLRef pluginURL = CFBundleCopyBuiltInPlugInsURL(mainBundle);
      CFStringRef fn = CFStringCreateWithWString(kCFAllocatorDefault, filename, kCFStringEncodingUTF8);
      CFURLRef path = CFURLCreateCopyAppendingPathComponent(NULL, pluginURL, fn, FALSE);
      
      CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, path);
      CFRelease(path);
      CFRelease(fn);
      CFRelease(pluginURL);
      
      if (bundle==NULL)
        throw filename;
      
      FuncLoadMessage func = (FuncLoadMessage)CFBundleGetFunctionPointerForName(bundle, CFSTR("load_message"));
      
      if (func==NULL) {
        CFRelease(bundle);
        throw filename;
      }
#elif _MSC_VER
      wstring path = wstring(L"dll\\")+filename;

      HMODULE handle = LoadLibrary(path.c_str());

      if (handle==0)
        throw path.c_str();

      FuncLoadMessage func = (FuncLoadMessage)GetProcAddress(handle, "load_message");

      if (func==0)
        throw path.c_str();
#else
#error Not implemented
#endif

      vector<wstring> message;
      message.resize(Message::NUMBER_OF_MESSAGES);

      func(message);

      message_object.reset(new Message);
      message_object->set(message);

#ifdef __APPLE__
      CFRelease(bundle);
#endif
    }
Beispiel #29
0
/////////////////////////////////////////////////////////////
// Get a pointer to an OpenGL extension
// Note on the Mac, this does a lot of work that could be saved
// if you call this function repeatedly. Write your own function that
// gets the bundle once, gets all the function pointers, then releases
// the bundle.
void *gltGetExtensionPointer(const char *szExtensionName)
	{
#ifdef WIN32
    // Well, this one is simple. An OpenGL context must be
    // current first. Returns NULL if extension not supported
    return (void *)wglGetProcAddress(szExtensionName);
#endif
	
#ifdef linux
    // Pretty much ditto above
    return (void *)glXGetProcAddress(szExtensionName);
#endif

    
#ifdef __APPLE__
    // Mac is a bit more tricky.
    // First we need the bundle
    CFBundleRef openGL = 0;
    SInt16      fwVersion = 0;
    SInt32      fwDir = 0;
    
    if(FindFolder(kSystemDomain, kFrameworksFolderType, kDontCreateFolder, &fwVersion, &fwDir) != noErr)
        return NULL;
	
    FSSpec fSpec;
    FSRef  fRef;
    if(FSMakeFSSpec(fwVersion, fwDir, "\pOpenGL.framework", &fSpec) != noErr)
        return NULL;
	
    FSpMakeFSRef(&fSpec, &fRef);
    CFURLRef url = CFURLCreateFromFSRef(kCFAllocatorDefault, &fRef);
    if(!url)
        return NULL;
	
    openGL = CFBundleCreate(kCFAllocatorDefault, url);
    CFRelease(url);
    
    // Then load the function pointer from the bundle
    CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, szExtensionName, kCFStringEncodingMacRoman);
    void *pFunc = CFBundleGetFunctionPointerForName(openGL, string);
    
    // Release the bundle and string
    CFRelease(string);
    CFRelease(openGL);
    
    // Return the function ponter
    return pFunc;
#endif    
    }
Beispiel #30
0
void* 	ioFindExternalFunctionIn(char *lookupName, void * moduleHandle) {
	void * 		functionPtr = 0;
        CFStringRef	theString;
        
	if (!moduleHandle) 
            return nil;
            
        theString = CFStringCreateWithCString(kCFAllocatorDefault,lookupName,gCurrentVMEncoding);
        if (theString == nil) 
            return nil;
        functionPtr = (void*)CFBundleGetFunctionPointerForName((CFBundleRef) moduleHandle,theString);
        CFRelease(theString);
                
	return (void*) functionPtr;
}