EDIT: (secid + 1) * 512 should be (secid + 1) * sec_size
hi.
having a bit of a struggle wrestling with the compound document format. I'm working in C at the moment but i am having problems with locating the directory sector. I can obtain the compound doc header which is trivial and i know the formula for finding a file offset of a sector id ( secid + 1 << sec_size), but whenever i use this formula to convert the secid to fileoffset for the directory i get random values. can someone help me understand how i resolve secid offsets properly and maybe also how to develop secid chains from the sector allocation table in a compound document.
Thanks.
Here is an example of what ive tried.(excuse the awful code lol)
comp_doc_header* cdh((comp_doc_header*)buffer);
printf("cdoc header:%d\n", sizeof(cd_dir_entry));
if(cdh->rev_num == 0x003E)printf("rev match\n");
//check magic number
if(cdh->comp_doc_id[0] != (unsigned char)0xD0 ||
cdh->comp_doc_id[1] != (unsigned char)0xCF ||
cdh->comp_doc_id[2] != (unsigned char)0x11 ||
cdh->comp_doc_id[3] != (unsigned char)0xE0 ||
cdh->comp_doc_id[4] != (unsigned char)0xA1 ||
cdh->comp_doc_id[5] != (unsigned char)0xB1 ||
cdh->comp_doc_id[6] != (unsigned char)0x1A ||
cdh->comp_doc_id[7] != (unsigned char)0xE1)
return 0;
buffer += 512;
//here i try and get the first directory entry
cd_dir_entry* cde((cd_dir_entry*)&buffer[(cdh->first_sector_id + 1) << 512]);