mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-18 09:51:15 +00:00
Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f32d342f66 | ||
|
09d7ae68e7 | ||
|
68fefbc1fc | ||
|
8d893d4c94 | ||
|
84798a4f7a | ||
|
87f88eeb2b | ||
|
7b2615744c | ||
|
d7faff4438 | ||
|
f15dfd7409 | ||
|
09162e8d97 | ||
|
eb8fcc8f30 | ||
|
5fcb3971bc | ||
|
e47e4484ce | ||
|
7e26decb31 | ||
|
e713946fd0 | ||
|
a93b0f6656 | ||
|
836e1aa11e | ||
|
154bbc6e5f | ||
|
d151e74336 | ||
|
df87cafdfb | ||
|
09494a5b23 | ||
|
e15a1c5ece | ||
|
f5843f576b | ||
|
be5bc6f3b7 | ||
|
f3b65452f4 | ||
|
ec4b6c2a2c | ||
|
be8b6e8976 | ||
|
82b1faa132 | ||
|
52ae65f54d | ||
|
ee104bfa97 | ||
|
9cfd05811b | ||
|
0c66908935 | ||
|
f53de3bdb0 | ||
|
8516786b31 | ||
|
f7c78879c7 | ||
|
f3e267a09e | ||
|
7c1370dcb0 | ||
|
1b5aa9c61d | ||
|
d6eba15d71 |
2
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
2
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
@@ -21,7 +21,7 @@ body:
|
||||
attributes:
|
||||
label: Ventoy Version
|
||||
description: What version of ventoy are you running?
|
||||
placeholder: 1.0.55
|
||||
placeholder: 1.0.57
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
|
@@ -59,6 +59,9 @@ static grub_env_set_pf grub_env_set = NULL;
|
||||
ventoy_grub_param_file_replace *g_file_replace_list = NULL;
|
||||
ventoy_efi_file_replace g_efi_file_replace;
|
||||
|
||||
ventoy_grub_param_file_replace *g_img_replace_list = NULL;
|
||||
ventoy_efi_file_replace g_img_file_replace;
|
||||
|
||||
CONST CHAR16 gIso9660EfiDriverPath[] = ISO9660_EFI_DRIVER_PATH;
|
||||
CONST CHAR16 gUdfEfiDriverPath[] = UDF_EFI_DRIVER_PATH;
|
||||
|
||||
@@ -707,6 +710,35 @@ STATIC EFI_STATUS EFIAPI ventoy_load_isoefi_driver(IN EFI_HANDLE ImageHandle)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS ventoy_proc_img_replace_name(ventoy_grub_param_file_replace *replace)
|
||||
{
|
||||
UINT32 i;
|
||||
char tmp[256];
|
||||
|
||||
if (replace->magic != GRUB_IMG_REPLACE_MAGIC)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (replace->old_file_name[0][0] == 0)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
AsciiStrCpyS(tmp, sizeof(tmp), replace->old_file_name[0]);
|
||||
|
||||
for (i = 0; i < 256 && tmp[i]; i++)
|
||||
{
|
||||
if (tmp[i] == '/')
|
||||
{
|
||||
tmp[i] = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
AsciiStrCpyS(replace->old_file_name[0], 256, tmp);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
{
|
||||
UINT32 i = 0;
|
||||
@@ -817,6 +849,19 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
|
||||
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
|
||||
);
|
||||
|
||||
g_img_replace_list = &pGrubParam->img_replace;
|
||||
ventoy_proc_img_replace_name(g_img_replace_list);
|
||||
old_cnt = g_img_replace_list->old_file_cnt;
|
||||
debug("img replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
|
||||
g_img_replace_list->magic,
|
||||
g_img_replace_list->new_file_virtual_id,
|
||||
old_cnt,
|
||||
old_cnt > 0 ? g_img_replace_list->old_file_name[0] : "",
|
||||
old_cnt > 1 ? g_img_replace_list->old_file_name[1] : "",
|
||||
old_cnt > 2 ? g_img_replace_list->old_file_name[2] : "",
|
||||
old_cnt > 3 ? g_img_replace_list->old_file_name[3] : ""
|
||||
);
|
||||
|
||||
pPos = StrStr(pCmdLine, L"mem:");
|
||||
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
|
||||
|
||||
@@ -1050,7 +1095,8 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
|
||||
gST->ConIn->Reset(gST->ConIn, FALSE);
|
||||
}
|
||||
|
||||
if (g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC)
|
||||
if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) ||
|
||||
(g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC))
|
||||
{
|
||||
ventoy_wrapper_push_openvolume(pFile->OpenVolume);
|
||||
pFile->OpenVolume = ventoy_wrapper_open_volume;
|
||||
|
@@ -243,6 +243,7 @@ typedef int (*grub_env_printf_pf)(const char *fmt, ...);
|
||||
#pragma pack(1)
|
||||
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
|
||||
|
||||
typedef struct ventoy_efi_file_replace
|
||||
{
|
||||
@@ -267,6 +268,7 @@ typedef struct ventoy_grub_param
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
||||
@@ -396,6 +398,7 @@ extern ventoy_virt_chunk *g_virt_chunk;
|
||||
extern UINT32 g_virt_chunk_num;
|
||||
extern vtoy_block_data gBlockData;
|
||||
extern ventoy_efi_file_replace g_efi_file_replace;
|
||||
extern ventoy_efi_file_replace g_img_file_replace;
|
||||
extern ventoy_sector_flag *g_sector_flag;
|
||||
extern UINT32 g_sector_flag_num;
|
||||
extern BOOLEAN gMemdiskMode;
|
||||
@@ -403,6 +406,7 @@ extern BOOLEAN gSector512Mode;
|
||||
extern UINTN g_iso_buf_size;
|
||||
extern UINT8 *g_iso_data_buf;
|
||||
extern ventoy_grub_param_file_replace *g_file_replace_list;
|
||||
extern ventoy_grub_param_file_replace *g_img_replace_list;
|
||||
extern BOOLEAN g_fixup_iso9660_secover_enable;
|
||||
extern EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *g_con_simple_input_ex;
|
||||
extern BOOLEAN g_fix_windows_1st_cdrom_issue;
|
||||
|
@@ -37,6 +37,9 @@
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Ventoy.h>
|
||||
|
||||
#define ASSIGN_REPLACE(This, replace) \
|
||||
replace = (This->FlushEx == ventoy_wrapper_file_flush_ex) ? &g_efi_file_replace : &g_img_file_replace
|
||||
|
||||
UINT8 *g_iso_data_buf = NULL;
|
||||
UINTN g_iso_buf_size = 0;
|
||||
BOOLEAN gMemdiskMode = FALSE;
|
||||
@@ -1245,6 +1248,15 @@ ventoy_wrapper_file_flush_ex(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Ex version */
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_flush_ex_img(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
|
||||
{
|
||||
(VOID)This;
|
||||
(VOID)Token;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_write(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
|
||||
@@ -1270,19 +1282,20 @@ ventoy_wrapper_file_close(EFI_FILE_HANDLE This)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
|
||||
{
|
||||
(VOID)This;
|
||||
|
||||
if (Position <= g_efi_file_replace.FileSizeBytes)
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
if (Position <= replace->FileSizeBytes)
|
||||
{
|
||||
g_efi_file_replace.CurPos = Position;
|
||||
replace->CurPos = Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_efi_file_replace.CurPos = g_efi_file_replace.FileSizeBytes;
|
||||
replace->CurPos = replace->FileSizeBytes;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -1291,9 +1304,11 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
|
||||
STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_get_pos(EFI_FILE_HANDLE This, UINT64 *Position)
|
||||
{
|
||||
(VOID)This;
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
*Position = g_efi_file_replace.CurPos;
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
*Position = replace->CurPos;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -1303,6 +1318,9 @@ STATIC EFI_STATUS EFIAPI
|
||||
ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, VOID *Data)
|
||||
{
|
||||
EFI_FILE_INFO *Info = (EFI_FILE_INFO *) Data;
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
debug("ventoy_wrapper_file_get_info ... %u", *Len);
|
||||
|
||||
@@ -1320,8 +1338,8 @@ ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, V
|
||||
ZeroMem(Data, sizeof(EFI_FILE_INFO));
|
||||
|
||||
Info->Size = sizeof(EFI_FILE_INFO);
|
||||
Info->FileSize = g_efi_file_replace.FileSizeBytes;
|
||||
Info->PhysicalSize = g_efi_file_replace.FileSizeBytes;
|
||||
Info->FileSize = replace->FileSizeBytes;
|
||||
Info->PhysicalSize = replace->FileSizeBytes;
|
||||
Info->Attribute = EFI_FILE_READ_ONLY;
|
||||
//Info->FileName = EFI_FILE_READ_ONLY;
|
||||
|
||||
@@ -1335,23 +1353,24 @@ ventoy_wrapper_file_read(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
|
||||
{
|
||||
EFI_LBA Lba;
|
||||
UINTN ReadLen = *Len;
|
||||
|
||||
(VOID)This;
|
||||
ventoy_efi_file_replace *replace = NULL;
|
||||
|
||||
ASSIGN_REPLACE(This, replace);
|
||||
|
||||
debug("ventoy_wrapper_file_read ... %u", *Len);
|
||||
|
||||
if (g_efi_file_replace.CurPos + ReadLen > g_efi_file_replace.FileSizeBytes)
|
||||
if (replace->CurPos + ReadLen > replace->FileSizeBytes)
|
||||
{
|
||||
ReadLen = g_efi_file_replace.FileSizeBytes - g_efi_file_replace.CurPos;
|
||||
ReadLen = replace->FileSizeBytes - replace->CurPos;
|
||||
}
|
||||
|
||||
Lba = g_efi_file_replace.CurPos / 2048 + g_efi_file_replace.BlockIoSectorStart;
|
||||
Lba = replace->CurPos / 2048 + replace->BlockIoSectorStart;
|
||||
|
||||
ventoy_block_io_read(NULL, 0, Lba, ReadLen, Data);
|
||||
|
||||
*Len = ReadLen;
|
||||
|
||||
g_efi_file_replace.CurPos += ReadLen;
|
||||
replace->CurPos += ReadLen;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -1362,7 +1381,7 @@ ventoy_wrapper_file_read_ex(IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN
|
||||
return ventoy_wrapper_file_read(This, &(Token->BufferSize), Token->Buffer);
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File)
|
||||
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, BOOLEAN Img)
|
||||
{
|
||||
File->Revision = EFI_FILE_PROTOCOL_REVISION2;
|
||||
File->Open = ventoy_wrapper_fs_open;
|
||||
@@ -1378,7 +1397,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File)
|
||||
File->OpenEx = ventoy_wrapper_file_open_ex;
|
||||
File->ReadEx = ventoy_wrapper_file_read_ex;
|
||||
File->WriteEx = ventoy_wrapper_file_write_ex;
|
||||
File->FlushEx = ventoy_wrapper_file_flush_ex;
|
||||
File->FlushEx = Img ? ventoy_wrapper_file_flush_ex_img : ventoy_wrapper_file_flush_ex;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -1397,6 +1416,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
UINT64 Sectors = 0;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
CHAR8 TmpName[256];
|
||||
CHAR8 OldName[256];
|
||||
ventoy_virt_chunk *virt = NULL;
|
||||
|
||||
debug("## ventoy_wrapper_file_open <%s> ", Name);
|
||||
@@ -1417,6 +1437,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
if (g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC &&
|
||||
g_file_replace_list->new_file_virtual_id < g_virt_chunk_num)
|
||||
{
|
||||
@@ -1427,7 +1448,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
{
|
||||
g_original_fclose(*New);
|
||||
*New = &g_efi_file_replace.WrapperHandle;
|
||||
ventoy_wrapper_file_procotol(*New);
|
||||
ventoy_wrapper_file_procotol(*New, FALSE);
|
||||
|
||||
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
|
||||
|
||||
@@ -1453,6 +1474,49 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC &&
|
||||
g_img_replace_list->new_file_virtual_id < g_virt_chunk_num)
|
||||
{
|
||||
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
|
||||
for (j = 0; j < g_img_replace_list->old_file_cnt; j++)
|
||||
{
|
||||
AsciiStrCpyS(OldName, sizeof(OldName), g_img_replace_list[i].old_file_name[j]);
|
||||
if ((0 == AsciiStrCmp(OldName, TmpName)) ||
|
||||
(AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
|
||||
AsciiStrCmp(OldName + 16, TmpName) == 0
|
||||
)
|
||||
)
|
||||
{
|
||||
g_original_fclose(*New);
|
||||
*New = &g_img_file_replace.WrapperHandle;
|
||||
ventoy_wrapper_file_procotol(*New, TRUE);
|
||||
|
||||
virt = g_virt_chunk + g_img_replace_list->new_file_virtual_id;
|
||||
|
||||
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
|
||||
|
||||
g_img_file_replace.BlockIoSectorStart = virt->mem_sector_start;
|
||||
g_img_file_replace.FileSizeBytes = Sectors * 2048;
|
||||
|
||||
if (gDebugPrint)
|
||||
{
|
||||
debug("## ventoy_wrapper_file_open2 <%s> BlockStart:%lu Sectors:%lu Bytes:%lu", Name,
|
||||
g_img_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048);
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
if (StrCmp(Name, L"\\loader\\entries") == 0)
|
||||
{
|
||||
(*New)->Open = ventoy_wrapper_file_open;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -41,6 +41,7 @@ typedef struct ventoy_grub_param
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
#pragma pack()
|
||||
|
@@ -94,7 +94,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
{
|
||||
total += r;
|
||||
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
|
||||
grub_printf("\rCalculating %d%% ", (int)div);
|
||||
grub_printf("\rCalculating %s %d%% ", hash->name, (int)div);
|
||||
grub_refresh();
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
grub_free (context);
|
||||
if (progress)
|
||||
{
|
||||
grub_printf("\rCalculating 100%% \n\r\n");
|
||||
grub_printf("\rCalculating %s 100%% \n\r\n", hash->name);
|
||||
grub_refresh();
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
@@ -224,6 +224,8 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
int keep = state[3].set;
|
||||
int uncompress = state[4].set;
|
||||
unsigned unread = 0;
|
||||
int len = 0;
|
||||
char hashsum[256];
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (aliases); i++)
|
||||
if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
|
||||
@@ -282,8 +284,12 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < hash->mdlen; j++)
|
||||
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
|
||||
{
|
||||
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
|
||||
len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]);
|
||||
}
|
||||
grub_printf (" %s\n", args[i]);
|
||||
grub_env_set("VT_LAST_CHECK_SUM", hashsum);
|
||||
}
|
||||
|
||||
if (unread)
|
||||
|
@@ -45,10 +45,24 @@ int g_ventoy_wimboot_mode = 0;
|
||||
int g_ventoy_iso_uefi_drv = 0;
|
||||
int g_ventoy_last_entry = -1;
|
||||
int g_ventoy_suppress_esc = 0;
|
||||
int g_ventoy_suppress_esc_default = 1;
|
||||
int g_ventoy_menu_esc = 0;
|
||||
int g_ventoy_fn_mutex = 0;
|
||||
int g_ventoy_terminal_output = 0;
|
||||
|
||||
#define VTOY_COMM_HOTKEY(cmdkey) \
|
||||
if (0 == g_ventoy_fn_mutex) { \
|
||||
cmdstr = grub_env_get(cmdkey); \
|
||||
if (cmdstr) \
|
||||
{ \
|
||||
menu_fini (); \
|
||||
g_ventoy_fn_mutex = 1; \
|
||||
grub_script_execute_sourcecode(cmdstr); \
|
||||
g_ventoy_fn_mutex = 0; \
|
||||
goto refresh; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Time to delay after displaying an error message about a default/fallback
|
||||
entry failing to boot. */
|
||||
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
|
||||
@@ -388,7 +402,7 @@ int g_menu_update_mode = 0;
|
||||
int g_ventoy_tip_label_enable = 0;
|
||||
const char * g_ventoy_tip_msg1 = NULL;
|
||||
const char * g_ventoy_tip_msg2 = NULL;
|
||||
|
||||
static const char *g_ventoy_cur_img_path = NULL;
|
||||
static void menu_set_chosen_tip(grub_menu_t menu, int entry)
|
||||
{
|
||||
img_info *img;
|
||||
@@ -402,6 +416,7 @@ static void menu_set_chosen_tip(grub_menu_t menu, int entry)
|
||||
{
|
||||
g_ventoy_tip_msg1 = img->tip1;
|
||||
g_ventoy_tip_msg2 = img->tip2;
|
||||
g_ventoy_cur_img_path = img->path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -625,7 +640,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
default_entry = get_entry_number (menu, "default");
|
||||
|
||||
if (g_ventoy_suppress_esc)
|
||||
default_entry = 1;
|
||||
default_entry = g_ventoy_suppress_esc_default;
|
||||
else if (g_ventoy_last_entry >= 0 && g_ventoy_last_entry < menu->size) {
|
||||
default_entry = g_ventoy_last_entry;
|
||||
}
|
||||
@@ -835,71 +850,23 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
|
||||
case GRUB_TERM_KEY_F2:
|
||||
case '2':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F2_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F2_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F3:
|
||||
case '3':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F3_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F3_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F4:
|
||||
case '4':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F4_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F4_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F5:
|
||||
case '5':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F5_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F5_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F6:
|
||||
case '6':
|
||||
if (0 == g_ventoy_fn_mutex) {
|
||||
cmdstr = grub_env_get("VTOY_F6_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_fn_mutex = 1;
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
g_ventoy_fn_mutex = 0;
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
VTOY_COMM_HOTKEY("VTOY_F6_CMD");
|
||||
break;
|
||||
case GRUB_TERM_KEY_F7:
|
||||
menu_fini ();
|
||||
@@ -945,6 +912,40 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
case (GRUB_TERM_CTRL | 'h'):
|
||||
case 'h':
|
||||
{
|
||||
cmdstr = grub_env_get("VTOY_HELP_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
while (grub_getkey() != GRUB_TERM_ESC)
|
||||
;
|
||||
menu_fini ();
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (GRUB_TERM_CTRL | 'm'):
|
||||
case 'm':
|
||||
{
|
||||
if (g_ventoy_cur_img_path)
|
||||
{
|
||||
grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
|
||||
cmdstr = grub_env_get("VTOY_CHKSUM_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_env_set("VTOY_CHKSUM_FILE_PATH", "X");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int entry;
|
||||
@@ -1038,6 +1039,11 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
break;
|
||||
}
|
||||
|
||||
if (autobooted == 0 && g_ventoy_menu_esc && auto_boot) {
|
||||
g_ventoy_last_entry = boot_entry;
|
||||
break;
|
||||
}
|
||||
|
||||
e = grub_menu_get_entry (menu, boot_entry);
|
||||
if (! e)
|
||||
continue; /* Menu is empty. */
|
||||
|
@@ -51,6 +51,37 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static grub_uint8_t g_check_mbr_data[440] = {
|
||||
0xEB, 0x63, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFA, 0x90, 0x90, 0xF6, 0xC2, 0x80, 0x74, 0x05, 0xF6, 0xC2, 0x70,
|
||||
0x74, 0x02, 0xB2, 0x80, 0xEA, 0x79, 0x7C, 0x00, 0x00, 0x31, 0xC0, 0x8E, 0xD8, 0x8E, 0xD0, 0xBC,
|
||||
0x00, 0x20, 0xFB, 0xA0, 0x64, 0x7C, 0x3C, 0xFF, 0x74, 0x02, 0x88, 0xC2, 0x52, 0xBE, 0x90, 0x7D,
|
||||
0xE8, 0x16, 0x01, 0xBE, 0x05, 0x7C, 0xB4, 0x41, 0xBB, 0xAA, 0x55, 0xCD, 0x13, 0x5A, 0x52, 0x72,
|
||||
0x3D, 0x81, 0xFB, 0x55, 0xAA, 0x75, 0x37, 0x83, 0xE1, 0x01, 0x74, 0x32, 0x31, 0xC0, 0x89, 0x44,
|
||||
0x04, 0x40, 0x88, 0x44, 0xFF, 0x89, 0x44, 0x02, 0xC7, 0x04, 0x10, 0x00, 0x66, 0x8B, 0x1E, 0x5C,
|
||||
0x7C, 0x66, 0x89, 0x5C, 0x08, 0x66, 0x8B, 0x1E, 0x60, 0x7C, 0x66, 0x89, 0x5C, 0x0C, 0xC7, 0x44,
|
||||
0x06, 0x00, 0x70, 0xB4, 0x42, 0xCD, 0x13, 0x72, 0x05, 0xBB, 0x00, 0x70, 0xEB, 0x76, 0xB4, 0x08,
|
||||
0xCD, 0x13, 0x73, 0x0D, 0x5A, 0x84, 0xD2, 0x0F, 0x83, 0xD8, 0x00, 0xBE, 0x96, 0x7D, 0xE9, 0x82,
|
||||
0x00, 0x66, 0x0F, 0xB6, 0xC6, 0x88, 0x64, 0xFF, 0x40, 0x66, 0x89, 0x44, 0x04, 0x0F, 0xB6, 0xD1,
|
||||
0xC1, 0xE2, 0x02, 0x88, 0xE8, 0x88, 0xF4, 0x40, 0x89, 0x44, 0x08, 0x0F, 0xB6, 0xC2, 0xC0, 0xE8,
|
||||
0x02, 0x66, 0x89, 0x04, 0x66, 0xA1, 0x60, 0x7C, 0x66, 0x09, 0xC0, 0x75, 0x4E, 0x66, 0xA1, 0x5C,
|
||||
0x7C, 0x66, 0x31, 0xD2, 0x66, 0xF7, 0x34, 0x88, 0xD1, 0x31, 0xD2, 0x66, 0xF7, 0x74, 0x04, 0x3B,
|
||||
0x44, 0x08, 0x7D, 0x37, 0xFE, 0xC1, 0x88, 0xC5, 0x30, 0xC0, 0xC1, 0xE8, 0x02, 0x08, 0xC1, 0x88,
|
||||
0xD0, 0x5A, 0x88, 0xC6, 0xBB, 0x00, 0x70, 0x8E, 0xC3, 0x31, 0xDB, 0xB8, 0x01, 0x02, 0xCD, 0x13,
|
||||
0x72, 0x1E, 0x8C, 0xC3, 0x60, 0x1E, 0xB9, 0x00, 0x01, 0x8E, 0xDB, 0x31, 0xF6, 0xBF, 0x00, 0x80,
|
||||
0x8E, 0xC6, 0xFC, 0xF3, 0xA5, 0x1F, 0x61, 0xFF, 0x26, 0x5A, 0x7C, 0xBE, 0x93, 0x7D, 0xEB, 0x03,
|
||||
0xBE, 0x99, 0x7D, 0xE8, 0x33, 0x00, 0xBE, 0x9C, 0x7D, 0xE8, 0x2D, 0x00, 0xCD, 0x18, 0xEB, 0xFE,
|
||||
0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
|
||||
0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44, 0x00, 0x52, 0x64, 0x00, 0x20, 0x45, 0x72, 0x0D,
|
||||
0x0A, 0x00, 0xBB, 0x01, 0x00, 0xB4, 0x0E, 0xCD, 0x10, 0xAC, 0x3C, 0x00, 0x75, 0xF4, 0xC3, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
initrd_info *g_initrd_img_list = NULL;
|
||||
initrd_info *g_initrd_img_tail = NULL;
|
||||
int g_initrd_img_count = 0;
|
||||
@@ -479,7 +510,7 @@ static int ventoy_set_check_result(int ret)
|
||||
grub_printf(VTOY_WARNING"\n");
|
||||
grub_printf(VTOY_WARNING"\n\n\n");
|
||||
|
||||
grub_printf("This is NOT a standard Ventoy device and is NOT supported (0x%x).\n\n", ret);
|
||||
grub_printf("This is NOT a standard Ventoy device and is NOT supported (%d).\n\n", ret);
|
||||
grub_printf("You should follow the instructions in https://www.ventoy.net to use Ventoy.\n");
|
||||
|
||||
grub_printf("\n\nWill exit after 10 seconds ...... ");
|
||||
@@ -497,6 +528,8 @@ static int ventoy_check_official_device(grub_device_t dev)
|
||||
grub_uint64_t offset;
|
||||
char devname[64];
|
||||
grub_fs_t fs;
|
||||
grub_uint8_t mbr[512];
|
||||
grub_disk_t disk;
|
||||
grub_device_t dev2;
|
||||
char *label = NULL;
|
||||
struct grub_partition *partition;
|
||||
@@ -611,7 +644,27 @@ static int ventoy_check_official_device(grub_device_t dev)
|
||||
|
||||
grub_device_close(dev2);
|
||||
}
|
||||
|
||||
|
||||
/* MBR check */
|
||||
disk = grub_disk_open(dev->disk->name);
|
||||
if (!disk)
|
||||
{
|
||||
return ventoy_set_check_result(11);
|
||||
}
|
||||
|
||||
grub_memset(mbr, 0, 512);
|
||||
grub_disk_read(disk, 0, 0, 512, mbr);
|
||||
grub_disk_close(disk);
|
||||
|
||||
g_check_mbr_data[92] = mbr[92];
|
||||
g_check_mbr_data[102] = mbr[102];
|
||||
g_check_mbr_data[103] = mbr[103];
|
||||
grub_memcpy(g_check_mbr_data + 0x180, mbr + 0x180, 16);
|
||||
if (grub_memcmp(g_check_mbr_data, mbr, 440))
|
||||
{
|
||||
return ventoy_set_check_result(12);
|
||||
}
|
||||
|
||||
return ventoy_set_check_result(0);
|
||||
}
|
||||
|
||||
@@ -865,6 +918,38 @@ static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_strcasebegin(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
char *c0, *c1;
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
c0 = args[0];
|
||||
c1 = args[1];
|
||||
|
||||
while (*c0 && *c1)
|
||||
{
|
||||
if ((*c0 != *c1) && (*c0 != grub_toupper(*c1)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
c0++;
|
||||
c1++;
|
||||
}
|
||||
|
||||
if (*c1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
long value_long = 0;
|
||||
@@ -2893,6 +2978,7 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
|
||||
}
|
||||
|
||||
grub_memset(&g_grub_param->file_replace, 0, sizeof(g_grub_param->file_replace));
|
||||
grub_memset(&g_grub_param->img_replace, 0, sizeof(g_grub_param->img_replace));
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
@@ -2924,15 +3010,21 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
|
||||
debug("Find conf replace for %s\n", args[1]);
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", node->orgconf);
|
||||
if (!file)
|
||||
if (file)
|
||||
{
|
||||
offset = grub_iso9660_get_last_file_dirent_pos(file);
|
||||
grub_file_close(file);
|
||||
}
|
||||
else if (node->img > 0)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("<(loop)%s> NOT exist\n", node->orgconf);
|
||||
goto end;
|
||||
}
|
||||
|
||||
offset = grub_iso9660_get_last_file_dirent_pos(file);
|
||||
grub_file_close(file);
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[0], node->newconf);
|
||||
if (!file)
|
||||
{
|
||||
@@ -2955,6 +3047,13 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
|
||||
g_conf_replace_node = node;
|
||||
g_conf_replace_offset = offset + 2;
|
||||
|
||||
if (node->img > 0)
|
||||
{
|
||||
g_grub_param->img_replace.magic = GRUB_IMG_REPLACE_MAGIC;
|
||||
g_grub_param->img_replace.old_name_cnt = 1;
|
||||
grub_snprintf(g_grub_param->img_replace.old_file_name[0], 256, "%s", node->orgconf);
|
||||
}
|
||||
|
||||
debug("conf_replace OK: newlen: %d\n", g_conf_replace_new_len);
|
||||
|
||||
end:
|
||||
@@ -2969,6 +3068,7 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
|
||||
{
|
||||
int i = 0;
|
||||
int pos = 0;
|
||||
int defidx = 1;
|
||||
char *buf = NULL;
|
||||
char configfile[128];
|
||||
install_template *node = NULL;
|
||||
@@ -2993,9 +3093,13 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
|
||||
|
||||
if (node->autosel >= 0 && node->autosel <= node->templatenum)
|
||||
{
|
||||
node->cursel = node->autosel - 1;
|
||||
debug("Auto install template auto select %d\n", node->autosel);
|
||||
return 0;
|
||||
defidx = node->autosel;
|
||||
if (node->timeout < 0)
|
||||
{
|
||||
node->cursel = node->autosel - 1;
|
||||
debug("Auto install template auto select %d\n", node->autosel);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
buf = (char *)grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||
@@ -3004,24 +3108,31 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (node->timeout > 0)
|
||||
{
|
||||
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
|
||||
}
|
||||
|
||||
vtoy_ssprintf(buf, pos, "menuentry \"Boot without auto installation template\" {\n"
|
||||
" echo %s\n}\n", "123");
|
||||
" echo %s\n}\n", "");
|
||||
|
||||
for (i = 0; i < node->templatenum; i++)
|
||||
{
|
||||
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" {\n"
|
||||
" echo 123\n}\n",
|
||||
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\"{\n"
|
||||
" echo \"\"\n}\n",
|
||||
node->templatepath[i].path);
|
||||
}
|
||||
|
||||
g_ventoy_menu_esc = 1;
|
||||
g_ventoy_suppress_esc = 1;
|
||||
g_ventoy_suppress_esc_default = defidx;
|
||||
|
||||
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, pos);
|
||||
grub_script_execute_sourcecode(configfile);
|
||||
|
||||
g_ventoy_menu_esc = 0;
|
||||
g_ventoy_suppress_esc = 0;
|
||||
g_ventoy_suppress_esc_default = 1;
|
||||
|
||||
grub_free(buf);
|
||||
|
||||
@@ -3034,6 +3145,7 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
|
||||
{
|
||||
int i = 0;
|
||||
int pos = 0;
|
||||
int defidx = 1;
|
||||
char *buf = NULL;
|
||||
char configfile[128];
|
||||
persistence_config *node;
|
||||
@@ -3058,9 +3170,13 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
|
||||
|
||||
if (node->autosel >= 0 && node->autosel <= node->backendnum)
|
||||
{
|
||||
node->cursel = node->autosel - 1;
|
||||
debug("Persistence image auto select %d\n", node->autosel);
|
||||
return 0;
|
||||
defidx = node->autosel;
|
||||
if (node->timeout < 0)
|
||||
{
|
||||
node->cursel = node->autosel - 1;
|
||||
debug("Persistence image auto select %d\n", node->autosel);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
buf = (char *)grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||
@@ -3069,25 +3185,32 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (node->timeout > 0)
|
||||
{
|
||||
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
|
||||
}
|
||||
|
||||
vtoy_ssprintf(buf, pos, "menuentry \"Boot without persistence\" {\n"
|
||||
" echo %s\n}\n", "123");
|
||||
" echo %s\n}\n", "");
|
||||
|
||||
for (i = 0; i < node->backendnum; i++)
|
||||
{
|
||||
vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" {\n"
|
||||
" echo 123\n}\n",
|
||||
" echo \"\"\n}\n",
|
||||
node->backendpath[i].path);
|
||||
|
||||
}
|
||||
|
||||
g_ventoy_menu_esc = 1;
|
||||
g_ventoy_suppress_esc = 1;
|
||||
|
||||
g_ventoy_suppress_esc_default = defidx;
|
||||
|
||||
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, pos);
|
||||
grub_script_execute_sourcecode(configfile);
|
||||
|
||||
g_ventoy_menu_esc = 0;
|
||||
g_ventoy_suppress_esc = 0;
|
||||
g_ventoy_suppress_esc_default = 1;
|
||||
|
||||
grub_free(buf);
|
||||
|
||||
@@ -4960,6 +5083,7 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_mod", ventoy_cmd_mod, 0, NULL, "{Int} {Int} {Var}", "mod integer variable", NULL },
|
||||
{ "vt_strstr", ventoy_cmd_strstr, 0, NULL, "", "", NULL },
|
||||
{ "vt_str_begin", ventoy_cmd_strbegin, 0, NULL, "", "", NULL },
|
||||
{ "vt_str_casebegin", ventoy_cmd_strcasebegin, 0, NULL, "", "", NULL },
|
||||
{ "vt_debug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
|
||||
{ "vtdebug", ventoy_cmd_debug, 0, NULL, "{on|off}", "turn debug on/off", NULL },
|
||||
{ "vtbreak", ventoy_cmd_break, 0, NULL, "{level}", "set debug break", NULL },
|
||||
|
@@ -550,6 +550,7 @@ typedef struct plugin_entry
|
||||
const char *key;
|
||||
ventoy_plugin_entry_pf entryfunc;
|
||||
ventoy_plugin_check_pf checkfunc;
|
||||
int flag;
|
||||
}plugin_entry;
|
||||
|
||||
typedef struct replace_fs_dir
|
||||
@@ -829,6 +830,7 @@ typedef struct install_template
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int timeout;
|
||||
int autosel;
|
||||
int cursel;
|
||||
int templatenum;
|
||||
@@ -860,6 +862,7 @@ typedef struct persistence_config
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
int timeout;
|
||||
int autosel;
|
||||
int cursel;
|
||||
int backendnum;
|
||||
@@ -923,6 +926,7 @@ typedef struct custom_boot
|
||||
typedef struct conf_replace
|
||||
{
|
||||
int pathlen;
|
||||
int img;
|
||||
char isopath[256];
|
||||
char orgconf[256];
|
||||
char newconf[256];
|
||||
@@ -987,6 +991,7 @@ typedef struct menu_password
|
||||
|
||||
extern int g_ventoy_menu_esc;
|
||||
extern int g_ventoy_suppress_esc;
|
||||
extern int g_ventoy_suppress_esc_default;
|
||||
extern int g_ventoy_last_entry;
|
||||
extern int g_ventoy_memdisk_mode;
|
||||
extern int g_ventoy_iso_raw;
|
||||
@@ -1106,5 +1111,7 @@ int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
|
||||
|
||||
#define ret_goto_end(a) ret = a; goto end;
|
||||
|
||||
extern ventoy_grub_param *g_grub_param;
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -691,6 +691,7 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
|
||||
static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_head *chain)
|
||||
{
|
||||
int id = 0;
|
||||
int virtid = 0;
|
||||
initrd_info *node;
|
||||
grub_uint64_t sector;
|
||||
grub_uint32_t offset;
|
||||
@@ -738,6 +739,7 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
offset += g_ventoy_cpio_size;
|
||||
sector += cpio_secs + initrd_secs;
|
||||
cur++;
|
||||
virtid++;
|
||||
}
|
||||
|
||||
/* Lenovo EasyStartup need an addional sector for boundary check */
|
||||
@@ -759,6 +761,7 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
offset += VTOY_APPEND_EXT_SIZE;
|
||||
sector += cpio_secs;
|
||||
cur++;
|
||||
virtid++;
|
||||
}
|
||||
|
||||
if (g_conf_replace_offset > 0)
|
||||
@@ -776,9 +779,15 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
|
||||
|
||||
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
|
||||
|
||||
if (g_grub_param->img_replace.magic == GRUB_IMG_REPLACE_MAGIC)
|
||||
{
|
||||
g_grub_param->img_replace.new_file_virtual_id = virtid;
|
||||
}
|
||||
|
||||
offset += g_conf_replace_new_len_align;
|
||||
sector += cpio_secs;
|
||||
cur++;
|
||||
virtid++;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -978,6 +987,12 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt)
|
||||
}
|
||||
}
|
||||
|
||||
/* skip hdt.img */
|
||||
if (file->size <= VTOY_SIZE_1MB && grub_strcmp(node->name, "/boot/hdt.img") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_strcmp(file->fs->name, "iso9660") == 0)
|
||||
{
|
||||
node->iso_type = 0;
|
||||
|
@@ -602,6 +602,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
{
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -638,6 +639,18 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
grub_printf("timeout: %d [OK]\n", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("timeout: %d [FAIL]\n", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -662,6 +675,18 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
grub_printf("timeout: %d [OK]\n", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("timeout: %d [FAIL]\n", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -682,6 +707,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
int type = 0;
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
install_template *node = NULL;
|
||||
@@ -729,6 +755,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
node->templatenum = pathnum;
|
||||
|
||||
node->autosel = -1;
|
||||
node->timeout = -1;
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
{
|
||||
if (autosel >= 0 && autosel <= pathnum)
|
||||
@@ -736,6 +763,14 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
node->autosel = autosel;
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
node->timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_install_template_head)
|
||||
{
|
||||
@@ -1175,6 +1210,7 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
int pathnum = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
@@ -1213,6 +1249,18 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
grub_printf("timeout: %d [OK]\n", timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("timeout: %d [FAIL]\n", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1231,6 +1279,7 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int autosel = 0;
|
||||
int timeout = 0;
|
||||
int pathnum = 0;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1273,6 +1322,7 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
|
||||
node->backendnum = pathnum;
|
||||
|
||||
node->autosel = -1;
|
||||
node->timeout = -1;
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
{
|
||||
if (autosel >= 0 && autosel <= pathnum)
|
||||
@@ -1280,6 +1330,14 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
|
||||
node->autosel = autosel;
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "timeout", &timeout))
|
||||
{
|
||||
if (timeout >= 0)
|
||||
{
|
||||
node->timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_persistence_head)
|
||||
{
|
||||
@@ -1947,6 +2005,7 @@ static int ventoy_plugin_custom_boot_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int img = 0;
|
||||
const char *isof = NULL;
|
||||
const char *orgf = NULL;
|
||||
const char *newf = NULL;
|
||||
@@ -1984,6 +2043,11 @@ static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk
|
||||
node = grub_zalloc(sizeof(conf_replace));
|
||||
if (node)
|
||||
{
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "img", &img))
|
||||
{
|
||||
node->img = img;
|
||||
}
|
||||
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", isof);
|
||||
grub_snprintf(node->orgconf, sizeof(node->orgconf), "%s", orgf);
|
||||
grub_snprintf(node->newconf, sizeof(node->newconf), "%s", newf);
|
||||
@@ -2006,6 +2070,7 @@ static int ventoy_plugin_conf_replace_entry(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int img = 0;
|
||||
const char *isof = NULL;
|
||||
const char *orgf = NULL;
|
||||
const char *newf = NULL;
|
||||
@@ -2075,7 +2140,7 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("new:<%s> [OK]\n", newf);
|
||||
grub_printf("new1:<%s> [OK]\n", newf);
|
||||
}
|
||||
grub_file_close(file);
|
||||
}
|
||||
@@ -2083,6 +2148,12 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
|
||||
{
|
||||
grub_printf("new:<%s> [NOT Exist]\n", newf);
|
||||
}
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "img", &img))
|
||||
{
|
||||
grub_printf("img:<%d>\n", img);
|
||||
}
|
||||
|
||||
grub_printf("\n");
|
||||
}
|
||||
}
|
||||
@@ -2267,45 +2338,59 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static plugin_entry g_plugin_entries[] =
|
||||
{
|
||||
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
|
||||
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
|
||||
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
|
||||
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
|
||||
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
|
||||
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check },
|
||||
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
|
||||
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
|
||||
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
|
||||
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
|
||||
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
|
||||
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
|
||||
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
|
||||
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
|
||||
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check },
|
||||
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check, 0 },
|
||||
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check, 0 },
|
||||
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check, 0 },
|
||||
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check, 0 },
|
||||
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check, 0 },
|
||||
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check, 0 },
|
||||
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check, 0 },
|
||||
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check, 0 },
|
||||
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check, 0 },
|
||||
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
|
||||
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
|
||||
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check, 0 },
|
||||
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check, 0 },
|
||||
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check, 0 },
|
||||
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check, 0 },
|
||||
};
|
||||
|
||||
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int i;
|
||||
char key[128];
|
||||
VTOY_JSON *cur = json;
|
||||
VTOY_JSON *cur = NULL;
|
||||
|
||||
grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
|
||||
|
||||
while (cur)
|
||||
for (cur = json; cur; cur = cur->pstNext)
|
||||
{
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
{
|
||||
grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix);
|
||||
if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0 || grub_strcmp(key, cur->pcName) == 0)
|
||||
if (g_plugin_entries[i].flag == 0 && grub_strcmp(key, cur->pcName) == 0)
|
||||
{
|
||||
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
|
||||
g_plugin_entries[i].entryfunc(cur, isodisk);
|
||||
g_plugin_entries[i].flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur = cur->pstNext;
|
||||
for (cur = json; cur; cur = cur->pstNext)
|
||||
{
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
{
|
||||
if (g_plugin_entries[i].flag == 0 && grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0)
|
||||
{
|
||||
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
|
||||
g_plugin_entries[i].entryfunc(cur, isodisk);
|
||||
g_plugin_entries[i].flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -3099,7 +3184,7 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
|
||||
grub_snprintf(key, sizeof(key), "%s_%s", args[1], g_arch_mode_suffix);
|
||||
for (node = json->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (grub_strcmp(node->pcName, args[1]) == 0 || grub_strcmp(node->pcName, key) == 0)
|
||||
if (grub_strcmp(node->pcName, key) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -3107,8 +3192,19 @@ grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, ch
|
||||
|
||||
if (!node)
|
||||
{
|
||||
grub_printf("%s is NOT found in ventoy.json\n", args[1]);
|
||||
goto end;
|
||||
for (node = json->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (grub_strcmp(node->pcName, args[1]) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!node)
|
||||
{
|
||||
grub_printf("%s is NOT found in ventoy.json\n", args[1]);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
|
||||
|
@@ -375,6 +375,7 @@ grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
|
||||
g_ventoy_menu_esc = 1;
|
||||
g_ventoy_suppress_esc = 1;
|
||||
g_ventoy_suppress_esc_default = 1;
|
||||
|
||||
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, size);
|
||||
grub_script_execute_sourcecode(configfile);
|
||||
|
@@ -242,6 +242,7 @@ typedef struct ventoy_img_chunk_list
|
||||
#pragma pack(1)
|
||||
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
|
||||
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
typedef int (*grub_env_set_pf)(const char *name, const char *val);
|
||||
@@ -260,6 +261,7 @@ typedef struct ventoy_grub_param
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace;
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
||||
|
@@ -22,9 +22,16 @@ porteus_hook() {
|
||||
$SED "/searching *for *\$CFG *file/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-disk.sh" -i $1
|
||||
}
|
||||
|
||||
if $GREP -q exfat /proc/filesystems; then
|
||||
vtPath=$($VTOY_PATH/tool/vtoydump -p $VTOY_PATH/ventoy_os_param)
|
||||
|
||||
vtPath=$($VTOY_PATH/tool/vtoydump -p $VTOY_PATH/ventoy_os_param)
|
||||
echo $vtPath | $GREP -q " "
|
||||
_vtRet1=$?
|
||||
|
||||
$GREP -q exfat /proc/filesystems
|
||||
_vtRet2=$?
|
||||
|
||||
echo "_vtRet1=$_vtRet1 _vtRet2=$_vtRet2 ..." >> $VTLOG
|
||||
|
||||
if [ $_vtRet1 -ne 0 -a $_vtRet2 -eq 0 ]; then
|
||||
vtFindFlag=0
|
||||
$GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' | while read vtline; do
|
||||
echo "hooking $vtline ..." >> $VTLOG
|
||||
@@ -34,11 +41,19 @@ if $GREP -q exfat /proc/filesystems; then
|
||||
|
||||
if [ $vtFindFlag -eq 0 ]; then
|
||||
if $GREP -q '`value from`' /linuxrc; then
|
||||
echo "hooking linuxrc ..." >> $VTLOG
|
||||
$SED "/searching *for *\$CFG *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
|
||||
$SED "/searching *for *\$CFG *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
|
||||
$SED "/searching *for *\$CFG *file/iISO=\$(cat /porteus-from)" -i /linuxrc
|
||||
vtFindFlag=1
|
||||
if $GREP -q "searching *for *\$CFG *file" /linuxrc; then
|
||||
echo "hooking linuxrc CFG..." >> $VTLOG
|
||||
$SED "/searching *for *\$CFG *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
|
||||
$SED "/searching *for *\$CFG *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
|
||||
$SED "/searching *for *\$CFG *file/iISO=\$(cat /porteus-from)" -i /linuxrc
|
||||
vtFindFlag=1
|
||||
else
|
||||
echo "hooking linuxrc SGN..." >> $VTLOG
|
||||
$SED "/searching *for *\$SGN *file/i$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/porteus-path.sh" -i /linuxrc
|
||||
$SED "/searching *for *\$SGN *file/iFROM=\$(cat /porteus-from)" -i /linuxrc
|
||||
$SED "/searching *for *\$SGN *file/iISO=\$(cat /porteus-from)" -i /linuxrc
|
||||
vtFindFlag=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -46,7 +61,7 @@ else
|
||||
for vtfile in '/linuxrc' '/init'; do
|
||||
if [ -e $vtfile ]; then
|
||||
if ! $GREP -q ventoy $vtfile; then
|
||||
echo "hooking $vtfile ..." >> $VTLOG
|
||||
echo "hooking disk $vtfile ..." >> $VTLOG
|
||||
porteus_hook $vtfile
|
||||
fi
|
||||
fi
|
||||
|
@@ -47,8 +47,29 @@ ventoy_os_install_dmsetup_by_fuse() {
|
||||
umount $VTOY_PATH/mnt/fuse
|
||||
}
|
||||
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
while [ -n "Y" ]; do
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
if [ -r /proc/sys/kernel/hotplug ]; then
|
||||
echo /sbin/mdev > /proc/sys/kernel/hotplug
|
||||
fi
|
||||
mdev -s
|
||||
sleep 1
|
||||
else
|
||||
if check_usb_disk_ready "$vtdiskname"; then
|
||||
vtlog "check_usb_disk_ready $vtdiskname ok"
|
||||
break
|
||||
else
|
||||
vtlog "check_usb_disk_ready $vtdiskname error"
|
||||
if [ -r /proc/sys/kernel/hotplug ]; then
|
||||
echo /sbin/mdev > /proc/sys/kernel/hotplug
|
||||
fi
|
||||
mdev -s
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
|
@@ -23,6 +23,11 @@ $SED "s#.*livefs_root=.*find_livefs.*#$BUSYBOX_PATH/mount -t iso9660 /dev/mapper
|
||||
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||
echo "Here before mountroot ..." >> $VTLOG
|
||||
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i /init
|
||||
|
||||
if [ -f /scripts/init-premount/ORDER ]; then
|
||||
$SED "/\/scripts\/init-premount\/partitioning/,+1d" -i /scripts/init-premount/ORDER
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Use default hook ..." >> $VTLOG
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
47
IMG/cpio/ventoy/loop/esysrescue/ventoy-disk.sh
Normal file
47
IMG/cpio/ventoy/loop/esysrescue/ventoy-disk.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
|
||||
ln -s "../../ventoy1" /dev/disk/by-label/ESYSRESCUE
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
26
IMG/cpio/ventoy/loop/esysrescue/ventoy-hook.sh
Normal file
26
IMG/cpio/ventoy/loop/esysrescue/ventoy-hook.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/maybe_break premount/i\ $BUSYBOX_PATH/sh $VTOY_PATH/loop/esysrescue/ventoy-disk.sh" -i /init
|
||||
|
||||
if [ -f /scripts/casper-bottom/09format_esr_data_partition ]; then
|
||||
$SED '/mkfs.vfat.*edev.3/icp -a /dev/dm-3 /dev/ventoy3' -i /scripts/casper-bottom/09format_esr_data_partition
|
||||
fi
|
Binary file not shown.
117
INSTALL/grub/checksum.cfg
Normal file
117
INSTALL/grub/checksum.cfg
Normal file
@@ -0,0 +1,117 @@
|
||||
|
||||
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.md5" ]; then
|
||||
set default=0
|
||||
menuentry "Calculate and check md5sum" --class=checksum_md5 {
|
||||
md5sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.md5" vtReadChecksum
|
||||
|
||||
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
|
||||
echo -e "\n\nCheck MD5 value with .md5 file. [ OK ]"
|
||||
else
|
||||
echo -e "\n\nCheck MD5 value with .md5 file. [ FAIL ]"
|
||||
echo "The MD5 value in .md5 file is:"
|
||||
echo "$vtReadChecksum"
|
||||
fi
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
else
|
||||
menuentry "Calculate md5sum" --class=checksum_md5 {
|
||||
md5sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
fi
|
||||
|
||||
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha1" ]; then
|
||||
set default=1
|
||||
menuentry "Calculate and check sha1sum" --class=checksum_sha1 {
|
||||
sha1sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha1" vtReadChecksum
|
||||
|
||||
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
|
||||
echo -e "\n\nCheck SHA1 value with .sha1 file. [ OK ]"
|
||||
else
|
||||
echo -e "\n\nCheck SHA1 value with .sha1 file. [ FAIL ]"
|
||||
echo "The SHA1 value in .sha1 file is:"
|
||||
echo "$vtReadChecksum"
|
||||
fi
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
else
|
||||
menuentry "Calculate sha1sum" --class=checksum_sha1 {
|
||||
sha1sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha256" ]; then
|
||||
set default=2
|
||||
menuentry "Calculate and check sha256sum" --class=checksum_sha256 {
|
||||
sha256sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha256" vtReadChecksum
|
||||
|
||||
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
|
||||
echo -e "\n\nCheck SHA256 value with .sha256 file. [ OK ]"
|
||||
else
|
||||
echo -e "\n\nCheck SHA256 value with .sha256 file. [ FAIL ]"
|
||||
echo "The SHA256 value in .sha256 file is:"
|
||||
echo "$vtReadChecksum"
|
||||
fi
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
else
|
||||
menuentry "Calculate sha256sum" --class=checksum_sha256 {
|
||||
sha256sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha512" ]; then
|
||||
set default=3
|
||||
menuentry "Calculate and check sha512sum" --class=checksum_sha512{
|
||||
sha512sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha512" vtReadChecksum
|
||||
|
||||
if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
|
||||
echo -e "\n\nCheck SHA512 value with .sha512 file. [ OK ]"
|
||||
else
|
||||
echo -e "\n\nCheck SHA512 value with .sha512 file. [ FAIL ]"
|
||||
echo "The SHA512 value in .sha512 file is:"
|
||||
echo "$vtReadChecksum"
|
||||
fi
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
else
|
||||
menuentry "Calculate sha512sum" --class=checksum_sha512{
|
||||
sha512sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
|
||||
|
||||
echo -e "\n\npress ENTER to exit ..."
|
||||
read vtInputKey
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
|
||||
echo 'Return ...'
|
||||
}
|
@@ -90,6 +90,28 @@ function ventoy_ext_menu {
|
||||
fi
|
||||
}
|
||||
|
||||
function ventoy_checksum {
|
||||
if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then
|
||||
configfile $prefix/checksum.cfg
|
||||
fi
|
||||
}
|
||||
|
||||
function ventoy_show_help {
|
||||
if [ -f $prefix/help.tar.gz ]; then
|
||||
if [ -z "$vtoy_help_txt_mem_addr" ]; then
|
||||
vt_load_file_to_mem "auto" $prefix/help.tar.gz vtoy_help_txt_mem
|
||||
fi
|
||||
|
||||
loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size}
|
||||
if [ -f "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt" ]; then
|
||||
cat "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt"
|
||||
else
|
||||
cat "(vt_help_tarfs)/help/en_US.txt"
|
||||
fi
|
||||
loopback -d vt_help_tarfs
|
||||
fi
|
||||
}
|
||||
|
||||
function get_os_type {
|
||||
set vtoy_os=Linux
|
||||
|
||||
@@ -225,7 +247,8 @@ function distro_specify_initrd_file {
|
||||
vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
|
||||
elif [ -f (loop)/boot/isolinux/initramfs_data64.cpio.gz ]; then
|
||||
vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
|
||||
|
||||
elif [ -f (loop)/boot/initrd.img ]; then
|
||||
vt_linux_specify_initrd_file /boot/initrd.img
|
||||
|
||||
fi
|
||||
|
||||
@@ -332,6 +355,8 @@ function distro_specify_initrd_file_phase2 {
|
||||
vt_linux_specify_initrd_file /porteus/initrd.xz
|
||||
elif [ -f (loop)/pyabr/boot/initrfs.img ]; then
|
||||
vt_linux_specify_initrd_file /pyabr/boot/initrfs.img
|
||||
elif [ -f (loop)/initrd0.img ]; then
|
||||
vt_linux_specify_initrd_file /initrd0.img
|
||||
|
||||
fi
|
||||
}
|
||||
@@ -1668,6 +1693,23 @@ function ventoy_img_recalbox {
|
||||
vt_unset_boot_opt
|
||||
}
|
||||
|
||||
function ventoy_img_esysrescue {
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
||||
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||
|
||||
ventoy_debug_pause
|
||||
|
||||
#boot image file
|
||||
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=esysrescue
|
||||
vt_img_hook_root
|
||||
|
||||
set root=(vtimghd,1)
|
||||
configfile (vtimghd,1)/boot/grub/grub.cfg
|
||||
|
||||
vt_img_unhook_root
|
||||
vt_unset_boot_opt
|
||||
}
|
||||
|
||||
function ventoy_img_batocera {
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
||||
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||
@@ -1920,6 +1962,8 @@ function img_common_menuentry {
|
||||
ventoy_img_tails
|
||||
elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
|
||||
ventoy_img_recalbox
|
||||
elif [ "$vtImgHd1Label" = "ESYSRESCUE" ]; then
|
||||
ventoy_img_esysrescue
|
||||
elif [ -e (vtimghd,1)/easy.sfs ]; then
|
||||
ventoy_img_easyos
|
||||
elif [ -e (vtimghd,1)/volumio.initrd ]; then
|
||||
@@ -1967,7 +2011,7 @@ function img_unsupport_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.55"
|
||||
set VENTOY_VERSION="1.0.57"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
@@ -1987,6 +2031,11 @@ set VTOY_F2_CMD="ventoy_power"
|
||||
set VTOY_F4_CMD="ventoy_localboot"
|
||||
set VTOY_F5_CMD="ventoy_diagnosis"
|
||||
set VTOY_F6_CMD="ventoy_ext_menu"
|
||||
set VTOY_HELP_CMD="ventoy_show_help"
|
||||
set VTOY_CHKSUM_CMD="ventoy_checksum"
|
||||
set VTOY_HELP_TXT_LANGUAGE="en_US"
|
||||
set VTOY_CHKSUM_FILE_PATH="X"
|
||||
|
||||
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
|
||||
@@ -2076,10 +2125,10 @@ fi
|
||||
|
||||
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
|
||||
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
|
||||
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
|
||||
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
|
||||
else
|
||||
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
|
||||
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
|
||||
set VTOY_HOTKEY_TIP="h:Help F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
|
||||
fi
|
||||
|
||||
|
||||
@@ -2167,6 +2216,14 @@ export VTOY_ISO_RAW_STR
|
||||
export VTOY_GRUB2_MODE_STR
|
||||
export VTOY_WIMBOOT_MODE_STR
|
||||
export VTOY_ISO_UEFI_DRV_STR
|
||||
export VTOY_F2_CMD
|
||||
export VTOY_F4_CMD
|
||||
export VTOY_F5_CMD
|
||||
export VTOY_F6_CMD
|
||||
export VTOY_HELP_CMD
|
||||
export VTOY_CHKSUM_CMD
|
||||
export VTOY_HELP_TXT_LANGUAGE
|
||||
export VTOY_CHKSUM_FILE_PATH
|
||||
|
||||
|
||||
#special VTOY_DEFAULT_IMAGE process
|
||||
|
18
INSTALL/grub/help/en_US.txt
Normal file
18
INSTALL/grub/help/en_US.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
h - Display this help information
|
||||
F1 - Memdisk Mode (Only for small WinPE/LiveCD ISO/IMG)
|
||||
F2 - Reboot/Power off
|
||||
F3 - Switch menu mode between Treeview <-> ListView
|
||||
F4 - Boot Windows/Linux in local disk
|
||||
F5 - Utilities
|
||||
F6 - Load Custom Grub2 Menu
|
||||
F7 - Switch between GUI Mode <-> TEXT Mode
|
||||
|
||||
m - Checksum image files (md5/sha1/sha256/sha512)
|
||||
Ctrl+w - WIMBOOT Mode (Only for standard Windows ISO)
|
||||
Ctrl+r - Grub2 Mode (Only for some Linux distros)
|
||||
Ctrl+i - Compatible Mode (Just only for debug)
|
||||
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
|
||||
|
||||
|
||||
|
||||
Press ESC to return ......
|
16
INSTALL/grub/help/fr_FR.txt
Normal file
16
INSTALL/grub/help/fr_FR.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
h - Afficher cette aide
|
||||
F1 - Mode Memdisk (Seulement pour WinPE/LiveCD ISO/IMG)
|
||||
F2 - Redémarrer/arrêter
|
||||
F3 - Basculer l'affichage 'Vue en arbre' <-> 'Vue en liste'
|
||||
F4 - Démarrer le système Windows/Linux local
|
||||
F5 - Utilitaires
|
||||
F6 - Charger le menu Grub2 personnalisé
|
||||
F7 - Basculer entre le mode graphique <-> mode texte
|
||||
|
||||
m - Somme de contrôle des images (md5/sha1/sha256/sha512)
|
||||
Ctrl+w - Mode WIMBOOT (seulement pour les images standards Windows)
|
||||
Ctrl+r - Mode Grub2 (seulement pour quelques Linux)
|
||||
Ctrl+i - Mode Compatible (seulement à fins de tests)
|
||||
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
|
||||
|
||||
Appuyer sur Echap pour sortir ......
|
17
INSTALL/grub/help/hr_HR.txt
Normal file
17
INSTALL/grub/help/hr_HR.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
h - Prikazuje ove informacije
|
||||
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
|
||||
F2 - Ponovno pokretanje/isključivanje
|
||||
F3 - Mijenja meni između TreeView <-> ListView
|
||||
F4 - Pokreće Windows/Linux na lokalnom disku
|
||||
F5 - Postavke
|
||||
F6 - Učitava prilagođen GRUB2 meni
|
||||
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
|
||||
|
||||
m - Generira kontrolnu sumu odabranog imidž fajla (md5/sha1/sha256/sha512)
|
||||
Ctrl + w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
|
||||
Ctrl + r - GRUB2 način rada (samo za neke Linux distribucije)
|
||||
Ctrl + i - Kompatibilni način rada (samo za testiranje)
|
||||
Ctrl + u - Load ISO efi driver (Just only for debug, can not be used officially)
|
||||
|
||||
|
||||
Pritisnite ESC za povratak...
|
18
INSTALL/grub/help/id_ID.txt
Normal file
18
INSTALL/grub/help/id_ID.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
h - Tampilkan bantuan informasi ini
|
||||
F1 - Mode Memdisk (Hanya untuk ukuran WinPE/LiveCD ISO/IMG yang kecil)
|
||||
F2 - Mulai ulang/Matikan
|
||||
F3 - Beralih mode menu antara Treeview <-> ListView
|
||||
F4 - Jalankan (boot) Windows/Linux pada disk lokal
|
||||
F5 - Alat Utilitas
|
||||
F6 - Memuat ubah suai Grub2 Menu
|
||||
F7 - Beralih antara mode GUI <-> Mode TEXT
|
||||
|
||||
m - Periksa berkas files (md5/sha1/sha256/sha512)
|
||||
Ctrl+w - Mode WIMBOOT (Hanya untuk berkas ISO Windows standar)
|
||||
Ctrl+r - Mode Grub2 (Hanya untuk distro Linux tertentu)
|
||||
Ctrl+i - Mode Kompatibel/Compatible (Hanya untuk debug saja)
|
||||
Ctrl+u - Memuat ISO efi driver (Hanya untuk debug saja, tidak dapat dipakai secara umum)
|
||||
|
||||
|
||||
|
||||
Tekan ESC untuk kembali ......
|
17
INSTALL/grub/help/pt_PT.txt
Normal file
17
INSTALL/grub/help/pt_PT.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
h - Mostra esta informação de ajuda
|
||||
F1 - Modo Memdisk (Apenas para pequenos WinPE/LiveCD ISO/IMG)
|
||||
F2 - Reiniciar/Desligar
|
||||
F3 - Alternar o modo menu entre Vista de árvore <-> Vista de lista
|
||||
F4 - Arrancar o Windows/Linux em disco local
|
||||
F5 - Utilitários
|
||||
F6 - Carregar menu Grub2 personalizado
|
||||
F7 - Alternar entre Modo GUI <-> Modo TEXTO
|
||||
|
||||
m - Checksum ficheiros de imagem (md5/sha1/sha256/sha512)
|
||||
Ctrl+w - Modo WIMBOOT (Apenas para Windows ISO padrão)
|
||||
Ctrl+r - Modo Grub2 (Apenas para algumas distros Linux)
|
||||
Ctrl+i - Modo Compatível (Apenas para depuração)
|
||||
Ctrl+u - Carregar o controlador ISO efi (Apenas para depuração, não pode ser utilizado oficialmente)
|
||||
|
||||
|
||||
Prima ESC para voltar ......
|
17
INSTALL/grub/help/sr_CY.txt
Normal file
17
INSTALL/grub/help/sr_CY.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
h - Приказује ове информације
|
||||
F1 - Memdisk начин рада (само за мале WinPE/LiveCD имиџ фајлове)
|
||||
F2 - Поновно покретање/искључивање
|
||||
F3 - Мијења мени између TreeView <-> ListView
|
||||
F4 - Покреће Windows/Linux на локалном диску
|
||||
F5 - Поставке
|
||||
F6 - Учитава прилагођен GRUB2 мени
|
||||
F7 - Мијења између GUI начина рада <-> TEXT начина рада
|
||||
|
||||
m - Генерира контролну суму одабраног имиџ фајла (md5/sha1/sha256/sha512)
|
||||
Ctrl + w - WIMBOOT начин рада (само за стандардне Windows имиџ фајлове)
|
||||
Ctrl + r - GRUB2 начин рада (само за неке Linux дистрибуције)
|
||||
Ctrl + i - Компатибилни начин рада (само за тестиранје)
|
||||
Ctrl + u - Load ISO efi driver (Just only for debug, can not be used officially)
|
||||
|
||||
|
||||
Притисните ESC за повратак...
|
17
INSTALL/grub/help/sr_SR.txt
Normal file
17
INSTALL/grub/help/sr_SR.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
h - Prikazuje ove informacije
|
||||
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
|
||||
F2 - Ponovno pokretanje/isključivanje
|
||||
F3 - Mijenja meni između TreeView <-> ListView
|
||||
F4 - Pokreće Windows/Linux na lokalnom disku
|
||||
F5 - Postavke
|
||||
F6 - Učitava prilagođen GRUB2 meni
|
||||
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
|
||||
|
||||
m - Generira kontrolnu sumu odabranog imidž fajla (md5/sha1/sha256/sha512)
|
||||
Ctrl + w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
|
||||
Ctrl + r - GRUB2 način rada (samo za neke Linux distribucije)
|
||||
Ctrl + i - Kompatibilni način rada (samo za testiranje)
|
||||
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
|
||||
|
||||
|
||||
Pritisnite ESC za povratak...
|
17
INSTALL/grub/help/tr_TR.txt
Normal file
17
INSTALL/grub/help/tr_TR.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
h - Yardım bilgilerini göster
|
||||
F1 - Memdisk Modu başlatır(Yalnızca küçük WinPE/LiveCD ISO/IMG ler için bu modu kullanabilirsiniz)
|
||||
F2 - Bilgisayarı Yeniden Başlat/Kapat
|
||||
F3 - Ventoy Menü modu olarak,Klasör görünümü(Treeview) ile Liste görünümü(ListView) arasında geçiş yapmayı sağlar.
|
||||
F4 - Bilgisayarınızda yüklü olan Windows yada Linux işletim sistemini, sabit diskten başlatır.
|
||||
F5 - Ventoy Araçlar menüsü
|
||||
F6 - Özelleştirilmiş Grub2 menüsünü yükler
|
||||
F7 - Grafik Modu(GUI Mode) ile Metin Modu(Text Mode) arasında geçiş yapmayı sağlar
|
||||
|
||||
m - İndirilen imaj dosyalarının hatasız indirildiğini teyit etmek için "md5/sha1/sha256/sha512" değerlerini kontrol etmeyi sağlar
|
||||
Ctrl+w - WIMBOOT Modu çalıştırmayı sağlar(Sadece normal Windows ISO ları için)
|
||||
Ctrl+r - Grub2 Modu çalıştırmayı sağlar (Sadece bazı Linux dağıtımları için)
|
||||
Ctrl+i - Uyumluluk Modu'nu (Compatible Mode) çalıştırmayı sağlar (Sadece hata ayıklama için bu modu kullanabilirsiniz)
|
||||
Ctrl+u - ISO efi sürücüsünü yükler(Sadece hata ayıklama için bu mod kullanılabilir, resmi olarak kullanılamaz)
|
||||
|
||||
|
||||
Geriye dönmek için ESC tuşuna basınız......
|
17
INSTALL/grub/help/zh_CN.txt
Normal file
17
INSTALL/grub/help/zh_CN.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
h - 显示本帮助信息
|
||||
F1 - 把文件加载到内存启动(只适用于文件很小的 WinPE/LiveCD等)
|
||||
F2 - 电源操作 (重启、关机)
|
||||
F3 - 菜单显示模式切换。可在列表模式和目录模式之间自由切换。
|
||||
F4 - 启动本地硬盘上的 Windows/Linux 等系统。
|
||||
F5 - 各类工具
|
||||
F6 - 加载自定义 GRUB2 菜单。
|
||||
F7 - 界面在文本模式和图形模式之间切换。
|
||||
|
||||
m - 计算文件校验值(md5/sha1/sha256/sha512)
|
||||
Ctrl+w - WIMBOOT 模式 (只适用于标准的 Windows ISO文件)
|
||||
Ctrl+r - Grub2 模式 (只适用于常见的一些 Linux 系统ISO文件)
|
||||
Ctrl+i - 兼容模式 (只用作调试目的,不能正式使用)
|
||||
Ctrl+u - 加载 ISO efi 驱动(只用作调试目的,不能正式使用)
|
||||
|
||||
|
||||
按 ESC 键返回 ......
|
@@ -46,7 +46,7 @@ terminal-box: "terminal_box_*.png"
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 30%
|
||||
left = 28%
|
||||
top = 95%
|
||||
width = 10%
|
||||
height = 25
|
||||
|
@@ -980,29 +980,29 @@
|
||||
"STR_INCORRECT_DIR":"Si prega di eseguire nella cartella corretta",
|
||||
"STR_INCORRECT_TREE_DIR":"Non eseguire qui, scarica il pacchetto di installazione ed avvialo",
|
||||
"STR_DEVICE":"Dispositivo",
|
||||
"STR_LOCAL_VER":"Versione Locale di Ventoy",
|
||||
"STR_LOCAL_VER":"Versione locale di Ventoy",
|
||||
"STR_DISK_VER":"Ventoy nel dispositivo",
|
||||
"STR_STATUS":"Stato - PRONTO",
|
||||
"STR_INSTALL":"Installa",
|
||||
"STR_UPDATE":"Aggiorna",
|
||||
"STR_UPDATE_TIP":"L'aggiornamento è sicuro, i file presenti nel dispositivo rimarranno invariati.#@Continuare?",
|
||||
"STR_INSTALL_TIP":"Il disco verrà formattato e tutti i dati saranno persi.#@Continuare?",
|
||||
"STR_INSTALL_TIP2":"Il disco verrà formattato e tutti i dati saranno persi.#@Continuare?' (Seconda Verifica)",
|
||||
"STR_INSTALL_TIP2":"Il disco verrà formattato e tutti i dati saranno persi.#@Continuare?' (seconda verifica)",
|
||||
"STR_INSTALL_SUCCESS":"Congratulazioni!#@Ventoy è stato installato con successo nel dispositivo",
|
||||
"STR_INSTALL_FAILED":"Si è verificato un errore durante l'installazione. Reinserisci il dispostivo e riprova. Controlla il file log.txt per i dettagli.",
|
||||
"STR_INSTALL_FAILED":"Si è verificato un errore durante l'installazione. Riconnetti il dispostivo e riprova. Controlla il file log.txt per i dettagli.",
|
||||
"STR_UPDATE_SUCCESS":"Congratulazioni!#@Ventoy è stato aggiornato con successo nel dispositivo",
|
||||
"STR_UPDATE_FAILED":"Si è verificato un errore durante l'aggiornamento. Reinserisci il dispostivo e riprova. Controlla il file log.txt per i dettagli.",
|
||||
"STR_UPDATE_FAILED":"Si è verificato un errore durante l'aggiornamento. Riconnetti il dispostivo e riprova. Controlla il file log.txt per i dettagli.",
|
||||
"STR_WAIT_PROCESS":"Un processo è in esecuzione, attendere prego...",
|
||||
"STR_MENU_OPTION":"Opzioni",
|
||||
"STR_MENU_SECURE_BOOT":"Avvio protetto (secure boot)",
|
||||
"STR_MENU_PART_CFG":"Configurazione della partizione",
|
||||
"STR_BTN_OK":"OK",
|
||||
"STR_BTN_CANCEL":"Annulla",
|
||||
"STR_PRESERVE_SPACE":"Conserva spazio nella parte finale del disco",
|
||||
"STR_PRESERVE_SPACE":"Riserva spazio nella parte finale del disco",
|
||||
"STR_SPACE_VAL_INVALID":"Quantità di spazio da riservare non valida",
|
||||
"STR_MENU_CLEAR":"Rimuovi Ventoy",
|
||||
"STR_CLEAR_SUCCESS":"Ventoy è stato rimosso con successo dal dispositivo.",
|
||||
"STR_CLEAR_FAILED":"Si è verificato un errore durante la rimozione di Ventoy dal dispositivo. Reinserisci il dispositivo e riprova. Controlla il file log.txt per maggiori dettagli",
|
||||
"STR_CLEAR_FAILED":"Si è verificato un errore durante la rimozione di Ventoy dal dispositivo. Riconnetti il dispositivo e riprova. Controlla il file log.txt per maggiori dettagli",
|
||||
"STR_MENU_PART_STYLE":"Stile Tabella delle partizioni",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Seleziona GPT per dischi con dimensioni maggiori di 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Mostra tutti i dispositivi",
|
||||
@@ -1015,7 +1015,7 @@
|
||||
"STR_WEB_SERVICE_BUSY":"Il servizio è occupato, riprova più tardi.",
|
||||
"STR_MENU_VTSI_CREATE":"Genera file VTSI",
|
||||
"STR_VTSI_CREATE_TIP":"Questa volta non scriverà sul dispositivo, ma genererà solo un file VTSI#@Continuare?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"File VTSI creato con successo!#@Puoiusare Rufus(3.15+)per scrivere sul dispositivo in modo da completare l'installazione di Ventoy.",
|
||||
"STR_VTSI_CREATE_SUCCESS":"File VTSI creato con successo!#@Puoi usare Rufus (versione 3.15 o successiva) per scrivere sul dispositivo in modo da completare l'installazione di Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"Creazione File VTSI non riuscito.",
|
||||
"STRXXX":""
|
||||
},
|
||||
@@ -1584,13 +1584,13 @@
|
||||
"name":"Portuguese (Português de Portugal)",
|
||||
"FontFamily":"Courier New",
|
||||
"FontSize":16,
|
||||
"Author":"Eskiso",
|
||||
"Author":"Eskiso, Hugo Carvalho",
|
||||
|
||||
"STR_ERROR":"Erro",
|
||||
"STR_WARNING":"Aviso",
|
||||
"STR_INFO":"Info",
|
||||
"STR_INCORRECT_DIR":"Por favor, execute na pasta correta!",
|
||||
"STR_INCORRECT_TREE_DIR":"Não me execute aqui, por favor transfira o pacote de instalação, e execute lá.",
|
||||
"STR_INCORRECT_DIR":"Execute na pasta correta!",
|
||||
"STR_INCORRECT_TREE_DIR":"Não me execute aqui, transfira o pacote de instalação e execute lá.",
|
||||
"STR_DEVICE":"Dispositivo",
|
||||
"STR_LOCAL_VER":"Ventoy em pacote",
|
||||
"STR_DISK_VER":"Ventoy no dispositivo",
|
||||
@@ -1601,34 +1601,34 @@
|
||||
"STR_INSTALL_TIP":"O disco será formatado e todos os dados serão perdidos.#@Continuar?",
|
||||
"STR_INSTALL_TIP2":"O disco será formatado e todos os dados serão perdidos.#@Continuar? (Confirmação)",
|
||||
"STR_INSTALL_SUCCESS":"Parabéns!#@Ventoy foi instalado com sucesso no dispositivo.",
|
||||
"STR_INSTALL_FAILED":"Um erro ocorreu durante a instalação. Pode reconectar o dispositivo USB e tentar novamente. Verifique o ficheiro log.txt para mais detalhes.",
|
||||
"STR_INSTALL_FAILED":"Ocorreu um erro durante a instalação. Pode voltar a ligar o dispositivo USB e tentar novamente. Verifique o ficheiro log.txt para mais detalhes.",
|
||||
"STR_UPDATE_SUCCESS":"Parabéns!#@Ventoy foi atualizado com sucesso no dispositivo.",
|
||||
"STR_UPDATE_FAILED":"Um erro ocorreu durante a atualização. Pode reconectar o dispositivo USB e tentar novamente. Verifique o ficheiro log.txt para mais detalhes.",
|
||||
"STR_WAIT_PROCESS":"Uma thread está em execução, por favor espere...",
|
||||
"STR_UPDATE_FAILED":"Ocorreu um erro durante a atualização. Pode voltar a ligar o dispositivo USB e tentar novamente. Verifique o ficheiro log.txt para mais detalhes.",
|
||||
"STR_WAIT_PROCESS":"Uma thread está em execução, aguarde...",
|
||||
"STR_MENU_OPTION":"Opção",
|
||||
"STR_MENU_SECURE_BOOT":"Boot seguro",
|
||||
"STR_MENU_PART_CFG":"Configuração da Partição",
|
||||
"STR_BTN_OK":"OK",
|
||||
"STR_MENU_SECURE_BOOT":"Arranque seguro",
|
||||
"STR_MENU_PART_CFG":"Configuração da partição",
|
||||
"STR_BTN_OK":"Aceitar",
|
||||
"STR_BTN_CANCEL":"Cancelar",
|
||||
"STR_PRESERVE_SPACE":"Preservar algum espaço no final do disco",
|
||||
"STR_SPACE_VAL_INVALID":"Valor invalido para o espaço reservado",
|
||||
"STR_PRESERVE_SPACE":"Reservar algum espaço no final do disco",
|
||||
"STR_SPACE_VAL_INVALID":"Valor inválido para o espaço reservado",
|
||||
"STR_MENU_CLEAR":"Remover o Ventoy",
|
||||
"STR_CLEAR_SUCCESS":"O Ventoy foi removido deste dispositivo com sucesso.",
|
||||
"STR_CLEAR_FAILED":"Um erro ocorreu ao remover o Ventoy do disco. Pode reconectar o dispositivo USB e tentar novamente. Verifique o ficheiro log.txt para mais detalhes.",
|
||||
"STR_MENU_PART_STYLE":"Estilo de Partição",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Por favor selecione GPT para discos maiores que 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Show All Devices",
|
||||
"STR_PART_ALIGN_4KB":"Align partitions with 4KB",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Communication error:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STR_CLEAR_FAILED":"Um erro ocorreu ao remover o Ventoy do disco. Pode voltar a ligar o dispositivo USB e tentar novamente. Verifique o ficheiro log.txt para mais detalhes.",
|
||||
"STR_MENU_PART_STYLE":"Estilo de partição",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Selecione GPT para discos maiores que 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Mostrar todos os dispositivos",
|
||||
"STR_PART_ALIGN_4KB":"Alinhar as partições com 4KB",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Erro de comunicação:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Erro de comunicação: Anomalia remota",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Erro de comunicação: Pedido de tempo limite",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Erro de comunicação: Serviço indisponível",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Estado do daemon atualizado, tente novamente mais tarde.",
|
||||
"STR_WEB_SERVICE_BUSY":"Serviço está ocupado, tente novamente mais tarde.",
|
||||
"STR_MENU_VTSI_CREATE":"Gerar ficheiro VTSI",
|
||||
"STR_VTSI_CREATE_TIP":"Desta vez não irá gravar no dispositivo, mas apenas gerar um ficheiro VTSI#@Continuar?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"Ficheiro VTSI criado com sucesso!#@Pode utilizar o Rufus(3.15+) para o gravar no dispositivo de modo a completar a instalação do Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"Falha no ficheiro VTSI criado.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1668,7 +1668,7 @@
|
||||
"STR_CLEAR_FAILED":"Terjadi kesalahan ketika penghapusan berlangsung. Anda perlu mencabut-pasang ulang USB dan coba lagi. Cek log.txt untuk detil.",
|
||||
"STR_MENU_PART_STYLE":"Gaya Partisi",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Silakan pilih GPT untuk disk yang lebih dari 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Show All Devices",
|
||||
"STR_SHOW_ALL_DEV":"Tampilkan semua perangkat",
|
||||
"STR_PART_ALIGN_4KB":"Meluruskan dengan partisi 4KB",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Kesalahan komunikasi:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Kesalahan komunikasi: tidak normalnya kendali",
|
||||
@@ -1828,11 +1828,11 @@
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Kommunikationsfel: Begäran tog för lång tid",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Kommunikationsfel: Tjänsten är inte tillgänglig",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon-status uppdaterad. Försök igen senare.",
|
||||
"STR_WEB_SERVICE_BUSY":"Tjänster är upptagen. Försök igen senare.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STR_WEB_SERVICE_BUSY":"Tjänsten är upptagen. Försök igen senare.",
|
||||
"STR_MENU_VTSI_CREATE":"Skapa VTSI-fil",
|
||||
"STR_VTSI_CREATE_TIP":"Den här gången skrivs det inget till enheten, utan det skapas endast en VTSI-fil#@Fortsätta?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI-filen skapad!#@Använd Rufus (3.15+) till att skriva till enheten för att slutföra installationen av Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"Misslyckades med att skapa VTSI-filen.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@ You can copy many image files at a time and ventoy will give you a boot menu to
|
||||
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.<br/>
|
||||
Both MBR and GPT partition style are supported in the same way.<br/>
|
||||
Most type of OS supported(Windows/WinPE/Linux/Unix/ChromeOS/Vmware/Xen...) <br/>
|
||||
750+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/>
|
||||
760+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/>
|
||||
<br/>Official Website: <a href=https://www.ventoy.net>https://www.ventoy.net</a>
|
||||
</h4>
|
||||
|
||||
@@ -52,7 +52,7 @@ VMware ESXi, Citrix XenServer, Xen XCP-ng
|
||||
* FAT32/exFAT/NTFS/UDF/XFS/Ext2(3)(4) supported for main partition
|
||||
* ISO files larger than 4GB supported
|
||||
* Native boot menu style for Legacy & UEFI
|
||||
* Most type of OS supported, 750+ iso files tested
|
||||
* Most type of OS supported, 760+ iso files tested
|
||||
* Linux vDisk boot supported
|
||||
* Not only boot but also complete installation process
|
||||
* Menu dynamically switchable between List/TreeView mode
|
||||
|
@@ -41,7 +41,7 @@ BOOL VDS_ChangeVtoyEFIAttr(int DriveIndex, UINT64 Attr);
|
||||
BOOL VDS_CreateVtoyEFIPart(int DriveIndex, UINT64 Offset);
|
||||
BOOL VDS_ChangeVtoyEFI2ESP(int DriveIndex, UINT64 Offset);
|
||||
BOOL VDS_ChangeVtoyEFI2Basic(int DriveIndex, UINT64 Offset);
|
||||
|
||||
BOOL VDS_FormatVtoyEFIPart(int DriveIndex, UINT64 Offset);
|
||||
|
||||
//diskpart.exe
|
||||
BOOL DSPT_CleanDisk(int DriveIndex);
|
||||
|
@@ -28,9 +28,515 @@
|
||||
#include "DiskService.h"
|
||||
|
||||
|
||||
|
||||
// Count on Microsoft to add a new API while not bothering updating the existing error facilities,
|
||||
// so that the new error messages have to be handled manually. Now, since I don't have all day:
|
||||
// 1. Copy text from https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-vds/5102cc53-3143-4268-ba4c-6ea39e999ab4
|
||||
// 2. awk '{l[NR%7]=$0} {if (NR%7==0) printf "\tcase %s:\t// %s\n\t\treturn \"%s\";\n", l[1], l[3], l[6]}' vds.txt
|
||||
// 3. Filter out the crap we don't need.
|
||||
static const char *GetVdsError(DWORD error_code)
|
||||
{
|
||||
switch (error_code) {
|
||||
case 0x80042400: // VDS_E_NOT_SUPPORTED
|
||||
return "The operation is not supported by the object.";
|
||||
case 0x80042401: // VDS_E_INITIALIZED_FAILED
|
||||
return "VDS or the provider failed to initialize.";
|
||||
case 0x80042402: // VDS_E_INITIALIZE_NOT_CALLED
|
||||
return "VDS did not call the hardware provider's initialization method.";
|
||||
case 0x80042403: // VDS_E_ALREADY_REGISTERED
|
||||
return "The provider is already registered.";
|
||||
case 0x80042404: // VDS_E_ANOTHER_CALL_IN_PROGRESS
|
||||
return "A concurrent second call is made on an object before the first call is completed.";
|
||||
case 0x80042405: // VDS_E_OBJECT_NOT_FOUND
|
||||
return "The specified object was not found.";
|
||||
case 0x80042406: // VDS_E_INVALID_SPACE
|
||||
return "The specified space is neither free nor valid.";
|
||||
case 0x80042407: // VDS_E_PARTITION_LIMIT_REACHED
|
||||
return "No more partitions can be created on the specified disk.";
|
||||
case 0x80042408: // VDS_E_PARTITION_NOT_EMPTY
|
||||
return "The extended partition is not empty.";
|
||||
case 0x80042409: // VDS_E_OPERATION_PENDING
|
||||
return "The operation is still in progress.";
|
||||
case 0x8004240A: // VDS_E_OPERATION_DENIED
|
||||
return "The operation is not permitted on the specified disk, partition, or volume.";
|
||||
case 0x8004240B: // VDS_E_OBJECT_DELETED
|
||||
return "The object no longer exists.";
|
||||
case 0x8004240C: // VDS_E_CANCEL_TOO_LATE
|
||||
return "The operation can no longer be canceled.";
|
||||
case 0x8004240D: // VDS_E_OPERATION_CANCELED
|
||||
return "The operation has already been canceled.";
|
||||
case 0x8004240E: // VDS_E_CANNOT_EXTEND
|
||||
return "The file system does not support extending this volume.";
|
||||
case 0x8004240F: // VDS_E_NOT_ENOUGH_SPACE
|
||||
return "There is not enough space to complete the operation.";
|
||||
case 0x80042410: // VDS_E_NOT_ENOUGH_DRIVE
|
||||
return "There are not enough free disk drives in the subsystem to complete the operation.";
|
||||
case 0x80042411: // VDS_E_BAD_COOKIE
|
||||
return "The cookie was not found.";
|
||||
case 0x80042412: // VDS_E_NO_MEDIA
|
||||
return "There is no removable media in the drive.";
|
||||
case 0x80042413: // VDS_E_DEVICE_IN_USE
|
||||
return "The device is currently in use.";
|
||||
case 0x80042414: // VDS_E_DISK_NOT_EMPTY
|
||||
return "The disk contains partitions or volumes.";
|
||||
case 0x80042415: // VDS_E_INVALID_OPERATION
|
||||
return "The specified operation is not valid.";
|
||||
case 0x80042416: // VDS_E_PATH_NOT_FOUND
|
||||
return "The specified path was not found.";
|
||||
case 0x80042417: // VDS_E_DISK_NOT_INITIALIZED
|
||||
return "The specified disk has not been initialized.";
|
||||
case 0x80042418: // VDS_E_NOT_AN_UNALLOCATED_DISK
|
||||
return "The specified disk is not an unallocated disk.";
|
||||
case 0x80042419: // VDS_E_UNRECOVERABLE_ERROR
|
||||
return "An unrecoverable error occurred. The service MUST shut down.";
|
||||
case 0x0004241A: // VDS_S_DISK_PARTIALLY_CLEANED
|
||||
return "The clean operation was not a full clean or was canceled before it could be completed.";
|
||||
case 0x8004241B: // VDS_E_DMADMIN_SERVICE_CONNECTION_FAILED
|
||||
return "The provider failed to connect to the LDMA service.";
|
||||
case 0x8004241C: // VDS_E_PROVIDER_INITIALIZATION_FAILED
|
||||
return "The provider failed to initialize.";
|
||||
case 0x8004241D: // VDS_E_OBJECT_EXISTS
|
||||
return "The object already exists.";
|
||||
case 0x8004241E: // VDS_E_NO_DISKS_FOUND
|
||||
return "No disks were found on the target machine.";
|
||||
case 0x8004241F: // VDS_E_PROVIDER_CACHE_CORRUPT
|
||||
return "The cache for a provider is corrupt.";
|
||||
case 0x80042420: // VDS_E_DMADMIN_METHOD_CALL_FAILED
|
||||
return "A method call to the LDMA service failed.";
|
||||
case 0x00042421: // VDS_S_PROVIDER_ERROR_LOADING_CACHE
|
||||
return "The provider encountered errors while loading the cache.";
|
||||
case 0x80042422: // VDS_E_PROVIDER_VOL_DEVICE_NAME_NOT_FOUND
|
||||
return "The device form of the volume pathname could not be retrieved.";
|
||||
case 0x80042423: // VDS_E_PROVIDER_VOL_OPEN
|
||||
return "Failed to open the volume device";
|
||||
case 0x80042424: // VDS_E_DMADMIN_CORRUPT_NOTIFICATION
|
||||
return "A corrupt notification was sent from the LDMA service.";
|
||||
case 0x80042425: // VDS_E_INCOMPATIBLE_FILE_SYSTEM
|
||||
return "The file system is incompatible with the specified operation.";
|
||||
case 0x80042426: // VDS_E_INCOMPATIBLE_MEDIA
|
||||
return "The media is incompatible with the specified operation.";
|
||||
case 0x80042427: // VDS_E_ACCESS_DENIED
|
||||
return "Access is denied. A VDS operation MUST run elevated.";
|
||||
case 0x80042428: // VDS_E_MEDIA_WRITE_PROTECTED
|
||||
return "The media is write-protected.";
|
||||
case 0x80042429: // VDS_E_BAD_LABEL
|
||||
return "The volume label is not valid.";
|
||||
case 0x8004242A: // VDS_E_CANT_QUICK_FORMAT
|
||||
return "The volume cannot be quick-formatted.";
|
||||
case 0x8004242B: // VDS_E_IO_ERROR
|
||||
return "An I/O error occurred during the operation.";
|
||||
case 0x8004242C: // VDS_E_VOLUME_TOO_SMALL
|
||||
return "The volume size is too small.";
|
||||
case 0x8004242D: // VDS_E_VOLUME_TOO_BIG
|
||||
return "The volume size is too large.";
|
||||
case 0x8004242E: // VDS_E_CLUSTER_SIZE_TOO_SMALL
|
||||
return "The cluster size is too small.";
|
||||
case 0x8004242F: // VDS_E_CLUSTER_SIZE_TOO_BIG
|
||||
return "The cluster size is too large.";
|
||||
case 0x80042430: // VDS_E_CLUSTER_COUNT_BEYOND_32BITS
|
||||
return "The number of clusters is too large to be represented as a 32-bit integer.";
|
||||
case 0x80042431: // VDS_E_OBJECT_STATUS_FAILED
|
||||
return "The component that the object represents has failed.";
|
||||
case 0x80042432: // VDS_E_VOLUME_INCOMPLETE
|
||||
return "The volume is incomplete.";
|
||||
case 0x80042433: // VDS_E_EXTENT_SIZE_LESS_THAN_MIN
|
||||
return "The specified extent size is too small.";
|
||||
case 0x00042434: // VDS_S_UPDATE_BOOTFILE_FAILED
|
||||
return "The operation was successful, but VDS failed to update the boot options.";
|
||||
case 0x00042436: // VDS_S_BOOT_PARTITION_NUMBER_CHANGE
|
||||
case 0x80042436: // VDS_E_BOOT_PARTITION_NUMBER_CHANGE
|
||||
return "The boot partition's partition number will change as a result of the operation.";
|
||||
case 0x80042437: // VDS_E_NO_FREE_SPACE
|
||||
return "The specified disk does not have enough free space to complete the operation.";
|
||||
case 0x80042438: // VDS_E_ACTIVE_PARTITION
|
||||
return "An active partition was detected on the selected disk.";
|
||||
case 0x80042439: // VDS_E_PARTITION_OF_UNKNOWN_TYPE
|
||||
return "The partition information cannot be read.";
|
||||
case 0x8004243A: // VDS_E_LEGACY_VOLUME_FORMAT
|
||||
return "A partition with an unknown type was detected on the specified disk.";
|
||||
case 0x8004243C: // VDS_E_MIGRATE_OPEN_VOLUME
|
||||
return "A volume on the specified disk could not be opened.";
|
||||
case 0x8004243D: // VDS_E_VOLUME_NOT_ONLINE
|
||||
return "The volume is not online.";
|
||||
case 0x8004243E: // VDS_E_VOLUME_NOT_HEALTHY
|
||||
return "The volume is failing or has failed.";
|
||||
case 0x8004243F: // VDS_E_VOLUME_SPANS_DISKS
|
||||
return "The volume spans multiple disks.";
|
||||
case 0x80042440: // VDS_E_REQUIRES_CONTIGUOUS_DISK_SPACE
|
||||
return "The volume does not consist of a single disk extent.";
|
||||
case 0x80042441: // VDS_E_BAD_PROVIDER_DATA
|
||||
return "A provider returned bad data.";
|
||||
case 0x80042442: // VDS_E_PROVIDER_FAILURE
|
||||
return "A provider failed to complete an operation.";
|
||||
case 0x00042443: // VDS_S_VOLUME_COMPRESS_FAILED
|
||||
return "The file system was formatted successfully but could not be compressed.";
|
||||
case 0x80042444: // VDS_E_PACK_OFFLINE
|
||||
return "The pack is offline.";
|
||||
case 0x80042445: // VDS_E_VOLUME_NOT_A_MIRROR
|
||||
return "The volume is not a mirror.";
|
||||
case 0x80042446: // VDS_E_NO_EXTENTS_FOR_VOLUME
|
||||
return "No extents were found for the volume.";
|
||||
case 0x80042447: // VDS_E_DISK_NOT_LOADED_TO_CACHE
|
||||
return "The migrated disk failed to load to the cache.";
|
||||
case 0x80042448: // VDS_E_INTERNAL_ERROR
|
||||
return "VDS encountered an internal error.";
|
||||
case 0x8004244A: // VDS_E_PROVIDER_TYPE_NOT_SUPPORTED
|
||||
return "The method call is not supported for the specified provider type.";
|
||||
case 0x8004244B: // VDS_E_DISK_NOT_ONLINE
|
||||
return "One or more of the specified disks are not online.";
|
||||
case 0x8004244C: // VDS_E_DISK_IN_USE_BY_VOLUME
|
||||
return "One or more extents of the disk are already being used by the volume.";
|
||||
case 0x0004244D: // VDS_S_IN_PROGRESS
|
||||
return "The asynchronous operation is in progress.";
|
||||
case 0x8004244E: // VDS_E_ASYNC_OBJECT_FAILURE
|
||||
return "Failure initializing the asynchronous object.";
|
||||
case 0x8004244F: // VDS_E_VOLUME_NOT_MOUNTED
|
||||
return "The volume is not mounted.";
|
||||
case 0x80042450: // VDS_E_PACK_NOT_FOUND
|
||||
return "The pack was not found.";
|
||||
case 0x80042453: // VDS_E_OBJECT_OUT_OF_SYNC
|
||||
return "The reference to the object might be stale.";
|
||||
case 0x80042454: // VDS_E_MISSING_DISK
|
||||
return "The specified disk could not be found.";
|
||||
case 0x80042455: // VDS_E_DISK_PNP_REG_CORRUPT
|
||||
return "The provider's list of PnP registered disks has become corrupted.";
|
||||
case 0x80042457: // VDS_E_NO_DRIVELETTER_FLAG
|
||||
return "The provider does not support the VDS_VF_NO DRIVELETTER volume flag.";
|
||||
case 0x80042459: // VDS_E_REVERT_ON_CLOSE_SET
|
||||
return "Some volume flags are already set.";
|
||||
case 0x0004245B: // VDS_S_UNABLE_TO_GET_GPT_ATTRIBUTES
|
||||
return "Unable to retrieve the GPT attributes for this volume.";
|
||||
case 0x8004245C: // VDS_E_VOLUME_TEMPORARILY_DISMOUNTED
|
||||
return "The volume is already dismounted temporarily.";
|
||||
case 0x8004245D: // VDS_E_VOLUME_PERMANENTLY_DISMOUNTED
|
||||
return "The volume is already permanently dismounted.";
|
||||
case 0x8004245E: // VDS_E_VOLUME_HAS_PATH
|
||||
return "The volume cannot be dismounted permanently because it still has an access path.";
|
||||
case 0x8004245F: // VDS_E_TIMEOUT
|
||||
return "The operation timed out.";
|
||||
case 0x80042461: // VDS_E_LDM_TIMEOUT
|
||||
return "The operation timed out in the LDMA service. Retry the operation.";
|
||||
case 0x80042462: // VDS_E_REVERT_ON_CLOSE_MISMATCH
|
||||
return "The flags to be cleared do not match the flags that were set previously.";
|
||||
case 0x80042463: // VDS_E_RETRY
|
||||
return "The operation failed. Retry the operation.";
|
||||
case 0x80042464: // VDS_E_ONLINE_PACK_EXISTS
|
||||
return "The operation failed, because an online pack object already exists.";
|
||||
case 0x80042468: // VDS_E_MAX_USABLE_MBR
|
||||
return "Only the first 2TB are usable on large MBR disks.";
|
||||
case 0x80042500: // VDS_E_NO_SOFTWARE_PROVIDERS_LOADED
|
||||
return "There are no software providers loaded.";
|
||||
case 0x80042501: // VDS_E_DISK_NOT_MISSING
|
||||
return "The disk is not missing.";
|
||||
case 0x80042502: // VDS_E_NO_VOLUME_LAYOUT
|
||||
return "The volume's layout could not be retrieved.";
|
||||
case 0x80042503: // VDS_E_CORRUPT_VOLUME_INFO
|
||||
return "The volume's driver information is corrupted.";
|
||||
case 0x80042504: // VDS_E_INVALID_ENUMERATOR
|
||||
return "The enumerator is corrupted";
|
||||
case 0x80042505: // VDS_E_DRIVER_INTERNAL_ERROR
|
||||
return "An internal error occurred in the volume management driver.";
|
||||
case 0x80042507: // VDS_E_VOLUME_INVALID_NAME
|
||||
return "The volume name is not valid.";
|
||||
case 0x00042508: // VDS_S_DISK_IS_MISSING
|
||||
return "The disk is missing and not all information could be returned.";
|
||||
case 0x80042509: // VDS_E_CORRUPT_PARTITION_INFO
|
||||
return "The disk's partition information is corrupted.";
|
||||
case 0x0004250A: // VDS_S_NONCONFORMANT_PARTITION_INFO
|
||||
return "The disk's partition information does not conform to what is expected on a dynamic disk.";
|
||||
case 0x8004250B: // VDS_E_CORRUPT_EXTENT_INFO
|
||||
return "The disk's extent information is corrupted.";
|
||||
case 0x0004250E: // VDS_S_SYSTEM_PARTITION
|
||||
return "Warning: There was a failure while checking for the system partition.";
|
||||
case 0x8004250F: // VDS_E_BAD_PNP_MESSAGE
|
||||
return "The PNP service sent a corrupted notification to the provider.";
|
||||
case 0x80042510: // VDS_E_NO_PNP_DISK_ARRIVE
|
||||
case 0x80042511: // VDS_E_NO_PNP_VOLUME_ARRIVE
|
||||
return "No disk/volume arrival notification was received.";
|
||||
case 0x80042512: // VDS_E_NO_PNP_DISK_REMOVE
|
||||
case 0x80042513: // VDS_E_NO_PNP_VOLUME_REMOVE
|
||||
return "No disk/volume removal notification was received.";
|
||||
case 0x80042514: // VDS_E_PROVIDER_EXITING
|
||||
return "The provider is exiting.";
|
||||
case 0x00042517: // VDS_S_NO_NOTIFICATION
|
||||
return "No volume arrival notification was received.";
|
||||
case 0x80042519: // VDS_E_INVALID_DISK
|
||||
return "The specified disk is not valid.";
|
||||
case 0x8004251A: // VDS_E_INVALID_PACK
|
||||
return "The specified disk pack is not valid.";
|
||||
case 0x8004251B: // VDS_E_VOLUME_ON_DISK
|
||||
return "This operation is not allowed on disks with volumes.";
|
||||
case 0x8004251C: // VDS_E_DRIVER_INVALID_PARAM
|
||||
return "The driver returned an invalid parameter error.";
|
||||
case 0x8004253D: // VDS_E_DRIVER_OBJECT_NOT_FOUND
|
||||
return "The object was not found in the driver cache.";
|
||||
case 0x8004253E: // VDS_E_PARTITION_NOT_CYLINDER_ALIGNED
|
||||
return "The disk layout contains partitions which are not cylinder aligned.";
|
||||
case 0x8004253F: // VDS_E_DISK_LAYOUT_PARTITIONS_TOO_SMALL
|
||||
return "The disk layout contains partitions which are less than the minimum required size.";
|
||||
case 0x80042540: // VDS_E_DISK_IO_FAILING
|
||||
return "The I/O to the disk is failing.";
|
||||
case 0x80042543: // VDS_E_GPT_ATTRIBUTES_INVALID
|
||||
return "Invalid GPT attributes were specified.";
|
||||
case 0x8004254D: // VDS_E_UNEXPECTED_DISK_LAYOUT_CHANGE
|
||||
return "An unexpected layout change occurred external to the volume manager.";
|
||||
case 0x8004254E: // VDS_E_INVALID_VOLUME_LENGTH
|
||||
return "The volume length is invalid.";
|
||||
case 0x8004254F: // VDS_E_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE
|
||||
return "The volume length is not a multiple of the sector size.";
|
||||
case 0x80042550: // VDS_E_VOLUME_NOT_RETAINED
|
||||
return "The volume does not have a retained partition association.";
|
||||
case 0x80042551: // VDS_E_VOLUME_RETAINED
|
||||
return "The volume already has a retained partition association.";
|
||||
case 0x80042553: // VDS_E_ALIGN_BEYOND_FIRST_CYLINDER
|
||||
return "The specified alignment is beyond the first cylinder.";
|
||||
case 0x80042554: // VDS_E_ALIGN_NOT_SECTOR_SIZE_MULTIPLE
|
||||
return "The specified alignment is not a multiple of the sector size.";
|
||||
case 0x80042555: // VDS_E_ALIGN_NOT_ZERO
|
||||
return "The specified partition type cannot be created with a non-zero alignment.";
|
||||
case 0x80042556: // VDS_E_CACHE_CORRUPT
|
||||
return "The service's cache has become corrupt.";
|
||||
case 0x80042557: // VDS_E_CANNOT_CLEAR_VOLUME_FLAG
|
||||
return "The specified volume flag cannot be cleared.";
|
||||
case 0x80042558: // VDS_E_DISK_BEING_CLEANED
|
||||
return "The operation is not allowed on a disk that is in the process of being cleaned.";
|
||||
case 0x8004255A: // VDS_E_DISK_REMOVEABLE
|
||||
return "The operation is not supported on removable media.";
|
||||
case 0x8004255B: // VDS_E_DISK_REMOVEABLE_NOT_EMPTY
|
||||
return "The operation is not supported on a non-empty removable disk.";
|
||||
case 0x8004255C: // VDS_E_DRIVE_LETTER_NOT_FREE
|
||||
return "The specified drive letter is not free to be assigned.";
|
||||
case 0x8004255E: // VDS_E_INVALID_DRIVE_LETTER
|
||||
return "The specified drive letter is not valid.";
|
||||
case 0x8004255F: // VDS_E_INVALID_DRIVE_LETTER_COUNT
|
||||
return "The specified number of drive letters to retrieve is not valid.";
|
||||
case 0x80042560: // VDS_E_INVALID_FS_FLAG
|
||||
return "The specified file system flag is not valid.";
|
||||
case 0x80042561: // VDS_E_INVALID_FS_TYPE
|
||||
return "The specified file system is not valid.";
|
||||
case 0x80042562: // VDS_E_INVALID_OBJECT_TYPE
|
||||
return "The specified object type is not valid.";
|
||||
case 0x80042563: // VDS_E_INVALID_PARTITION_LAYOUT
|
||||
return "The specified partition layout is invalid.";
|
||||
case 0x80042564: // VDS_E_INVALID_PARTITION_STYLE
|
||||
return "VDS only supports MBR or GPT partition style disks.";
|
||||
case 0x80042565: // VDS_E_INVALID_PARTITION_TYPE
|
||||
return "The specified partition type is not valid for this operation.";
|
||||
case 0x80042566: // VDS_E_INVALID_PROVIDER_CLSID
|
||||
case 0x80042567: // VDS_E_INVALID_PROVIDER_ID
|
||||
case 0x8004256A: // VDS_E_INVALID_PROVIDER_VERSION_GUID
|
||||
return "A NULL GUID was passed to the provider.";
|
||||
case 0x80042568: // VDS_E_INVALID_PROVIDER_NAME
|
||||
return "The specified provider name is invalid.";
|
||||
case 0x80042569: // VDS_E_INVALID_PROVIDER_TYPE
|
||||
return "The specified provider type is invalid.";
|
||||
case 0x8004256B: // VDS_E_INVALID_PROVIDER_VERSION_STRING
|
||||
return "The specified provider version string is invalid.";
|
||||
case 0x8004256C: // VDS_E_INVALID_QUERY_PROVIDER_FLAG
|
||||
return "The specified query provider flag is invalid.";
|
||||
case 0x8004256D: // VDS_E_INVALID_SERVICE_FLAG
|
||||
return "The specified service flag is invalid.";
|
||||
case 0x8004256E: // VDS_E_INVALID_VOLUME_FLAG
|
||||
return "The specified volume flag is invalid.";
|
||||
case 0x8004256F: // VDS_E_PARTITION_NOT_OEM
|
||||
return "The operation is only supported on an OEM, ESP, or unknown partition.";
|
||||
case 0x80042570: // VDS_E_PARTITION_PROTECTED
|
||||
return "Cannot delete a protected partition without the force protected parameter set.";
|
||||
case 0x80042571: // VDS_E_PARTITION_STYLE_MISMATCH
|
||||
return "The specified partition style is not the same as the disk's partition style.";
|
||||
case 0x80042572: // VDS_E_PROVIDER_INTERNAL_ERROR
|
||||
return "An internal error has occurred in the provider.";
|
||||
case 0x80042575: // VDS_E_UNRECOVERABLE_PROVIDER_ERROR
|
||||
return "An unrecoverable error occurred in the provider.";
|
||||
case 0x80042576: // VDS_E_VOLUME_HIDDEN
|
||||
return "Cannot assign a mount point to a hidden volume.";
|
||||
case 0x00042577: // VDS_S_DISMOUNT_FAILED
|
||||
case 0x00042578: // VDS_S_REMOUNT_FAILED
|
||||
return "Failed to dismount/remount the volume after setting the volume flags.";
|
||||
case 0x80042579: // VDS_E_FLAG_ALREADY_SET
|
||||
return "Cannot set the specified flag as revert-on-close because it is already set.";
|
||||
case 0x8004257B: // VDS_E_DISTINCT_VOLUME
|
||||
return "The input volume id cannot be the id of the volume that is the target of the operation.";
|
||||
case 0x00042583: // VDS_S_FS_LOCK
|
||||
return "Failed to obtain a file system lock.";
|
||||
case 0x80042584: // VDS_E_READONLY
|
||||
return "The volume is read only.";
|
||||
case 0x80042585: // VDS_E_INVALID_VOLUME_TYPE
|
||||
return "The volume type is invalid for this operation.";
|
||||
case 0x80042588: // VDS_E_VOLUME_MIRRORED
|
||||
return "This operation is not supported on a mirrored volume.";
|
||||
case 0x80042589: // VDS_E_VOLUME_SIMPLE_SPANNED
|
||||
return "The operation is only supported on simple or spanned volumes.";
|
||||
case 0x8004258C: // VDS_E_PARTITION_MSR
|
||||
case 0x8004258D: // VDS_E_PARTITION_LDM
|
||||
return "The operation is not supported on this type of partitions.";
|
||||
case 0x0004258E: // VDS_S_WINPE_BOOTENTRY
|
||||
return "The boot entries cannot be updated automatically on WinPE.";
|
||||
case 0x8004258F: // VDS_E_ALIGN_NOT_A_POWER_OF_TWO
|
||||
return "The alignment is not a power of two.";
|
||||
case 0x80042590: // VDS_E_ALIGN_IS_ZERO
|
||||
return "The alignment is zero.";
|
||||
case 0x80042593: // VDS_E_FS_NOT_DETERMINED
|
||||
return "The default file system could not be determined.";
|
||||
case 0x80042595: // VDS_E_DISK_NOT_OFFLINE
|
||||
return "This disk is already online.";
|
||||
case 0x80042596: // VDS_E_FAILED_TO_ONLINE_DISK
|
||||
return "The online operation failed.";
|
||||
case 0x80042597: // VDS_E_FAILED_TO_OFFLINE_DISK
|
||||
return "The offline operation failed.";
|
||||
case 0x80042598: // VDS_E_BAD_REVISION_NUMBER
|
||||
return "The operation could not be completed because the specified revision number is not supported.";
|
||||
case 0x00042700: // VDS_S_NAME_TRUNCATED
|
||||
return "The name was set successfully but had to be truncated.";
|
||||
case 0x80042701: // VDS_E_NAME_NOT_UNIQUE
|
||||
return "The specified name is not unique.";
|
||||
case 0x8004270F: // VDS_E_NO_DISK_PATHNAME
|
||||
return "The disk's path could not be retrieved. Some operations on the disk might fail.";
|
||||
case 0x80042711: // VDS_E_NO_VOLUME_PATHNAME
|
||||
return "The path could not be retrieved for one or more volumes.";
|
||||
case 0x80042712: // VDS_E_PROVIDER_CACHE_OUTOFSYNC
|
||||
return "The provider's cache is not in sync with the driver cache.";
|
||||
case 0x80042713: // VDS_E_NO_IMPORT_TARGET
|
||||
return "No import target was set for the subsystem.";
|
||||
case 0x00042714: // VDS_S_ALREADY_EXISTS
|
||||
return "The object already exists.";
|
||||
case 0x00042715: // VDS_S_PROPERTIES_INCOMPLETE
|
||||
return "Some, but not all, of the properties were successfully retrieved.";
|
||||
case 0x80042803: // VDS_E_UNABLE_TO_FIND_BOOT_DISK
|
||||
return "Volume disk extent information could not be retrieved for the boot volume.";
|
||||
case 0x80042807: // VDS_E_BOOT_DISK
|
||||
return "Disk attributes cannot be changed on the boot disk.";
|
||||
case 0x00042808: // VDS_S_DISK_MOUNT_FAILED
|
||||
case 0x00042809: // VDS_S_DISK_DISMOUNT_FAILED
|
||||
return "One or more of the volumes on the disk could not be mounted/dismounted.";
|
||||
case 0x8004280A: // VDS_E_DISK_IS_OFFLINE
|
||||
case 0x8004280B: // VDS_E_DISK_IS_READ_ONLY
|
||||
return "The operation cannot be performed on a disk that is offline or read-only.";
|
||||
case 0x8004280C: // VDS_E_PAGEFILE_DISK
|
||||
case 0x8004280D: // VDS_E_HIBERNATION_FILE_DISK
|
||||
case 0x8004280E: // VDS_E_CRASHDUMP_DISK
|
||||
return "The operation cannot be performed on a disk that contains a pagefile, hibernation or crashdump volume.";
|
||||
case 0x8004280F: // VDS_E_UNABLE_TO_FIND_SYSTEM_DISK
|
||||
return "A system error occurred while retrieving the system disk information.";
|
||||
case 0x80042810: // VDS_E_INCORRECT_SYSTEM_VOLUME_EXTENT_INFO
|
||||
return "Multiple disk extents reported for the system volume - system error.";
|
||||
case 0x80042811: // VDS_E_SYSTEM_DISK
|
||||
return "Disk attributes cannot be changed on the current system disk or BIOS disk 0.";
|
||||
case 0x80042823: // VDS_E_SECTOR_SIZE_ERROR
|
||||
return "The sector size MUST be non-zero, a power of 2, and less than the maximum sector size.";
|
||||
case 0x80042907: // VDS_E_SUBSYSTEM_ID_IS_NULL
|
||||
return "The provider returned a NULL subsystem identification string.";
|
||||
case 0x8004290C: // VDS_E_REBOOT_REQUIRED
|
||||
return "A reboot is required before any further operations are initiated.";
|
||||
case 0x8004290D: // VDS_E_VOLUME_GUID_PATHNAME_NOT_ALLOWED
|
||||
return "Volume GUID pathnames are not valid input to this method.";
|
||||
case 0x8004290E: // VDS_E_BOOT_PAGEFILE_DRIVE_LETTER
|
||||
return "Assigning or removing drive letters on the current boot or pagefile volume is not allowed.";
|
||||
case 0x8004290F: // VDS_E_DELETE_WITH_CRITICAL
|
||||
return "Delete is not allowed on a critical volume.";
|
||||
case 0x80042910: // VDS_E_CLEAN_WITH_DATA
|
||||
case 0x80042911: // VDS_E_CLEAN_WITH_OEM
|
||||
return "The FORCE parameter MUST be set to TRUE in order to clean a disk that contains a data or OEM volume.";
|
||||
case 0x80042912: // VDS_E_CLEAN_WITH_CRITICAL
|
||||
return "Clean is not allowed on a critical disk.";
|
||||
case 0x80042913: // VDS_E_FORMAT_CRITICAL
|
||||
return "Format is not allowed on a critical volume.";
|
||||
case 0x80042914: // VDS_E_NTFS_FORMAT_NOT_SUPPORTED
|
||||
case 0x80042915: // VDS_E_FAT32_FORMAT_NOT_SUPPORTED
|
||||
case 0x80042916: // VDS_E_FAT_FORMAT_NOT_SUPPORTED
|
||||
return "The requested file system format is not supported on this volume.";
|
||||
case 0x80042917: // VDS_E_FORMAT_NOT_SUPPORTED
|
||||
return "The volume is not formattable.";
|
||||
case 0x80042918: // VDS_E_COMPRESSION_NOT_SUPPORTED
|
||||
return "The specified file system does not support compression.";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* GetVimError(DWORD error_code)
|
||||
{
|
||||
switch (error_code) {
|
||||
case 0xC1420127:
|
||||
return "The specified image in the specified wim is already mounted for read and write access.";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define sfree(p) do {if (p != NULL) {free((void*)(p)); p = NULL;}} while(0)
|
||||
#define wconvert(p) wchar_t* w ## p = utf8_to_wchar(p)
|
||||
#define walloc(p, size) wchar_t* w ## p = (p == NULL)?NULL:(wchar_t*)calloc(size, sizeof(wchar_t))
|
||||
#define wfree(p) sfree(w ## p)
|
||||
#define wchar_to_utf8_no_alloc(wsrc, dest, dest_size) \
|
||||
WideCharToMultiByte(CP_UTF8, 0, wsrc, -1, dest, dest_size, NULL, NULL)
|
||||
|
||||
static __inline DWORD FormatMessageU(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
|
||||
DWORD dwLanguageId, char* lpBuffer, DWORD nSize, va_list *Arguments)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, nSize);
|
||||
ret = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, wlpBuffer, nSize, Arguments);
|
||||
err = GetLastError();
|
||||
if ((ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpBuffer, lpBuffer, nSize)) == 0)) {
|
||||
err = GetLastError();
|
||||
ret = 0;
|
||||
}
|
||||
wfree(lpBuffer);
|
||||
SetLastError(err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// Convert a windows error to human readable string
|
||||
const char *WindowsErrorString(DWORD error_code)
|
||||
{
|
||||
static char err_string[256] = { 0 };
|
||||
|
||||
DWORD size, presize;
|
||||
DWORD format_error;
|
||||
|
||||
// Check for VDS error codes
|
||||
if ((HRESULT_FACILITY(error_code) == FACILITY_ITF) && (GetVdsError(error_code) != NULL)) {
|
||||
sprintf_s(err_string, sizeof(err_string), "[0x%08lX] %s", error_code, GetVdsError(error_code));
|
||||
return err_string;
|
||||
}
|
||||
if ((HRESULT_FACILITY(error_code) == 322) && (GetVimError(error_code) != NULL)) {
|
||||
sprintf_s(err_string, sizeof(err_string), "[0x%08lX] %s", error_code, GetVimError(error_code));
|
||||
return err_string;
|
||||
}
|
||||
sprintf_s(err_string, sizeof(err_string), "[0x%08lX] ", error_code);
|
||||
presize = (DWORD)strlen(err_string);
|
||||
|
||||
size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
HRESULT_CODE(error_code), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||
&err_string[presize], sizeof(err_string)-(DWORD)strlen(err_string), NULL);
|
||||
if (size == 0) {
|
||||
format_error = GetLastError();
|
||||
if ((format_error) && (format_error != ERROR_MR_MID_NOT_FOUND) && (format_error != ERROR_MUI_FILE_NOT_LOADED))
|
||||
sprintf_s(err_string, sizeof(err_string), "Windows error code 0x%08lX (FormatMessage error code 0x%08lX)",
|
||||
error_code, format_error);
|
||||
else
|
||||
sprintf_s(err_string, sizeof(err_string), "Windows error code 0x%08lX", error_code);
|
||||
}
|
||||
else {
|
||||
// Microsoft may suffix CRLF to error messages, which we need to remove...
|
||||
size += presize - 2;
|
||||
// Cannot underflow if the above assert passed since our first char is neither of the following
|
||||
while ((err_string[size] == 0x0D) || (err_string[size] == 0x0A) || (err_string[size] == 0x20))
|
||||
err_string[size--] = 0;
|
||||
}
|
||||
|
||||
return err_string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define INTF_ADVANCEDDISK 1
|
||||
#define INTF_ADVANCEDDISK2 2
|
||||
#define INTF_CREATEPARTITIONEX 3
|
||||
#define INTF_PARTITIONMF 4
|
||||
|
||||
/*
|
||||
* Some code and functions in the file are copied from rufus.
|
||||
@@ -64,6 +570,11 @@
|
||||
|
||||
#define IVdsCreatePartitionEx_CreatePartitionEx(This, ullOffset, ullSize, ulAlign, para, ppAsync) (This)->lpVtbl->CreatePartitionEx(This, ullOffset, ullSize, ulAlign, para, ppAsync)
|
||||
#define IVdsCreatePartitionEx_Release(This) (This)->lpVtbl->Release(This)
|
||||
|
||||
#define IVdsPartitionMF_FormatPartitionEx(This, ullOffset, pwszFileSystemTypeName, usFileSystemRevision, ulDesiredUnitAllocationSize, pwszLabel, bForce, bQuickFormat, bEnableCompression, ppAsync) \
|
||||
(This)->lpVtbl->FormatPartitionEx(This, ullOffset, pwszFileSystemTypeName, usFileSystemRevision, ulDesiredUnitAllocationSize, pwszLabel, bForce, bQuickFormat, bEnableCompression, ppAsync)
|
||||
#define IVdsPartitionMF_Release(This) (This)->lpVtbl->Release(This)
|
||||
|
||||
#define IEnumVdsObject_Next(This, celt, ppObjectArray, pcFetched) (This)->lpVtbl->Next(This, celt, ppObjectArray, pcFetched)
|
||||
#define IVdsPack_QueryVolumes(This, ppEnum) (This)->lpVtbl->QueryVolumes(This, ppEnum)
|
||||
#define IVdsVolume_QueryInterface(This, riid, ppvObject) (This)->lpVtbl->QueryInterface(This, riid, ppvObject)
|
||||
@@ -97,7 +608,7 @@ STATIC IVdsService * VDS_InitService(void)
|
||||
if (hr != S_OK)
|
||||
{
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("Could not create VDS Loader Instance: %u", LASTERR);
|
||||
Log("Could not create VDS Loader Instance: 0x%x", LASTERR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -107,7 +618,7 @@ STATIC IVdsService * VDS_InitService(void)
|
||||
if (hr != S_OK)
|
||||
{
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("Could not load VDS Service: %u", LASTERR);
|
||||
Log("Could not load VDS Service: 0x%x", LASTERR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -116,7 +627,7 @@ STATIC IVdsService * VDS_InitService(void)
|
||||
if (hr != S_OK)
|
||||
{
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("VDS Service is not ready: %u", LASTERR);
|
||||
Log("VDS Service is not ready: 0x%x", LASTERR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -222,6 +733,7 @@ STATIC BOOL VDS_DiskCommProc(int intf, int DriveIndex, VDS_Callback_PF callback,
|
||||
IVdsAdvancedDisk *pAdvancedDisk;
|
||||
IVdsAdvancedDisk2 *pAdvancedDisk2;
|
||||
IVdsCreatePartitionEx *pCreatePartitionEx;
|
||||
IVdsDiskPartitionMF *pPartitionMP;
|
||||
|
||||
// Get the disk interface.
|
||||
hr = IUnknown_QueryInterface(pDiskUnk, &IID_IVdsDisk, (void **)&pDisk);
|
||||
@@ -300,6 +812,24 @@ STATIC BOOL VDS_DiskCommProc(int intf, int DriveIndex, VDS_Callback_PF callback,
|
||||
}
|
||||
IVdsCreatePartitionEx_Release(pCreatePartitionEx);
|
||||
}
|
||||
else if (intf == INTF_PARTITIONMF)
|
||||
{
|
||||
// Instantiate the DiskPartitionMF interface for our disk.
|
||||
hr = IVdsDisk_QueryInterface(pDisk, &IID_IVdsDiskPartitionMF, (void **)&pPartitionMP);
|
||||
IVdsDisk_Release(pDisk);
|
||||
if (hr != S_OK)
|
||||
{
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("Could not access VDS PartitionMF interface: %u", LASTERR);
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Callback %d process for disk <%S>", intf, diskprop.pwszName);
|
||||
r = callback(pPartitionMP, &diskprop, data);
|
||||
}
|
||||
IVdsPartitionMF_Release(pPartitionMP);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
@@ -357,7 +887,7 @@ STATIC BOOL VDS_CallBack_CleanDisk(void *pInterface, VDS_DISK_PROP *pDiskProp, U
|
||||
BOOL VDS_CleanDisk(int DriveIndex)
|
||||
{
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK, DriveIndex, VDS_CallBack_CleanDisk, 0);
|
||||
Log("VDS_CleanDisk %d ret:%d", DriveIndex, ret);
|
||||
Log("VDS_CleanDisk %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -383,6 +913,7 @@ STATIC BOOL VDS_CallBack_DeletePartition(void *pInterface, VDS_DISK_PROP *pDiskP
|
||||
hr = IVdsAdvancedDisk_QueryPartitions(pAdvancedDisk, &prop_array, &prop_array_size);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
r = TRUE;
|
||||
for (i = 0; i < prop_array_size; i++)
|
||||
{
|
||||
if (PartNumber == 0 || PartNumber == prop_array[i].ulPartitionNumber)
|
||||
@@ -402,36 +933,40 @@ STATIC BOOL VDS_CallBack_DeletePartition(void *pInterface, VDS_DISK_PROP *pDiskP
|
||||
{
|
||||
r = FALSE;
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("Could not delete partitions: %u", LASTERR);
|
||||
Log("Could not delete partitions: 0x%x", LASTERR);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Delete this partitions success");
|
||||
}
|
||||
}
|
||||
r = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("No partition to delete on disk '%S'", pDiskProp->pwszName);
|
||||
r = TRUE;
|
||||
}
|
||||
CoTaskMemFree(prop_array);
|
||||
|
||||
if (prop_array)
|
||||
{
|
||||
CoTaskMemFree(prop_array);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
BOOL VDS_DeleteAllPartitions(int DriveIndex)
|
||||
{
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK, DriveIndex, VDS_CallBack_DeletePartition, 0);
|
||||
Log("VDS_DeleteAllPartitions %d ret:%d", DriveIndex, ret);
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK, DriveIndex, VDS_CallBack_DeletePartition, 0);
|
||||
Log("VDS_DeleteAllPartitions %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL VDS_DeleteVtoyEFIPartition(int DriveIndex)
|
||||
{
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK, DriveIndex, VDS_CallBack_DeletePartition, 2);
|
||||
Log("VDS_DeleteVtoyEFIPartition %d ret:%d", DriveIndex, ret);
|
||||
Log("VDS_DeleteVtoyEFIPartition %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -494,8 +1029,8 @@ STATIC BOOL VDS_CallBack_ChangeEFIAttr(void *pInterface, VDS_DISK_PROP *pDiskPro
|
||||
|
||||
BOOL VDS_ChangeVtoyEFIAttr(int DriveIndex, UINT64 Attr)
|
||||
{
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK, DriveIndex, VDS_CallBack_ChangeEFIAttr, Attr);
|
||||
Log("VDS_ChangeVtoyEFIAttr %d ret:%d", DriveIndex, ret);
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK, DriveIndex, VDS_CallBack_ChangeEFIAttr, Attr);
|
||||
Log("VDS_ChangeVtoyEFIAttr %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -519,7 +1054,7 @@ STATIC BOOL VDS_CallBack_ChangeEFIType(void *pInterface, VDS_DISK_PROP *pDiskPro
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Failed to change partition type 0x%lx", hr);
|
||||
Log("Failed to change partition type 0x%lx(%s)", hr, WindowsErrorString(hr));
|
||||
}
|
||||
|
||||
return r;
|
||||
@@ -535,7 +1070,7 @@ BOOL VDS_ChangeVtoyEFI2ESP(int DriveIndex, UINT64 Offset)
|
||||
Para.Offset = Offset;
|
||||
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK2, DriveIndex, VDS_CallBack_ChangeEFIType, (ULONG)&Para);
|
||||
Log("VDS_ChangeVtoyEFI2ESP %d ret:%d", DriveIndex, ret);
|
||||
Log("VDS_ChangeVtoyEFI2ESP %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -548,7 +1083,7 @@ BOOL VDS_ChangeVtoyEFI2Basic(int DriveIndex, UINT64 Offset)
|
||||
Para.Offset = Offset;
|
||||
|
||||
BOOL ret = VDS_DiskCommProc(INTF_ADVANCEDDISK2, DriveIndex, VDS_CallBack_ChangeEFIType, (ULONG)&Para);
|
||||
Log("VDS_ChangeVtoyEFI2ESP %d ret:%d", DriveIndex, ret);
|
||||
Log("VDS_ChangeVtoyEFI2Basic %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -599,7 +1134,7 @@ STATIC BOOL VDS_CallBack_CreateVtoyEFI(void *pInterface, VDS_DISK_PROP *pDiskPro
|
||||
if (hr != S_OK)
|
||||
{
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("Could not create partition, err:0x%lx", LASTERR);
|
||||
Log("Could not create partition, err:0x%lx(%s)", LASTERR, WindowsErrorString(hr));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -622,8 +1157,68 @@ BOOL VDS_CreateVtoyEFIPart(int DriveIndex, UINT64 Offset)
|
||||
memcpy(&(Para.Type), &EspPartType, sizeof(GUID));
|
||||
CoCreateGuid(&(Para.Id));
|
||||
|
||||
BOOL ret = VDS_DiskCommProc(INTF_CREATEPARTITIONEX, DriveIndex, VDS_CallBack_CreateVtoyEFI, (ULONG)&Para);
|
||||
Log("VDS_CreateVtoyEFIPart %d ret:%d", DriveIndex, ret);
|
||||
BOOL ret = VDS_DiskCommProc(INTF_CREATEPARTITIONEX, DriveIndex, VDS_CallBack_CreateVtoyEFI, (ULONG)&Para);
|
||||
Log("VDS_CreateVtoyEFIPart %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
STATIC BOOL VDS_CallBack_FormatVtoyEFI(void *pInterface, VDS_DISK_PROP *pDiskProp, UINT64 data)
|
||||
{
|
||||
HRESULT hr, hr2;
|
||||
ULONG completed;
|
||||
IVdsAsync* pAsync;
|
||||
IVdsDiskPartitionMF *pPartitionMF = (IVdsDiskPartitionMF *)pInterface;
|
||||
VDS_PARA *VdsPara = (VDS_PARA *)(ULONG)data;
|
||||
|
||||
(void)pDiskProp;
|
||||
|
||||
hr = IVdsPartitionMF_FormatPartitionEx(pPartitionMF, VdsPara->Offset, L"FAT", 0x0100, 0, VdsPara->Name, TRUE, TRUE, FALSE, &pAsync);
|
||||
while (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IVdsAsync_QueryStatus(pAsync, &hr2, &completed);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = hr2;
|
||||
if (hr == S_OK)
|
||||
{
|
||||
Log("Disk format partition QueryStatus OK, %lu%%", completed);
|
||||
break;
|
||||
}
|
||||
else if (hr == VDS_E_OPERATION_PENDING)
|
||||
{
|
||||
Log("Disk format finish: %lu%%", completed);
|
||||
hr = S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("QueryStatus invalid status:0x%lx", hr);
|
||||
}
|
||||
}
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
if (hr != S_OK)
|
||||
{
|
||||
VDS_SET_ERROR(hr);
|
||||
Log("Could not format partition, err:0x%lx (%s)", LASTERR, WindowsErrorString(hr));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Not supported for removable disk
|
||||
BOOL VDS_FormatVtoyEFIPart(int DriveIndex, UINT64 Offset)
|
||||
{
|
||||
VDS_PARA Para;
|
||||
|
||||
memset(&Para, 0, sizeof(Para));
|
||||
Para.Offset = Offset;
|
||||
memcpy(Para.Name, L"VTOYEFI", 7 * 2);
|
||||
|
||||
BOOL ret = VDS_DiskCommProc(INTF_PARTITIONMF, DriveIndex, VDS_CallBack_FormatVtoyEFI, (ULONG)&Para);
|
||||
Log("VDS_FormatVtoyEFIPart %d ret:%d (%s)", DriveIndex, ret, ret ? "SUCCESS" : "FAIL");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <Windows.h>
|
||||
#include <time.h>
|
||||
#include <winternl.h>
|
||||
#include <commctrl.h>
|
||||
#include <initguid.h>
|
||||
@@ -30,6 +31,8 @@
|
||||
#include "ff.h"
|
||||
#include "DiskService.h"
|
||||
|
||||
static int g_backup_bin_index = 0;
|
||||
|
||||
static DWORD GetVentoyVolumeName(int PhyDrive, UINT64 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)
|
||||
{
|
||||
size_t len;
|
||||
@@ -1588,9 +1591,11 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle, int TryId)
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 Part2StartSector = 0;
|
||||
|
||||
Log("#####################################################");
|
||||
Log("InstallVentoy2PhyDrive try%d %s PhyDrive%d <<%s %s %dGB>>", TryId,
|
||||
PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
|
||||
GetHumanReadableGBSize(pPhyDrive->SizeInBytes));
|
||||
Log("#####################################################");
|
||||
|
||||
if (PartStyle)
|
||||
{
|
||||
@@ -1657,7 +1662,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle, int TryId)
|
||||
|
||||
if (!VDS_DeleteAllPartitions(pPhyDrive->PhyDrive))
|
||||
{
|
||||
Log("Notice: Could not delete partitions: %u", GetLastError());
|
||||
Log("Notice: Could not delete partitions: 0x%x, but we continue.", GetLastError());
|
||||
}
|
||||
|
||||
Log("Deleting all partitions ......................... OK");
|
||||
@@ -1825,14 +1830,201 @@ End:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static BOOL DiskCheckWriteAccess(HANDLE hDrive)
|
||||
{
|
||||
DWORD dwSize;
|
||||
BOOL ret = FALSE;
|
||||
BOOL bRet = FALSE;
|
||||
BYTE Buffer[512];
|
||||
LARGE_INTEGER liCurPosition;
|
||||
LARGE_INTEGER liNewPosition;
|
||||
|
||||
liCurPosition.QuadPart = 2039 * 512;
|
||||
liNewPosition.QuadPart = 0;
|
||||
if (0 == SetFilePointerEx(hDrive, liCurPosition, &liNewPosition, FILE_BEGIN) ||
|
||||
liNewPosition.QuadPart != liCurPosition.QuadPart)
|
||||
{
|
||||
Log("SetFilePointer1 Failed %u", LASTERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
dwSize = 0;
|
||||
ret = ReadFile(hDrive, Buffer, 512, &dwSize, NULL);
|
||||
if ((!ret) || (dwSize != 512))
|
||||
{
|
||||
Log("Failed to read %d %u 0x%x", ret, dwSize, LASTERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
liCurPosition.QuadPart = 2039 * 512;
|
||||
liNewPosition.QuadPart = 0;
|
||||
if (0 == SetFilePointerEx(hDrive, liCurPosition, &liNewPosition, FILE_BEGIN) ||
|
||||
liNewPosition.QuadPart != liCurPosition.QuadPart)
|
||||
{
|
||||
Log("SetFilePointer2 Failed %u", LASTERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
dwSize = 0;
|
||||
ret = WriteFile(hDrive, Buffer, 512, &dwSize, NULL);
|
||||
if ((!ret) || dwSize != 512)
|
||||
{
|
||||
Log("Failed to write %d %u %u", ret, dwSize, LASTERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
bRet = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
static BOOL BackupDataBeforeCleanDisk(int PhyDrive, UINT64 DiskSize, BYTE **pBackup)
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwStatus;
|
||||
BOOL Return = FALSE;
|
||||
BOOL ret = FALSE;
|
||||
BYTE *backup = NULL;
|
||||
UINT64 offset;
|
||||
HANDLE hDrive = INVALID_HANDLE_VALUE;
|
||||
LARGE_INTEGER liCurPosition;
|
||||
LARGE_INTEGER liNewPosition;
|
||||
VTOY_GPT_INFO *pGPT = NULL;
|
||||
|
||||
Log("BackupDataBeforeCleanDisk %d", PhyDrive);
|
||||
|
||||
// step1: check write access
|
||||
hDrive = GetPhysicalHandle(PhyDrive, TRUE, TRUE, FALSE);
|
||||
if (hDrive == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Log("Failed to GetPhysicalHandle for write.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (DiskCheckWriteAccess(hDrive))
|
||||
{
|
||||
Log("DiskCheckWriteAccess success");
|
||||
CHECK_CLOSE_HANDLE(hDrive);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("DiskCheckWriteAccess failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
//step2 backup 4MB data
|
||||
backup = malloc(SIZE_1MB * 4);
|
||||
if (!backup)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
hDrive = GetPhysicalHandle(PhyDrive, FALSE, FALSE, FALSE);
|
||||
if (hDrive == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
//read first 2MB
|
||||
dwStatus = SetFilePointer(hDrive, 0, NULL, FILE_BEGIN);
|
||||
if (dwStatus != 0)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
dwSize = 0;
|
||||
ret = ReadFile(hDrive, backup, SIZE_2MB, &dwSize, NULL);
|
||||
if ((!ret) || (dwSize != SIZE_2MB))
|
||||
{
|
||||
Log("Failed to read %d %u 0x%x", ret, dwSize, LASTERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
pGPT = (VTOY_GPT_INFO *)backup;
|
||||
offset = pGPT->Head.EfiBackupLBA * 512;
|
||||
if (offset >= (DiskSize - SIZE_2MB) && offset < DiskSize)
|
||||
{
|
||||
Log("EFI partition table check success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Backup EFI LBA not in last 2MB range: %llu", pGPT->Head.EfiBackupLBA);
|
||||
goto out;
|
||||
}
|
||||
|
||||
//read last 2MB
|
||||
liCurPosition.QuadPart = DiskSize - SIZE_2MB;
|
||||
liNewPosition.QuadPart = 0;
|
||||
if (0 == SetFilePointerEx(hDrive, liCurPosition, &liNewPosition, FILE_BEGIN) ||
|
||||
liNewPosition.QuadPart != liCurPosition.QuadPart)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
dwSize = 0;
|
||||
ret = ReadFile(hDrive, backup + SIZE_2MB, SIZE_2MB, &dwSize, NULL);
|
||||
if ((!ret) || (dwSize != SIZE_2MB))
|
||||
{
|
||||
Log("Failed to read %d %u 0x%x", ret, dwSize, LASTERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
*pBackup = backup;
|
||||
backup = NULL; //For don't free later
|
||||
Return = TRUE;
|
||||
|
||||
out:
|
||||
CHECK_CLOSE_HANDLE(hDrive);
|
||||
if (backup)
|
||||
free(backup);
|
||||
|
||||
return Return;
|
||||
}
|
||||
|
||||
|
||||
static BOOL WriteBackupDataToDisk(HANDLE hDrive, UINT64 Offset, BYTE *Data, DWORD Length)
|
||||
{
|
||||
DWORD dwSize = 0;
|
||||
BOOL ret = FALSE;
|
||||
LARGE_INTEGER liCurPosition;
|
||||
LARGE_INTEGER liNewPosition;
|
||||
|
||||
Log("WriteBackupDataToDisk %llu %p %u", Offset, Data, Length);
|
||||
|
||||
liCurPosition.QuadPart = Offset;
|
||||
liNewPosition.QuadPart = 0;
|
||||
if (0 == SetFilePointerEx(hDrive, liCurPosition, &liNewPosition, FILE_BEGIN) ||
|
||||
liNewPosition.QuadPart != liCurPosition.QuadPart)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = WriteFile(hDrive, Data, Length, &dwSize, NULL);
|
||||
if ((!ret) || dwSize != Length)
|
||||
{
|
||||
Log("Failed to write %d %u %u", ret, dwSize, LASTERR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Log("WriteBackupDataToDisk %llu %p %u success", Offset, Data, Length);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
|
||||
{
|
||||
int i;
|
||||
int rc = 0;
|
||||
int MaxRetry = 3;
|
||||
int MaxRetry = 4;
|
||||
BOOL ForceMBR = FALSE;
|
||||
BOOL Esp2Basic = FALSE;
|
||||
BOOL ChangeAttr = FALSE;
|
||||
BOOL CleanDisk = FALSE;
|
||||
BOOL bWriteBack = TRUE;
|
||||
HANDLE hVolume;
|
||||
HANDLE hDrive;
|
||||
DWORD Status;
|
||||
@@ -1840,16 +2032,20 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
|
||||
BOOL bRet;
|
||||
CHAR DriveName[] = "?:\\";
|
||||
CHAR DriveLetters[MAX_PATH] = { 0 };
|
||||
CHAR BackBinFile[MAX_PATH];
|
||||
UINT64 StartSector;
|
||||
UINT64 ReservedMB = 0;
|
||||
MBR_HEAD BootImg;
|
||||
MBR_HEAD MBR;
|
||||
BYTE *pBackup = NULL;
|
||||
VTOY_GPT_INFO *pGptInfo = NULL;
|
||||
UINT8 ReservedData[4096];
|
||||
|
||||
Log("#####################################################");
|
||||
Log("UpdateVentoy2PhyDrive try%d %s PhyDrive%d <<%s %s %dGB>>", TryId,
|
||||
pPhyDrive->PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
|
||||
GetHumanReadableGBSize(pPhyDrive->SizeInBytes));
|
||||
Log("#####################################################");
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_LOCK_FOR_CLEAN);
|
||||
|
||||
@@ -1933,20 +2129,52 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
|
||||
if (pPhyDrive->PartStyle == 1)
|
||||
{
|
||||
Log("TryId=%d EFI GPT partition type is 0x%llx", TryId, pPhyDrive->Part2GPTAttr);
|
||||
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
|
||||
|
||||
if ((TryId == 1 && (pPhyDrive->Part2GPTAttr >> 56) == 0xC0) || TryId == 2)
|
||||
if (TryId == 1)
|
||||
{
|
||||
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
|
||||
Log("Change GPT partition type to ESP");
|
||||
|
||||
if (VDS_ChangeVtoyEFI2ESP(pPhyDrive->PhyDrive, StartSector * 512))
|
||||
{
|
||||
Esp2Basic = TRUE;
|
||||
Sleep(1000);
|
||||
Sleep(3000);
|
||||
}
|
||||
}
|
||||
else if (TryId == 2)
|
||||
{
|
||||
Log("Change GPT partition attribute");
|
||||
if (VDS_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, 0x8000000000000001))
|
||||
{
|
||||
ChangeAttr = TRUE;
|
||||
Sleep(2000);
|
||||
}
|
||||
}
|
||||
else if (TryId == 3)
|
||||
{
|
||||
Log("Clean disk GPT partition table");
|
||||
if (BackupDataBeforeCleanDisk(pPhyDrive->PhyDrive, pPhyDrive->SizeInBytes, &pBackup))
|
||||
{
|
||||
sprintf_s(BackBinFile, sizeof(BackBinFile), ".\\ventoy\\phydrive%d_%u_%d.bin",
|
||||
pPhyDrive->PhyDrive, GetCurrentProcessId(), g_backup_bin_index++);
|
||||
SaveBufToFile(BackBinFile, pBackup, 4 * SIZE_1MB);
|
||||
Log("Save backup data to %s", BackBinFile);
|
||||
|
||||
Log("Success to backup data before clean");
|
||||
CleanDisk = TRUE;
|
||||
if (!VDS_CleanDisk(pPhyDrive->PhyDrive))
|
||||
{
|
||||
Sleep(3000);
|
||||
DSPT_CleanDisk(pPhyDrive->PhyDrive);
|
||||
}
|
||||
Sleep(3000);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Failed to backup data before clean");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_LOCK_FOR_WRITE);
|
||||
|
||||
Log("Lock disk for update ............................ ");
|
||||
@@ -1964,7 +2192,23 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
|
||||
hVolume = INVALID_HANDLE_VALUE;
|
||||
|
||||
//If we change VTOYEFI to ESP, it can not have s volume name, so don't try to get it.
|
||||
if (Esp2Basic)
|
||||
if (CleanDisk)
|
||||
{
|
||||
//writeback the last 2MB
|
||||
if (!WriteBackupDataToDisk(hDrive, pPhyDrive->SizeInBytes - SIZE_2MB, pBackup + SIZE_2MB, SIZE_2MB))
|
||||
{
|
||||
bWriteBack = FALSE;
|
||||
}
|
||||
|
||||
//write the first 2MB except parttable
|
||||
if (!WriteBackupDataToDisk(hDrive, 34 * 512, pBackup + 34 * 512, SIZE_2MB - 34 * 512))
|
||||
{
|
||||
bWriteBack = FALSE;
|
||||
}
|
||||
|
||||
Status = ERROR_NOT_FOUND;
|
||||
}
|
||||
else if (Esp2Basic)
|
||||
{
|
||||
Status = ERROR_NOT_FOUND;
|
||||
}
|
||||
@@ -2033,24 +2277,41 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
|
||||
goto End;
|
||||
}
|
||||
|
||||
if (!TryWritePart2(hDrive, StartSector))
|
||||
bRet = TryWritePart2(hDrive, StartSector);
|
||||
if (FALSE == bRet && Esp2Basic)
|
||||
{
|
||||
Log("TryWritePart2 agagin ...");
|
||||
Sleep(3000);
|
||||
bRet = TryWritePart2(hDrive, StartSector);
|
||||
}
|
||||
|
||||
if (!bRet)
|
||||
{
|
||||
if (pPhyDrive->PartStyle == 0)
|
||||
{
|
||||
ForceMBR = TRUE;
|
||||
|
||||
Log("Try write failed, now delete partition 2 for MBR...");
|
||||
CHECK_CLOSE_HANDLE(hDrive);
|
||||
|
||||
Log("Now delete partition 2...");
|
||||
VDS_DeleteVtoyEFIPartition(pPhyDrive->PhyDrive);
|
||||
|
||||
hDrive = GetPhysicalHandle(pPhyDrive->PhyDrive, TRUE, TRUE, FALSE);
|
||||
if (hDrive == INVALID_HANDLE_VALUE)
|
||||
if (DiskCheckWriteAccess(hDrive))
|
||||
{
|
||||
Log("Failed to GetPhysicalHandle for write.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
Log("MBR DiskCheckWriteAccess success");
|
||||
|
||||
ForceMBR = TRUE;
|
||||
|
||||
Log("Try write failed, now delete partition 2 for MBR...");
|
||||
CHECK_CLOSE_HANDLE(hDrive);
|
||||
|
||||
Log("Now delete partition 2...");
|
||||
VDS_DeleteVtoyEFIPartition(pPhyDrive->PhyDrive);
|
||||
|
||||
hDrive = GetPhysicalHandle(pPhyDrive->PhyDrive, TRUE, TRUE, FALSE);
|
||||
if (hDrive == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Log("Failed to GetPhysicalHandle for write.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("MBR DiskCheckWriteAccess failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2129,11 +2390,40 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
|
||||
}
|
||||
}
|
||||
|
||||
if (CleanDisk)
|
||||
{
|
||||
if (!WriteBackupDataToDisk(hDrive, 0, pBackup, 34 * 512))
|
||||
{
|
||||
bWriteBack = FALSE;
|
||||
}
|
||||
|
||||
free(pBackup);
|
||||
|
||||
if (bWriteBack)
|
||||
{
|
||||
Log("Write backup data success, now delete %s", BackBinFile);
|
||||
DeleteFileA(BackBinFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Write backup data failed");
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
//Refresh Drive Layout
|
||||
DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);
|
||||
|
||||
End:
|
||||
|
||||
if (hVolume != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
bRet = DeviceIoControl(hVolume, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &dwSize, NULL);
|
||||
Log("FSCTL_UNLOCK_VOLUME bRet:%u code:%u", bRet, LASTERR);
|
||||
CHECK_CLOSE_HANDLE(hVolume);
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
Log("OK");
|
||||
@@ -2151,6 +2441,23 @@ End:
|
||||
VDS_ChangeVtoyEFI2Basic(pPhyDrive->PhyDrive, StartSector * 512);
|
||||
}
|
||||
|
||||
if (pPhyDrive->PartStyle == 1)
|
||||
{
|
||||
if (ChangeAttr || ((pPhyDrive->Part2GPTAttr >> 56) != 0xC0))
|
||||
{
|
||||
Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pPhyDrive->Part2GPTAttr, 0xC000000000000001ULL);
|
||||
if (VDS_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, 0xC000000000000001ULL))
|
||||
{
|
||||
Log("Change EFI partition attr success");
|
||||
pPhyDrive->Part2GPTAttr = 0xC000000000000001ULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Change EFI partition attr failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pGptInfo)
|
||||
{
|
||||
free(pGptInfo);
|
||||
|
@@ -267,69 +267,93 @@ static const char* GetEdition(DWORD ProductType)
|
||||
// From: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getproductinfo
|
||||
// These values can be found in the winnt.h header.
|
||||
switch (ProductType) {
|
||||
case 0x00000000: return ""; // Undefined
|
||||
case 0x00000001: return "Ultimate";
|
||||
case 0x00000002: return "Home Basic";
|
||||
case 0x00000003: return "Home Premium";
|
||||
case 0x00000004: return "Enterprise";
|
||||
case 0x00000005: return "Home Basic N";
|
||||
case 0x00000006: return "Business";
|
||||
case 0x00000007: return "Standard Server";
|
||||
case 0x00000008: return "Datacenter Server";
|
||||
case 0x00000009: return "Smallbusiness Server";
|
||||
case 0x0000000A: return "Enterprise Server";
|
||||
case 0x0000000B: return "Starter";
|
||||
case 0x00000010: return "Business N";
|
||||
case 0x00000011: return "Web Server";
|
||||
case 0x00000012: return "Cluster Server";
|
||||
case 0x00000013: return "Home Server";
|
||||
case 0x0000001A: return "Home Premium N";
|
||||
case 0x0000001B: return "Enterprise N";
|
||||
case 0x0000001C: return "Ultimate N";
|
||||
case 0x00000022: return "Home Premium Server";
|
||||
case 0x0000002F: return "Starter N";
|
||||
case 0x00000030: return "Pro";
|
||||
case 0x00000031: return "Pro N";
|
||||
case 0x00000042: return "Starter E";
|
||||
case 0x00000043: return "Home Basic E";
|
||||
case 0x00000044: return "Premium E";
|
||||
case 0x00000045: return "Pro E";
|
||||
case 0x00000046: return "Enterprise E";
|
||||
case 0x00000047: return "Ultimate E";
|
||||
case 0x00000048: return "Enterprise Eval";
|
||||
case 0x00000054: return "Enterprise N Eval";
|
||||
case 0x00000057: return "Thin PC";
|
||||
case 0x0000006F: return "Core Connected";
|
||||
case 0x00000070: return "Pro Student";
|
||||
case 0x00000071: return "Core Connected N";
|
||||
case 0x00000072: return "Pro Student N";
|
||||
case 0x00000073: return "Core Connected Single Language";
|
||||
case 0x00000074: return "Core Connected China";
|
||||
case 0x00000079: return "Edu";
|
||||
case 0x0000007A: return "Edu N";
|
||||
case 0x0000007D: return "Enterprise S";
|
||||
case 0x0000007E: return "Enterprise S N";
|
||||
case 0x0000007F: return "Pro S";
|
||||
case 0x00000080: return "Pro S N";
|
||||
case 0x00000081: return "Enterprise S Eval";
|
||||
case 0x00000082: return "Enterprise S N Eval";
|
||||
case 0x0000008A: return "Pro Single Language";
|
||||
case 0x0000008B: return "Pro China";
|
||||
case 0x0000008C: return "Enterprise Subscription";
|
||||
case 0x0000008D: return "Enterprise Subscription N";
|
||||
case 0x00000095: return "Utility VM";
|
||||
case 0x000000A1: return "Pro Workstation";
|
||||
case 0x000000A2: return "Pro Workstation N";
|
||||
case 0x000000A4: return "Pro for Education";
|
||||
case 0x000000A5: return "Pro for Education N";
|
||||
case 0x000000AB: return "Enterprise G"; // I swear Microsoft are just making up editions...
|
||||
case 0x000000AC: return "Enterprise G N";
|
||||
case 0x000000B6: return "Core OS";
|
||||
case 0x000000B7: return "Cloud E";
|
||||
case 0x000000B8: return "Cloud E N";
|
||||
case 0x000000BD: return "Lite";
|
||||
case 0xABCDABCD: return "(Unlicensed)";
|
||||
default: return "(Unknown Edition)";
|
||||
case 0x00000000: return ""; // Undefined
|
||||
case 0x00000001: return "Ultimate";
|
||||
case 0x00000002: return "Home Basic";
|
||||
case 0x00000003: return "Home Premium";
|
||||
case 0x00000004: return "Enterprise";
|
||||
case 0x00000005: return "Home Basic N";
|
||||
case 0x00000006: return "Business";
|
||||
case 0x00000007: return "Server Standard";
|
||||
case 0x00000008: return "Server Datacenter";
|
||||
case 0x00000009: return "Smallbusiness Server";
|
||||
case 0x0000000A: return "Server Enterprise";
|
||||
case 0x0000000B: return "Starter";
|
||||
case 0x0000000C: return "Server Datacenter (Core)";
|
||||
case 0x0000000D: return "Server Standard (Core)";
|
||||
case 0x0000000E: return "Server Enterprise (Core)";
|
||||
case 0x00000010: return "Business N";
|
||||
case 0x00000011: return "Web Server";
|
||||
case 0x00000012: return "HPC Edition";
|
||||
case 0x00000013: return "Storage Server (Essentials)";
|
||||
case 0x0000001A: return "Home Premium N";
|
||||
case 0x0000001B: return "Enterprise N";
|
||||
case 0x0000001C: return "Ultimate N";
|
||||
case 0x00000022: return "Home Server";
|
||||
case 0x00000024: return "Server Standard without Hyper-V";
|
||||
case 0x00000025: return "Server Datacenter without Hyper-V";
|
||||
case 0x00000026: return "Server Enterprise without Hyper-V";
|
||||
case 0x00000027: return "Server Datacenter without Hyper-V (Core)";
|
||||
case 0x00000028: return "Server Standard without Hyper-V (Core)";
|
||||
case 0x00000029: return "Server Enterprise without Hyper-V (Core)";
|
||||
case 0x0000002A: return "Hyper-V Server";
|
||||
case 0x0000002F: return "Starter N";
|
||||
case 0x00000030: return "Pro";
|
||||
case 0x00000031: return "Pro N";
|
||||
case 0x00000034: return "Server Solutions Premium";
|
||||
case 0x00000035: return "Server Solutions Premium (Core)";
|
||||
case 0x00000040: return "Server Hyper Core V";
|
||||
case 0x00000042: return "Starter E";
|
||||
case 0x00000043: return "Home Basic E";
|
||||
case 0x00000044: return "Premium E";
|
||||
case 0x00000045: return "Pro E";
|
||||
case 0x00000046: return "Enterprise E";
|
||||
case 0x00000047: return "Ultimate E";
|
||||
case 0x00000048: return "Enterprise (Eval)";
|
||||
case 0x0000004F: return "Server Standard (Eval)";
|
||||
case 0x00000050: return "Server Datacenter (Eval)";
|
||||
case 0x00000054: return "Enterprise N (Eval)";
|
||||
case 0x00000057: return "Thin PC";
|
||||
case 0x00000058: case 0x00000059: case 0x0000005A: case 0x0000005B: case 0x0000005C: return "Embedded";
|
||||
case 0x00000062: return "Home N";
|
||||
case 0x00000063: return "Home China";
|
||||
case 0x00000064: return "Home Single Language";
|
||||
case 0x00000065: return "Home";
|
||||
case 0x00000067: return "Pro with Media Center";
|
||||
case 0x00000069: case 0x0000006A: case 0x0000006B: case 0x0000006C: return "Embedded";
|
||||
case 0x0000006F: return "Home Connected";
|
||||
case 0x00000070: return "Pro Student";
|
||||
case 0x00000071: return "Home Connected N";
|
||||
case 0x00000072: return "Pro Student N";
|
||||
case 0x00000073: return "Home Connected Single Language";
|
||||
case 0x00000074: return "Home Connected China";
|
||||
case 0x00000079: return "Education";
|
||||
case 0x0000007A: return "Education N";
|
||||
case 0x0000007D: return "Enterprise LTSB";
|
||||
case 0x0000007E: return "Enterprise LTSB N";
|
||||
case 0x0000007F: return "Pro S";
|
||||
case 0x00000080: return "Pro S N";
|
||||
case 0x00000081: return "Enterprise LTSB (Eval)";
|
||||
case 0x00000082: return "Enterprise LTSB N (Eval)";
|
||||
case 0x0000008A: return "Pro Single Language";
|
||||
case 0x0000008B: return "Pro China";
|
||||
case 0x0000008C: return "Enterprise Subscription";
|
||||
case 0x0000008D: return "Enterprise Subscription N";
|
||||
case 0x00000091: return "Server Datacenter SA (Core)";
|
||||
case 0x00000092: return "Server Standard SA (Core)";
|
||||
case 0x00000095: return "Utility VM";
|
||||
case 0x000000A1: return "Pro for Workstations";
|
||||
case 0x000000A2: return "Pro for Workstations N";
|
||||
case 0x000000A4: return "Pro for Education";
|
||||
case 0x000000A5: return "Pro for Education N";
|
||||
case 0x000000AB: return "Enterprise G"; // I swear Microsoft are just making up editions...
|
||||
case 0x000000AC: return "Enterprise G N";
|
||||
case 0x000000B6: return "Home OS";
|
||||
case 0x000000B7: return "Cloud E";
|
||||
case 0x000000B8: return "Cloud E N";
|
||||
case 0x000000BD: return "Lite";
|
||||
case 0xABCDABCD: return "(Unlicensed)";
|
||||
default: return "(Unknown Edition)";
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
@@ -25,6 +25,7 @@
|
||||
|
||||
|
||||
#include <Windows.h>
|
||||
#include <time.h>
|
||||
#include <winternl.h>
|
||||
#include <commctrl.h>
|
||||
#include <initguid.h>
|
||||
@@ -471,6 +472,7 @@ int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive)
|
||||
char cmdline[MAX_PATH] = { 0 };
|
||||
wchar_t wexe_path[MAX_PATH], *wcmdline;
|
||||
int cur_pid;
|
||||
time_t starttime, curtime;
|
||||
|
||||
|
||||
Log("FindProcessOccupyDisk for PhyDrive %d", pPhyDrive->PhyDrive);
|
||||
@@ -504,11 +506,30 @@ int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive)
|
||||
if (buffer == NULL)
|
||||
goto out;
|
||||
|
||||
for (i = 0;; i++) {
|
||||
Log("handles->NumberOfHandles = %lu", (ULONG)handles->NumberOfHandles);
|
||||
|
||||
if (handles->NumberOfHandles > 10000)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
starttime = time(NULL);
|
||||
|
||||
for (i = 0; i < handles->NumberOfHandles; i++) {
|
||||
ULONG attempts = 8;
|
||||
PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX handleInfo =
|
||||
(i < handles->NumberOfHandles) ? &handles->Handles[i] : NULL;
|
||||
|
||||
//limit the search time
|
||||
if ((i % 100) == 0)
|
||||
{
|
||||
curtime = time(NULL);
|
||||
if (curtime - starttime > 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((dupHandle != NULL) && (processHandle != NtCurrentProcess())) {
|
||||
pfNtClose(dupHandle);
|
||||
dupHandle = NULL;
|
||||
@@ -663,8 +684,12 @@ out:
|
||||
else
|
||||
Log("NOTE: Could not identify the process(es) or service(s) accessing %S", _wHandleName);
|
||||
|
||||
PhFree(buffer);
|
||||
PhFree(handles);
|
||||
if (buffer)
|
||||
PhFree(buffer);
|
||||
|
||||
if (handles)
|
||||
PhFree(handles);
|
||||
|
||||
PhDestroyHeap();
|
||||
|
||||
return 0;
|
||||
|
@@ -435,6 +435,24 @@ static int vtoy_printf_iso_path(ventoy_os_param *param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vtoy_printf_fs(ventoy_os_param *param)
|
||||
{
|
||||
const char *fs[] =
|
||||
{
|
||||
"exfat", "ntfs", "ext", "xfs", "udf", "fat"
|
||||
};
|
||||
|
||||
if (param->vtoy_disk_part_type < 6)
|
||||
{
|
||||
printf("%s\n", fs[param->vtoy_disk_part_type]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("unknown\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vtoy_check_device(ventoy_os_param *param, const char *device)
|
||||
{
|
||||
unsigned long long size;
|
||||
@@ -551,12 +569,13 @@ int vtoydump_main(int argc, char **argv)
|
||||
int rc;
|
||||
int ch;
|
||||
int print_path = 0;
|
||||
int print_fs = 0;
|
||||
char filename[256] = {0};
|
||||
char diskname[256] = {0};
|
||||
char device[64] = {0};
|
||||
ventoy_os_param *param = NULL;
|
||||
|
||||
while ((ch = getopt(argc, argv, "c:f:p:v::")) != -1)
|
||||
while ((ch = getopt(argc, argv, "c:f:p:s:v::")) != -1)
|
||||
{
|
||||
if (ch == 'f')
|
||||
{
|
||||
@@ -575,6 +594,11 @@ int vtoydump_main(int argc, char **argv)
|
||||
print_path = 1;
|
||||
strncpy(filename, optarg, sizeof(filename) - 1);
|
||||
}
|
||||
else if (ch == 's')
|
||||
{
|
||||
print_fs = 1;
|
||||
strncpy(filename, optarg, sizeof(filename) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -f datafile [ -v ] \n", argv[0]);
|
||||
@@ -627,6 +651,10 @@ int vtoydump_main(int argc, char **argv)
|
||||
{
|
||||
rc = vtoy_printf_iso_path(param);
|
||||
}
|
||||
else if (print_fs)
|
||||
{
|
||||
rc = vtoy_printf_fs(param);
|
||||
}
|
||||
else if (device[0])
|
||||
{
|
||||
rc = vtoy_check_device(param, device);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user