c - How to parse raw "disk" data? -


the output below belongs fat32 disk file. want display files , corresponding allocated sectors each file, c program.

i'm unable find root directory following guide. (example 1 - find root directory in http://www.tavi.co.uk/phobos/fat.html) seems 0x16 , 0x17 00. don't point anything?

i'm reading document again , again , i'm exhausted. can explain i'm doing wrong, or how right simple steps?

any appreciated! thank you.

alternative resource: http://wiki.osdev.org/fat#fat_32_2

0000000: eb58 906d 6b66 732e 6661 7400 0201 2000  .x.mkfs.fat... . 0000010: 0200 0000 00f8 0000 2000 4000 0000 0000  ........ .@..... 0000020: 400d 0300 0306 0000 0000 0000 0200 0000  @............... 0000030: 0100 0600 0000 0000 0000 0000 0000 0000  ................ 0000040: 8000 29c8 a726 5e4e 4f20 4e41 4d45 2020  ..)..&^no name   0000050: 2020 4641 5433 3220 2020 0e1f be77 7cac    fat32   ...w|. 0000060: 22c0 740b 56b4 0ebb 0700 cd10 5eeb f032  ".t.v.......^..2 0000070: e4cd 16cd 19eb fe54 6869 7320 6973 206e  .......this n 0000080: 6f74 2061 2062 6f6f 7461 626c 6520 6469  ot bootable di 0000090: 736b 2e20 2050 6c65 6173 6520 696e 7365  sk.  please inse 00000a0: 7274 2061 2062 6f6f 7461 626c 6520 666c  rt bootable fl 00000b0: 6f70 7079 2061 6e64 0d0a 7072 6573 7320  oppy and..press  00000c0: 616e 7920 6b65 7920 746f 2074 7279 2061  key try 00000d0: 6761 696e 202e 2e2e 200d 0a00 0000 0000  gain ... ....... 00000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000100: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000110: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000120: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000140: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000150: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000160: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000170: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000180: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000190: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00001a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00001b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00001c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00001d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............u. 0000200: 5252 6141 0000 0000 0000 0000 0000 0000  rraa............ 0000210: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000220: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000230: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000240: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000250: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 0000260: 0000 0000 0000 0000 0000 0000 0000 0000  ................ .... 

i used these create file:

dd if=/dev/zero of=disk.img bs=1k count=100000 losetup /dev/loop0 disk.img mkdosfs -s 1 -f 32 /dev/loop0 100000 

i'm unable find root directory following guide. (example 1 - find root directory in http://www.tavi.co.uk/phobos/fat.html) seems 0x16 , 0x17 00. don't point anything?

the mentioned document talks fat16, doesn't apply fat32 file system; refer alternative resource instead.
according that, size of fat in sectors @ offset 36 (= 0x24, start of standard boot record) length 4 (in bytes); in c, access (assuming there's unsigned char *fat32fs pointing boot record, , you're on little-endian system) e. g.

#include <stdint.h>     uint32_t fatsectors = *(uint32_t *)&fat32fs[36]; 

in example file, size 0x00000603 (= 1539).


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -