`

将字符串的转换为hash码

    博客分类:
  • VC++
阅读更多

#include "stdio.h"

void main()
{
 char* des=new char[100];
 printf("请输入函数名:\n");
 scanf("%s",des);
 printf("您要查找的函数为:%s\n",des);
 unsigned int ans=0;
_asm
{
 push des
 call gethash
 add esp,4
 mov ans,eax
 jmp mexit
gethash:
   push ebp
   mov ebp,esp
   push ebx
   push edx
   push ecx
   push edi
   mov ebx,[ebp+8]
   mov esi,ebx
   xor ebx,ebx
   xor edx,edx
   xor edi,edi
   xor eax,eax
b:   cmp dl,byte ptr [esi]
   jz a
   mov ecx,ebx
   shl ebx,25
   shr ecx,7
   or ebx,ecx
   mov al,byte ptr [esi]
   add ebx,eax
   inc esi
   jmp b
a:   
   mov eax,ebx
   pop edi
   pop ecx
   pop edx
   pop ebx
   mov esp,ebp
   pop ebp
   ret
mexit:

}
printf("ans=%8x\n",ans);
getchar();
getchar();
return;

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics