直接上代码:
void ccpCommand(unsigned char *com )
{
unsigned char a[4]; //用于观察形参的值是否正确
a[0]=com[2];
a[1]=com[3];
a[2]=com[4];
a[3]=com[5];
ccp.ProtectionStatus |= ccpUnlock(&com[2]);
}
函数中调用的ccpUnlock函数定义如下:
unsigned char ccpUnlock( unsigned char *key )
{
unsigned long temp;
ccpLastSeed = 0x4f833483;
temp = *(unsigned long *)key;
if ( temp != ccpLastSeed )
{
return 0;
}
return 1;
}
通过观察a数组,发现数组元素的值分别为
a[0]=0x83;
a[1]=0x34;
a[2]=0x83;
a[3]=0x4f;
通过调用ccpUnlock函数,得到的temp应该和ccpLastSeed值相等,都是0x4f833483,返回的应该是1,可是通过观察,
temp的值居然是0,导致函数返回值为0.后面的操作就都错了。 |