From: ovek AT arcticnet DOT no (Ove Kåven) Newsgroups: comp.os.msdos.djgpp Subject: Re: source code help Date: Thu, 24 Oct 1996 13:57:16 GMT Organization: Vplan Programvare AS Lines: 39 Message-ID: <54p01c$q17@troll.powertech.no> References: <326EBDEE DOT 4ED AT iamerica DOT net> NNTP-Posting-Host: alwayscold.darkness.arcticnet.no To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Jon Slaughter 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 */