This commit is contained in:
vxunderground
2022-09-10 13:20:38 -05:00
parent 8f5eca39d2
commit 86ca3658a5
143 changed files with 2396 additions and 1398 deletions
+49
View File
@@ -0,0 +1,49 @@
#include "Win32Helper.h"
HMODULE GetModuleHandleExA(LPCSTR lpModuleName)
{
PPEB Peb = GetPeb();
PLDR_MODULE Module = NULL;
CHAR wDllName[64] = { 0 };
PLIST_ENTRY Head = &Peb->LoaderData->InMemoryOrderModuleList;
PLIST_ENTRY Next = Head->Flink;
Module = (PLDR_MODULE)((PBYTE)Next - 16);
while (Next != Head)
{
Module = (PLDR_MODULE)((PBYTE)Next - 16);
if (Module->BaseDllName.Buffer != NULL)
{
ZeroMemoryEx(wDllName, sizeof(wDllName));
WCharStringToCharString(wDllName, Module->BaseDllName.Buffer, 64);
if (StringCompareA(lpModuleName, wDllName) == 0)
return (HMODULE)Module->BaseAddress;
}
}
return NULL;
}
HMODULE GetModuleHandleExW(LPCWSTR lpModuleName)
{
PPEB Peb = GetPeb();
PLDR_MODULE Module = NULL;
PLIST_ENTRY Head = &Peb->LoaderData->InMemoryOrderModuleList;
PLIST_ENTRY Next = Head->Flink;
Module = (PLDR_MODULE)((PBYTE)Next - 16);
while (Next != Head)
{
Module = (PLDR_MODULE)((PBYTE)Next - 16);
if (Module->BaseDllName.Buffer != NULL)
{
if (StringCompareW(lpModuleName, Module->BaseDllName.Buffer) == 0)
return (HMODULE)Module->BaseAddress;
}
Next = Next->Flink;
}
return NULL;
}