monoxgas / sRDI

Shellcode implementation of Reflective DLL Injection. Convert DLLs to position independent shellcode
Other
2.1k stars 456 forks source link

Exported function name hash calculation is not right #11

Closed Moriarty2016 closed 6 years ago

Moriarty2016 commented 6 years ago

I pick out the hash calculation snippet from FunctionTest.cpp, and recreate a project with it, code as below:

include "stdafx.h"

include

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 6 years ago

Problem solved, My fault:-)