首页| 论坛| 消息
主题:Office文档修复原理
1直在努力发表于 2010-02-04 17:39
);
if(root_list == -2) break;
}
if(len >= MAXBLOCKS) fprintf(stderr,"Help too many root blocks\n");
Root =(char *) malloc(512*len);
s = Root;
/* Read in Root stream data */
for(i=0; i Input file has faulty OLE format\n");
return 5;
}
s += 0x200;
}

/* assign space for pps list */
pps_list = (pps_entry **)malloc(len*4*sizeof(pps_entry *));
for(j=0; jindex = j;
s = Root+(j*0x80);
/* some pps names have first byte as an integer !!
so we make it visible so you can extract a named pps */
if(!isprint(*s)) *s = *s + 48;

pps_list->nsize=ShortInt(s+0x40);
if(pps_list->nsize == 0) continue;
for(p=pps_list->name,t=s; tnsize; t++) *p++ = *t++;
s+=0x42;
pps_list->type = *s;
if(pps_list->type == 5) {
root_entry = j; /* this is root */
}
s+=0x02;
linkto = LongInt(s);
if(linkto != -1) pps_list->previous = pps_list;
else pps_list->previous = NULL;
s+=0x04;
linkto = LongInt(s);
if(linkto != -1) pps_list->next = pps_list;
else pps_list->next = NULL;
s+=0x04;
linkto = LongInt(s);
if(linkto != -1) pps_list->directory = pps_list;
else pps_list->directory = NULL;
s+=0x28;
pps_list->start = LongInt(s);
s+=0x04;
pps_list->size = LongInt(s);
}

/* go through the pps entries, tagging them with level number
use recursive routine to follow list starting at root entry */

unravel(pps_list,0);

/* go through the level 0 list looking for named entries */
for(j=0; jnsize == 0) continue; /* skip empty pps */
/* we mostly only want the top level (level 1) stuff, so
here we skip anything more deeply nested. */
if(pps_list->level > 1) continue;
pps_start = pps_list->start;
pps_size = pps_list->size;
OLEfile = NULL;
if(pps_list->type == 5) { /* Root entry */
OLEfile = tmpfile();
sbfile = OLEfile;
if(debug) fprintf(stderr,"Reading sbFile %ld\n",pps_start);
}
else if(!strcmp(pps_list->name, Target)) {
OLEfile=fopen("OLE.tmp","w+b"); /* try and open */
printf("Reading Target %s\n", Target);
}
if(pps_size=4096 | OLEfile==sbfile) {
Offset = 1;
BlockSize = 512;
infile = input;
Depot = BDepot;
} else {
Offset = 0;
BlockSize = 64;
infile = sbfile;
Depot = SDepot;
}
while(pps_start != -2) {
if(debug) fprintf(stderr,"Reading block %ld\n",pps_start);
FilePos = (pps_start+Offset)* BlockSize;
bytes = MIN(BlockSize,pps_size);
fseek(infile,FilePos,SEEK_SET);
if(fread(Block,bytes,1,infile) != 1) {
fprintf(stderr,"5 =========> Input file has faulty OLE format\n");
exit (5);
}
fwrite(Block,bytes,1,OLEfile);
pps_start = LongInt(Depot+(pps_start*4));
pps_size -= BlockSize;
if(pps_size
下一页上一页  (2/4)
回帖(39):
39楼:Office文档是平常最重要、最普遍的需要修复文件
38楼:谢谢老师谢谢老师谢谢老师
37楼:学习下,看看是否有用先!

全部回帖(39)»
最新回帖
收藏本帖
发新帖