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

Function SK_Hook_PreCacheModule

src/hooks.cpp:376–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374
375
376sk_hook_cache_enablement_s
377SK_Hook_PreCacheModule ( const wchar_t *wszModuleName,
378 sk_hook_cache_array &local_cache,
379 sk_hook_cache_array &global_cache,
380 iSK_INI *ini )
381{
382 if (ini == nullptr)
383 return {};
384
385 if (__SK_bypass)
386 return sk_hook_cache_enablement_s { };
387
388 UNREFERENCED_PARAMETER (global_cache);
389
390 std::wstring ini_name = std::wstring (wszModuleName) +
391 L".Hooks";
392 sk_hook_cache_enablement_s cache_state =
393 SK_Hook_IsCacheEnabled (ini_name.c_str (), ini);
394
395 // This first pass will iterate over any records in the DLL's shared
396 // data segment (for global injection).
397 //
398 if ( SK_IsInjected () && cache_state.use_cached_addresses.global )
399 {
400 auto it_global = global_cache.begin ();
401
402 for ( auto& it : local_cache )
403 {
404 it->active = false;
405
406 if ((*it_global)->target.addr != nullptr)
407 {
408 LPVOID target_addr = (*it_global)->target.addr;
409
410 it->target.addr = nullptr;
411
412 if (SK_Modules->LoadLibraryLL (it->target.module_path))
413 {
414 // If hot-patched, then don't bother
415 if (! SKX_IsHotPatchableAddr (target_addr))
416 {
417 SK_LOG1 ( ( L"Discarding global address for '%50hs' (not hot patched)",
418 it->target.symbol_name ),
419 L"Hook Cache" );
420
421 ++it_global;
422
423 continue;
424 }
425
426 SK_LOG0 ( ( L"Trying global address for '%50hs' :: '%72s'"
427 L" { Last seen in '%s' }",
428 it->target.symbol_name,
429 SK_MakePrettyAddress ( target_addr).c_str (),
430 SK_ConcealUserDir (
431 std::wstring (it->target.module_path).data ()) ),
432 L"Hook Cache" );
433

Callers 3

SK_DXGI_QuickHookFunction · 0.85
SK_D3D9_QuickHookFunction · 0.85
SK_D3D11_QuickHookFunction · 0.85

Calls 11

SK_Hook_IsCacheEnabledFunction · 0.85
SK_IsInjectedFunction · 0.85
SKX_IsHotPatchableAddrFunction · 0.85
SK_MakePrettyAddressFunction · 0.85
MH_CreateHookFunction · 0.85
SK_QueueEnableHookFunction · 0.85
SK_Hook_PredictTargetFunction · 0.85
LoadLibraryLLMethod · 0.80
c_strMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected