| 985 | static std::map<HMODULE, int>* g_load_map = NULL; |
| 986 | |
| 987 | HMODULE WINAPI WindowsInfo::Perftools_LoadLibraryExW(LPCWSTR lpFileName, |
| 988 | HANDLE hFile, |
| 989 | DWORD dwFlags) { |
| 990 | HMODULE rv; |
| 991 | // Check to see if the modules is already loaded, flag 0 gets a |
| 992 | // reference if it was loaded. If it was loaded no need to call |
| 993 | // PatchAllModules, just increase the reference count to match |
| 994 | // what GetModuleHandleExW does internally inside windows. |
| 995 | if (::GetModuleHandleExW(0, lpFileName, &rv)) { |
| 996 | return rv; |
| 997 | } else { |
| 998 | // Not already loaded, so load it. |
| 999 | rv = ((HMODULE (WINAPI *)(LPCWSTR, HANDLE, DWORD)) |
| 1000 | function_info_[kLoadLibraryExW].origstub_fn)( |
| 1001 | lpFileName, hFile, dwFlags); |
| 1002 | // This will patch any newly loaded libraries, if patching needs |
| 1003 | // to be done. |
| 1004 | PatchAllModules(); |
| 1005 | |
| 1006 | return rv; |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | BOOL WINAPI WindowsInfo::Perftools_FreeLibrary(HMODULE hLibModule) { |
| 1011 | BOOL rv = ((BOOL (WINAPI *)(HMODULE)) |
nothing calls this directly
no test coverage detected