|
1 | 1 | /* |
2 | 2 | * PROJECT: ReactOS Setup Library |
3 | | - * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) |
| 3 | + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) |
4 | 4 | * PURPOSE: MBR and GPT Partition types |
5 | | - * COPYRIGHT: Copyright 2018-2020 Hermes Belusca-Maito |
| 5 | + * COPYRIGHT: Copyright 2018-2025 Hermès Bélusca-Maïto <[email protected]> |
6 | 6 | */ |
7 | 7 |
|
8 | 8 | #include "precomp.h" |
9 | 9 | #include "partinfo.h" |
10 | 10 |
|
11 | | -/* MBR PARTITION TYPES ******************************************************/ |
| 11 | +/* MBR PARTITION TYPES *******************************************************/ |
12 | 12 |
|
13 | 13 | /* |
14 | 14 | * This partition type list is based from: |
|
42 | 42 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
43 | 43 | */ |
44 | 44 |
|
| 45 | +typedef struct _MBR_PARTITION_TYPE |
| 46 | +{ |
| 47 | + UCHAR Type; |
| 48 | + PCSTR Description; |
| 49 | +} MBR_PARTITION_TYPE, *PMBR_PARTITION_TYPE; |
| 50 | + |
45 | 51 | /* Known MBR partition type codes and descriptions */ |
46 | | -const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES] = |
| 52 | +const MBR_PARTITION_TYPE MbrPartitionTypes[] = |
47 | 53 | { |
48 | 54 | { 0x00, "(Empty)" }, // PARTITION_ENTRY_UNUSED |
49 | 55 | { 0x01, "FAT12" }, // PARTITION_FAT_12 |
@@ -201,7 +207,7 @@ const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES] = |
201 | 207 | }; |
202 | 208 |
|
203 | 209 |
|
204 | | -/* GPT PARTITION TYPES ******************************************************/ |
| 210 | +/* GPT PARTITION TYPES *******************************************************/ |
205 | 211 |
|
206 | 212 | #define GUID_CONST(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ |
207 | 213 | { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } |
@@ -267,8 +273,14 @@ DEFINE_GUID(PARTITION_DPP_GUID, 0x57434F53, 0x94CB, 0x43F0, 0xA5, 0 |
267 | 273 | * https://www.magnumdb.com/search?q=PARTITION_* |
268 | 274 | */ |
269 | 275 |
|
| 276 | +typedef struct _GPT_PARTITION_TYPE |
| 277 | +{ |
| 278 | + GUID Guid; |
| 279 | + PCSTR Description; |
| 280 | +} GPT_PARTITION_TYPE, *PGPT_PARTITION_TYPE; |
| 281 | + |
270 | 282 | /* Known GPT partition type GUIDs and descriptions */ |
271 | | -const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES] = |
| 283 | +const GPT_PARTITION_TYPE GptPartitionTypes[] = |
272 | 284 | { |
273 | 285 | /* |
274 | 286 | * EFI specification |
@@ -784,4 +796,44 @@ const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES] = |
784 | 796 | "ArcaOS Type 1" }, |
785 | 797 | }; |
786 | 798 |
|
| 799 | + |
| 800 | +/* PARTITION TYPES LOOKUP ****************************************************/ |
| 801 | + |
| 802 | +PCSTR |
| 803 | +NTAPI |
| 804 | +LookupPartitionTypeString( |
| 805 | + _In_ PARTITION_STYLE PartitionStyle, |
| 806 | + _In_ PVOID PartitionType) |
| 807 | +{ |
| 808 | + UINT i; |
| 809 | + |
| 810 | + /* Do the table lookup */ |
| 811 | + if (PartitionStyle == PARTITION_STYLE_MBR) |
| 812 | + { |
| 813 | + for (i = 0; i < _countof(MbrPartitionTypes); ++i) |
| 814 | + { |
| 815 | + if (*(PUCHAR)PartitionType == MbrPartitionTypes[i].Type) |
| 816 | + { |
| 817 | + return MbrPartitionTypes[i].Description; |
| 818 | + } |
| 819 | + } |
| 820 | + } |
| 821 | +#if 0 // TODO: GPT support! |
| 822 | + else if (PartitionStyle == PARTITION_STYLE_GPT) |
| 823 | + { |
| 824 | + for (i = 0; i < _countof(GptPartitionTypes); ++i) |
| 825 | + { |
| 826 | + if (IsEqualPartitionType((PGUID)PartitionType, |
| 827 | + &GptPartitionTypes[i].Guid)) |
| 828 | + { |
| 829 | + return GptPartitionTypes[i].Description; |
| 830 | + } |
| 831 | + } |
| 832 | + } |
| 833 | +#endif |
| 834 | + |
| 835 | + /* The partition type is unknown */ |
| 836 | + return NULL; |
| 837 | +} |
| 838 | + |
787 | 839 | /* EOF */ |
0 commit comments