1.0.04 release

pull/24/head
longpanda 4 years ago
parent c72f96312c
commit 790fa744f8

@ -32,11 +32,15 @@
#include <Guid/FileInfo.h> #include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h> #include <Guid/FileSystemInfo.h>
#include <Protocol/BlockIo.h> #include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h> #include <Protocol/SimpleFileSystem.h>
#include <Ventoy.h> #include <Ventoy.h>
UINTN g_iso_buf_size = 0;
BOOLEAN gMemdiskMode = FALSE;
BOOLEAN gDebugPrint = FALSE; BOOLEAN gDebugPrint = FALSE;
BOOLEAN gLoadIsoEfi = FALSE; BOOLEAN gLoadIsoEfi = FALSE;
ventoy_ram_disk g_ramdisk_param;
ventoy_chain_head *g_chain; ventoy_chain_head *g_chain;
ventoy_img_chunk *g_chunk; ventoy_img_chunk *g_chunk;
UINT32 g_img_chunk_num; UINT32 g_img_chunk_num;
@ -353,6 +357,25 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
return EFI_SUCCESS; return EFI_SUCCESS;
} }
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);
(VOID)This;
(VOID)MediaId;
CopyMem(Buffer, (char *)g_chain + (Lba * 2048), BufferSize);
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI ventoy_block_io_read EFI_STATUS EFIAPI ventoy_block_io_read
( (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
@ -497,6 +520,33 @@ EFI_STATUS EFIAPI ventoy_fill_device_path(VOID)
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFIAPI ventoy_save_ramdisk_param(VOID)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID;
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_ramdisk_param), &(g_ramdisk_param));
debug("set efi variable %r", Status);
return Status;
}
EFI_STATUS EFIAPI ventoy_del_ramdisk_param(VOID)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_GUID VarGuid = VENTOY_GUID;
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL);
debug("delete efi variable %r", Status);
return Status;
}
EFI_STATUS EFIAPI ventoy_set_variable(VOID) EFI_STATUS EFIAPI ventoy_set_variable(VOID)
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
@ -524,7 +574,7 @@ EFI_STATUS EFIAPI ventoy_delete_variable(VOID)
} }
EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle) EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize)
{ {
EFI_STATUS Status = EFI_SUCCESS; EFI_STATUS Status = EFI_SUCCESS;
EFI_BLOCK_IO_PROTOCOL *pBlockIo = &(gBlockData.BlockIo); EFI_BLOCK_IO_PROTOCOL *pBlockIo = &(gBlockData.BlockIo);
@ -532,7 +582,7 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle)
ventoy_fill_device_path(); ventoy_fill_device_path();
gBlockData.Media.BlockSize = 2048; gBlockData.Media.BlockSize = 2048;
gBlockData.Media.LastBlock = g_chain->virt_img_size_in_bytes / 2048 - 1; gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
gBlockData.Media.ReadOnly = TRUE; gBlockData.Media.ReadOnly = TRUE;
gBlockData.Media.MediaPresent = 1; gBlockData.Media.MediaPresent = 1;
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1; gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;
@ -540,7 +590,16 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle)
pBlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3; pBlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3;
pBlockIo->Media = &(gBlockData.Media); pBlockIo->Media = &(gBlockData.Media);
pBlockIo->Reset = ventoy_block_io_reset; pBlockIo->Reset = ventoy_block_io_reset;
pBlockIo->ReadBlocks = ventoy_block_io_read;
if (gMemdiskMode)
{
pBlockIo->ReadBlocks = ventoy_block_io_ramdisk_read;
}
else
{
pBlockIo->ReadBlocks = ventoy_block_io_read;
}
pBlockIo->WriteBlocks = ventoy_block_io_write; pBlockIo->WriteBlocks = ventoy_block_io_write;
pBlockIo->FlushBlocks = ventoy_block_io_flush; pBlockIo->FlushBlocks = ventoy_block_io_flush;
@ -827,6 +886,7 @@ static int ventoy_update_image_location(ventoy_os_param *param)
STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle) STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{ {
UINT32 i = 0; UINT32 i = 0;
UINTN size = 0;
UINT8 chksum = 0; UINT8 chksum = 0;
CHAR16 *pPos = NULL; CHAR16 *pPos = NULL;
CHAR16 *pCmdLine = NULL; CHAR16 *pCmdLine = NULL;
@ -866,32 +926,44 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param=")); pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param="));
grub_env_get = pGrubParam->grub_env_get; grub_env_get = pGrubParam->grub_env_get;
pPos = StrStr(pCmdLine, L"mem:"); pPos = StrStr(pCmdLine, L"mem:");
g_chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4); g_chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset); pPos = StrStr(pPos, L"size:");
g_img_chunk_num = g_chain->img_chunk_num; size = StrDecimalToUintn(pPos + 5);
g_override_chunk = (ventoy_override_chunk *)((char *)g_chain + g_chain->override_chunk_offset);
g_override_chunk_num = g_chain->override_chunk_num;
g_virt_chunk = (ventoy_virt_chunk *)((char *)g_chain + g_chain->virt_chunk_offset);
g_virt_chunk_num = g_chain->virt_chunk_num;
for (i = 0; i < sizeof(ventoy_os_param); i++) debug("memory addr:%p size:%lu", g_chain, size);
{
chksum += *((UINT8 *)(&(g_chain->os_param)) + i);
}
if (gDebugPrint) if (StrStr(pCmdLine, L"memdisk"))
{ {
debug("os param checksum: 0x%x %a", g_chain->os_param.chksum, chksum ? "FAILED" : "SUCCESS"); g_iso_buf_size = size;
gMemdiskMode = TRUE;
} }
else
{
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);
g_override_chunk_num = g_chain->override_chunk_num;
g_virt_chunk = (ventoy_virt_chunk *)((char *)g_chain + g_chain->virt_chunk_offset);
g_virt_chunk_num = g_chain->virt_chunk_num;
for (i = 0; i < sizeof(ventoy_os_param); i++)
{
chksum += *((UINT8 *)(&(g_chain->os_param)) + i);
}
ventoy_update_image_location(&(g_chain->os_param)); if (gDebugPrint)
{
debug("os param checksum: 0x%x %a", g_chain->os_param.chksum, chksum ? "FAILED" : "SUCCESS");
}
if (gDebugPrint) ventoy_update_image_location(&(g_chain->os_param));
{
ventoy_dump_chain(g_chain); if (gDebugPrint)
{
ventoy_dump_chain(g_chain);
}
} }
FreePool(pCmdLine); FreePool(pCmdLine);
@ -974,6 +1046,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
if (EFI_ERROR(Status)) if (EFI_ERROR(Status))
{ {
debug("Failed to start image %r", Status); debug("Failed to start image %r", Status);
sleep(3);
gBS->UnloadImage(Image); gBS->UnloadImage(Image);
break; break;
} }
@ -1016,8 +1089,49 @@ EFI_STATUS EFIAPI ventoy_clean_env(VOID)
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFIAPI VentoyEfiMain EFI_STATUS EFIAPI ventoy_ramdisk_boot(IN EFI_HANDLE ImageHandle)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_RAM_DISK_PROTOCOL *RamDisk = NULL;
EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL;
debug("RamDisk Boot ...");
Status = gBS->LocateProtocol(&gEfiRamDiskProtocolGuid, NULL, (VOID **)&RamDisk);
if (EFI_ERROR(Status))
{
debug("Failed to locate ramdisk protocol %r", Status);
return Status;
}
debug("Locate RamDisk Protocol %r ...", Status);
Status = RamDisk->Register((UINTN)g_chain, (UINT64)g_iso_buf_size, &gEfiVirtualCdGuid, NULL, &DevicePath);
if (EFI_ERROR(Status))
{
debug("Failed to register ramdisk %r", Status);
return Status;
}
debug("Register RamDisk %r ...", Status);
debug("RamDisk DevicePath:<%s> ...", ConvertDevicePathToText(DevicePath, FALSE, FALSE));
ventoy_debug_pause();
gBlockData.Path = DevicePath;
gBlockData.DevicePathCompareLen = GetDevicePathSize(DevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
Status = ventoy_boot(ImageHandle);
if (EFI_NOT_FOUND == Status)
{
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
sleep(300);
}
return EFI_SUCCESS;
}
EFI_STATUS EFIAPI VentoyEfiMain
( (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
@ -1037,36 +1151,56 @@ EFI_STATUS EFIAPI VentoyEfiMain
ventoy_clear_input(); ventoy_clear_input();
ventoy_parse_cmdline(ImageHandle); ventoy_parse_cmdline(ImageHandle);
ventoy_set_variable();
ventoy_find_iso_disk(ImageHandle);
if (gLoadIsoEfi) if (gMemdiskMode)
{ {
ventoy_find_iso_disk_fs(ImageHandle); g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_chain;
ventoy_load_isoefi_driver(ImageHandle); g_ramdisk_param.DiskSize = (UINT64)g_iso_buf_size;
ventoy_save_ramdisk_param();
ventoy_install_blockio(ImageHandle, g_iso_buf_size);
Status = ventoy_boot(ImageHandle);
if (EFI_NOT_FOUND == Status)
{
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
sleep(300);
}
ventoy_del_ramdisk_param();
} }
else
{
ventoy_set_variable();
ventoy_find_iso_disk(ImageHandle);
ventoy_debug_pause(); if (gLoadIsoEfi)
{
ventoy_install_blockio(ImageHandle); ventoy_find_iso_disk_fs(ImageHandle);
ventoy_load_isoefi_driver(ImageHandle);
}
ventoy_debug_pause(); ventoy_debug_pause();
ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes);
Status = ventoy_boot(ImageHandle); ventoy_debug_pause();
if (EFI_NOT_FOUND == Status)
{
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
sleep(300);
}
ventoy_clean_env(); Status = ventoy_boot(ImageHandle);
if (EFI_NOT_FOUND == Status)
{
gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
sleep(300);
}
ventoy_clean_env();
}
ventoy_clear_input(); ventoy_clear_input();
gST->ConOut->ClearScreen(gST->ConOut); gST->ConOut->ClearScreen(gST->ConOut);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

@ -223,6 +223,13 @@ typedef struct ventoy_grub_param
{ {
grub_env_get_pf grub_env_get; grub_env_get_pf grub_env_get;
}ventoy_grub_param; }ventoy_grub_param;
typedef struct ventoy_ram_disk
{
UINT64 PhyAddr;
UINT64 DiskSize;
}ventoy_ram_disk;
#pragma pack() #pragma pack()

@ -41,9 +41,11 @@
[Guids] [Guids]
gShellVariableGuid gShellVariableGuid
gEfiVirtualCdGuid
[Protocols] [Protocols]
gEfiLoadedImageProtocolGuid gEfiLoadedImageProtocolGuid
gEfiBlockIoProtocolGuid gEfiBlockIoProtocolGuid
gEfiDevicePathProtocolGuid gEfiDevicePathProtocolGuid
gEfiSimpleFileSystemProtocolGuid gEfiSimpleFileSystemProtocolGuid
gEfiRamDiskProtocolGuid

@ -32,6 +32,7 @@
#include <grub/script_sh.h> #include <grub/script_sh.h>
#include <grub/gfxterm.h> #include <grub/gfxterm.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/env.h>
/* Time to delay after displaying an error message about a default/fallback /* Time to delay after displaying an error message about a default/fallback
entry failing to boot. */ entry failing to boot. */
@ -786,6 +787,36 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
} }
goto refresh; goto refresh;
case GRUB_TERM_KEY_F1:
menu_fini ();
if (grub_env_get("VTOY_MEM_DISK")) {
grub_env_unset("VTOY_MEM_DISK");
}else {
grub_env_set("VTOY_MEM_DISK", grub_env_get("VTOY_MEM_DISK_STR"));
}
grub_env_set("VTOY_MENU_REFRESH", "1");
goto refresh;
case GRUB_TERM_KEY_F3:
menu_fini ();
if (grub_env_get("VTOY_ISO_RAW")) {
grub_env_unset("VTOY_ISO_RAW");
}else {
grub_env_set("VTOY_ISO_RAW", grub_env_get("VTOY_ISO_RAW_STR"));
}
grub_env_set("VTOY_MENU_REFRESH", "1");
goto refresh;
case GRUB_TERM_KEY_F4:
menu_fini ();
if (grub_env_get("VTOY_ISO_UEFI_DRV")) {
grub_env_unset("VTOY_ISO_UEFI_DRV");
}else {
grub_env_set("VTOY_ISO_UEFI_DRV", grub_env_get("VTOY_ISO_UEFI_DRV_STR"));
}
grub_env_set("VTOY_MENU_REFRESH", "1");
goto refresh;
default: default:
{ {
int entry; int entry;

@ -33,6 +33,9 @@
#include <grub/datetime.h> #include <grub/datetime.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/net.h> #include <grub/net.h>
#ifdef GRUB_MACHINE_EFI
#include <grub/efi/efi.h>
#endif
#include <grub/time.h> #include <grub/time.h>
#include <grub/ventoy.h> #include <grub/ventoy.h>
#include "ventoy_def.h" #include "ventoy_def.h"
@ -261,6 +264,84 @@ static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **a
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
static grub_err_t ventoy_cmd_file_size(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc = 1;
char buf[32];
grub_file_t file;
(void)ctxt;
(void)argc;
(void)args;
if (argc != 2)
{
return rc;
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
if (file == NULL)
{
debug("failed to open file <%s> for udf check\n", args[0]);
return 1;
}
grub_snprintf(buf, sizeof(buf), "%llu", (unsigned long long)file->size);
grub_env_set(args[1], buf);
grub_file_close(file);
rc = 0;
return rc;
}
static grub_err_t ventoy_cmd_load_iso_to_mem(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc = 1;
char name[32];
char value[32];
char *buf = NULL;
grub_file_t file;
(void)ctxt;
(void)argc;
(void)args;
if (argc != 2)
{
return rc;
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
if (file == NULL)
{
debug("failed to open file <%s> for udf check\n", args[0]);
return 1;
}
#ifdef GRUB_MACHINE_EFI
buf = (char *)grub_efi_allocate_iso_buf(file->size);
#else
buf = (char *)grub_malloc(file->size);
#endif
grub_file_read(file, buf, file->size);
grub_snprintf(name, sizeof(name), "%s_addr", args[1]);
grub_snprintf(value, sizeof(value), "0x%llx", (unsigned long long)(unsigned long)buf);
grub_env_set(name, value);
grub_snprintf(name, sizeof(name), "%s_size", args[1]);
grub_snprintf(value, sizeof(value), "%llu", (unsigned long long)file->size);
grub_env_set(name, value);
grub_file_close(file);
rc = 0;
return rc;
}
static grub_err_t ventoy_cmd_is_udf(grub_extcmd_context_t ctxt, int argc, char **args) static grub_err_t ventoy_cmd_is_udf(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int i; int i;
@ -1107,6 +1188,8 @@ static cmd_para ventoy_cmds[] =
{ "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL }, { "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL },
{ "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL }, { "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL },
{ "vt_file_size", ventoy_cmd_file_size, 0, NULL, "", "", NULL },
{ "vt_load_iso_to_mem", ventoy_cmd_load_iso_to_mem, 0, NULL, "", "", NULL },
{ "vt_linux_parse_initrd_isolinux", ventoy_cmd_isolinux_initrd_collect, 0, NULL, "{cfgfile}", "", 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_parse_initrd_grub", ventoy_cmd_grub_initrd_collect, 0, NULL, "{cfgfile}", "", NULL },

Binary file not shown.

Binary file not shown.

@ -119,7 +119,7 @@ if [ "$MODE" = "install" ]; then
#Print disk info #Print disk info
echo "Disk : $DISK" echo "Disk : $DISK"
parted $DISK p 2>&1 | grep Model parted -s $DISK p 2>&1 | grep Model
echo "Size : $disk_size_gb GB" echo "Size : $disk_size_gb GB"
echo '' echo ''
@ -176,13 +176,17 @@ if [ "$MODE" = "install" ]; then
$cmd -n ventoy -s $cluster_sectors ${DISK}1 $cmd -n ventoy -s $cluster_sectors ${DISK}1
dd status=none if=./boot/boot.img of=$DISK bs=1 count=446 chmod +x ./tool/vtoy_gen_uuid
dd status=none if=./boot/boot.img of=$DISK bs=1 count=446
./tool/xzcat ./boot/core.img.xz | dd status=none of=$DISK bs=512 count=2047 seek=1 ./tool/xzcat ./boot/core.img.xz | dd status=none of=$DISK bs=512 count=2047 seek=1
./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector ./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
#disk uuid
chmod +x ./tool/vtoy_gen_uuid
./tool/vtoy_gen_uuid | dd status=none of=${DISK} seek=384 bs=1 count=16 ./tool/vtoy_gen_uuid | dd status=none of=${DISK} seek=384 bs=1 count=16
#disk signature
./tool/vtoy_gen_uuid | dd status=none of=${DISK} skip=12 seek=440 bs=1 count=4
sync sync
@ -216,7 +220,7 @@ else
PART2=$(get_disk_part_name $DISK 2) PART2=$(get_disk_part_name $DISK 2)
dd status=none if=./boot/boot.img of=$DISK bs=1 count=446 dd status=none if=./boot/boot.img of=$DISK bs=1 count=440
./tool/xzcat ./boot/core.img.xz | dd status=none of=$DISK bs=512 count=2047 seek=1 ./tool/xzcat ./boot/core.img.xz | dd status=none of=$DISK bs=512 count=2047 seek=1

@ -146,6 +146,9 @@ function uefi_iso_menu_func {
if [ -n "$vtisouefi" ]; then if [ -n "$vtisouefi" ]; then
set LoadIsoEfiDriver=on set LoadIsoEfiDriver=on
unset vtisouefi
elif [ -n "$VTOY_ISO_UEFI_DRV" ]; then
set LoadIsoEfiDriver=on
else else
unset LoadIsoEfiDriver unset LoadIsoEfiDriver
fi fi
@ -161,7 +164,14 @@ function uefi_iso_menu_func {
loopback loop ${1}${chosen_path} loopback loop ${1}${chosen_path}
get_os_type (loop) get_os_type (loop)
vt_check_compatible (loop) if [ -n "$vtcompat" ]; then
set ventoy_compatible=YES
unset vtcompat
elif [ -n "$VTOY_ISO_RAW" ]; then
set ventoy_compatible=YES
else
vt_check_compatible (loop)
fi
vt_img_sector ${1}${chosen_path} vt_img_sector ${1}${chosen_path}
@ -178,6 +188,21 @@ function uefi_iso_menu_func {
terminal_output gfxterm terminal_output gfxterm
} }
function uefi_iso_memdisk {
vt_chosen_img_path chosen_path
echo 'Loading ISO file to memory ...'
vt_load_iso_to_mem ${1}${chosen_path} vtoy_iso_buf
terminal_output console
chainloader ${vtoy_path}/ventoy_x64.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
boot
}
function legacy_windows_menu_func { function legacy_windows_menu_func {
vt_windows_reset vt_windows_reset
@ -280,7 +305,14 @@ function legacy_iso_menu_func {
get_os_type (loop) get_os_type (loop)
vt_check_compatible (loop) if [ -n "$vtcompat" ]; then
set ventoy_compatible=YES
unset vtcompat
elif [ -n "$VTOY_ISO_RAW" ]; then
set ventoy_compatible=YES
else
vt_check_compatible (loop)
fi
vt_img_sector ${1}${chosen_path} vt_img_sector ${1}${chosen_path}
@ -294,8 +326,14 @@ function legacy_iso_menu_func {
fi fi
} }
function legacy_iso_memdisk {
vt_chosen_img_path chosen_path
linux16 $vtoy_path/memdisk iso raw
echo "Loading ISO file to memory ..."
initrd16 ${1}${chosen_path}
boot
}
############################################################# #############################################################
@ -306,11 +344,15 @@ function legacy_iso_menu_func {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.02" set VENTOY_VERSION="1.0.04"
#disable timeout #disable timeout
unset timeout unset timeout
set VTOY_MEM_DISK_STR="MEMDISK"
set VTOY_ISO_RAW_STR="ISO RAW"
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
vt_device $root vtoy_dev vt_device $root vtoy_dev
if [ "$vtoy_dev" = "tftp" ]; then if [ "$vtoy_dev" = "tftp" ]; then
@ -357,9 +399,17 @@ if vt_cmp $ventoy_img_count ne 0; then
vt_img_name $imgid img_name vt_img_name $imgid img_name
menuentry "$img_name" { menuentry "$img_name" {
if [ "$grub_platform" = "pc" ]; then if [ "$grub_platform" = "pc" ]; then
legacy_iso_menu_func $iso_path if [ -n "$VTOY_MEM_DISK" ]; then
legacy_iso_memdisk $iso_path
else
legacy_iso_menu_func $iso_path
fi
else else
uefi_iso_menu_func $iso_path if [ -n "$VTOY_MEM_DISK" ]; then
uefi_iso_memdisk $iso_path
else
uefi_iso_menu_func $iso_path
fi
fi fi
} }

Binary file not shown.

@ -48,3 +48,31 @@ terminal-box: "terminal_box_*.png"
bar_style = "*" bar_style = "*"
highlight_style = "*" highlight_style = "*"
} }
+ hbox{
left = 90%
top = 5
width = 10%
height = 25
+ label {text = "@VTOY_MEM_DISK@" color = "red" align = "left"}
}
+ hbox{
left = 90%
top = 30
width = 10%
height = 25
+ label {text = "@VTOY_ISO_RAW@" color = "red" align = "left"}
}
+ hbox{
left = 90%
top = 55
width = 10%
height = 25
+ label {text = "@VTOY_ISO_UEFI_DRV@" color = "red" align = "left"}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -426,12 +426,22 @@ static int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT
int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR) int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
{ {
GUID Guid;
UINT32 DiskSignature;
UINT32 DiskSectorCount; UINT32 DiskSectorCount;
UINT32 PartSectorCount; UINT32 PartSectorCount;
UINT32 PartStartSector; UINT32 PartStartSector;
VentoyGetLocalBootImg(pMBR); VentoyGetLocalBootImg(pMBR);
CoCreateGuid(&Guid);
memcpy(&DiskSignature, &Guid, sizeof(UINT32));
Log("Disk signature: 0x%08x", DiskSignature);
*((UINT32 *)(pMBR->BootCode + 0x1B8)) = DiskSignature;
DiskSectorCount = (UINT32)(DiskSizeBytes / 512); DiskSectorCount = (UINT32)(DiskSizeBytes / 512);
//Part1 //Part1

@ -28,6 +28,7 @@
#include "vtoyjump.h" #include "vtoyjump.h"
#include "fat_filelib.h" #include "fat_filelib.h"
static UINT8 g_os_param_reserved[32];
static BOOL g_64bit_system = FALSE; static BOOL g_64bit_system = FALSE;
static ventoy_guid g_ventoy_guid = VENTOY_GUID; static ventoy_guid g_ventoy_guid = VENTOY_GUID;
@ -714,23 +715,26 @@ static int VentoyHook(ventoy_os_param *param)
while (Drives) while (Drives)
{ {
sprintf_s(IsoPath, sizeof(IsoPath), "%C:\\%s", Letter, param->vtoy_img_path); if (Drives & 0x01)
if (IsPathExist(FALSE, "%s", IsoPath)) {
{ sprintf_s(IsoPath, sizeof(IsoPath), "%C:\\%s", Letter, param->vtoy_img_path);
Log("File exist under %C:", Letter); if (IsPathExist(FALSE, "%s", IsoPath))
if (GetPhyDiskUUID(Letter, UUID, &DiskExtent) == 0) {
{ Log("File exist under %C:", Letter);
if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0) if (GetPhyDiskUUID(Letter, UUID, &DiskExtent) == 0)
{ {
Log("Disk UUID match"); if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0)
break; {
} Log("Disk UUID match");
} break;
} }
else }
{ }
Log("File NOT exist under %C:", Letter); else
} {
Log("File NOT exist under %C:", Letter);
}
}
Drives >>= 1; Drives >>= 1;
Letter++; Letter++;
@ -816,7 +820,9 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
Log("Find os pararm at %u", PeStart); Log("Find os pararm at %u", PeStart);
memcpy(&os_param, Buffer + PeStart, sizeof(ventoy_os_param)); memcpy(&os_param, Buffer + PeStart, sizeof(ventoy_os_param));
if (os_param.vtoy_reserved[0] == 1) memcpy(g_os_param_reserved, os_param.vtoy_reserved, sizeof(g_os_param_reserved));
if (g_os_param_reserved[0] == 1)
{ {
Log("break here for debug ....."); Log("break here for debug .....");
goto End; goto End;
@ -844,7 +850,7 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
goto End; goto End;
} }
if (os_param.vtoy_reserved[0] == 2) if (g_os_param_reserved[0] == 2)
{ {
Log("skip hook for debug ....."); Log("skip hook for debug .....");
rc = 0; rc = 0;
@ -865,6 +871,8 @@ End:
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i = 0;
int rc = 0;
CHAR *Pos = NULL; CHAR *Pos = NULL;
CHAR CurDir[MAX_PATH]; CHAR CurDir[MAX_PATH];
CHAR LunchFile[MAX_PATH]; CHAR LunchFile[MAX_PATH];
@ -904,20 +912,35 @@ int main(int argc, char **argv)
GetStartupInfoA(&Si); GetStartupInfoA(&Si);
memset(LunchFile, 0, sizeof(LunchFile)); for (i = 0; i < 10; i++)
if (VentoyJump(argc, argv, LunchFile) == 0)
{
Log("Ventoy jump success ...");
Si.dwFlags |= STARTF_USESHOWWINDOW;
Si.wShowWindow = SW_HIDE;
}
else
{ {
Log("Ventoy jump fail, now lunch cmd..."); Log("VentoyJump loop %d", i + 1);
sprintf_s(LunchFile, sizeof(LunchFile), "%s", "cmd.exe");
memset(LunchFile, 0, sizeof(LunchFile));
rc = VentoyJump(argc, argv, LunchFile);
if (g_os_param_reserved[0] == 3)
{
Log("Open log for debug ...");
sprintf_s(LunchFile, sizeof(LunchFile), "%s", "notepad.exe ventoy.log");
break;
}
else if (rc == 0)
{
Log("Ventoy jump success ...");
Si.dwFlags |= STARTF_USESHOWWINDOW;
Si.wShowWindow = SW_HIDE;
break;
}
else
{
Log("Ventoy jump fail, now wait ...");
sprintf_s(LunchFile, sizeof(LunchFile), "%s", "cmd.exe");
Sleep(3000);
}
} }
CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi); CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
WaitForSingleObject(Pi.hProcess, INFINITE); WaitForSingleObject(Pi.hProcess, INFINITE);
return 0; return 0;

Loading…
Cancel
Save