// Pre-load DLLs that need to be used by the EME plugin but that can't be // loaded after the sandbox has started bool GMPChild::PreLoadLibraries(const nsAString& aPluginPath) { // This must be in sorted order and lowercase! static const char* whitelist[] = { "d3d9.dll", // Create an `IDirect3D9` to get adapter information "dxva2.dll", // Get monitor information "evr.dll", // MFGetStrideForBitmapInfoHeader "mfh264dec.dll", // H.264 decoder (on Windows Vista) "mfheaacdec.dll", // AAC decoder (on Windows Vista) "mfplat.dll", // MFCreateSample, MFCreateAlignedMemoryBuffer, MFCreateMediaType "msauddecmft.dll", // AAC decoder (on Windows 8) "msmpeg2adec.dll", // AAC decoder (on Windows 7) "msmpeg2vdec.dll", // H.264 decoder }; nsCOMPtr<nsIFile> infoFile; GetInfoFile(aPluginPath, infoFile); static const size_t MAX_GMP_INFO_FILE_LENGTH = 5 * 1024; nsAutoCString info; if (!ReadIntoString(infoFile, info, MAX_GMP_INFO_FILE_LENGTH)) { NS_WARNING("Failed to read info file in GMP process."); return false; } // Note: we pass "\r\n" to SplitAt so that we'll split lines delimited // by \n (Unix), \r\n (Windows) and \r (old MacOSX). nsTArray<nsCString> lines; SplitAt("\r\n", info, lines); for (nsCString line : lines) { // Make lowercase. std::transform(line.BeginWriting(), line.EndWriting(), line.BeginWriting(), tolower); const char* libraries = "libraries:"; int32_t offset = line.Find(libraries, false, 0); if (offset == kNotFound) { continue; } // Line starts with "libraries:". nsTArray<nsCString> libs; SplitAt(",", Substring(line, offset + strlen(libraries)), libs); for (nsCString lib : libs) { lib.Trim(" "); for (const char* whiteListedLib : whitelist) { if (lib.EqualsASCII(whiteListedLib)) { LoadLibraryA(lib.get()); break; } } } } return true; }
bool GMPInfoFileParser::Init(nsIFile* aInfoFile) { nsTArray<nsCString> lines; static const size_t MAX_GMP_INFO_FILE_LENGTH = 5 * 1024; nsAutoCString info; if (!ReadIntoString(aInfoFile, info, MAX_GMP_INFO_FILE_LENGTH)) { NS_WARNING("Failed to read info file in GMP process."); return false; } // Note: we pass "\r\n" to SplitAt so that we'll split lines delimited // by \n (Unix), \r\n (Windows) and \r (old MacOSX). SplitAt("\r\n", info, lines); for (nsCString line : lines) { // Field name is the string up to but not including the first ':' // character on the line. int32_t colon = line.FindChar(':'); if (colon <= 0) { // Not allowed to be the first character. // Info field name must be at least one character. continue; } nsAutoCString key(Substring(line, 0, colon)); ToLowerCase(key); key.Trim(" "); nsCString* value = new nsCString(Substring(line, colon + 1)); value->Trim(" "); mValues.Put(key, value); // Hashtable assumes ownership of value. } return true; }