diff --git a/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c b/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
index 0682c74c..8a84c3f3 100644
--- a/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
+++ b/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
@@ -7,12 +7,12 @@
* 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 .
*
@@ -76,7 +76,7 @@ STATIC EFI_EXIT_BOOT_SERVICES g_org_exit_boot_service = NULL;
/* Boot filename */
UINTN gBootFileStartIndex = 1;
-CONST CHAR16 *gEfiBootFileName[] =
+CONST CHAR16 *gEfiBootFileName[] =
{
L"@",
EFI_REMOVABLE_MEDIA_FILE_NAME,
@@ -101,7 +101,7 @@ CONST CHAR16 *gEfiBootFileName[] =
L"\\EFI\\BOOT\\bootaa64.efi",
L"\\efi\\boot\\bootaa64.efi",
#endif
-
+
};
VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...)
@@ -112,14 +112,14 @@ VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...)
VA_START (Marker, Format);
UnicodeVSPrintAsciiFormat(Buffer, sizeof(Buffer), Format, Marker);
VA_END (Marker);
-
+
gST->ConOut->OutputString(gST->ConOut, Buffer);
}
VOID EFIAPI ventoy_clear_input(VOID)
{
EFI_INPUT_KEY Key;
-
+
gST->ConIn->Reset(gST->ConIn, FALSE);
while (EFI_SUCCESS == gST->ConIn->ReadKeyStroke(gST->ConIn, &Key))
{
@@ -142,7 +142,7 @@ static void EFIAPI ventoy_dump_img_chunk(ventoy_chain_head *chain)
for (i = 0; i < chain->img_chunk_num; i++)
{
debug("%2u: [ %u - %u ] <==> [ %llu - %llu ]",
- i, chunk[i].img_start_sector, chunk[i].img_end_sector,
+ i, chunk[i].img_start_sector, chunk[i].img_end_sector,
chunk[i].disk_start_sector, chunk[i].disk_end_sector);
if (i > 0 && (chunk[i].img_start_sector != chunk[i - 1].img_end_sector + 1))
@@ -161,7 +161,7 @@ static void EFIAPI ventoy_dump_img_chunk(ventoy_chain_head *chain)
{
debug("image chunk size check failed %d", errcnt);
}
-
+
ventoy_debug_pause();
}
@@ -169,7 +169,7 @@ static void EFIAPI ventoy_dump_override_chunk(ventoy_chain_head *chain)
{
UINT32 i;
ventoy_override_chunk *chunk;
-
+
chunk = (ventoy_override_chunk *)((char *)chain + chain->override_chunk_offset);
debug("##################### ventoy_dump_override_chunk #######################");
@@ -186,7 +186,7 @@ static void EFIAPI ventoy_dump_virt_chunk(ventoy_chain_head *chain)
{
UINT32 i;
ventoy_virt_chunk *node;
-
+
debug("##################### ventoy_dump_virt_chunk #######################");
debug("virt_chunk_offset=%u", chain->virt_chunk_offset);
debug("virt_chunk_num=%u", chain->virt_chunk_num);
@@ -194,7 +194,7 @@ static void EFIAPI ventoy_dump_virt_chunk(ventoy_chain_head *chain)
node = (ventoy_virt_chunk *)((char *)chain + chain->virt_chunk_offset);
for (i = 0; i < chain->virt_chunk_num; i++, node++)
{
- debug("%2u: mem:[ %u, %u, %u ] remap:[ %u, %u, %u ]", i,
+ debug("%2u: mem:[ %u, %u, %u ] remap:[ %u, %u, %u ]", i,
node->mem_sector_start,
node->mem_sector_end,
node->mem_sector_offset,
@@ -202,7 +202,7 @@ static void EFIAPI ventoy_dump_virt_chunk(ventoy_chain_head *chain)
node->remap_sector_end,
node->org_sector_start);
}
-
+
ventoy_debug_pause();
}
@@ -211,7 +211,7 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
UINT32 i = 0;
UINT8 chksum = 0;
UINT8 *guid;
-
+
guid = chain->os_param.vtoy_disk_guid;
for (i = 0; i < sizeof(ventoy_os_param); i++)
{
@@ -229,10 +229,10 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
debug("os_param->vtoy_img_size=<%llu>", chain->os_param.vtoy_img_size);
debug("os_param->vtoy_img_location_addr=<0x%llx>", chain->os_param.vtoy_img_location_addr);
debug("os_param->vtoy_img_location_len=<%u>", chain->os_param.vtoy_img_location_len);
- debug("os_param->vtoy_reserved=<%u %u %u %u %u %u %u>",
- g_os_param_reserved[0],
- g_os_param_reserved[1],
- g_os_param_reserved[2],
+ debug("os_param->vtoy_reserved=<%u %u %u %u %u %u %u>",
+ g_os_param_reserved[0],
+ g_os_param_reserved[1],
+ g_os_param_reserved[2],
g_os_param_reserved[3],
g_os_param_reserved[4],
g_os_param_reserved[5],
@@ -240,7 +240,7 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
);
ventoy_debug_pause();
-
+
debug("chain->disk_drive=0x%x", chain->disk_drive);
debug("chain->disk_sector_size=%u", chain->disk_sector_size);
debug("chain->real_img_size_in_bytes=%llu", chain->real_img_size_in_bytes);
@@ -252,7 +252,7 @@ static void EFIAPI ventoy_dump_chain(ventoy_chain_head *chain)
debug("chain->override_chunk_num=%u", chain->override_chunk_num);
ventoy_debug_pause();
-
+
ventoy_dump_img_chunk(chain);
ventoy_dump_override_chunk(chain);
ventoy_dump_virt_chunk(chain);
@@ -344,7 +344,7 @@ EFI_HANDLE EFIAPI ventoy_get_parent_handle(IN EFI_DEVICE_PATH_PROTOCOL *pDevPath
EFI_DEVICE_PATH_PROTOCOL *pLastNode = NULL;
EFI_DEVICE_PATH_PROTOCOL *pCurNode = NULL;
EFI_DEVICE_PATH_PROTOCOL *pTmpDevPath = NULL;
-
+
pTmpDevPath = DuplicateDevicePath(pDevPath);
if (!pTmpDevPath)
{
@@ -387,8 +387,8 @@ EFI_STATUS EFIAPI ventoy_save_ramdisk_param(VOID)
{
debug("find previous ramdisk variable <%llu>", g_backup_ramdisk_param.DiskSize);
}
-
- Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
+
+ Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_ramdisk_param), &(g_ramdisk_param));
debug("set ramdisk variable %r", Status);
@@ -403,14 +403,14 @@ EFI_STATUS EFIAPI ventoy_delete_ramdisk_param(VOID)
if (g_backup_ramdisk_param.DiskSize > 0 && g_backup_ramdisk_param.PhyAddr > 0)
{
- Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
+ Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_ramdisk_param), &g_backup_ramdisk_param);
debug("resotre ramdisk variable %r", Status);
}
else
{
- Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
+ Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL);
debug("delete ramdisk variable %r", Status);
@@ -432,7 +432,7 @@ EFI_STATUS EFIAPI ventoy_save_variable(VOID)
debug("find previous efi variable <%a>", g_backup_os_param_var.vtoy_img_path);
}
- Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
+ Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_chain->os_param), &(g_chain->os_param));
debug("set efi variable %r", Status);
@@ -447,14 +447,14 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
if (0 == CompareMem(&(g_backup_os_param_var.guid), &VarGuid, sizeof(EFI_GUID)))
{
- Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
+ Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_backup_os_param_var), &(g_backup_os_param_var));
debug("restore efi variable %r", Status);
}
else
{
- Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
+ Status = gRT->SetVariable(L"VentoyOsParam", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL);
debug("delete efi variable %r", Status);
@@ -481,7 +481,7 @@ STATIC VOID ventoy_warn_invalid_device(VOID)
gST->ConOut->OutputString(gST->ConOut, L"This is NOT a standard Ventoy device and is NOT supported.\r\n\r\n");
gST->ConOut->OutputString(gST->ConOut, L"You should follow the official instructions in https://www.ventoy.net\r\n");
-
+
gST->ConOut->OutputString(gST->ConOut, L"\r\n\r\nWill exit after 10 seconds ...... ");
sleep(10);
@@ -489,7 +489,7 @@ STATIC VOID ventoy_warn_invalid_device(VOID)
#else
STATIC VOID ventoy_warn_invalid_device(VOID)
{
-
+
}
#endif
@@ -513,19 +513,19 @@ STATIC EFI_STATUS EFIAPI ventoy_load_image
pFilePath->Header.Length[0] = FileNameLen + sizeof(EFI_DEVICE_PATH_PROTOCOL);
pFilePath->Header.Length[1] = 0;
CopyMem(pFilePath->PathName, FileName, FileNameLen);
-
+
pImgPath = AppendDevicePathNode(pDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)pFilePath);
if (!pImgPath)
{
return EFI_NOT_FOUND;
}
-
+
Status = gBS->LoadImage(FALSE, ImageHandle, pImgPath, NULL, 0, Image);
-
+
debug("Load Image File %r DP: <%s>", Status, ConvertDevicePathToText(pImgPath, FALSE, FALSE));
FreePool(pImgPath);
-
+
return Status;
}
@@ -547,7 +547,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
return EFI_OUT_OF_RESOURCES;
}
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -591,16 +591,16 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
ventoy_warn_invalid_device();
}
}
-
+
gBlockData.RawBlockIoHandle = Handles[i];
gBlockData.pRawBlockIo = pBlockIo;
- gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
+ gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
(VOID **)&(gBlockData.pDiskDevPath),
ImageHandle,
Handles[i],
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
-
- debug("Find Ventoy Disk Sig Handle:%p DP:%s", Handles[i],
+
+ debug("Find Ventoy Disk Sig Handle:%p DP:%s", Handles[i],
ConvertDevicePathToText(gBlockData.pDiskDevPath, FALSE, FALSE));
break;
}
@@ -629,7 +629,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk_fs(IN EFI_HANDLE ImageHandle)
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pFile = NULL;
EFI_DEVICE_PATH_PROTOCOL *pDevPath = NULL;
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -646,7 +646,7 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk_fs(IN EFI_HANDLE ImageHandle)
continue;
}
- Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
+ Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
(VOID **)&pDevPath,
ImageHandle,
Handles[i],
@@ -683,29 +683,29 @@ STATIC EFI_STATUS EFIAPI ventoy_load_isoefi_driver(IN EFI_HANDLE ImageHandle)
if (gIsoUdf)
{
- Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath,
- gUdfEfiDriverPath,
- sizeof(gUdfEfiDriverPath),
+ Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath,
+ gUdfEfiDriverPath,
+ sizeof(gUdfEfiDriverPath),
&Image);
debug("load iso UDF efi driver status:%r", Status);
}
else
{
- Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath,
- gIso9660EfiDriverPath,
- sizeof(gIso9660EfiDriverPath),
+ Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath,
+ gIso9660EfiDriverPath,
+ sizeof(gIso9660EfiDriverPath),
&Image);
- debug("load iso 9660 efi driver status:%r", Status);
+ debug("load iso 9660 efi driver status:%r", Status);
}
if (gDebugPrint)
{
- gRT->SetVariable(L"FS_LOGGING", &gShellVariableGuid,
+ gRT->SetVariable(L"FS_LOGGING", &gShellVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(LogVar), LogVar);
}
- gRT->SetVariable(L"FS_NAME_NOCASE", &gShellVariableGuid,
+ gRT->SetVariable(L"FS_NAME_NOCASE", &gShellVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(LogVar), LogVar);
@@ -732,7 +732,7 @@ STATIC EFI_STATUS ventoy_proc_img_replace_name(ventoy_grub_param_file_replace *r
}
AsciiStrCpyS(tmp, sizeof(tmp), replace->old_file_name[0]);
-
+
for (i = 0; i < 256 && tmp[i]; i++)
{
if (tmp[i] == '/')
@@ -755,7 +755,7 @@ EFI_STATUS EFIAPI ventoy_get_variable_wrapper
)
{
EFI_STATUS Status = EFI_SUCCESS;
-
+
Status = g_org_get_variable(VariableName, VendorGuid, Attributes, DataSize, Data);
if (StrCmp(VariableName, L"SecureBoot") == 0)
{
@@ -779,7 +779,7 @@ EFI_STATUS EFIAPI ventoy_exit_boot_service_wrapper
gRT->GetVariable = g_org_get_variable;
g_org_get_variable = NULL;
}
-
+
return g_org_exit_boot_service(ImageHandle, MapKey);
}
@@ -803,12 +803,12 @@ STATIC EFI_STATUS EFIAPI ventoy_disable_secure_boot(IN EFI_HANDLE ImageHandle)
/* step1: wrapper security protocol. */
/* Do we still need it since we have been loaded ? */
-
-
+
+
/* step2: fake SecureBoot variable */
g_org_exit_boot_service = gBS->ExitBootServices;
gBS->ExitBootServices = ventoy_exit_boot_service_wrapper;
-
+
g_org_get_variable = gRT->GetVariable;
gRT->GetVariable = ventoy_get_variable_wrapper;
@@ -817,7 +817,7 @@ STATIC EFI_STATUS EFIAPI ventoy_disable_secure_boot(IN EFI_HANDLE ImageHandle)
STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
-{
+{
UINT32 i = 0;
UINT32 old_cnt = 0;
UINTN size = 0;
@@ -846,12 +846,12 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
gDebugPrint = TRUE;
}
-
+
if (StrStr(pCmdLine, L"fallback"))
{
gBootFallBack = TRUE;
}
-
+
if (StrStr(pCmdLine, L"dotefi"))
{
gDotEfiBoot = TRUE;
@@ -861,7 +861,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
gLoadIsoEfi = TRUE;
}
-
+
if (StrStr(pCmdLine, L"iso_udf"))
{
gIsoUdf = TRUE;
@@ -899,7 +899,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
return EFI_INVALID_PARAMETER;
}
-
+
pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param="));
grub_env_set = pGrubParam->grub_env_set;
grub_env_get = pGrubParam->grub_env_get;
@@ -914,7 +914,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
ventoy_warn_invalid_device();
return EFI_INVALID_PARAMETER;
}
-
+
g_file_replace_list = &pGrubParam->file_replace;
old_cnt = g_file_replace_list->old_file_cnt;
debug("file replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
@@ -927,7 +927,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
);
-
+
for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
{
replace = pGrubParam->img_replace + i;
@@ -948,7 +948,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
}
}
-
+
pPos = StrStr(pCmdLine, L"mem:");
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
@@ -977,7 +977,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
debug("This is normal mode");
g_chain = AllocatePool(size);
CopyMem(g_chain, chain, size);
-
+
g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset);
g_img_chunk_num = g_chain->img_chunk_num;
g_override_chunk = (ventoy_override_chunk *)((char *)g_chain + g_chain->override_chunk_offset);
@@ -997,7 +997,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
g_hook_keyboard = TRUE;
}
-
+
if (g_os_param_reserved[5] == 1 && g_os_param_reserved[2] == ventoy_chain_linux)
{
ventoy_disable_secure_boot(ImageHandle);
@@ -1024,7 +1024,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
}
g_fix_windows_1st_cdrom_issue = FALSE;
- if (ventoy_chain_windows == g_os_param_reserved[2] ||
+ if (ventoy_chain_windows == g_os_param_reserved[2] ||
ventoy_chain_wim == g_os_param_reserved[2])
{
if (ventoy_is_cdrom_dp_exist())
@@ -1066,7 +1066,7 @@ EFI_STATUS EFIAPI ventoy_clean_env(VOID)
if (!gMemdiskMode)
{
- FreePool(g_chain);
+ FreePool(g_chain);
}
return EFI_SUCCESS;
@@ -1126,7 +1126,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
Count = 0;
Handles = NULL;
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -1145,7 +1145,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
debug("FS:%u Protocol:%p OpenVolume:%p", i, pFile, pFile->OpenVolume);
- Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
+ Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid,
(VOID **)&pDevPath,
ImageHandle,
Handles[i],
@@ -1165,7 +1165,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
for (j = gBootFileStartIndex; j < ARRAY_SIZE(gEfiBootFileName); j++)
{
- Status = ventoy_load_image(ImageHandle, pDevPath, gEfiBootFileName[j],
+ Status = ventoy_load_image(ImageHandle, pDevPath, gEfiBootFileName[j],
StrSize(gEfiBootFileName[j]), &Image);
if (EFI_SUCCESS == Status)
{
@@ -1187,7 +1187,7 @@ 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) || g_img_replace_list)
{
ventoy_wrapper_push_openvolume(pFile->OpenVolume);
@@ -1199,7 +1199,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
//ventoy_wrapper_system();
Status = gBS->StartImage(Image, NULL, NULL);
ventoy_hook_stop();
-
+
if (EFI_ERROR(Status))
{
debug("Failed to start image %r", Status);
@@ -1217,7 +1217,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
{
break;
}
-
+
debug("Fs not found, now wait and retry...");
sleep(1);
}
@@ -1239,7 +1239,7 @@ EFI_STATUS EFIAPI VentoyEfiMain
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol;
-
+
g_sector_flag_num = 512; /* initial value */
g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag));
@@ -1263,6 +1263,11 @@ EFI_STATUS EFIAPI VentoyEfiMain
return Status;
}
+ if (g_os_param_reserved[11] == 1)
+ {
+ ventoy_lock_max_res();
+ }
+
ventoy_disable_ex_filesystem();
if (gMemdiskMode)
@@ -1278,12 +1283,12 @@ EFI_STATUS EFIAPI VentoyEfiMain
ventoy_find_iso_disk_fs(ImageHandle);
ventoy_load_isoefi_driver(ImageHandle);
}
-
+
ventoy_install_blockio(ImageHandle, g_iso_buf_size);
ventoy_debug_pause();
Status = ventoy_boot(ImageHandle);
-
+
ventoy_delete_ramdisk_param();
if (gLoadIsoEfi && gBlockData.IsoDriverImage)
@@ -1310,14 +1315,14 @@ EFI_STATUS EFIAPI VentoyEfiMain
}
ventoy_debug_pause();
-
+
ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes);
ventoy_debug_pause();
Status = ventoy_boot(ImageHandle);
}
-
+
ventoy_clean_env();
}
@@ -1330,17 +1335,22 @@ EFI_STATUS EFIAPI VentoyEfiMain
sleep(30);
}
}
-
+
ventoy_clear_input();
gST->ConOut->ClearScreen(gST->ConOut);
if (gDotEfiBoot && (EFI_NOT_FOUND == Status))
{
- grub_env_set("vtoy_dotefi_retry", "YES");
+ grub_env_set("vtoy_dotefi_retry", "YES");
}
ventoy_enable_ex_filesystem();
+ if (g_os_param_reserved[11] == 1)
+ {
+ ventoy_unlock_max_res();
+ }
+
return EFI_SUCCESS;
}
diff --git a/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h b/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
index 8de03516..121ebd31 100644
--- a/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
+++ b/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
@@ -7,17 +7,17 @@
* 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 .
*
*/
-
+
#ifndef __VENTOY_H__
#define __VENTOY_H__
@@ -54,7 +54,7 @@ typedef struct ventoy_image_disk_region
typedef struct ventoy_image_location
{
ventoy_guid guid;
-
+
/* image sector size, currently this value is always 2048 */
UINT32 image_sector_size;
@@ -62,10 +62,10 @@ typedef struct ventoy_image_location
UINT32 disk_sector_size;
UINT32 region_count;
-
+
/*
* disk region data
- * If the image file has more than one fragments in disk,
+ * If the image file has more than one fragments in disk,
* there will be more than one region data here.
*
*/
@@ -86,7 +86,7 @@ typedef struct ventoy_os_param
char vtoy_img_path[384]; // It seems to be enough, utf-8 format
UINT64 vtoy_img_size; // image file size in bytes
- /*
+ /*
* Ventoy will write a copy of ventoy_image_location data into runtime memory
* this is the physically address and length of that memory.
* Address 0 means no such data exist.
@@ -95,7 +95,7 @@ typedef struct ventoy_os_param
*/
UINT64 vtoy_img_location_addr;
UINT32 vtoy_img_location_len;
-
+
UINT64 vtoy_reserved[4]; // Internal use by ventoy
UINT8 vtoy_disk_signature[4];
@@ -124,7 +124,7 @@ typedef struct ventoy_chain_head
UINT64 virt_img_size_in_bytes;
UINT32 boot_catalog;
UINT8 boot_catalog_sector[2048];
-
+
UINT32 img_chunk_offset;
UINT32 img_chunk_num;
@@ -199,11 +199,11 @@ typedef struct ventoy_virt_chunk
typedef struct ventoy_sector_flag
{
UINT8 flag; // 0:init 1:mem 2:remap
- UINT64 remap_lba;
+ UINT64 remap_lba;
}ventoy_sector_flag;
-typedef struct vtoy_block_data
+typedef struct vtoy_block_data
{
EFI_HANDLE Handle;
EFI_BLOCK_IO_MEDIA Media; /* Media descriptor */
@@ -272,7 +272,7 @@ typedef struct ventoy_grub_param
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
- grub_env_printf_pf grub_env_printf;
+ grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
typedef struct ventoy_ram_disk
@@ -318,7 +318,7 @@ typedef struct MBR_HEAD
#pragma pack()
-typedef struct well_known_guid
+typedef struct well_known_guid
{
EFI_GUID *guid;
const char *name;
@@ -331,7 +331,7 @@ typedef struct ventoy_system_wrapper
EFI_HANDLE_PROTOCOL NewHandleProtocol;
EFI_HANDLE_PROTOCOL OriHandleProtocol;
-
+
EFI_OPEN_PROTOCOL NewOpenProtocol;
EFI_OPEN_PROTOCOL OriOpenProtocol;
@@ -382,7 +382,7 @@ typedef struct DriverBindWrapper
extern BOOLEAN gDebugPrint;
VOID EFIAPI VtoyDebug(IN CONST CHAR8 *Format, ...);
EFI_STATUS EFIAPI ventoy_wrapper_system(VOID);
-EFI_STATUS EFIAPI ventoy_block_io_read
+EFI_STATUS EFIAPI ventoy_block_io_read
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
@@ -428,6 +428,8 @@ EFI_STATUS ventoy_hook_1st_cdrom_start(VOID);
EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID);
EFI_STATUS ventoy_disable_ex_filesystem(VOID);
EFI_STATUS ventoy_enable_ex_filesystem(VOID);
+EFI_STATUS ventoy_lock_max_res(VOID);
+EFI_STATUS ventoy_unlock_max_res(VOID);
#endif
diff --git a/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c b/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
index c0c1fc3b..0dfe28c2 100644
--- a/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
+++ b/EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
@@ -7,12 +7,12 @@
* 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 .
*
@@ -85,7 +85,7 @@ BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -107,24 +107,24 @@ BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
FreePool(Handles);
return TRUE;
}
-
+
DevicePath = NextDevicePathNode(DevicePath);
}
}
FreePool(Handles);
- return FALSE;
+ return FALSE;
}
#if 0
/* Block IO procotol */
#endif
-EFI_STATUS EFIAPI ventoy_block_io_reset
+EFI_STATUS EFIAPI ventoy_block_io_reset
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
-)
+)
{
(VOID)This;
(VOID)ExtendedVerification;
@@ -151,8 +151,8 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
ventoy_img_chunk *pchunk = g_chunk;
ventoy_override_chunk *pOverride = g_override_chunk;
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
-
- debug("read iso sector %lu count %u Buffer:%p Align:%u blk:%u",
+
+ debug("read iso sector %lu count %u Buffer:%p Align:%u blk:%u",
Sector, Count, Buffer, pRawBlockIo->Media->IoAlign, pRawBlockIo->Media->BlockSize);
ReadStart = Sector * 2048;
@@ -207,7 +207,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{
OverrideStart = pOverride->img_offset;
OverrideEnd = pOverride->img_offset + pOverride->override_size;
-
+
if (OverrideStart >= ReadEnd || ReadStart >= OverrideEnd)
{
continue;
@@ -217,7 +217,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{
if (ReadEnd <= OverrideEnd)
{
- CopyMem(pCurBuf + OverrideStart - ReadStart, pOverride->override_data, ReadEnd - OverrideStart);
+ CopyMem(pCurBuf + OverrideStart - ReadStart, pOverride->override_data, ReadEnd - OverrideStart);
}
else
{
@@ -228,7 +228,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
{
if (ReadEnd <= OverrideEnd)
{
- CopyMem(pCurBuf, pOverride->override_data + ReadStart - OverrideStart, ReadEnd - ReadStart);
+ CopyMem(pCurBuf, pOverride->override_data + ReadStart - OverrideStart, ReadEnd - ReadStart);
}
else
{
@@ -236,7 +236,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
}
}
- if (g_fixup_iso9660_secover_enable && (!g_fixup_iso9660_secover_start) &&
+ if (g_fixup_iso9660_secover_enable && (!g_fixup_iso9660_secover_start) &&
pOverride->override_size == sizeof(ventoy_iso9660_override))
{
ventoy_iso9660_override *dirent = (ventoy_iso9660_override *)pOverride->override_data;
@@ -256,7 +256,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
}
}
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
@@ -276,7 +276,7 @@ STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
UINT8 *pCurBuf = (UINT8 *)Buffer;
ventoy_img_chunk *pchunk = g_chunk;
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
-
+
debug("write iso sector %lu count %u", Sector, Count);
ReadStart = Sector * 2048;
@@ -321,17 +321,17 @@ STATIC EFI_STATUS EFIAPI ventoy_write_iso_sector
}
}
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
-EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write
+EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
IN VOID *Buffer
-)
+)
{
(VOID)This;
(VOID)MediaId;
@@ -349,14 +349,14 @@ EFI_STATUS EFIAPI ventoy_block_io_ramdisk_write
return EFI_SUCCESS;
}
-EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read
+EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
-)
+)
{
//debug("### ventoy_block_io_ramdisk_read sector:%u count:%u", (UINT32)Lba, (UINT32)BufferSize / 2048);
@@ -364,12 +364,12 @@ EFI_STATUS EFIAPI ventoy_block_io_ramdisk_read
(VOID)MediaId;
CopyMem(Buffer, g_iso_data_buf + (Lba * 2048), BufferSize);
-
+
if (g_blockio_start_record_bcd && FALSE == g_blockio_bcd_read_done)
{
if (*(UINT32 *)Buffer == 0x66676572)
{
- g_blockio_bcd_read_done = TRUE;
+ g_blockio_bcd_read_done = TRUE;
}
}
@@ -429,14 +429,14 @@ end:
return Lba;
}
-EFI_STATUS EFIAPI ventoy_block_io_read_real
+EFI_STATUS EFIAPI ventoy_block_io_read_real
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
-)
+)
{
UINT32 i = 0;
UINT32 j = 0;
@@ -450,7 +450,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_real
UINT8 *lastbuffer;
ventoy_sector_flag *cur_flag;
ventoy_virt_chunk *node;
-
+
debug("### block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
secNum = BufferSize / 2048;
@@ -510,7 +510,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_real
{
if (curlba >= node->mem_sector_start && curlba < node->mem_sector_end)
{
- CopyMem((UINT8 *)Buffer + j * 2048,
+ CopyMem((UINT8 *)Buffer + j * 2048,
(char *)g_virt_chunk + node->mem_sector_offset + (curlba - node->mem_sector_start) * 2048,
2048);
cur_flag->flag = 1;
@@ -564,7 +564,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
-)
+)
{
UINT32 IoAlign = 0;
VOID *NewBuf = NULL;
@@ -593,18 +593,18 @@ EFI_STATUS EFIAPI ventoy_block_io_read
return Status;
}
-EFI_STATUS EFIAPI ventoy_block_io_write
+EFI_STATUS EFIAPI ventoy_block_io_write
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
IN VOID *Buffer
-)
+)
{
UINT32 secNum = 0;
UINT64 offset = 0;
-
+
(VOID)This;
(VOID)MediaId;
@@ -636,8 +636,8 @@ STATIC UINTN ventoy_get_current_device_path_id(VOID)
EFI_STATUS Status = EFI_SUCCESS;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
VENDOR_DEVICE_PATH *venPath = NULL;
-
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
+
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDevicePathProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -688,7 +688,7 @@ EFI_STATUS EFIAPI ventoy_fill_device_path(VOID)
venPath->Header.Length[1] = 0;
CopyMem(&venPath->Guid, &gVtoyBlockDevicePathGuid, sizeof(EFI_GUID));
CopyMem(venPath + 1, VtoyDpName, NameLen);
-
+
gBlockData.Path = AppendDevicePathNode(NULL, (EFI_DEVICE_PATH_PROTOCOL *)TmpBuf);
gBlockData.DevicePathCompareLen = sizeof(VENDOR_DEVICE_PATH) + NameLen;
@@ -710,7 +710,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
debug("ventoy_connect_driver <%s>...", DrvName);
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -748,7 +748,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
FreePool(Handles);
Handles = NULL;
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -781,10 +781,10 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
}
Status = EFI_NOT_FOUND;
-
+
end:
FreePool(Handles);
-
+
return Status;
}
@@ -805,11 +805,11 @@ STATIC BOOLEAN ventoy_filesystem_need_wrapper(IN CONST CHAR16 *DrvName)
}
/*
- * suppress some file system drivers
+ * suppress some file system drivers
* 1. rEFInd File System Driver
*
*/
-
+
if (StrStr(UpperDrvName, L"REFIND") && StrStr(UpperDrvName, L"FILE SYSTEM"))
{
return TRUE;
@@ -820,7 +820,7 @@ STATIC BOOLEAN ventoy_filesystem_need_wrapper(IN CONST CHAR16 *DrvName)
STATIC VOID ventoy_add_filesystem_wrapper
(
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol,
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol,
IN CONST CHAR16 *DriverName
)
{
@@ -865,10 +865,10 @@ STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
EFI_COMPONENT_NAME_PROTOCOL *NameProtocol = NULL;
EFI_COMPONENT_NAME2_PROTOCOL *Name2Protocol = NULL;
EFI_DRIVER_BINDING_PROTOCOL *DriverBindProtocol = NULL;
-
+
debug("ventoy_find_filesystem_driverbind...");
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentName2ProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -899,7 +899,7 @@ STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
FreePool(Handles);
Handles = NULL;
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid,
NULL, &Count, &Handles);
if (EFI_ERROR(Status))
{
@@ -927,7 +927,7 @@ STATIC EFI_STATUS ventoy_find_filesystem_driverbind(VOID)
}
FreePool(Handles);
-
+
return EFI_SUCCESS;
}
@@ -988,7 +988,7 @@ EFI_STATUS ventoy_disable_ex_filesystem(VOID)
debug("Wrapper Ex Driver Binding %lu", g_DriverBindWrapperCnt);
ventoy_debug_pause();
-
+
return EFI_SUCCESS;
}
@@ -1046,10 +1046,10 @@ EFI_STATUS EFIAPI ventoy_block_io_read_512
if (BufferSize >= 2048)
{
ReadSize = BufferSize / 2048 * 2048;
-
+
Status |= g_sector_2048_read(This, MediaId, Lba / 4, ReadSize, CurBuf);
CurBuf += ReadSize;
-
+
Lba += ReadSize / 512;
BufferSize -= ReadSize;
}
@@ -1096,7 +1096,7 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
ReadSize = (4 - Mod) * 512;
CopyMem(g_sector_buf + Mod * 512, CurBuf, ReadSize);
g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
-
+
CurBuf += ReadSize;
Lba += (4 - Mod);
BufferSize -= ReadSize;
@@ -1106,10 +1106,10 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
if (BufferSize >= 2048)
{
ReadSize = BufferSize / 2048 * 2048;
-
+
Status |= g_sector_2048_write(This, MediaId, Lba / 4, ReadSize, CurBuf);
CurBuf += ReadSize;
-
+
Lba += ReadSize / 512;
BufferSize -= ReadSize;
}
@@ -1117,7 +1117,7 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
if (BufferSize > 0)
{
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
-
+
CopyMem(g_sector_buf, CurBuf, BufferSize);
g_sector_2048_write(This, MediaId, Lba / 4, 2048, g_sector_buf);
}
@@ -1126,10 +1126,10 @@ EFI_STATUS EFIAPI ventoy_block_io_write_512
}
EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize)
-{
+{
EFI_STATUS Status = EFI_SUCCESS;
EFI_BLOCK_IO_PROTOCOL *pBlockIo = &(gBlockData.BlockIo);
-
+
ventoy_fill_device_path();
debug("install block io protocol %p", ImageHandle);
@@ -1144,10 +1144,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
else
{
gBlockData.Media.BlockSize = 2048;
- gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
+ gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
gBlockData.Media.ReadOnly = TRUE;
}
-
+
gBlockData.Media.MediaPresent = 1;
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
@@ -1164,10 +1164,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
}
else
{
- pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
+ pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
pBlockIo->WriteBlocks = ventoy_block_io_write;
}
-
+
pBlockIo->FlushBlocks = ventoy_block_io_flush;
Status = gBS->InstallMultipleProtocolInterfaces(&gBlockData.Handle,
@@ -1295,7 +1295,7 @@ DEF_WRAP_FUNC(7);
#error "VTOY_MAX_CONF_REPLACE overflow"
#endif
-static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] =
+static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] =
{
ventoy_wrapper_file_flush_ex_img0,
ventoy_wrapper_file_flush_ex_img1,
@@ -1335,7 +1335,7 @@ STATIC ventoy_efi_file_replace *ventoy_wrapper_get_replace(EFI_FILE_HANDLE This)
return g_img_file_replace + i;
}
}
-
+
return NULL;
}
@@ -1369,7 +1369,7 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This);
-
+
if (Position <= replace->FileSizeBytes)
{
replace->CurPos = Position;
@@ -1378,7 +1378,7 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
{
replace->CurPos = replace->FileSizeBytes;
}
-
+
return EFI_SUCCESS;
}
@@ -1425,7 +1425,7 @@ ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, V
//Info->FileName = EFI_FILE_READ_ONLY;
*Len = Info->Size;
-
+
return EFI_SUCCESS;
}
@@ -1437,7 +1437,7 @@ ventoy_wrapper_file_read(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
ventoy_efi_file_replace *replace = NULL;
replace = ventoy_wrapper_get_replace(This);
-
+
debug("ventoy_wrapper_file_read ... %u", *Len);
if (replace->CurPos + ReadLen > replace->FileSizeBytes)
@@ -1494,7 +1494,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, B
STATIC BOOLEAN EFIAPI ventoy_replace_name_match(CHAR8 *pReplace, CHAR8 *pName)
{
UINTN Len1, Len2;
-
+
Len1 = AsciiStrLen(pReplace);
Len2 = AsciiStrLen(pName);
@@ -1521,10 +1521,10 @@ STATIC BOOLEAN EFIAPI ventoy_replace_name_match(CHAR8 *pReplace, CHAR8 *pName)
STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
(
- EFI_FILE_HANDLE This,
+ EFI_FILE_HANDLE This,
EFI_FILE_HANDLE *New,
- CHAR16 *Name,
- UINT64 Mode,
+ CHAR16 *Name,
+ UINT64 Mode,
UINT64 Attributes
)
{
@@ -1571,7 +1571,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
-
+
g_efi_file_replace.BlockIoSectorStart = virt->mem_sector_start;
g_efi_file_replace.FileSizeBytes = Sectors * 2048;
@@ -1581,7 +1581,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
g_efi_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3);
}
-
+
return Status;
}
}
@@ -1605,9 +1605,9 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
{
AsciiStrCpyS(OldName, sizeof(OldName), replace->old_file_name[j]);
if ((0 == AsciiStrCmp(OldName, TmpName)) ||
- (AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
+ (AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
AsciiStrCmp(OldName + 16, TmpName) == 0
- )
+ )
)
{
g_original_fclose(*New);
@@ -1617,7 +1617,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
virt = g_virt_chunk + replace->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[i].BlockIoSectorStart = virt->mem_sector_start;
g_img_file_replace[i].FileSizeBytes = Sectors * 2048;
@@ -1627,7 +1627,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
g_img_file_replace[i].BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3);
}
-
+
return Status;
}
}
@@ -1648,7 +1648,7 @@ EFI_STATUS EFIAPI ventoy_wrapper_open_volume
)
{
EFI_STATUS Status = EFI_SUCCESS;
-
+
Status = g_original_open_volume(This, Root);
if (!EFI_ERROR(Status))
{
@@ -1685,10 +1685,10 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_read_key_ex
KeyData->Key.UnicodeChar = 0;
KeyData->KeyState.KeyShiftState = 0;
KeyData->KeyState.KeyToggleState = 0;
-
+
return EFI_SUCCESS;
}
-
+
return g_org_read_key_ex(This, KeyData);
}
@@ -1725,7 +1725,7 @@ EFI_STATUS ventoy_hook_keyboard_start(VOID)
g_org_read_key = gST->ConIn->ReadKeyStroke;
gST->ConIn->ReadKeyStroke = ventoy_wrapper_read_key;
-
+
return EFI_SUCCESS;
}
@@ -1763,7 +1763,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_locate_handle
EFI_STATUS Status = EFI_SUCCESS;
Status = g_org_locate_handle(SearchType, Protocol, SearchKey, BufferSize, Buffer);
-
+
if (EFI_SUCCESS == Status && Protocol && CompareGuid(&gEfiBlockIoProtocolGuid, Protocol))
{
for (i = 0; i < (*BufferSize) / sizeof(EFI_HANDLE); i++)
@@ -1785,7 +1785,7 @@ EFI_STATUS ventoy_hook_1st_cdrom_start(VOID)
{
g_org_locate_handle = gBS->LocateHandle;
gBS->LocateHandle = ventoy_wrapper_locate_handle;
-
+
return EFI_SUCCESS;
}
@@ -1793,7 +1793,112 @@ EFI_STATUS ventoy_hook_1st_cdrom_stop(VOID)
{
gBS->LocateHandle = g_org_locate_handle;
g_org_locate_handle = NULL;
-
+
return EFI_SUCCESS;
}
+
+
+#if 0
+/* For force highest resolution for Windows/WinPE */
+#endif
+
+
+STATIC UINT32 g_org_mode_num;
+STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE g_org_set_mode = NULL;
+
+STATIC EFI_STATUS EFIAPI ventoy_set_mode
+(
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN UINT32 ModeNumber
+)
+{
+ (void)This;
+ (void)ModeNumber;
+
+ /* Force highest resolution */
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS ventoy_lock_max_res(VOID)
+{
+ UINT32 i = 0;
+ UINT32 x = 0;
+ UINT32 y = 0;
+ UINT32 CurMode = 0;
+ UINT32 Highest = 0;
+ UINTN Size;
+ EFI_STATUS rc;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
+
+ /* already hook */
+ if (g_org_set_mode)
+ {
+ return EFI_SUCCESS;
+ }
+
+ rc = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (void **)&gop);
+ if (rc != EFI_SUCCESS)
+ {
+ debug("Failed to locate GOP protocol");
+ return EFI_SUCCESS;
+ }
+
+ CurMode = gop->Mode->Mode;
+
+ for (i = 0 ; i < gop->Mode->MaxMode ; i++)
+ {
+ /* Get mode information */
+ if (gop->QueryMode(gop, i, &Size, &info) == EFI_SUCCESS)
+ {
+ if (x < info->HorizontalResolution ||
+ (x == info->HorizontalResolution && y < info->VerticalResolution))
+ {
+ Highest = i;
+ x = info->HorizontalResolution;
+ y = info->VerticalResolution;
+ }
+ }
+ }
+
+ if (Highest != CurMode)
+ {
+ gop->SetMode(gop, Highest);
+ }
+
+ debug("Lock resolution to Mode:%d %d x %d", Highest, x, y);
+
+ g_org_mode_num = CurMode;
+ g_org_set_mode = gop->SetMode;
+ gop->SetMode = ventoy_set_mode;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS ventoy_unlock_max_res(VOID)
+{
+ EFI_STATUS rc;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
+
+ /* not hooked yet */
+ if (!g_org_set_mode)
+ {
+ return EFI_SUCCESS;
+ }
+
+ rc = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (void **)&gop);
+ if (rc != EFI_SUCCESS)
+ {
+ debug("Failed to locate GOP protocol");
+ return EFI_SUCCESS;
+ }
+
+ g_org_set_mode(gop, g_org_mode_num);
+
+ gop->SetMode = g_org_set_mode;
+ g_org_set_mode = NULL;
+ return EFI_SUCCESS;
+}
+
+
diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
index 38927df8..77253d0a 100644
--- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
+++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
@@ -1,5 +1,5 @@
/******************************************************************************
- * ventoy.c
+ * ventoy.c
*
* Copyright (c) 2020, longpanda
*
@@ -7,12 +7,12 @@
* 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 .
*
@@ -137,7 +137,7 @@ int ventoy_str_len_alnum(const char *str, int len)
{
int i;
int slen;
-
+
if (NULL == str || 0 == *str)
{
return 0;
@@ -168,7 +168,7 @@ int ventoy_str_len_alnum(const char *str, int len)
char * ventoy_str_basename(char *path)
{
char *pos = NULL;
-
+
pos = grub_strrchr(path, '/');
if (pos)
{
@@ -185,17 +185,17 @@ char * ventoy_str_basename(char *path)
int ventoy_str_chrcnt(const char *str, char c)
{
int n = 0;
-
+
if (str)
{
while (*str)
{
if (*str == c)
{
- n++;
+ n++;
}
str++;
- }
+ }
}
return n;
@@ -235,7 +235,7 @@ int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n)
grub_err_t ventoy_env_int_set(const char *name, int value)
{
char buf[16];
-
+
grub_snprintf(buf, sizeof(buf), "%d", value);
return grub_env_set(name, buf);
}
@@ -248,13 +248,13 @@ void ventoy_debug_dump_guid(const char *prefix, grub_uint8_t *guid)
{
return;
}
-
+
debug("%s", prefix);
for (i = 0; i < 16; i++)
{
grub_printf("%02x ", guid[i]);
}
- grub_printf("\n");
+ grub_printf("\n");
}
int ventoy_is_efi_os(void)
@@ -290,7 +290,7 @@ void ventoy_memfile_env_set(const char *prefix, const void *buf, unsigned long l
grub_snprintf(name, sizeof(name), "%s_addr", prefix);
grub_snprintf(val, sizeof(val), "0x%llx", (ulonglong)(ulong)buf);
grub_env_set(name, val);
-
+
grub_snprintf(name, sizeof(name), "%s_size", prefix);
grub_snprintf(val, sizeof(val), "%llu", len);
grub_env_set(name, val);
@@ -374,7 +374,7 @@ static int ventoy_hwinfo_init(void)
return 0;
}
-static global_var_cfg g_global_vars[] =
+static global_var_cfg g_global_vars[] =
{
{ "gfxmode", "1024x768", NULL },
{ ventoy_left_key, "5%", NULL },
@@ -422,19 +422,20 @@ int ventoy_global_var_init(void)
for (i = 0; g_global_vars[i].name; i++)
{
g_global_vars[i].value = grub_strdup(g_global_vars[i].defval);
- ventoy_env_export(g_global_vars[i].name, g_global_vars[i].defval);
+ ventoy_env_export(g_global_vars[i].name, g_global_vars[i].defval);
grub_register_variable_hook(g_global_vars[i].name, ventoy_global_var_read_hook, ventoy_global_var_write_hook);
}
return 0;
}
-static ctrl_var_cfg g_ctrl_vars[] =
+static ctrl_var_cfg g_ctrl_vars[] =
{
{ "VTOY_WIN11_BYPASS_CHECK", 1 },
{ "VTOY_WIN11_BYPASS_NRO", 1 },
{ "VTOY_LINUX_REMOUNT", 0 },
{ "VTOY_SECONDARY_BOOT_MENU", 1 },
+ { "VTOY_WIN_UEFI_MAX_RES", 1 },
{ NULL, 0 }
};
diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
index ae831cff..3356a0a5 100644
--- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
@@ -1,5 +1,5 @@
/******************************************************************************
- * ventoy_cmd.c
+ * ventoy_cmd.c
*
* Copyright (c) 2021, longpanda
*
@@ -7,12 +7,12 @@
* 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 .
*
@@ -55,7 +55,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
static grub_uint8_t g_check_mbr_data[] = {
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,
0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44, 0x00, 0x52, 0x64, 0x00, 0x20, 0x45, 0x72, 0x0D,
};
@@ -149,12 +149,12 @@ static char g_iso_vd_id_application[130];
static int g_pager_flag = 0;
static char g_old_pager[32];
-const char *g_menu_class[img_type_max] =
+const char *g_menu_class[img_type_max] =
{
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg", "vtoyvhd", "vtoyvtoy"
};
-
-const char *g_menu_prefix[img_type_max] =
+
+const char *g_menu_prefix[img_type_max] =
{
"iso", "wim", "efi", "img", "vhd", "vtoy"
};
@@ -216,7 +216,7 @@ static int ventoy_string_check(const char *str, grub_char_check_func check)
{
return 0;
}
-
+
for ( ; *str; str++)
{
if (!check(*str))
@@ -238,7 +238,7 @@ static grub_ssize_t ventoy_fs_read(grub_file_t file, char *buf, grub_size_t len)
static int ventoy_control_get_flag(const char *key)
{
const char *val = ventoy_get_env(key);
-
+
if (val && val[0] == '1' && val[1] == 0)
{
return 1;
@@ -267,10 +267,10 @@ static int ventoy_video_hook(const struct grub_video_mode_info *info, void *hook
{
return 0;
}
-
+
for (i = 0; i < g_video_mode_num; i++)
{
- if (g_video_mode_list[i].width == info->width &&
+ if (g_video_mode_list[i].width == info->width &&
g_video_mode_list[i].height == info->height &&
g_video_mode_list[i].bpp == info->bpp)
{
@@ -324,7 +324,7 @@ static int ventoy_enum_video_mode(void)
grub_video_adapter_t adapter;
grub_video_driver_id_t id;
ventoy_video_mode mode;
-
+
g_video_mode_num = 0;
g_video_mode_max = 1024;
g_video_mode_list = grub_malloc(sizeof(ventoy_video_mode) * g_video_mode_max);
@@ -367,7 +367,7 @@ static int ventoy_enum_video_mode(void)
grub_memcpy(g_video_mode_list + j, &mode, sizeof(ventoy_video_mode));
}
}
-
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -396,15 +396,15 @@ static int ventoy_pre_parse_data(char *src, int size)
goto end;
}
- grub_snprintf(buf, sizeof(buf),
- "regexp -s 1:%s -s 2:%s -s 3:%s \"@([^@]*)@([^@]*)@([^@]*)@\" \"%s\"",
+ grub_snprintf(buf, sizeof(buf),
+ "regexp -s 1:%s -s 2:%s -s 3:%s \"@([^@]*)@([^@]*)@([^@]*)@\" \"%s\"",
ventoy_left_key, ventoy_top_key, ventoy_color_key, src);
grub_script_execute_sourcecode(buf);
-end:
+end:
*pos = c;
- return 0;
+ return 0;
}
static grub_file_t ventoy_wrapper_open(grub_file_t rawFile, enum grub_file_type type)
@@ -444,7 +444,7 @@ static grub_file_t ventoy_wrapper_open(grub_file_t rawFile, enum grub_file_type
len = ventoy_fill_data(4096, (char *)file->data + rawFile->size);
g_old_file = rawFile;
-
+
file->size = rawFile->size + len;
file->device = rawFile->device;
file->fs = &vtoy_fs;
@@ -456,7 +456,7 @@ static grub_file_t ventoy_wrapper_open(grub_file_t rawFile, enum grub_file_type
static int ventoy_check_decimal_var(const char *name, long *value)
{
const char *value_str = NULL;
-
+
value_str = grub_env_get(name);
if (NULL == value_str)
{
@@ -476,7 +476,7 @@ static int ventoy_check_decimal_var(const char *name, long *value)
grub_uint64_t ventoy_get_vtoy_partsize(int part)
{
grub_uint64_t sectors;
-
+
if (grub_strncmp(g_ventoy_part_info->Head.Signature, "EFI PART", 8) == 0)
{
sectors = g_ventoy_part_info->PartTbl[part].LastLBA + 1 - g_ventoy_part_info->PartTbl[part].StartLBA;
@@ -505,23 +505,23 @@ static int ventoy_load_efiboot_template(char **buf, int *datalen, int *direntoff
}
len = (int)file->size;
-
+
data = (char *)grub_malloc(file->size);
if (!data)
{
return 1;
}
-
+
grub_file_read(file, data, file->size);
- grub_file_close(file);
+ grub_file_close(file);
grub_snprintf(exec, sizeof(exec), "loopback efiboot mem:0x%llx:size:%d", (ulonglong)(ulong)data, len);
grub_script_execute_sourcecode(exec);
- file = grub_file_open("(efiboot)/EFI/BOOT/BOOTX64.EFI", GRUB_FILE_TYPE_LINUX_INITRD);
+ file = grub_file_open("(efiboot)/EFI/BOOT/BOOTX64.EFI", GRUB_FILE_TYPE_LINUX_INITRD);
offset = (grub_uint32_t)grub_iso9660_get_last_file_dirent_pos(file);
grub_file_close(file);
-
+
grub_script_execute_sourcecode("loopback -d efiboot");
*buf = data;
@@ -534,7 +534,7 @@ static int ventoy_load_efiboot_template(char **buf, int *datalen, int *direntoff
static int ventoy_set_check_result(int ret, const char *msg)
{
char buf[32];
-
+
grub_snprintf(buf, sizeof(buf), "%d", (ret & 0x7FFF));
grub_env_set("VTOY_CHKDEV_RESULT_STRING", buf);
grub_env_export("VTOY_CHKDEV_RESULT_STRING");
@@ -545,7 +545,7 @@ static int ventoy_set_check_result(int ret, const char *msg)
grub_printf(VTOY_WARNING"\n");
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 (%d).\n", ret);
grub_printf("Error message: <%s>\n\n", msg);
grub_printf("You should follow the instructions in https://www.ventoy.net to use Ventoy.\n");
@@ -567,7 +567,7 @@ static int ventoy_check_official_device(grub_device_t dev)
grub_device_t dev2;
char *label = NULL;
struct grub_partition *partition;
-
+
if (dev->disk == NULL || dev->disk->partition == NULL)
{
return ventoy_set_check_result(1 | 0x1000, "Internal Error");
@@ -604,7 +604,7 @@ static int ventoy_check_official_device(grub_device_t dev)
}
else
{
- file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
+ file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
}
if (!file)
{
@@ -682,7 +682,7 @@ static int ventoy_check_official_device(grub_device_t dev)
return ventoy_set_check_result(10, "Partition name is not VTOYEFI");
}
- grub_device_close(dev2);
+ grub_device_close(dev2);
}
/* MBR check */
@@ -695,7 +695,7 @@ static int ventoy_check_official_device(grub_device_t dev)
grub_memset(mbr, 0, 512);
grub_disk_read(disk, 0, 0, 512, mbr);
grub_disk_close(disk);
-
+
if (grub_memcmp(g_check_mbr_data, mbr, 0x30) || grub_memcmp(g_check_mbr_data + 0x30, mbr + 0x190, 16))
{
return ventoy_set_check_result(12, "MBR check failed");
@@ -728,7 +728,7 @@ grub_uint64_t ventoy_grub_get_file_size(const char *fmt, ...)
va_start (ap, fmt);
grub_vsnprintf(fullpath, 255, fmt, ap);
va_end (ap);
-
+
file = grub_file_open(fullpath, VENTOY_FILE_TYPE);
if (!file)
{
@@ -792,7 +792,7 @@ int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_ou
{
mz_stream s;
grub_uint8_t *outbuf;
- grub_uint8_t gzHdr[10] =
+ grub_uint8_t gzHdr[10] =
{
0x1F, 0x8B, /* magic */
8, /* z method */
@@ -805,7 +805,7 @@ int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_ou
grub_memset(&s, 0, sizeof(mz_stream));
mz_deflateInit2(&s, 1, MZ_DEFLATED, -MZ_DEFAULT_WINDOW_BITS, 6, MZ_DEFAULT_STRATEGY);
-
+
outbuf = (grub_uint8_t *)mem_out;
mem_out_len -= sizeof(gzHdr) + 8;
@@ -826,7 +826,7 @@ int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_ou
*(grub_uint32_t *)outbuf = grub_getcrc32c(0, outbuf, s.total_out);
*(grub_uint32_t *)(outbuf + 4) = (grub_uint32_t)(s.total_out);
- return s.total_out + sizeof(gzHdr) + 8;
+ return s.total_out + sizeof(gzHdr) + 8;
}
@@ -899,7 +899,7 @@ static grub_err_t ventoy_cmd_strstr(grub_extcmd_context_t ctxt, int argc, char *
static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char **args)
{
char *c0, *c1;
-
+
(void)ctxt;
if (argc != 2)
@@ -931,7 +931,7 @@ static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char
static grub_err_t ventoy_cmd_strcasebegin(grub_extcmd_context_t ctxt, int argc, char **args)
{
char *c0, *c1;
-
+
(void)ctxt;
if (argc != 2)
@@ -964,7 +964,7 @@ static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **a
{
long value_long = 0;
char buf[32];
-
+
if ((argc != 2) || (!ventoy_is_decimal(args[1])))
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {Variable} {Int}", cmd_raw_name);
@@ -988,7 +988,7 @@ static grub_err_t ventoy_cmd_mod(grub_extcmd_context_t ctxt, int argc, char **ar
ulonglong value1 = 0;
ulonglong value2 = 0;
char buf[32];
-
+
if (argc != 3)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {Int} {Int} {Variable}", cmd_raw_name);
@@ -1008,7 +1008,7 @@ static grub_err_t ventoy_cmd_file_size(grub_extcmd_context_t ctxt, int argc, cha
int rc = 1;
char buf[32];
grub_file_t file;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -1029,16 +1029,16 @@ static grub_err_t ventoy_cmd_file_size(grub_extcmd_context_t ctxt, int argc, cha
grub_env_set(args[1], buf);
- grub_file_close(file);
+ grub_file_close(file);
rc = 0;
-
+
return rc;
}
static grub_err_t ventoy_cmd_load_wimboot(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_file_t file;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -1060,7 +1060,7 @@ static grub_err_t ventoy_cmd_load_wimboot(grub_extcmd_context_t ctxt, int argc,
{
return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Can't allocate image chunk memoty\n");
}
-
+
g_wimiso_chunk_list.max_chunk = DEFAULT_CHUNK_NUM;
g_wimiso_chunk_list.cur_chunk = 0;
@@ -1083,7 +1083,7 @@ static grub_err_t ventoy_cmd_concat_efi_iso(grub_extcmd_context_t ctxt, int argc
char *buf = NULL;
char *data = NULL;
ventoy_iso9660_override *dirent;
-
+
(void)ctxt;
if (argc != 2)
@@ -1100,7 +1100,7 @@ static grub_err_t ventoy_cmd_concat_efi_iso(grub_extcmd_context_t ctxt, int argc
}
totlen += len;
-
+
debug("efiboot template len:%d offset:%d\n", len, offset);
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "%s", args[0]);
@@ -1129,7 +1129,7 @@ static grub_err_t ventoy_cmd_concat_efi_iso(grub_extcmd_context_t ctxt, int argc
data = (char *)grub_efi_allocate_iso_buf(totlen);
#else
data = (char *)grub_malloc(totlen);
-#endif
+#endif
ventoy_fill_os_param(file, (ventoy_os_param *)data);
@@ -1137,7 +1137,7 @@ static grub_err_t ventoy_cmd_concat_efi_iso(grub_extcmd_context_t ctxt, int argc
grub_check_free(buf);
grub_file_read(file, data + sizeof(ventoy_chain_head) + len, file->size);
- grub_file_close(file);
+ grub_file_close(file);
ventoy_memfile_env_set(args[1], data, (ulonglong)totlen);
@@ -1152,7 +1152,7 @@ grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char
g_vtoy_load_prompt = 0;
grub_memset(g_vtoy_prompt_msg, 0, sizeof(g_vtoy_prompt_msg));
-
+
if (argc == 2 && args[0][0] == '1')
{
g_vtoy_load_prompt = 1;
@@ -1174,7 +1174,7 @@ grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssiz
grub_ssize_t left = size;
char *cur = (char *)buf;
- grub_printf("\r%s 1%% ", g_vtoy_prompt_msg);
+ grub_printf("\r%s 1%% ", g_vtoy_prompt_msg);
grub_refresh();
while (left >= VTOY_SIZE_2MB)
@@ -1189,7 +1189,7 @@ grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssiz
div = 1;
}
grub_printf("\r%s %d%% ", g_vtoy_prompt_msg, (int)div);
- grub_refresh();
+ grub_refresh();
}
if (left > 0)
@@ -1198,7 +1198,7 @@ grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssiz
}
grub_printf("\r%s 100%% \n", g_vtoy_prompt_msg);
- grub_refresh();
+ grub_refresh();
return size;
}
@@ -1209,7 +1209,7 @@ static grub_err_t ventoy_cmd_load_file_to_mem(grub_extcmd_context_t ctxt, int ar
char *buf = NULL;
grub_file_t file;
enum grub_file_type type;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -1239,7 +1239,7 @@ static grub_err_t ventoy_cmd_load_file_to_mem(grub_extcmd_context_t ctxt, int ar
buf = (char *)grub_efi_allocate_chain_buf(file->size);
#else
buf = (char *)grub_malloc(file->size);
-#endif
+#endif
if (!buf)
{
@@ -1258,9 +1258,9 @@ static grub_err_t ventoy_cmd_load_file_to_mem(grub_extcmd_context_t ctxt, int ar
ventoy_memfile_env_set(args[2], buf, (ulonglong)(file->size));
- grub_file_close(file);
+ grub_file_close(file);
rc = 0;
-
+
return rc;
}
@@ -1270,7 +1270,7 @@ static grub_err_t ventoy_cmd_load_img_memdisk(grub_extcmd_context_t ctxt, int ar
int headlen;
char *buf = NULL;
grub_file_t file;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -1293,7 +1293,7 @@ static grub_err_t ventoy_cmd_load_img_memdisk(grub_extcmd_context_t ctxt, int ar
buf = (char *)grub_efi_allocate_iso_buf(headlen + file->size);
#else
buf = (char *)grub_malloc(headlen + file->size);
-#endif
+#endif
ventoy_fill_os_param(file, (ventoy_os_param *)buf);
@@ -1301,9 +1301,9 @@ static grub_err_t ventoy_cmd_load_img_memdisk(grub_extcmd_context_t ctxt, int ar
ventoy_memfile_env_set(args[1], buf, (ulonglong)(file->size));
- grub_file_close(file);
+ grub_file_close(file);
rc = 0;
-
+
return rc;
}
@@ -1312,7 +1312,7 @@ static grub_err_t ventoy_cmd_iso9660_is_joliet(grub_extcmd_context_t ctxt, int a
(void)ctxt;
(void)argc;
(void)args;
-
+
if (grub_iso9660_is_joliet())
{
debug("This time has joliet process\n");
@@ -1351,7 +1351,7 @@ static grub_err_t ventoy_cmd_is_udf(grub_extcmd_context_t ctxt, int argc, char *
int rc = 1;
grub_file_t file;
grub_uint8_t buf[32];
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -1395,10 +1395,10 @@ static grub_err_t ventoy_cmd_is_udf(grub_extcmd_context_t ctxt, int argc, char *
}
}
- grub_file_close(file);
+ grub_file_close(file);
debug("ISO UDF: %s\n", rc ? "NO" : "YES");
-
+
return rc;
}
@@ -1406,7 +1406,7 @@ static grub_err_t ventoy_cmd_cmp(grub_extcmd_context_t ctxt, int argc, char **ar
{
long value_long1 = 0;
long value_long2 = 0;
-
+
if ((argc != 3) || (!ventoy_is_decimal(args[0])) || (!ventoy_is_decimal(args[2])))
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {Int1} { eq|ne|gt|lt|ge|le } {Int2}", cmd_raw_name);
@@ -1443,7 +1443,7 @@ static grub_err_t ventoy_cmd_cmp(grub_extcmd_context_t ctxt, int argc, char **ar
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {Int1} { eq ne gt lt ge le } {Int2}", cmd_raw_name);
}
-
+
return grub_errno;
}
@@ -1451,7 +1451,7 @@ static grub_err_t ventoy_cmd_device(grub_extcmd_context_t ctxt, int argc, char *
{
char *pos = NULL;
char buf[128] = {0};
-
+
if (argc != 2)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s path var", cmd_raw_name);
@@ -1465,7 +1465,7 @@ static grub_err_t ventoy_cmd_device(grub_extcmd_context_t ctxt, int argc, char *
}
grub_env_set(args[1], buf);
-
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -1478,7 +1478,7 @@ static grub_err_t ventoy_cmd_check_compatible(grub_extcmd_context_t ctxt, int ar
const char *files[] = { "ventoy.dat", "VENTOY.DAT" };
(void)ctxt;
-
+
if (argc != 1)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s (loop)", cmd_raw_name);
@@ -1498,7 +1498,7 @@ static grub_err_t ventoy_cmd_check_compatible(grub_extcmd_context_t ctxt, int ar
debug("file %s NOT exist\n", buf);
}
}
-
+
grub_snprintf(buf, sizeof(buf) - 1, "%s", args[0][0] == '(' ? (args[0] + 1) : args[0]);
pos = grub_strstr(buf, ")");
if (pos)
@@ -1511,7 +1511,7 @@ static grub_err_t ventoy_cmd_check_compatible(grub_extcmd_context_t ctxt, int ar
{
grub_disk_read(disk, 16 << 2, 0, 1024, g_img_swap_tmp_buf);
grub_disk_close(disk);
-
+
g_img_swap_tmp_buf[703] = 0;
for (i = 318; i < 703; i++)
{
@@ -1555,7 +1555,7 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
{
c1 = c1 - 'a' + 'A';
}
-
+
if (grub_islower(c2))
{
c2 = c2 - 'a' + 'A';
@@ -1599,7 +1599,7 @@ static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
{
c1 = c1 - 'a' + 'A';
}
-
+
if (grub_islower(c2))
{
c2 = c2 - 'a' + 'A';
@@ -1616,7 +1616,7 @@ static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
{
c1 = 0;
}
-
+
if (len == node2->dirlen)
{
c2 = 0;
@@ -1628,7 +1628,7 @@ static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
void ventoy_swap_img(img_info *img1, img_info *img2)
{
grub_memcpy(&g_img_swap_tmp, img1, sizeof(img_info));
-
+
grub_memcpy(img1, img2, sizeof(img_info));
img1->next = g_img_swap_tmp.next;
img1->prev = g_img_swap_tmp.prev;
@@ -1641,7 +1641,7 @@ void ventoy_swap_img(img_info *img1, img_info *img2)
int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
{
(void)namelen;
-
+
if (g_filt_dot_underscore_file && filename[0] == '.' && filename[1] == '_')
{
return 0;
@@ -1698,7 +1698,7 @@ static int ventoy_vlnk_iterate_disk(const char *name, void *data)
static int ventoy_vlnk_probe_fs(ventoy_vlnk_part *cur)
{
- const char *fs[ventoy_fs_max + 1] =
+ const char *fs[ventoy_fs_max + 1] =
{
"exfat", "ntfs", "ext2", "xfs", "udf", "fat", "btrfs", NULL
};
@@ -1725,7 +1725,7 @@ static int ventoy_check_vlnk_data(ventoy_vlnk *vlnk, int print, char *dst, int s
grub_uint32_t readcrc, calccrc;
ventoy_vlnk_part *cur;
grub_fs_t fs = NULL;
-
+
if (grub_memcmp(&(vlnk->guid), &g_ventoy_guid, sizeof(ventoy_guid)))
{
if (print)
@@ -1770,12 +1770,12 @@ static int ventoy_check_vlnk_data(ventoy_vlnk *vlnk, int print, char *dst, int s
cur->probe = 1;
ventoy_vlnk_probe_fs(cur);
}
-
+
if (!fs)
{
fs = cur->fs;
}
-
+
if (cur->fs)
{
struct grub_file file;
@@ -1813,7 +1813,7 @@ static int ventoy_check_vlnk_data(ventoy_vlnk *vlnk, int print, char *dst, int s
{
grub_printf("Disk Find: [ NO ]\n");
}
-
+
if (partfind)
{
grub_printf("Part Find: [ YES ] [ %s ] [ %s ]\n", device, fs ? fs->name : "N/A");
@@ -1827,7 +1827,7 @@ static int ventoy_check_vlnk_data(ventoy_vlnk *vlnk, int print, char *dst, int s
{
grub_printf("VLNK File: <%s>\n", dst);
}
-
+
grub_printf("\n");
grub_refresh();
}
@@ -1868,7 +1868,7 @@ int ventoy_add_vlnk_file(char *dir, const char *name)
if (ventoy_check_vlnk_data(&vlnk, 0, dst, sizeof(dst)) == 0)
{
- rc = grub_file_add_vlnk(src, dst);
+ rc = grub_file_add_vlnk(src, dst);
}
return rc;
@@ -1898,18 +1898,18 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
grub_printf("\n\n Ventoy scanning files, please wait...\n");
grub_refresh();
g_enumerate_time_checked = 1;
- }
+ }
}
len = grub_strlen(filename);
-
+
if (info->dir)
{
if (node->level + 1 > g_img_max_search_level)
{
return 0;
}
-
+
if ((len == 1 && filename[0] == '.') ||
(len == 2 && filename[0] == '.' && filename[1] == '.'))
{
@@ -1938,7 +1938,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
if (index == 0)
{
debug("Directory %s not found in image_list plugin config...\n", g_img_swap_tmp_buf);
- return 0;
+ return 0;
}
}
@@ -1993,7 +1993,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
{
type = img_type_wim;
}
- else if (FILE_FLT(VHD) && g_vhdboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".vhd") ||
+ else if (FILE_FLT(VHD) && g_vhdboot_enable && (0 == grub_strcasecmp(filename + len - 4, ".vhd") ||
(len >= 5 && 0 == grub_strcasecmp(filename + len - 5, ".vhdx"))))
{
type = img_type_vhd;
@@ -2046,12 +2046,12 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
if (VENTOY_IMG_WHITE_LIST == g_plugin_image_list && index == 0)
{
debug("File %s not found in image_list plugin config...\n", g_img_swap_tmp_buf);
- return 0;
+ return 0;
}
else if (VENTOY_IMG_BLACK_LIST == g_plugin_image_list && index > 0)
{
debug("File %s found in image_blacklist plugin config %d ...\n", g_img_swap_tmp_buf, index);
- return 0;
+ return 0;
}
}
@@ -2066,7 +2066,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
}
}
}
-
+
img = grub_zalloc(sizeof(img_info));
if (img)
{
@@ -2081,11 +2081,11 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
{
if (node->dir[0] == '/')
{
- img->size = ventoy_grub_get_file_size("%s%s%s", g_iso_path, node->dir, filename);
+ img->size = ventoy_grub_get_file_size("%s%s%s", g_iso_path, node->dir, filename);
}
else
{
- img->size = ventoy_grub_get_file_size("%s/%s%s", g_iso_path, node->dir, filename);
+ img->size = ventoy_grub_get_file_size("%s/%s%s", g_iso_path, node->dir, filename);
}
}
@@ -2095,7 +2095,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
grub_free(img);
return 0;
}
-
+
if (g_ventoy_img_list)
{
tail = *(node->tail);
@@ -2106,7 +2106,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
{
g_ventoy_img_list = img;
}
-
+
img->id = g_ventoy_img_count;
img->parent = node;
if (node && NULL == node->firstiso)
@@ -2121,7 +2121,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
tmp->isocnt++;
tmp = tmp->parent;
}
-
+
*((img_info **)(node->tail)) = img;
g_ventoy_img_count++;
@@ -2133,7 +2133,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
img->tip1 = tip->tip1;
img->tip2 = tip->tip2;
}
-
+
img->class = ventoy_plugin_get_menu_class(vtoy_class_image_file, img->name, img->path);
if (!img->class)
{
@@ -2173,7 +2173,7 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer)
ventoy_guid guid = VENTOY_GUID;
const char *fmt1 = NULL;
const char *fmt2 = NULL;
- const char *fmt3 = NULL;
+ const char *fmt3 = NULL;
grub_uint32_t *puint = (grub_uint32_t *)name;
grub_uint32_t *puint2 = (grub_uint32_t *)plat;
const char fmtdata[]={ 0x39, 0x35, 0x25, 0x00, 0x35, 0x00, 0x23, 0x30, 0x30, 0x30, 0x30, 0x66, 0x66, 0x00 };
@@ -2201,12 +2201,12 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer)
{
fmt1 = fmtdata;
}
-
+
grub_memset(name, 0, sizeof(name));
puint[1] = grub_swap_bytes32(0x5f4c4654);
puint[0] = grub_swap_bytes32(0x56544c45);
fmt2 = ventoy_get_env(name);
-
+
grub_memset(name, 0, sizeof(name));
puint[1] = grub_swap_bytes32(0x5f434c52);
puint[0] = grub_swap_bytes32(0x56544c45);
@@ -2214,15 +2214,15 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer)
grub_memcpy(guidstr, &guid, sizeof(guid));
- puint2[0] = grub_swap_bytes32(g_ventoy_plat_data);
+ puint2[0] = grub_swap_bytes32(g_ventoy_plat_data);
/* Easter egg :) It will be appreciated if you reserve it, but NOT mandatory. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
- len = grub_snprintf(buffer, buflen, fmtcode,
- fmt1 ? fmt1 : fmtdata,
- fmt2 ? fmt2 : fmtdata + 4,
- value ? value : "", plat, guidstr,
+ len = grub_snprintf(buffer, buflen, fmtcode,
+ fmt1 ? fmt1 : fmtdata,
+ fmt2 ? fmt2 : fmtdata + 4,
+ value ? value : "", plat, guidstr,
fmt3 ? fmt3 : fmtdata + 6);
#pragma GCC diagnostic pop
@@ -2244,7 +2244,7 @@ ventoy_password_get (char buf[], unsigned buf_size)
while (1)
{
- key = grub_getkey ();
+ key = grub_getkey ();
if (key == '\n' || key == '\r')
break;
@@ -2315,7 +2315,7 @@ int ventoy_check_password(const vtoy_password *pwd, int retry)
grub_printf("Enter password: ");
grub_refresh();
-
+
if (pwd->type == VTOY_PASSWORD_TXT)
{
ventoy_get_password(input, 128);
@@ -2337,14 +2337,14 @@ int ventoy_check_password(const vtoy_password *pwd, int retry)
{
offset = (int)grub_snprintf(input, 128, "%s", pwd->salt);
ventoy_get_password(input + offset, 128);
-
+
grub_crypto_hash(GRUB_MD_MD5, md5, input, grub_strlen(input));
if (grub_memcmp(pwd->md5, md5, 16) == 0)
{
return 0;
}
}
-
+
grub_printf("Invalid password!\n\n");
grub_refresh();
}
@@ -2404,7 +2404,7 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
const char *dir_alias = NULL;
img_iterator_node *child = NULL;
const menu_tip *tip = NULL;
-
+
if (node->isocnt == 0 || node->done == 1)
{
return 0;
@@ -2421,14 +2421,14 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
{
if (g_tree_view_menu_style == 0)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%-10s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", "<--", ventoy_get_vmenu_title("VTLANG_RET_TO_LISTVIEW"));
}
else
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"[%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", ventoy_get_vmenu_title("VTLANG_RET_TO_LISTVIEW"));
@@ -2453,14 +2453,14 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
{
if (g_tree_view_menu_style == 0)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "submenu \"%-10s %s\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"%-10s %s\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
"DIR", dir_alias, dir_class, node->dir + offset, tip);
}
else
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "submenu \"%s\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"%s\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
dir_alias, dir_class, node->dir + offset, tip);
}
}
@@ -2470,28 +2470,28 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
if (g_tree_view_menu_style == 0)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "submenu \"%-10s [%s]\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"%-10s [%s]\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
"DIR", dir_alias, dir_class, node->dir + offset, tip);
}
else
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "submenu \"[%s]\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"[%s]\" --class=\"%s\" --id=\"DIR_%s\" _VTIP_%p {\n",
dir_alias, dir_class, node->dir + offset, tip);
}
}
if (g_tree_view_menu_style == 0)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%-10s [%s/..]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", "<--", node->dir);
}
else
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"[%s/..]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", node->dir);
@@ -2507,23 +2507,23 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
{
if (g_tree_view_menu_style == 0)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%-10s %s%s\" --class=\"%s\" --id=\"VID_%p\" {\n"
- " %s_%s \n"
- "}\n",
- grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT),
- img->unsupport ? "[***********] " : "",
+ " %s_%s \n"
+ "}\n",
+ grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT),
+ img->unsupport ? "[***********] " : "",
img->alias ? img->alias : img->name, img->class, img,
img->menu_prefix,
img->unsupport ? "unsupport_menuentry" : "common_menuentry");
}
else
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%p\" {\n"
- " %s_%s \n"
- "}\n",
- img->unsupport ? "[***********] " : "",
+ " %s_%s \n"
+ "}\n",
+ img->unsupport ? "[***********] " : "",
img->alias ? img->alias : img->name, img->class, img,
img->menu_prefix,
img->unsupport ? "unsupport_menuentry" : "common_menuentry");
@@ -2536,7 +2536,7 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
}
node->done = 1;
- return 0;
+ return 0;
}
static int ventoy_set_default_menu(void)
@@ -2550,7 +2550,7 @@ static int ventoy_set_default_menu(void)
img_info *default_node = NULL;
const char *default_image = NULL;
- default_image = ventoy_get_env("VTOY_DEFAULT_IMAGE");
+ default_image = ventoy_get_env("VTOY_DEFAULT_IMAGE");
if (default_image && default_image[0] == '/')
{
img_len = grub_strlen(default_image);
@@ -2599,7 +2599,7 @@ static int ventoy_set_default_menu(void)
while ((end = grub_strchr(pos, '/')) != NULL)
{
- *end = 0;
+ *end = 0;
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "DIR_%s>", pos);
pos = end + 1;
}
@@ -2627,10 +2627,10 @@ static grub_err_t ventoy_cmd_clear_img(grub_extcmd_context_t ctxt, int argc, cha
grub_free(cur);
cur = next;
}
-
+
g_ventoy_img_list = NULL;
g_ventoy_img_count = 0;
-
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -2640,7 +2640,7 @@ static grub_err_t ventoy_cmd_img_name(grub_extcmd_context_t ctxt, int argc, char
img_info *cur = g_ventoy_img_list;
(void)ctxt;
-
+
if (argc != 2 || (!ventoy_is_decimal(args[0])))
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {imageID} {var}", cmd_raw_name);
@@ -2668,7 +2668,7 @@ static grub_err_t ventoy_cmd_img_name(grub_extcmd_context_t ctxt, int argc, char
debug("image name is %s\n", cur->name);
grub_env_set(args[1], cur->name);
-
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -2679,7 +2679,7 @@ static grub_err_t ventoy_cmd_ext_select_img_path(grub_extcmd_context_t ctxt, int
img_info *cur = g_ventoy_img_list;
(void)ctxt;
-
+
if (argc != 1)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
@@ -2737,7 +2737,7 @@ static grub_err_t ventoy_cmd_reset_fake_vlnk(grub_extcmd_context_t ctxt, int arg
g_fake_vlnk_dst[0] = 0;
g_fake_vlnk_size = 0;
grub_file_vtoy_vlnk(NULL, NULL);
-
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -2751,7 +2751,7 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
img_info *cur = NULL;
(void)ctxt;
-
+
if (argc < 1 || argc > 3)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
@@ -2764,9 +2764,9 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
if (argc > 1)
{
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(g_fake_vlnk_size));
- grub_env_set(args[1], value);
+ grub_env_set(args[1], value);
}
-
+
if (argc > 2)
{
for (last = pos; *pos; pos++)
@@ -2804,9 +2804,9 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
if (argc > 1)
{
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(cur->size));
- grub_env_set(args[1], value);
+ grub_env_set(args[1], value);
}
-
+
if (argc > 2)
{
grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(cur->size));
@@ -2857,7 +2857,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
{
g_filt_dot_underscore_file = 1;
}
-
+
strdata = ventoy_get_env("VTOY_FILT_TRASH_DIR");
if (strdata && strdata[0] == '0' && strdata[1] == 0)
{
@@ -2879,7 +2879,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
g_enum_dev = dev = grub_device_open(device_name);
if (!dev)
{
- goto fail;
+ goto fail;
}
g_enum_fs = fs = grub_fs_probe(dev);
@@ -2920,7 +2920,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
else
{
g_img_iterator_head.dirlen = 1;
- grub_strcpy(g_img_iterator_head.dir, "/");
+ grub_strcpy(g_img_iterator_head.dir, "/");
}
g_img_iterator_head.tail = &tail;
@@ -2944,7 +2944,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
for (node = &g_img_iterator_head; node; node = node->next)
{
- fs->fs_dir(dev, node->dir, ventoy_collect_img_files, node);
+ fs->fs_dir(dev, node->dir, ventoy_collect_img_files, node);
}
strdata = ventoy_get_env("VTOY_TREE_VIEW_MENU_STYLE");
@@ -2961,14 +2961,14 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
}
/* free node */
- node = g_img_iterator_head.next;
+ node = g_img_iterator_head.next;
while (node)
{
tmp = node->next;
grub_free(node);
node = tmp;
}
-
+
/* sort image list by image name */
while (g_ventoy_img_list)
{
@@ -2983,9 +2983,9 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
if (min->prev)
{
- min->prev->next = min->next;
+ min->prev->next = min->next;
}
-
+
if (min->next)
{
min->next->prev = min->prev;
@@ -3015,7 +3015,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
if (g_default_menu_mode == 1)
{
- vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
+ vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
"menuentry \"%s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", "<--", ventoy_get_vmenu_title("VTLANG_RET_TO_TREEVIEW"));
@@ -3025,9 +3025,9 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
{
vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
"menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%p\" {\n"
- " %s_%s \n"
- "}\n",
- cur->unsupport ? "[***********] " : "",
+ " %s_%s \n"
+ "}\n",
+ cur->unsupport ? "[***********] " : "",
cur->alias ? cur->alias : cur->name, cur->class, cur,
cur->menu_prefix,
cur->unsupport ? "unsupport_menuentry" : "common_menuentry");
@@ -3053,7 +3053,7 @@ int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t
char *device_name;
char *pos;
char *pos2;
-
+
device_name = grub_file_get_device_name(filename);
if (!device_name)
{
@@ -3071,7 +3071,7 @@ int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t
{
pos2 = grub_strstr(pos, ")");
}
-
+
if (pos2)
{
*pos2 = 0;
@@ -3112,7 +3112,7 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file)
return 0;
}
- return desc.sector;
+ return desc.sector;
}
static grub_uint32_t ventoy_get_bios_eltorito_rba(grub_file_t file, grub_uint32_t sector)
@@ -3122,7 +3122,7 @@ static grub_uint32_t ventoy_get_bios_eltorito_rba(grub_file_t file, grub_uint32_
grub_file_seek(file, sector * 2048);
grub_file_read(file, buf, sizeof(buf));
- if (buf[0] == 0x01 && buf[1] == 0x00 &&
+ if (buf[0] == 0x01 && buf[1] == 0x00 &&
buf[30] == 0x55 && buf[31] == 0xaa && buf[32] == 0x88)
{
return *((grub_uint32_t *)(buf + 40));
@@ -3207,14 +3207,14 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
}
grub_snprintf(param->vtoy_img_path, sizeof(param->vtoy_img_path), "%s", pos);
-
+
ventoy_get_disk_guid(file->name, param->vtoy_disk_guid, param->vtoy_disk_signature);
param->vtoy_img_size = file->size;
param->vtoy_reserved[0] = g_ventoy_break_level;
param->vtoy_reserved[1] = g_ventoy_debug_level;
-
+
param->vtoy_reserved[2] = g_ventoy_chain_type;
/* Windows CD/DVD prompt 0:suppress 1:reserved */
@@ -3227,7 +3227,7 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
param->vtoy_reserved[4] = 1;
}
}
-
+
fs = ventoy_get_env("ventoy_fs_probe");
if (fs && grub_strcmp(fs, "udf") == 0)
{
@@ -3245,6 +3245,18 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
param->vtoy_reserved[6] = file->vlnk;
grub_memcpy(param->vtoy_reserved + 7, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
+
+ /* Windows UEFI force highest resolution */
+ if (g_ventoy_chain_type == 1) /* Windows */
+ {
+ val = ventoy_get_env("VTOY_WIN_UEFI_MAX_RES");
+ if (val && val[0] == '1' && val[1] == 0)
+ {
+ param->vtoy_reserved[11] = 1;
+ }
+ }
+
+
/* calculate checksum */
for (i = 0; i < sizeof(ventoy_os_param); i++)
{
@@ -3255,7 +3267,7 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
return;
}
-static const char* g_chunk_err_msg[VTOY_CHUNK_ERR_MAX] =
+static const char* g_chunk_err_msg[VTOY_CHUNK_ERR_MAX] =
{
"success",
"File system use more than 1 disks! (maybe RAID)",
@@ -3271,11 +3283,11 @@ static const char * ventoy_get_chunk_err_msg(grub_uint32_t err)
{
return g_chunk_err_msg[err];
}
-
+
return "XXXX";
}
-int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist,
+int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist,
grub_disk_addr_t start, char *err, grub_uint32_t len)
{
grub_uint32_t i = 0;
@@ -3289,7 +3301,7 @@ grub_disk_addr_t start, char *err, grub_uint32_t len)
{
grub_snprintf(err, len, "%s", ventoy_get_chunk_err_msg(chunklist->err_code));
}
-
+
return 1;
}
@@ -3301,7 +3313,7 @@ grub_disk_addr_t start, char *err, grub_uint32_t len)
for (i = 0; i < chunklist->cur_chunk; i++)
{
chunk = chunklist->chunk + i;
-
+
if (chunk->disk_start_sector <= start)
{
debug("%u disk start invalid %lu\n", i, (ulong)start);
@@ -3321,7 +3333,7 @@ grub_disk_addr_t start, char *err, grub_uint32_t len)
debug("maybe img file to be processed.\n");
return 0;
}
-
+
return 1;
}
@@ -3341,15 +3353,15 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
fs_type = ventoy_get_fs_type(file->fs->name);
if (fs_type == ventoy_fs_exfat)
{
- grub_fat_get_file_chunk(start, file, chunklist);
+ grub_fat_get_file_chunk(start, file, chunklist);
}
else if (fs_type == ventoy_fs_ext)
{
- grub_ext_get_file_chunk(start, file, chunklist);
+ grub_ext_get_file_chunk(start, file, chunklist);
}
else if (fs_type == ventoy_fs_btrfs)
{
- grub_btrfs_get_file_chunk(start, file, chunklist);
+ grub_btrfs_get_file_chunk(start, file, chunklist);
}
else
{
@@ -3397,7 +3409,7 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
{
count >>= 2;
}
-
+
chunklist->chunk[i].img_start_sector = sector;
chunklist->chunk[i].img_end_sector = sector + count - 1;
sector += count;
@@ -3414,20 +3426,20 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
grub_file_t file;
grub_disk_addr_t start;
char errmsg[128];
-
+
(void)ctxt;
(void)argc;
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
if (!file)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't open file %s\n", args[0]);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't open file %s\n", args[0]);
}
g_conf_replace_count = 0;
grub_memset(g_conf_replace_node, 0, sizeof(g_conf_replace_node ));
grub_memset(g_conf_replace_offset, 0, sizeof(g_conf_replace_offset ));
-
+
if (g_img_chunk_list.chunk)
{
grub_free(g_img_chunk_list.chunk);
@@ -3437,9 +3449,9 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
if (fs_type >= ventoy_fs_max)
{
grub_file_close(file);
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Unsupported filesystem %s\n", file->fs->name);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Unsupported filesystem %s\n", file->fs->name);
}
-
+
/* get image chunk data */
grub_memset(&g_img_chunk_list, 0, sizeof(g_img_chunk_list));
g_img_chunk_list.chunk = grub_malloc(sizeof(ventoy_img_chunk) * DEFAULT_CHUNK_NUM);
@@ -3447,7 +3459,7 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
{
return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Can't allocate image chunk memoty\n");
}
-
+
g_img_chunk_list.max_chunk = DEFAULT_CHUNK_NUM;
g_img_chunk_list.cur_chunk = 0;
@@ -3463,7 +3475,7 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
if (fs_type == ventoy_fs_btrfs)
{
vtoy_tip(10, "%s\n\nWill exit in 10 seconds...\n", errmsg);
- grub_exit();
+ grub_exit();
}
return grub_error(GRUB_ERR_NOT_IMPLEMENTED_YET, "%s\n", errmsg);
}
@@ -3483,7 +3495,7 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
conf_replace *node = NULL;
conf_replace *nodes[VTOY_MAX_CONF_REPLACE] = { NULL };
ventoy_grub_param_file_replace *replace = NULL;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -3513,7 +3525,7 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
if (file)
{
offset = grub_iso9660_get_last_file_dirent_pos(file);
- grub_file_close(file);
+ grub_file_close(file);
}
else if (node->img > 0)
{
@@ -3605,7 +3617,7 @@ static int ventoy_var_expand(int *record, int *flag, const char *var, char *expa
*flag = 1;
grub_printf("\n=================== Variables Expansion ===================\n\n");
}
-
+
grub_printf("<%s>: ", var);
grub_refresh();
@@ -3619,7 +3631,7 @@ static int ventoy_var_expand(int *record, int *flag, const char *var, char *expa
grub_printf("\n");
grub_refresh();
*record = 1;
- break;
+ break;
}
}
else if (grub_isprint(c))
@@ -3641,7 +3653,7 @@ static int ventoy_var_expand(int *record, int *flag, const char *var, char *expa
expand[i - 1] = 0;
grub_printf("\r<%s>: %s", var, expand);
-
+
grub_refresh();
i--;
}
@@ -3654,7 +3666,7 @@ end:
{
grub_snprintf(expand, len, "$$%s$$", var);
}
-
+
return 0;
}
@@ -3681,7 +3693,7 @@ static int ventoy_auto_install_var_expand(install_template *node)
debug("auto install script too long %d\n", node->filelen);
return 0;
}
-
+
if ((code[0] == 0xff && code[1] == 0xfe) || (code[0] == 0xfe && code[1] == 0xff))
{
debug("UCS-2 encoding NOT supported\n");
@@ -3751,9 +3763,9 @@ static int ventoy_auto_install_var_expand(install_template *node)
}
}
}
-
+
VTOY_APPEND_NEWBUF(value);
-
+
VTOY_APPEND_NEWBUF(end + 2);
}
else
@@ -3794,7 +3806,7 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
grub_file_t file = NULL;
char configfile[128];
install_template *node = NULL;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -3832,9 +3844,9 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
if (node->timeout > 0)
{
- vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
+ vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
}
-
+
vtoy_ssprintf(buf, pos, "menuentry \"$VTLANG_NO_AUTOINS_SCRIPT\" --class=\"sel_auto_install\" {\n"
" echo %s\n}\n", "");
@@ -3850,10 +3862,10 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
g_ventoy_suppress_esc = 1;
g_ventoy_suppress_esc_default = defidx;
g_ventoy_secondary_menu_on = 1;
-
+
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;
@@ -3869,7 +3881,7 @@ load:
if (node->cursel >= 0 && node->cursel < node->templatenum)
{
- file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", ventoy_get_env("vtoy_iso_part"),
+ file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", ventoy_get_env("vtoy_iso_part"),
node->templatepath[node->cursel].path);
if (file)
{
@@ -3878,7 +3890,7 @@ load:
{
grub_file_read(file, node->filebuf, file->size);
grub_file_close(file);
-
+
grub_memset(node->filebuf + file->size, 0, 8);
node->filelen = (int)file->size;
@@ -3887,7 +3899,7 @@ load:
}
else
{
- debug("Failed to open auto install script <%s%s>\n",
+ debug("Failed to open auto install script <%s%s>\n",
ventoy_get_env("vtoy_iso_part"), node->templatepath[node->cursel].path);
}
}
@@ -3903,7 +3915,7 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
char *buf = NULL;
char configfile[128];
persistence_config *node;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -3929,7 +3941,7 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
{
node->cursel = node->autosel - 1;
debug("Persistence image auto select %d\n", node->autosel);
- return 0;
+ return 0;
}
}
@@ -3941,19 +3953,19 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
if (node->timeout > 0)
{
- vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
+ vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
}
vtoy_ssprintf(buf, pos, "menuentry \"$VTLANG_NO_PERSIST\" --class=\"sel_persistence\" {\n"
" echo %s\n}\n", "");
-
+
for (i = 0; i < node->backendnum; i++)
{
vtoy_ssprintf(buf, pos, "menuentry \"%s %s\" --class=\"sel_persistence\" {\n"
" echo \"\"\n}\n",
ventoy_get_vmenu_title("VTLANG_PERSIST_USE"),
node->backendpath[i].path);
-
+
}
g_ventoy_menu_esc = 1;
@@ -3963,7 +3975,7 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
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;
@@ -3980,7 +3992,7 @@ static grub_err_t ventoy_cmd_dump_img_sector(grub_extcmd_context_t ctxt, int arg
{
grub_uint32_t i;
ventoy_img_chunk *cur;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -3988,7 +4000,7 @@ static grub_err_t ventoy_cmd_dump_img_sector(grub_extcmd_context_t ctxt, int arg
for (i = 0; i < g_img_chunk_list.cur_chunk; i++)
{
cur = g_img_chunk_list.chunk + i;
- grub_printf("image:[%u - %u] <==> disk:[%llu - %llu]\n",
+ grub_printf("image:[%u - %u] <==> disk:[%llu - %llu]\n",
cur->img_start_sector, cur->img_end_sector,
(unsigned long long)cur->disk_start_sector, (unsigned long long)cur->disk_end_sector
);
@@ -4003,14 +4015,14 @@ static grub_err_t ventoy_cmd_test_block_list(grub_extcmd_context_t ctxt, int arg
grub_file_t file;
ventoy_img_chunk_list chunklist;
char errmsg[128];
-
+
(void)ctxt;
(void)argc;
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
if (!file)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't open file %s\n", args[0]);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't open file %s\n", args[0]);
}
/* get image chunk data */
@@ -4020,12 +4032,12 @@ static grub_err_t ventoy_cmd_test_block_list(grub_extcmd_context_t ctxt, int arg
{
return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Can't allocate image chunk memoty\n");
}
-
+
chunklist.max_chunk = DEFAULT_CHUNK_NUM;
chunklist.cur_chunk = 0;
ventoy_get_block_list(file, &chunklist, 0);
-
+
if (0 != ventoy_check_block_list(file, &chunklist, 0, errmsg, sizeof(errmsg)))
{
grub_printf("%s\n", errmsg);
@@ -4044,7 +4056,7 @@ static grub_err_t ventoy_cmd_test_block_list(grub_extcmd_context_t ctxt, int arg
for (i = 0; i < chunklist.cur_chunk; i++)
{
- grub_printf("%2u: [%llu %llu] - [%llu %llu]\n", i,
+ grub_printf("%2u: [%llu %llu] - [%llu %llu]\n", i,
(ulonglong)chunklist.chunk[i].img_start_sector,
(ulonglong)chunklist.chunk[i].img_end_sector,
(ulonglong)chunklist.chunk[i].disk_start_sector,
@@ -4062,7 +4074,7 @@ static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int ar
{
int i;
ventoy_grub_param_file_replace *replace = NULL;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -4071,14 +4083,14 @@ static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int ar
{
replace = &(g_grub_param->file_replace);
replace->magic = GRUB_FILE_REPLACE_MAGIC;
-
+
replace->old_name_cnt = 0;
for (i = 0; i < 4 && i + 1 < argc; i++)
{
replace->old_name_cnt++;
grub_snprintf(replace->old_file_name[i], sizeof(replace->old_file_name[i]), "%s", args[i + 1]);
}
-
+
replace->new_file_virtual_id = (grub_uint32_t)grub_strtoul(args[0], NULL, 10);
}
@@ -4089,13 +4101,13 @@ static grub_err_t ventoy_cmd_get_replace_file_cnt(grub_extcmd_context_t ctxt, in
{
char buf[32];
ventoy_grub_param_file_replace *replace = &(g_grub_param->file_replace);
-
+
(void)ctxt;
if (argc >= 1)
{
grub_snprintf(buf, sizeof(buf), "%u", replace->old_name_cnt);
- grub_env_set(args[0], buf);
+ grub_env_set(args[0], buf);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
@@ -4115,7 +4127,7 @@ static grub_err_t ventoy_cmd_dump_menu(grub_extcmd_context_t ctxt, int argc, cha
else
{
grub_printf("Tree Mode: CurLen:%d MaxLen:%u\n", g_tree_script_pos, VTOY_MAX_SCRIPT_BUF);
- grub_printf("%s", g_tree_script_buf);
+ grub_printf("%s", g_tree_script_buf);
}
return 0;
@@ -4124,7 +4136,7 @@ static grub_err_t ventoy_cmd_dump_menu(grub_extcmd_context_t ctxt, int argc, cha
static grub_err_t ventoy_cmd_dump_img_list(grub_extcmd_context_t ctxt, int argc, char **args)
{
img_info *cur = g_ventoy_img_list;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -4177,7 +4189,7 @@ static int ventoy_check_mode_by_name(char *filename, const char *suffix)
int i;
int len1;
int len2;
-
+
len1 = (int)grub_strlen(filename);
len2 = (int)grub_strlen(suffix);
@@ -4208,7 +4220,7 @@ static int ventoy_check_mode_by_name(char *filename, const char *suffix)
{
return 1;
}
-
+
return 0;
}
@@ -4251,7 +4263,7 @@ static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, ch
{
return 0;
}
-
+
if (argc == 2 && ventoy_check_mode_by_name(args[1], "vtgrub2"))
{
return 0;
@@ -4265,7 +4277,7 @@ static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, ch
{
return 0;
}
-
+
if (argc == 2 && ventoy_check_mode_by_name(args[1], "vtwimboot"))
{
return 0;
@@ -4281,12 +4293,12 @@ static grub_err_t ventoy_cmd_dynamic_menu(grub_extcmd_context_t ctxt, int argc,
{
static int configfile_mode = 0;
char memfile[128] = {0};
-
+
(void)ctxt;
(void)argc;
(void)args;
- /*
+ /*
* args[0]: 0:normal 1:configfile
* args[1]: 0:list_buf 1:tree_buf
*/
@@ -4303,11 +4315,11 @@ static grub_err_t ventoy_cmd_dynamic_menu(grub_extcmd_context_t ctxt, int argc,
{
if (args[1][0] == '0')
{
- grub_script_execute_sourcecode(g_list_script_buf);
+ grub_script_execute_sourcecode(g_list_script_buf);
}
else
{
- grub_script_execute_sourcecode(g_tree_script_buf);
+ grub_script_execute_sourcecode(g_tree_script_buf);
}
}
else
@@ -4320,21 +4332,21 @@ static grub_err_t ventoy_cmd_dynamic_menu(grub_extcmd_context_t ctxt, int argc,
if (args[1][0] == '0')
{
- grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
+ grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
(ulonglong)(ulong)g_list_script_buf, g_list_script_pos);
}
else
{
g_ventoy_last_entry = -1;
- grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
- (ulonglong)(ulong)g_tree_script_buf, g_tree_script_pos);
+ grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
+ (ulonglong)(ulong)g_tree_script_buf, g_tree_script_pos);
}
configfile_mode = 1;
grub_script_execute_sourcecode(memfile);
configfile_mode = 0;
}
-
+
return 0;
}
@@ -4348,7 +4360,7 @@ static grub_err_t ventoy_cmd_file_exist_nocase(grub_extcmd_context_t ctxt, int a
{
return 1;
}
-
+
g_ventoy_case_insensitive = 1;
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
g_ventoy_case_insensitive = 0;
@@ -4371,13 +4383,13 @@ static grub_err_t ventoy_cmd_find_bootable_hdd(grub_extcmd_context_t ctxt, int a
const char *isopath = NULL;
char hdname[32];
ventoy_mbr_head mbr;
-
+
(void)ctxt;
(void)argc;
if (argc != 1)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s variable\n", cmd_raw_name);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s variable\n", cmd_raw_name);
}
isopath = grub_env_get("vtoy_iso_part");
@@ -4399,7 +4411,7 @@ static grub_err_t ventoy_cmd_find_bootable_hdd(grub_extcmd_context_t ctxt, int a
}
grub_snprintf(hdname, sizeof(hdname), "hd%d", id);
-
+
disk = grub_disk_open(hdname);
if (!disk)
{
@@ -4415,7 +4427,7 @@ static grub_err_t ventoy_cmd_find_bootable_hdd(grub_extcmd_context_t ctxt, int a
if (mbr.PartTbl[0].Active == 0x80 || mbr.PartTbl[1].Active == 0x80 ||
mbr.PartTbl[2].Active == 0x80 || mbr.PartTbl[3].Active == 0x80)
{
-
+
grub_env_set(args[0], hdname);
find = 1;
}
@@ -4438,13 +4450,13 @@ static grub_err_t ventoy_cmd_read_1st_line(grub_extcmd_context_t ctxt, int argc,
int len = 1024;
grub_file_t file;
char *buf = NULL;
-
+
(void)ctxt;
(void)argc;
if (argc != 2)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s file var \n", cmd_raw_name);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s file var \n", cmd_raw_name);
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
@@ -4470,7 +4482,7 @@ end:
grub_check_free(buf);
grub_file_close(file);
-
+
return 0;
}
@@ -4478,7 +4490,7 @@ static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_par
{
grub_uint64_t end_max = 0;
int *pCnt = (int *)data;
-
+
(void)disk;
(*pCnt)++;
@@ -4491,7 +4503,7 @@ static int ventoy_img_partition_callback (struct grub_disk *disk, const grub_par
{
g_part_end_max = end_max;
}
-
+
return 0;
}
@@ -4501,7 +4513,7 @@ static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc,
char *device_name = NULL;
grub_device_t dev = NULL;
char buf[64];
-
+
(void)ctxt;
g_part_list_pos = 0;
@@ -4524,7 +4536,7 @@ static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc,
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
- goto end;
+ goto end;
}
grub_partition_iterate(dev->disk, ventoy_img_partition_callback, &cnt);
@@ -4534,7 +4546,7 @@ static grub_err_t ventoy_cmd_img_part_info(grub_extcmd_context_t ctxt, int argc,
grub_snprintf(buf, sizeof(buf), "%d", cnt);
grub_env_set("vtoy_img_part_cnt", buf);
-
+
grub_snprintf(buf, sizeof(buf), "%llu", (ulonglong)g_part_end_max);
grub_env_set("vtoy_img_max_part_end", buf);
@@ -4542,7 +4554,7 @@ end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
-
+
return 0;
}
@@ -4552,13 +4564,13 @@ static grub_err_t ventoy_cmd_file_strstr(grub_extcmd_context_t ctxt, int argc, c
int rc = 1;
grub_file_t file;
char *buf = NULL;
-
+
(void)ctxt;
(void)argc;
if (argc != 2)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s file str \n", cmd_raw_name);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s file str \n", cmd_raw_name);
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
@@ -4586,7 +4598,7 @@ end:
grub_check_free(buf);
grub_file_close(file);
-
+
return rc;
}
@@ -4597,13 +4609,13 @@ static grub_err_t ventoy_cmd_parse_volume(grub_extcmd_context_t ctxt, int argc,
char buf[64];
grub_uint64_t size;
ventoy_iso9660_vd pvd;
-
+
(void)ctxt;
(void)argc;
if (argc != 4)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s sysid volid space \n", cmd_raw_name);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s sysid volid space \n", cmd_raw_name);
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
@@ -4633,10 +4645,10 @@ static grub_err_t ventoy_cmd_parse_volume(grub_extcmd_context_t ctxt, int argc,
size *= 2048;
grub_snprintf(buf, sizeof(buf), "%llu", (ulonglong)size);
ventoy_set_env(args[3], buf);
-
+
end:
grub_file_close(file);
-
+
return 0;
}
@@ -4645,13 +4657,13 @@ static grub_err_t ventoy_cmd_parse_create_date(grub_extcmd_context_t ctxt, int a
int len;
grub_file_t file;
char buf[64];
-
+
(void)ctxt;
(void)argc;
if (argc != 2)
{
- return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s var \n", cmd_raw_name);
+ return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s var \n", cmd_raw_name);
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
@@ -4674,7 +4686,7 @@ static grub_err_t ventoy_cmd_parse_create_date(grub_extcmd_context_t ctxt, int a
end:
grub_file_close(file);
-
+
return 0;
}
@@ -4685,7 +4697,7 @@ static grub_err_t ventoy_cmd_img_hook_root(grub_extcmd_context_t ctxt, int argc,
(void)args;
ventoy_env_hook_root(1);
-
+
return 0;
}
@@ -4696,7 +4708,7 @@ static grub_err_t ventoy_cmd_img_unhook_root(grub_extcmd_context_t ctxt, int arg
(void)args;
ventoy_env_hook_root(0);
-
+
return 0;
}
@@ -4717,7 +4729,7 @@ static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, in
{
return 0;
}
-
+
return ret;
}
#else
@@ -4739,7 +4751,7 @@ static grub_err_t ventoy_cmd_img_check_range(grub_extcmd_context_t ctxt, int arg
ventoy_gpt_info *gpt = NULL;
ventoy_part_table *pt = NULL;
grub_uint8_t zeroguid[16] = {0};
-
+
(void)ctxt;
(void)argc;
@@ -4775,7 +4787,7 @@ static grub_err_t ventoy_cmd_img_check_range(grub_extcmd_context_t ctxt, int arg
{
if (FileSectors < gpt->PartTbl[i].LastLBA)
{
- debug("out of range: part[%d] LastLBA:%llu FileSectors:%llu\n", i,
+ debug("out of range: part[%d] LastLBA:%llu FileSectors:%llu\n", i,
(ulonglong)gpt->PartTbl[i].LastLBA, (ulonglong)FileSectors);
goto out;
}
@@ -4791,16 +4803,16 @@ static grub_err_t ventoy_cmd_img_check_range(grub_extcmd_context_t ctxt, int arg
pt = gpt->MBR.PartTbl + i;
if (FileSectors < pt->StartSectorId + pt->SectorCount)
{
- debug("out of range: part[%d] LastLBA:%llu FileSectors:%llu\n", i,
- (ulonglong)(pt->StartSectorId + pt->SectorCount),
+ debug("out of range: part[%d] LastLBA:%llu FileSectors:%llu\n", i,
+ (ulonglong)(pt->StartSectorId + pt->SectorCount),
(ulonglong)FileSectors);
goto out;
}
}
}
-
+
ret = 0;
-
+
out:
grub_file_close(file);
grub_check_free(gpt);
@@ -4812,7 +4824,7 @@ static grub_err_t ventoy_cmd_clear_key(grub_extcmd_context_t ctxt, int argc, cha
{
int i;
int ret;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -4833,7 +4845,7 @@ static grub_err_t ventoy_cmd_clear_key(grub_extcmd_context_t ctxt, int argc, cha
grub_refresh();
grub_sleep(5);
}
-
+
return 0;
}
@@ -4852,9 +4864,9 @@ static grub_err_t ventoy_cmd_acpi_param(grub_extcmd_context_t ctxt, int argc, ch
ventoy_image_location *location;
ventoy_image_disk_region *region;
struct grub_acpi_table_header *acpi;
-
+
(void)ctxt;
-
+
if (argc != 2)
{
return 1;
@@ -4880,14 +4892,14 @@ static grub_err_t ventoy_cmd_acpi_param(grub_extcmd_context_t ctxt, int argc, ch
loclen = sizeof(ventoy_image_location) + (img_chunk_num - 1) * sizeof(ventoy_image_disk_region);
datalen = sizeof(ventoy_os_param) + loclen;
-
+
buflen = sizeof(struct grub_acpi_table_header) + datalen;
acpi = grub_zalloc(buflen);
if (!acpi)
{
return 1;
}
-
+
/* Step1: Fill acpi table header */
grub_memcpy(acpi->signature, "VTOY", 4);
acpi->length = buflen;
@@ -4931,7 +4943,7 @@ static grub_err_t ventoy_cmd_acpi_param(grub_extcmd_context_t ctxt, int argc, ch
{
region->image_sector_count = chunk->img_end_sector - chunk->img_start_sector + 1;
region->image_start_sector = chunk->img_start_sector;
- region->disk_start_sector = chunk->disk_start_sector;
+ region->disk_start_sector = chunk->disk_start_sector;
region++;
chunk++;
}
@@ -4946,7 +4958,7 @@ static grub_err_t ventoy_cmd_acpi_param(grub_extcmd_context_t ctxt, int argc, ch
grub_script_execute_sourcecode(cmd);
grub_free(acpi);
-
+
VENTOY_CMD_RETURN(0);
}
@@ -4958,7 +4970,7 @@ static grub_err_t ventoy_cmd_push_last_entry(grub_extcmd_context_t ctxt, int arg
g_ventoy_last_entry_back = g_ventoy_last_entry;
g_ventoy_last_entry = -1;
-
+
return 0;
}
@@ -4969,7 +4981,7 @@ static grub_err_t ventoy_cmd_pop_last_entry(grub_extcmd_context_t ctxt, int argc
(void)args;
g_ventoy_last_entry = g_ventoy_last_entry_back;
-
+
return 0;
}
@@ -5003,7 +5015,7 @@ static grub_err_t ventoy_cmd_lib_module_ver(grub_extcmd_context_t ctxt, int argc
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
char buf[128] = {0};
-
+
(void)ctxt;
if (argc != 3)
@@ -5025,7 +5037,7 @@ static grub_err_t ventoy_cmd_lib_module_ver(grub_extcmd_context_t ctxt, int argc
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
- goto end;
+ goto end;
}
fs = grub_fs_probe(dev);
@@ -5039,16 +5051,16 @@ static grub_err_t ventoy_cmd_lib_module_ver(grub_extcmd_context_t ctxt, int argc
if (buf[0])
{
- ventoy_set_env(args[2], buf);
+ ventoy_set_env(args[2], buf);
}
-
+
rc = 0;
-
+
end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
-
+
return rc;
}
@@ -5058,7 +5070,7 @@ int ventoy_load_part_table(const char *diskname)
int ret;
grub_disk_t disk;
grub_device_t dev;
-
+
g_ventoy_part_info = grub_zalloc(sizeof(ventoy_gpt_info));
if (!g_ventoy_part_info)
{
@@ -5136,7 +5148,7 @@ static void ventoy_prompt_end(void)
grub_reboot();
}
else if (op == 3)
- {
+ {
grub_script_execute_sourcecode("halt");
}
}
@@ -5157,7 +5169,7 @@ static void ventoy_prompt_end(void)
static grub_err_t ventoy_cmd_load_part_table(grub_extcmd_context_t ctxt, int argc, char **args)
{
int ret;
-
+
(void)argc;
(void)ctxt;
@@ -5208,7 +5220,7 @@ static grub_err_t ventoy_cmd_part_exist(grub_extcmd_context_t ctxt, int argc, ch
id = (int)grub_strtoul(args[0], NULL, 10);
grub_errno = 0;
-
+
if (grub_memcmp(g_ventoy_part_info->Head.Signature, "EFI PART", 8) == 0)
{
if (id >= 1 && id <= 128)
@@ -5217,7 +5229,7 @@ static grub_err_t ventoy_cmd_part_exist(grub_extcmd_context_t ctxt, int argc, ch
{
return 0;
}
- }
+ }
}
else
{
@@ -5240,7 +5252,7 @@ static grub_err_t ventoy_cmd_get_fs_label(grub_extcmd_context_t ctxt, int argc,
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
char *label = NULL;
-
+
(void)ctxt;
debug("get fs label for %s\n", args[0]);
@@ -5262,7 +5274,7 @@ static grub_err_t ventoy_cmd_get_fs_label(grub_extcmd_context_t ctxt, int argc,
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
- goto end;
+ goto end;
}
fs = grub_fs_probe(dev);
@@ -5281,12 +5293,12 @@ static grub_err_t ventoy_cmd_get_fs_label(grub_extcmd_context_t ctxt, int argc,
}
rc = 0;
-
+
end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
-
+
return rc;
}
@@ -5319,7 +5331,7 @@ static grub_err_t ventoy_fs_enum_1st_child(int argc, char **args, grub_fs_dir_ho
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
char name[256] ={0};
-
+
if (argc != 3)
{
debug("ventoy_fs_enum_1st_child, invalid param num %d\n", argc);
@@ -5337,7 +5349,7 @@ static grub_err_t ventoy_fs_enum_1st_child(int argc, char **args, grub_fs_dir_ho
if (!dev)
{
debug("grub_device_open failed, %s\n", device_name);
- goto end;
+ goto end;
}
fs = grub_fs_probe(dev);
@@ -5352,14 +5364,14 @@ static grub_err_t ventoy_fs_enum_1st_child(int argc, char **args, grub_fs_dir_ho
{
ventoy_set_env(args[2], name);
}
-
+
rc = 0;
-
+
end:
check_free(device_name, grub_free);
check_free(dev, grub_device_close);
-
+
return rc;
}
@@ -5380,7 +5392,7 @@ static grub_err_t ventoy_cmd_basename(grub_extcmd_context_t ctxt, int argc, char
char c;
char *pos = NULL;
char *end = NULL;
-
+
(void)ctxt;
if (argc != 2)
@@ -5418,7 +5430,7 @@ static grub_err_t ventoy_cmd_basefile(grub_extcmd_context_t ctxt, int argc, char
int i;
int len;
const char *buf;
-
+
(void)ctxt;
if (argc != 2)
@@ -5447,7 +5459,7 @@ static grub_err_t ventoy_cmd_enum_video_mode(grub_extcmd_context_t ctxt, int arg
{
struct grub_video_mode_info info;
char buf[32];
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -5478,7 +5490,7 @@ static grub_err_t vt_cmd_update_cur_video_mode(grub_extcmd_context_t ctxt, int a
{
struct grub_video_mode_info info;
char buf[32];
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -5501,7 +5513,7 @@ static grub_err_t ventoy_cmd_get_video_mode(grub_extcmd_context_t ctxt, int argc
{
int id;
char buf[32];
-
+
(void)ctxt;
(void)argc;
@@ -5513,7 +5525,7 @@ static grub_err_t ventoy_cmd_get_video_mode(grub_extcmd_context_t ctxt, int argc
id = (int)grub_strtoul(args[0], NULL, 10);
if (id < g_video_mode_num)
{
- grub_snprintf(buf, sizeof(buf), "%ux%ux%u",
+ grub_snprintf(buf, sizeof(buf), "%ux%ux%u",
g_video_mode_list[id].width, g_video_mode_list[id].height, g_video_mode_list[id].bpp);
}
@@ -5530,7 +5542,7 @@ static grub_err_t ventoy_cmd_get_efivdisk_offset(grub_extcmd_context_t ctxt, int
char value[32];
grub_uint32_t boot_catlog = 0;
grub_uint8_t buf[512];
-
+
(void)ctxt;
if (argc != 2)
@@ -5597,7 +5609,7 @@ static int ventoy_collect_replace_initrd(const char *filename, const struct grub
curpos = pfsdir->curpos;
len = grub_strlen(filename);
-
+
if (info->dir)
{
if ((len == 1 && filename[0] == '.') ||
@@ -5608,7 +5620,7 @@ static int ventoy_collect_replace_initrd(const char *filename, const struct grub
//debug("#### [DIR] <%s> <%s>\n", pfsdir->fullpath, filename);
pfsdir->dircnt++;
-
+
printlen = grub_snprintf(pfsdir->fullpath + curpos, 512 - curpos, "%s/", filename);
pfsdir->curpos = curpos + printlen;
pfsdir->fs->fs_dir(pfsdir->dev, pfsdir->fullpath, ventoy_collect_replace_initrd, pfsdir);
@@ -5619,7 +5631,7 @@ static int ventoy_collect_replace_initrd(const char *filename, const struct grub
{
//debug("#### [FILE] <%s> <%s>\n", pfsdir->fullpath, filename);
pfsdir->filecnt++;
-
+
/* We consider the xxx.img file bigger than 32MB is the initramfs file */
if (len > 4 && grub_strncmp(filename + len - 4, ".img", 4) == 0)
{
@@ -5642,7 +5654,7 @@ static grub_err_t ventoy_cmd_search_replace_initrd(grub_extcmd_context_t ctxt, i
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
replace_fs_dir *pfsdir = NULL;
-
+
(void)ctxt;
if (argc != 2)
@@ -5666,7 +5678,7 @@ static grub_err_t ventoy_cmd_search_replace_initrd(grub_extcmd_context_t ctxt, i
dev = grub_device_open(device_name);
if (!dev)
{
- goto fail;
+ goto fail;
}
fs = grub_fs_probe(dev);
@@ -5702,7 +5714,7 @@ static grub_err_t ventoy_cmd_search_replace_initrd(grub_extcmd_context_t ctxt, i
}
fail:
-
+
grub_check_free(pfsdir);
grub_check_free(device_name);
check_free(dev, grub_device_close);
@@ -5713,7 +5725,7 @@ fail:
static grub_err_t ventoy_cmd_push_pager(grub_extcmd_context_t ctxt, int argc, char **args)
{
const char *pager = NULL;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -5793,7 +5805,7 @@ static int ventoy_chk_case_dir(const char *filename, const struct grub_dirhook_i
}
}
}
-
+
return 0;
}
@@ -5804,7 +5816,7 @@ static grub_err_t ventoy_cmd_chk_json_pathcase(grub_extcmd_context_t ctxt, int a
grub_device_t dev = NULL;
grub_fs_t fs = NULL;
chk_case_fs_dir fs_dir;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -5913,7 +5925,7 @@ static grub_err_t grub_cmd_syslinux_nojoliet(grub_extcmd_context_t ctxt, int arg
grub_uint32_t boot_catlog = 0;
grub_uint8_t sector[512];
boot_info_table *info = NULL;
-
+
(void)ctxt;
(void)argc;
@@ -5942,7 +5954,7 @@ static grub_err_t grub_cmd_syslinux_nojoliet(grub_extcmd_context_t ctxt, int arg
debug("no bootcatlog found %u\n", boot_catlog);
goto out;
}
-
+
loadrba = ventoy_get_bios_eltorito_rba(file, boot_catlog);
if (loadrba == 0)
{
@@ -5954,9 +5966,9 @@ static grub_err_t grub_cmd_syslinux_nojoliet(grub_extcmd_context_t ctxt, int arg
grub_file_read(file, sector, 512);
info = (boot_info_table *)sector;
- if (info->bi_data0 == 0x7c6ceafa &&
- info->bi_data1 == 0x90900000 &&
- info->bi_PrimaryVolumeDescriptor == 16 &&
+ if (info->bi_data0 == 0x7c6ceafa &&
+ info->bi_data1 == 0x90900000 &&
+ info->bi_PrimaryVolumeDescriptor == 16 &&
info->bi_BootFileLocation == loadrba)
{
debug("bootloader is syslinux, %u.\n", loadrba);
@@ -5974,15 +5986,15 @@ static grub_err_t grub_cmd_vlnk_dump_part(grub_extcmd_context_t ctxt, int argc,
{
int n = 0;
ventoy_vlnk_part *node;
-
+
(void)ctxt;
(void)argc;
(void)args;
for (node = g_vlnk_part_list; node; node = node->next)
{
- grub_printf("[%d] %s disksig:%08x offset:%llu fs:%s\n",
- ++n, node->device, node->disksig,
+ grub_printf("[%d] %s disksig:%08x offset:%llu fs:%s\n",
+ ++n, node->device, node->disksig,
(ulonglong)node->partoffset, (node->fs ? node->fs->name : "N/A"));
}
@@ -5992,7 +6004,7 @@ static grub_err_t grub_cmd_vlnk_dump_part(grub_extcmd_context_t ctxt, int argc,
static grub_err_t grub_cmd_is_vlnk_name(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len = 0;
-
+
(void)ctxt;
if (argc == 1)
@@ -6001,7 +6013,7 @@ static grub_err_t grub_cmd_is_vlnk_name(grub_extcmd_context_t ctxt, int argc, ch
if (grub_file_is_vlnk_suffix(args[0], len))
{
return 0;
- }
+ }
}
return 1;
@@ -6011,7 +6023,7 @@ static grub_err_t grub_cmd_get_vlnk_dst(grub_extcmd_context_t ctxt, int argc, ch
{
int vlnk = 0;
const char *name = NULL;
-
+
(void)ctxt;
if (argc == 2)
@@ -6037,7 +6049,7 @@ static grub_err_t grub_cmd_check_vlnk(grub_extcmd_context_t ctxt, int argc, char
grub_file_t file = NULL;
ventoy_vlnk vlnk;
char dst[512];
-
+
(void)ctxt;
if (argc != 1)
@@ -6096,7 +6108,7 @@ static grub_err_t ventoy_cmd_iso_vd_id_parse(grub_extcmd_context_t ctxt, int arg
int ret = 1;
int offset = 318;
grub_file_t file = NULL;
-
+
(void)ctxt;
(void)argc;
@@ -6129,7 +6141,7 @@ static grub_err_t ventoy_cmd_iso_vd_id_begin(grub_extcmd_context_t ctxt, int arg
{
int ret = 1;
char *id = g_iso_vd_id_publisher;
-
+
(void)ctxt;
(void)argc;
@@ -6146,7 +6158,7 @@ static grub_err_t ventoy_cmd_iso_vd_id_begin(grub_extcmd_context_t ctxt, int arg
{
ret = 0;
}
-
+
if (args[1][0] == '1' && grub_strncmp(id, args[2], grub_strlen(args[2])) == 0)
{
ret = 0;
@@ -6175,7 +6187,7 @@ static grub_err_t ventoy_cmd_dump_rsv_page(grub_extcmd_context_t ctxt, int argc,
grub_uint64_t total;
grub_uint64_t org_required;
grub_uint64_t new_required;
-
+
(void)ctxt;
(void)argc;
(void)args;
@@ -6200,7 +6212,7 @@ static grub_err_t ventoy_cmd_dump_rsv_page(grub_extcmd_context_t ctxt, int argc,
static grub_err_t ventoy_cmd_need_secondary_menu(grub_extcmd_context_t ctxt, int argc, char **args)
{
const char *env = NULL;
-
+
(void)ctxt;
(void)argc;
@@ -6303,7 +6315,7 @@ static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int
g_ventoy_secondary_menu_on = 0;
select = seldata[g_ventoy_last_entry];
-
+
if (select == 2)
{
g_ventoy_wimboot_mode = 1;
@@ -6354,7 +6366,7 @@ static grub_err_t ventoy_cmd_secondary_recover_mode(grub_extcmd_context_t ctxt,
}
g_vtoy_secondary_need_recover = 0;
-
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@@ -6411,17 +6423,17 @@ static int ventoy_chksum_pathcmp(int chktype, char *rlpath, char *rdpath)
return 0;
}
}
-
+
return 1;
}
static int ventoy_find_checksum
(
- grub_file_t file,
- const char *uname,
- int retlen,
- char *path,
- int chktype,
+ grub_file_t file,
+ const char *uname,
+ int retlen,
+ char *path,
+ int chktype,
char *chksum
)
{
@@ -6455,7 +6467,7 @@ static int ventoy_find_checksum
pos = grub_strchr(currline, '=');
pos1 = grub_strchr(currline, '(');
pos2 = grub_strchr(currline, ')');
-
+
if (pos && pos1 && pos2)
{
*pos2 = 0;
@@ -6473,7 +6485,7 @@ static int ventoy_find_checksum
if (ventoy_chksum_pathcmp(chktype, path, pos) == 0)
{
grub_memcpy(chksum, currline, retlen);
- goto end;
+ goto end;
}
}
}
@@ -6523,7 +6535,7 @@ end:
if (pfile)
{
- *pfile = file;
+ *pfile = file;
}
else
{
@@ -6555,9 +6567,9 @@ static grub_err_t ventoy_cmd_cmp_checksum(grub_extcmd_context_t ctxt, int argc,
grub_strncpy(uchkname, g_lower_chksum_name[index], sizeof(uchkname));
ventoy_str_toupper(uchkname);
-
+
isopart = grub_env_get("vtoy_iso_part");
- calc_value = grub_env_get("VT_LAST_CHECK_SUM");
+ calc_value = grub_env_get("VT_LAST_CHECK_SUM");
chktype = ventoy_check_chkfile(isopart, args[1], g_lower_chksum_name[index], &file);
if (chktype <= 0)
@@ -6632,7 +6644,7 @@ end:
static int ventoy_find_all_checksum
(
- grub_file_t file,
+ grub_file_t file,
char *path,
int chktype,
int exists[VTOY_CHKSUM_NUM],
@@ -6674,7 +6686,7 @@ static int ventoy_find_all_checksum
{
continue;
}
-
+
uname = g_lower_chksum_name[i];
ulen = g_lower_chksum_namelen[i];
@@ -6683,7 +6695,7 @@ static int ventoy_find_all_checksum
pos = grub_strchr(currline, '=');
pos1 = grub_strchr(currline, '(');
pos2 = grub_strchr(currline, ')');
-
+
if (pos && pos1 && pos2)
{
c = *pos2;
@@ -6734,7 +6746,7 @@ static grub_err_t ventoy_cmd_vtoychksum_exist(grub_extcmd_context_t ctxt, int ar
(void)argc;
(void)ctxt;
-
+
isopart = grub_env_get("vtoy_iso_part");
for (i = 0; i < VTOY_CHKSUM_NUM; i++)
@@ -6759,7 +6771,7 @@ static grub_err_t ventoy_cmd_vtoychksum_exist(grub_extcmd_context_t ctxt, int ar
*pos = 0;
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s/VENTOY_CHECKSUM", isopart, args[0]);
*pos = c;
-
+
if (file)
{
if (tip == 0 && file->size > (32 * VTOY_SIZE_1KB))
@@ -6768,7 +6780,7 @@ static grub_err_t ventoy_cmd_vtoychksum_exist(grub_extcmd_context_t ctxt, int ar
grub_printf("Reading checksum file...\n");
grub_refresh();
}
-
+
debug("parse local VENTOY_CHECKSUM\n");
ventoy_find_all_checksum(file, args[0], 2, exists, &totexist);
grub_file_close(file);
@@ -6828,7 +6840,7 @@ int ventoy_env_init(void)
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
{
- g_conf_replace_new_buf[i] = grub_malloc(vtoy_max_replace_file_size);
+ g_conf_replace_new_buf[i] = grub_malloc(vtoy_max_replace_file_size);
}
ventoy_filt_register(0, ventoy_wrapper_open);
@@ -6857,7 +6869,7 @@ int ventoy_env_init(void)
grub_snprintf(buf, sizeof(buf), "0x%lx", (ulong)ventoy_chain_file_read);
grub_env_set("vtoy_chain_file_read", buf);
grub_env_export("vtoy_chain_file_read");
-
+
grub_snprintf(buf, sizeof(buf), "0x%lx", (ulong)ventoy_get_vmenu_title);
grub_env_set("VTOY_VMENU_FUNC_ADDR", buf);
grub_env_export("VTOY_VMENU_FUNC_ADDR");
@@ -6871,7 +6883,7 @@ int ventoy_env_init(void)
-static cmd_para ventoy_cmds[] =
+static cmd_para ventoy_cmds[] =
{
{ "vt_browser_disk", ventoy_cmd_browser_disk, 0, NULL, "", "", NULL },
{ "vt_browser_dir", ventoy_cmd_browser_dir, 0, NULL, "", "", NULL },
@@ -6914,13 +6926,13 @@ static cmd_para ventoy_cmds[] =
{ "vt_get_fs_label", ventoy_cmd_get_fs_label, 0, NULL, "", "", NULL },
{ "vt_fs_enum_1st_file", ventoy_cmd_fs_enum_1st_file, 0, NULL, "", "", NULL },
{ "vt_fs_enum_1st_dir", ventoy_cmd_fs_enum_1st_dir, 0, NULL, "", "", NULL },
- { "vt_file_basename", ventoy_cmd_basename, 0, NULL, "", "", NULL },
- { "vt_file_basefile", ventoy_cmd_basefile, 0, NULL, "", "", NULL },
- { "vt_enum_video_mode", ventoy_cmd_enum_video_mode, 0, NULL, "", "", NULL },
- { "vt_get_video_mode", ventoy_cmd_get_video_mode, 0, NULL, "", "", NULL },
- { "vt_update_cur_video_mode", vt_cmd_update_cur_video_mode, 0, NULL, "", "", NULL },
+ { "vt_file_basename", ventoy_cmd_basename, 0, NULL, "", "", NULL },
+ { "vt_file_basefile", ventoy_cmd_basefile, 0, NULL, "", "", NULL },
+ { "vt_enum_video_mode", ventoy_cmd_enum_video_mode, 0, NULL, "", "", NULL },
+ { "vt_get_video_mode", ventoy_cmd_get_video_mode, 0, NULL, "", "", NULL },
+ { "vt_update_cur_video_mode", vt_cmd_update_cur_video_mode, 0, NULL, "", "", NULL },
+
-
{ "vt_find_first_bootable_hd", ventoy_cmd_find_bootable_hdd, 0, NULL, "", "", NULL },
{ "vt_dump_menu", ventoy_cmd_dump_menu, 0, NULL, "", "", NULL },
{ "vt_dynamic_menu", ventoy_cmd_dynamic_menu, 0, NULL, "", "", NULL },
@@ -6940,7 +6952,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_load_file_to_mem", ventoy_cmd_load_file_to_mem, 0, NULL, "", "", NULL },
{ "vt_load_img_memdisk", ventoy_cmd_load_img_memdisk, 0, NULL, "", "", NULL },
{ "vt_concat_efi_iso", ventoy_cmd_concat_efi_iso, 0, NULL, "", "", NULL },
-
+
{ "vt_linux_parse_initrd_isolinux", ventoy_cmd_isolinux_initrd_collect, 0, NULL, "{cfgfile}", "", NULL },
{ "vt_linux_parse_initrd_grub", ventoy_cmd_grub_initrd_collect, 0, NULL, "{cfgfile}", "", NULL },
{ "vt_linux_specify_initrd_file", ventoy_cmd_specify_initrd_file, 0, NULL, "", "", NULL },
@@ -6967,16 +6979,16 @@ static cmd_para ventoy_cmds[] =
{ "vt_test_block_list", ventoy_cmd_test_block_list, 0, NULL, "", "", NULL },
{ "vt_file_exist_nocase", ventoy_cmd_file_exist_nocase, 0, NULL, "", "", NULL },
-
+
{ "vt_load_plugin", ventoy_cmd_load_plugin, 0, NULL, "", "", NULL },
{ "vt_check_plugin_json", ventoy_cmd_plugin_check_json, 0, NULL, "", "", NULL },
{ "vt_check_password", ventoy_cmd_check_password, 0, NULL, "", "", NULL },
-
+
{ "vt_1st_line", ventoy_cmd_read_1st_line, 0, NULL, "", "", NULL },
{ "vt_file_strstr", ventoy_cmd_file_strstr, 0, NULL, "", "", NULL },
{ "vt_img_part_info", ventoy_cmd_img_part_info, 0, NULL, "", "", NULL },
-
+
{ "vt_parse_iso_volume", ventoy_cmd_parse_volume, 0, NULL, "", "", NULL },
{ "vt_parse_iso_create_date", ventoy_cmd_parse_create_date, 0, NULL, "", "", NULL },
{ "vt_parse_freenas_ver", ventoy_cmd_parse_freenas_ver, 0, NULL, "", "", NULL },
@@ -7047,11 +7059,11 @@ int ventoy_register_all_cmd(void)
{
grub_uint32_t i;
cmd_para *cur = NULL;
-
+
for (i = 0; i < ARRAY_SIZE(ventoy_cmds); i++)
{
cur = ventoy_cmds + i;
- cur->cmd = grub_register_extcmd(cur->name, cur->func, cur->flags,
+ cur->cmd = grub_register_extcmd(cur->name, cur->func, cur->flags,
cur->summary, cur->description, cur->parser);
}
@@ -7061,12 +7073,12 @@ int ventoy_register_all_cmd(void)
int ventoy_unregister_all_cmd(void)
{
grub_uint32_t i;
-
+
for (i = 0; i < ARRAY_SIZE(ventoy_cmds); i++)
{
grub_unregister_extcmd(ventoy_cmds[i].cmd);
}
-
+
return 0;
}
diff --git a/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h b/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
index 96c59ef9..d15e26e0 100644
--- a/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
+++ b/GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
@@ -7,12 +7,12 @@
* 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 .
*
@@ -82,7 +82,7 @@ typedef struct ventoy_image_location
/*
* disk region data (region_count)
- * If the image file has more than one fragments in disk,
+ * If the image file has more than one fragments in disk,
* there will be more than one region data here.
*
*/
@@ -104,7 +104,7 @@ typedef struct ventoy_os_param
char vtoy_img_path[384]; // It seems to be enough, utf-8 format
grub_uint64_t vtoy_img_size; // image file size in bytes
- /*
+ /*
* Ventoy will write a copy of ventoy_image_location data into runtime memory
* this is the physically address and length of that memory.
* Address 0 means no such data exist.
@@ -114,7 +114,7 @@ typedef struct ventoy_os_param
grub_uint64_t vtoy_img_location_addr;
grub_uint32_t vtoy_img_location_len;
- /*
+ /*
* These 32 bytes are reserved by ventoy.
*
* vtoy_reserved[0]: vtoy_break_level
@@ -125,6 +125,7 @@ typedef struct ventoy_os_param
* vtoy_reserved[5]: vtoy_linux_remount
* vtoy_reserved[6]: vtoy_vlnk
* vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk
+ * vtoy_reserved[11]: vtoy_win_uefi_max_res
*
*/
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
@@ -155,8 +156,8 @@ typedef struct ventoy_windows_data
typedef struct ventoy_secure_data
{
grub_uint8_t magic1[16]; /* VENTOY_GUID */
- grub_uint8_t diskuuid[16];
- grub_uint8_t Checksum[16];
+ grub_uint8_t diskuuid[16];
+ grub_uint8_t Checksum[16];
grub_uint8_t adminSHA256[32];
grub_uint8_t reserved[4000];
grub_uint8_t magic2[16]; /* VENTOY_GUID */
@@ -200,7 +201,7 @@ typedef struct ventoy_chain_head
grub_uint64_t virt_img_size_in_bytes;
grub_uint32_t boot_catalog;
grub_uint8_t boot_catalog_sector[2048];
-
+
grub_uint32_t img_chunk_offset;
grub_uint32_t img_chunk_num;
@@ -319,7 +320,7 @@ grub_uint64_t grub_udf_get_file_offset(grub_file_t file);
grub_uint64_t grub_udf_get_last_pd_size_offset(void);
grub_uint64_t grub_udf_get_last_file_attr_offset
(
- grub_file_t file,
+ grub_file_t file,
grub_uint32_t *startBlock,
grub_uint64_t *fe_entry_size_offset
);
diff --git a/IMG/cpio/ventoy/hook/debian/porteus-hook.sh b/IMG/cpio/ventoy/hook/debian/porteus-hook.sh
index 287e6309..86863b75 100644
--- a/IMG/cpio/ventoy/hook/debian/porteus-hook.sh
+++ b/IMG/cpio/ventoy/hook/debian/porteus-hook.sh
@@ -33,11 +33,13 @@ 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
+ $GREP '`value from`' /usr/* -r | $AWK -F: '{print $1}' > $VTOY_PATH/.porteus
+ while read vtline; do
echo "hooking $vtline ..." >> $VTLOG
$SED "s#\`value from\`#$vtPath#g" -i $vtline
vtFindFlag=1
- done
+ done < $VTOY_PATH/.porteus
+ rm -f $VTOY_PATH/.porteus
if [ $vtFindFlag -eq 0 ]; then
if $GREP -q '`value from`' /linuxrc; then
diff --git a/INSTALL/Ventoy2Disk.sh b/INSTALL/Ventoy2Disk.sh
index b091e321..966a28dc 100644
--- a/INSTALL/Ventoy2Disk.sh
+++ b/INSTALL/Ventoy2Disk.sh
@@ -66,6 +66,16 @@ if [ -f mkexfatfs_static ]; then
if ldd --version 2>&1 | grep -qi musl; then
mv mkexfatfs mkexfatfs_shared
mv mkexfatfs_static mkexfatfs
+ else
+ if ./mkexfatfs -V > /dev/null 2>&1; then
+ echo "mkexfatfs can not run, check static version" >> ./log.txt
+ else
+ if ./mkexfatfs_static -V > /dev/null 2>&1; then
+ echo "Use static version of mkexfatfs" >> ./log.txt
+ mv mkexfatfs mkexfatfs_shared
+ mv mkexfatfs_static mkexfatfs
+ fi
+ fi
fi
fi
diff --git a/INSTALL/grub/debug.cfg b/INSTALL/grub/debug.cfg
index 09b1992f..bbf2b3b7 100644
--- a/INSTALL/grub/debug.cfg
+++ b/INSTALL/grub/debug.cfg
@@ -22,13 +22,22 @@ submenu "$VTLANG_CTRL_TEMP_SET" --class=debug_temp_set --class=F5tool {
}
menuentry "[ $VTOY_SECONDARY_BOOT_MENU ] $VTLANG_SECONDARY_BOOT_MENU" --class=debug_temp_second_menu --class=debug_temp_set --class=F5tool \
- VTOY_RUN_SET3 {
+ VTOY_RUN_SET2 {
if [ "$VTOY_SECONDARY_BOOT_MENU" = "0" ]; then
set VTOY_SECONDARY_BOOT_MENU=1
else
set VTOY_SECONDARY_BOOT_MENU=0
fi
}
+
+ menuentry "[ $VTOY_WIN_UEFI_MAX_RES ] $VTLANG_WIN_UEFI_MAX_RES" --class=debug_temp_win_uefi_res --class=debug_temp_set --class=F5tool \
+ VTOY_RUN_SET3 {
+ if [ "$VTOY_WIN_UEFI_MAX_RES" = "0" ]; then
+ set VTOY_WIN_UEFI_MAX_RES=1
+ else
+ set VTOY_WIN_UEFI_MAX_RES=0
+ fi
+ }
menuentry "$VTLANG_RETURN_PREVIOUS" --class=vtoyret VTOY_RET {
echo "Return ..."
diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg
index 4cf3d1e5..d6b32add 100644
--- a/INSTALL/grub/grub.cfg
+++ b/INSTALL/grub/grub.cfg
@@ -2449,7 +2449,7 @@ function mimg_common_menuentry {
#############################################################
#############################################################
-set VENTOY_VERSION="1.1.10"
+set VENTOY_VERSION="1.1.11"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
diff --git a/INSTALL/tool/ventoy_lib.sh b/INSTALL/tool/ventoy_lib.sh
index 854881d7..c90d13c8 100644
--- a/INSTALL/tool/ventoy_lib.sh
+++ b/INSTALL/tool/ventoy_lib.sh
@@ -60,7 +60,7 @@ check_tool_work_ok() {
return
fi
- if mkexfatfs -V > /dev/null; then
+ if mkexfatfs -V > /dev/null; then
vtdebug "mkexfatfs test ok ..."
else
vtdebug "mkexfatfs test fail ..."
@@ -341,6 +341,7 @@ EOF
udevadm trigger --name-match=$DISK >/dev/null 2>&1
partprobe >/dev/null 2>&1
+ partx -u $DISK >/dev/null 2>&1
sleep 3
echo "Done"
@@ -458,6 +459,7 @@ format_ventoy_disk_gpt() {
udevadm trigger --name-match=$DISK >/dev/null 2>&1
partprobe >/dev/null 2>&1
+ partx -u $DISK >/dev/null 2>&1
sleep 3
echo "Done"
diff --git a/VtoyTool/vtoyexpand.c b/VtoyTool/vtoyexpand.c
index c0a15d37..b97d09ca 100644
--- a/VtoyTool/vtoyexpand.c
+++ b/VtoyTool/vtoyexpand.c
@@ -7,12 +7,12 @@
* 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 .
*
@@ -70,7 +70,7 @@ static void vlog(const char *fmt, ...)
n += vsnprintf(log, sizeof(log) - 1, fmt, arg);
va_end(arg);
- fwrite(log, 1, n, fp);
+ fwrite(log, 1, n, fp);
fclose(fp);
}
}
@@ -90,7 +90,7 @@ static int copy_file(const char *file1, const char *file2)
vlog("Failed to read file <%s>\n", file1);
goto end;
}
-
+
fp2 = fopen(file2, "wb+");
if (!fp2)
{
@@ -115,7 +115,7 @@ static int copy_file(const char *file1, const char *file2)
vlog("Failed to read <%s> %d %d\n", file1, n, size);
goto end;
}
-
+
n = fwrite(buf, 1, size, fp2);
if (n != size)
{
@@ -167,7 +167,7 @@ static int vtoy_is_possible_blkdev(const char *name)
{
return 0;
}
-
+
return 1;
}
@@ -184,7 +184,7 @@ static ulonglong vtoy_get_disk_size_in_byte(const char *disk)
if (access(diskpath, F_OK) >= 0)
{
vlog("get disk size from sysfs for %s\n", disk);
-
+
fd = open(diskpath, O_RDONLY | O_BINARY);
if (fd >= 0)
{
@@ -233,7 +233,7 @@ static int get_disk_num(void)
{
return 0;
}
-
+
while ((p = readdir(dir)) != NULL)
{
n++;
@@ -248,7 +248,7 @@ static int is_usb_disk(const char *diskname)
int rc;
char dstpath[1024] = { 0 };
char syspath[1024] = { 0 };
-
+
snprintf(syspath, sizeof(syspath), "/sys/block/%s", diskname);
rc = readlink(syspath, dstpath, sizeof(dstpath) - 1);
if (rc > 0 && strstr(dstpath, "/usb"))
@@ -296,13 +296,13 @@ static int get_all_disk(void)
vlog("disk %s is filted by name\n", p->d_name);
continue;
}
-
+
cursize = vtoy_get_disk_size_in_byte(p->d_name);
node = g_disk_list + g_disk_num;
g_disk_num++;
-
+
snprintf(node->name, sizeof(node->name), p->d_name);
node->size = cursize;
node->isUSB = is_usb_disk(p->d_name);
@@ -338,7 +338,7 @@ static int get_all_disk(void)
node->size / 1024 / 1024 / 1024, node->size, node->isUSB);
}
vlog("============ DISK DUMP END ===========\n");
-
+
return 0;
}
@@ -410,7 +410,7 @@ static int expand_var(const char *var, char *value, int len)
{
uiDst = strtoul(var + 22, NULL, 10);
uiDst = uiDst * (1024ULL * 1024ULL * 1024ULL);
-
+
for (i = 0; i < g_disk_num; i++)
{
node = g_disk_list + i;
@@ -418,7 +418,7 @@ static int expand_var(const char *var, char *value, int len)
{
continue;
}
-
+
if (node->size > uiDst)
{
delta = node->size - uiDst;
@@ -427,7 +427,52 @@ static int expand_var(const char *var, char *value, int len)
{
delta = uiDst - node->size;
}
-
+
+ if (delta < maxdelta)
+ {
+ index = i;
+ maxdelta = delta;
+ }
+ }
+
+ if (index >= 0)
+ {
+ vlog("%s=<%s>\n", var, g_disk_list[index].name);
+ snprintf(value, len, "%s", g_disk_list[index].name);
+ return 0;
+ }
+ else
+ {
+ vlog("[Error] %s not found\n", var);
+ }
+ }
+ else if (strncmp(var, "VT_LINUX_DISK_NONVTOY_CLOSEST_", 30) == 0)
+ {
+ uiDst = strtoul(var + 30, NULL, 10);
+ uiDst = uiDst * (1024ULL * 1024ULL * 1024ULL);
+
+ for (i = 0; i < g_disk_num; i++)
+ {
+ node = g_disk_list + i;
+ if (node->size == 0)
+ {
+ continue;
+ }
+
+ if (strcmp(node->name, g_vtoy_disk_name) == 0)
+ {
+ continue;
+ }
+
+ if (node->size > uiDst)
+ {
+ delta = node->size - uiDst;
+ }
+ else
+ {
+ delta = uiDst - node->size;
+ }
+
if (delta < maxdelta)
{
index = i;
@@ -481,10 +526,10 @@ int vtoyexpand_main(int argc, char **argv)
{
g_vtoy_disk_name += 5;
}
- vlog("<%s> <%s> <%s>\n", argv[1], argv[2], g_vtoy_disk_name);
+ vlog("<%s> <%s> <%s>\n", argv[1], argv[2], g_vtoy_disk_name);
get_all_disk();
-
+
fp = fopen(argv[1], "r");
if (!fp)
{
@@ -502,7 +547,7 @@ int vtoyexpand_main(int argc, char **argv)
memset(line, 0, sizeof(line));
memset(value, 0, sizeof(value));
-
+
while (fgets(line, sizeof(line), fp))
{
start = strstr(line, "$$VT_");
@@ -519,7 +564,7 @@ int vtoyexpand_main(int argc, char **argv)
*end = 0;
expand_var(start + 2, value, sizeof(value));
fprintf(fout, "%s", value);
-
+
fprintf(fout, "%s", end + 2);
memset(value, 0, sizeof(value));
@@ -531,7 +576,7 @@ int vtoyexpand_main(int argc, char **argv)
line[0] = line[4095] = 0;
}
-
+
fclose(fp);
fclose(fout);
@@ -540,7 +585,7 @@ int vtoyexpand_main(int argc, char **argv)
vlog("Copy file <%s> --> <%s>\n", TMP_FILE, argv[1]);
copy_file(TMP_FILE, argv[1]);
-
+
return 0;
}