Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/storage/mbr_gpt.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2019 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef MBR_GPT_H
19
#define MBR_GPT_H
20
21
#include <utils/types.h>
22
23
typedef struct _mbr_chs_t
24
{
25
u8 head;
26
u8 sector;
27
u8 cylinder;
28
} __attribute__((packed)) mbr_chs_t;
29
30
typedef struct _mbr_part_t
31
{
32
u8 status;
33
mbr_chs_t start_sct_chs;
34
u8 type;
35
mbr_chs_t end_sct_chs;
36
u32 start_sct;
37
u32 size_sct;
38
} __attribute__((packed)) mbr_part_t;
39
40
typedef struct _mbr_t
41
{
42
/* 0x000 */ u8 bootstrap[440];
43
/* 0x1B8 */ u32 signature;
44
/* 0x1BC */ u16 copy_protected;
45
/* 0x1BE */ mbr_part_t partitions[4];
46
/* 0x1FE */ u16 boot_signature;
47
} __attribute__((packed)) mbr_t;
48
49
typedef struct _gpt_entry_t
50
{
51
/* 0x00 */ u8 type_guid[0x10];
52
/* 0x10 */ u8 part_guid[0x10];
53
/* 0x20 */ u64 lba_start;
54
/* 0x28 */ u64 lba_end;
55
/* 0x30 */ u64 attrs;
56
/* 0x38 */ u16 name[36];
57
} gpt_entry_t;
58
59
typedef struct _gpt_header_t
60
{
61
/* 0x00 */ u64 signature; // "EFI PART"
62
/* 0x08 */ u32 revision;
63
/* 0x0C */ u32 size;
64
/* 0x10 */ u32 crc32;
65
/* 0x14 */ u32 res1;
66
/* 0x18 */ u64 my_lba;
67
/* 0x20 */ u64 alt_lba;
68
/* 0x28 */ u64 first_use_lba;
69
/* 0x30 */ u64 last_use_lba;
70
/* 0x38 */ u8 disk_guid[0x10];
71
/* 0x48 */ u64 part_ent_lba;
72
/* 0x50 */ u32 num_part_ents;
73
/* 0x54 */ u32 part_ent_size;
74
/* 0x58 */ u32 part_ents_crc32;
75
/* 0x5C */ u8 res2[420]; // Used as first 3 partition entries backup for HOS.
76
} gpt_header_t;
77
78
typedef struct _gpt_t
79
{
80
gpt_header_t header;
81
gpt_entry_t entries[128];
82
} gpt_t;
83
84
#endif
85
86