x64下Hash获取Kernel32基地址
一丶 工程代码
代码中包含x64Asm 其中函数也是可以算hash的.自己写asm遍历导出表即可.
1.主要代码
代码语言:javascript复制extern "C" long long _readgsqword(long long ReadValue);
extern "C" void * _GetLdrDataTableEntry();
map<DWORD, char*> m_HashProcMap; //记录导出表名字以及Hash值
vector<DWORD> m_ProcHash; //记录函数的Hash值
typedef struct _UNICODE_STRING {
unsigned short length;
unsigned short Maximumlength;
wchar_t* Buffer;
}UNICODE_STRING,*PUNICODE_STRING;
typedef struct _LDR_DATA_TABLE_ENTRY
{
LIST_ENTRY InLoadOrderLinks;
LIST_ENTRY InMemoryOrderLinks;
LIST_ENTRY InInitializationOrderLinks;
PVOID DllBase;
PVOID EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
ULONG Flags;
WORD LoadCount;
WORD TlsIndex;
} LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;
DWORD _ROR32(unsigned int Value, unsigned int shift)
{
//0X12345678 << 24 LOW >> 24 = HIGHT
shift &= 31;
unsigned int LowByte = (Value << 24) & 0xFF000000;
unsigned int HighByte = (Value >> (shift));
unsigned int Result = LowByte | HighByte;
return Result;
}
long long GetProcHashValue(char* Names)
{
if (Names == nullptr)
return 0;
auto HashValue = 0u;
while (*Names !='