1 /******************************************************************************
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
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.
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.
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/>.
20 #ifndef __VTOYJUMP_H__
21 #define __VTOYJUMP_H__
23 #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
25 #define SIZE_1MB (1024 * 1024)
26 #define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)
28 #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
32 typedef struct ventoy_guid
41 typedef struct ventoy_os_param
43 ventoy_guid guid
; // VENTOY_GUID
44 UINT8 chksum
; // checksum
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
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.
60 UINT64 vtoy_img_location_addr
;
61 UINT32 vtoy_img_location_len
;
63 UINT64 vtoy_reserved
[4]; // Internal use by ventoy
65 UINT8 vtoy_disk_signature
[4];
70 typedef struct ventoy_windows_data
72 char auto_install_script
[384];
73 char injection_archive
[384];
74 UINT8 windows11_bypass_check
;
76 UINT32 auto_install_len
;
78 UINT8 reserved
[255 - 4];
80 /* auto install script file data ... + auto_install_len */
88 typedef struct PART_TABLE
90 UINT8 Active
; // 0x00 0x80
93 UINT16 StartSector
: 6;
94 UINT16 StartCylinder
: 10;
100 UINT16 EndCylinder
: 10;
102 UINT32 StartSectorId
;
106 typedef struct MBR_HEAD
109 PART_TABLE PartTbl
[4];
114 typedef struct VTOY_GPT_HDR
116 CHAR Signature
[8]; /* EFI PART */
123 UINT64 PartAreaStartLBA
;
124 UINT64 PartAreaEndLBA
;
126 UINT64 PartTblStartLBA
;
127 UINT32 PartTblTotNum
;
128 UINT32 PartTblEntryLen
;
130 UINT8 Reserved2
[420];
133 typedef struct VTOY_GPT_PART_TBL
143 typedef struct VTOY_GPT_INFO
147 VTOY_GPT_PART_TBL PartTbl
[128];
155 typedef struct VarDiskInfo
163 CHAR ProductRev
[128];
164 CHAR SerialNumber
[128];
171 CHAR PulisherId
[256];
172 CHAR PreparerId
[256];
175 #define SAFE_CLOSE_HANDLE(handle) \
177 if (handle != INVALID_HANDLE_VALUE) \
179 CloseHandle(handle); \
180 (handle) = INVALID_HANDLE_VALUE; \
184 #define safe_sprintf(dst, fmt, ...) sprintf_s(dst, sizeof(dst), fmt, __VA_ARGS__)
185 #define safe_strcpy(dst, src) strcpy_s(dst, sizeof(dst), src)
188 #define LASTERR GetLastError()
190 int unxz(unsigned char *in
, int in_size
,
191 int(*fill
)(void *dest
, unsigned int size
),
192 int(*flush
)(void *src
, unsigned int size
),
193 unsigned char *out
, int *in_used
,
194 void(*error
)(char *x
));