MediaPluginHost::MediaPluginHost() { MOZ_COUNT_CTOR(MediaPluginHost); const char* name = GetOmxLibraryName(); ALOG("Loading OMX Plugin: %s", name ? name : "nullptr"); if (name) { char *path = PR_GetLibraryFilePathname("libxul.so", (PRFuncPtr) GetOmxLibraryName); PRLibrary *lib = NULL; if (path) { nsAutoCString libpath(path); PR_Free(path); int32_t slash = libpath.RFindChar('/'); if (slash != kNotFound) { libpath.Truncate(slash + 1); libpath.Append(name); lib = PR_LoadLibrary(libpath.get()); } } if (!lib) lib = PR_LoadLibrary(name); if (lib) { Manifest *manifest = static_cast<Manifest *>(PR_FindSymbol(lib, "MPAPI_MANIFEST")); if (manifest) { mPlugins.AppendElement(manifest); ALOG("OMX plugin successfully loaded"); } } } }
/* static */ bool FFVPXRuntimeLinker::Link() { if (sLinkStatus) { return sLinkStatus == LinkStatus_SUCCEEDED; } MOZ_ASSERT(NS_IsMainThread()); // We retrieve the path of the XUL library as this is where mozavcodec and // mozavutil libs are located. char* path = PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Link); if (!path) { return false; } nsCOMPtr<nsIFile> xulFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); if (!xulFile || NS_FAILED(xulFile->InitWithNativePath(nsDependentCString(path)))) { PR_Free(path); return false; } PR_Free(path); nsCOMPtr<nsIFile> rootDir; if (NS_FAILED(xulFile->GetParent(getter_AddRefs(rootDir))) || !rootDir) { return false; } nsAutoCString rootPath; if (NS_FAILED(rootDir->GetNativePath(rootPath))) { return false; } char* libname = NULL; /* Get the platform-dependent library name of the module */ libname = PR_GetLibraryName(rootPath.get(), "mozavutil"); if (!libname) { return false; } sLinkedUtilLib = MozAVLink(libname); PR_FreeLibraryName(libname); libname = PR_GetLibraryName(rootPath.get(), "mozavcodec"); if (libname) { sLinkedLib = MozAVLink(libname); PR_FreeLibraryName(libname); if (sLinkedLib && sLinkedUtilLib) { if (Bind("mozavcodec")) { sLinkStatus = LinkStatus_SUCCEEDED; return true; } } } Unlink(); sLinkStatus = LinkStatus_FAILED; return false; }
PRLibrary* PORT_LoadLibraryFromOrigin(const char* existingShLibName, PRFuncPtr staticShLibFunc, const char* newShLibName) { PRLibrary* lib = NULL; char* fullPath = NULL; PRLibSpec libSpec; /* Get the pathname for existingShLibName, e.g. /usr/lib/libnss3.so * PR_GetLibraryFilePathname works with either the base library name or a * function pointer, depending on the platform. * We require the address of a function in the "reference library", * provided by the caller. To avoid getting the address of the stub/thunk * of an exported function by accident, use the address of a static * function rather than an exported function. */ fullPath = PR_GetLibraryFilePathname(existingShLibName, staticShLibFunc); if (fullPath) { lib = loader_LoadLibInReferenceDir(fullPath, newShLibName); #ifdef XP_UNIX if (!lib) { /* * If fullPath is a symbolic link, resolve the symbolic * link and try again. */ char* originalfullPath = loader_GetOriginalPathname(fullPath); if (originalfullPath) { PR_Free(fullPath); fullPath = originalfullPath; lib = loader_LoadLibInReferenceDir(fullPath, newShLibName); } } #endif PR_Free(fullPath); } if (!lib) { #ifdef DEBUG_LOADER PR_fprintf(PR_STDOUT, "\nAttempting to load %s\n", newShLibName); #endif libSpec.type = PR_LibSpec_Pathname; libSpec.value.pathname = newShLibName; lib = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL); } if (NULL == lib) { #ifdef DEBUG_LOADER PR_fprintf(PR_STDOUT, "\nLoading failed : %s.\n", newShLibName); #endif } return lib; }
static PRLibrary* loader_LoadLibrary(const char* nameToLoad) { PRLibrary* lib = NULL; char* fullPath = NULL; PRLibSpec libSpec; /* Get the pathname for nameOfAlreadyLoadedLib, i.e. /usr/lib/libnss3.so * PR_GetLibraryFilePathname works with either the base library name or a * function pointer, depending on the platform. We can't query an exported * symbol such as NSC_GetFunctionList, because on some platforms we can't * find symbols in loaded implicit dependencies. * But we can just get the address of this function ! */ fullPath = PR_GetLibraryFilePathname(NameOfThisSharedLib, (PRFuncPtr)&loader_LoadLibrary); if (fullPath) { lib = loader_LoadLibInReferenceDir(fullPath, nameToLoad); #ifdef XP_UNIX if (!lib) { /* * If fullPath is a symbolic link, resolve the symbolic * link and try again. */ char* originalfullPath = loader_GetOriginalPathname(fullPath); if (originalfullPath) { PR_Free(fullPath); fullPath = originalfullPath; lib = loader_LoadLibInReferenceDir(fullPath, nameToLoad); } } #endif PR_Free(fullPath); } if (!lib) { #ifdef DEBUG_LOADER PR_fprintf(PR_STDOUT, "\nAttempting to load %s\n", nameToLoad); #endif libSpec.type = PR_LibSpec_Pathname; libSpec.value.pathname = nameToLoad; lib = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL); } if (NULL == lib) { #ifdef DEBUG_LOADER PR_fprintf(PR_STDOUT, "\nLoading failed : %s.\n", nameToLoad); #endif } return lib; }
static PRBool blapi_SHVerify(const char *name, PRFuncPtr addr, PRBool self) { PRBool result = PR_FALSE; /* if anything goes wrong, * the signature does not verify */ /* find our shared library name */ char *shName = PR_GetLibraryFilePathname(name, addr); if (!shName) { goto loser; } result = blapi_SHVerifyFile(shName, self); loser: if (shName != NULL) { PR_Free(shName); } return result; }
static PRLibrary * sftkdb_LoadLibrary(const char *libname) { PRLibrary *lib = NULL; PRFuncPtr fn_addr; char *parentLibPath = NULL; fn_addr = (PRFuncPtr) &sftkdb_LoadLibrary; parentLibPath = PR_GetLibraryFilePathname(SOFTOKEN_LIB_NAME, fn_addr); if (!parentLibPath) { goto done; } lib = sftkdb_LoadFromPath(parentLibPath, libname); #ifdef XP_UNIX /* handle symbolic link case */ if (!lib) { char *trueParentLibPath = sftkdb_resolvePath(parentLibPath); if (!trueParentLibPath) { goto done; } lib = sftkdb_LoadFromPath(trueParentLibPath, libname); PORT_Free(trueParentLibPath); } #endif done: if (parentLibPath) { PORT_Free(parentLibPath); } /* still couldn't load it, try the generic path */ if (!lib) { PRLibSpec libSpec; libSpec.type = PR_LibSpec_Pathname; libSpec.value.pathname = libname; lib = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL); } return lib; }
PRBool BLAPI_SHVerify(const char *name, PRFuncPtr addr) { #ifdef PSEUDO_FIPS return PR_TRUE; /* a lie, hence *pseudo* FIPS */ #else PRBool result = PR_FALSE; /* if anything goes wrong, * the signature does not verify */ /* find our shared library name */ char *shName = PR_GetLibraryFilePathname(name, addr); if (!shName) { goto loser; } result = BLAPI_SHVerifyFile(shName); loser: if (shName != NULL) { PR_Free(shName); } return result; #endif /* PSEUDO_FIPS */ }