mirror of
https://github.com/vxunderground/VX-API
synced 2024-06-30 18:51:17 +00:00
27 lines
1.0 KiB
C++
27 lines
1.0 KiB
C++
DWORD64 __stdcall GetProcAddressRotr32(DWORD64 ModuleBase, 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 = HashStringRotr32A((PCHAR)pFunctionName);
|
|
if (Hash == dwFunctionHash)
|
|
return ((DWORD64)ModuleBase + FunctionAddressArray[FunctionOrdinalAddressArray[dwX]]);
|
|
}
|
|
|
|
return 0;
|
|
}
|