unsigned long string_id(const char *str)
{
int i;
unsigned int v;
static unsigned m[70]; //m[70]为静态无符号整型,所以占用280个字节
strncpy((char *)m,str,256); //复制str中最多256个字符到m[70]中
for (i=0;i<256/4 && m[i];i++); //此处为什么加分号,循环条件:“i<64”与“m[i]!=0”
m[i++]=0x9BE74448,m[i++]=0x66F42C48;
v=0xF4FA8928;
__asm //感觉这个函数像CRC
{
mov esi,0x37A8470E //x0=0x37A8470E
mov edi,0x7758B42B //y0=0x7758B42B
xor ecx,ecx //用到了循环,所以清空ecx寄存器
_loop:
mov ebx,0x267B0B11 //w=0x267B0B11
rol v,1 //循环左移1位,并把最高位放入CF
lea eax,m //取地址
xor ebx,v //w^v
mov eax,[eax+ecx*4] //m[j]
mov edx,ebx //w^v
xor esi,eax //m[j]^x0
xor edi,eax //m[j]^y0
add edx,edi //(w^v)+(m[j]^y0)
or edx,0x2040801 //a=0x02040801,((w^v)+(m[j]^y0))|a
and edx,0xBFEF7FDF //c=0xBFEF7FDF,(((w^v)+(m[j]^y0))|a)&c
mov eax,esi //m[j]^x0
mul edx //((((w^v)+(m[j]^y0))|a)&c)*(m[j]^x0)
adc eax,edx //
mov edx,ebx //w^v
adc eax,0 //
add edx,esi //(w^v)+(m[j]^x0)
or edx,0x804021 //b=0x00804021,((w^v)+(m[j]^x0))|b
and edx,0x7DFEFBFF //d=0x7DFEFBFF,(((w^v)+(m[j]^x0))|b)&d
mov esi,eax //
mov eax,edi //m[j]^y0
mul edx //((((w^v)+(m[j]^x0))|b)&d)*(m[j]^y0)
add edx,edx
adc eax,edx
jnc _skip //CF=0则跳到_skip
add eax,2
_skip:
inc ecx; //ecx++
mov edi,eax
cmp ecx,i //如果ecx<i,那么ZF!=0就继续循环
jnz _loop //ZF!=0则跳到_loop
xor esi,edi
mov v,esi //此v即FILE_LST结构中的uid
}
return v;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课