Exported function name hash calculation is not right
Moriarty2016 opened this issue · 1 comments
Moriarty2016 commented
I pick out the hash calculation snippet from FunctionTest.cpp, and recreate a project with it, code as below:
#include "stdafx.h"
#include <Windows.h>
#define ROTR32(value, shift) (((DWORD) value >> (BYTE) shift) | ((DWORD) value << (32 - (BYTE) shift)))
DWORD HashFunctionName(LPSTR name) {
DWORD hash = 0;
do
{
hash = ROTR32(hash, 13);
hash += *name;
name++;
} while (*(name - 1) != 0);
return hash;
}
int main(int argc, char **argv)
{
if (argc == 2) {
printf("0x%x\n", HashFunctionName(argv[1]));
}
return 0;
}
The output is clearly not right, what's wrong?
Moriarty2016 commented
Problem solved, My fault:-)