]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - vtoyjump/vtoyjump/vtoyjump.h
3af9f855bdd9460c100ebc6f8ceb36f84370836b
[Ventoy.git] / vtoyjump / vtoyjump / vtoyjump.h
1 /******************************************************************************
2 * vtoyjump.h
3 *
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20 #ifndef __VTOYJUMP_H__
21 #define __VTOYJUMP_H__
22
23 #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
24
25 #define SIZE_1MB (1024 * 1024)
26 #define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)
27
28 #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
29
30 #pragma pack(1)
31
32 typedef struct ventoy_guid
33 {
34 UINT32 data1;
35 UINT16 data2;
36 UINT16 data3;
37 UINT8 data4[8];
38 }ventoy_guid;
39
40
41 typedef struct ventoy_os_param
42 {
43 ventoy_guid guid; // VENTOY_GUID
44 UINT8 chksum; // checksum
45
46 UINT8 vtoy_disk_guid[16];
47 UINT64 vtoy_disk_size; // disk size in bytes
48 UINT16 vtoy_disk_part_id; // begin with 1
49 UINT16 vtoy_disk_part_type; // 0:exfat 1:ntfs other: reserved
50 char vtoy_img_path[384]; // It seems to be enough, utf-8 format
51 UINT64 vtoy_img_size; // image file size in bytes
52
53 /*
54 * Ventoy will write a copy of ventoy_image_location data into runtime memory
55 * this is the physically address and length of that memory.
56 * Address 0 means no such data exist.
57 * Address will be aligned by 4KB.
58 *
59 */
60 UINT64 vtoy_img_location_addr;
61 UINT32 vtoy_img_location_len;
62
63 UINT64 vtoy_reserved[4]; // Internal use by ventoy
64
65 UINT8 reserved[31];
66 }ventoy_os_param;
67
68 typedef struct ventoy_windows_data
69 {
70 char auto_install_script[384];
71 char injection_archive[384];
72 UINT8 windows11_bypass_check;
73 UINT8 reserved[255];
74 }ventoy_windows_data;
75
76
77
78 typedef struct PART_TABLE
79 {
80 UINT8 Active; // 0x00 0x80
81
82 UINT8 StartHead;
83 UINT16 StartSector : 6;
84 UINT16 StartCylinder : 10;
85
86 UINT8 FsFlag;
87
88 UINT8 EndHead;
89 UINT16 EndSector : 6;
90 UINT16 EndCylinder : 10;
91
92 UINT32 StartSectorId;
93 UINT32 SectorCount;
94 }PART_TABLE;
95
96 typedef struct MBR_HEAD
97 {
98 UINT8 BootCode[446];
99 PART_TABLE PartTbl[4];
100 UINT8 Byte55;
101 UINT8 ByteAA;
102 }MBR_HEAD;
103
104 typedef struct VTOY_GPT_HDR
105 {
106 CHAR Signature[8]; /* EFI PART */
107 UINT8 Version[4];
108 UINT32 Length;
109 UINT32 Crc;
110 UINT8 Reserved1[4];
111 UINT64 EfiStartLBA;
112 UINT64 EfiBackupLBA;
113 UINT64 PartAreaStartLBA;
114 UINT64 PartAreaEndLBA;
115 GUID DiskGuid;
116 UINT64 PartTblStartLBA;
117 UINT32 PartTblTotNum;
118 UINT32 PartTblEntryLen;
119 UINT32 PartTblCrc;
120 UINT8 Reserved2[420];
121 }VTOY_GPT_HDR;
122
123 typedef struct VTOY_GPT_PART_TBL
124 {
125 GUID PartType;
126 GUID PartGuid;
127 UINT64 StartLBA;
128 UINT64 LastLBA;
129 UINT64 Attr;
130 UINT16 Name[36];
131 }VTOY_GPT_PART_TBL;
132
133 typedef struct VTOY_GPT_INFO
134 {
135 MBR_HEAD MBR;
136 VTOY_GPT_HDR Head;
137 VTOY_GPT_PART_TBL PartTbl[128];
138 }VTOY_GPT_INFO;
139
140
141
142 #pragma pack()
143
144
145 #define SAFE_CLOSE_HANDLE(handle) \
146 {\
147 if (handle != INVALID_HANDLE_VALUE) \
148 {\
149 CloseHandle(handle); \
150 (handle) = INVALID_HANDLE_VALUE; \
151 }\
152 }
153
154 #define LASTERR GetLastError()
155
156 #endif