MCPcopy Create free account
hub / github.com/NtQuery/Scylla / findApiByModule

Method findApiByModule

Scylla/ApiReader.cpp:470–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470void ApiReader::findApiByModule(ModuleInfo * module, char * searchFunctionName, WORD ordinal, DWORD_PTR * vaApi, DWORD_PTR * rvaApi)
471{
472 if (isModuleLoadedInOwnProcess(module))
473 {
474 HMODULE hModule = GetModuleHandle(module->getFilename());
475
476 if (hModule)
477 {
478 if (vaApi)
479 {
480 if (ordinal)
481 {
482 *vaApi = (DWORD_PTR)GetProcAddress(hModule, (LPCSTR)ordinal);
483 }
484 else
485 {
486 *vaApi = (DWORD_PTR)GetProcAddress(hModule, searchFunctionName);
487 }
488
489 *rvaApi = (*vaApi) - (DWORD_PTR)hModule;
490 *vaApi = (*rvaApi) + module->modBaseAddr;
491 }
492 else
493 {
494#ifdef DEBUG_COMMENTS
495 Scylla::debugLog.log(L"findApiByModule :: vaApi == NULL, should never happen %S", searchFunctionName);
496#endif
497 }
498 }
499 else
500 {
501#ifdef DEBUG_COMMENTS
502 Scylla::debugLog.log(L"findApiByModule :: hModule == NULL, should never happen %s", module->getFilename());
503#endif
504 }
505 }
506 else
507 {
508 //search api in extern process
509 findApiInProcess(module,searchFunctionName,ordinal,vaApi,rvaApi);
510 }
511}
512
513bool ApiReader::isModuleLoadedInOwnProcess(ModuleInfo * module)
514{

Callers

nothing calls this directly

Calls 2

getFilenameMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected