I'm having an odd time trying to get the volume label of a disk image in C. I understand that for FAT12 disks this piece of information is located at offset 0x2b or 43 in decimal and is 11 bytes in length. Anyway here is my code right now:
void main(int argc, char *argv[]) {
...
FILE *fp = fopen(argv[1], "rb");
printf("Volume Label: %s\n", seekData(fp, 43, 11));
...
}
unsigned char* seekData(FILE *fp, int offset, int bytes) {
unsigned char* buff = malloc(sizeof(unsigned char)*bytes);
fseek(fp, offset, SEEK_SET);
fread(buff, 1, bytes, fp);
rewind(fp);
return buff;
}
For any input file I use (.IMA) I keep getting back 20 20 20 20 20 20 20 20 20 20 20
in hex. Or just Volume Label:(nothing here)
when the above code is run. Am I missing something super obvious here? Any help would be appreciated