summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-19 23:33:13 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-19 23:33:13 +0000
commit3e24622628f9b80010c3784b7ee615c25236fc7f (patch)
tree4da8b15c4e8e012abaa553be00849a968ae2dc8e
parentf2ba4e66c27fe30a9575db9816458fb497bd6f29 (diff)
downloadchromium_src-3e24622628f9b80010c3784b7ee615c25236fc7f.zip
chromium_src-3e24622628f9b80010c3784b7ee615c25236fc7f.tar.gz
chromium_src-3e24622628f9b80010c3784b7ee615c25236fc7f.tar.bz2
Fixes a crash in the Windows media player plugin caused when the Real player recorder
plugin is installed on the machine. This plugin intercepts LoadLibrary calls issued by chrome.dll and wraps NPAPI calls provided the actual plugin dll, in this case media player. This is to provide the Download this video functionality. Crash occurs probably due to an interacton with Real player and media player. Fix is to load the plugin dynamically via the exported kernel32 function LoadLibrary instead of invoking it via the LoadLibrary import from chrome.dll. This would bypass the recorder plugin. Fixes bug http://code.google.com/p/chromium/issues/detail?id=63552 Bug=63552 Test=Install real player and media player on the machine and navigate to the url mentioned in the bug. It should not crash Review URL: http://codereview.chromium.org/5190005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66839 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/native_library.h9
-rw-r--r--base/native_library_win.cc23
-rw-r--r--webkit/glue/plugins/plugin_lib.cc15
3 files changed, 44 insertions, 3 deletions
diff --git a/base/native_library.h b/base/native_library.h
index 3d8c280..6afd06d 100644
--- a/base/native_library.h
+++ b/base/native_library.h
@@ -54,6 +54,15 @@ typedef void* NativeLibrary;
// you're done.
NativeLibrary LoadNativeLibrary(const FilePath& library_path);
+#if defined(OS_WIN)
+// Loads a native library from disk. Release it with UnloadNativeLibrary when
+// you're done.
+// This function retrieves the LoadLibrary function exported from kernel32.dll
+// and calls it instead of directly calling the LoadLibrary function via the
+// import table.
+NativeLibrary LoadNativeLibraryDynamically(const FilePath& library_path);
+#endif // OS_WIN
+
// Unloads a native library.
void UnloadNativeLibrary(NativeLibrary library);
diff --git a/base/native_library_win.cc b/base/native_library_win.cc
index b498eba..b8a806b 100644
--- a/base/native_library_win.cc
+++ b/base/native_library_win.cc
@@ -12,8 +12,10 @@
namespace base {
-// static
-NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
+typedef HMODULE (WINAPI* LoadLibraryFunction)(const wchar_t* file_name);
+
+NativeLibrary LoadNativeLibraryHelper(const FilePath& library_path,
+ LoadLibraryFunction load_library_api) {
// LoadLibrary() opens the file off disk.
base::ThreadRestrictions::AssertIOAllowed();
@@ -29,7 +31,7 @@ NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
}
}
- HMODULE module = LoadLibrary(library_path.value().c_str());
+ HMODULE module = (*load_library_api)(library_path.value().c_str());
if (restore_directory)
file_util::SetCurrentDirectory(current_directory);
@@ -37,6 +39,21 @@ NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
}
// static
+NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
+ return LoadNativeLibraryHelper(library_path, LoadLibraryW);
+}
+
+NativeLibrary LoadNativeLibraryDynamically(const FilePath& library_path) {
+ typedef HMODULE (WINAPI* LoadLibraryFunction)(const wchar_t* file_name);
+
+ LoadLibraryFunction load_library;
+ load_library = reinterpret_cast<LoadLibraryFunction>(
+ GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryW"));
+
+ return LoadNativeLibraryHelper(library_path, load_library);
+}
+
+// static
void UnloadNativeLibrary(NativeLibrary library) {
FreeLibrary(library);
}
diff --git a/webkit/glue/plugins/plugin_lib.cc b/webkit/glue/plugins/plugin_lib.cc
index 292cd63..4ae4da4 100644
--- a/webkit/glue/plugins/plugin_lib.cc
+++ b/webkit/glue/plugins/plugin_lib.cc
@@ -165,7 +165,22 @@ bool PluginLib::Load() {
base::NativeLibrary library = 0;
if (!internal_) {
+#if defined(OS_WIN)
+ // This is to work around a bug in the Real player recorder plugin which
+ // intercepts LoadLibrary calls from chrome.dll and wraps NPAPI functions
+ // provided by the plugin. It crashes if the media player plugin is being
+ // loaded. Workaround is to load the dll dynamically by getting the
+ // LoadLibrary API address from kernel32.dll which bypasses the recorder
+ // plugin.
+ if (web_plugin_info_.name.find(L"Windows Media Player") !=
+ std::wstring::npos) {
+ library = base::LoadNativeLibraryDynamically(web_plugin_info_.path);
+ } else {
+ library = base::LoadNativeLibrary(web_plugin_info_.path);
+ }
+#else // OS_WIN
library = base::LoadNativeLibrary(web_plugin_info_.path);
+#endif // OS_WIN
if (library == 0) {
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< "Couldn't load plugin " << web_plugin_info_.path.value();