static nsresult LoadGtkModule(GnomeAccessibilityModule& aModule) { NS_ENSURE_ARG(aModule.libName); if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) { MAI_LOG_DEBUG(("Fail to load lib: %s in default path\n", aModule.libName)); //try to load the module with "gtk-2.0/modules" appended char *curLibPath = PR_GetLibraryPath(); nsCAutoString libPath(curLibPath); #if defined(LINUX) && defined(__x86_64__) libPath.Append(":/usr/lib64:/usr/lib"); #else libPath.Append(":/usr/lib"); #endif MAI_LOG_DEBUG(("Current Lib path=%s\n", libPath.get())); PR_FreeLibraryName(curLibPath); PRInt16 loc1 = 0, loc2 = 0; PRInt16 subLen = 0; while (loc2 >= 0) { loc2 = libPath.FindChar(':', loc1); if (loc2 < 0) subLen = libPath.Length() - loc1; else subLen = loc2 - loc1; nsCAutoString sub(Substring(libPath, loc1, subLen)); sub.Append("/gtk-2.0/modules/"); sub.Append(aModule.libName); aModule.lib = PR_LoadLibrary(sub.get()); if (aModule.lib) { MAI_LOG_DEBUG(("Ok, load %s from %s\n", aModule.libName, sub.get())); break; } loc1 = loc2+1; } if (!aModule.lib) { MAI_LOG_DEBUG(("Fail to load %s\n", aModule.libName)); return NS_ERROR_FAILURE; } } //we have loaded the library, try to get the function ptrs if (!(aModule.init = PR_FindFunctionSymbol(aModule.lib, aModule.initName)) || !(aModule.shutdown = PR_FindFunctionSymbol(aModule.lib, aModule.shutdownName))) { //fail, :( MAI_LOG_DEBUG(("Fail to find symbol %s in %s", aModule.init ? aModule.shutdownName : aModule.initName, aModule.libName)); PR_UnloadLibrary(aModule.lib); aModule.lib = NULL; return NS_ERROR_FAILURE; } return NS_OK; }
static void Initialize() { if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) return; // This will leak - See comments in ~nsIdleServiceGTK(). PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1"); if (!xsslib) // ouch. { #ifdef PR_LOGGING PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to find libXss.so!\n")); #endif return; } _XSSQueryExtension = (_XScreenSaverQueryExtension_fn) PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryExtension"); _XSSAllocInfo = (_XScreenSaverAllocInfo_fn) PR_FindFunctionSymbol(xsslib, "XScreenSaverAllocInfo"); _XSSQueryInfo = (_XScreenSaverQueryInfo_fn) PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryInfo"); #ifdef PR_LOGGING if (!_XSSQueryExtension) PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to get XSSQueryExtension!\n")); if (!_XSSAllocInfo) PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to get XSSAllocInfo!\n")); if (!_XSSQueryInfo) PR_LOG(sIdleLog, PR_LOG_WARNING, ("Failed to get XSSQueryInfo!\n")); #endif sInitialized = true; }
static void ProcessModule(const char *modulesDir, const char *fileName) { int dLen = strlen(modulesDir); int fLen = strlen(fileName); char *buf = (char *) malloc(dLen + 1 + fLen + 1); memcpy(buf, modulesDir, dLen); buf[dLen] = kPathSep; memcpy(buf + dLen + 1, fileName, fLen); buf[dLen + 1 + fLen] = '\0'; PRLibrary *lib = PR_LoadLibrary(buf); if (lib) { EntryPoint initFunc = (EntryPoint) PR_FindFunctionSymbol(lib, kInitMethod); EntryPoint testFunc = (EntryPoint) PR_FindFunctionSymbol(lib, kTestMethod); EntryPoint shutdownFunc = (EntryPoint) PR_FindFunctionSymbol(lib, kShutdownMethod); if (testFunc) { int rv = 0; if (initFunc) rv = initFunc(); // don't run test case if init fails. if (rv == 0) testFunc(); if (shutdownFunc) shutdownFunc(); } PR_UnloadLibrary(lib); } free(buf); }
static nsresult ensure_libgnomeui() { // Attempt to get the libgnomeui symbol references. We do it this way so that stock icons from Init() // don't get held back by InitWithGnome()'s libgnomeui dependency. if (!gTriedToLoadGnomeLibs) { gLibGnomeUI = PR_LoadLibrary("libgnomeui-2.so.0"); if (!gLibGnomeUI) return NS_ERROR_NOT_AVAILABLE; _gnome_init = (_GnomeInit_fn)PR_FindFunctionSymbol(gLibGnomeUI, "gnome_init_with_popt_table"); _gnome_icon_theme_new = (_GnomeIconThemeNew_fn)PR_FindFunctionSymbol(gLibGnomeUI, "gnome_icon_theme_new"); _gnome_icon_lookup = (_GnomeIconLookup_fn)PR_FindFunctionSymbol(gLibGnomeUI, "gnome_icon_lookup"); if (!_gnome_init || !_gnome_icon_theme_new || !_gnome_icon_lookup) { PR_UnloadLibrary(gLibGnomeUI); gLibGnomeUI = nullptr; return NS_ERROR_NOT_AVAILABLE; } } if (!gLibGnomeUI) return NS_ERROR_NOT_AVAILABLE; return NS_OK; }
void nsApplicationAccessibleWrap::PreCreate() { if (!sATKChecked) { sATKLib = PR_LoadLibrary(sATKLibName); if (sATKLib) { AtkGetTypeType pfn_atk_hyperlink_impl_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol); if (pfn_atk_hyperlink_impl_get_type) g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type(); AtkGetTypeType pfn_atk_socket_get_type; pfn_atk_socket_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, AtkSocketAccessible::sATKSocketGetTypeSymbol); if (pfn_atk_socket_get_type) { AtkSocketAccessible::g_atk_socket_type = pfn_atk_socket_get_type(); AtkSocketAccessible::g_atk_socket_embed = (AtkSocketEmbedType) PR_FindFunctionSymbol(sATKLib, AtkSocketAccessible ::sATKSocketEmbedSymbol); AtkSocketAccessible::gCanEmbed = AtkSocketAccessible::g_atk_socket_type != G_TYPE_INVALID && AtkSocketAccessible::g_atk_socket_embed; } } sATKChecked = PR_TRUE; } }
static PRStatus ssl_InitCngFunctions(void) { SECStatus rv; ncrypt_library = PR_LoadLibrary("ncrypt.dll"); if (ncrypt_library == NULL) goto loser; pNCryptFreeObject = (NCryptFreeObjectFunc)PR_FindFunctionSymbol( ncrypt_library, "NCryptFreeObject"); if (pNCryptFreeObject == NULL) goto loser; pNCryptSignHash = (NCryptSignHashFunc)PR_FindFunctionSymbol( ncrypt_library, "NCryptSignHash"); if (pNCryptSignHash == NULL) goto loser; rv = NSS_RegisterShutdown(ssl_ShutdownCngFunctions, NULL); if (rv != SECSuccess) goto loser; return PR_SUCCESS; loser: pNCryptSignHash = NULL; pNCryptFreeObject = NULL; if (ncrypt_library) { PR_UnloadLibrary(ncrypt_library); ncrypt_library = NULL; } return PR_FAILURE; }
GMPErr ChromiumCDMAdapter::GMPInit(const GMPPlatformAPI* aPlatformAPI) { GMP_LOG("ChromiumCDMAdapter::GMPInit"); sPlatform = aPlatformAPI; if (!mLib) { return GMPGenericErr; } #ifdef MOZILLA_OFFICIAL // Note: we must call the VerifyCdmHost_0 function if it's present before // we call the initialize function. auto verify = reinterpret_cast<decltype(::VerifyCdmHost_0)*>( PR_FindFunctionSymbol(mLib, STRINGIFY(VerifyCdmHost_0))); if (verify) { nsTArray<cdm::HostFile> files; for (HostFileData& hostFile : mHostFiles) { files.AppendElement(TakeToCDMHostFile(hostFile)); } bool result = verify(files.Elements(), files.Length()); GMP_LOG("%s VerifyCdmHost_0 returned %d", __func__, result); } #endif auto init = reinterpret_cast<decltype(::INITIALIZE_CDM_MODULE)*>( PR_FindFunctionSymbol(mLib, STRINGIFY(INITIALIZE_CDM_MODULE))); if (!init) { return GMPGenericErr; } GMP_LOG(STRINGIFY(INITIALIZE_CDM_MODULE) "()"); init(); return GMPNoErr; }
bool GMPChild::LoadPluginLibrary(const std::string& aPluginPath) { nsDependentCString pluginPath(aPluginPath.c_str()); nsCOMPtr<nsIFile> libFile; nsresult rv = NS_NewNativeLocalFile(pluginPath, true, getter_AddRefs(libFile)); if (NS_FAILED(rv)) { return false; } nsAutoString leafName; if (NS_FAILED(libFile->GetLeafName(leafName))) { return false; } nsAutoString baseName(Substring(leafName, 4, leafName.Length() - 1)); #if defined(XP_MACOSX) nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib"); #elif defined(OS_POSIX) nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so"); #elif defined(XP_WIN) nsAutoString binaryName = baseName + NS_LITERAL_STRING(".dll"); #else #error not defined #endif libFile->AppendRelativePath(binaryName); nsAutoCString nativePath; libFile->GetNativePath(nativePath); mLib = PR_LoadLibrary(nativePath.get()); if (!mLib) { return false; } GMPInitFunc initFunc = reinterpret_cast<GMPInitFunc>(PR_FindFunctionSymbol(mLib, "GMPInit")); if (!initFunc) { return false; } auto platformAPI = new GMPPlatformAPI(); InitPlatformAPI(*platformAPI); if (initFunc(platformAPI) != GMPNoErr) { return false; } mGetAPIFunc = reinterpret_cast<GMPGetAPIFunc>(PR_FindFunctionSymbol(mLib, "GMPGetAPI")); if (!mGetAPIFunc) { return false; } return true; }
NS_IMETHODIMP nsSound::Init() { // This function is designed so that no library is compulsory, and // one library missing doesn't cause the other(s) to not be used. if (mInited) return NS_OK; mInited = true; if (!libcanberra) { libcanberra = PR_LoadLibrary("libcanberra.so.0"); if (libcanberra) { ca_context_create = (ca_context_create_fn) PR_FindFunctionSymbol(libcanberra, "ca_context_create"); if (!ca_context_create) { PR_UnloadLibrary(libcanberra); libcanberra = nullptr; } else { // at this point we know we have a good libcanberra library ca_context_destroy = (ca_context_destroy_fn) PR_FindFunctionSymbol(libcanberra, "ca_context_destroy"); ca_context_play = (ca_context_play_fn) PR_FindFunctionSymbol(libcanberra, "ca_context_play"); ca_context_change_props = (ca_context_change_props_fn) PR_FindFunctionSymbol(libcanberra, "ca_context_change_props"); ca_proplist_create = (ca_proplist_create_fn) PR_FindFunctionSymbol(libcanberra, "ca_proplist_create"); ca_proplist_destroy = (ca_proplist_destroy_fn) PR_FindFunctionSymbol(libcanberra, "ca_proplist_destroy"); ca_proplist_sets = (ca_proplist_sets_fn) PR_FindFunctionSymbol(libcanberra, "ca_proplist_sets"); ca_context_play_full = (ca_context_play_full_fn) PR_FindFunctionSymbol(libcanberra, "ca_context_play_full"); } } } return NS_OK; }
GMPErr WidevineAdapter::GMPInit(const GMPPlatformAPI* aPlatformAPI) { #ifdef ENABLE_WIDEVINE_LOG if (getenv("GMP_LOG_FILE")) { // Clear log file. FILE* f = fopen(getenv("GMP_LOG_FILE"), "w"); if (f) { fclose(f); } } #endif sPlatform = aPlatformAPI; if (!mLib) { return GMPGenericErr; } auto init = reinterpret_cast<decltype(::INITIALIZE_CDM_MODULE)*>( PR_FindFunctionSymbol(mLib, STRINGIFY(INITIALIZE_CDM_MODULE))); if (!init) { return GMPGenericErr; } Log(STRINGIFY(INITIALIZE_CDM_MODULE)"()"); init(); return GMPNoErr; }
PRFuncPtr GLLibraryLoader::LookupSymbol(PRLibrary *lib, const char *sym, PlatformLookupFunction lookupFunction) { PRFuncPtr res = 0; // try finding it in the library directly, if we have one if (lib) { res = PR_FindFunctionSymbol(lib, sym); } // then try looking it up via the lookup symbol if (!res && lookupFunction) { res = lookupFunction(sym); } // finally just try finding it in the process if (!res) { PRLibrary *leakedLibRef; res = PR_FindFunctionSymbolAndLibrary(sym, &leakedLibRef); } return res; }
nsresult PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) { JNIEnv* env = GetJNIForThread(); if (!env) return NS_ERROR_FAILURE; if (mNP_Initialize) { *error = mNP_Initialize(bFuncs, pFuncs, env); } else { NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc) PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); if (!pfNP_Initialize) return NS_ERROR_FAILURE; *error = pfNP_Initialize(bFuncs, pFuncs, env); } // Save pointers to functions that get called through PluginLibrary itself. mNPP_New = pFuncs->newp; mNPP_GetValue = pFuncs->getvalue; mNPP_ClearSiteData = pFuncs->clearsitedata; mNPP_GetSitesWithData = pFuncs->getsiteswithdata; return NS_OK; }
nsresult nsGSettingsService::Init() { #define FUNC(name, type, params) { #name, (nsGSettingsFunc *)&_##name }, typedef void (*nsGSettingsFunc)(); static const struct nsGSettingsDynamicFunction { const char *functionName; nsGSettingsFunc *function; } kGSettingsSymbols[] = { GSETTINGS_FUNCTIONS }; #undef FUNC if (!gioLib) { gioLib = PR_LoadLibrary("libgio-2.0.so.0"); if (!gioLib) return NS_ERROR_FAILURE; } for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kGSettingsSymbols); i++) { *kGSettingsSymbols[i].function = PR_FindFunctionSymbol(gioLib, kGSettingsSymbols[i].functionName); if (!*kGSettingsSymbols[i].function) { PR_UnloadLibrary(gioLib); return NS_ERROR_FAILURE; } } return NS_OK; }
NS_IMETHODIMP nsSound::Init() { /* we don't need to do esd_open_sound if we are only going to play files but we will if we want to do things like streams, etc */ if (mInited) return NS_OK; if (elib) return NS_OK; EsdOpenSoundType EsdOpenSound; elib = PR_LoadLibrary("libesd.so.0"); if (!elib) return NS_ERROR_NOT_AVAILABLE; EsdOpenSound = (EsdOpenSoundType) PR_FindFunctionSymbol(elib, "esd_open_sound"); if (!EsdOpenSound) return NS_ERROR_FAILURE; esdref = (*EsdOpenSound)("localhost"); if (!esdref) return NS_ERROR_FAILURE; mInited = PR_TRUE; return NS_OK; }
// Gets shell version as packed 64 bit int PRUint64 nsDragService::GetShellVersion() { PRUint64 lVersion = LL_INIT(0, 0); PRUint64 lMinor = lVersion; // shell32.dll should be loaded already, so we ae not actually loading the library here PRLibrary *libShell = PR_LoadLibrary("shell32.dll"); if (libShell == NULL) return lVersion; do { DLLGETVERSIONPROC versionProc = NULL; versionProc = (DLLGETVERSIONPROC)PR_FindFunctionSymbol(libShell, "DllGetVersion"); if (versionProc == NULL) break; DLLVERSIONINFO versionInfo; ::ZeroMemory(&versionInfo, sizeof(DLLVERSIONINFO)); versionInfo.cbSize = sizeof(DLLVERSIONINFO); if (FAILED(versionProc(&versionInfo))) break; // why is this? LL_UI2L(lVersion, versionInfo.dwMajorVersion); LL_SHL(lVersion, lVersion, 32); LL_UI2L(lMinor, versionInfo.dwMinorVersion); LL_OR2(lVersion, lMinor); } while (false); PR_UnloadLibrary(libShell); libShell = NULL; return lVersion; }
gfxFT2LockedFace::CharVariantFunction gfxFT2LockedFace::FindCharVariantFunction() { // This function is available from FreeType 2.3.6 (June 2008). PRLibrary *lib = nsnull; CharVariantFunction function = reinterpret_cast<CharVariantFunction> (PR_FindFunctionSymbolAndLibrary("FT_Face_GetCharVariantIndex", &lib)); if (!lib) { return nsnull; } FT_Int major; FT_Int minor; FT_Int patch; FT_Library_Version(mFace->glyph->library, &major, &minor, &patch); // Versions 2.4.0 to 2.4.3 crash if configured with // FT_CONFIG_OPTION_OLD_INTERNALS. Presence of the symbol FT_Alloc // indicates FT_CONFIG_OPTION_OLD_INTERNALS. if (major == 2 && minor == 4 && patch < 4 && PR_FindFunctionSymbol(lib, "FT_Alloc")) { function = nsnull; } // Decrement the reference count incremented in // PR_FindFunctionSymbolAndLibrary. PR_UnloadLibrary(lib); return function; }
nsSound::~nsSound() { /* see above comment */ if (esdref != -1) { EsdCloseType EsdClose = (EsdCloseType) PR_FindFunctionSymbol(elib, "esd_close"); if (EsdClose) (*EsdClose)(esdref); esdref = -1; } }
static void Initialize() { sInitialized = true; #if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11) // This will leak - See comments in ~nsIdleServiceQt(). PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1"); if (!xsslib) { return; } _XSSQueryExtension = (_XScreenSaverQueryExtension_fn) PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryExtension"); _XSSAllocInfo = (_XScreenSaverAllocInfo_fn) PR_FindFunctionSymbol(xsslib, "XScreenSaverAllocInfo"); _XSSQueryInfo = (_XScreenSaverQueryInfo_fn) PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryInfo"); #endif }
void GMPSetNodeId(const char* aNodeId, uint32_t aLength) override { if (!mLib) { return; } GMPSetNodeIdFunc setNodeIdFunc = reinterpret_cast<GMPSetNodeIdFunc>(PR_FindFunctionSymbol(mLib, "GMPSetNodeId")); if (setNodeIdFunc) { setNodeIdFunc(aNodeId, aLength); } }
GMPErr GMPInit(const GMPPlatformAPI* aPlatformAPI) override { if (!mLib) { return GMPGenericErr; } GMPInitFunc initFunc = reinterpret_cast<GMPInitFunc>(PR_FindFunctionSymbol(mLib, "GMPInit")); if (!initFunc) { return GMPNotImplementedErr; } return initFunc(aPlatformAPI); }
void GMPShutdown() override { if (mLib) { GMPShutdownFunc shutdownFunc = reinterpret_cast<GMPShutdownFunc>(PR_FindFunctionSymbol(mLib, "GMPShutdown")); if (shutdownFunc) { shutdownFunc(); } PR_UnloadLibrary(mLib); mLib = nullptr; } }
void ChromiumCDMAdapter::GMPShutdown() { GMP_LOG("ChromiumCDMAdapter::GMPShutdown()"); decltype(::DeinitializeCdmModule)* deinit; deinit = (decltype(deinit))(PR_FindFunctionSymbol(mLib, "DeinitializeCdmModule")); if (deinit) { GMP_LOG("DeinitializeCdmModule()"); deinit(); } }
void WidevineAdapter::GMPShutdown() { Log("WidevineAdapter::GMPShutdown()"); decltype(::DeinitializeCdmModule)* deinit; deinit = (decltype(deinit))(PR_FindFunctionSymbol(mLib, "DeinitializeCdmModule")); if (deinit) { Log("DeinitializeCdmModule()"); deinit(); } }
GMPErr ChromiumCDMAdapter::GMPGetAPI(const char* aAPIName, void* aHostAPI, void** aPluginAPI, uint32_t aDecryptorId) { GMP_LOG("ChromiumCDMAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p", aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this); bool isCDM9 = !strcmp(aAPIName, CHROMIUM_CDM_API); bool isCDM8 = !strcmp(aAPIName, CHROMIUM_CDM_API_BACKWARD_COMPAT); if (isCDM8 || isCDM9) { auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>( PR_FindFunctionSymbol(mLib, "CreateCdmInstance")); if (!create) { GMP_LOG("ChromiumCDMAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p " "FAILED to find CreateCdmInstance", aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this); return GMPGenericErr; } int version = isCDM8 ? cdm::ContentDecryptionModule_8::kVersion : cdm::ContentDecryptionModule_9::kVersion; void* cdm = create(version, kEMEKeySystemWidevine.get(), kEMEKeySystemWidevine.Length(), &ChromiumCdmHost, aHostAPI); if (!cdm) { GMP_LOG("ChromiumCDMAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p " "FAILED to create cdm version %d", aAPIName, aHostAPI, aPluginAPI, aDecryptorId, this, version); return GMPGenericErr; } GMP_LOG("cdm: 0x%p, version: %d", cdm, version); *aPluginAPI = cdm; } return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr; }
nsresult NSGetModule(nsIComponentManager* aCompMgr, nsIFile* aLocation, nsIModule* *aResult) { nsresult rv; // This is not the real component. We want to load the dependent libraries // of the real component, then the component itself, and call NSGetModule on // the component. // Assume that we're in <extensiondir>/components, and we want to find // <extensiondir>/libraries nsCOMPtr<nsIFile> libraries; rv = aLocation->GetParent(getter_AddRefs(libraries)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsILocalFile> library(do_QueryInterface(libraries)); if (!library) return NS_ERROR_UNEXPECTED; library->SetNativeLeafName(NS_LITERAL_CSTRING("libraries")); library->AppendNative(NS_LITERAL_CSTRING("dummy")); // loop through and load dependent libraries for (char const *const *dependent = kDependentLibraries; *dependent; ++dependent) { library->SetNativeLeafName(nsDependentCString(*dependent)); PRLibrary *lib; library->Load(&lib); // 1) We don't care if this failed! // 2) We are going to leak this library. We don't care about that either. } library->SetNativeLeafName(NS_LITERAL_CSTRING(kRealComponent)); PRLibrary *lib; rv = library->Load(&lib); if (NS_FAILED(rv)) return rv; nsGetModuleProc getmoduleproc = (nsGetModuleProc) PR_FindFunctionSymbol(lib, NS_GET_MODULE_SYMBOL); if (!getmoduleproc) return NS_ERROR_FAILURE; return getmoduleproc(aCompMgr, aLocation, aResult); }
static nsresult ensure_libgnomevfs() { if (!gTriedToLoadGnomeLibs) { gLibGnomeVFS = PR_LoadLibrary("libgnomevfs-2.so.0"); if (!gLibGnomeVFS) return NS_ERROR_NOT_AVAILABLE; _gnome_vfs_get_file_info = (_GnomeVFSGetFileInfo_fn)PR_FindFunctionSymbol(gLibGnomeVFS, "gnome_vfs_get_file_info"); _gnome_vfs_file_info_clear = (_GnomeVFSFileInfoClear_fn)PR_FindFunctionSymbol(gLibGnomeVFS, "gnome_vfs_file_info_clear"); if (!_gnome_vfs_get_file_info || !_gnome_vfs_file_info_clear) { PR_UnloadLibrary(gLibGnomeVFS); gLibGnomeVFS = nullptr; return NS_ERROR_NOT_AVAILABLE; } } if (!gLibGnomeVFS) return NS_ERROR_NOT_AVAILABLE; return NS_OK; }
static void InitModuleFromLib(const char *modulesDir, const char *fileName) { LOG(("InitModuleFromLib [%s]\n", fileName)); static const ipcDaemonMethods gDaemonMethods = { IPC_DAEMON_METHODS_VERSION, IPC_DispatchMsg, IPC_SendMsg, IPC_GetClientByID, IPC_GetClientByName, IPC_EnumClients, IPC_GetClientID, IPC_ClientHasName, IPC_ClientHasTarget, IPC_EnumClientNames, IPC_EnumClientTargets }; int dLen = strlen(modulesDir); int fLen = strlen(fileName); char *buf = (char *) malloc(dLen + 1 + fLen + 1); memcpy(buf, modulesDir, dLen); buf[dLen] = IPC_PATH_SEP_CHAR; memcpy(buf + dLen + 1, fileName, fLen); buf[dLen + 1 + fLen] = '\0'; PRLibrary *lib = PR_LoadLibrary(buf); if (lib) { ipcGetModulesFunc func = (ipcGetModulesFunc) PR_FindFunctionSymbol(lib, "IPC_GetModules"); LOG((" func=%p\n", (void*) func)); if (func) { const ipcModuleEntry *entries = NULL; int count = func(&gDaemonMethods, &entries); for (int i=0; i<count; ++i) { if (AddModule(entries[i].target, entries[i].methods, buf) == PR_SUCCESS) { if (entries[i].methods->init) entries[i].methods->init(); } } } PR_UnloadLibrary(lib); } free(buf); }
GMPErr WidevineAdapter::GMPGetAPI(const char* aAPIName, void* aHostAPI, void** aPluginAPI) { Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p", aAPIName, aHostAPI, aPluginAPI, this); if (!strcmp(aAPIName, GMP_API_DECRYPTOR)) { if (sCDMWrapper) { // We only support one CDM instance per GMP process. Fail! Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per process! FAIL!"); return GMPQuotaExceededErr; } auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>( PR_FindFunctionSymbol(mLib, "CreateCdmInstance")); if (!create) { Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to find CreateCdmInstance", aAPIName, aHostAPI, aPluginAPI, this); return GMPGenericErr; } WidevineDecryptor* decryptor = new WidevineDecryptor(); auto cdm = reinterpret_cast<cdm::ContentDecryptionModule*>( create(cdm::ContentDecryptionModule::kVersion, kEMEKeySystemWidevine, strlen(kEMEKeySystemWidevine), &GetCdmHost, decryptor)); if (!cdm) { Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to create cdm", aAPIName, aHostAPI, aPluginAPI, this); return GMPGenericErr; } Log("cdm: 0x%x", cdm); sCDMWrapper = new CDMWrapper(cdm); decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper)); *aPluginAPI = decryptor; } else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) { if (!sCDMWrapper) { Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p No cdm for video decoder", aAPIName, aHostAPI, aPluginAPI, this); return GMPGenericErr; } *aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI), RefPtr<CDMWrapper>(sCDMWrapper)); } return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr; }
nsBidiKeyboard::nsBidiKeyboard() { #if defined(MOZ_X11) if (!gtklib) gtklib = PR_LoadLibrary("libgtk-x11-2.0.so.0"); #else return; #endif if (gtklib && !GdkKeymapHaveBidiLayouts) GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) PR_FindFunctionSymbol(gtklib, "gdk_keymap_have_bidi_layouts"); SetHaveBidiKeyboards(); }
void nsApplicationAccessibleWrap::PreCreate() { if (!sATKChecked) { sATKLib = PR_LoadLibrary(sATKLibName); if (sATKLib) { AtkGetTypeType pfn_atk_hyperlink_impl_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol); if (pfn_atk_hyperlink_impl_get_type) { g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type(); } } sATKChecked = PR_TRUE; } }