| Index: base/native_library_win.cc
|
| ===================================================================
|
| --- base/native_library_win.cc (revision 66680)
|
| +++ base/native_library_win.cc (working copy)
|
| @@ -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 @@
|
| }
|
| }
|
|
|
| - 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 @@
|
| }
|
|
|
| // 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);
|
| }
|
|
|