MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / loadModule

Method loadModule

src/common/os/win32/mod_loader.cpp:209–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209ModuleLoader::Module* ModuleLoader::loadModule(ISC_STATUS* status, const PathName& modPath)
210{
211 ContextActivator ctx;
212
213 // supress error message box if it is not done yet
214 const UINT oldErrorMode =
215 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
216
217 HMODULE module = 0;
218 if (PathUtils::isRelative(modPath))
219 {
220 MasterInterfacePtr master;
221 const char* baseDir = master->getConfigManager()->getDirectory(IConfigManager::DIR_BIN);
222
223 PathName fullName;
224 PathUtils::concatPath(fullName, baseDir, modPath);
225
226 module = LoadLibraryEx(fullName.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
227 }
228
229 if (!module)
230 module = LoadLibraryEx(modPath.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
231
232 if (!module && status)
233 {
234 status[0] = isc_arg_win32;
235 status[1] = GetLastError();
236 status[2] = isc_arg_end;
237 }
238
239 // Restore old mode in case we are embedded into user application
240 SetErrorMode(oldErrorMode);
241
242 if (!module)
243 return 0;
244
245 char fileName[MAX_PATH];
246 GetModuleFileName(module, fileName, sizeof(fileName));
247
248 return FB_NEW_POOL(*getDefaultMemoryPool()) Win32Module(*getDefaultMemoryPool(), fileName, module);
249}
250
251Win32Module::~Win32Module()
252{

Callers

nothing calls this directly

Calls 5

getDefaultMemoryPoolFunction · 0.85
Win32ModuleClass · 0.85
getDirectoryMethod · 0.45
getConfigManagerMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected