diff options
-rw-r--r-- | base/native_library.h | 9 | ||||
-rw-r--r-- | base/native_library_win.cc | 23 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_lib.cc | 15 |
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(); |