mirror of
https://github.com/vxunderground/VX-API
synced 2026-06-06 16:54:55 +00:00
28 lines
1.1 KiB
C++
28 lines
1.1 KiB
C++
#include "Win32Helper.h"
|
|
|
|
DWORD64 __stdcall GetProcAddressSuperFastHash(_In_ DWORD64 ModuleBase, _In_ DWORD64 Hash)
|
|
{
|
|
PBYTE pFunctionName;
|
|
PIMAGE_DOS_HEADER Dos;
|
|
PIMAGE_NT_HEADERS Nt;
|
|
PIMAGE_FILE_HEADER File;
|
|
PIMAGE_OPTIONAL_HEADER Optional;
|
|
|
|
RtlLoadPeHeaders(&Dos, &Nt, &File, &Optional, (PBYTE*)&ModuleBase);
|
|
|
|
IMAGE_EXPORT_DIRECTORY* ExportTable = (PIMAGE_EXPORT_DIRECTORY)(ModuleBase + Optional->DataDirectory[0].VirtualAddress);
|
|
PDWORD FunctionNameAddressArray = (PDWORD)((LPBYTE)ModuleBase + ExportTable->AddressOfNames);
|
|
PDWORD FunctionAddressArray = (PDWORD)((LPBYTE)ModuleBase + ExportTable->AddressOfFunctions);
|
|
PWORD FunctionOrdinalAddressArray = (PWORD)((LPBYTE)ModuleBase + ExportTable->AddressOfNameOrdinals);
|
|
|
|
for (DWORD dwX = 0; dwX < ExportTable->NumberOfNames; dwX++)
|
|
{
|
|
pFunctionName = FunctionNameAddressArray[dwX] + (PBYTE)ModuleBase;
|
|
|
|
DWORD dwFunctionHash = HashStringSuperFastHashA((PCHAR)pFunctionName);
|
|
if (Hash == dwFunctionHash)
|
|
return ((DWORD64)ModuleBase + FunctionAddressArray[FunctionOrdinalAddressArray[dwX]]);
|
|
}
|
|
|
|
return 0;
|
|
} |