#include "mbr.h" #include #define MBR_PART_TABLE_OFFSET (446) #define MBR_BOOT_SIGNATURE_OFFSET (510) #define MBR_BOOT_SIGNATURE0 (0x55) #define MBR_BOOT_SIGNATURE1 (0xAA) const PartEntry *mbr_get_partitions(const uint8_t *mbr_sec) { // check if disk is MBR type if ((mbr_sec[MBR_BOOT_SIGNATURE_OFFSET] != MBR_BOOT_SIGNATURE0) || (mbr_sec[MBR_BOOT_SIGNATURE_OFFSET + 1] != MBR_BOOT_SIGNATURE1)) { return NULL; // if not } else { return (PartEntry *) (mbr_sec + MBR_PART_TABLE_OFFSET); // if it is } }