forked from difcareer/010templates
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGPTTemplate.bt
executable file
·68 lines (60 loc) · 1.6 KB
/
GPTTemplate.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//--------------------------------------
//--- 010 Editor v5.0 Binary Template
//
// File: GPTTemplate
// Author: [email protected]
// Revision: V1.0
// Purpose: Guid Partition Table
//--------------------------------------
typedef struct {
BYTE BootIndicator;
BYTE StartHead;
WORD StartSector:6;
WORD StartCylinder:10;
BYTE PartitionType;
BYTE EndHead;
WORD EndSector:6;
WORD EndCylider:10;
DWORD SectorsPrecedingPartion;
DWORD SectorsInPartition;
}MBRPARTITIONTABLE;
typedef struct{
char SIGNATURE[8];
DWORD Revision;
DWORD Headersize;
DWORD CRC32OfHeader;
DWORD Reserved;
uint64 CurrentLBA;
uint64 BackupLBA; //location of the other head copy
uint64 FirstUsableLBA; //primary partition table last LBA+1
uint64 LastUsableLBA; //secondary parition table first LBA-1
BYTE DiskGUID[16];
uint64 PartitionEntries;
DWORD NumOfPartitions;
DWORD SizeOfPartitionEntry;
DWORD CRC32ofPartitionArray;
BYTE reserved[420];
}GPT;
typedef struct {
BYTE PartitionTypeGUID[16];
BYTE PartitionGUID[16];
uint64 PartitionStartLBA;
uint64 PartitionEndLBA;
uint64 PartitionProperty;
wchar_t PartitionName[36]; //Unicode
}GPTPAPTITIONTABLE <size=128>;
LittleEndian();
struct {
BYTE bootcode[446];
MBRPARTITIONTABLE partitionTable[4];
WORD signature;
}MBR <size=512>;
if ((MBR.partitionTable[0].PartitionType & 0xFF) == 0xEE) {
Printf("Protected MBR. GPT reserved");
GPT gptheader;
GPTPAPTITIONTABLE table[128];
FSeek(FileSize()-sizeof(GPT)-sizeof(GPTPAPTITIONTABLE)*128);
GPTPAPTITIONTABLE BackupTable[128];
FSeek(FileSize()-sizeof(GPT));
GPT Backupgptheader;
}