LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 761|回复: 0

关于内核较验的问题,请诸位大侠看看,谢谢!!

[复制链接]
发表于 2005-3-27 13:14:06 | 显示全部楼层 |阅读模式
关于内核较验的问题,请诸位大侠看看,谢谢!!

我想做对内核的CRC较验,拿一个为例来作即可:
ftp://ftp.arca.com.cn/pub/Arca-P ... .18/binary/vm-draco
编写了如下的测试程序,但是不能起作用.不知该如何解决,代码贴在下面:
///////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#define KERNEL_SIZE 14911305 //bytes,此处大小应为实际大小.
int main(int argc,char *argv[])
{
unsigned char *crc_input=malloc(sizeof(char)*KERNEL_SIZE+1);
unsigned long crc_output;
FILE *fp;
int i;
if (!crc_input){
printf("out of memory. \n");
exit(1);
}

if((fp=fopen("vm-draco","rb"))==NULL){
printf("Cannot open file. \n");
exit(1);
}
fseek(fp,0,SEEK_SET);
fread(crc_input,sizeof(char),KERNEL_SIZE,fp);
crc_input[KERNEL_SIZE]=0;
fclose(fp);
//crc_input="polynomial";
crc_output=crc32(crc_input,KERNEL_SIZE); //用的CRC32函数为Linux源码中所带的算法.在此不列了.
printf("the crc_input is : 0x%x \n",crc_input);
printf("the length of crc_input is: %d \n",strlen(crc_input));
printf("the crc_output is :0x%x\n",crc_output);

free(crc_input);
return 0;
}
////////////////////////////////////
结果为:
the crc_input is : 0x40029008
the length of crc_input is: 7
the crc_output is : 0xa4ae400c

1:为什么显示crc_input为7?
2:在windows下用了几个CRC较验工具来测,得到结果都为 0x7adfb959.
如果上面的方法不对,那怎样才能得到内核的CRC值呢/?

请诸位大侠帮忙看看,这对我真的很重要,非常感谢!!!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表