69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char **argv)
{
char filepath[256]={0};
unsigned int flag,off;
unsigned short int sflag;
char uch;
int i=0;
if(argc!=2)
{
puts("no filename!");
return -1;
}
FILE *fp=fopen(argv[1],"rb");
if(!fp)
{
puts("can not open file!");
return -1;
}
fread(&flag,4,1,fp);
if (flag!=0x4c)
{
puts("this is not a lnk file!");
fclose(fp);
return -1;
}
fseek(fp,0x14,SEEK_SET);
fread(&flag,4,1,fp);
fseek(fp,0x4c,SEEK_SET);
if(flag & 0x01)
{
fread(&sflag,2,1,fp);
fseek(fp,sflag,SEEK_CUR);
}
off = ftell(fp);
fseek(fp,off+0x10,SEEK_SET);
fread(&flag,4,1,fp);
fseek(fp,flag+off,SEEK_SET);
do
{
fread(&uch,1,1,fp);
filepath[i++]=uch;
}
while (uch!='\0');
fclose(fp);
printf("%s\n",filepath);
system("pause");
return 0;
}