当前位置: 代码迷 >> C语言 >> 至今还没有解决的C语言问题
  详细解决方案

至今还没有解决的C语言问题

热度:193   发布时间:2008-02-15 11:18:43.0
至今还没有解决的C语言问题
至今还没有解决的C语言问题.

#define VALLEN 2
#include"stdio.h"
#include"dir.h"
#include"string.h"
#include"dos.h"
FILE *fp;
struct ffblk ffb,dirment;
char driver,curdriver,path[MAXDIR],curpath[MAXDIR];
unsigned char curval[VALLEN],saveval[VALLEN];
int p,status=0;
void pathm(void);
void dirm(void);
void scan(void);
void log(void);
main(int argc,char *argv[])
{
if(!stricmp(argv[2],"/b")||!stricmp(argv[2],"/B"))
status=0;
else if(!stricmp(argv[2],"/s")||!stricmp(argv[2],"/S"))
status=1;
curdriver=getdisk();
getcwd(curpath,MAXDIR);
driver=toupper(argv[1][0])-'A';
setdisk(driver);
chdir(argv[1]);
strcpy(dirment.ff_name,argv[1]);
pathm();
setdisk(curdriver);
chdir(curpath);
exit(0);
}


void pathm()
{
dirm();
getcwd(path,MAXDIR);
p=findfirst("*.*",&dirment,0x3f);
if(!p&&dirment.ff_name[0]=='.')
{
p=findnext(&dirment);
p=findnext(&dirment);
}
while(!p)
{
if((dirment.ff_attrib&0x10)==FA_DIREC)
{
chdir(dirment.ff_name);
dirm();
chdir(path);
}
p=findnext(&dirment);
}
}

void dirm()
{
int done;
printf("Scanning directory %s\n",dirment.ff_name);
done=findfirst("*.*",&ffb,0);
while(!done)
{
if(strstr(ffb.ff_name,".COM")||strstr(ffb.ff_name,".EXE"))
{
fp=fopen(ffb.ff_name,"rb+");
switch(status)
{
case 0:log();break;
case 1:scan();break;
}
}
done=findnext(&ffb);
}
}

void scan()
{
int i;
printf("Scanning %s\n",ffb.ff_name);
fseek(fp,1,SEEK_SET);
fread(curval,VALLEN,1,fp);
fseek(fp,VALLEN,SEEK_END);
fread(saveval,VALLEN,1,fp);
for(i=0;i<VALLEN;i++)
if(curval!=saveval)
{
printf("File %s was changed!\n",ffb.ff_name);
break;
}
fclose(fp);
}

void log()
{
fseek(fp,1,SEEK_SET);
fread(curval,VALLEN,1,fp);
fseek(fp,0,SEEK_END);
fwrite(curval,VALLEN,1,fp);
fclose(fp);
printf("%s loginned!\n",ffb.ff_name);
}


据说是病毒扫描修复程序源代码

但是并不明白这程序到底有什么做用?它实现的效果是什么?有大哥能帮助么?
搜索更多相关的解决方案: C语言  

----------------解决方案--------------------------------------------------------
好东西稍微能看懂一点但还不行
期待强人
顶了
----------------解决方案--------------------------------------------------------
  相关解决方案