Skip to content

Commit 0440e46

Browse files
committed
fat32 direntry search, ntfs INDX size fix
1 parent 358b8c1 commit 0440e46

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

indx3.c

+20-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ void parseindx(unsigned char* p){
5757
time_t timep=(unsigned int)t;
5858
struct tm *tt=localtime(&timep);
5959

60-
unsigned long long fs=*((unsigned long long*)(p+o+0x40));
60+
unsigned long long fs=*((unsigned long long*)(p+o+0x40)) & 0x0000FFFFFFFFFFFFLL;;
6161
int nl=p[o+0x50];
6262
if(n!=0x10 || nl>0){
63-
printf("%04X entry T=%8lld (%d.%02d.%02d) size=%d size=%dMB name=0x%X (%d) ",o,t,
64-
1900+tt->tm_year,1+tt->tm_mon,tt->tm_mday, s,(int)(fs/(1024*1024)),n,nl);
63+
printf("%04X entry T=%8lld (%d.%02d.%02d) size=%d size=%dkB name=0x%X (%d) ",o,t,
64+
1900+tt->tm_year,1+tt->tm_mon,tt->tm_mday, s,(int)(fs/(1024)),n,nl);
6565
// printf("%04X entry T=%8lld (%s) size=%d size=%dMB name=0x%X (%d) ",o,t,
6666
// ctime(&timep), s,(int)(fs/(1024*1024)),n,nl);
6767
for(i=0;i<nl;i++) putchar(p[o+0x52+2*i]);
@@ -313,8 +313,23 @@ int main(){
313313

314314
//A_mbr_ntfs5P.img B_ntfs2.img C_ntfs1.img D_ntfs3.img E_mbr_ntfs4.img
315315

316-
FILE* f=fopen("/dev/sda","rb");
317-
//FILE* f=fopen("/home/sda_orig.img","rb");
316+
//FILE* f=fopen("/dev/sda","rb");
317+
FILE* f=fopen("raw2.img","rb");
318+
319+
320+
#if 0
321+
// search for FAT16/FAT32 directory entries:
322+
// https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#Directory_table
323+
while(fread(buffer,32,1,f)>0){
324+
int i;
325+
// if(buffer[8]=='P' && buffer[9]=='D' && buffer[10]=='F'){
326+
if(buffer[8]=='J' && buffer[9]=='P' && buffer[10]=='G'){
327+
for(i=0;i<8+3;i++) if(buffer[i]<32) break;
328+
if(i==8+3) printf("%.8s.%.3s\n",buffer,buffer+8);
329+
}
330+
}
331+
#endif
332+
318333

319334
//fseek(f,0x186A000000LL,0);
320335
//fseek(f,0x3FFC43000LL,0);

0 commit comments

Comments
 (0)