MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / CustomGetModuleHandle

Function CustomGetModuleHandle

Source/Client/NM_Engine/ManualMap.cpp:49–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47};
48
49inline HMODULE CustomGetModuleHandle(const std::string & szModule)
50{
51 HMODULE hModule = NULL;
52 auto pPEB = GetCurrentPEB();
53 auto CurrentEntry = pPEB->LoaderData->InLoadOrderModuleList.Flink;
54
55 DEBUG_LOG(LL_TRACE, "\t[*] Searching for loaded module: %s", szModule.c_str());
56
57 while (CurrentEntry != &pPEB->LoaderData->InLoadOrderModuleList && CurrentEntry != NULL)
58 {
59 auto Current = CONTAINING_RECORD(CurrentEntry, _LDR_MODULE, InLoadOrderModuleList);
60
61 std::wstring wszCurrentModuleFullName(Current->FullDllName.Buffer, Current->FullDllName.Length / 2);
62 std::string szCurrentModuleFullName(wszCurrentModuleFullName.begin(), wszCurrentModuleFullName.end());
63
64 if (strcmp(szCurrentModuleFullName.c_str(), szModule.c_str()) == 0)
65 {
66 DEBUG_LOG(LL_TRACE, "Found in memory: %p", Current->BaseAddress);
67 hModule = (HMODULE)Current->BaseAddress;
68 break;
69 }
70
71 CurrentEntry = CurrentEntry->Flink;
72 }
73
74 if (!hModule)
75 hModule = g_winapiApiTable->LoadLibraryA(szModule.c_str());
76
77 if (!hModule)
78 {
79 DEBUG_LOG(LL_ERR, "Module can not loaded: %s", szModule.c_str());
80 return hModule;
81 }
82
83 return hModule;
84}
85
86inline FARPROC WINAPI CustomGetProcAddress(const HMODULE hModule, PCSTR lpProcName)
87{

Callers 1

ManualMapModuleMethod · 0.85

Calls 3

GetCurrentPEBFunction · 0.85
beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected