MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / GetModuleHandle_Ldr

Method GetModuleHandle_Ldr

Process/Process.cpp:831–864  ·  view source on GitHub ↗

GetModuleHandle_Ldr - returns base address of a module as HMODULE type returns NULL on failure */

Source from the content-addressed store, hash-verified

829 returns NULL on failure
830*/
831HMODULE Process::GetModuleHandle_Ldr(__in const wchar_t* moduleName)
832{
833#ifdef _M_IX86
834 MYPEB* peb = (MYPEB*)__readfsdword(0x30);
835#else
836 MYPEB* peb = (MYPEB*)__readgsqword(0x60);
837#endif
838
839 uintptr_t kernel32Base = 0;
840
841 LIST_ENTRY* current_record = NULL;
842 LIST_ENTRY* start = &(peb->Ldr->InLoadOrderModuleList);
843
844 current_record = start->Flink;
845
846 while (true)
847 {
848 MY_LDR_DATA_TABLE_ENTRY* module_entry = (MY_LDR_DATA_TABLE_ENTRY*)CONTAINING_RECORD(current_record, MY_LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
849
850 current_record = current_record->Flink;
851
852 if (wcsstr(module_entry->FullDllName.Buffer, moduleName) != NULL)
853 {
854 return (HMODULE)module_entry->DllBase;
855 }
856
857 if (current_record == start)
858 {
859 return (HMODULE)NULL;
860 }
861 }
862
863 return (HMODULE)NULL;
864}
865
866DWORD Process::GetSectionSize(__in const HMODULE hModule, __in const std::string section)
867{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected