diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 22:18:33 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 22:18:33 +0000 |
commit | 56377c0323b23f86ae1498aceb43243010de79e1 (patch) | |
tree | aa1e3e016db470ca5c47289541e0222b4a88a21b /chrome_frame | |
parent | a378371d9cea193dfa27b1cebc533b81aa9b0887 (diff) | |
download | chromium_src-56377c0323b23f86ae1498aceb43243010de79e1.zip chromium_src-56377c0323b23f86ae1498aceb43243010de79e1.tar.gz chromium_src-56377c0323b23f86ae1498aceb43243010de79e1.tar.bz2 |
Fix npchrome_frame dll lookups for shared_library builds.
PathService will give back the path to base.dll, which isn't what is wanted in specific cases. For the DLL redirector, the true path to npchrome_frame must be used, primarily for testing purposes, but it's also the right thing to do. For pinnig, npchrome_frame.dll must be pinned rather than base.dll.
BUG=110492
TEST=the integration tests (chrome_frame_tests.exe) cover it
R=robertshield@chromium.org
Review URL: http://codereview.chromium.org/9141015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/dll_redirector.cc | 44 | ||||
-rw-r--r-- | chrome_frame/test/dll_redirector_loading_test.cc | 11 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 19 |
3 files changed, 36 insertions, 38 deletions
diff --git a/chrome_frame/dll_redirector.cc b/chrome_frame/dll_redirector.cc index 98ede3a..0ca1546 100644 --- a/chrome_frame/dll_redirector.cc +++ b/chrome_frame/dll_redirector.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -271,24 +271,30 @@ HMODULE DllRedirector::GetFirstModule() { HMODULE DllRedirector::LoadVersionedModule(Version* version) { DCHECK(version); - FilePath module_path; - PathService::Get(base::FILE_MODULE, &module_path); - DCHECK(!module_path.empty()); - - // For a module located in - // Foo\XXXXXXXXX\<module>.dll, load - // Foo\<version>\<module>.dll: - FilePath module_name = module_path.BaseName(); - module_path = module_path.DirName() - .DirName() - .Append(ASCIIToWide(version->GetString())) - .Append(module_name); - - HMODULE hmodule = LoadLibrary(module_path.value().c_str()); - if (hmodule == NULL) { - DPLOG(ERROR) << "Could not load reported module version " - << version->GetString(); + HMODULE hmodule = NULL; + wchar_t system_buffer[MAX_PATH]; + HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase); + system_buffer[0] = 0; + if (GetModuleFileName(this_module, system_buffer, + arraysize(system_buffer)) != 0) { + FilePath module_path(system_buffer); + + // For a module located in + // Foo\XXXXXXXXX\<module>.dll, load + // Foo\<version>\<module>.dll: + FilePath module_name = module_path.BaseName(); + module_path = module_path.DirName() + .DirName() + .Append(ASCIIToWide(version->GetString())) + .Append(module_name); + + hmodule = LoadLibrary(module_path.value().c_str()); + if (hmodule == NULL) { + DPLOG(ERROR) << "Could not load reported module version " + << version->GetString(); + } + } else { + DPLOG(FATAL) << "Failed to get module file name"; } - return hmodule; } diff --git a/chrome_frame/test/dll_redirector_loading_test.cc b/chrome_frame/test/dll_redirector_loading_test.cc index bba490f..f19cbde 100644 --- a/chrome_frame/test/dll_redirector_loading_test.cc +++ b/chrome_frame/test/dll_redirector_loading_test.cc @@ -122,16 +122,7 @@ scoped_ptr<Version> DllRedirectorLoadingTest::original_version_; scoped_ptr<Version> DllRedirectorLoadingTest::new_version_; ScopedTempDir DllRedirectorLoadingTest::temp_dir_; -#if defined(COMPONENT_BUILD) -// Disabling since npchrome_frame.dll's DllMain can't handle being loaded into -// a process that has already started services in base.dll such as logging; see -// http://crbug.com/110492. -#define MAYBE_TestDllRedirection DISABLED_TestDllRedirection -#else -#define MAYBE_TestDllRedirection TestDllRedirection -#endif - -TEST_F(DllRedirectorLoadingTest, MAYBE_TestDllRedirection) { +TEST_F(DllRedirectorLoadingTest, TestDllRedirection) { struct TestData { FilePath first_dll; FilePath second_dll; diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 8610f83..cb4f0c0 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1475,18 +1475,20 @@ bool CanNavigate(const GURL& url, void PinModule() { static bool s_pinned = false; if (!s_pinned && !IsUnpinnedMode()) { - FilePath module_path; - if (PathService::Get(base::FILE_MODULE, &module_path)) { + wchar_t system_buffer[MAX_PATH]; + HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase); + system_buffer[0] = 0; + if (GetModuleFileName(this_module, system_buffer, + arraysize(system_buffer)) != 0) { HMODULE unused; - if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, - module_path.value().c_str(), &unused)) { - NOTREACHED() << "Failed to pin module " << module_path.value().c_str() - << " , last error: " << GetLastError(); + if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, system_buffer, + &unused)) { + DPLOG(FATAL) << "Failed to pin module " << system_buffer; } else { s_pinned = true; } } else { - NOTREACHED() << "Could not get module path."; + DPLOG(FATAL) << "Could not get module path."; } } } @@ -1643,4 +1645,3 @@ bool IncreaseWinInetConnections(DWORD connections) { wininet_connection_count_updated = true; return true; } - |