Advertisement
fernandop

struct_sizes.c

Nov 4th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. // set struct alignment in memory to 1 byte
  5. #pragma pack(push, 1)
  6.  
  7. typedef struct _FAT32_BOOTSECTOR
  8. {
  9.     uint8_t jmp[3];
  10.     int8_t OemName[8];
  11.     uint16_t BytesPerSector;
  12.     uint8_t SectorsPerCluster;
  13.     uint16_t ReservedSectors;
  14.     uint8_t NumberOfFATs;
  15.     uint16_t RootEntries;
  16.     uint16_t TotalSectors;
  17.     uint8_t Media;
  18.     uint16_t SectorsPerFAT;
  19.     uint16_t SectorsPerTrack;
  20.     uint16_t HeadsPerCylinder;
  21.     uint32_t HiddenSectors;
  22.     uint32_t BigTotalSectors;
  23.     uint32_t BigSectorsPerFAT;
  24.     uint16_t Flags;
  25.     uint16_t Version;
  26.     uint32_t RootCluster;
  27.     uint16_t InfoSector;
  28.     uint16_t BootBackupStart;
  29.     uint8_t Reserved[12];
  30.     uint8_t DriveNumber;
  31.     uint8_t Unused;
  32.     uint8_t ExtBootSignature;
  33.     uint32_t SerialNumber;
  34.     int8_t VolumeLabel[11];
  35.     int8_t FileSystem[8];
  36.     uint8_t BootCode[422];
  37. } FAT32_BOOTSECTOR;
  38.  
  39. #pragma pack(pop)
  40.  
  41. typedef struct _FAT32_BOOTSECTOR_2
  42. {
  43.     uint8_t jmp[3];
  44.     int8_t OemName[8];
  45.     uint16_t BytesPerSector;
  46.     uint8_t SectorsPerCluster;
  47.     uint16_t ReservedSectors;
  48.     uint8_t NumberOfFATs;
  49.     uint16_t RootEntries;
  50.     uint16_t TotalSectors;
  51.     uint8_t Media;
  52.     uint16_t SectorsPerFAT;
  53.     uint16_t SectorsPerTrack;
  54.     uint16_t HeadsPerCylinder;
  55.     uint32_t HiddenSectors;
  56.     uint32_t BigTotalSectors;
  57.     uint32_t BigSectorsPerFAT;
  58.     uint16_t Flags;
  59.     uint16_t Version;
  60.     uint32_t RootCluster;
  61.     uint16_t InfoSector;
  62.     uint16_t BootBackupStart;
  63.     uint8_t Reserved[12];
  64.     uint8_t DriveNumber;
  65.     uint8_t Unused;
  66.     uint8_t ExtBootSignature;
  67.     uint32_t SerialNumber;
  68.     int8_t VolumeLabel[11];
  69.     int8_t FileSystem[8];
  70.     uint8_t BootCode[422];
  71. } FAT32_BOOTSECTOR_2;
  72.  
  73. int main(int argc, char *argv[])
  74. {
  75.     printf("FAT32_BOOTSECTOR (1-byte aligned) size: %lu\n", sizeof(FAT32_BOOTSECTOR));
  76.     printf("FAT32_BOOTSECTOR_2 size: %lu\n", sizeof(FAT32_BOOTSECTOR_2));
  77.  
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement