mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Smbios: add struct layout check
This commit is contained in:
@@ -154,8 +154,6 @@ static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef struct FFSmbiosPortableBattery
|
||||
{
|
||||
FFSmbiosHeader Header;
|
||||
@@ -178,7 +176,10 @@ typedef struct FFSmbiosPortableBattery
|
||||
uint8_t SbdsDeviceChemistry; // string
|
||||
uint8_t DesignCapacityMultiplier; // varies
|
||||
uint16_t OEMSpecific; // varies
|
||||
} FFSmbiosPortableBattery;
|
||||
} __attribute__((__packed__)) FFSmbiosPortableBattery;
|
||||
|
||||
static_assert(offsetof(FFSmbiosPortableBattery, OEMSpecific) == 0x16,
|
||||
"FFSmbiosPortableBattery: Wrong struct alignment");
|
||||
|
||||
const char* detectBySmbios(FFBatteryResult* battery)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ typedef struct FFSmbiosBios
|
||||
uint16_t BiosStartingAddressSegment; // varies
|
||||
uint8_t BiosReleaseDate; // string
|
||||
uint8_t BiosRomSize; // string
|
||||
uint32_t BiosCharacteristics; // bit field
|
||||
uint64_t BiosCharacteristics; // bit field
|
||||
|
||||
// 2.4+
|
||||
uint8_t BiosCharacteristicsExtensionBytes[2]; // bit field
|
||||
@@ -46,7 +46,10 @@ typedef struct FFSmbiosBios
|
||||
|
||||
// 3.1+
|
||||
uint16_t ExtendedBiosRomSize; // bit field
|
||||
} FFSmbiosBios;
|
||||
} __attribute__((__packed__)) FFSmbiosBios;
|
||||
|
||||
static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18,
|
||||
"FFSmbiosBios: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectBios(FFBiosResult* bios)
|
||||
{
|
||||
|
||||
@@ -14,9 +14,12 @@ typedef struct FFSmbiosBaseboard
|
||||
uint8_t LocationInChassis; // string
|
||||
uint16_t ChassisHandle; // varies
|
||||
uint8_t BoardType; // enum
|
||||
uint8_t NumberOfContainedObjectHandle; // varies
|
||||
uint16_t ContainedObjectHandle[]; // varies
|
||||
} FFSmbiosBaseboard;
|
||||
uint8_t NumberOfContainedObjectHandles; // varies
|
||||
uint16_t ContainedObjectHandles[]; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosBaseboard;
|
||||
|
||||
static_assert(offsetof(FFSmbiosBaseboard, ContainedObjectHandles) == 0x0F,
|
||||
"FFSmbiosBaseboard: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectBoard(FFBoardResult* board)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,10 @@ typedef struct FFSmbiosSystemEnclosure
|
||||
uint8_t ContainedElementCount; // varies
|
||||
uint8_t ContainedRecordLength; // varies
|
||||
uint8_t ContainedElements[]; // varies
|
||||
} FFSmbiosSystemEnclosure;
|
||||
} __attribute__((__packed__)) FFSmbiosSystemEnclosure;
|
||||
|
||||
static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15,
|
||||
"FFSmbiosSystemEnclosure: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectChassis(FFChassisResult* result)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,10 @@ typedef struct FFSmbiosProcessorInfo
|
||||
|
||||
// 3.6+
|
||||
uint16_t ThreadEnabled; // varies
|
||||
} FFSmbiosProcessorInfo;
|
||||
} __attribute__((__packed__)) FFSmbiosProcessorInfo;
|
||||
|
||||
static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30,
|
||||
"FFSmbiosProcessorInfo: Wrong struct alignment");
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
|
||||
|
||||
@@ -18,13 +18,16 @@ typedef struct FFSmbiosSystemInfo
|
||||
uint8_t ClockSeqHiAndReserved;
|
||||
uint8_t ClockSeqLow;
|
||||
uint8_t Node[6];
|
||||
} UUID; // varies
|
||||
} __attribute__((__packed__)) UUID; // varies
|
||||
uint8_t WakeUpType; // enum
|
||||
|
||||
// 2.4+
|
||||
uint8_t SKUNumber; // string
|
||||
uint8_t Family; // string
|
||||
} FFSmbiosSystemInfo;
|
||||
} __attribute__((__packed__)) FFSmbiosSystemInfo;
|
||||
|
||||
static_assert(offsetof(FFSmbiosSystemInfo, Family) == 0x1A,
|
||||
"FFSmbiosSystemInfo: Wrong struct alignment");
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ typedef struct FFSmbiosHeader
|
||||
FFSmbiosType Type;
|
||||
uint8_t Length;
|
||||
uint16_t Handle;
|
||||
} FFSmbiosHeader;
|
||||
} __attribute__((__packed__)) FFSmbiosHeader;
|
||||
static_assert(sizeof(FFSmbiosHeader) == 4, "FFSmbiosHeader should be 4 bytes");
|
||||
|
||||
typedef struct FFRawSmbiosData
|
||||
|
||||
Reference in New Issue
Block a user