summaryrefslogtreecommitdiffstats
path: root/base/native_library_win.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-01-07 14:18:56 +0000
committerBen Murdoch <benm@google.com>2011-01-11 10:23:13 +0000
commit201ade2fbba22bfb27ae029f4d23fca6ded109a0 (patch)
treeb793f4ed916f73cf18357ea467ff3deb5ffb5b52 /base/native_library_win.cc
parentd8c4c37a7d0961944bfdfaa117d5c68c8e129c97 (diff)
downloadexternal_chromium-201ade2fbba22bfb27ae029f4d23fca6ded109a0.zip
external_chromium-201ade2fbba22bfb27ae029f4d23fca6ded109a0.tar.gz
external_chromium-201ade2fbba22bfb27ae029f4d23fca6ded109a0.tar.bz2
Merge chromium at 9.0.597.55: Initial merge by git.
Change-Id: Id686a88437441ec7e17abb3328a404c7b6c3c6ad
Diffstat (limited to 'base/native_library_win.cc')
-rw-r--r--base/native_library_win.cc23
1 files changed, 20 insertions, 3 deletions
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);
}