MCPcopy Create free account
hub / github.com/SpecialKO/SpecialK / SK_LoadImportModule

Function SK_LoadImportModule

src/import.cpp:308–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void
309SK_LoadImportModule (import_s& import)
310{
311 // Do not load twice...
312 if (import.hLibrary != nullptr)
313 return;
314
315 if (StrStrIW (import.filename->get_value_ref ().c_str (), L"ReShade") != nullptr)
316 {
317 SK_ReShade_LoadDLL ( import.filename->get_value_ref ().c_str (),
318 import.mode->get_value_str ().c_str () );
319 }
320
321 if (config.system.central_repository)
322 {
323 wchar_t wszProfilePlugIn [MAX_PATH + 2] = { };
324 wcsncpy_s (wszProfilePlugIn, MAX_PATH, SK_GetConfigPath (), _TRUNCATE);
325 PathAppendW (wszProfilePlugIn, import.filename->get_value_str ().c_str ());
326
327 if (! SK_GetModuleHandleW (wszProfilePlugIn))
328 {
329 import.hLibrary = SK_Modules->LoadLibrary (
330 wszProfilePlugIn
331 );
332 }
333 }
334
335 if (import.hLibrary == nullptr && !SK_GetModuleHandleW (import.filename->get_value_str ().c_str ()))
336 {
337 import.hLibrary = SK_Modules->LoadLibrary (
338 import.filename->get_value_str ().c_str ()
339 );
340 }
341
342 // If we still can't find the library, try expanding environment variables
343 // in the user-supplied path.
344 if (import.hLibrary == nullptr)
345 {
346 wchar_t wszExpandedPath [MAX_PATH + 2] = { };
347 const DWORD nExpandedPathSize =
348 ExpandEnvironmentStrings (
349 import.filename->get_value_str ().c_str (),
350 wszExpandedPath, MAX_PATH );
351
352 if (nExpandedPathSize != 0 && !SK_GetModuleHandleW (wszExpandedPath))
353 {
354 if (nExpandedPathSize <= MAX_PATH)
355 {
356 import.hLibrary = SK_Modules->LoadLibrary(
357 wszExpandedPath
358 );
359 }
360
361 else
362 {
363 // There's no guarantee that the length of the fully-expanded path will fit within
364 // the array defined above. If the path is long, we'll need to dynamically allocate
365 // memory on the heap for the long path and then call `ExpandEnvironmentStrings` again.

Callers 9

SK_LoadEarlyImports64Function · 0.85
SK_LoadPlugIns64Function · 0.85
SK_LoadLateImports64Function · 0.85
SK_LoadLazyImports64Function · 0.85
SK_LoadEarlyImports32Function · 0.85
SK_LoadPlugIns32Function · 0.85
SK_LoadLateImports32Function · 0.85
SK_LoadLazyImports32Function · 0.85
SK_Import_LoadImportNowFunction · 0.85

Calls 8

SK_ReShade_LoadDLLFunction · 0.85
SK_GetConfigPathFunction · 0.85
SK_GetModuleHandleWFunction · 0.85
SK_ReShadeAddOn_InitFunction · 0.85
get_value_strMethod · 0.80
c_strMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected