diff --git a/Core/Disk.cpp b/Core/Disk.cpp index 0a734ad..7943c96 100644 --- a/Core/Disk.cpp +++ b/Core/Disk.cpp @@ -84,13 +84,15 @@ namespace Disk for (uint32_t e = 0; e < Entries; e++) { - GUIDPartitionTablePartition GPTPartition = reinterpret_cast(RWBuffer)[e]; - if (GPTPartition.TypeLow || GPTPartition.TypeHigh) + GUIDPartitionTableEntry GPTPartition = reinterpret_cast(RWBuffer)[e]; + if (memcmp(GPTPartition.PartitionType, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(GPTPartition.PartitionType)) != 0) { Partition partition{}; - memcpy(partition.Label, GPTPartition.Label, sizeof(partition.Label)); - partition.StartLBA = GPTPartition.StartLBA; - partition.EndLBA = GPTPartition.EndLBA; + for (int i = 0; i < 36; i++) + memcpy(partition.Label + i * 2, &GPTPartition.PartitionName[i], 2); + partition.Label[71] = '\0'; + partition.StartLBA = GPTPartition.FirstLBA; + partition.EndLBA = GPTPartition.LastLBA; partition.Sectors = partition.EndLBA - partition.StartLBA; partition.Port = ItrPort; partition.Flags = Present; @@ -98,14 +100,7 @@ namespace Disk if (GPTPartition.Attributes & 1) partition.Flags |= EFISystemPartition; partition.Index = drive.Partitions.size(); - // why there is NUL (\0) between every char????? - char PartName[72]; - memcpy(PartName, GPTPartition.Label, 72); - for (int i = 0; i < 72; i++) - if (PartName[i] == '\0') - PartName[i] = ' '; - PartName[71] = '\0'; - trace("GPT partition \"%s\" found with %lld sectors", PartName, partition.Sectors); + trace("GPT partition \"%s\" found with %lld sectors", partition.Label, partition.Sectors); drive.Partitions.push_back(partition); // char *PartitionName = new char[64]; diff --git a/include/disk.hpp b/include/disk.hpp index 8bdfb94..9ba1e27 100644 --- a/include/disk.hpp +++ b/include/disk.hpp @@ -62,16 +62,14 @@ namespace Disk uint8_t Signature[2]; } __packed; - struct GUIDPartitionTablePartition + struct GUIDPartitionTableEntry { - uint64_t TypeLow; - uint64_t TypeHigh; - uint64_t GUIDLow; - uint64_t GUIDHigh; - uint64_t StartLBA; - uint64_t EndLBA; + uint8_t PartitionType[16]; + uint8_t UniquePartitionGUID[16]; + uint64_t FirstLBA; + uint64_t LastLBA; uint64_t Attributes; - char Label[72]; + uint16_t PartitionName[36]; } __packed; struct GUIDPartitionTable