Mail Archives: djgpp/1996/10/25/01:01:16
Jon Slaughter <lobo AT iamerica DOT net> wrote:
>here is some code that is supose to read the boot sector and print out
>all the information in BOOT_RECORD. But for some reason, it doesn't :( I
>have no idea why. It would seem that I left some variable out of the
>structure because the first two are ok, but I've looked over it and
>couldn't find anything wrong. It also could be the strings since I have
>no idea of how c handles them(except that they are null terminated)...
>Its probably something stupid, but if anyone can help me, please!!
You need to pack the structure, otherwise the fields doesn't get
aligned right, due to padding.
struct BOOT_RECORD_STRUCT {
BYTE jump[3];
BYTE oem_name[8];
WORD bytes_per_sector;
BYTE sectors_per_cluster;
WORD number_of_reserved_sectors;
BYTE number_of_fats;
WORD number_of_root_dir_entries;
WORD number_of_total_sectors;
BYTE media_descriptor_byte;
WORD sectors_per_fat;
WORD sectors_per_track;
WORD number_of_heads;
WORD number_of_hidden_sectors1;
WORD number_of_hidden_sectors2;
DWORD number_of_sectors;
BYTE physical_drive_number;
BYTE reserved;
BYTE signature_byte;
DWORD volume_serial_number;
BYTE volume_label[11];
BYTE fat_type_char_str[8];
BYTE filler[500];
} __attribute__((packed)); /* <=== important */
- Raw text -