这段程序的功能是什么?
#include <stdio.h>
#include <string.h>
#define M 65279
int main(int argc,char **argv)
{
FILE *fp,*fp1;
char c;
char ch;
int i=1,k=256;
long lenth;
if(argc==1)
{
printf( " <Usage:e2b.exe a.exe b.bat> \n ");
exit(0);
}
if((fp=fopen(argv[1], "rb "))==NULL)
{
printf( "Can 't open the file %s.\n ",argv[1]);
exit(0);
}
if((fp1=fopen(argv[2], "w+ "))==NULL)
{
printf( "Can 't create the file %s.\n ",argv[2]);
exit(0);
}
fseek(fp,0,SEEK_END);
lenth=ftell(fp);
fseek(fp,0,SEEK_SET);
printf( "%ld,%x\n ",lenth,lenth);
if(lenth> =M)
{
printf( "The exe file 's lenth must be <= M-1\n ");
exit(0);
}
fputs( "@echo e ",fp1);
fprintf(fp1, "%04x ",k);
while(!feof(fp))
{
k++;
c = fgetc(fp);
if((unsigned char )c <=(unsigned char)15)
fprintf(fp1, "0 ",c);
fprintf(fp1, "%x ",(unsigned char)c);
if(i%16==0)
{
fputs( "> > sgl\n ",fp1);
fputs( "@echo e ",fp1);
fprintf(fp1, "%04x ",k);
}
i++;
}
if(lenth%16!=0)
fputs( "> > %tmp%\\sgl\n ",fp1);
fputs( "@echo rcx> > sgl\n ",fp1);
fprintf(fp1, "@echo %x> > sgl\n ",lenth,fp1);
fputs( "@echo n tthacker> > sgl\n ",fp1);
fputs( "@echo w> > sgl\n ",fp1);
fputs( "@echo q> > sgl\n ",fp1);
fputs( "@debug <sgl> nul\n ",fp1);
fputs( "@del sgl\n ",fp1);
fputs( "@ren tthacker ",fp1);
fprintf(fp1, "%s> > sgl\n ",argv[1]);
fputs( "@ ",fp1);
fprintf(fp1, "%s ",argv[1]);
fclose(fp);
fclose(fp1);
printf( "done.\n ");
}
------解决方案--------------------
exe转bat文件